summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/splice/15.4.4.12-9-c-ii-1.js
blob: 5323c13cfc114e77a6e5795c9238d32759f19572 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2012 Ecma International.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-array.prototype.splice
description: >
    Array.prototype.splice will splice an array even when
    Array.prototype has index '0' set to read-only and 'fromPresent'
    less than 'actualDeleteCount (Step 9.c.ii)
---*/

var arr = ["a", "b", "c"];
Array.prototype[0] = "test";
var newArr = arr.splice(2, 1, "d");

var verifyValue = false;
verifyValue = arr.length === 3 && arr[0] === "a" && arr[1] === "b" && arr[2] === "d" &&
  newArr[0] === "c" && newArr.length === 1;

var verifyEnumerable = false;
for (var p in newArr) {
  if (newArr.hasOwnProperty("0") && p === "0") {
    verifyEnumerable = true;
  }
}

var verifyWritable = false;
newArr[0] = 12;
verifyWritable = newArr[0] === 12;

var verifyConfigurable = false;
delete newArr[0];
verifyConfigurable = newArr.hasOwnProperty("0");

assert(verifyValue, 'verifyValue !== true');
assert.sameValue(verifyConfigurable, false, 'verifyConfigurable');
assert(verifyEnumerable, 'verifyEnumerable !== true');
assert(verifyWritable, 'verifyWritable !== true');

reportCompare(0, 0);