Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove interpreter #1543

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions src/__tests__/__snapshots__/display.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -106,27 +106,6 @@ Object {
}
`;

exports[`display can be used to display objects: expectDisplayResult 1`] = `
Object {
"alertResult": Array [],
"code": "display({a: 1, b: 2, c: {d: 3}});",
"displayResult": Array [
"{\\"a\\": 1, \\"b\\": 2, \\"c\\": {\\"d\\": 3}}",
],
"numErrors": 0,
"parsedErrors": "",
"result": Object {
"a": 1,
"b": 2,
"c": Object {
"d": 3,
},
},
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`display second argument can be a string: expectDisplayResult 1`] = `
Object {
"alertResult": Array [],
Expand Down
135 changes: 7 additions & 128 deletions src/__tests__/__snapshots__/index.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@ a[1];",
}
`;

exports[`Accessing object with nonexistent property returns undefined: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "const o = {};
o.nonexistent;",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": undefined,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Allow display to return value it is displaying: expectResult 1`] = `
Object {
"alertResult": Array [],
Expand Down Expand Up @@ -181,23 +167,6 @@ test();",
}
`;

exports[`Deep object assignment and retrieval: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "const o = {};
o.a = {};
o.a.b = {};
o.a.b.c = \\"string\\";
o.a.b.c;",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": "string",
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Empty code returns undefined: expectResult 1`] = `
Object {
"alertResult": Array [],
Expand Down Expand Up @@ -579,55 +548,6 @@ identity(t) === t && t(1, 2, 3) === 6;",
}
`;

exports[`Multiline string self-evaluates to itself: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "\`1
1\`;",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": "1
1",
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Objects toString matches up with JS: expect to match JS 1`] = `
Object {
"alertResult": Array [],
"code": "toString({a: 1});",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": "[object Object]",
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Rest parameters work: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "function rest(a, b, ...c) {
let sum = a + b;
for (let i = 0; i < array_length(c); i = i + 1) {
sum = sum + c[i];
}
return sum;
}
rest(1, 2); // no error
rest(1, 2, ...[3, 4, 5], ...[6, 7], ...[]);",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 28,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Simple arrow function infinite recursion represents CallExpression well: expectParsedErrorNoErrorSnapshot 1`] = `
Object {
"alertResult": Array [],
Expand All @@ -649,11 +569,11 @@ Object {
"displayResult": Array [],
"numErrors": 1,
"parsedErrors": "Line 1: Maximum call stack size exceeded
x(function f(x) {
x(x => {
return x(x)(x);
}).. x(function f(x) {
}).. x(x => {
return x(x)(x);
}).. x(function f(x) {
}).. x(x => {
return x(x)(x);
})..",
"result": undefined,
Expand All @@ -662,21 +582,6 @@ Object {
}
`;

exports[`Simple object assignment and retrieval: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "const o = {};
o.a = 1;
o.a;",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 1,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Single boolean self-evaluates to itself: expectResult 1`] = `
Object {
"alertResult": Array [],
Expand Down Expand Up @@ -723,7 +628,8 @@ Object {
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 60,
"result": "native:60
interpreted:undefined",
"resultStatus": "finished",
"visualiseListResult": Array [],
}
Expand Down Expand Up @@ -786,32 +692,6 @@ Object {
}
`;

exports[`Test equal for different lists: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "!equal(list(1, 2), pair(1, 2)) && !equal(list(1, 2, 3), list(1, list(2, 3)));",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": true,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Test equal for lists: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "equal(list(1, 2), pair(1, pair(2, null))) && equal(list(1, 2, 3, 4), list(1, 2, 3, 4));",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": true,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Test equal for primitives: expectResult 1`] = `
Object {
"alertResult": Array [],
Expand Down Expand Up @@ -866,9 +746,8 @@ toString(a=>a) + toString(f);",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": "a => afunction f(x) {
return 5;
}",
"result": "native:\\"a => afunction f(x) {\\\\n return 5;\\\\n}\\"
interpreted:\\"a => ax => {\\\\n return 5;\\\\n}\\"",
"resultStatus": "finished",
"visualiseListResult": Array [],
}
Expand Down
39 changes: 0 additions & 39 deletions src/__tests__/__snapshots__/lazy.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,6 @@ res;",
}
`;

exports[`Tail calls work: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "function test(a, b) {
return a === 1 ? a : b;
}

function test2(a) {
return test(a, head(null));
}

const res = test2(1);
res;",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 1,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Thunks are memoized: expectResult 1`] = `
Object {
"alertResult": Array [],
Expand Down Expand Up @@ -119,20 +97,3 @@ res;",
"visualiseListResult": Array [],
}
`;

exports[`Unused arguments are not evaluated: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "function test(a, b, c, d, e, f) {
return a;
}
const res = test(1, head(null), 1 + '', !1, '' - 1, head(head(null)));
res;",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 1,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;
3 changes: 2 additions & 1 deletion src/__tests__/__snapshots__/scmlib.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,8 @@ Object {
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 1,
"result": "native:1
interpreted:undefined",
"resultStatus": "finished",
"visualiseListResult": Array [],
}
Expand Down
52 changes: 0 additions & 52 deletions src/__tests__/__snapshots__/stdlib.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -408,32 +408,6 @@ Object {
}
`;

exports[`Builtins work as expected 31: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "is_object({});",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": true,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Builtins work as expected 32: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "is_object({a: 1});",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": true,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Builtins work as expected 33: expectResult 1`] = `
Object {
"alertResult": Array [],
Expand Down Expand Up @@ -551,32 +525,6 @@ Object {
}
`;

exports[`Builtins work as expected 42: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "has_own_property({a: 1, b: 2}, 'a');",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": true,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Builtins work as expected 43: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "has_own_property({a: 1, b: 2}, 'c');",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": false,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Builtins work as expected 44: expectResult 1`] = `
Object {
"alertResult": Array [],
Expand Down
Loading
Loading