summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Array/splice-return-array-elements-defined-not-set.js
blob: 2f5eca610dfc41a7417d6ef6b598abc98da0b140 (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
41
42
43
44
45
46
/*
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/licenses/publicdomain/
 */

//-----------------------------------------------------------------------------
var BUGNUMBER = 668024;
var summary =
  'Array.prototype.splice should define, not set, the elements of the array ' +
  'it returns';

print(BUGNUMBER + ": " + summary);

/**************
 * BEGIN TEST *
 **************/

Object.defineProperty(Object.prototype, 2,
  {
    set: function(v)
    {
      throw new Error("setter on Object.prototype called!");
    },
    get: function() { return "fnord"; },
    enumerable: false,
    configurable: true
  });

var arr = [0, 1, 2, 3, 4, 5];
var removed = arr.splice(0, 6);

assertEq(arr.length, 0);
assertEq(removed.length, 6);
assertEq(removed[0], 0);
assertEq(removed[1], 1);
assertEq(removed[2], 2);
assertEq(removed[3], 3);
assertEq(removed[4], 4);
assertEq(removed[5], 5);

/******************************************************************************/

if (typeof reportCompare === "function")
  reportCompare(true, true);

print("Tests complete");