summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/Function/function-name-property.js
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-19 15:47:10 +0100
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-19 15:47:10 +0100
commit5ef44cf6484b9dfd49c0174ac2969a29587a1bbd (patch)
treeef1e8a83106f6b54504dbe3b29554ef7b349a1bb /js/src/tests/ecma_6/Function/function-name-property.js
parent6822460d3b0d4609ee5d4e1ab4b093799ed06580 (diff)
downloadUXP-5ef44cf6484b9dfd49c0174ac2969a29587a1bbd.tar
UXP-5ef44cf6484b9dfd49c0174ac2969a29587a1bbd.tar.gz
UXP-5ef44cf6484b9dfd49c0174ac2969a29587a1bbd.tar.lz
UXP-5ef44cf6484b9dfd49c0174ac2969a29587a1bbd.tar.xz
UXP-5ef44cf6484b9dfd49c0174ac2969a29587a1bbd.zip
Part 1: Implement ES6 function name property semantics
Issue #78
Diffstat (limited to 'js/src/tests/ecma_6/Function/function-name-property.js')
-rw-r--r--js/src/tests/ecma_6/Function/function-name-property.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/Function/function-name-property.js b/js/src/tests/ecma_6/Function/function-name-property.js
new file mode 100644
index 000000000..7ad174b10
--- /dev/null
+++ b/js/src/tests/ecma_6/Function/function-name-property.js
@@ -0,0 +1,58 @@
+var BUGNUMBER = 883377;
+var summary = "Anonymous function name should be set based on property name";
+
+print(BUGNUMBER + ": " + summary);
+
+var fooSymbol = Symbol("foo");
+var emptySymbol = Symbol("");
+var undefSymbol = Symbol();
+
+var exprs = [
+ ["function() {}", false],
+ ["function named() {}", true],
+ ["function*() {}", false],
+ ["function* named() {}", true],
+ ["async function() {}", false],
+ ["async function named() {}", true],
+ ["() => {}", false],
+ ["async () => {}", false],
+ ["class {}", false],
+ ["class named {}", true],
+];
+
+function testPropertyDefinition(expr, named) {
+ var obj = eval(`({
+ prop: ${expr},
+ "literal": ${expr},
+ "": ${expr},
+ 5: ${expr},
+ 0.4: ${expr},
+ [Symbol.iterator]: ${expr},
+ [fooSymbol]: ${expr},
+ [emptySymbol]: ${expr},
+ [undefSymbol]: ${expr},
+ [/a/]: ${expr},
+ })`);
+ assertEq(obj.prop.name, named ? "named" : "prop");
+ assertEq(obj["literal"].name, named ? "named" : "literal");
+ assertEq(obj[""].name, named ? "named" : "");
+ assertEq(obj[5].name, named ? "named" : "5");
+ assertEq(obj[0.4].name, named ? "named" : "0.4");
+ assertEq(obj[Symbol.iterator].name, named ? "named" : "[Symbol.iterator]");
+ assertEq(obj[fooSymbol].name, named ? "named" : "[foo]");
+ assertEq(obj[emptySymbol].name, named ? "named" : "[]");
+ assertEq(obj[undefSymbol].name, named ? "named" : "");
+ assertEq(obj[/a/].name, named ? "named" : "/a/");
+
+ // Not applicable cases: __proto__.
+ obj = {
+ __proto__: function() {}
+ };
+ assertEq(obj.__proto__.name, "");
+}
+for (var [expr, named] of exprs) {
+ testPropertyDefinition(expr, named);
+}
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0);