summaryrefslogtreecommitdiff
path: root/js/src/tests/ecma_5/strict/15.4.5.1.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/ecma_5/strict/15.4.5.1.js')
-rw-r--r--js/src/tests/ecma_5/strict/15.4.5.1.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/js/src/tests/ecma_5/strict/15.4.5.1.js b/js/src/tests/ecma_5/strict/15.4.5.1.js
new file mode 100644
index 0000000..010c7fa
--- /dev/null
+++ b/js/src/tests/ecma_5/strict/15.4.5.1.js
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+function arr() {
+ return Object.defineProperty([1, 2, 3, 4], 2, {configurable: false});
+}
+
+assertEq(testLenientAndStrict('var a = arr(); a.length = 2; a',
+ returnsCopyOf([1, 2, 3]),
+ raisesException(TypeError)),
+ true);
+
+// Internally, SpiderMonkey has two representations for arrays:
+// fast-but-inflexible, and slow-but-flexible. Adding a non-index property
+// to an array turns it into the latter. We should test on both kinds.
+function addx(obj) {
+ obj.x = 5;
+ return obj;
+}
+
+assertEq(testLenientAndStrict('var a = addx(arr()); a.length = 2; a',
+ returnsCopyOf(addx([1, 2, 3])),
+ raisesException(TypeError)),
+ true);
+
+reportCompare(true, true);