-
Notifications
You must be signed in to change notification settings - Fork 858
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow updating of
name
of a function, as required by the standard (#…
…1398) Make the attributes of the "name" properties of functions match current ECMAScript specs. See #1297 for more details
- Loading branch information
1 parent
1457790
commit 05ab4ff
Showing
5 changed files
with
53 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
testsrc/org/mozilla/javascript/tests/es6/Issue1297FunctionNameTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.javascript.tests.es6; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
import org.mozilla.javascript.Scriptable; | ||
import org.mozilla.javascript.tests.Utils; | ||
|
||
/** Test that we can redefine a function's name. */ | ||
public class Issue1297FunctionNameTest { | ||
private static final String source = | ||
"'use strict';" | ||
+ "function X() {};\n" | ||
+ "Object.defineProperty(X, 'name', {value: 'y', configurable: true, writable: true});" | ||
+ "X.name"; | ||
|
||
@Test | ||
public void canSetFunctionName() { | ||
Utils.runWithAllOptimizationLevels( | ||
cx -> { | ||
Scriptable scope = cx.initStandardObjects(null); | ||
Object result = cx.evaluateString(scope, source, "test", 1, null); | ||
assertEquals("y", result); | ||
return null; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters