summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/es6/indexed-integer-exotics.js
blob: 7aefd78c4ffa4cd84f5504793cb69d8793cbfe76 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --allow-natives-syntax

Object.prototype["10"] = "unreachable";
Object.prototype["7"] = "unreachable";
Object.prototype["-1"] = "unreachable";
Object.prototype["-0"] = "unreachable";
Object.prototype["4294967296"] = "unreachable";

var array = new Int32Array(10);

function check() {
  for (var i = 0; i < 4; i++) {
    assertEquals(undefined, array["-1"]);
    assertEquals(undefined, array["-0"]);
    assertEquals(undefined, array["10"]);
    assertEquals(undefined, array["4294967296"]);
  }
  assertEquals("unreachable", array.__proto__["-1"]);
  assertEquals("unreachable", array.__proto__["-0"]);
  assertEquals("unreachable", array.__proto__["10"]);
  assertEquals("unreachable", array.__proto__["4294967296"]);
}

check();

array["-1"] = "unreachable";
array["-0"] = "unreachable";
array["10"] = "unreachable";
array["4294967296"] = "unreachable";

check();

delete array["-0"];
delete array["-1"];
delete array["10"];
delete array["4294967296"];

assertEquals(undefined, Object.getOwnPropertyDescriptor(array, "-1"));
assertEquals(undefined, Object.getOwnPropertyDescriptor(array, "-0"));
assertEquals(undefined, Object.getOwnPropertyDescriptor(array, "10"));
assertEquals(undefined, Object.getOwnPropertyDescriptor(array, "4294967296"));
assertEquals(10, Object.keys(array).length);

check();

function f() { return array["-1"]; }

for (var i = 0; i < 3; i++) {
  assertEquals(undefined, f());
}
%OptimizeFunctionOnNextCall(f);
assertEquals(undefined, f());

Object.defineProperty(new Int32Array(), "-1", {'value': 1});
Object.defineProperty(new Int32Array(), "-0", {'value': 1});
Object.defineProperty(new Int32Array(), "-10", {'value': 1});
Object.defineProperty(new Int32Array(), "4294967296", {'value': 1});

check();