Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
test: add ts eval snapshots
  • Loading branch information
marco-ippolito committed Dec 30, 2024
commit 0c6a364e4fce8059bc4da8bae7c403b19ed279ba
5 changes: 0 additions & 5 deletions test/fixtures/eval/eval_messages.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions test/fixtures/eval/eval_typescript.js
Original file line number Diff line number Diff line change
@@ -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)};',
Comment thread
marco-ippolito marked this conversation as resolved.
];

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);
}
51 changes: 51 additions & 0 deletions test/fixtures/eval/eval_typescript.snapshot
Original file line number Diff line number Diff line change
@@ -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 *
1 change: 0 additions & 1 deletion test/fixtures/eval/stdin_messages.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ with(this){__filename}
: ^^^^
`----


Caused by:
failed to parse

Expand Down
88 changes: 0 additions & 88 deletions test/fixtures/eval/stdin_typescript.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,8 @@ enum Foo{};
: ^^^^^^^^^^
`----


SyntaxError: Unexpected reserved word









Node.js *
[stdin]:1
enum Foo{};
Expand All @@ -28,81 +19,36 @@ enum Foo{};
: ^^^^^^^^^^
`----


SyntaxError: Unexpected reserved word









Node.js *
[stdin]:1
throw new SyntaxError("hello")
^

SyntaxError: hello











Node.js *
[stdin]:1
throw new SyntaxError("hello")
^

SyntaxError: hello











Node.js *
[stdin]:1
const foo;
^^^

SyntaxError: Missing initializer in const declaration









Node.js *
[stdin]:1
const foo;
^^^

SyntaxError: Missing initializer in const declaration









Node.js *
100
100
Expand All @@ -116,29 +62,13 @@ false

SyntaxError: Missing initializer in const declaration









Node.js *
[stdin]:1
;const foo;
^^^

SyntaxError: Missing initializer in const declaration









Node.js *
[stdin]:1
function foo(){ await Promise.resolve(1)};
Expand All @@ -149,20 +79,11 @@ 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)};
Expand All @@ -173,19 +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 *
done
7 changes: 4 additions & 3 deletions test/parallel/test-node-output-eval.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down