Skip to content

Commit be5e243

Browse files
test: add ts eval snapshots
1 parent 3f10557 commit be5e243

File tree

4 files changed

+77
-5
lines changed

4 files changed

+77
-5
lines changed

test/fixtures/eval/eval_messages.snapshot

-5
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@ with(this){__filename}
88
: ^^^^
99
`----
1010

11-
1211
Caused by:
1312
failed to parse
1413

1514
SyntaxError: Strict mode code may not include a with statement
1615

17-
18-
19-
20-
2116
Node.js *
2217
42
2318
42

test/fixtures/eval/eval_typescript.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
require('../../common');
4+
5+
const spawnSync = require('child_process').spawnSync;
6+
7+
const queue = [
8+
'enum Foo{};',
9+
'throw new SyntaxError("hello")',
10+
'const foo;',
11+
'let x: number = 100;x;',
12+
'const foo: string = 10;',
13+
'function foo(){};foo<Number>(1);',
14+
'interface Foo{};const foo;',
15+
'function foo(){ await Promise.resolve(1)};',
16+
];
17+
18+
for (const cmd of queue) {
19+
const args = ['--disable-warning=ExperimentalWarning', '-p', cmd];
20+
const result = spawnSync(process.execPath, args, {
21+
stdio: 'pipe'
22+
});
23+
process.stdout.write(result.stdout);
24+
process.stdout.write(result.stderr);
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[eval]:1
2+
enum Foo{};
3+
^^^^
4+
x TypeScript enum is not supported in strip-only mode
5+
,----
6+
1 | enum Foo{};
7+
: ^^^^^^^^^^
8+
`----
9+
10+
SyntaxError: Unexpected reserved word
11+
12+
Node.js *
13+
[eval]:1
14+
throw new SyntaxError("hello")
15+
^
16+
17+
SyntaxError: hello
18+
19+
Node.js *
20+
[eval]:1
21+
const foo;
22+
^^^
23+
24+
SyntaxError: Missing initializer in const declaration
25+
26+
Node.js *
27+
100
28+
undefined
29+
false
30+
[eval]:1
31+
;const foo;
32+
^^^
33+
34+
SyntaxError: Missing initializer in const declaration
35+
36+
Node.js *
37+
[eval]:1
38+
function foo(){ await Promise.resolve(1)};
39+
^^^^^
40+
x await isn't allowed in non-async function
41+
,----
42+
1 | function foo(){ await Promise.resolve(1)};
43+
: ^^^^^^^
44+
`----
45+
46+
Caused by:
47+
failed to parse
48+
49+
SyntaxError: await is only valid in async functions and the top level bodies of modules
50+
51+
Node.js *

test/parallel/test-node-output-eval.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ describe('eval output', { concurrency: true }, () => {
2929
const tests = [
3030
{ name: 'eval/eval_messages.js' },
3131
{ name: 'eval/stdin_messages.js' },
32+
{ name: 'eval/eval_typescript.js' },
3233
];
3334

3435
for (const { name } of tests) {

0 commit comments

Comments
 (0)