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 | |
6 | |
7 | 5 |
8 (function TestDefaults() { | 6 (function TestDefaults() { |
9 function f1(x = 1) { return x } | 7 function f1(x = 1) { return x } |
10 assertEquals(1, f1()); | 8 assertEquals(1, f1()); |
11 assertEquals(1, f1(undefined)); | 9 assertEquals(1, f1(undefined)); |
12 assertEquals(2, f1(2)); | 10 assertEquals(2, f1(2)); |
13 assertEquals(null, f1(null)); | 11 assertEquals(null, f1(null)); |
14 | 12 |
15 function f2(x, y = x) { return x + y; } | 13 function f2(x, y = x) { return x + y; } |
16 assertEquals(8, f2(4)); | 14 assertEquals(8, f2(4)); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 assertThrows(function(){ eval("(x=1) => {'use strict';}") }, SyntaxError); | 354 assertThrows(function(){ eval("(x=1) => {'use strict';}") }, SyntaxError); |
357 assertThrows( | 355 assertThrows( |
358 function(){ eval("(class{foo(x=1) {'use strict';}});") }, SyntaxError); | 356 function(){ eval("(class{foo(x=1) {'use strict';}});") }, SyntaxError); |
359 | 357 |
360 assertThrows( | 358 assertThrows( |
361 function(){ eval("function(a, x=1){'use strict';}") }, SyntaxError); | 359 function(){ eval("function(a, x=1){'use strict';}") }, SyntaxError); |
362 assertThrows(function(){ eval("(a, x=1) => {'use strict';}") }, SyntaxError); | 360 assertThrows(function(){ eval("(a, x=1) => {'use strict';}") }, SyntaxError); |
363 assertThrows( | 361 assertThrows( |
364 function(){ eval("(class{foo(a, x=1) {'use strict';}});") }, SyntaxError); | 362 function(){ eval("(class{foo(a, x=1) {'use strict';}});") }, SyntaxError); |
365 })(); | 363 })(); |
OLD | NEW |