Skip to content

Commit 4bc9540

Browse files
test: migrate messages v8 tests from Python to JS
Migrated messages v8 tests from Python to JavaScript. This change is part of an effort to enhance maintainability and consistency in the test suite. All relevant test files and dependencies have been updated accordingly. Refs: nodejs#47707
1 parent fbf1fb3 commit 4bc9540

17 files changed

+195
-171
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
require('../../common');
4+
const assert = require('assert').strict;
5+
6+
assert.throws(
7+
() => {
8+
throw new Error('foo');
9+
},
10+
{ bar: true }
11+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
node:assert:*
2+
throw err;
3+
^
4+
5+
AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
6+
+ actual - expected
7+
8+
+ Comparison {}
9+
- Comparison {
10+
- bar: true
11+
- }
12+
at Object.<anonymous> (*assert_throws_stack.js:*:*)
13+
at Module._compile (node:internal*modules*cjs*loader:*:*)
14+
at Module._extensions..js (node:internal*modules*cjs*loader:*:*)
15+
at Module.load (node:internal*modules*cjs*loader:*:*)
16+
at Module._load (node:internal*modules*cjs*loader:*:*)
17+
at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:*:*)
18+
at node:internal*main*run_main_module:*:* {
19+
generatedMessage: true,
20+
code: 'ERR_ASSERTION',
21+
actual: Error: foo
22+
at assert.throws.bar (*assert_throws_stack.js:*:*)
23+
at getActual (node:assert:*:*)
24+
at Function.throws (node:assert:*:*)
25+
at Object.<anonymous> (*assert_throws_stack.js:*:*)
26+
at Module._compile (node:internal*modules*cjs*loader:*:*)
27+
at Module._extensions..js (node:internal*modules*cjs*loader:*:*)
28+
at Module.load (node:internal*modules*cjs*loader:*:*)
29+
at Module._load (node:internal*modules*cjs*loader:*:*)
30+
at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:*:*)
31+
at node:internal*main*run_main_module:*:*,
32+
expected: { bar: true },
33+
operator: 'throws'
34+
}
35+
36+
Node.js *
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
22

3-
require('../common');
3+
require('../../common');
44

55
console.assert(false, Symbol('hello'));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
node:internal*console*constructor:*
2+
args[0] = `Assertion failed${args.length === 0 ? '' : `: ${args[0]}`}`;
3+
^
4+
5+
TypeError: Cannot convert a Symbol value to a string
6+
at console.assert (node:internal*console*constructor:*:*)
7+
at Object.<anonymous> (*console_assert.js:*:*)
8+
at Module._compile (node:internal*modules*cjs*loader:*:*)
9+
at Module._extensions..js (node:internal*modules*cjs*loader:*:*)
10+
at Module.load (node:internal*modules*cjs*loader:*:*)
11+
at Module._load (node:internal*modules*cjs*loader:*:*)
12+
at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:*:*)
13+
at node:internal*main*run_main_module:*:*
14+
15+
Node.js *

test/message/eval_messages.js test/fixtures/errors/eval_messages.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
'use strict';
2323

24-
require('../common');
24+
require('../../common');
2525

2626
const spawn = require('child_process').spawn;
2727

@@ -35,17 +35,18 @@ function run(cmd, strict, cb) {
3535
child.on('close', cb);
3636
}
3737

38-
const queue =
39-
[ 'with(this){__filename}',
40-
'42',
41-
'throw new Error("hello")',
42-
'var x = 100; y = x;',
43-
'var ______________________________________________; throw 10' ];
38+
const queue = [
39+
'with(this){__filename}',
40+
'42',
41+
'throw new Error("hello")',
42+
'var x = 100; y = x;',
43+
'var ______________________________________________; throw 10',
44+
];
4445

4546
function go() {
4647
const c = queue.shift();
4748
if (!c) return console.log('done');
48-
run(c, false, function() {
49+
run(c, false, function () {
4950
run(c, true, go);
5051
});
5152
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
[eval]
2+
[eval]:*
3+
with(this){__filename}
4+
^^^^
5+
6+
SyntaxError: Strict mode code may not include a with statement
7+
at makeContextifyScript (node:internal*vm:*:*)
8+
at node:internal*process*execution:*:*
9+
at [eval]-wrapper:*:*
10+
at runScript (node:internal*process*execution:*:*)
11+
at evalScript (node:internal*process*execution:*:*)
12+
at node:internal*main*eval_string:*:*
13+
14+
Node.js *
15+
42
16+
42
17+
[eval]:*
18+
throw new Error("hello")
19+
^
20+
21+
Error: hello
22+
at [eval]:*:*
23+
at runScriptInThisContext (node:internal*vm:*:*)
24+
at node:internal*process*execution:*:*
25+
at [eval]-wrapper:*:*
26+
at runScript (node:internal*process*execution:*:*)
27+
at evalScript (node:internal*process*execution:*:*)
28+
at node:internal*main*eval_string:*:*
29+
30+
Node.js *
31+
[eval]:*
32+
throw new Error("hello")
33+
^
34+
35+
Error: hello
36+
at [eval]:*:*
37+
at runScriptInThisContext (node:internal*vm:*:*)
38+
at node:internal*process*execution:*:*
39+
at [eval]-wrapper:*:*
40+
at runScript (node:internal*process*execution:*:*)
41+
at evalScript (node:internal*process*execution:*:*)
42+
at node:internal*main*eval_string:*:*
43+
44+
Node.js *
45+
100
46+
[eval]:*
47+
var x = 100; y = x;
48+
^
49+
50+
ReferenceError: y is not defined
51+
at [eval]:*:*
52+
at runScriptInThisContext (node:internal*vm:*:*)
53+
at node:internal*process*execution:*:*
54+
at [eval]-wrapper:*:*
55+
at runScript (node:internal*process*execution:*:*)
56+
at evalScript (node:internal*process*execution:*:*)
57+
at node:internal*main*eval_string:*:*
58+
59+
Node.js *
60+
61+
[eval]:*
62+
var ______________________________________________; throw 10
63+
^
64+
10
65+
(Use `node --trace-uncaught ...` to show where the exception was thrown)
66+
67+
Node.js *
68+
69+
[eval]:*
70+
var ______________________________________________; throw 10
71+
^
72+
10
73+
(Use `node --trace-uncaught ...` to show where the exception was thrown)
74+
75+
Node.js *
76+
done
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
// Flags: --expose-internals
4-
require('../common');
4+
require('../../common');
55

66
const assert = require('internal/assert');
77
assert(false);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
node:internal*assert:*
2+
throw new ERR_INTERNAL_ASSERTION(message);
3+
^
4+
5+
Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
6+
Please open an issue with this stack trace at https:*github.com*nodejs*node*issues
7+
8+
at assert (node:internal*assert:*:*)
9+
at Object.<anonymous> (*internal_assert.js:*:*)
10+
at Module._compile (node:internal*modules*cjs*loader:*:*)
11+
at Module._extensions..js (node:internal*modules*cjs*loader:*:*)
12+
at Module.load (node:internal*modules*cjs*loader:*:*)
13+
at Module._load (node:internal*modules*cjs*loader:*:*)
14+
at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:*:*)
15+
at node:internal*main*run_main_module:*:* {
16+
code: 'ERR_INTERNAL_ASSERTION'
17+
}
18+
19+
Node.js *
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
// Flags: --expose-internals
4-
require('../common');
4+
require('../../common');
55

66
const assert = require('internal/assert');
77
assert.fail('Unreachable!');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
node:internal*assert:*
2+
throw new ERR_INTERNAL_ASSERTION(message);
3+
^
4+
5+
Error [ERR_INTERNAL_ASSERTION]: Unreachable!
6+
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
7+
Please open an issue with this stack trace at https:*github.com*nodejs*node*issues
8+
9+
at Function.fail (node:internal*assert:*:*)
10+
at Object.<anonymous> (*internal_assert_fail.js:*:*)
11+
at Module._compile (node:internal*modules*cjs*loader:*:*)
12+
at Module._extensions..js (node:internal*modules*cjs*loader:*:*)
13+
at Module.load (node:internal*modules*cjs*loader:*:*)
14+
at Module._load (node:internal*modules*cjs*loader:*:*)
15+
at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:*:*)
16+
at node:internal*main*run_main_module:*:* {
17+
code: 'ERR_INTERNAL_ASSERTION'
18+
}
19+
20+
Node.js *

test/message/assert_throws_stack.js

-6
This file was deleted.

test/message/assert_throws_stack.out

-36
This file was deleted.

test/message/console_assert.out

-1
This file was deleted.

test/message/eval_messages.out

-77
This file was deleted.

test/message/internal_assert.out

-19
This file was deleted.

0 commit comments

Comments
 (0)