summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_5/Expressions
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_5/Expressions
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_5/Expressions')
-rw-r--r--js/src/tests/ecma_5/Expressions/11.1.5-01.js37
-rw-r--r--js/src/tests/ecma_5/Expressions/browser.js0
-rw-r--r--js/src/tests/ecma_5/Expressions/named-accessor-function.js49
-rw-r--r--js/src/tests/ecma_5/Expressions/nested-delete-name-in-evalcode.js163
-rw-r--r--js/src/tests/ecma_5/Expressions/object-literal-accessor-arguments.js42
-rw-r--r--js/src/tests/ecma_5/Expressions/object-literal-accessor-property-name.js29
-rw-r--r--js/src/tests/ecma_5/Expressions/primitive-this-boxing-behavior.js106
-rw-r--r--js/src/tests/ecma_5/Expressions/shell.js0
-rw-r--r--js/src/tests/ecma_5/Expressions/string-literal-escape-sequences.js146
9 files changed, 572 insertions, 0 deletions
diff --git a/js/src/tests/ecma_5/Expressions/11.1.5-01.js b/js/src/tests/ecma_5/Expressions/11.1.5-01.js
new file mode 100644
index 000000000..7db12aada
--- /dev/null
+++ b/js/src/tests/ecma_5/Expressions/11.1.5-01.js
@@ -0,0 +1,37 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 520696;
+var summary =
+ 'Implement support for string literals as names for properties defined ' +
+ 'using ES5 get/set syntax';
+
+print(BUGNUMBER + ": " + summary);
+
+
+var o;
+
+o = { get "a b c"() { return 17; } };
+assertEq("get" in Object.getOwnPropertyDescriptor(o, "a b c"), true);
+
+o = eval('({ get "a b c"() { return 17; } })');
+assertEq("get" in Object.getOwnPropertyDescriptor(o, "a b c"), true);
+
+var f = eval("(function literalInside() { return { set 'c d e'(q) { } }; })");
+f = function literalInside() { return { set 'c d e'(q) { } }; };
+
+function checkO()
+{
+ assertEq(3.141592654 in o, true, "fractional-named property isn't in object");
+ assertEq(10000 in o, true, "exponential-named property is in object");
+ assertEq(0xdeadbeef in o, true, "hex-named property is in object");
+ assertEq("Infinity" in o, true, "numeric index stringified correctly");
+}
+
+o = eval('({ 3.141592654: "pi", 1e4: 17, 0xdeadbeef: "hex", 1e3000: "Infinity" })');
+checkO();
+o = { 3.141592654: "pi", 1e4: 17, 0xdeadbeef: "hex", 1e3000: "Infinity" };
+checkO();
+
+reportCompare(true, true);
diff --git a/js/src/tests/ecma_5/Expressions/browser.js b/js/src/tests/ecma_5/Expressions/browser.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/ecma_5/Expressions/browser.js
diff --git a/js/src/tests/ecma_5/Expressions/named-accessor-function.js b/js/src/tests/ecma_5/Expressions/named-accessor-function.js
new file mode 100644
index 000000000..d6a055487
--- /dev/null
+++ b/js/src/tests/ecma_5/Expressions/named-accessor-function.js
@@ -0,0 +1,49 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+// Contributor:
+// Jeff Walden <jwalden+code@mit.edu>
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 999999;
+var summary = '{ get x y() { } } is not valid getter syntax';
+
+print(BUGNUMBER + ": " + summary);
+
+var BAD_CODE = ["({ get x y() { } })", "({ set x y(v) { } })"];
+
+for (var i = 0, sz = BAD_CODE.length; i < sz; i++)
+{
+ var code = BAD_CODE[i];
+
+ var err = "no exception";
+ try
+ {
+ eval(code);
+ }
+ catch (e)
+ {
+ err = e;
+ }
+ if (!(err instanceof SyntaxError))
+ {
+ assertEq(true, false,
+ "bad or no exception thrown for eval(" + code + "): " + err);
+ }
+
+ err = "no exception";
+ try
+ {
+ new Function(code);
+ }
+ catch (e)
+ {
+ err = e;
+ }
+ if (!(err instanceof SyntaxError))
+ {
+ assertEq(true, false,
+ "bad or no exception thrown for Function(" + code + "): " + err);
+ }
+}
+
+reportCompare(true, true);
diff --git a/js/src/tests/ecma_5/Expressions/nested-delete-name-in-evalcode.js b/js/src/tests/ecma_5/Expressions/nested-delete-name-in-evalcode.js
new file mode 100644
index 000000000..8226ba7c8
--- /dev/null
+++ b/js/src/tests/ecma_5/Expressions/nested-delete-name-in-evalcode.js
@@ -0,0 +1,163 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 616294;
+var summary =
+ "|delete x| inside a function in eval code, where that eval code includes " +
+ "|var x| at top level, actually does delete the binding for x";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var f;
+
+function testOuterVar()
+{
+ return eval("var x; (function() { return delete x; })");
+}
+
+f = testOuterVar();
+
+assertEq(f(), true); // configurable, so remove => true
+assertEq(f(), true); // not there => true (only non-configurable => false)
+
+
+function testOuterFunction()
+{
+ return eval("function x() { } (function() { return delete x; })");
+}
+
+f = testOuterFunction();
+
+assertEq(f(), true); // configurable, so remove => true
+assertEq(f(), true); // not there => true (only non-configurable => false)
+
+
+function testOuterForVar()
+{
+ return eval("for (var x; false; ); (function() { return delete x; })");
+}
+
+f = testOuterForVar();
+
+assertEq(f(), true); // configurable, so remove => true
+assertEq(f(), true); // not there => true (only non-configurable => false)
+
+
+function testOuterForInVar()
+{
+ return eval("for (var x in {}); (function() { return delete x; })");
+}
+
+f = testOuterForInVar();
+
+assertEq(f(), true); // configurable, so remove => true
+assertEq(f(), true); // not there => true (only non-configurable => false)
+
+
+function testOuterNestedVar()
+{
+ return eval("for (var q = 0; q < 5; q++) { var x; } (function() { return delete x; })");
+}
+
+f = testOuterNestedVar();
+
+assertEq(f(), true); // configurable, so remove => true
+assertEq(f(), true); // not there => true (only non-configurable => false)
+
+
+function testOuterNestedConditionalVar()
+{
+ return eval("for (var q = 0; q < 5; q++) { if (false) { var x; } } (function() { return delete x; })");
+}
+
+f = testOuterNestedConditionalVar();
+
+assertEq(f(), true); // configurable, so remove => true
+assertEq(f(), true); // not there => true (only non-configurable => false)
+
+
+function testVarInWith()
+{
+ return eval("with ({}) { var x; } (function() { return delete x; })");
+}
+
+f = testVarInWith();
+
+assertEq(f(), true); // configurable, so remove => true
+assertEq(f(), true); // not there => true (only non-configurable => false)
+
+
+function testForVarInWith()
+{
+ return eval("with ({}) { for (var x = 0; x < 5; x++); } (function() { return delete x; })");
+}
+
+f = testForVarInWith();
+
+assertEq(f(), true); // configurable, so remove => true
+assertEq(f(), true); // not there => true (only non-configurable => false)
+
+
+function testForInVarInWith()
+{
+ return eval("with ({}) { for (var x in {}); } (function() { return delete x; })");
+}
+
+f = testForInVarInWith();
+
+assertEq(f(), true); // configurable, so remove => true
+assertEq(f(), true); // not there => true (only non-configurable => false)
+
+
+function testUnknown()
+{
+ return eval("nameToDelete = 17; (function() { return delete nameToDelete; })");
+}
+
+f = testUnknown();
+
+assertEq(f(), true); // configurable global property, so remove => true
+assertEq(f(), true); // not there => true (only non-configurable => false)
+
+
+function testArgumentShadow()
+{
+ return eval("var x; (function(x) { return delete x; })");
+}
+
+f = testArgumentShadow();
+
+assertEq(f(), false); // non-configurable argument => false
+
+
+function testArgument()
+{
+ return eval("(function(x) { return delete x; })");
+}
+
+f = testArgument();
+
+assertEq(f(), false); // non-configurable argument => false
+
+
+function testFunctionLocal()
+{
+ return eval("(function() { var x; return delete x; })");
+}
+
+f = testFunctionLocal();
+
+assertEq(f(), false); // defined by function code => not configurable => false
+
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("All tests passed!");
diff --git a/js/src/tests/ecma_5/Expressions/object-literal-accessor-arguments.js b/js/src/tests/ecma_5/Expressions/object-literal-accessor-arguments.js
new file mode 100644
index 000000000..5b6e7e672
--- /dev/null
+++ b/js/src/tests/ecma_5/Expressions/object-literal-accessor-arguments.js
@@ -0,0 +1,42 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+var gTestfile = 'object-literal-accessor-arguments.js';
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 536472;
+var summary =
+ 'ES5: { get x(v) { } } and { set x(v, v2) { } } should be syntax errors';
+
+print(BUGNUMBER + ": " + summary);
+
+//-----------------------------------------------------------------------------
+
+function expectSyntaxError(s)
+{
+ try
+ {
+ eval(s);
+ throw new Error("no error thrown");
+ }
+ catch (e)
+ {
+ assertEq(e instanceof SyntaxError, true,
+ "expected syntax error parsing '" + s + "', got: " + e);
+ }
+}
+
+expectSyntaxError("({ get x(a) { } })");
+expectSyntaxError("({ get x(a, a) { } })");
+expectSyntaxError("({ get x(a, b) { } })");
+expectSyntaxError("({ get x(a, a, b) { } })");
+expectSyntaxError("({ get x(a, b, c) { } })");
+
+expectSyntaxError("({ set x() { } })");
+expectSyntaxError("({ set x(a, a) { } })");
+expectSyntaxError("({ set x(a, b) { } })");
+expectSyntaxError("({ set x(a, a, b) { } })");
+expectSyntaxError("({ set x(a, b, c) { } })");
+
+//-----------------------------------------------------------------------------
+
+reportCompare(true, true);
diff --git a/js/src/tests/ecma_5/Expressions/object-literal-accessor-property-name.js b/js/src/tests/ecma_5/Expressions/object-literal-accessor-property-name.js
new file mode 100644
index 000000000..11a7f20e0
--- /dev/null
+++ b/js/src/tests/ecma_5/Expressions/object-literal-accessor-property-name.js
@@ -0,0 +1,29 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+var gTestfile = 'object-literal-accessor-property-name.js';
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 715682;
+var summary =
+ "Permit numbers and strings containing numbers as accessor property names";
+print(BUGNUMBER + ": " + summary);
+
+//-----------------------------------------------------------------------------
+
+({ get "0"() { } });
+({ get 0() { } });
+({ get 0.0() { } });
+({ get 0.() { } });
+({ get 1.() { } });
+({ get 5.2322341234123() { } });
+
+({ set "0"(q) { } });
+({ set 0(q) { } });
+({ set 0.0(q) { } });
+({ set 0.(q) { } });
+({ set 1.(q) { } });
+({ set 5.2322341234123(q) { } });
+
+//-----------------------------------------------------------------------------
+
+reportCompare(true, true);
diff --git a/js/src/tests/ecma_5/Expressions/primitive-this-boxing-behavior.js b/js/src/tests/ecma_5/Expressions/primitive-this-boxing-behavior.js
new file mode 100644
index 000000000..36cc0e9e8
--- /dev/null
+++ b/js/src/tests/ecma_5/Expressions/primitive-this-boxing-behavior.js
@@ -0,0 +1,106 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 732669;
+var summary = "Primitive values don't box correctly";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var t;
+function returnThis() { return this; }
+
+// Boolean
+
+Boolean.prototype.method = returnThis;
+t = true.method();
+assertEq(t !== Boolean.prototype, true);
+assertEq(t.toString(), "true");
+
+Object.defineProperty(Boolean.prototype, "property", { get: returnThis, configurable: true });
+t = false.property;
+assertEq(t !== Boolean.prototype, true);
+assertEq(t.toString(), "false");
+
+delete Boolean.prototype.method;
+delete Boolean.prototype.property;
+
+
+// Number
+
+Number.prototype.method = returnThis;
+t = 5..method();
+assertEq(t !== Number.prototype, true);
+assertEq(t.toString(), "5");
+
+Object.defineProperty(Number.prototype, "property", { get: returnThis, configurable: true });
+t = 17..property;
+assertEq(t !== Number.prototype, true);
+assertEq(t.toString(), "17");
+
+delete Number.prototype.method;
+delete Number.prototype.property;
+
+
+// String
+
+String.prototype.method = returnThis;
+t = "foo".method();
+assertEq(t !== String.prototype, true);
+assertEq(t.toString(), "foo");
+
+Object.defineProperty(String.prototype, "property", { get: returnThis, configurable: true });
+t = "bar".property;
+assertEq(t !== String.prototype, true);
+assertEq(t.toString(), "bar");
+
+delete String.prototype.method;
+delete String.prototype.property;
+
+
+// Object
+
+Object.prototype.method = returnThis;
+
+t = true.method();
+assertEq(t !== Object.prototype, true);
+assertEq(t !== Boolean.prototype, true);
+assertEq(t.toString(), "true");
+
+t = 42..method();
+assertEq(t !== Object.prototype, true);
+assertEq(t !== Number.prototype, true);
+assertEq(t.toString(), "42");
+
+t = "foo".method();
+assertEq(t !== Object.prototype, true);
+assertEq(t !== String.prototype, true);
+assertEq(t.toString(), "foo");
+
+Object.defineProperty(Object.prototype, "property", { get: returnThis, configurable: true });
+
+t = false.property;
+assertEq(t !== Object.prototype, true);
+assertEq(t !== Boolean.prototype, true);
+assertEq(t.toString(), "false");
+
+t = 8675309..property;
+assertEq(t !== Object.prototype, true);
+assertEq(t !== Number.prototype, true);
+assertEq(t.toString(), "8675309");
+
+t = "bar".property;
+assertEq(t !== Object.prototype, true);
+assertEq(t !== String.prototype, true);
+assertEq(t.toString(), "bar");
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");
diff --git a/js/src/tests/ecma_5/Expressions/shell.js b/js/src/tests/ecma_5/Expressions/shell.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/ecma_5/Expressions/shell.js
diff --git a/js/src/tests/ecma_5/Expressions/string-literal-escape-sequences.js b/js/src/tests/ecma_5/Expressions/string-literal-escape-sequences.js
new file mode 100644
index 000000000..bc50b2c85
--- /dev/null
+++ b/js/src/tests/ecma_5/Expressions/string-literal-escape-sequences.js
@@ -0,0 +1,146 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 663300;
+var summary =
+ "\\u and \\x must be followed by the appropriate number of hex digits or " +
+ "else it is a syntax error";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+function expectSyntaxError(str)
+{
+ try
+ {
+ eval(str);
+ }
+ catch (e)
+ {
+ assertEq(e instanceof SyntaxError, true,
+ "no syntax error evaluating " + str);
+ }
+}
+
+expectSyntaxError('"\\x"');
+expectSyntaxError('"\\x0"');
+expectSyntaxError('"\\x1"');
+expectSyntaxError('"\\x2"');
+expectSyntaxError('"\\x3"');
+expectSyntaxError('"\\x4"');
+expectSyntaxError('"\\x5"');
+expectSyntaxError('"\\x6"');
+expectSyntaxError('"\\x7"');
+expectSyntaxError('"\\x8"');
+expectSyntaxError('"\\x9"');
+expectSyntaxError('"\\xA"');
+expectSyntaxError('"\\xB"');
+expectSyntaxError('"\\xC"');
+expectSyntaxError('"\\xD"');
+expectSyntaxError('"\\xE"');
+expectSyntaxError('"\\xF"');
+expectSyntaxError('"\\xG"');
+expectSyntaxError('"\\x0G"');
+expectSyntaxError('"\\x1G"');
+expectSyntaxError('"\\x2G"');
+expectSyntaxError('"\\x3G"');
+expectSyntaxError('"\\x4G"');
+expectSyntaxError('"\\x5G"');
+expectSyntaxError('"\\x6G"');
+expectSyntaxError('"\\x7G"');
+expectSyntaxError('"\\x8G"');
+expectSyntaxError('"\\x9G"');
+expectSyntaxError('"\\xAG"');
+expectSyntaxError('"\\xBG"');
+expectSyntaxError('"\\xCG"');
+expectSyntaxError('"\\xDG"');
+expectSyntaxError('"\\xEG"');
+expectSyntaxError('"\\xFG"');
+expectSyntaxError('"\\xGG"');
+
+expectSyntaxError('"\\u"');
+expectSyntaxError('"\\u0"');
+expectSyntaxError('"\\u1"');
+expectSyntaxError('"\\u2"');
+expectSyntaxError('"\\u3"');
+expectSyntaxError('"\\u4"');
+expectSyntaxError('"\\u5"');
+expectSyntaxError('"\\u6"');
+expectSyntaxError('"\\u7"');
+expectSyntaxError('"\\u8"');
+expectSyntaxError('"\\u9"');
+expectSyntaxError('"\\uA"');
+expectSyntaxError('"\\uB"');
+expectSyntaxError('"\\uC"');
+expectSyntaxError('"\\uD"');
+expectSyntaxError('"\\uE"');
+expectSyntaxError('"\\uF"');
+expectSyntaxError('"\\uG"');
+expectSyntaxError('"\\u00"');
+expectSyntaxError('"\\u11"');
+expectSyntaxError('"\\u22"');
+expectSyntaxError('"\\u33"');
+expectSyntaxError('"\\u44"');
+expectSyntaxError('"\\u55"');
+expectSyntaxError('"\\u66"');
+expectSyntaxError('"\\u77"');
+expectSyntaxError('"\\u88"');
+expectSyntaxError('"\\u99"');
+expectSyntaxError('"\\uAA"');
+expectSyntaxError('"\\uBB"');
+expectSyntaxError('"\\uCC"');
+expectSyntaxError('"\\uDD"');
+expectSyntaxError('"\\uEE"');
+expectSyntaxError('"\\uFF"');
+expectSyntaxError('"\\uGG"');
+expectSyntaxError('"\\u000"');
+expectSyntaxError('"\\u111"');
+expectSyntaxError('"\\u222"');
+expectSyntaxError('"\\u333"');
+expectSyntaxError('"\\u444"');
+expectSyntaxError('"\\u555"');
+expectSyntaxError('"\\u666"');
+expectSyntaxError('"\\u777"');
+expectSyntaxError('"\\u888"');
+expectSyntaxError('"\\u999"');
+expectSyntaxError('"\\uAAA"');
+expectSyntaxError('"\\uBBB"');
+expectSyntaxError('"\\uCCC"');
+expectSyntaxError('"\\uDDD"');
+expectSyntaxError('"\\uEEE"');
+expectSyntaxError('"\\uFFF"');
+expectSyntaxError('"\\uGGG"');
+expectSyntaxError('"\\u000G"');
+expectSyntaxError('"\\u111G"');
+expectSyntaxError('"\\u222G"');
+expectSyntaxError('"\\u333G"');
+expectSyntaxError('"\\u444G"');
+expectSyntaxError('"\\u555G"');
+expectSyntaxError('"\\u666G"');
+expectSyntaxError('"\\u777G"');
+expectSyntaxError('"\\u888G"');
+expectSyntaxError('"\\u999G"');
+expectSyntaxError('"\\uAAAG"');
+expectSyntaxError('"\\uBBBG"');
+expectSyntaxError('"\\uCCCG"');
+expectSyntaxError('"\\uDDDG"');
+expectSyntaxError('"\\uEEEG"');
+expectSyntaxError('"\\uFFFG"');
+expectSyntaxError('"\\uGGGG"');
+
+assertEq(eval('"a\\\rb"'), "ab");
+assertEq(eval('"a\\\nb"'), "ab");
+assertEq(eval('"a\\\r\nb"'), "ab");
+assertEq(eval('"a\\\u2028b"'), "ab");
+assertEq(eval('"a\\\u2029b"'), "ab");
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("All tests passed!");