OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function testSpreadCallsStrict() { | 5 (function testSpreadCallsStrict() { |
6 "use strict" | 6 "use strict" |
7 function countArgs() { return arguments.length; } | 7 function countArgs() { return arguments.length; } |
8 | 8 |
9 // Test this argument | 9 // Test this argument |
10 function returnThis() { return this; } | 10 function returnThis() { return this; } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 // Test values | 43 // Test values |
44 function sum() { | 44 function sum() { |
45 var sum = arguments[0]; | 45 var sum = arguments[0]; |
46 for (var i = 1; i < arguments.length; ++i) { | 46 for (var i = 1; i < arguments.length; ++i) { |
47 sum += arguments[i]; | 47 sum += arguments[i]; |
48 } | 48 } |
49 return sum; | 49 return sum; |
50 } | 50 } |
51 | 51 |
| 52 assertThrows(function() { |
| 53 sum(...0); |
| 54 }, TypeError); |
52 assertEquals(void 0, sum(..."")); | 55 assertEquals(void 0, sum(..."")); |
53 assertEquals(void 0, sum(...[])); | 56 assertEquals(void 0, sum(...[])); |
54 assertEquals(void 0, sum(...new Set)); | 57 assertEquals(void 0, sum(...new Set)); |
55 assertEquals(void 0, sum(...(function*() { })())); | 58 assertEquals(void 0, sum(...(function*() { })())); |
56 | 59 |
57 assertEquals("test", sum(..."test")); | 60 assertEquals("test", sum(..."test")); |
58 assertEquals(10, sum(...[1, 2, 3, 4])); | 61 assertEquals(10, sum(...[1, 2, 3, 4])); |
59 assertEquals(10, sum(...[1, 2, 3], 4)); | 62 assertEquals(10, sum(...[1, 2, 3], 4)); |
60 assertEquals(10, sum(1, ...[2, 3], 4)); | 63 assertEquals(10, sum(1, ...[2, 3], 4)); |
61 assertEquals(10, sum(1, ...[2, 3], ...[4])); | 64 assertEquals(10, sum(1, ...[2, 3], ...[4])); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 197 |
195 // Test values | 198 // Test values |
196 function sum() { | 199 function sum() { |
197 var sum = arguments[0]; | 200 var sum = arguments[0]; |
198 for (var i = 1; i < arguments.length; ++i) { | 201 for (var i = 1; i < arguments.length; ++i) { |
199 sum += arguments[i]; | 202 sum += arguments[i]; |
200 } | 203 } |
201 return sum; | 204 return sum; |
202 } | 205 } |
203 | 206 |
| 207 assertThrows(function() { |
| 208 sum(...0); |
| 209 }, TypeError); |
204 assertEquals(void 0, sum(..."")); | 210 assertEquals(void 0, sum(..."")); |
205 assertEquals(void 0, sum(...[])); | 211 assertEquals(void 0, sum(...[])); |
206 assertEquals(void 0, sum(...new Set)); | 212 assertEquals(void 0, sum(...new Set)); |
207 assertEquals(void 0, sum(...(function*() { })())); | 213 assertEquals(void 0, sum(...(function*() { })())); |
208 | 214 |
209 assertEquals("test", sum(..."test")); | 215 assertEquals("test", sum(..."test")); |
210 assertEquals(10, sum(...[1, 2, 3, 4])); | 216 assertEquals(10, sum(...[1, 2, 3, 4])); |
211 assertEquals(10, sum(...[1, 2, 3], 4)); | 217 assertEquals(10, sum(...[1, 2, 3], 4)); |
212 assertEquals(10, sum(1, ...[2, 3], 4)); | 218 assertEquals(10, sum(1, ...[2, 3], 4)); |
213 assertEquals(10, sum(1, ...[2, 3], ...[4])); | 219 assertEquals(10, sum(1, ...[2, 3], ...[4])); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 get: function() { | 487 get: function() { |
482 called++; | 488 called++; |
483 return it; | 489 return it; |
484 } | 490 } |
485 }); | 491 }); |
486 | 492 |
487 countArgs(...a); | 493 countArgs(...a); |
488 | 494 |
489 assertEquals(1, called); | 495 assertEquals(1, called); |
490 })(); | 496 })(); |
OLD | NEW |