From c3e384c8c5fcee43395bebc958e48e23dc2c8d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Tue, 23 Oct 2018 12:23:08 -0700 Subject: [PATCH] Add initial tests for import.meta (#1888) Fixes #1342 --- features.txt | 4 + .../import.meta/distinct-for-each-module.js | 36 +++++++++ .../distinct-for-each-module_FIXTURE.js | 8 ++ .../import-meta-is-an-ordinary-object.js | 77 +++++++++++++++++++ .../not-accessible-from-direct-eval.js | 16 ++++ .../import.meta/same-object-returned.js | 34 ++++++++ .../syntax/escape-sequence-import.js | 34 ++++++++ .../syntax/escape-sequence-meta.js | 34 ++++++++ .../goal-async-function-params-or-body.js | 21 +++++ .../goal-async-generator-params-or-body.js | 21 +++++ .../syntax/goal-function-params-or-body.js | 19 +++++ .../syntax/goal-generator-params-or-body.js | 21 +++++ .../syntax/goal-module-nested-function.js | 16 ++++ .../import.meta/syntax/goal-module.js | 14 ++++ .../import.meta/syntax/goal-script.js | 18 +++++ ...ignment-target-array-destructuring-expr.js | 31 ++++++++ ...nt-target-array-rest-destructuring-expr.js | 31 ++++++++ ...valid-assignment-target-assignment-expr.js | 31 ++++++++ ...lid-assignment-target-for-await-of-loop.js | 32 ++++++++ .../invalid-assignment-target-for-in-loop.js | 30 ++++++++ .../invalid-assignment-target-for-of-loop.js | 30 ++++++++ ...gnment-target-object-destructuring-expr.js | 31 ++++++++ ...t-target-object-rest-destructuring-expr.js | 31 ++++++++ .../invalid-assignment-target-update-expr.js | 32 ++++++++ 24 files changed, 652 insertions(+) create mode 100644 test/language/expressions/import.meta/distinct-for-each-module.js create mode 100644 test/language/expressions/import.meta/distinct-for-each-module_FIXTURE.js create mode 100644 test/language/expressions/import.meta/import-meta-is-an-ordinary-object.js create mode 100644 test/language/expressions/import.meta/not-accessible-from-direct-eval.js create mode 100644 test/language/expressions/import.meta/same-object-returned.js create mode 100644 test/language/expressions/import.meta/syntax/escape-sequence-import.js create mode 100644 test/language/expressions/import.meta/syntax/escape-sequence-meta.js create mode 100644 test/language/expressions/import.meta/syntax/goal-async-function-params-or-body.js create mode 100644 test/language/expressions/import.meta/syntax/goal-async-generator-params-or-body.js create mode 100644 test/language/expressions/import.meta/syntax/goal-function-params-or-body.js create mode 100644 test/language/expressions/import.meta/syntax/goal-generator-params-or-body.js create mode 100644 test/language/expressions/import.meta/syntax/goal-module-nested-function.js create mode 100644 test/language/expressions/import.meta/syntax/goal-module.js create mode 100644 test/language/expressions/import.meta/syntax/goal-script.js create mode 100644 test/language/expressions/import.meta/syntax/invalid-assignment-target-array-destructuring-expr.js create mode 100644 test/language/expressions/import.meta/syntax/invalid-assignment-target-array-rest-destructuring-expr.js create mode 100644 test/language/expressions/import.meta/syntax/invalid-assignment-target-assignment-expr.js create mode 100644 test/language/expressions/import.meta/syntax/invalid-assignment-target-for-await-of-loop.js create mode 100644 test/language/expressions/import.meta/syntax/invalid-assignment-target-for-in-loop.js create mode 100644 test/language/expressions/import.meta/syntax/invalid-assignment-target-for-of-loop.js create mode 100644 test/language/expressions/import.meta/syntax/invalid-assignment-target-object-destructuring-expr.js create mode 100644 test/language/expressions/import.meta/syntax/invalid-assignment-target-object-rest-destructuring-expr.js create mode 100644 test/language/expressions/import.meta/syntax/invalid-assignment-target-update-expr.js diff --git a/features.txt b/features.txt index 63bd7d3292..504c577c45 100644 --- a/features.txt +++ b/features.txt @@ -131,6 +131,10 @@ globalThis # https://github.com/tc39/ecma262/pull/1174 export-star-as-namespace-from-module +# import.meta +# https://github.com/tc39/proposal-import-meta +import.meta + # Standard language features # # Language features that have been included in a published version of the diff --git a/test/language/expressions/import.meta/distinct-for-each-module.js b/test/language/expressions/import.meta/distinct-for-each-module.js new file mode 100644 index 0000000000..e84c1e267b --- /dev/null +++ b/test/language/expressions/import.meta/distinct-for-each-module.js @@ -0,0 +1,36 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-meta-properties-runtime-semantics-evaluation +description: > + The import.meta object is not shared across modules. +info: | + Runtime Semantics: Evaluation + + ImportMeta : import.meta + + 1. Let module be GetActiveScriptOrModule(). + ... + 3. Let importMeta be module.[[ImportMeta]]. + 4. If importMeta is undefined. + ... + f. Set module.[[ImportMeta]] to importMeta. + g. Return importMeta. + ... +flags: [module] +features: [import.meta] +---*/ + +import {meta as fixture_meta, getMeta} from "./distinct-for-each-module_FIXTURE.js"; + +// The imported module has a distinct import.meta object. +assert.notSameValue(import.meta, fixture_meta, + "foreign import.meta accessed via import binding"); +assert.notSameValue(import.meta, getMeta(), + "foreign import.meta accessed via function call"); + +// Calling a function which returns import.meta returns the import.meta object +// from the module in which the function is declared. +assert.sameValue(fixture_meta, getMeta(), + "import.meta accessed via import binding is identical to the one accessed via call"); diff --git a/test/language/expressions/import.meta/distinct-for-each-module_FIXTURE.js b/test/language/expressions/import.meta/distinct-for-each-module_FIXTURE.js new file mode 100644 index 0000000000..92b4b28b18 --- /dev/null +++ b/test/language/expressions/import.meta/distinct-for-each-module_FIXTURE.js @@ -0,0 +1,8 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +export var meta = import.meta; + +export function getMeta() { + return import.meta; +} diff --git a/test/language/expressions/import.meta/import-meta-is-an-ordinary-object.js b/test/language/expressions/import.meta/import-meta-is-an-ordinary-object.js new file mode 100644 index 0000000000..121cf84521 --- /dev/null +++ b/test/language/expressions/import.meta/import-meta-is-an-ordinary-object.js @@ -0,0 +1,77 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-meta-properties-runtime-semantics-evaluation +description: > + import.meta is an ordinary object. +info: | + Runtime Semantics: Evaluation + + ImportMeta : import.meta + + ... + 4. If importMeta is undefined. + a. Set importMeta to ObjectCreate(null). + b. Let importMetaValues be ! HostGetImportMetaProperties(module). + ... + e. Perform ! HostFinalizeImportMeta(importMeta, module). + ... + g. Return importMeta. + ... +flags: [module] +features: [import.meta] +---*/ + +// import.meta is an object. +assert.sameValue(typeof import.meta, "object", + "typeof import.meta is 'object'"); +assert.notSameValue(import.meta, null, + "typeof import.meta is 'object' and import.meta isn't |null|."); + +assert.throws(TypeError, function() { + import.meta(); +}, "import.meta is not callable"); + +assert.throws(TypeError, function() { + new import.meta(); +}, "import.meta is not a constructor"); + +// Note: The properties, the shape of the properties, the extensibility state, and the prototype +// of import.meta are implementation-defined via HostGetImportMetaProperties and +// HostFinalizeImportMeta. + +// Properties and the prototype can only be modified when import.meta is extensible. +if (Object.isExtensible(import.meta)) { + assert.sameValue(Object.getOwnPropertyDescriptor(import.meta, "test262prop"), undefined, + "test262 test property is not present initially"); + + import.meta.test262prop = "blubb"; + + assert.sameValue(import.meta.test262prop, "blubb", + "Properties can be added and retrieved from import.meta"); + + assert.sameValue(delete import.meta.test262prop, true, + "Properties can be removed from import.meta"); + + assert.sameValue(Object.getOwnPropertyDescriptor(import.meta, "test262prop"), undefined, + "test262 test property is no longer present"); + + var proto = {}; + Object.setPrototypeOf(import.meta, proto); + + assert.sameValue(Object.getPrototypeOf(import.meta), proto, + "[[Prototype]] of import.meta can be changed"); +} + +Object.preventExtensions(import.meta); +assert.sameValue(Object.isExtensible(import.meta), false, + "import.meta is non-extensible after calling |Object.preventExtensions|"); + +Object.seal(import.meta); +assert.sameValue(Object.isSealed(import.meta), true, + "import.meta is sealed after calling |Object.seal|"); + +Object.freeze(import.meta); +assert.sameValue(Object.isFrozen(import.meta), true, + "import.meta is frozen after calling |Object.freeze|"); diff --git a/test/language/expressions/import.meta/not-accessible-from-direct-eval.js b/test/language/expressions/import.meta/not-accessible-from-direct-eval.js new file mode 100644 index 0000000000..299fd6dd90 --- /dev/null +++ b/test/language/expressions/import.meta/not-accessible-from-direct-eval.js @@ -0,0 +1,16 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-left-hand-side-expressions-static-semantics-early-errors +description: > + import.meta is not allowed in direct eval in module code. +info: | + It is an early Syntax Error if Module is not the syntactic goal symbol. +flags: [module] +features: [import.meta] +---*/ + +assert.throws(SyntaxError, function() { + eval("import.meta"); +}); diff --git a/test/language/expressions/import.meta/same-object-returned.js b/test/language/expressions/import.meta/same-object-returned.js new file mode 100644 index 0000000000..4bb52b5643 --- /dev/null +++ b/test/language/expressions/import.meta/same-object-returned.js @@ -0,0 +1,34 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-meta-properties-runtime-semantics-evaluation +description: > + The same import.meta object is returned for a module. +info: | + Runtime Semantics: Evaluation + + ImportMeta : import.meta + + 1. Let module be GetActiveScriptOrModule(). + ... + 3. Let importMeta be module.[[ImportMeta]]. + 4. If importMeta is undefined. + ... + f. Set module.[[ImportMeta]] to importMeta. + g. Return importMeta. + 5. Else, + a. Assert: Type(importMeta) is Object. + b. Return importMeta. +flags: [module] +features: [import.meta] +---*/ + +var a = import.meta; +var b = function() { return import.meta; }(); + +assert.sameValue(import.meta, a, + "import.meta accessed directly and accessed via variable declaration"); + +assert.sameValue(import.meta, b, + "import.meta accessed directly and accessed via function return value"); diff --git a/test/language/expressions/import.meta/syntax/escape-sequence-import.js b/test/language/expressions/import.meta/syntax/escape-sequence-import.js new file mode 100644 index 0000000000..928e5b994f --- /dev/null +++ b/test/language/expressions/import.meta/syntax/escape-sequence-import.js @@ -0,0 +1,34 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-left-hand-side-expressions +description: > + "import" in import.meta must not contain escape sequences. +info: | + 5.1.5 Grammar Notation + + Terminal symbols of the lexical, RegExp, and numeric string grammars are shown in fixed width + font, both in the productions of the grammars and throughout this specification whenever the + text directly refers to such a terminal symbol. These are to appear in a script exactly as + written. All terminal symbol code points specified in this way are to be understood as the + appropriate Unicode code points from the Basic Latin range, as opposed to any similar-looking + code points from other Unicode ranges. + + 12.3 Left-Hand-Side Expressions + MetaProperty: + NewTarget + ImportMeta + + ImportMeta: + import.meta +flags: [module] +negative: + phase: parse + type: SyntaxError +features: [import.meta] +---*/ + +throw "Test262: This statement should not be evaluated."; + +im\u0070ort.meta; diff --git a/test/language/expressions/import.meta/syntax/escape-sequence-meta.js b/test/language/expressions/import.meta/syntax/escape-sequence-meta.js new file mode 100644 index 0000000000..5f2638646d --- /dev/null +++ b/test/language/expressions/import.meta/syntax/escape-sequence-meta.js @@ -0,0 +1,34 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-left-hand-side-expressions +description: > + "meta" in import.meta must not contain escape sequences. +info: | + 5.1.5 Grammar Notation + + Terminal symbols of the lexical, RegExp, and numeric string grammars are shown in fixed width + font, both in the productions of the grammars and throughout this specification whenever the + text directly refers to such a terminal symbol. These are to appear in a script exactly as + written. All terminal symbol code points specified in this way are to be understood as the + appropriate Unicode code points from the Basic Latin range, as opposed to any similar-looking + code points from other Unicode ranges. + + 12.3 Left-Hand-Side Expressions + MetaProperty: + NewTarget + ImportMeta + + ImportMeta: + import.meta +flags: [module] +negative: + phase: parse + type: SyntaxError +features: [import.meta] +---*/ + +throw "Test262: This statement should not be evaluated."; + +import.m\u0065ta; diff --git a/test/language/expressions/import.meta/syntax/goal-async-function-params-or-body.js b/test/language/expressions/import.meta/syntax/goal-async-function-params-or-body.js new file mode 100644 index 0000000000..782c94c322 --- /dev/null +++ b/test/language/expressions/import.meta/syntax/goal-async-function-params-or-body.js @@ -0,0 +1,21 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-left-hand-side-expressions-static-semantics-early-errors +description: > + An Syntax Error is thrown when the syntactic goal symbol is AsyncFunctionBody or FormalParameters. +info: | + It is an early Syntax Error if Module is not the syntactic goal symbol. +features: [import.meta, async-functions] +---*/ + +var AsyncFunction = async function(){}.constructor; + +assert.throws(SyntaxError, function() { + AsyncFunction("import.meta"); +}, "import.meta in AsyncFunctionBody"); + +assert.throws(SyntaxError, function() { + AsyncFunction("a = import.meta", ""); +}, "import.meta in FormalParameters"); diff --git a/test/language/expressions/import.meta/syntax/goal-async-generator-params-or-body.js b/test/language/expressions/import.meta/syntax/goal-async-generator-params-or-body.js new file mode 100644 index 0000000000..47018f13f6 --- /dev/null +++ b/test/language/expressions/import.meta/syntax/goal-async-generator-params-or-body.js @@ -0,0 +1,21 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-left-hand-side-expressions-static-semantics-early-errors +description: > + An Syntax Error is thrown when the syntactic goal symbol is AsyncGeneratorBody or FormalParameters. +info: | + It is an early Syntax Error if Module is not the syntactic goal symbol. +features: [import.meta, async-iteration] +---*/ + +var AsyncGenerator = async function*(){}.constructor; + +assert.throws(SyntaxError, function() { + AsyncGenerator("import.meta"); +}, "import.meta in AsyncGeneratorBody"); + +assert.throws(SyntaxError, function() { + AsyncGenerator("a = import.meta", ""); +}, "import.meta in FormalParameters"); diff --git a/test/language/expressions/import.meta/syntax/goal-function-params-or-body.js b/test/language/expressions/import.meta/syntax/goal-function-params-or-body.js new file mode 100644 index 0000000000..e1030b61a8 --- /dev/null +++ b/test/language/expressions/import.meta/syntax/goal-function-params-or-body.js @@ -0,0 +1,19 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-left-hand-side-expressions-static-semantics-early-errors +description: > + An Syntax Error is thrown when the syntactic goal symbol is FunctionBody or FormalParameters. +info: | + It is an early Syntax Error if Module is not the syntactic goal symbol. +features: [import.meta] +---*/ + +assert.throws(SyntaxError, function() { + Function("import.meta"); +}, "import.meta in FunctionBody"); + +assert.throws(SyntaxError, function() { + Function("a = import.meta", ""); +}, "import.meta in FormalParameters"); diff --git a/test/language/expressions/import.meta/syntax/goal-generator-params-or-body.js b/test/language/expressions/import.meta/syntax/goal-generator-params-or-body.js new file mode 100644 index 0000000000..ac31a38140 --- /dev/null +++ b/test/language/expressions/import.meta/syntax/goal-generator-params-or-body.js @@ -0,0 +1,21 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-left-hand-side-expressions-static-semantics-early-errors +description: > + An Syntax Error is thrown when the syntactic goal symbol is GeneratorBody or FormalParameters. +info: | + It is an early Syntax Error if Module is not the syntactic goal symbol. +features: [import.meta, generators] +---*/ + +var Generator = function*(){}.constructor; + +assert.throws(SyntaxError, function() { + Generator("import.meta"); +}, "import.meta in GeneratorBody"); + +assert.throws(SyntaxError, function() { + Generator("a = import.meta", ""); +}, "import.meta in FormalParameters"); diff --git a/test/language/expressions/import.meta/syntax/goal-module-nested-function.js b/test/language/expressions/import.meta/syntax/goal-module-nested-function.js new file mode 100644 index 0000000000..f698e78d48 --- /dev/null +++ b/test/language/expressions/import.meta/syntax/goal-module-nested-function.js @@ -0,0 +1,16 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-left-hand-side-expressions-static-semantics-early-errors +description: > + No SyntaxError is thrown when import.meta appears in nested functions in module scripts. +info: | + It is an early Syntax Error if Module is not the syntactic goal symbol. +flags: [module] +features: [import.meta] +---*/ + +function f() { + import.meta; +} diff --git a/test/language/expressions/import.meta/syntax/goal-module.js b/test/language/expressions/import.meta/syntax/goal-module.js new file mode 100644 index 0000000000..8f5db47e1e --- /dev/null +++ b/test/language/expressions/import.meta/syntax/goal-module.js @@ -0,0 +1,14 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-left-hand-side-expressions-static-semantics-early-errors +description: > + No early Syntax Error is thrown when the syntactic goal symbol is Module. +info: | + It is an early Syntax Error if Module is not the syntactic goal symbol. +flags: [module] +features: [import.meta] +---*/ + +import.meta; diff --git a/test/language/expressions/import.meta/syntax/goal-script.js b/test/language/expressions/import.meta/syntax/goal-script.js new file mode 100644 index 0000000000..4f71123a77 --- /dev/null +++ b/test/language/expressions/import.meta/syntax/goal-script.js @@ -0,0 +1,18 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-left-hand-side-expressions-static-semantics-early-errors +description: > + An early Syntax Error is thrown when the syntactic goal symbol is Script. +info: | + It is an early Syntax Error if Module is not the syntactic goal symbol. +negative: + phase: early + type: SyntaxError +features: [import.meta] +---*/ + +throw "Test262: This statement should not be evaluated."; + +import.meta; diff --git a/test/language/expressions/import.meta/syntax/invalid-assignment-target-array-destructuring-expr.js b/test/language/expressions/import.meta/syntax/invalid-assignment-target-array-destructuring-expr.js new file mode 100644 index 0000000000..e21a7a5c81 --- /dev/null +++ b/test/language/expressions/import.meta/syntax/invalid-assignment-target-array-destructuring-expr.js @@ -0,0 +1,31 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-static-semantics-static-semantics-assignmenttargettype +description: > + import.meta is not a valid assignment target. +info: | + Static Semantics: AssignmentTargetType + + ImportMeta: + import.meta + + Return invalid. + + 12.15.5.1 Static Semantics: Early Errors + + DestructuringAssignmentTarget : LeftHandSideExpression + + It is a Syntax Error if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral + and AssignmentTargetType(LeftHandSideExpression) is not simple. +flags: [module] +negative: + phase: early + type: SyntaxError +features: [import.meta, destructuring-assignment] +---*/ + +throw "Test262: This statement should not be evaluated."; + +[import.meta] = []; diff --git a/test/language/expressions/import.meta/syntax/invalid-assignment-target-array-rest-destructuring-expr.js b/test/language/expressions/import.meta/syntax/invalid-assignment-target-array-rest-destructuring-expr.js new file mode 100644 index 0000000000..f854167751 --- /dev/null +++ b/test/language/expressions/import.meta/syntax/invalid-assignment-target-array-rest-destructuring-expr.js @@ -0,0 +1,31 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-static-semantics-static-semantics-assignmenttargettype +description: > + import.meta is not a valid assignment target. +info: | + Static Semantics: AssignmentTargetType + + ImportMeta: + import.meta + + Return invalid. + + 12.15.5.1 Static Semantics: Early Errors + + DestructuringAssignmentTarget : LeftHandSideExpression + + It is a Syntax Error if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral + and AssignmentTargetType(LeftHandSideExpression) is not simple. +flags: [module] +negative: + phase: early + type: SyntaxError +features: [import.meta, destructuring-assignment] +---*/ + +throw "Test262: This statement should not be evaluated."; + +[...import.meta] = []; diff --git a/test/language/expressions/import.meta/syntax/invalid-assignment-target-assignment-expr.js b/test/language/expressions/import.meta/syntax/invalid-assignment-target-assignment-expr.js new file mode 100644 index 0000000000..a7032044d9 --- /dev/null +++ b/test/language/expressions/import.meta/syntax/invalid-assignment-target-assignment-expr.js @@ -0,0 +1,31 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-static-semantics-static-semantics-assignmenttargettype +description: > + import.meta is not a valid assignment target. +info: | + Static Semantics: AssignmentTargetType + + ImportMeta: + import.meta + + Return invalid. + + 12.15.1 Static Semantics: Early Errors + + AssignmentExpression : LeftHandSideExpression = AssignmentExpression + + It is an early Reference Error if LeftHandSideExpression is neither an ObjectLiteral nor an + ArrayLiteral and AssignmentTargetType of LeftHandSideExpression is invalid. +flags: [module] +negative: + phase: early + type: ReferenceError +features: [import.meta] +---*/ + +throw "Test262: This statement should not be evaluated."; + +import.meta = 0; diff --git a/test/language/expressions/import.meta/syntax/invalid-assignment-target-for-await-of-loop.js b/test/language/expressions/import.meta/syntax/invalid-assignment-target-for-await-of-loop.js new file mode 100644 index 0000000000..f171c344ef --- /dev/null +++ b/test/language/expressions/import.meta/syntax/invalid-assignment-target-for-await-of-loop.js @@ -0,0 +1,32 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-static-semantics-static-semantics-assignmenttargettype +description: > + import.meta is not a valid assignment target. +info: | + Static Semantics: AssignmentTargetType + + ImportMeta: + import.meta + + Return invalid. + + 13.7.5.1 Static Semantics: Early Errors + IterationStatement: + for await ( LeftHandSideExpression of AssignmentExpression ) Statement + + It is a Syntax Error if AssignmentTargetType of LeftHandSideExpression is not simple. +flags: [module] +negative: + phase: early + type: SyntaxError +features: [import.meta, async-iteration] +---*/ + +throw "Test262: This statement should not be evaluated."; + +async function* f() { + for await (import.meta of null) ; +} diff --git a/test/language/expressions/import.meta/syntax/invalid-assignment-target-for-in-loop.js b/test/language/expressions/import.meta/syntax/invalid-assignment-target-for-in-loop.js new file mode 100644 index 0000000000..d463a030ee --- /dev/null +++ b/test/language/expressions/import.meta/syntax/invalid-assignment-target-for-in-loop.js @@ -0,0 +1,30 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-static-semantics-static-semantics-assignmenttargettype +description: > + import.meta is not a valid assignment target. +info: | + Static Semantics: AssignmentTargetType + + ImportMeta: + import.meta + + Return invalid. + + 13.7.5.1 Static Semantics: Early Errors + IterationStatement: + for ( LeftHandSideExpression in Expression ) Statement + + It is a Syntax Error if AssignmentTargetType of LeftHandSideExpression is not simple. +flags: [module] +negative: + phase: early + type: SyntaxError +features: [import.meta] +---*/ + +throw "Test262: This statement should not be evaluated."; + +for (import.meta in null) ; diff --git a/test/language/expressions/import.meta/syntax/invalid-assignment-target-for-of-loop.js b/test/language/expressions/import.meta/syntax/invalid-assignment-target-for-of-loop.js new file mode 100644 index 0000000000..c921e9853b --- /dev/null +++ b/test/language/expressions/import.meta/syntax/invalid-assignment-target-for-of-loop.js @@ -0,0 +1,30 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-static-semantics-static-semantics-assignmenttargettype +description: > + import.meta is not a valid assignment target. +info: | + Static Semantics: AssignmentTargetType + + ImportMeta: + import.meta + + Return invalid. + + 13.7.5.1 Static Semantics: Early Errors + IterationStatement: + for ( LeftHandSideExpression of AssignmentExpression ) Statement + + It is a Syntax Error if AssignmentTargetType of LeftHandSideExpression is not simple. +flags: [module] +negative: + phase: early + type: SyntaxError +features: [import.meta] +---*/ + +throw "Test262: This statement should not be evaluated."; + +for (import.meta of null) ; diff --git a/test/language/expressions/import.meta/syntax/invalid-assignment-target-object-destructuring-expr.js b/test/language/expressions/import.meta/syntax/invalid-assignment-target-object-destructuring-expr.js new file mode 100644 index 0000000000..9fad1e15b3 --- /dev/null +++ b/test/language/expressions/import.meta/syntax/invalid-assignment-target-object-destructuring-expr.js @@ -0,0 +1,31 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-static-semantics-static-semantics-assignmenttargettype +description: > + import.meta is not a valid assignment target. +info: | + Static Semantics: AssignmentTargetType + + ImportMeta: + import.meta + + Return invalid. + + 12.15.5.1 Static Semantics: Early Errors + + DestructuringAssignmentTarget : LeftHandSideExpression + + It is a Syntax Error if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral + and AssignmentTargetType(LeftHandSideExpression) is not simple. +flags: [module] +negative: + phase: early + type: SyntaxError +features: [import.meta, destructuring-assignment] +---*/ + +throw "Test262: This statement should not be evaluated."; + +({a: import.meta} = {}); diff --git a/test/language/expressions/import.meta/syntax/invalid-assignment-target-object-rest-destructuring-expr.js b/test/language/expressions/import.meta/syntax/invalid-assignment-target-object-rest-destructuring-expr.js new file mode 100644 index 0000000000..fd9f4a9eab --- /dev/null +++ b/test/language/expressions/import.meta/syntax/invalid-assignment-target-object-rest-destructuring-expr.js @@ -0,0 +1,31 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-static-semantics-static-semantics-assignmenttargettype +description: > + import.meta is not a valid assignment target. +info: | + Static Semantics: AssignmentTargetType + + ImportMeta: + import.meta + + Return invalid. + + 12.15.5.1 Static Semantics: Early Errors + + DestructuringAssignmentTarget : LeftHandSideExpression + + It is a Syntax Error if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral + and AssignmentTargetType(LeftHandSideExpression) is not simple. +flags: [module] +negative: + phase: early + type: SyntaxError +features: [import.meta, destructuring-assignment, object-rest] +---*/ + +throw "Test262: This statement should not be evaluated."; + +({...import.meta} = {}); diff --git a/test/language/expressions/import.meta/syntax/invalid-assignment-target-update-expr.js b/test/language/expressions/import.meta/syntax/invalid-assignment-target-update-expr.js new file mode 100644 index 0000000000..3cd7213d02 --- /dev/null +++ b/test/language/expressions/import.meta/syntax/invalid-assignment-target-update-expr.js @@ -0,0 +1,32 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-static-semantics-static-semantics-assignmenttargettype +description: > + import.meta is not a valid assignment target. +info: | + Static Semantics: AssignmentTargetType + + ImportMeta: + import.meta + + Return invalid. + + 12.4.1 Static Semantics: Early Errors + + UpdateExpression: + LeftHandSideExpression++ + LeftHandSideExpression-- + + It is an early Reference Error if AssignmentTargetType of LeftHandSideExpression is invalid. +flags: [module] +negative: + phase: early + type: ReferenceError +features: [import.meta] +---*/ + +throw "Test262: This statement should not be evaluated."; + +import.meta++;