Skip to content

Commit ffe7c01

Browse files
committed
Fix test failures
1 parent 4f45e8a commit ffe7c01

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

lib/Runtime/Library/EngineInterfaceObject.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,16 @@ namespace Js
270270
/* static */
271271
ScriptFunction *EngineInterfaceObject::CreateLibraryCodeScriptFunction(ScriptFunction *scriptFunction, JavascriptString *displayName, bool isConstructor, bool isJsBuiltIn, bool isPublic)
272272
{
273+
if (scriptFunction->GetFunctionProxy()->IsPublicLibraryCode())
274+
{
275+
// this can happen when we re-initialize Intl for a different mode -- for instance, if we have the following JS:
276+
// print((1).toLocaleString())
277+
// print(new Intl.NumberFormat().format(1))
278+
// Intl will first get initialized for Number, and then will get re-initialized for all of Intl. This will cause
279+
// Number.prototype.toLocaleString to be registered twice, which breaks some of our assertions below.
280+
return scriptFunction;
281+
}
282+
273283
ScriptContext *scriptContext = scriptFunction->GetScriptContext();
274284

275285
if (!isConstructor)

test/es6/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var tests = [
2424
assert.throws(function () { eval("function f(a, b, a, c = 10) { }"); }, SyntaxError, "Duplicate parameters are not allowed before the default argument", "Duplicate formal parameter names not allowed in this context");
2525
assert.throws(function () { eval("function f(a, b = 10, a) { }"); }, SyntaxError, "Duplicate parameters are not allolwed after the default argument", "Duplicate formal parameter names not allowed in this context");
2626
assert.throws(function () { eval("function f(a, b, a, c) { \"use strict\"; }"); }, SyntaxError, "When function is in strict mode duplicate parameters are not allowed for simple parameter list", "Duplicate formal parameter names not allowed in strict mode");
27-
assert.throws(function () { eval("function f(a, b = 1) { \"use strict\"; }"); }, SyntaxError, "Strict mode cannot be applied to functions with default parameters", "Cannot apply strict mode on functions with non-simple parameter list");
27+
assert.throws(function () { eval("function f(a, b = 1) { \"use strict\"; }"); }, SyntaxError, "Strict mode cannot be applied to functions with default parameters", "Illegal 'use strict' directive in function with non-simple parameter list");
2828
assert.throws(function () { eval("function f() { \"use strict\"; function g(a, b, a) { } }"); }, SyntaxError, "When a function is already in strict mode duplicate parameters are not allowed for simple parameter list", "Duplicate formal parameter names not allowed in strict mode");
2929
assert.throws(function () { eval("function f() { \"use strict\"; function g(a, b, a = 10) { } }"); }, SyntaxError, "When a function is already in strict mode duplicate parameters are not allowed for formal parameter list", "Duplicate formal parameter names not allowed in strict mode");
3030

test/es6/rest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ var tests = [
1414
assert.throws(function () { eval("var obj = class { method(a, b = 1, ...c = [2,3]) {} };")}, SyntaxError, "Rest parameter cannot have a default value");
1515
assert.throws(function () { eval("function f(c, a, ...a) { }")}, SyntaxError, "Duplicate parameters are not allowed for non-simple parameter list with only rest", "Duplicate formal parameter names not allowed in this context");
1616
assert.throws(function () { eval("function f(c = 10, a, ...a) { }")}, SyntaxError, "Duplicate parameters are not allowed for non-simple parameter list with both rest and default", "Duplicate formal parameter names not allowed in this context");
17-
assert.throws(function () { eval("function f(...a) { 'use strict'; }"); }, SyntaxError, "Strict mode cannot be applied to functions with rest parameter", "Cannot apply strict mode on functions with non-simple parameter list");
18-
assert.throws(function () { eval("function f(a, ...b) { 'use strict'; }"); }, SyntaxError, "Strict mode cannot be applied to functions with rest parameter", "Cannot apply strict mode on functions with non-simple parameter list");
17+
assert.throws(function () { eval("function f(...a) { 'use strict'; }"); }, SyntaxError, "Strict mode cannot be applied to functions with rest parameter", "Illegal 'use strict' directive in function with non-simple parameter list");
18+
assert.throws(function () { eval("function f(a, ...b) { 'use strict'; }"); }, SyntaxError, "Strict mode cannot be applied to functions with rest parameter", "Illegal 'use strict' directive in function with non-simple parameter list");
1919
assert.throws(function () { eval("function f() { \"use strict\"; function g(a, b, c, ...a) { } }")}, SyntaxError, "Cannot have duplicate parameters for a function with non-simple parameter list, which is already in strict mode", "Duplicate formal parameter names not allowed in strict mode");
2020
assert.throws(function () { eval("function f() { \"use strict\"; function g(a, b, a, ...c) { } }")}, SyntaxError, "Cannot have duplicate parameters for a function with non-simple parameter list with rest, which is already in strict mode", "Duplicate formal parameter names not allowed in strict mode");
2121

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
SyntaxError: Cannot apply strict mode on functions with non-simple parameter list
1+
SyntaxError: Illegal 'use strict' directive in function with non-simple parameter list
22
at code (nonSimpleParameterList.js:8:30)

0 commit comments

Comments
 (0)