From 485059c46d6ce5001911f6900bb057d7f2ceaf49 Mon Sep 17 00:00:00 2001
From: Sam Mikes <smikes@cubane.com>
Date: Thu, 7 Aug 2014 17:27:40 +0100
Subject: [PATCH] initial tests of Array.prototpe.splice requiring settable
 "length" add test of object with only "length" getter *fix typo

per comments from @anba, thanks!
 * remove needless checks
 * add "splice" method

fix es5id
---
 .../prototype/splice/S15.4.4.12_A6.1_T1.js    | 24 +++++++++++++++++++
 .../prototype/splice/S15.4.4.12_A6.1_T2.js    | 17 +++++++++++++
 .../prototype/splice/S15.4.4.12_A6.1_T3.js    | 22 +++++++++++++++++
 3 files changed, 63 insertions(+)
 create mode 100644 test/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T1.js
 create mode 100644 test/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T2.js
 create mode 100644 test/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T3.js

diff --git a/test/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T1.js b/test/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T1.js
new file mode 100644
index 0000000000..87ddb735c6
--- /dev/null
+++ b/test/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T1.js
@@ -0,0 +1,24 @@
+// Copyright 2014 Ecma International.  All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Array.prototype.splice sets `length` on `this`
+es5id: 15.4.4.12_A6.1_T1
+description: Array.prototype.splice sets `length` on Array
+---*/
+
+var a = [0, 1, 2];
+
+a.splice(1, 2, 4);
+
+if (a.length !== 2) {
+    $ERROR("Expected a.length === 2, actually " + a.length);
+}
+
+if (a[0] !== 0) {
+    $ERROR("Expected a[0] === 0, actually " + a[0]);
+}
+
+if (a[1] !== 4) {
+    $ERROR("Expected a[1] === 4, actually " + a[1]);
+}
diff --git a/test/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T2.js b/test/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T2.js
new file mode 100644
index 0000000000..48e2022819
--- /dev/null
+++ b/test/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T2.js
@@ -0,0 +1,17 @@
+// Copyright 2014 Ecma International.  All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Array.prototype.splice sets `length` on `this`
+es5id: 15.4.4.12_A6.1_T2
+description: Array.prototype.splice throws if `length` is read-only
+negative: TypeError
+---*/
+
+var a = [0, 1, 2];
+
+Object.defineProperty(a, 'length', {
+    writable: false
+});
+
+a.splice(1, 2, 4);
diff --git a/test/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T3.js b/test/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T3.js
new file mode 100644
index 0000000000..beb38a5563
--- /dev/null
+++ b/test/built-ins/Array/prototype/splice/S15.4.4.12_A6.1_T3.js
@@ -0,0 +1,22 @@
+// Copyright 2014 Ecma International.  All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: Array.prototype.splice sets `length` on `this`
+es5id: 15.4.4.12_A6.1_T3
+description: Array.prototype.splice throws if `length` is read-only
+---*/
+
+var a = { 
+    get length() { return 0; },
+    splice: Array.prototype.splice 
+};
+
+try {
+    a.splice(1, 2, 4);
+    $ERROR("Expected a TypeError");
+} catch (e) {
+    if (!(e instanceof TypeError)) {
+        throw e;
+    }
+}
-- 
GitLab