Skip to content

Commit

Permalink
improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
uzmoi committed Oct 17, 2024
1 parent 01e17fe commit 3dbea45
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ describe('callstack', () => {
@function2() { function1() }
function2()
`);
expect(result).toMatch(/at function1.+at function2/s);
expect(result).toMatchInlineSnapshot(`
"emitError
at function1 (Line 2, Column 28)
at function2 (Line 3, Column 28)
at <root> (Line 4, Column 13)"
`);
});
test('error in function in namespace', async () => {
const result = await exeAndGetErrMessage(`
Expand All @@ -142,12 +147,20 @@ describe('callstack', () => {
}
Ai:function()
`);
expect(result).toContain("at Ai:function");
expect(result).toMatchInlineSnapshot(`
"emitError
at Ai:function (Line 3, Column 28)
at <root> (Line 5, Column 15)"
`);
});
test('error in anonymous function', async () => {
const result = await exeAndGetErrMessage(`
(@() { emitError() })()
`);
expect(result).toContain('at <anonymous>');
expect(result).toMatchInlineSnapshot(`
"emitError
at <anonymous> (Line 2, Column 20)
at <root> (Line 2, Column 25)"
`);
});
});

0 comments on commit 3dbea45

Please sign in to comment.