@@ -14189,22 +14189,22 @@ static njs_unit_test_t njs_test[] =
14189
14189
njs_str("true") },
14190
14190
14191
14191
{ njs_str("new Function('('.repeat(2**13));"),
14192
- njs_str("SyntaxError: Unexpected token \"}\" in runtime:1 ") },
14192
+ njs_str("SyntaxError: Unexpected token \"}\" in runtime") },
14193
14193
14194
14194
{ njs_str("new Function('{'.repeat(2**13));"),
14195
- njs_str("SyntaxError: Unexpected token \")\" in runtime:1 ") },
14195
+ njs_str("SyntaxError: Unexpected token \")\" in runtime") },
14196
14196
14197
14197
{ njs_str("new Function('['.repeat(2**13));"),
14198
- njs_str("SyntaxError: Unexpected token \"}\" in runtime:1 ") },
14198
+ njs_str("SyntaxError: Unexpected token \"}\" in runtime") },
14199
14199
14200
14200
{ njs_str("new Function('`'.repeat(2**13));"),
14201
14201
njs_str("[object Function]") },
14202
14202
14203
14203
{ njs_str("new Function('{['.repeat(2**13));"),
14204
- njs_str("SyntaxError: Unexpected token \"}\" in runtime:1 ") },
14204
+ njs_str("SyntaxError: Unexpected token \"}\" in runtime") },
14205
14205
14206
14206
{ njs_str("new Function('{;'.repeat(2**13));"),
14207
- njs_str("SyntaxError: Unexpected token \")\" in runtime:1 ") },
14207
+ njs_str("SyntaxError: Unexpected token \")\" in runtime") },
14208
14208
14209
14209
{ njs_str("(new Function('1;'.repeat(2**13) + 'return 2'))()"),
14210
14210
njs_str("2") },
@@ -14216,7 +14216,7 @@ static njs_unit_test_t njs_test[] =
14216
14216
njs_str("-4") },
14217
14217
14218
14218
{ njs_str("new Function('new '.repeat(2**13));"),
14219
- njs_str("SyntaxError: Unexpected token \"}\" in runtime:1 ") },
14219
+ njs_str("SyntaxError: Unexpected token \"}\" in runtime") },
14220
14220
14221
14221
{ njs_str("(new Function('return ' + 'typeof '.repeat(2**13) + 'x'))()"),
14222
14222
njs_str("string") },
@@ -14282,7 +14282,13 @@ static njs_unit_test_t njs_test[] =
14282
14282
njs_str("ReferenceError: \"foo\" is not defined") },
14283
14283
14284
14284
{ njs_str("this.NN = {}; var f = Function('eval = 42;'); f()"),
14285
- njs_str("SyntaxError: Identifier \"eval\" is forbidden as left-hand in assignment in runtime:1") },
14285
+ njs_str("SyntaxError: Identifier \"eval\" is forbidden as left-hand in assignment in runtime") },
14286
+
14287
+ { njs_str("new Function('}); let a; a; function o(){}; //')"),
14288
+ njs_str("SyntaxError: Unexpected token \"}\" in runtime") },
14289
+
14290
+ { njs_str("new Function('}); let a; a; function o(){}; ({')"),
14291
+ njs_str("SyntaxError: single function literal required") },
14286
14292
14287
14293
{ njs_str("RegExp()"),
14288
14294
njs_str("/(?:)/") },
@@ -19811,7 +19817,7 @@ static njs_unit_test_t njs_test[] =
19811
19817
njs_str("[object AsyncFunction]") },
19812
19818
19813
19819
{ njs_str("let f = new Function('x', 'await 1; return x'); f(1)"),
19814
- njs_str("SyntaxError: await is only valid in async functions in runtime:1 ") },
19820
+ njs_str("SyntaxError: await is only valid in async functions in runtime") },
19815
19821
19816
19822
{ njs_str("new AsyncFunction()"),
19817
19823
njs_str("ReferenceError: \"AsyncFunction\" is not defined") },
@@ -21676,7 +21682,9 @@ njs_process_test(njs_external_state_t *state, njs_opts_t *opts,
21676
21682
return NJS_ERROR;
21677
21683
}
21678
21684
21679
- success = njs_strstr_eq(&expected->ret, &s);
21685
+ success = expected->ret.length <= s.length
21686
+ && (memcmp(expected->ret.start, s.start, expected->ret.length)
21687
+ == 0);
21680
21688
if (!success) {
21681
21689
njs_stderror("njs(\"%V\")\nexpected: \"%V\"\n got: \"%V\"\n",
21682
21690
&expected->script, &expected->ret, &s);
0 commit comments