-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* arrow syntax fixed * quote added * Fix syntax error * fix imports and add arrow function test * bump version * Move MCI parser tests to new file * fix reference issues with parser * silence typescript whining * Add tests for parse in js-slang * Add Metacircular interpreter test within context
- Loading branch information
Showing
7 changed files
with
193 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Parse an arrow function 1`] = ` | ||
Array [ | ||
Object { | ||
"body": Object { | ||
"expression": Object { | ||
"line": 0, | ||
"operands": Array [ | ||
Object { | ||
"line": 0, | ||
"name": "x", | ||
"tag": "name", | ||
}, | ||
Array [ | ||
1, | ||
Array [], | ||
], | ||
], | ||
"operator": Object { | ||
"line": 0, | ||
"name": "+", | ||
"tag": "name", | ||
}, | ||
"tag": "application", | ||
}, | ||
"line": 0, | ||
"tag": "return_statement", | ||
}, | ||
"line": 0, | ||
"location": Object { | ||
"end_col": 0, | ||
"end_line": 1, | ||
"start_col": 0, | ||
"start_line": 1, | ||
}, | ||
"parameters": Array [ | ||
Object { | ||
"line": 0, | ||
"name": "x", | ||
"tag": "name", | ||
}, | ||
Array [], | ||
], | ||
"tag": "function_definition", | ||
}, | ||
Array [], | ||
] | ||
`; | ||
|
||
exports[`Parse arrow function assignment 1`] = ` | ||
Array [ | ||
Object { | ||
"line": 0, | ||
"name": "y", | ||
"tag": "constant_declaration", | ||
"value": Object { | ||
"body": Object { | ||
"expression": Object { | ||
"line": 0, | ||
"operands": Array [ | ||
Object { | ||
"line": 0, | ||
"name": "x", | ||
"tag": "name", | ||
}, | ||
Array [ | ||
1, | ||
Array [], | ||
], | ||
], | ||
"operator": Object { | ||
"line": 0, | ||
"name": "+", | ||
"tag": "name", | ||
}, | ||
"tag": "application", | ||
}, | ||
"line": 0, | ||
"tag": "return_statement", | ||
}, | ||
"line": 0, | ||
"location": Object { | ||
"end_col": 10, | ||
"end_line": 1, | ||
"start_col": 10, | ||
"start_line": 1, | ||
}, | ||
"parameters": Array [ | ||
Object { | ||
"line": 0, | ||
"name": "x", | ||
"tag": "name", | ||
}, | ||
Array [], | ||
], | ||
"tag": "function_definition", | ||
}, | ||
}, | ||
Array [], | ||
] | ||
`; |
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,18 @@ | ||
import { mockContext } from '../mocks/context' | ||
//@ts-ignore | ||
import { Parser } from '../stdlib/parser.js' | ||
|
||
const parser = new Parser(); | ||
|
||
test('Parse an arrow function', () => { | ||
const context = mockContext() | ||
const program = parser.parse('x => x + 1;', context) | ||
expect(program).toMatchSnapshot() | ||
}) | ||
|
||
test('Parse arrow function assignment', () => { | ||
const context = mockContext() | ||
const program = parser.parse('const y = x => x + 1;', context) | ||
expect(program).toMatchSnapshot() | ||
}) | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.