OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
| 28 /* These tests should pass now but they take too long to run. |
28 var a = []; | 29 var a = []; |
29 a[0xfffffffe] = 10; | 30 a[0xfffffffe] = 10; |
30 assertThrows("a.unshift(1);", RangeError); | 31 assertThrows("a.unshift(1);", RangeError); |
31 assertEquals(0xffffffff, a.length); | 32 assertEquals(0xffffffff, a.length); |
32 assertEquals(10, a[0xffffffff]); | 33 assertEquals(10, a[0xffffffff]); |
33 assertEquals(undefined, a[0xfffffffe]); | 34 assertEquals(undefined, a[0xfffffffe]); |
34 | 35 |
35 a = [1,2,3]; | 36 a = [1,2,3]; |
36 a[0xfffffffe] = 10; | 37 a[0xfffffffe] = 10; |
37 assertThrows("a.splice(1,1,7,7,7,7,7);", RangeError); | 38 assertThrows("a.splice(1,1,7,7,7,7,7);", RangeError); |
38 assertEquals([1,7,7,7,7,7,3], a.slice(0, 7)); | 39 assertEquals([1,7,7,7,7,7,3], a.slice(0, 7)); |
39 assertEquals(0xffffffff, a.length); | 40 assertEquals(0xffffffff, a.length); |
40 assertEquals(10, a[0xfffffffe + 5 - 1]); | 41 assertEquals(10, a[0xfffffffe + 5 - 1]); |
| 42 */ |
41 | 43 |
42 a = [1]; | 44 a = [1]; |
43 Object.defineProperty(a, "1", {writable:false, configurable:false, value: 100}); | 45 Object.defineProperty(a, "1", {writable:false, configurable:false, value: 100}); |
44 assertThrows("a.unshift(4);", TypeError); | 46 assertThrows("a.unshift(4);", TypeError); |
45 assertEquals([1, 100, 100], a); | 47 assertEquals([1, 100, 100], a); |
46 var desc = Object.getOwnPropertyDescriptor(a, "1"); | 48 var desc = Object.getOwnPropertyDescriptor(a, "1"); |
47 assertEquals(false, desc.writable); | 49 assertEquals(false, desc.writable); |
48 assertEquals(false, desc.configurable); | 50 assertEquals(false, desc.configurable); |
49 | 51 |
50 a = [1]; | 52 a = [1]; |
(...skipping 19 matching lines...) Expand all Loading... |
70 a = [1]; | 72 a = [1]; |
71 Object.defineProperty(a, "1", {configurable:false, value:10}); | 73 Object.defineProperty(a, "1", {configurable:false, value:10}); |
72 assertThrows("a.splice(1,1);", TypeError); | 74 assertThrows("a.splice(1,1);", TypeError); |
73 assertEquals([1, 10], a); | 75 assertEquals([1, 10], a); |
74 desc = Object.getOwnPropertyDescriptor(a, "1"); | 76 desc = Object.getOwnPropertyDescriptor(a, "1"); |
75 assertEquals(false, desc.configurable); | 77 assertEquals(false, desc.configurable); |
76 | 78 |
77 a = [0,1,2,3,4,5,6]; | 79 a = [0,1,2,3,4,5,6]; |
78 Object.defineProperty(a, "3", {configurable:false, writable:false, value:3}); | 80 Object.defineProperty(a, "3", {configurable:false, writable:false, value:3}); |
79 assertThrows("a.splice(1,4);", TypeError); | 81 assertThrows("a.splice(1,4);", TypeError); |
80 assertEquals([0,5,6,3,,,,,], a); | 82 assertEquals([0,5,6,3,,,,], a); |
81 desc = Object.getOwnPropertyDescriptor(a, "3"); | 83 desc = Object.getOwnPropertyDescriptor(a, "3"); |
82 assertEquals(false, desc.configurable); | 84 assertEquals(false, desc.configurable); |
83 assertEquals(false, desc.writable); | 85 assertEquals(false, desc.writable); |
84 | 86 |
85 a = [0,1,2,3,4,5,6]; | 87 a = [0,1,2,3,4,5,6]; |
86 Object.defineProperty(a, "5", {configurable:false, value:5}); | 88 Object.defineProperty(a, "5", {configurable:false, value:5}); |
87 assertThrows("a.splice(1,4);", TypeError); | 89 assertThrows("a.splice(1,4);", TypeError); |
88 assertEquals([0,5,6,3,4,5,,,], a); | 90 assertEquals([0,5,6,3,4,5,,], a); |
89 desc = Object.getOwnPropertyDescriptor(a, "5"); | 91 desc = Object.getOwnPropertyDescriptor(a, "5"); |
90 assertEquals(false, desc.configurable); | 92 assertEquals(false, desc.configurable); |
91 | 93 |
92 a = [1,2,3,,5]; | 94 a = [1,2,3,,5]; |
93 Object.defineProperty(a, "1", {configurable:false, writable:true, value:2}); | 95 Object.defineProperty(a, "1", {configurable:false, writable:true, value:2}); |
94 assertEquals(1, a.shift()); | 96 assertEquals(1, a.shift()); |
95 assertEquals([2,3,,5], a); | 97 assertEquals([2,3,,5], a); |
96 desc = Object.getOwnPropertyDescriptor(a, "1"); | 98 desc = Object.getOwnPropertyDescriptor(a, "1"); |
97 assertEquals(false, desc.configurable); | 99 assertEquals(false, desc.configurable); |
98 assertEquals(true, desc.writable); | 100 assertEquals(true, desc.writable); |
99 assertThrows("a.shift();", TypeError); | 101 assertThrows("a.shift();", TypeError); |
100 assertEquals([3,3,,5], a); | 102 assertEquals([3,3,,5], a); |
101 desc = Object.getOwnPropertyDescriptor(a, "1"); | 103 desc = Object.getOwnPropertyDescriptor(a, "1"); |
102 assertEquals(false, desc.configurable); | 104 assertEquals(false, desc.configurable); |
103 assertEquals(true, desc.writable); | 105 assertEquals(true, desc.writable); |
104 | 106 |
105 a = [1,2,3]; | 107 a = [1,2,3]; |
106 Object.defineProperty(a, "2", {configurable:false, value:3}); | 108 Object.defineProperty(a, "2", {configurable:false, value:3}); |
107 assertThrows("a.pop();", TypeError); | 109 assertThrows("a.pop();", TypeError); |
108 assertEquals([1,2,3], a); | 110 assertEquals([1,2,3], a); |
109 desc = Object.getOwnPropertyDescriptor(a, "2"); | 111 desc = Object.getOwnPropertyDescriptor(a, "2"); |
110 assertEquals(false, desc.configurable); | 112 assertEquals(false, desc.configurable); |
111 | |
112 a = [1,2,,,5]; | |
113 Object.defineProperty(a, "4", {writable:true, configurable:false, value:5}); | |
114 assertThrows("a.sort();", TypeError); | |
115 assertEquals([1,2,5,,5], a); | |
116 desc = Object.getOwnPropertyDescriptor(a, "2"); | |
117 assertEquals(true, desc.configurable); | |
118 desc = Object.getOwnPropertyDescriptor(a, "4"); | |
119 assertEquals(false, desc.configurable); | |
120 | |
121 a = [1,2,3,,5,6]; | |
122 Object.defineProperty(a, "4", {value:5, writable:false}); | |
123 assertThrows("a.sort();", TypeError); | |
124 assertEquals([1,2,3,5,5,6], a); | |
125 desc = Object.getOwnPropertyDescriptor(a, "4"); | |
126 assertEquals(false, desc.writable); | |
OLD | NEW |