| 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } catch (e) { | 100 } catch (e) { |
| 101 assertEquals('Exception', e); | 101 assertEquals('Exception', e); |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 })(); | 104 })(); |
| 105 | 105 |
| 106 | 106 |
| 107 // Nasty: modify the array in ToInteger. | 107 // Nasty: modify the array in ToInteger. |
| 108 (function() { | 108 (function() { |
| 109 var array = []; | 109 var array = []; |
| 110 var expected = [] | 110 var expected = []; |
| 111 bad_guy = { valueOf: function() { array.push(array.length); return -1; } }; | 111 bad_guy = { valueOf: function() { array.push(array.length); return -1; } }; |
| 112 | 112 |
| 113 for (var i = 0; i < 13; i++) { | 113 for (var i = 0; i < 13; i++) { |
| 114 var sliced = array.slice(bad_guy); | 114 var sliced = array.slice(bad_guy); |
| 115 expected.push(i); | 115 expected.push(i); |
| 116 assertEquals(expected, array); | 116 assertEquals(expected, array); |
| 117 // According to the spec (15.4.4.10), length is calculated before | 117 // According to the spec (15.4.4.10), length is calculated before |
| 118 // performing ToInteger on arguments. | 118 // performing ToInteger on arguments. |
| 119 if (i == 0) { | 119 if (i == 0) { |
| 120 assertEquals([], sliced); // Length was 0, nothing to get. | 120 assertEquals([], sliced); // Length was 0, nothing to get. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // Check slicing on arguments object when argument has been deleted by index. | 283 // Check slicing on arguments object when argument has been deleted by index. |
| 284 (function() { | 284 (function() { |
| 285 function func(x, y, z) { | 285 function func(x, y, z) { |
| 286 assertEquals(3, arguments.length); | 286 assertEquals(3, arguments.length); |
| 287 delete arguments[1]; | 287 delete arguments[1]; |
| 288 assertEquals([x,,z], Array.prototype.slice.call(arguments, 0)); | 288 assertEquals([x,,z], Array.prototype.slice.call(arguments, 0)); |
| 289 } | 289 } |
| 290 | 290 |
| 291 func('a', 'b', 'c'); | 291 func('a', 'b', 'c'); |
| 292 })(); | 292 })(); |
| OLD | NEW |