OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 assertTrue(delete {}.x); | 38 assertTrue(delete {}.x); |
39 assertTrue(delete {}.y); | 39 assertTrue(delete {}.y); |
40 assertTrue(delete {}.toString); | 40 assertTrue(delete {}.toString); |
41 | 41 |
42 x = 42; | 42 x = 42; |
43 assertEquals(42, x); | 43 assertEquals(42, x); |
44 assertTrue(delete x); | 44 assertTrue(delete x); |
45 assertTrue(typeof x === 'undefined', "x is gone"); | 45 assertTrue(typeof x === 'undefined', "x is gone"); |
46 | 46 |
47 /**** | |
48 * This test relies on DontDelete attributes. This is not | |
49 * working yet. | |
50 | |
51 var y = 87; // should have DontDelete attribute | 47 var y = 87; // should have DontDelete attribute |
52 assertEquals(87, y); | 48 assertEquals(87, y); |
53 assertFalse(delete y, "don't delete"); | 49 assertFalse(delete y, "don't delete"); |
54 assertFalse(typeof y === 'undefined'); | 50 assertFalse(typeof y === 'undefined'); |
55 assertEquals(87, y); | 51 assertEquals(87, y); |
56 */ | |
57 | 52 |
58 var o = { x: 42, y: 87 }; | 53 var o = { x: 42, y: 87 }; |
59 assertTrue(has(o, 'x')); | 54 assertTrue(has(o, 'x')); |
60 assertTrue(has(o, 'y')); | 55 assertTrue(has(o, 'y')); |
61 assertTrue(delete o.x); | 56 assertTrue(delete o.x); |
62 assertFalse(has(o, 'x')); | 57 assertFalse(has(o, 'x')); |
63 assertTrue(has(o, 'y')); | 58 assertTrue(has(o, 'y')); |
64 assertTrue(delete o['y']); | 59 assertTrue(delete o['y']); |
65 assertFalse(has(o, 'x')); | 60 assertFalse(has(o, 'x')); |
66 assertFalse(has(o, 'y')); | 61 assertFalse(has(o, 'y')); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 assertFalse(has(a, 1), "delete 1"); | 149 assertFalse(has(a, 1), "delete 1"); |
155 assertFalse(has(a, Math.pow(2,30)-1), "delete 2^30-1"); | 150 assertFalse(has(a, Math.pow(2,30)-1), "delete 2^30-1"); |
156 assertTrue(has(a, Math.pow(2,31)-1)); | 151 assertTrue(has(a, Math.pow(2,31)-1)); |
157 assertEquals(Math.pow(2,31), a.length); | 152 assertEquals(Math.pow(2,31), a.length); |
158 | 153 |
159 assertTrue(delete a[Math.pow(2,31)-1]); | 154 assertTrue(delete a[Math.pow(2,31)-1]); |
160 assertFalse(has(a, 1), "delete 1"); | 155 assertFalse(has(a, 1), "delete 1"); |
161 assertFalse(has(a, Math.pow(2,30)-1), "delete 2^30-1"); | 156 assertFalse(has(a, Math.pow(2,30)-1), "delete 2^30-1"); |
162 assertFalse(has(a, Math.pow(2,31)-1), "delete 2^31-1"); | 157 assertFalse(has(a, Math.pow(2,31)-1), "delete 2^31-1"); |
163 assertEquals(Math.pow(2,31), a.length); | 158 assertEquals(Math.pow(2,31), a.length); |
| 159 |
| 160 // Check that a LoadIC for a dictionary field works, even |
| 161 // when the dictionary probe misses. |
| 162 function load_deleted_property_using_IC() { |
| 163 var x = new Object(); |
| 164 x.a = 3; |
| 165 x.b = 4; |
| 166 x.c = 5; |
| 167 |
| 168 delete x.c; |
| 169 assertEquals(3, load_a(x)); |
| 170 assertEquals(3, load_a(x)); |
| 171 delete x.a; |
| 172 assertTrue(typeof load_a(x) === 'undefined', "x.a is gone"); |
| 173 assertTrue(typeof load_a(x) === 'undefined', "x.a is gone"); |
| 174 } |
| 175 |
| 176 function load_a(x) { |
| 177 return x.a; |
| 178 } |
| 179 |
| 180 load_deleted_property_using_IC(); |
OLD | NEW |