From 14595b47b8778fa2e6b4bb4220fe7abea998f1fb Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Fri, 1 Jul 2016 16:34:26 -0400 Subject: [PATCH] Add tests for restricted grammar productions --- test/language/global-code/return.js | 18 ++++++++++++ test/language/global-code/yield-non-strict.js | 24 ++++++++++++++++ test/language/global-code/yield-strict.js | 21 ++++++++++++++ test/language/module-code/parse-err-return.js | 28 +++++++++++++++++++ test/language/module-code/parse-err-yield.js | 28 +++++++++++++++++++ 5 files changed, 119 insertions(+) create mode 100644 test/language/global-code/return.js create mode 100644 test/language/global-code/yield-non-strict.js create mode 100644 test/language/global-code/yield-strict.js create mode 100644 test/language/module-code/parse-err-return.js create mode 100644 test/language/module-code/parse-err-yield.js diff --git a/test/language/global-code/return.js b/test/language/global-code/return.js new file mode 100644 index 0000000000..e9d3383426 --- /dev/null +++ b/test/language/global-code/return.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts +es6id: 15.1 +description: ReturnStatement may not be used directly within global code +info: | + Syntax + + Script : + ScriptBodyopt + + ScriptBody : + StatementList[~Yield, ~Return] +negative: SyntaxError +---*/ + +return; diff --git a/test/language/global-code/yield-non-strict.js b/test/language/global-code/yield-non-strict.js new file mode 100644 index 0000000000..72c063f083 --- /dev/null +++ b/test/language/global-code/yield-non-strict.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts +es6id: 15.1 +description: > + The `yield` token is interpreted as an Identifier when it appears in global + code (non-strict mode) +info: | + Syntax + + Script : + ScriptBodyopt + + ScriptBody : + StatementList[~Yield, ~Return] +flags: [noStrict] +---*/ + +// Avoid test failures in cases where the host has defined a `yield` property +// on the global object. +try { + yield = 0; +} catch (_) {} diff --git a/test/language/global-code/yield-strict.js b/test/language/global-code/yield-strict.js new file mode 100644 index 0000000000..24e912bb5a --- /dev/null +++ b/test/language/global-code/yield-strict.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts +es6id: 15.1 +description: > + The `yield` token is interpreted as an Identifier when it appears in global + code (strict mode) +info: | + Syntax + + Script : + ScriptBodyopt + + ScriptBody : + StatementList[~Yield, ~Return] +flags: [onlyStrict] +negative: SyntaxError +---*/ + +yield; diff --git a/test/language/module-code/parse-err-return.js b/test/language/module-code/parse-err-return.js new file mode 100644 index 0000000000..e51e894a8d --- /dev/null +++ b/test/language/module-code/parse-err-return.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-modules +es6id: 15.2 +description: ReturnStatement may not be used directly within ModuleBody +info: | + Syntax + + Module : + ModuleBodyopt + + ModuleBody : + ModuleItemList + + ModuleItemList : + ModuleItem + ModuleItemList ModuleItem + + ModuleItem: + ImportDeclaration + ExportDeclaration + StatementListItem[~Yield, ~Return] +flags: [module] +negative: SyntaxError +---*/ + +return; diff --git a/test/language/module-code/parse-err-yield.js b/test/language/module-code/parse-err-yield.js new file mode 100644 index 0000000000..34600568a2 --- /dev/null +++ b/test/language/module-code/parse-err-yield.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-modules +es6id: 15.2 +description: YieldExpression may not be used directly within ModuleBody +info: | + Syntax + + Module : + ModuleBodyopt + + ModuleBody : + ModuleItemList + + ModuleItemList : + ModuleItem + ModuleItemList ModuleItem + + ModuleItem: + ImportDeclaration + ExportDeclaration + StatementListItem[~Yield, ~Return] +flags: [module] +negative: SyntaxError +---*/ + +yield;