| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 assertEquals([], a.splice(1, 0, 'a', 'b', 'c')); | 60 assertEquals([], a.splice(1, 0, 'a', 'b', 'c')); |
| 61 assertEquals([1, 'a', 'b', 'c', 2, 3], a); | 61 assertEquals([1, 'a', 'b', 'c', 2, 3], a); |
| 62 } | 62 } |
| 63 })(); | 63 })(); |
| 64 | 64 |
| 65 | 65 |
| 66 // Check various forms of arguments omission. | 66 // Check various forms of arguments omission. |
| 67 (function() { | 67 (function() { |
| 68 var array; | 68 var array; |
| 69 for (var i = 0; i < 7; i++) { | 69 for (var i = 0; i < 7; i++) { |
| 70 array = [1, 2, 3] | 70 array = [1, 2, 3]; |
| 71 assertEquals([], array.splice()); | 71 assertEquals([], array.splice()); |
| 72 assertEquals([1, 2, 3], array); | 72 assertEquals([1, 2, 3], array); |
| 73 | 73 |
| 74 // SpiderMonkey, TraceMonkey and JSC treat the case where no delete count is | 74 // SpiderMonkey, TraceMonkey and JSC treat the case where no delete count is |
| 75 // given differently from when an undefined delete count is given. | 75 // given differently from when an undefined delete count is given. |
| 76 // This does not follow ECMA-262, but we do the same for | 76 // This does not follow ECMA-262, but we do the same for |
| 77 // compatibility. | 77 // compatibility. |
| 78 array = [1, 2, 3] | 78 array = [1, 2, 3]; |
| 79 assertEquals([1, 2, 3], array.splice(0)); | 79 assertEquals([1, 2, 3], array.splice(0)); |
| 80 assertEquals([], array); | 80 assertEquals([], array); |
| 81 | 81 |
| 82 array = [1, 2, 3] | 82 array = [1, 2, 3]; |
| 83 assertEquals([1, 2, 3], array.splice(undefined)); | 83 assertEquals([1, 2, 3], array.splice(undefined)); |
| 84 assertEquals([], array); | 84 assertEquals([], array); |
| 85 | 85 |
| 86 array = [1, 2, 3] | 86 array = [1, 2, 3]; |
| 87 assertEquals([1, 2, 3], array.splice("foobar")); | 87 assertEquals([1, 2, 3], array.splice("foobar")); |
| 88 assertEquals([], array); | 88 assertEquals([], array); |
| 89 | 89 |
| 90 array = [1, 2, 3] | 90 array = [1, 2, 3]; |
| 91 assertEquals([], array.splice(undefined, undefined)); | 91 assertEquals([], array.splice(undefined, undefined)); |
| 92 assertEquals([1, 2, 3], array); | 92 assertEquals([1, 2, 3], array); |
| 93 | 93 |
| 94 array = [1, 2, 3] | 94 array = [1, 2, 3]; |
| 95 assertEquals([], array.splice("foobar", undefined)); | 95 assertEquals([], array.splice("foobar", undefined)); |
| 96 assertEquals([1, 2, 3], array); | 96 assertEquals([1, 2, 3], array); |
| 97 | 97 |
| 98 array = [1, 2, 3] | 98 array = [1, 2, 3]; |
| 99 assertEquals([], array.splice(undefined, "foobar")); | 99 assertEquals([], array.splice(undefined, "foobar")); |
| 100 assertEquals([1, 2, 3], array); | 100 assertEquals([1, 2, 3], array); |
| 101 | 101 |
| 102 array = [1, 2, 3] | 102 array = [1, 2, 3]; |
| 103 assertEquals([], array.splice("foobar", "foobar")); | 103 assertEquals([], array.splice("foobar", "foobar")); |
| 104 assertEquals([1, 2, 3], array); | 104 assertEquals([1, 2, 3], array); |
| 105 } | 105 } |
| 106 })(); | 106 })(); |
| 107 | 107 |
| 108 | 108 |
| 109 // Check variants of negatives and positive indices. | 109 // Check variants of negatives and positive indices. |
| 110 (function() { | 110 (function() { |
| 111 var array, spliced; | 111 var array, spliced; |
| 112 for (var i = 0; i < 7; i++) { | 112 for (var i = 0; i < 7; i++) { |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 373 |
| 374 (function() { | 374 (function() { |
| 375 for (var i = 0; i < 7; i++) { | 375 for (var i = 0; i < 7; i++) { |
| 376 var a = [7, 8, 9]; | 376 var a = [7, 8, 9]; |
| 377 a.splice(0, 0, 1, 2, 3, 4, 5, 6); | 377 a.splice(0, 0, 1, 2, 3, 4, 5, 6); |
| 378 assertEquals([1, 2, 3, 4, 5, 6, 7, 8, 9], a); | 378 assertEquals([1, 2, 3, 4, 5, 6, 7, 8, 9], a); |
| 379 assertFalse(a.hasOwnProperty(10), "a.hasOwnProperty(10)"); | 379 assertFalse(a.hasOwnProperty(10), "a.hasOwnProperty(10)"); |
| 380 assertEquals(undefined, a[10]); | 380 assertEquals(undefined, a[10]); |
| 381 } | 381 } |
| 382 })(); | 382 })(); |
| OLD | NEW |