OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 var own = a.hasOwnProperty(j); | 74 var own = a.hasOwnProperty(j); |
75 var inherited = Array.prototype.hasOwnProperty(j); | 75 var inherited = Array.prototype.hasOwnProperty(j); |
76 assertEquals(j, a.pop(), "inherit-pop"); | 76 assertEquals(j, a.pop(), "inherit-pop"); |
77 assertEquals(j, a.length, "inherit-post-length"); | 77 assertEquals(j, a.length, "inherit-post-length"); |
78 assertFalse(a.hasOwnProperty(j), "inherit-deleted-own-" + j); | 78 assertFalse(a.hasOwnProperty(j), "inherit-deleted-own-" + j); |
79 assertEquals(inherited, Array.prototype.hasOwnProperty(j), | 79 assertEquals(inherited, Array.prototype.hasOwnProperty(j), |
80 "inherit-not-deleted-inherited" + j); | 80 "inherit-not-deleted-inherited" + j); |
81 } | 81 } |
82 Array.prototype.length = 0; // Clean-up. | 82 Array.prototype.length = 0; // Clean-up. |
83 } | 83 } |
| 84 |
| 85 // Check that pop works on inherited properties for |
| 86 // arrays with array prototype. |
| 87 for (var i = 0; i < 10 ;i++) { // Ensure ICs are stabilized. |
| 88 var array_proto = []; |
| 89 array_proto[1] = 1; |
| 90 array_proto[3] = 3; |
| 91 array_proto[5] = 5; |
| 92 array_proto[7] = 7; |
| 93 array_proto[9] = 9; |
| 94 a = [0,1,2,,4,,6,7,8,,]; |
| 95 a.__proto__ = array_proto; |
| 96 assertEquals(10, a.length, "array_proto-inherit-initial-length"); |
| 97 for (var j = 9; j >= 0; j--) { |
| 98 assertEquals(j + 1, a.length, "array_proto-inherit-pre-length-" + j); |
| 99 assertTrue(j in a, "array_proto-has property " + j); |
| 100 var own = a.hasOwnProperty(j); |
| 101 var inherited = array_proto.hasOwnProperty(j); |
| 102 assertEquals(j, a.pop(), "array_proto-inherit-pop"); |
| 103 assertEquals(j, a.length, "array_proto-inherit-post-length"); |
| 104 assertFalse(a.hasOwnProperty(j), "array_proto-inherit-deleted-own-" + j); |
| 105 assertEquals(inherited, array_proto.hasOwnProperty(j), |
| 106 "array_proto-inherit-not-deleted-inherited" + j); |
| 107 } |
| 108 } |
| 109 |
| 110 // Check that pop works on inherited properties for |
| 111 // arrays with array prototype. |
84 })(); | 112 })(); |
85 | 113 |
86 // Test the case of not JSArray receiver. | 114 // Test the case of not JSArray receiver. |
87 // Regression test for custom call generators, see issue 684. | 115 // Regression test for custom call generators, see issue 684. |
88 (function() { | 116 (function() { |
89 var a = []; | 117 var a = []; |
90 for (var i = 0; i < 100; i++) a.push(i); | 118 for (var i = 0; i < 100; i++) a.push(i); |
91 var x = {__proto__: a}; | 119 var x = {__proto__: a}; |
92 for (var i = 0; i < 100; i++) { | 120 for (var i = 0; i < 100; i++) { |
93 assertEquals(99 - i, x.pop(), i + 'th iteration'); | 121 assertEquals(99 - i, x.pop(), i + 'th iteration'); |
94 } | 122 } |
95 })(); | 123 })(); |
OLD | NEW |