improve testing compatibility with Node.js (#5204)

This commit is contained in:
Alex Lam S.L
2021-12-06 14:42:45 +00:00
committed by GitHub
parent 033d8d9405
commit d2e7c4af20
9 changed files with 58 additions and 55 deletions

View File

@@ -4,7 +4,7 @@ arithmetic: {
} }
expect_exact: "console.log((1n+0x2n)*(0o3n- -4n)>>5n-6n);" expect_exact: "console.log((1n+0x2n)*(0o3n- -4n)>>5n-6n);"
expect_stdout: "42n" expect_stdout: "42n"
node_version: ">=10" node_version: ">=10.4.0"
} }
minus_dot: { minus_dot: {
@@ -13,7 +13,7 @@ minus_dot: {
} }
expect_exact: "console.log(typeof-42n.toString(),typeof(-42n).toString());" expect_exact: "console.log(typeof-42n.toString(),typeof(-42n).toString());"
expect_stdout: "number string" expect_stdout: "number string"
node_version: ">=10" node_version: ">=10.4.0"
} }
evaluate: { evaluate: {
@@ -28,7 +28,7 @@ evaluate: {
console.log(0xdeadbeefn.toString(16)); console.log(0xdeadbeefn.toString(16));
} }
expect_stdout: "deadbeef" expect_stdout: "deadbeef"
node_version: ">=10" node_version: ">=10.4.0"
} }
Number: { Number: {
@@ -42,7 +42,7 @@ Number: {
console.log(+("" + -0xfeed_dead_beef_badn)); console.log(+("" + -0xfeed_dead_beef_badn));
} }
expect_stdout: "-1148098955808013200" expect_stdout: "-1148098955808013200"
node_version: ">=10" node_version: ">=10.4.0"
} }
issue_4590: { issue_4590: {
@@ -58,7 +58,7 @@ issue_4590: {
0n || console.log("PASS"); 0n || console.log("PASS");
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=10" node_version: ">=10.4.0"
} }
issue_4801: { issue_4801: {
@@ -88,5 +88,5 @@ issue_4801: {
} }
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=10" node_version: ">=10.4.0"
} }

View File

@@ -1037,7 +1037,7 @@ mangle_arrow_1: {
}); });
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=6" node_version: ">=6.9.3"
} }
mangle_arrow_1_toplevel: { mangle_arrow_1_toplevel: {
@@ -1073,7 +1073,7 @@ mangle_arrow_1_toplevel: {
}); });
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=6" node_version: ">=6.9.3"
} }
mangle_arrow_2: { mangle_arrow_2: {
@@ -1109,7 +1109,7 @@ mangle_arrow_2: {
}); });
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=6" node_version: ">=6.9.3"
} }
mangle_arrow_2_toplevel: { mangle_arrow_2_toplevel: {
@@ -1145,7 +1145,7 @@ mangle_arrow_2_toplevel: {
}); });
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=6" node_version: ">=6.9.3"
} }
issue_4444: { issue_4444: {
@@ -1587,7 +1587,7 @@ issue_4510_2: {
}; };
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8.3.0"
} }
issue_4523: { issue_4523: {

View File

@@ -220,7 +220,7 @@ funarg_side_effects_2: {
} }
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=6" node_version: ">=6.9.2"
} }
funarg_side_effects_3: { funarg_side_effects_3: {
@@ -254,7 +254,7 @@ funarg_side_effects_3: {
} }
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=6" node_version: ">=6.9.2"
} }
funarg_unused_1: { funarg_unused_1: {

View File

@@ -62,7 +62,7 @@ assignment_2: {
} }
expect_exact: "var a=8n;a**=a;console.log(a);" expect_exact: "var a=8n;a**=a;console.log(a);"
expect_stdout: "16777216n" expect_stdout: "16777216n"
node_version: ">=10" node_version: ">=10.4.0"
} }
evaluate: { evaluate: {

View File

@@ -51,7 +51,7 @@ arrow_destructured_object_1: {
} }
expect_exact: "var f=({...a})=>a,o=f({PASS:42});for(var k in o)console.log(k,o[k]);" expect_exact: "var f=({...a})=>a,o=f({PASS:42});for(var k in o)console.log(k,o[k]);"
expect_stdout: "PASS 42" expect_stdout: "PASS 42"
node_version: ">=8" node_version: ">=8.3.0"
} }
arrow_destructured_object_2: { arrow_destructured_object_2: {
@@ -62,7 +62,7 @@ arrow_destructured_object_2: {
} }
expect_exact: "var f=({FAIL:a,...b})=>b,o=f({PASS:42,FAIL:null});for(var k in o)console.log(k,o[k]);" expect_exact: "var f=({FAIL:a,...b})=>b,o=f({PASS:42,FAIL:null});for(var k in o)console.log(k,o[k]);"
expect_stdout: "PASS 42" expect_stdout: "PASS 42"
node_version: ">=8" node_version: ">=8.3.0"
} }
arrow_destructured_object_3: { arrow_destructured_object_3: {
@@ -79,7 +79,7 @@ arrow_destructured_object_3: {
"2 S", "2 S",
"3 S", "3 S",
] ]
node_version: ">=8" node_version: ">=8.3.0"
} }
funarg_1: { funarg_1: {
@@ -131,7 +131,7 @@ destructured_object_1: {
} }
expect_exact: 'var{...a}=["FAIL","PASS",42];console.log(a[1],a[2]);' expect_exact: 'var{...a}=["FAIL","PASS",42];console.log(a[1],a[2]);'
expect_stdout: "PASS 42" expect_stdout: "PASS 42"
node_version: ">=8" node_version: ">=8.3.0"
} }
destructured_object_2: { destructured_object_2: {
@@ -141,7 +141,7 @@ destructured_object_2: {
} }
expect_exact: 'var{0:a,...b}=["FAIL","PASS",42];console.log(b[1],b[2]);' expect_exact: 'var{0:a,...b}=["FAIL","PASS",42];console.log(b[1],b[2]);'
expect_stdout: "PASS 42" expect_stdout: "PASS 42"
node_version: ">=8" node_version: ">=8.3.0"
} }
drop_fargs: { drop_fargs: {
@@ -231,7 +231,7 @@ reduce_destructured_object: {
console.log(a[0]); console.log(a[0]);
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8.3.0"
} }
retain_destructured_array: { retain_destructured_array: {
@@ -270,7 +270,7 @@ retain_destructured_object_1: {
"1 PASS", "1 PASS",
"2 42", "2 42",
] ]
node_version: ">=8" node_version: ">=8.3.0"
} }
retain_destructured_object_2: { retain_destructured_object_2: {
@@ -292,7 +292,7 @@ retain_destructured_object_2: {
"bar PASS", "bar PASS",
"baz 42", "baz 42",
] ]
node_version: ">=8" node_version: ">=8.3.0"
} }
retain_funarg_destructured_array_1: { retain_funarg_destructured_array_1: {
@@ -344,7 +344,7 @@ retain_funarg_destructured_object_1: {
console.log((({ ...a }) => a)([ "PASS" ])[0]); console.log((({ ...a }) => a)([ "PASS" ])[0]);
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8.3.0"
} }
retain_funarg_destructured_object_2: { retain_funarg_destructured_object_2: {
@@ -362,7 +362,7 @@ retain_funarg_destructured_object_2: {
}({ p: "FAIL" }).p || "PASS"); }({ p: "FAIL" }).p || "PASS");
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8.3.0"
} }
drop_unused_call_args_1: { drop_unused_call_args_1: {
@@ -482,7 +482,7 @@ merge_funarg_destructured_object: {
})([ "PASS" ]); })([ "PASS" ]);
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8.3.0"
} }
keep_arguments: { keep_arguments: {
@@ -992,7 +992,7 @@ issue_5089_1: {
console.log(o.p); console.log(o.p);
} }
expect_stdout: "undefined" expect_stdout: "undefined"
node_version: ">=8" node_version: ">=8.3.0"
} }
issue_5089_2: { issue_5089_2: {
@@ -1019,7 +1019,7 @@ issue_5089_2: {
console.log(o.p); console.log(o.p);
} }
expect_stdout: "undefined" expect_stdout: "undefined"
node_version: ">=8" node_version: ">=8.3.0"
} }
issue_5100_1: { issue_5100_1: {
@@ -1054,7 +1054,7 @@ issue_5100_1: {
console.log(a.r); console.log(a.r);
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8.3.0"
} }
issue_5100_2: { issue_5100_2: {
@@ -1085,7 +1085,7 @@ issue_5100_2: {
} ][0]); } ][0]);
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=10" node_version: ">=10.22.0"
} }
issue_5108: { issue_5108: {

View File

@@ -341,7 +341,7 @@ convert_setter: {
console.log(k, o[k]); console.log(k, o[k]);
} }
expect_stdout: "PASS undefined" expect_stdout: "PASS undefined"
node_version: ">=8" node_version: ">=8.3.0"
} }
keep_getter_1: { keep_getter_1: {
@@ -370,7 +370,7 @@ keep_getter_1: {
}); });
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8.3.0"
} }
keep_getter_2: { keep_getter_2: {
@@ -399,7 +399,7 @@ keep_getter_2: {
"foo", "foo",
"bar", "bar",
] ]
node_version: ">=8" node_version: ">=8.3.0"
} }
keep_getter_3: { keep_getter_3: {
@@ -429,7 +429,7 @@ keep_getter_3: {
}); });
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8.3.0"
} }
keep_getter_4: { keep_getter_4: {
@@ -460,7 +460,7 @@ keep_getter_4: {
}); });
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8.3.0"
} }
keep_accessor: { keep_accessor: {
@@ -508,7 +508,7 @@ keep_accessor: {
"q undefined", "q undefined",
"r null", "r null",
] ]
node_version: ">=8" node_version: ">=8.3.0"
} }
object_key_order_1: { object_key_order_1: {
@@ -538,7 +538,7 @@ object_key_order_1: {
"a 3", "a 3",
"b 2", "b 2",
] ]
node_version: ">=8 <=10" node_version: ">=8.3.0 <=10"
} }
object_key_order_2: { object_key_order_2: {
@@ -568,7 +568,7 @@ object_key_order_2: {
"a 3", "a 3",
"b 2", "b 2",
] ]
node_version: ">=8" node_version: ">=8.3.0"
} }
object_key_order_3: { object_key_order_3: {
@@ -598,7 +598,7 @@ object_key_order_3: {
"a 3", "a 3",
"b 2", "b 2",
] ]
node_version: ">=8" node_version: ">=8.3.0"
} }
object_key_order_4: { object_key_order_4: {
@@ -628,7 +628,7 @@ object_key_order_4: {
"a 3", "a 3",
"b 2", "b 2",
] ]
node_version: ">=8" node_version: ">=8.3.0"
} }
object_spread_array: { object_spread_array: {
@@ -654,7 +654,7 @@ object_spread_array: {
"0 foo", "0 foo",
"1 bar", "1 bar",
] ]
node_version: ">=8" node_version: ">=8.3.0"
} }
object_spread_string: { object_spread_string: {
@@ -681,7 +681,7 @@ object_spread_string: {
"1 o", "1 o",
"2 o", "2 o",
] ]
node_version: ">=8" node_version: ">=8.3.0"
} }
unused_var_side_effects: { unused_var_side_effects: {
@@ -711,7 +711,7 @@ unused_var_side_effects: {
}); });
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8.3.0"
} }
unsafe_join_1: { unsafe_join_1: {
@@ -793,7 +793,7 @@ issue_4329: {
}[0]); }[0]);
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8.3.0"
} }
issue_4331: { issue_4331: {
@@ -871,7 +871,7 @@ issue_4345: {
}[42]); }[42]);
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8.3.0"
} }
issue_4361: { issue_4361: {
@@ -901,7 +901,7 @@ issue_4361: {
"foo", "foo",
"undefined", "undefined",
] ]
node_version: ">=8" node_version: ">=8.3.0"
} }
issue_4363: { issue_4363: {
@@ -922,7 +922,7 @@ issue_4363: {
}); });
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=8" node_version: ">=8.3.0"
} }
issue_4556: { issue_4556: {
@@ -994,7 +994,7 @@ issue_4849: {
}())); }()));
} }
expect_stdout: "object" expect_stdout: "object"
node_version: ">=8" node_version: ">=8.3.0"
} }
issue_4882_1: { issue_4882_1: {
@@ -1026,7 +1026,7 @@ issue_4882_1: {
"PASS", "PASS",
"undefined", "undefined",
] ]
node_version: ">=8" node_version: ">=8.3.0"
} }
issue_4882_2: { issue_4882_2: {
@@ -1052,7 +1052,7 @@ issue_4882_2: {
"42", "42",
"PASS", "PASS",
] ]
node_version: ">=8" node_version: ">=8.3.0"
} }
issue_4882_3: { issue_4882_3: {
@@ -1082,7 +1082,7 @@ issue_4882_3: {
"PASS", "PASS",
"42", "42",
] ]
node_version: ">=8" node_version: ">=8.3.0"
} }
issue_5006: { issue_5006: {

View File

@@ -337,7 +337,7 @@ malformed_evaluate_4: {
console.log("\\u00b5"); console.log("\\u00b5");
} }
expect_stdout: "\\u00b5" expect_stdout: "\\u00b5"
node_version: ">=8" node_version: ">=8.10.0"
} }
unsafe_evaluate: { unsafe_evaluate: {
@@ -353,7 +353,7 @@ unsafe_evaluate: {
console.log("\\uFo"); console.log("\\uFo");
} }
expect_stdout: "\\uFo" expect_stdout: "\\uFo"
node_version: ">=8" node_version: ">=8.10.0"
} }
side_effects_1: { side_effects_1: {

View File

@@ -970,7 +970,7 @@ issue_4639_1: {
}().next().value()); }().next().value());
} }
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=4" node_version: ">=4 <7 || >=8.7.0"
} }
issue_4639_2: { issue_4639_2: {

View File

@@ -253,7 +253,10 @@ function run_code_vm(code, toplevel, timeout) {
// for Node.js v6 // for Node.js v6
vm.runInContext(setup_code, ctx); vm.runInContext(setup_code, ctx);
vm.runInContext(toplevel ? "(function(){" + code + "})();" : code, ctx, { timeout: timeout }); vm.runInContext(toplevel ? "(function(){" + code + "})();" : code, ctx, { timeout: timeout });
return strip_color_codes(stdout); // for Node.js v4
return strip_color_codes(stdout.replace(/\b(Array \[|Object {)/g, function(match) {
return match.slice(-1);
}));
} catch (ex) { } catch (ex) {
return ex; return ex;
} finally { } finally {
@@ -292,7 +295,7 @@ function run_code_exec(code, toplevel, timeout) {
} catch (e) {} } catch (e) {}
} }
var match = /\n([^:\s]*Error)(?:: ([\s\S]+?))?\n( at [\s\S]+)\n$/.exec(msg); var match = /\n([^:\s]*Error)(?:: ([\s\S]+?))?\n( at [\s\S]+)\n$/.exec(msg);
if (!match) return details; if (!match) return details || new Error(msg);
var ex = new global[match[1]](match[2]); var ex = new global[match[1]](match[2]);
ex.stack = ex.stack.slice(0, ex.stack.indexOf(" at ")) + match[3]; ex.stack = ex.stack.slice(0, ex.stack.indexOf(" at ")) + match[3];
if (typeof details == "object") { if (typeof details == "object") {