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 // Flags: --harmony-default-parameters --harmony-arrow-functions | 5 // Flags: --harmony-default-parameters --harmony-arrow-functions |
6 // Flags: --harmony-rest-parameters --harmony-destructuring | 6 // Flags: --harmony-rest-parameters --harmony-destructuring |
7 | 7 |
8 | 8 |
9 (function TestDefaults() { | 9 (function TestDefaults() { |
10 function f1(x = 1) { return x } | 10 function f1(x = 1) { return x } |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 function f1(x = 900) { arguments[0] = 1; return x } | 411 function f1(x = 900) { arguments[0] = 1; return x } |
412 assertEquals(9, f1(9)); | 412 assertEquals(9, f1(9)); |
413 assertEquals(900, f1()); | 413 assertEquals(900, f1()); |
414 function f2(x = 1001) { x = 2; return arguments[0] } | 414 function f2(x = 1001) { x = 2; return arguments[0] } |
415 assertEquals(10, f2(10)); | 415 assertEquals(10, f2(10)); |
416 assertEquals(undefined, f2()); | 416 assertEquals(undefined, f2()); |
417 }()); | 417 }()); |
418 | 418 |
419 | 419 |
420 (function TestFunctionLength() { | 420 (function TestFunctionLength() { |
421 // TODO(rossberg): Fix arity. | 421 assertEquals(0, (function(x = 1) {}).length); |
422 // assertEquals(0, (function(x = 1) {}).length); | 422 assertEquals(0, (function(x = 1, ...a) {}).length); |
423 // assertEquals(0, (function(x = 1, ...a) {}).length); | 423 assertEquals(1, (function(x, y = 1) {}).length); |
424 // assertEquals(1, (function(x, y = 1) {}).length); | 424 assertEquals(1, (function(x, y = 1, ...a) {}).length); |
425 // assertEquals(1, (function(x, y = 1, ...a) {}).length); | 425 assertEquals(2, (function(x, y, z = 1) {}).length); |
426 // assertEquals(2, (function(x, y, z = 1) {}).length); | 426 assertEquals(2, (function(x, y, z = 1, ...a) {}).length); |
427 // assertEquals(2, (function(x, y, z = 1, ...a) {}).length); | 427 assertEquals(1, (function(x, y = 1, z) {}).length); |
428 // assertEquals(1, (function(x, y = 1, z) {}).length); | 428 assertEquals(1, (function(x, y = 1, z, ...a) {}).length); |
429 // assertEquals(1, (function(x, y = 1, z, ...a) {}).length); | 429 assertEquals(1, (function(x, y = 1, z, v = 2) {}).length); |
430 // assertEquals(1, (function(x, y = 1, z, v = 2) {}).length); | 430 assertEquals(1, (function(x, y = 1, z, v = 2, ...a) {}).length); |
431 // assertEquals(1, (function(x, y = 1, z, v = 2, ...a) {}).length); | |
432 })(); | 431 })(); |
OLD | NEW |