-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
3,135 additions
and
61 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
84 changes: 84 additions & 0 deletions
84
src/cse-machine/__tests__/__snapshots__/cset-machine-apply.ts.snap
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,84 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`eval of strings: expectResult 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(eval \\"hello\\") | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 0, | ||
"parsedErrors": "", | ||
"result": "hello", | ||
"resultStatus": "finished", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
|
||
exports[`incorrect use of apply throws error (insufficient arguments): expectParsedError 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(apply) | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 1, | ||
"parsedErrors": "Expected 2 arguments, but got 0.", | ||
"result": undefined, | ||
"resultStatus": "error", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
|
||
exports[`incorrect use of apply throws error (last argument not a list): expectParsedError 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(apply + 1 2 3) | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 1, | ||
"parsedErrors": "Error: Last argument of apply must be a list", | ||
"result": undefined, | ||
"resultStatus": "error", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
|
||
exports[`multi-operand apply: expectResult 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(define args '(1 2 3 4 5)) | ||
(apply + 6 7 8 9 10 args) | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 0, | ||
"parsedErrors": "", | ||
"result": SchemeInteger { | ||
"numberType": 1, | ||
"value": 55n, | ||
}, | ||
"resultStatus": "finished", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
|
||
exports[`two-operand apply: expectResult 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(define args '(1 2)) | ||
(apply + args) | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 0, | ||
"parsedErrors": "", | ||
"result": SchemeInteger { | ||
"numberType": 1, | ||
"value": 3n, | ||
}, | ||
"resultStatus": "finished", | ||
"visualiseListResult": Array [], | ||
} | ||
`; |
224 changes: 224 additions & 0 deletions
224
src/cse-machine/__tests__/__snapshots__/cset-machine-eval.ts.snap
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,224 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`eval of application: expectResult 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(eval '(+ 1 2)) | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 0, | ||
"parsedErrors": "", | ||
"result": SchemeInteger { | ||
"numberType": 1, | ||
"value": 3n, | ||
}, | ||
"resultStatus": "finished", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
|
||
exports[`eval of begin: expectResult 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(eval '(begin 1 2 3)) | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 0, | ||
"parsedErrors": "", | ||
"result": SchemeInteger { | ||
"numberType": 1, | ||
"value": 3n, | ||
}, | ||
"resultStatus": "finished", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
|
||
exports[`eval of booleans: expectResult 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(eval #t) | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 0, | ||
"parsedErrors": "", | ||
"result": true, | ||
"resultStatus": "finished", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
|
||
exports[`eval of define: expectResult 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(eval '(define x 1)) | ||
x | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 0, | ||
"parsedErrors": "", | ||
"result": SchemeInteger { | ||
"numberType": 1, | ||
"value": 1n, | ||
}, | ||
"resultStatus": "finished", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
|
||
exports[`eval of empty list: expectParsedError 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(eval '()) | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 1, | ||
"parsedErrors": "Error: Cannot evaluate null", | ||
"result": undefined, | ||
"resultStatus": "error", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
|
||
exports[`eval of if: expectResult 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(eval '(if #t 1 2)) | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 0, | ||
"parsedErrors": "", | ||
"result": SchemeInteger { | ||
"numberType": 1, | ||
"value": 1n, | ||
}, | ||
"resultStatus": "finished", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
|
||
exports[`eval of lambda: expectResult 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(eval '(lambda (x) x)) | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 0, | ||
"parsedErrors": "", | ||
"result": [Function], | ||
"resultStatus": "finished", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
|
||
exports[`eval of numbers: expectResult 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(eval 1) | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 0, | ||
"parsedErrors": "", | ||
"result": SchemeInteger { | ||
"numberType": 1, | ||
"value": 1n, | ||
}, | ||
"resultStatus": "finished", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
|
||
exports[`eval of quote: expectResult 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(eval '(quote (1 2 3))) | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 0, | ||
"parsedErrors": "", | ||
"result": Array [ | ||
SchemeInteger { | ||
"numberType": 1, | ||
"value": 1n, | ||
}, | ||
Array [ | ||
SchemeInteger { | ||
"numberType": 1, | ||
"value": 2n, | ||
}, | ||
Array [ | ||
SchemeInteger { | ||
"numberType": 1, | ||
"value": 3n, | ||
}, | ||
null, | ||
], | ||
], | ||
], | ||
"resultStatus": "finished", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
|
||
exports[`eval of set!: expectResult 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(define x 2) | ||
(eval '(set! x 1)) | ||
x | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 0, | ||
"parsedErrors": "", | ||
"result": SchemeInteger { | ||
"numberType": 1, | ||
"value": 1n, | ||
}, | ||
"resultStatus": "finished", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
exports[`eval of strings: expectResult 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(eval \\"hello\\") | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 0, | ||
"parsedErrors": "", | ||
"result": "hello", | ||
"resultStatus": "finished", | ||
"visualiseListResult": Array [], | ||
} | ||
`; | ||
exports[`eval of symbols: expectResult 1`] = ` | ||
Object { | ||
"alertResult": Array [], | ||
"code": " | ||
(define hello 1) | ||
(eval 'hello) | ||
", | ||
"displayResult": Array [], | ||
"numErrors": 0, | ||
"parsedErrors": "", | ||
"result": SchemeInteger { | ||
"numberType": 1, | ||
"value": 1n, | ||
}, | ||
"resultStatus": "finished", | ||
"visualiseListResult": Array [], | ||
} | ||
`; |
Oops, something went wrong.