зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1305566 - Part 5: Allow yield in object destructuring shorthand and CoverInitName. r=arai
--HG-- extra : rebase_source : 3077ce9812e12e1a714b03f82c7e4ca49579834c
This commit is contained in:
Родитель
7c128adb58
Коммит
8364af7470
|
@ -8328,11 +8328,12 @@ Parser<ParseHandler>::newName(PropertyName* name, TokenPos pos)
|
|||
|
||||
template <typename ParseHandler>
|
||||
PropertyName*
|
||||
Parser<ParseHandler>::labelOrIdentifierReference(YieldHandling yieldHandling)
|
||||
Parser<ParseHandler>::labelOrIdentifierReference(YieldHandling yieldHandling,
|
||||
bool yieldTokenizedAsName)
|
||||
{
|
||||
PropertyName* ident;
|
||||
const Token& tok = tokenStream.currentToken();
|
||||
if (tok.type == TOK_NAME) {
|
||||
if (tok.type == TOK_NAME && !yieldTokenizedAsName) {
|
||||
ident = tok.name();
|
||||
MOZ_ASSERT(ident != context->names().yield,
|
||||
"tokenizer should have treated 'yield' as TOK_YIELD");
|
||||
|
@ -8349,7 +8350,9 @@ Parser<ParseHandler>::labelOrIdentifierReference(YieldHandling yieldHandling)
|
|||
}
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(tok.type == TOK_YIELD);
|
||||
MOZ_ASSERT(tok.type == TOK_YIELD ||
|
||||
(tok.type == TOK_NAME && yieldTokenizedAsName &&
|
||||
tok.name() == context->names().yield));
|
||||
|
||||
if (yieldHandling == YieldIsKeyword ||
|
||||
pc->sc()->strict() ||
|
||||
|
@ -8815,12 +8818,20 @@ Parser<ParseHandler>::objectLiteral(YieldHandling yieldHandling, PossibleError*
|
|||
} else if (propType == PropertyType::Shorthand) {
|
||||
/*
|
||||
* Support, e.g., |var {x, y} = o| as destructuring shorthand
|
||||
* for |var {x: x, y: y} = o|, per proposed JS2/ES4 for JS1.8.
|
||||
* for |var {x: x, y: y} = o|, and |var o = {x, y}| as initializer
|
||||
* shorthand for |var o = {x: x, y: y}|.
|
||||
*/
|
||||
if (!tokenStream.checkForKeyword(propAtom, nullptr))
|
||||
TokenKind propToken = TOK_NAME;
|
||||
if (!tokenStream.checkForKeyword(propAtom, &propToken))
|
||||
return null();
|
||||
|
||||
Rooted<PropertyName*> name(context, identifierReference(yieldHandling));
|
||||
if (propToken != TOK_NAME && propToken != TOK_YIELD) {
|
||||
report(ParseError, false, null(), JSMSG_RESERVED_ID, TokenKindToDesc(propToken));
|
||||
return null();
|
||||
}
|
||||
|
||||
Rooted<PropertyName*> name(context,
|
||||
identifierReference(yieldHandling, propToken == TOK_YIELD));
|
||||
if (!name)
|
||||
return null();
|
||||
|
||||
|
@ -8833,12 +8844,19 @@ Parser<ParseHandler>::objectLiteral(YieldHandling yieldHandling, PossibleError*
|
|||
} else if (propType == PropertyType::CoverInitializedName) {
|
||||
/*
|
||||
* Support, e.g., |var {x=1, y=2} = o| as destructuring shorthand
|
||||
* with default values, as per ES6 12.14.5 (2016/2/4)
|
||||
* with default values, as per ES6 12.14.5
|
||||
*/
|
||||
if (!tokenStream.checkForKeyword(propAtom, nullptr))
|
||||
TokenKind propToken = TOK_NAME;
|
||||
if (!tokenStream.checkForKeyword(propAtom, &propToken))
|
||||
return null();
|
||||
|
||||
Rooted<PropertyName*> name(context, identifierReference(yieldHandling));
|
||||
if (propToken != TOK_NAME && propToken != TOK_YIELD) {
|
||||
report(ParseError, false, null(), JSMSG_RESERVED_ID, TokenKindToDesc(propToken));
|
||||
return null();
|
||||
}
|
||||
|
||||
Rooted<PropertyName*> name(context,
|
||||
identifierReference(yieldHandling, propToken == TOK_YIELD));
|
||||
if (!name)
|
||||
return null();
|
||||
|
||||
|
|
|
@ -1210,14 +1210,17 @@ class Parser final : private JS::AutoGCRooter, public StrictModeGetter
|
|||
Node classDefinition(YieldHandling yieldHandling, ClassContext classContext,
|
||||
DefaultHandling defaultHandling);
|
||||
|
||||
PropertyName* labelOrIdentifierReference(YieldHandling yieldHandling);
|
||||
PropertyName* labelOrIdentifierReference(YieldHandling yieldHandling,
|
||||
bool yieldTokenizedAsName);
|
||||
|
||||
PropertyName* labelIdentifier(YieldHandling yieldHandling) {
|
||||
return labelOrIdentifierReference(yieldHandling);
|
||||
return labelOrIdentifierReference(yieldHandling, false);
|
||||
}
|
||||
|
||||
PropertyName* identifierReference(YieldHandling yieldHandling) {
|
||||
return labelOrIdentifierReference(yieldHandling);
|
||||
PropertyName* identifierReference(YieldHandling yieldHandling,
|
||||
bool yieldTokenizedAsName = false)
|
||||
{
|
||||
return labelOrIdentifierReference(yieldHandling, yieldTokenizedAsName);
|
||||
}
|
||||
|
||||
PropertyName* importedBinding() {
|
||||
|
|
|
@ -982,12 +982,8 @@ TokenStream::checkForKeyword(const KeywordInfo* kw, TokenKind* ttp)
|
|||
return reportStrictModeError(JSMSG_RESERVED_ID, kw->chars);
|
||||
|
||||
// Working keyword.
|
||||
if (ttp) {
|
||||
*ttp = kw->tokentype;
|
||||
return true;
|
||||
}
|
||||
|
||||
return reportError(JSMSG_RESERVED_ID, kw->chars);
|
||||
*ttp = kw->tokentype;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -741,10 +741,8 @@ class MOZ_STACK_CLASS TokenStream
|
|||
// If it is a reserved word in this version and strictness mode, and thus
|
||||
// can't be present in correct code, report a SyntaxError and return false.
|
||||
//
|
||||
// If it is a keyword, like "if", the behavior depends on ttp. If ttp is
|
||||
// null, report a SyntaxError ("if is a reserved identifier") and return
|
||||
// false. If ttp is non-null, return true with the keyword's TokenKind in
|
||||
// *ttp.
|
||||
// If it is a keyword, like "if", return true with the keyword's TokenKind
|
||||
// in *ttp.
|
||||
MOZ_MUST_USE bool checkForKeyword(JSAtom* atom, TokenKind* ttp);
|
||||
|
||||
// Same semantics as above, but for the provided keyword.
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
// Destructuring binding patterns with var.
|
||||
(function() {
|
||||
var {a: yield} = {a: "yield-with-name"};
|
||||
assertEq(yield, "yield-with-name");
|
||||
|
||||
var {yield} = {yield: "yield-with-shorthand"};
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
|
||||
var {yield = 0} = {yield: "yield-with-coverinitname"};
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
})();
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f() {
|
||||
var {a: yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f() {
|
||||
var {yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f() {
|
||||
var {yield = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns with let.
|
||||
(function(){
|
||||
let {a: yield} = {a: "yield-with-name"};
|
||||
assertEq(yield, "yield-with-name");
|
||||
})();
|
||||
|
||||
(function() {
|
||||
let {yield} = {yield: "yield-with-shorthand"};
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
})();
|
||||
|
||||
(function() {
|
||||
let {yield = 0} = {yield: "yield-with-coverinitname"};
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
})();
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f() {
|
||||
let {a: yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f() {
|
||||
let {yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f() {
|
||||
let {yield = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns with const.
|
||||
(function() {
|
||||
const {a: yield} = {a: "yield-with-name"};
|
||||
assertEq(yield, "yield-with-name");
|
||||
})();
|
||||
|
||||
(function() {
|
||||
const {yield} = {yield: "yield-with-shorthand"};
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
})();
|
||||
|
||||
(function() {
|
||||
const {yield = 0} = {yield: "yield-with-coverinitname"};
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
})();
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f() {
|
||||
const {a: yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f() {
|
||||
const {yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f() {
|
||||
const {yield = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns in parameters.
|
||||
(function({a: yield} = {a: "yield-with-name"}) {
|
||||
assertEq(yield, "yield-with-name");
|
||||
})();
|
||||
|
||||
(function({yield} = {yield: "yield-with-shorthand"}) {
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
})();
|
||||
|
||||
(function({yield = 0} = {yield: "yield-with-coverinitname"}) {
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
})();
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f({a: yield} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f({yield} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f({yield = 0} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring assignment pattern.
|
||||
(function() {
|
||||
var a, yield;
|
||||
|
||||
({a: yield} = {a: "yield-with-name"});
|
||||
assertEq(yield, "yield-with-name");
|
||||
|
||||
({yield} = {yield: "yield-with-shorthand"});
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
|
||||
({yield = 0} = {yield: "yield-with-coverinitname"});
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
})();
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f() {
|
||||
({a: yield} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f() {
|
||||
({yield} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function f() {
|
||||
({yield = 0} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(0, 0, "ok");
|
|
@ -0,0 +1,200 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
// Destructuring binding patterns with var.
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g() {
|
||||
var {a: yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g() {
|
||||
var {yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g() {
|
||||
var {yield = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g() {
|
||||
var {a: yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g() {
|
||||
var {yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g() {
|
||||
var {yield = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns with let.
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g() {
|
||||
let {a: yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g() {
|
||||
let {yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g() {
|
||||
let {yield = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g() {
|
||||
let {a: yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g() {
|
||||
let {yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g() {
|
||||
let {yield = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns with const.
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g() {
|
||||
const {a: yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g() {
|
||||
const {yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g() {
|
||||
const {yield = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g() {
|
||||
const {a: yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g() {
|
||||
const {yield} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g() {
|
||||
const {yield = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns in parameters.
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g({a: yield} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g({yield} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g({yield = 0} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g({a: yield} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g({yield} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g({yield = 0} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring assignment pattern.
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g() {
|
||||
({a: yield} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g() {
|
||||
({yield} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
function* g() {
|
||||
({yield = 0} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g() {
|
||||
({a: yield} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g() {
|
||||
({yield} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
function* g() {
|
||||
({yield = 0} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(0, 0, "ok");
|
|
@ -0,0 +1,123 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
// Destructuring binding patterns with var.
|
||||
var {a: yield} = {a: "yield-with-name"};
|
||||
assertEq(yield, "yield-with-name");
|
||||
|
||||
var {yield} = {yield: "yield-with-shorthand"};
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
|
||||
var {yield = 0} = {yield: "yield-with-coverinitname"};
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
var {a: yield} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
var {yield} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
var {yield = 0} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns with let.
|
||||
{
|
||||
let {a: yield} = {a: "yield-with-name"};
|
||||
assertEq(yield, "yield-with-name");
|
||||
}
|
||||
|
||||
{
|
||||
let {yield} = {yield: "yield-with-shorthand"};
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
}
|
||||
|
||||
{
|
||||
let {yield = 0} = {yield: "yield-with-coverinitname"};
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
}
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
let {a: yield} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
let {yield} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
let {yield = 0} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns with const.
|
||||
{
|
||||
const {a: yield} = {a: "yield-with-name"};
|
||||
assertEq(yield, "yield-with-name");
|
||||
}
|
||||
|
||||
{
|
||||
const {yield} = {yield: "yield-with-shorthand"};
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
}
|
||||
|
||||
{
|
||||
const {yield = 0} = {yield: "yield-with-coverinitname"};
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
}
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
const {a: yield} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
const {yield} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
const {yield = 0} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring assignment pattern.
|
||||
({a: yield} = {a: "yield-with-name"});
|
||||
assertEq(yield, "yield-with-name");
|
||||
|
||||
({yield} = {yield: "yield-with-shorthand"});
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
|
||||
({yield = 0} = {yield: "yield-with-coverinitname"});
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
({a: yield} = {});
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
({yield} = {});
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(`
|
||||
"use strict";
|
||||
({yield = 0} = {});
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(0, 0, "ok");
|
|
@ -0,0 +1,192 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
/******/
|
||||
var message = "Congratulations, you've fixed escape sequences in yield! Please enable the commented out tests in this file.";
|
||||
try {
|
||||
eval(String.raw`var yi\u0065ld;`);
|
||||
} catch (e) {
|
||||
message = "";
|
||||
}
|
||||
if (message) throw message;
|
||||
/******/
|
||||
|
||||
// Destructuring binding patterns with var.
|
||||
(function() {
|
||||
// var {a: yi\u0065ld} = {a: "yield-with-name"};
|
||||
// assertEq(yield, "yield-with-name");
|
||||
|
||||
var {yi\u0065ld} = {yield: "yield-with-shorthand"};
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
|
||||
var {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"};
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
})();
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f() {
|
||||
var {a: yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f() {
|
||||
var {yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f() {
|
||||
var {yi\u0065ld = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns with let.
|
||||
(function(){
|
||||
// let {a: yi\u0065ld} = {a: "yield-with-name"};
|
||||
// assertEq(yield, "yield-with-name");
|
||||
})();
|
||||
|
||||
(function() {
|
||||
let {yi\u0065ld} = {yield: "yield-with-shorthand"};
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
})();
|
||||
|
||||
(function() {
|
||||
let {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"};
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
})();
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f() {
|
||||
let {a: yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f() {
|
||||
let {yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f() {
|
||||
let {yi\u0065ld = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns with const.
|
||||
(function() {
|
||||
// const {a: yi\u0065ld} = {a: "yield-with-name"};
|
||||
// assertEq(yield, "yield-with-name");
|
||||
})();
|
||||
|
||||
(function() {
|
||||
const {yi\u0065ld} = {yield: "yield-with-shorthand"};
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
})();
|
||||
|
||||
(function() {
|
||||
const {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"};
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
})();
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f() {
|
||||
const {a: yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f() {
|
||||
const {yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f() {
|
||||
const {yi\u0065ld = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns in parameters.
|
||||
// (function({a: yi\u0065ld} = {a: "yield-with-name"}) {
|
||||
// assertEq(yield, "yield-with-name");
|
||||
// })();
|
||||
|
||||
(function({yi\u0065ld} = {yield: "yield-with-shorthand"}) {
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
})();
|
||||
|
||||
(function({yi\u0065ld = 0} = {yield: "yield-with-coverinitname"}) {
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
})();
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f({a: yi\u0065ld} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f({yi\u0065ld} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f({yi\u0065ld = 0} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring assignment pattern.
|
||||
(function() {
|
||||
var a, yield;
|
||||
|
||||
// ({a: yi\u0065ld} = {a: "yield-with-name"});
|
||||
// assertEq(yield, "yield-with-name");
|
||||
|
||||
({yi\u0065ld} = {yield: "yield-with-shorthand"});
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
|
||||
({yi\u0065ld = 0} = {yield: "yield-with-coverinitname"});
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
})();
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f() {
|
||||
({a: yi\u0065ld} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f() {
|
||||
({yi\u0065ld} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function f() {
|
||||
({yi\u0065ld = 0} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(0, 0, "ok");
|
|
@ -0,0 +1,200 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
// Destructuring binding patterns with var.
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g() {
|
||||
var {a: yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g() {
|
||||
var {yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g() {
|
||||
var {yi\u0065ld = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g() {
|
||||
var {a: yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g() {
|
||||
var {yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g() {
|
||||
var {yi\u0065ld = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns with let.
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g() {
|
||||
let {a: yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g() {
|
||||
let {yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g() {
|
||||
let {yi\u0065ld = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g() {
|
||||
let {a: yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g() {
|
||||
let {yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g() {
|
||||
let {yi\u0065ld = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns with const.
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g() {
|
||||
const {a: yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g() {
|
||||
const {yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g() {
|
||||
const {yi\u0065ld = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g() {
|
||||
const {a: yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g() {
|
||||
const {yi\u0065ld} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g() {
|
||||
const {yi\u0065ld = 0} = {};
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns in parameters.
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g({a: yi\u0065ld} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g({yi\u0065ld} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g({yi\u0065ld = 0} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g({a: yi\u0065ld} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g({yi\u0065ld} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g({yi\u0065ld = 0} = {}) { }
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring assignment pattern.
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g() {
|
||||
({a: yi\u0065ld} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g() {
|
||||
({yi\u0065ld} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
function* g() {
|
||||
({yi\u0065ld = 0} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g() {
|
||||
({a: yi\u0065ld} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g() {
|
||||
({yi\u0065ld} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
function* g() {
|
||||
({yi\u0065ld = 0} = {});
|
||||
}
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(0, 0, "ok");
|
|
@ -0,0 +1,133 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
/******/
|
||||
var message = "Congratulations, you've fixed escape sequences in yield! Please enable the commented out tests in this file.";
|
||||
try {
|
||||
eval(String.raw`var yi\u0065ld;`);
|
||||
} catch (e) {
|
||||
message = "";
|
||||
}
|
||||
if (message) throw message;
|
||||
/******/
|
||||
|
||||
// Destructuring binding patterns with var.
|
||||
// var {a: yi\u0065ld} = {a: "yield-with-name"};
|
||||
// assertEq(yield, "yield-with-name");
|
||||
|
||||
var {yi\u0065ld} = {yield: "yield-with-shorthand"};
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
|
||||
var {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"};
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
var {a: yi\u0065ld} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
var {yi\u0065ld} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
var {yi\u0065ld = 0} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns with let.
|
||||
{
|
||||
// let {a: yi\u0065ld} = {a: "yield-with-name"};
|
||||
// assertEq(yield, "yield-with-name");
|
||||
}
|
||||
|
||||
{
|
||||
let {yi\u0065ld} = {yield: "yield-with-shorthand"};
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
}
|
||||
|
||||
{
|
||||
let {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"};
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
}
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
let {a: yi\u0065ld} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
let {yi\u0065ld} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
let {yi\u0065ld = 0} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring binding patterns with const.
|
||||
{
|
||||
// const {a: yi\u0065ld} = {a: "yield-with-name"};
|
||||
// assertEq(yield, "yield-with-name");
|
||||
}
|
||||
|
||||
{
|
||||
const {yi\u0065ld} = {yield: "yield-with-shorthand"};
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
}
|
||||
|
||||
{
|
||||
const {yi\u0065ld = 0} = {yield: "yield-with-coverinitname"};
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
}
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
const {a: yi\u0065ld} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
const {yi\u0065ld} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
const {yi\u0065ld = 0} = {};
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
// Destructuring assignment pattern.
|
||||
// ({a: yi\u0065ld} = {a: "yield-with-name"});
|
||||
// assertEq(yield, "yield-with-name");
|
||||
|
||||
({yi\u0065ld} = {yield: "yield-with-shorthand"});
|
||||
assertEq(yield, "yield-with-shorthand");
|
||||
|
||||
({yi\u0065ld = 0} = {yield: "yield-with-coverinitname"});
|
||||
assertEq(yield, "yield-with-coverinitname");
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
({a: yi\u0065ld} = {});
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
({yi\u0065ld} = {});
|
||||
`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOf(() => eval(String.raw`
|
||||
"use strict";
|
||||
({yi\u0065ld = 0} = {});
|
||||
`), SyntaxError);
|
||||
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(0, 0, "ok");
|
Загрузка…
Ссылка в новой задаче