mirror of https://github.com/nodejs/node.git
test: add ts eval snapshots
PR-URL: https://github.com/nodejs/node/pull/56358 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Jacob Smith <jacob@frende.me>pull/56414/head
parent
eca22a4aa9
commit
b3f82febf1
|
@ -8,16 +8,11 @@ with(this){__filename}
|
|||
: ^^^^
|
||||
`----
|
||||
|
||||
|
||||
Caused by:
|
||||
failed to parse
|
||||
|
||||
SyntaxError: Strict mode code may not include a with statement
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Node.js *
|
||||
42
|
||||
42
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
'use strict';
|
||||
|
||||
require('../../common');
|
||||
|
||||
const spawnSync = require('child_process').spawnSync;
|
||||
|
||||
const queue = [
|
||||
'enum Foo{};',
|
||||
'throw new SyntaxError("hello")',
|
||||
'const foo;',
|
||||
'let x: number = 100;x;',
|
||||
'const foo: string = 10;',
|
||||
'function foo(){};foo<Number>(1);',
|
||||
'interface Foo{};const foo;',
|
||||
'function foo(){ await Promise.resolve(1)};',
|
||||
];
|
||||
|
||||
for (const cmd of queue) {
|
||||
const args = ['--disable-warning=ExperimentalWarning', '-p', cmd];
|
||||
const result = spawnSync(process.execPath, args, {
|
||||
stdio: 'pipe'
|
||||
});
|
||||
process.stdout.write(result.stdout);
|
||||
process.stdout.write(result.stderr);
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
[eval]:1
|
||||
enum Foo{};
|
||||
^^^^
|
||||
x TypeScript enum is not supported in strip-only mode
|
||||
,----
|
||||
1 | enum Foo{};
|
||||
: ^^^^^^^^^^
|
||||
`----
|
||||
|
||||
SyntaxError: Unexpected reserved word
|
||||
|
||||
Node.js *
|
||||
[eval]:1
|
||||
throw new SyntaxError("hello")
|
||||
^
|
||||
|
||||
SyntaxError: hello
|
||||
|
||||
Node.js *
|
||||
[eval]:1
|
||||
const foo;
|
||||
^^^
|
||||
|
||||
SyntaxError: Missing initializer in const declaration
|
||||
|
||||
Node.js *
|
||||
100
|
||||
undefined
|
||||
false
|
||||
[eval]:1
|
||||
;const foo;
|
||||
^^^
|
||||
|
||||
SyntaxError: Missing initializer in const declaration
|
||||
|
||||
Node.js *
|
||||
[eval]:1
|
||||
function foo(){ await Promise.resolve(1)};
|
||||
^^^^^
|
||||
x await isn't allowed in non-async function
|
||||
,----
|
||||
1 | function foo(){ await Promise.resolve(1)};
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
Caused by:
|
||||
failed to parse
|
||||
|
||||
SyntaxError: await is only valid in async functions and the top level bodies of modules
|
||||
|
||||
Node.js *
|
|
@ -8,7 +8,6 @@ with(this){__filename}
|
|||
: ^^^^
|
||||
`----
|
||||
|
||||
|
||||
Caused by:
|
||||
failed to parse
|
||||
|
||||
|
|
|
@ -7,17 +7,8 @@ enum Foo{};
|
|||
: ^^^^^^^^^^
|
||||
`----
|
||||
|
||||
|
||||
SyntaxError: Unexpected reserved word
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Node.js *
|
||||
[stdin]:1
|
||||
enum Foo{};
|
||||
|
@ -28,16 +19,14 @@ enum Foo{};
|
|||
: ^^^^^^^^^^
|
||||
`----
|
||||
|
||||
|
||||
SyntaxError: Unexpected reserved word
|
||||
|
||||
Node.js *
|
||||
[stdin]:1
|
||||
throw new SyntaxError("hello")
|
||||
^
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SyntaxError: hello
|
||||
|
||||
Node.js *
|
||||
[stdin]:1
|
||||
|
@ -46,33 +35,6 @@ throw new SyntaxError("hello")
|
|||
|
||||
SyntaxError: hello
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Node.js *
|
||||
[stdin]:1
|
||||
throw new SyntaxError("hello")
|
||||
^
|
||||
|
||||
SyntaxError: hello
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Node.js *
|
||||
[stdin]:1
|
||||
const foo;
|
||||
|
@ -80,14 +42,6 @@ const foo;
|
|||
|
||||
SyntaxError: Missing initializer in const declaration
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Node.js *
|
||||
[stdin]:1
|
||||
const foo;
|
||||
|
@ -95,14 +49,6 @@ const foo;
|
|||
|
||||
SyntaxError: Missing initializer in const declaration
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Node.js *
|
||||
100
|
||||
100
|
||||
|
@ -116,14 +62,6 @@ false
|
|||
|
||||
SyntaxError: Missing initializer in const declaration
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Node.js *
|
||||
[stdin]:1
|
||||
;const foo;
|
||||
|
@ -131,13 +69,20 @@ Node.js *
|
|||
|
||||
SyntaxError: Missing initializer in const declaration
|
||||
|
||||
Node.js *
|
||||
[stdin]:1
|
||||
function foo(){ await Promise.resolve(1)};
|
||||
^^^^^
|
||||
x await isn't allowed in non-async function
|
||||
,----
|
||||
1 | function foo(){ await Promise.resolve(1)};
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
Caused by:
|
||||
failed to parse
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SyntaxError: await is only valid in async functions and the top level bodies of modules
|
||||
|
||||
Node.js *
|
||||
[stdin]:1
|
||||
|
@ -149,43 +94,10 @@ function foo(){ await Promise.resolve(1)};
|
|||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
|
||||
Caused by:
|
||||
failed to parse
|
||||
|
||||
SyntaxError: await is only valid in async functions and the top level bodies of modules
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Node.js *
|
||||
[stdin]:1
|
||||
function foo(){ await Promise.resolve(1)};
|
||||
^^^^^
|
||||
x await isn't allowed in non-async function
|
||||
,----
|
||||
1 | function foo(){ await Promise.resolve(1)};
|
||||
: ^^^^^^^
|
||||
`----
|
||||
|
||||
|
||||
Caused by:
|
||||
failed to parse
|
||||
|
||||
SyntaxError: await is only valid in async functions and the top level bodies of modules
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Node.js *
|
||||
done
|
||||
|
|
|
@ -10,12 +10,12 @@ describe('eval output', { concurrency: true }, () => {
|
|||
}
|
||||
|
||||
const defaultTransform = snapshot.transform(
|
||||
removeStackTraces,
|
||||
filterEmptyLines,
|
||||
normalize,
|
||||
snapshot.replaceWindowsLineEndings,
|
||||
snapshot.replaceWindowsPaths,
|
||||
snapshot.replaceNodeVersion
|
||||
snapshot.replaceNodeVersion,
|
||||
removeStackTraces,
|
||||
filterEmptyLines,
|
||||
);
|
||||
|
||||
function removeStackTraces(output) {
|
||||
|
@ -30,6 +30,7 @@ describe('eval output', { concurrency: true }, () => {
|
|||
{ name: 'eval/eval_messages.js' },
|
||||
{ name: 'eval/stdin_messages.js' },
|
||||
{ name: 'eval/stdin_typescript.js' },
|
||||
{ name: 'eval/eval_typescript.js' },
|
||||
];
|
||||
|
||||
for (const { name } of tests) {
|
||||
|
|
Loading…
Reference in New Issue