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 | 5 |
6 (function TestDefaults() { | 6 (function TestDefaults() { |
7 function f1(x = 1) { return x } | 7 function f1(x = 1) { return x } |
8 assertEquals(1, f1()); | 8 assertEquals(1, f1()); |
9 assertEquals(1, f1(undefined)); | 9 assertEquals(1, f1(undefined)); |
10 assertEquals(2, f1(2)); | 10 assertEquals(2, f1(2)); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 assertEquals(2, (function(x, y, z = 1, ...a) {}).length); | 343 assertEquals(2, (function(x, y, z = 1, ...a) {}).length); |
344 assertEquals(1, (function(x, y = 1, z) {}).length); | 344 assertEquals(1, (function(x, y = 1, z) {}).length); |
345 assertEquals(1, (function(x, y = 1, z, ...a) {}).length); | 345 assertEquals(1, (function(x, y = 1, z, ...a) {}).length); |
346 assertEquals(1, (function(x, y = 1, z, v = 2) {}).length); | 346 assertEquals(1, (function(x, y = 1, z, v = 2) {}).length); |
347 assertEquals(1, (function(x, y = 1, z, v = 2, ...a) {}).length); | 347 assertEquals(1, (function(x, y = 1, z, v = 2, ...a) {}).length); |
348 })(); | 348 })(); |
349 | 349 |
350 (function TestDirectiveThrows() { | 350 (function TestDirectiveThrows() { |
351 "use strict"; | 351 "use strict"; |
352 | 352 |
353 assertThrows(function(){ eval("function(x=1){'use strict';}") }, SyntaxError); | 353 assertThrows("(function(x=1){'use strict';})", SyntaxError); |
354 assertThrows(function(){ eval("(x=1) => {'use strict';}") }, SyntaxError); | 354 assertThrows("(x=1) => {'use strict';}", SyntaxError); |
355 assertThrows( | 355 assertThrows("(class{foo(x=1) {'use strict';}});", SyntaxError); |
356 function(){ eval("(class{foo(x=1) {'use strict';}});") }, SyntaxError); | |
357 | 356 |
358 assertThrows( | 357 assertThrows("(function(a, x=1){'use strict';})", SyntaxError); |
359 function(){ eval("function(a, x=1){'use strict';}") }, SyntaxError); | 358 assertThrows("(a, x=1) => {'use strict';}", SyntaxError); |
360 assertThrows(function(){ eval("(a, x=1) => {'use strict';}") }, SyntaxError); | 359 assertThrows("(class{foo(a, x=1) {'use strict';}});", SyntaxError); |
361 assertThrows( | 360 |
362 function(){ eval("(class{foo(a, x=1) {'use strict';}});") }, SyntaxError); | 361 assertThrows("(function({x}){'use strict';})", SyntaxError); |
| 362 assertThrows("({x}) => {'use strict';}", SyntaxError); |
| 363 assertThrows("(class{foo({x}) {'use strict';}});", SyntaxError); |
363 })(); | 364 })(); |
OLD | NEW |