| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // Out-of-bounds integer access with and without argument | 72 // Out-of-bounds integer access with and without argument |
| 73 // adaptor frames. | 73 // adaptor frames. |
| 74 assertTrue(typeof(A(-10000)) == 'undefined'); | 74 assertTrue(typeof(A(-10000)) == 'undefined'); |
| 75 assertTrue(typeof(A(-10000, 0)) == 'undefined'); | 75 assertTrue(typeof(A(-10000, 0)) == 'undefined'); |
| 76 assertTrue(typeof(A(-1)) == 'undefined'); | 76 assertTrue(typeof(A(-1)) == 'undefined'); |
| 77 assertTrue(typeof(A(-1, 0)) == 'undefined'); | 77 assertTrue(typeof(A(-1, 0)) == 'undefined'); |
| 78 assertTrue(typeof(A(10000)) == 'undefined'); | 78 assertTrue(typeof(A(10000)) == 'undefined'); |
| 79 assertTrue(typeof(A(10000, 0)) == 'undefined'); | 79 assertTrue(typeof(A(10000, 0)) == 'undefined'); |
| 80 | 80 |
| 81 // String access. | 81 // String access. |
| 82 assertEquals(0, A('0')); | 82 assertEquals('0', A('0')); |
| 83 assertEquals(0, A('0',1)); | 83 assertEquals('0', A('0',1)); |
| 84 assertEquals(2, A('1',2)); | 84 assertEquals(2, A('1',2)); |
| 85 assertEquals(2, A('1',2,3,4,5)); | 85 assertEquals(2, A('1',2,3,4,5)); |
| 86 assertEquals(5, A('4',2,3,4,5)); | 86 assertEquals(5, A('4',2,3,4,5)); |
| 87 assertTrue(typeof A('1') == 'undefined'); | 87 assertEquals('undefined', typeof A('1')); |
| 88 assertTrue(typeof A('3',2,1) == 'undefined'); | 88 assertEquals('undefined', typeof A('3',2,1)); |
| 89 assertEquals(A, A('callee')); | 89 assertEquals(A, A('callee')); |
| 90 assertEquals(1, A('length')); | 90 assertEquals(1, A('length')); |
| 91 assertEquals(2, A('length',2)); | 91 assertEquals(2, A('length',2)); |
| 92 assertEquals(5, A('length',2,3,4,5)); | 92 assertEquals(5, A('length',2,3,4,5)); |
| 93 assertEquals({}.toString, A('toString')); | 93 assertEquals({}.toString, A('toString')); |
| 94 assertEquals({}.isPrototypeOf, A('isPrototypeOf')); | 94 assertEquals({}.isPrototypeOf, A('isPrototypeOf')); |
| 95 assertTrue(typeof A('xxx') == 'undefined'); | 95 assertEquals('undefined', typeof A('xxx')); |
| 96 | 96 |
| 97 // Object access. | 97 // Object access. |
| 98 function O(key) { | 98 function O(key) { |
| 99 return { toString: function() { return key; } }; | 99 return { toString: function() { return key; } }; |
| 100 } | 100 } |
| 101 | 101 |
| 102 assertEquals(0, A(O(0))); | 102 var O0 = O(0); |
| 103 assertEquals(0, A(O(0),1)); | 103 assertSame(O0, A(O0)); |
| 104 assertSame(O0, A(O0,1)); |
| 104 assertEquals(2, A(O(1),2)); | 105 assertEquals(2, A(O(1),2)); |
| 105 assertEquals(2, A(O(1),2,3,4,5)); | 106 assertEquals(2, A(O(1),2,3,4,5)); |
| 106 assertEquals(5, A(O(4),2,3,4,5)); | 107 assertEquals(5, A(O(4),2,3,4,5)); |
| 107 assertTrue(typeof A(O(1)) == 'undefined'); | 108 assertTrue(typeof A(O(1)) == 'undefined'); |
| 108 assertTrue(typeof A(O(3),2,1) == 'undefined'); | 109 assertTrue(typeof A(O(3),2,1) == 'undefined'); |
| 109 | 110 |
| 110 assertEquals(0, A(O('0'))); | 111 O0 = O('0'); |
| 111 assertEquals(0, A(O('0'),1)); | 112 assertSame(O0, A(O0)); |
| 113 assertSame(O0, A(O0,1)); |
| 112 assertEquals(2, A(O('1'),2)); | 114 assertEquals(2, A(O('1'),2)); |
| 113 assertEquals(2, A(O('1'),2,3,4,5)); | 115 assertEquals(2, A(O('1'),2,3,4,5)); |
| 114 assertEquals(5, A(O('4'),2,3,4,5)); | 116 assertEquals(5, A(O('4'),2,3,4,5)); |
| 115 assertTrue(typeof A(O('1')) == 'undefined'); | 117 assertTrue(typeof A(O('1')) == 'undefined'); |
| 116 assertTrue(typeof A(O('3'),2,1) == 'undefined'); | 118 assertTrue(typeof A(O('3'),2,1) == 'undefined'); |
| 117 assertEquals(A, A(O('callee'))); | 119 assertEquals(A, A(O('callee'))); |
| 118 assertEquals(1, A(O('length'))); | 120 assertEquals(1, A(O('length'))); |
| 119 assertEquals(2, A(O('length'),2)); | 121 assertEquals(2, A(O('length'),2)); |
| 120 assertEquals(5, A(O('length'),2,3,4,5)); | 122 assertEquals(5, A(O('length'),2,3,4,5)); |
| 121 assertEquals({}.toString, A(O('toString'))); | 123 assertEquals({}.toString, A(O('toString'))); |
| 122 assertEquals({}.isPrototypeOf, A(O('isPrototypeOf'))); | 124 assertEquals({}.isPrototypeOf, A(O('isPrototypeOf'))); |
| 123 assertTrue(typeof A(O('xxx')) == 'undefined'); | 125 assertTrue(typeof A(O('xxx')) == 'undefined'); |
| 124 | 126 |
| 125 // Make sure that out-of-bounds access do lookups in the | 127 // Make sure that out-of-bounds access do lookups in the |
| 126 // prototype chain. | 128 // prototype chain. |
| 127 Object.prototype[5] = 42; | 129 Object.prototype[5] = 42; |
| 128 assertEquals(42, A(5)); | 130 assertEquals(42, A(5)); |
| 129 Object.prototype[-5] = 87; | 131 Object.prototype[-5] = 87; |
| 130 assertEquals(87, A(-5)); | 132 assertEquals(87, A(-5)); |
| OLD | NEW |