Bug 1842999 - Part 30: Enable now passing tests. r=jandem
[gecko.git] / js / src / jit-test / tests / typedarray / indexed-integer-exotics.js
blob510e57c0f036109b104c0c6a01363889d371f235
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 //     * Redistributions of source code must retain the above copyright
7 //       notice, this list of conditions and the following disclaimer.
8 //     * Redistributions in binary form must reproduce the above
9 //       copyright notice, this list of conditions and the following
10 //       disclaimer in the documentation and/or other materials provided
11 //       with the distribution.
12 //     * Neither the name of Google Inc. nor the names of its
13 //       contributors may be used to endorse or promote products derived
14 //       from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 function assertThrows(code) {
29   try {
30     eval(code);
31   } catch (e) {
32     return;
33   }
34   assertEq(true, false);
37 Object.prototype["10"] = "unreachable";
38 Object.prototype["7"] = "unreachable";
39 Object.prototype["-1"] = "unreachable";
40 Object.prototype["-0"] = "unreachable";
41 Object.prototype["4294967295"] = "unreachable";
43 var array = new Int32Array(10);
45 function check() {
46   for (var i = 0; i < 4; i++) {
47     assertEq(undefined, array["-1"]);
48     assertEq(undefined, array["-0"]);
49     assertEq(undefined, array["10"]);
50     assertEq(undefined, array["4294967295"]);
51   }
52   assertEq("unreachable", array.__proto__["-1"]);
53   assertEq("unreachable", array.__proto__["-0"]);
54   assertEq("unreachable", array.__proto__["10"]);
55   assertEq("unreachable", array.__proto__["4294967295"]);
58 check();
60 array["-1"] = "unreachable";
61 array["-0"] = "unreachable";
62 array["10"] = "unreachable";
63 array["4294967295"] = "unreachable";
65 check();
67 delete array["-0"];
68 delete array["-1"];
69 delete array["10"];
70 delete array["4294967295"];
72 assertEq(undefined, Object.getOwnPropertyDescriptor(array, "-1"));
73 assertEq(undefined, Object.getOwnPropertyDescriptor(array, "-0"));
74 assertEq(undefined, Object.getOwnPropertyDescriptor(array, "10"));
75 assertEq(undefined, Object.getOwnPropertyDescriptor(array, "4294967295"));
76 assertEq(10, Object.keys(array).length);
78 check();
80 function f() { return array["-1"]; }
82 for (var i = 0; i < 3; i++) {
83   assertEq(undefined, f());
85 setJitCompilerOption("baseline.warmup.trigger", 0);
86 setJitCompilerOption("ion.warmup.trigger", 0);
87 assertEq(undefined, f());
89 // These checks currently fail due to bug 1129202 not being implemented yet.
90 // We should uncomment them once that bug landed.
91 assertThrows('Object.defineProperty(new Int32Array(100), -1, {value: 1})');
92 // -0 gets converted to the string "0", so use "-0" instead.
93 assertThrows('Object.defineProperty(new Int32Array(100), "-0", {value: 1})');
94 assertThrows('Object.defineProperty(new Int32Array(100), -10, {value: 1})');
95 assertThrows('Object.defineProperty(new Int32Array(), 4294967295, {value: 1})');
97 check();