Skip to content

Commit 835ca63

Browse files
Trottevanlucas
authored andcommitted
test: make test-repl engine agnostic
Remove reliance on V8-specific error messages in test-repl. Test should pass whether V8 is the engine, or V8 changes error message strings, or ChakraCore is the engine, or some other valid JavaScript engine is used in the future. PR-URL: #16272 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent f8337ce commit 835ca63

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

‎test/parallel/test-repl.js‎

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function clean_up() {
7272
functionstrict_mode_error_test(){
7373
send_expect([
7474
{client: client_unix,send: 'ref = 1',
75-
expect: /^ReferenceError:\sref\sis\snot\sdefined\nnodeviaUnixsocket>$/},
75+
expect: /^ReferenceError:\s/},
7676
]);
7777
}
7878

@@ -143,7 +143,7 @@ function error_test() {
143143
expect: prompt_unix},
144144
// But passing the same string to eval() should throw
145145
{client: client_unix,send: 'eval("function test_func() {")',
146-
expect: /^SyntaxError:Unexpectedendofinput/},
146+
expect: /^SyntaxError:/},
147147
// Can handle multiline template literals
148148
{client: client_unix,send: '`io.js',
149149
expect: prompt_multiline},
@@ -172,51 +172,48 @@ function error_test() {
172172
// invalid input to JSON.parse error is special case of syntax error,
173173
// should throw
174174
{client: client_unix,send: 'JSON.parse(\'{invalid: \\\'json\\\'}\');',
175-
expect: /^SyntaxError:Unexpectedtokeni/},
175+
expect: /^SyntaxError:/},
176176
// end of input to JSON.parse error is special case of syntax error,
177177
// should throw
178178
{client: client_unix,send: 'JSON.parse(\'066\');',
179-
expect: /^SyntaxError:Unexpectednumber/},
179+
expect: /^SyntaxError:/},
180180
// should throw
181181
{client: client_unix,send: 'JSON.parse(\'{\');',
182-
expect: /^SyntaxError:UnexpectedendofJSONinput/},
182+
expect: /^SyntaxError:/},
183183
// invalid RegExps are a special case of syntax error,
184184
// should throw
185185
{client: client_unix,send: '/(/;',
186-
expect: /^SyntaxError:Invalidregularexpression:/},
186+
expect: /^SyntaxError:/},
187187
// invalid RegExp modifiers are a special case of syntax error,
188188
// should throw (GH-4012)
189189
{client: client_unix,send: 'new RegExp("foo", "wrong modifier");',
190-
expect: /^SyntaxError:InvalidflagssuppliedtoRegExpconstructor/},
190+
expect: /^SyntaxError:/},
191191
// strict mode syntax errors should be caught (GH-5178)
192192
{client: client_unix,
193193
send: '(function() { "use strict"; return 0755; })()',
194-
expect: /\bSyntaxError:Octalliteralsarenotallowedinstrictmode/},
194+
expect: /\bSyntaxError:/},
195195
{
196196
client: client_unix,
197197
send: '(function(a, a, b) { "use strict"; return a + b + c; })()',
198-
expect:
199-
/\bSyntaxError:Duplicateparameternamenotallowedinthiscontext/
198+
expect: /\bSyntaxError:/
200199
},
201200
{
202201
client: client_unix,
203202
send: '(function() { "use strict"; with (this) {} })()',
204-
expect: /\bSyntaxError:Strictmodecodemaynotincludeawithstatement/
203+
expect: /\bSyntaxError:/
205204
},
206205
{
207206
client: client_unix,
208207
send: '(function() { "use strict"; var x; delete x; })()',
209-
expect:
210-
/\bSyntaxError:Deleteofanunqualifiedidentifierinstrictmode/
208+
expect: /\bSyntaxError:/
211209
},
212210
{client: client_unix,
213211
send: '(function() { "use strict"; eval = 17; })()',
214-
expect: /\bSyntaxError:Unexpectedevalorargumentsinstrictmode/},
212+
expect: /\bSyntaxError:/},
215213
{
216214
client: client_unix,
217215
send: '(function() { "use strict"; if (true) function f() { } })()',
218-
expect:
219-
/\bSyntaxError:Instrictmodecode,functionscanonlybedeclaredattoplevelorinsideablock\./
216+
expect: /\bSyntaxError:/
220217
},
221218
// Named functions can be used:
222219
{client: client_unix,send: 'function blah() { return 1; }',
@@ -268,7 +265,7 @@ function error_test() {
268265
expect: `Invalid REPL keyword\n${prompt_unix}`},
269266
// fail when we are not inside a String and a line continuation is used
270267
{client: client_unix,send: '[] \\',
271-
expect: /\bSyntaxError:Invalidorunexpectedtoken/},
268+
expect: /\bSyntaxError:/},
272269
// do not fail when a String is created with line continuation
273270
{client: client_unix,send: '\'the\\\nfourth\\\neye\'',
274271
expect: `${prompt_multiline}${prompt_multiline}'thefourtheye'\n${

0 commit comments

Comments
 (0)