| 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 18 matching lines...) Expand all Loading... |
| 29 (function() { | 29 (function() { |
| 30 var array = new Array(10); | 30 var array = new Array(10); |
| 31 for (var i = 0; i < 7; i++) { | 31 for (var i = 0; i < 7; i++) { |
| 32 var sliced = array.slice(); | 32 var sliced = array.slice(); |
| 33 assertEquals(array.length, sliced.length); | 33 assertEquals(array.length, sliced.length); |
| 34 assertFalse(0 in sliced); | 34 assertFalse(0 in sliced); |
| 35 } | 35 } |
| 36 })(); | 36 })(); |
| 37 | 37 |
| 38 | 38 |
| 39 // Check various variants of empty array's slicing. |
| 40 (function() { |
| 41 for (var i = 0; i < 7; i++) { |
| 42 assertEquals([], [].slice(0, 0)); |
| 43 assertEquals([], [].slice(1, 0)); |
| 44 assertEquals([], [].slice(0, 1)); |
| 45 assertEquals([], [].slice(-1, 0)); |
| 46 } |
| 47 })(); |
| 48 |
| 49 |
| 39 // Check various forms of arguments omission. | 50 // Check various forms of arguments omission. |
| 40 (function() { | 51 (function() { |
| 41 var array = new Array(7); | 52 var array = new Array(7); |
| 42 | 53 |
| 43 for (var i = 0; i < 7; i++) { | 54 for (var i = 0; i < 7; i++) { |
| 44 assertEquals(array, array.slice()); | 55 assertEquals(array, array.slice()); |
| 45 assertEquals(array, array.slice(0)); | 56 assertEquals(array, array.slice(0)); |
| 46 assertEquals(array, array.slice(undefined)); | 57 assertEquals(array, array.slice(undefined)); |
| 47 assertEquals(array, array.slice("foobar")); | 58 assertEquals(array, array.slice("foobar")); |
| 48 assertEquals(array, array.slice(undefined, undefined)); | 59 assertEquals(array, array.slice(undefined, undefined)); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // ... but keeps the rest as holes: | 164 // ... but keeps the rest as holes: |
| 154 Array.prototype[5] = "@5"; | 165 Array.prototype[5] = "@5"; |
| 155 assertEquals(array[5], Array.prototype[5]); | 166 assertEquals(array[5], Array.prototype[5]); |
| 156 assertFalse(array.hasOwnProperty(5)); | 167 assertFalse(array.hasOwnProperty(5)); |
| 157 assertEquals(sliced[5], Array.prototype[5]); | 168 assertEquals(sliced[5], Array.prototype[5]); |
| 158 assertFalse(sliced.hasOwnProperty(5)); | 169 assertFalse(sliced.hasOwnProperty(5)); |
| 159 | 170 |
| 160 assertTrue(delete Array.prototype[5]); | 171 assertTrue(delete Array.prototype[5]); |
| 161 } | 172 } |
| 162 })(); | 173 })(); |
| OLD | NEW |