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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 (function() { | 46 (function() { |
47 for (var i = 0; i < 7; i++) { | 47 for (var i = 0; i < 7; i++) { |
48 assertEquals([], [].splice(0, 0)); | 48 assertEquals([], [].splice(0, 0)); |
49 assertEquals([], [].splice(1, 0)); | 49 assertEquals([], [].splice(1, 0)); |
50 assertEquals([], [].splice(0, 1)); | 50 assertEquals([], [].splice(0, 1)); |
51 assertEquals([], [].splice(-1, 0)); | 51 assertEquals([], [].splice(-1, 0)); |
52 } | 52 } |
53 })(); | 53 })(); |
54 | 54 |
55 | 55 |
| 56 // Check that even if result array is empty, receiver gets sliced. |
| 57 (function() { |
| 58 for (var i = 0; i < 7; i++) { |
| 59 var a = [1, 2, 3]; |
| 60 assertEquals([], a.splice(1, 0, 'a', 'b', 'c')); |
| 61 assertEquals([1, 'a', 'b', 'c', 2, 3], a); |
| 62 } |
| 63 })(); |
| 64 |
| 65 |
56 // Check various forms of arguments omission. | 66 // Check various forms of arguments omission. |
57 (function() { | 67 (function() { |
58 var array; | 68 var array; |
59 for (var i = 0; i < 7; i++) { | 69 for (var i = 0; i < 7; i++) { |
60 // SpiderMonkey and JSC return undefined in the case where no | 70 // SpiderMonkey and JSC return undefined in the case where no |
61 // arguments are given instead of using the implicit undefined | 71 // arguments are given instead of using the implicit undefined |
62 // arguments. This does not follow ECMA-262, but we do the same for | 72 // arguments. This does not follow ECMA-262, but we do the same for |
63 // compatibility. | 73 // compatibility. |
64 // TraceMonkey follows ECMA-262 though. | 74 // TraceMonkey follows ECMA-262 though. |
65 array = [1, 2, 3] | 75 array = [1, 2, 3] |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 311 |
302 (function() { | 312 (function() { |
303 for (var i = 0; i < 7; i++) { | 313 for (var i = 0; i < 7; i++) { |
304 var a = [7, 8, 9]; | 314 var a = [7, 8, 9]; |
305 a.splice(0, 0, 1, 2, 3, 4, 5, 6); | 315 a.splice(0, 0, 1, 2, 3, 4, 5, 6); |
306 assertEquals([1, 2, 3, 4, 5, 6, 7, 8, 9], a); | 316 assertEquals([1, 2, 3, 4, 5, 6, 7, 8, 9], a); |
307 assertFalse(a.hasOwnProperty(10)); | 317 assertFalse(a.hasOwnProperty(10)); |
308 assertEquals(undefined, a[10]); | 318 assertEquals(undefined, a[10]); |
309 } | 319 } |
310 })(); | 320 })(); |
OLD | NEW |