Commit 7ea3b099 authored by littledan's avatar littledan Committed by Commit bot

Destructuring/default tests for generators and async functions

This patch adds additional tests for async functions and generators, in how
they interact with destructuring, default arguments and shadow parameter
copying.

BUG=v8:5167

Review-Url: https://codereview.chromium.org/2229243002
Cr-Commit-Position: refs/heads/master@{#38560}
parent e61bd68e
......@@ -350,14 +350,15 @@
(function TestDirectiveThrows() {
"use strict";
assertThrows(function(){ eval("function(x=1){'use strict';}") }, SyntaxError);
assertThrows(function(){ eval("(x=1) => {'use strict';}") }, SyntaxError);
assertThrows(
function(){ eval("(class{foo(x=1) {'use strict';}});") }, SyntaxError);
assertThrows(
function(){ eval("function(a, x=1){'use strict';}") }, SyntaxError);
assertThrows(function(){ eval("(a, x=1) => {'use strict';}") }, SyntaxError);
assertThrows(
function(){ eval("(class{foo(a, x=1) {'use strict';}});") }, SyntaxError);
assertThrows("(function(x=1){'use strict';})", SyntaxError);
assertThrows("(x=1) => {'use strict';}", SyntaxError);
assertThrows("(class{foo(x=1) {'use strict';}});", SyntaxError);
assertThrows("(function(a, x=1){'use strict';})", SyntaxError);
assertThrows("(a, x=1) => {'use strict';}", SyntaxError);
assertThrows("(class{foo(a, x=1) {'use strict';}});", SyntaxError);
assertThrows("(function({x}){'use strict';})", SyntaxError);
assertThrows("({x}) => {'use strict';}", SyntaxError);
assertThrows("(class{foo({x}) {'use strict';}});", SyntaxError);
})();
......@@ -1045,9 +1045,9 @@
function f20({x}) { function x() { return 2 }; return x(); }
assertEquals(2, f20({x: 1}));
// Function hoisting is blocked by the conflicting x declaration
function f21({x}) { { function x() { return 2 } } return x(); }
assertThrows(() => f21({x: 1}), TypeError);
// Annex B 3.3 function hoisting is blocked by the conflicting x declaration
function f21({x}) { { function x() { return 2 } } return x; }
assertEquals(1, f21({x: 1}));
var g1 = ({x}) => { var x = 2; return x };
assertEquals(2, g1({x: 1}));
......@@ -1082,15 +1082,15 @@
var g21 = ({x}) => { { function x() { return 2 } } return x(); }
assertThrows(() => g21({x: 1}), TypeError);
assertThrows("'use strict'; function f(x) { let x = 0; }; f({});", SyntaxError);
assertThrows("'use strict'; function f({x}) { let x = 0; }; f({});", SyntaxError);
assertThrows("'use strict'; function f(x) { const x = 0; }; f({});", SyntaxError);
assertThrows("'use strict'; function f({x}) { const x = 0; }; f({});", SyntaxError);
assertThrows("'use strict'; function f(x) { let x = 0; }", SyntaxError);
assertThrows("'use strict'; function f({x}) { let x = 0; }", SyntaxError);
assertThrows("'use strict'; function f(x) { const x = 0; }", SyntaxError);
assertThrows("'use strict'; function f({x}) { const x = 0; }", SyntaxError);
assertThrows("'use strict'; let g = (x) => { let x = 0; }; f({});", SyntaxError);
assertThrows("'use strict'; let g = ({x}) => { let x = 0; }; f({});", SyntaxError);
assertThrows("'use strict'; let g = (x) => { const x = 0; }; f({});", SyntaxError);
assertThrows("'use strict'; let g = ({x}) => { const x = 0; }; f({});", SyntaxError);
assertThrows("'use strict'; let g = (x) => { let x = 0; }", SyntaxError);
assertThrows("'use strict'; let g = ({x}) => { let x = 0; }", SyntaxError);
assertThrows("'use strict'; let g = (x) => { const x = 0; }", SyntaxError);
assertThrows("'use strict'; let g = ({x}) => { const x = 0; }", SyntaxError);
}());
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment