summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/arguments/mapped-unmapped-args.js
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/jit-test/tests/arguments/mapped-unmapped-args.js
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/jit-test/tests/arguments/mapped-unmapped-args.js')
-rw-r--r--js/src/jit-test/tests/arguments/mapped-unmapped-args.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/arguments/mapped-unmapped-args.js b/js/src/jit-test/tests/arguments/mapped-unmapped-args.js
new file mode 100644
index 000000000..d1b063be3
--- /dev/null
+++ b/js/src/jit-test/tests/arguments/mapped-unmapped-args.js
@@ -0,0 +1,61 @@
+// An unmapped arguments object is created for strict functions or functions
+// with default/rest/destructuring args.
+
+load(libdir + "asserts.js");
+
+function testDefaults(a, b=3) {
+ a = 3;
+ b = 4;
+ assertEq(arguments.length, 1);
+ assertEq(arguments[0], 1);
+ assertEq(arguments[1], undefined);
+ arguments[0] = 5;
+ assertEq(a, 3);
+ assertThrowsInstanceOf(() => arguments.callee, TypeError);
+}
+testDefaults(1);
+
+function testRest(a, ...rest) {
+ a = 3;
+ assertEq(arguments.length, 3);
+ assertEq(arguments[0], 1);
+ assertEq(arguments[1], 2);
+ arguments[0] = 5;
+ assertEq(a, 3);
+ arguments[1] = 6;
+ assertEq(arguments[1], 6);
+ assertEq(rest.toString(), "2,3");
+ assertThrowsInstanceOf(() => arguments.callee, TypeError);
+}
+testRest(1, 2, 3);
+
+function testDestructuring(a, {foo, bar}, b) {
+ a = 3;
+ bar = 4;
+ b = 1;
+ assertEq(arguments.length, 3);
+ assertEq(arguments[0], 1);
+ assertEq(arguments[1].bar, 2);
+ assertEq(arguments[2], 9);
+ assertThrowsInstanceOf(() => arguments.callee, TypeError);
+}
+testDestructuring(1, {foo: 1, bar: 2}, 9);
+
+function testStrict(a) {
+ "use strict";
+ a = 3;
+ assertEq(arguments[0], 1);
+ arguments[0] = 8;
+ assertEq(a, 3);
+ assertThrowsInstanceOf(() => arguments.callee, TypeError);
+}
+testStrict(1, 2);
+
+function testMapped(a) {
+ a = 3;
+ assertEq(arguments[0], 3);
+ arguments[0] = 5;
+ assertEq(a, 5);
+ assertEq(arguments.callee, testMapped);
+}
+testMapped(1);