-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unused heap objects, improve test coverage
- Loading branch information
1 parent
724d509
commit 9d60129
Showing
10 changed files
with
116 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { parse } from '../../parser/go'; | ||
import { ECE } from '../ece'; | ||
|
||
function evaluateSequence(sequence) { | ||
const program = ` | ||
package main | ||
import "fmt" | ||
func main() { | ||
${sequence} | ||
} | ||
` | ||
const parsed_program = parse(program); | ||
const heapSize = 32768; | ||
const return_value = (new ECE(heapSize, parsed_program)).evaluate(true).output; | ||
const check_mark_and_sweep = (new ECE(heapSize, parsed_program)).evaluate(true, true).output; | ||
expect(return_value).toBe(check_mark_and_sweep); | ||
return return_value; | ||
} | ||
|
||
describe("Support boolean types", () => { | ||
it('can create a boolean', () => { | ||
const sequence = ` | ||
var b bool | ||
b = true | ||
fmt.Println(b) | ||
` | ||
const result = evaluateSequence(sequence); | ||
expect(result).toBe("true\n"); | ||
}) | ||
|
||
it('can perform boolean operations', () => { | ||
const sequence = ` | ||
var b bool | ||
b = true | ||
fmt.Println(!b) | ||
c := b && true | ||
fmt.Println(c) | ||
d := b || false | ||
fmt.Println(d) | ||
` | ||
const result = evaluateSequence(sequence); | ||
expect(result).toBe("false\ntrue\ntrue\n"); | ||
}) | ||
}) | ||
|
||
describe("Support string types", () => { | ||
it('can create a string', () => { | ||
const sequence = ` | ||
var s string | ||
s = "hello" | ||
fmt.Println(s) | ||
` | ||
const result = evaluateSequence(sequence); | ||
expect(result).toBe("hello\n"); | ||
}) | ||
|
||
it('can perform string operations', () => { | ||
const sequence = ` | ||
var s string | ||
s = "hello" | ||
fmt.Println(s + " world") | ||
t := s + " world" | ||
fmt.Println(t) | ||
` | ||
const result = evaluateSequence(sequence); | ||
expect(result).toBe("hello world\nhello world\n"); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.