Skip to content

Commit

Permalink
Merge commit 'd6553ca7499a0bb16593a9402c2cef724ba7fbc0' into import-c…
Browse files Browse the repository at this point in the history
…hecker

# Conflicts:
#	src/index.ts
#	src/transpiler/transpiler.ts
  • Loading branch information
leeyi45 committed Feb 1, 2024
2 parents 6864a5c + d6553ca commit f9e207d
Show file tree
Hide file tree
Showing 22 changed files with 471 additions and 380 deletions.
42 changes: 21 additions & 21 deletions src/__tests__/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ xtest('debugger; statement basic test', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
})
})
Expand All @@ -53,7 +53,7 @@ xtest('debugger; statement in function', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
})
})
Expand Down Expand Up @@ -110,7 +110,7 @@ xtest('debugger; statement test function scope', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
})
})
Expand All @@ -136,7 +136,7 @@ xtest('debugger; statement hoisting', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
})
})
Expand All @@ -160,7 +160,7 @@ xtest('debugger; pauses for', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
})
})
Expand All @@ -185,7 +185,7 @@ xtest('debugger; pauses while', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
})
})
Expand Down Expand Up @@ -216,7 +216,7 @@ xtest('setBreakpointAtLine basic', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
})
})
Expand All @@ -241,7 +241,7 @@ xtest('setBreakpointAtLine function 1', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
})
})
Expand All @@ -266,7 +266,7 @@ xtest('setBreakpointAtLine function 2', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
})
})
Expand Down Expand Up @@ -318,7 +318,7 @@ xtest('setBreakpointAtLine function 4', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
})
})
Expand Down Expand Up @@ -349,12 +349,12 @@ xtest('setBreakpointAtLine granularity 1', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
return (resume(obj1) as Promise<Result>).then(obj2 => {
return (resume(obj2) as Promise<Result>).then(obj3 => {
expect(flattenEnvironments(obj3)).toMatchSnapshot()
expect(obj3.status).toBe('suspended-ec-eval')
expect(obj3.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
})
})
Expand Down Expand Up @@ -384,7 +384,7 @@ xtest('setBreakpointAtLine granularity 2', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
return (resume(obj1) as Promise<Result>).then(obj2 => {
expect(flattenEnvironments(obj2)).toMatchSnapshot()
Expand Down Expand Up @@ -418,11 +418,11 @@ xtest('setBreakpointAtLine granularity 3', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
return (resume(obj1) as Promise<Result>).then(obj2 => {
expect(flattenEnvironments(obj2)).toMatchSnapshot()
expect(obj2.status).toBe('suspended-ec-eval')
expect(obj2.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
return (resume(obj2) as Promise<Result>).then(obj3 => {
expect(flattenEnvironments(obj3)).toMatchSnapshot()
Expand Down Expand Up @@ -454,19 +454,19 @@ xtest('setBreakpointAtLine for loops', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
return (resume(obj1) as Promise<Result>).then(obj2 => {
expect(flattenEnvironments(obj2)).toMatchSnapshot()
expect(obj2.status).toBe('suspended-ec-eval')
expect(obj2.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
return (resume(obj2) as Promise<Result>).then(obj3 => {
expect(flattenEnvironments(obj3)).toMatchSnapshot()
expect(obj3.status).toBe('suspended-ec-eval')
expect(obj3.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
return (resume(obj3) as Promise<Result>).then(obj4 => {
expect(flattenEnvironments(obj4)).toMatchSnapshot()
expect(obj4.status).toBe('suspended-ec-eval')
expect(obj4.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
return (resume(obj4) as Promise<Result>).then(obj5 => {
expect(flattenEnvironments(obj5)).toMatchSnapshot()
Expand Down Expand Up @@ -501,11 +501,11 @@ xtest('setBreakpointAtLine while loops', () => {
id: expect.any(String)
})
})
expect(obj1.status).toBe('suspended-ec-eval')
expect(obj1.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
return (resume(obj1) as Promise<Result>).then(obj2 => {
expect(flattenEnvironments(obj2)).toMatchSnapshot()
expect(obj2.status).toBe('suspended-ec-eval')
expect(obj2.status).toBe('suspended-cse-eval')
expect(parseError(context.errors)).toMatchSnapshot()
return (resume(obj2) as Promise<Result>).then(obj5 => {
expect(flattenEnvironments(obj5)).toMatchSnapshot()
Expand Down
2 changes: 1 addition & 1 deletion src/createContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const createEmptyRuntime = () => ({
environments: [],
value: undefined,
nodes: [],
agenda: null,
control: null,
stash: null,
envSteps: -1,
envStepsTotal: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1029,3 +1029,21 @@ Object {
"visualiseListResult": Array [],
}
`;
exports[`Undefined variables are caught even when unreached: expectParsedError 1`] = `
Object {
"alertResult": Array [],
"code": "const a = 1;
if (false) {
im_undefined;
} else {
a;
}",
"displayResult": Array [],
"numErrors": 1,
"parsedErrors": "Line 3: Name im_undefined not declared.",
"result": undefined,
"resultStatus": "error",
"visualiseListResult": Array [],
}
`;
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Array literals are unpacked in the correct order: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "let d = 0;
let c = [ d = d * 10 + 1, d = d * 10 + 2, d = d * 10 + 3];
d;",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": 123,
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Array literals work as expected: expectResult 1`] = `
Object {
"alertResult": Array [],
"code": "let c = [1, 2, 3];
c;",
"displayResult": Array [],
"numErrors": 0,
"parsedErrors": "",
"result": Array [
1,
2,
3,
],
"resultStatus": "finished",
"visualiseListResult": Array [],
}
`;

exports[`Conditional statements are value producing always: expectResult 1`] = `
Object {
"alertResult": Array [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ test('Undefined variable error is thrown - verbose', () => {
`)
})

const undefinedUnreachedVariable = stripIndent`
const a = 1;
if (false) {
im_undefined;
} else {
a;
}
`

test('Undefined variables are caught even when unreached', () => {
return expectParsedError(undefinedUnreachedVariable, optionEC).toMatchInlineSnapshot(
`"Line 3: Name im_undefined not declared."`
)
})

test('Undefined variable error message differs from verbose version', () => {
return expectDifferentParsedErrors(undefinedVariable, undefinedVariableVerbose, optionEC).toBe(
undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,3 +407,30 @@ test('Nullary functions properly restore environment 2', () => {
optionEC3
).toMatchInlineSnapshot(`1`)
})

test('Array literals work as expected', () => {
return expectResult(
stripIndent`
let c = [1, 2, 3];
c;
`,
optionEC3
).toMatchInlineSnapshot(`
Array [
1,
2,
3,
]
`)
})

test('Array literals are unpacked in the correct order', () => {
return expectResult(
stripIndent`
let d = 0;
let c = [ d = d * 10 + 1, d = d * 10 + 2, d = d * 10 + 3];
d;
`,
optionEC3
).toMatchInlineSnapshot(`123`)
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Utility functions for creating the various agenda instructions.
* Utility functions for creating the various control instructions.
*/

import * as es from 'estree'
Expand Down
Loading

0 comments on commit f9e207d

Please sign in to comment.