diff --git a/src/dynamic-import/import-attributes-trailing-comma-first.case b/src/dynamic-import/import-attributes-trailing-comma-first.case new file mode 100644 index 0000000000..dc33458cc8 --- /dev/null +++ b/src/dynamic-import/import-attributes-trailing-comma-first.case @@ -0,0 +1,14 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: ImportCall trailing comma following first parameter +template: syntax/valid +info: | + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) +features: [import-assertions] +---*/ + +//- import +import('./empty_FIXTURE.js',) diff --git a/src/dynamic-import/import-attributes-trailing-comma-second.case b/src/dynamic-import/import-attributes-trailing-comma-second.case new file mode 100644 index 0000000000..f82af0a93a --- /dev/null +++ b/src/dynamic-import/import-attributes-trailing-comma-second.case @@ -0,0 +1,14 @@ +// Copyright (C) 2021 V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: ImportCall trailing comma following second parameter +template: syntax/valid +info: | + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) +features: [import-assertions] +---*/ + +//- import +import('./empty_FIXTURE.js', {},) diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-await-expr.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-await-expr.js new file mode 100644 index 0000000000..966ab94369 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-await-expr.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ImportCall parameter list forwards the Await production parameter - AwaitExpression +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall[Yield, Await]: + import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) +features: [dynamic-import, import-assertions, async-functions] +flags: [async] +---*/ + +(async function () { + return import('./2nd-param_FIXTURE.js', await undefined); +}()) + .then(function(module) { + assert.sameValue(module.default, 262); + }) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-await-ident.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-await-ident.js new file mode 100644 index 0000000000..d13ca53b20 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-await-ident.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ImportCall parameter list forwards the Await production parameter - IdentifierReference +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall[Yield, Await]: + import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) +features: [dynamic-import, import-assertions, async-functions] +flags: [async] +---*/ + +function await() {} + +import('./2nd-param_FIXTURE.js', await(undefined)) + .then(function(module) { + assert.sameValue(module.default, 262); + }) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-evaluation-abrupt-return.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-evaluation-abrupt-return.js new file mode 100644 index 0000000000..6da4a5482b --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-evaluation-abrupt-return.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Forwards "return" completion when evaluating second parameter +esid: sec-import-call-runtime-semantics-evaluation +info: | + 2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] ) + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let specifierRef be the result of evaluating specifierExpression. + 3. Let specifier be ? GetValue(specifierRef). + 4. If optionsExpression is present, then + a. Let optionsRef be the result of evaluating optionsExpression. + b. Let options be ? GetValue(optionsRef). + [...] +features: [dynamic-import, import-assertions] +---*/ + +var beforeCount = 0; +var afterCount = 0; +var iter = function*() { + beforeCount += 1, import('', yield), afterCount += 1; +}(); + +iter.next(); +var result = iter.return(595); + +assert.sameValue(result.done, true); +assert.sameValue(result.value, 595); +assert.sameValue(beforeCount, 1); +assert.sameValue(afterCount, 0); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-evaluation-abrupt-throw.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-evaluation-abrupt-throw.js new file mode 100644 index 0000000000..e5e6619096 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-evaluation-abrupt-throw.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Forwards "throw" completion when evaluating second parameter +esid: sec-import-call-runtime-semantics-evaluation +info: | + 2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] ) + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let specifierRef be the result of evaluating specifierExpression. + 3. Let specifier be ? GetValue(specifierRef). + 4. If optionsExpression is present, then + a. Let optionsRef be the result of evaluating optionsExpression. + b. Let options be ? GetValue(optionsRef). + [...] +features: [dynamic-import, import-assertions] +---*/ + +var beforeCount = 0; +var afterCount = 0; +function throwError() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + beforeCount += 1, import('', throwError()), afterCount += 1; +}); + +assert.sameValue(beforeCount, 1); +assert.sameValue(afterCount, 0); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-evaluation-sequence.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-evaluation-sequence.js new file mode 100644 index 0000000000..9795c4bada --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-evaluation-sequence.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Evaluates parameters in correct sequence +esid: sec-import-call-runtime-semantics-evaluation +info: | + 2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] ) + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Let specifierRef be the result of evaluating specifierExpression. + 3. Let specifier be ? GetValue(specifierRef). + 4. If optionsExpression is present, then + a. Let optionsRef be the result of evaluating optionsExpression. + b. Let options be ? GetValue(optionsRef). + [...] +features: [dynamic-import, import-assertions] +---*/ + +var log = []; + +import(log.push('first'), (log.push('second'), undefined)) + .then(null, function() {}); + +assert.sameValue(log.length, 2); +assert.sameValue(log[0], 'first'); +assert.sameValue(log[1], 'second'); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-get-with-error.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-get-with-error.js new file mode 100644 index 0000000000..d7bb7d8c04 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-get-with-error.js @@ -0,0 +1,36 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Rejects promise when accessing "assert" property throws an error +esid: sec-import-call-runtime-semantics-evaluation +info: | + 2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] ) + [...] + 6. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 7. Let specifierString be ToString(specifier). + 8. IfAbruptRejectPromise(specifierString, promiseCapability). + 9. Let assertions be a new empty List. + 10. If options is not undefined, then + a. If Type(options) is not Object, + [...] + b. Let assertionsObj be Get(options, "assert"). + c. IfAbruptRejectPromise(assertionsObj, promiseCapability). + [...] +features: [dynamic-import, import-assertions] +flags: [async] +---*/ + +var thrown = new Test262Error(); +var options = { + get assert() { + throw thrown; + } +}; + +import('./2nd-param_FIXTURE.js', options) + .then(function() { + throw new Test262Error('Expected an error, but observed no error'); + }, function(caught) { + assert.sameValue(thrown, caught); + }) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-in.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-in.js new file mode 100644 index 0000000000..6d8ac2b0eb --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-in.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: ImportCall parameter list enables the Yield production parameter +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall[Yield, Await]: + import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) +features: [dynamic-import, import-assertions] +flags: [async] +---*/ + +var promise; + +for (promise = import('./2nd-param_FIXTURE.js', 'test262' in {} || undefined); false; ) ; + +promise + .then(function(module) { + assert.sameValue(module.default, 262); + }) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-non-object.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-non-object.js new file mode 100644 index 0000000000..28b6e573d1 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-non-object.js @@ -0,0 +1,40 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Rejects promise when the second argument is neither undefined nor an object +esid: sec-import-call-runtime-semantics-evaluation +info: | + 2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] ) + [...] + 6. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 7. Let specifierString be ToString(specifier). + 8. IfAbruptRejectPromise(specifierString, promiseCapability). + 9. Let assertions be a new empty List. + 10. If options is not undefined, then + a. If Type(options) is not Object, + i. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »). + ii. Return promiseCapability.[[Promise]]. + [...] +features: [dynamic-import, import-assertions, Symbol, BigInt] +flags: [async] +---*/ + +function test(promise, valueType) { + return promise.then(function() { + throw new Test262Error('Promise for ' + valueType + ' was not rejected.'); + }, function(error) { + assert.sameValue(error.constructor, TypeError, valueType); + }); +} + +Promise.all([ + test(import('./2nd-param_FIXTURE.js', null), 'null'), + test(import('./2nd-param_FIXTURE.js', false), 'boolean'), + test(import('./2nd-param_FIXTURE.js', 23), 'number'), + test(import('./2nd-param_FIXTURE.js', ''), 'string'), + test(import('./2nd-param_FIXTURE.js', Symbol('')), 'symbol'), + test(import('./2nd-param_FIXTURE.js', 23n), 'bigint') + ]) + .then(function() {}) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-trailing-comma-fulfill.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-trailing-comma-fulfill.js new file mode 100644 index 0000000000..c806f3e683 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-trailing-comma-fulfill.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ImportCall parameter list supports an optional trailing comma (fulfillment + semantics) +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall[Yield, Await]: + import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) +features: [dynamic-import, import-assertions] +flags: [async] +---*/ + +import('./2nd-param_FIXTURE.js', {},) + .then(function(module) { + assert.sameValue(module.default, 262); + }) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-trailing-comma-reject.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-trailing-comma-reject.js new file mode 100644 index 0000000000..3970c745b6 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-trailing-comma-reject.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ImportCall parameter list supports an optional trailing comma (rejection + semantics) +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall[Yield, Await]: + import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) +features: [dynamic-import, import-assertions] +flags: [async] +---*/ + +var thrown = new Test262Error(); + +import({toString: function() { throw thrown; } }, {},) + .then(function() { + throw new Test262Error('Expected promise to be rejected, but it was fulfilled.'); + }, function(caught) { + assert.sameValue(thrown, caught); + }) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-enumeration-abrupt.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-enumeration-abrupt.js new file mode 100644 index 0000000000..282c7613aa --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-enumeration-abrupt.js @@ -0,0 +1,43 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Reports abrupt completions produced by attributes enumeration +esid: sec-import-call-runtime-semantics-evaluation +info: | + 2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] ) + [...] + 6. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 7. Let specifierString be ToString(specifier). + 8. IfAbruptRejectPromise(specifierString, promiseCapability). + 9. Let assertions be a new empty List. + 10. If options is not undefined, then + a. If Type(options) is not Object, + [...] + b. Let assertionsObj be Get(options, "assert"). + c. IfAbruptRejectPromise(assertionsObj, promiseCapability). + d. If assertionsObj is not undefined, + i. If Type(assertionsObj) is not Object, + [...] + ii. Let keys be EnumerableOwnPropertyNames(assertionsObj, key). + iii. IfAbruptRejectPromise(keys, promiseCapability). + [...] +features: [dynamic-import, import-assertions, Proxy] +flags: [async] +---*/ + +var thrown = new Test262Error(); +var options = { + assert: new Proxy({}, { + ownKeys: function() { + throw thrown; + }, + }) +}; + +import('./2nd-param_FIXTURE.js', options) + .then(function() { + throw new Test262Error('Expected promise to be rejected, but promise was fulfilled.'); + }, function(error) { + assert.sameValue(error, thrown); + }) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-enumeration-enumerable.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-enumeration-enumerable.js new file mode 100644 index 0000000000..341eb4d1d8 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-enumeration-enumerable.js @@ -0,0 +1,60 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Follows the semantics of the EnumerableOwnPropertyNames abstract operation + during attributes enumeration +esid: sec-import-call-runtime-semantics-evaluation +info: | + 2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] ) + [...] + 6. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 7. Let specifierString be ToString(specifier). + 8. IfAbruptRejectPromise(specifierString, promiseCapability). + 9. Let assertions be a new empty List. + 10. If options is not undefined, then + a. If Type(options) is not Object, + [...] + b. Let assertionsObj be Get(options, "assert"). + c. IfAbruptRejectPromise(assertionsObj, promiseCapability). + d. If assertionsObj is not undefined, + i. If Type(assertionsObj) is not Object, + [...] + ii. Let keys be EnumerableOwnPropertyNames(assertionsObj, key). + [...] +features: [dynamic-import, import-assertions, json-modules, Symbol, Proxy] +flags: [async] +---*/ + +var symbol = Symbol(''); +var target = { + type: "json" +}; +var descriptors = { + type: {configurable: true, enumerable: true} +}; +var log = []; + +var options = { + assert: new Proxy({}, { + ownKeys: function() { + return ["type"]; + }, + get(_, name) { + log.push(name); + return "json"; + }, + getOwnPropertyDescriptor(target, name) { + return {configurable: true, enumerable: true, value: "json"}; + }, + }) +}; + +import('./2nd-param_FIXTURE.json', options) + .then(function(module) { + assert.sameValue(module.default, 262); + }) + .then($DONE, $DONE); + +assert.sameValue(log.length, 1); +assert.sameValue(log[0], "type") diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-enumeration.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-enumeration.js new file mode 100644 index 0000000000..cfa9d28a8f --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-enumeration.js @@ -0,0 +1,58 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Follows the semantics of the EnumerableOwnPropertyNames abstract operation + during attributes enumeration +esid: sec-import-call-runtime-semantics-evaluation +info: | + 2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] ) + [...] + 6. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 7. Let specifierString be ToString(specifier). + 8. IfAbruptRejectPromise(specifierString, promiseCapability). + 9. Let assertions be a new empty List. + 10. If options is not undefined, then + a. If Type(options) is not Object, + [...] + b. Let assertionsObj be Get(options, "assert"). + c. IfAbruptRejectPromise(assertionsObj, promiseCapability). + d. If assertionsObj is not undefined, + i. If Type(assertionsObj) is not Object, + [...] + ii. Let keys be EnumerableOwnPropertyNames(assertionsObj, key). + [...] +features: [dynamic-import, import-assertions, Symbol, Proxy] +flags: [async] +---*/ + +var symbol = Symbol(''); +var target = { + [symbol]: '', + unreported: '', + nonEnumerable: '' +}; +var descriptors = { + [symbol]: {configurable: true, enumerable: true}, + nonEnumerable: {configurable: true, enumerable: false} +}; + +var options = { + assert: new Proxy({}, { + ownKeys: function() { + return [symbol, 'nonEnumerable', 'absent']; + }, + get() { + throw new Error("Should not be called"); + }, + getOwnPropertyDescriptor(target, name) { + return descriptors[name]; + } + }) +}; + +import('./2nd-param_FIXTURE.js', options) + .then(function(module) { + assert.sameValue(module.default, 262); + }) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-non-object.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-non-object.js new file mode 100644 index 0000000000..d685ee83d3 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-non-object.js @@ -0,0 +1,47 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Rejects promise when the `assert` property of the second argument is neither + undefined nor an object +esid: sec-import-call-runtime-semantics-evaluation +info: | + 2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] ) + [...] + 6. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 7. Let specifierString be ToString(specifier). + 8. IfAbruptRejectPromise(specifierString, promiseCapability). + 9. Let assertions be a new empty List. + 10. If options is not undefined, then + a. If Type(options) is not Object, + [...] + b. Let assertionsObj be Get(options, "assert"). + c. IfAbruptRejectPromise(assertionsObj, promiseCapability). + d. If assertionsObj is not undefined, + i. If Type(assertionsObj) is not Object, + 1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a + newly created TypeError object »). + 2. Return promiseCapability.[[Promise]]. + [...] +features: [dynamic-import, import-assertions, Symbol, BigInt] +flags: [async] +---*/ + +function test(promise, valueType) { + return promise.then(function() { + throw new Test262Error('Promise for ' + valueType + ' was not rejected.'); + }, function(error) { + assert.sameValue(error.constructor, TypeError, valueType); + }); +} + +Promise.all([ + test(import('./2nd-param_FIXTURE.js', {assert:null}), 'null'), + test(import('./2nd-param_FIXTURE.js', {assert:false}), 'boolean'), + test(import('./2nd-param_FIXTURE.js', {assert:23}), 'number'), + test(import('./2nd-param_FIXTURE.js', {assert:''}), 'string'), + test(import('./2nd-param_FIXTURE.js', {assert:Symbol('')}), 'symbol'), + test(import('./2nd-param_FIXTURE.js', {assert:23n}), 'bigint') + ]) + .then(function() {}) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-undefined.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-undefined.js new file mode 100644 index 0000000000..bdd4003d38 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-undefined.js @@ -0,0 +1,36 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Accepts undefined for the `assert` property of the second argument +esid: sec-import-call-runtime-semantics-evaluation +info: | + 2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] ) + [...] + 6. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 7. Let specifierString be ToString(specifier). + 8. IfAbruptRejectPromise(specifierString, promiseCapability). + 9. Let assertions be a new empty List. + 10. If options is not undefined, then + a. If Type(options) is not Object, + [...] + b. Let assertionsObj be Get(options, "assert"). + c. IfAbruptRejectPromise(assertionsObj, promiseCapability). + d. If assertionsObj is not undefined, + i. If Type(assertionsObj) is not Object, + 1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a + newly created TypeError object »). + 2. Return promiseCapability.[[Promise]]. + [...] +features: [dynamic-import, import-assertions, Symbol, BigInt] +flags: [async] +---*/ + +Promise.all([ + import('./2nd-param_FIXTURE.js', {}), + import('./2nd-param_FIXTURE.js', {assert:undefined}), + ]) + .then(function(values) { + assert.sameValue(values[0].default, 262); + assert.sameValue(values[1].default, 262); + }) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-value-abrupt.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-value-abrupt.js new file mode 100644 index 0000000000..e840a71950 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-value-abrupt.js @@ -0,0 +1,34 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Rejects promise when retrieving a value of the `assert` object produces an + abrupt completion +esid: sec-import-call-runtime-semantics-evaluation +info: | + 2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] ) + [...] + 10. If options is not undefined, then + [...] + d. If assertionsObj is not undefined, + [...] + ii. Let keys be EnumerableOwnPropertyNames(assertionsObj, key). + iii. IfAbruptRejectPromise(keys, promiseCapability). + iv. Let supportedAssertions be ! HostGetSupportedImportAssertions(). + v. For each String key of keys, + 1. Let value be Get(assertionsObj, key). + 2. IfAbruptRejectPromise(value, promiseCapability). + [...] +features: [dynamic-import, import-assertions] +flags: [async] +---*/ + +var thrown = new Test262Error(); + +import('./2nd-param_FIXTURE.js', {assert:{get ''() { throw thrown; }}}) + .then(function() { + throw new Test262Error('Expected promise to be rejected, but it was fulfilled'); + }, function(error) { + assert.sameValue(error, thrown); + }) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-value-non-string.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-value-non-string.js new file mode 100644 index 0000000000..aa71b1c282 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-with-value-non-string.js @@ -0,0 +1,47 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Rejects promise when any property of the `assert` object is not a string +esid: sec-import-call-runtime-semantics-evaluation +info: | + 2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] ) + [...] + 10. If options is not undefined, then + [...] + d. If assertionsObj is not undefined, + [...] + ii. Let keys be EnumerableOwnPropertyNames(assertionsObj, key). + iii. IfAbruptRejectPromise(keys, promiseCapability). + iv. Let supportedAssertions be ! HostGetSupportedImportAssertions(). + v. For each String key of keys, + 1. Let value be Get(assertionsObj, key). + 2. IfAbruptRejectPromise(value, promiseCapability). + 3. If Type(value) is not String, then + a. Perform ! Call(promiseCapability.[[Reject]], undefined, « a + newly created TypeError object »). + b. Return promiseCapability.[[Promise]]. + [...] +features: [dynamic-import, import-assertions, Symbol, BigInt] +flags: [async] +---*/ + +function test(promise, valueType) { + return promise.then(function() { + throw new Test262Error('Promise for ' + valueType + ' was not rejected.'); + }, function(error) { + assert.sameValue(error.constructor, TypeError, valueType); + }); +} + +Promise.all([ + test(import('./2nd-param_FIXTURE.js', {assert:{'': undefined}}), 'undefined'), + test(import('./2nd-param_FIXTURE.js', {assert:{'': null}}), 'null'), + test(import('./2nd-param_FIXTURE.js', {assert:{'': false}}), 'boolean'), + test(import('./2nd-param_FIXTURE.js', {assert:{'': 23}}), 'number'), + test(import('./2nd-param_FIXTURE.js', {assert:{'': Symbol('')}}), 'symbol'), + test(import('./2nd-param_FIXTURE.js', {assert:{'': 23n}}), 'bigint'), + test(import('./2nd-param_FIXTURE.js', {assert:{'': {}}}), 'object') + ]) + .then(function() {}) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-yield-expr.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-yield-expr.js new file mode 100644 index 0000000000..b1482ac9e8 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-yield-expr.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ImportCall parameter list forwards the Yield production parameter - YieldExpression +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall[Yield, Await]: + import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) +features: [dynamic-import, import-assertions] +flags: [async] +---*/ + +var promise; + +var iter = (function * () { + promise = import('./2nd-param_FIXTURE.js', yield); +}()); + +iter.next(); + +assert.sameValue(promise, undefined); + +iter.next(); + +promise + .then(function(module) { + assert.sameValue(module.default, 262); + }) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-yield-ident-invalid.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-yield-ident-invalid.js new file mode 100644 index 0000000000..56971e8031 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-yield-ident-invalid.js @@ -0,0 +1,19 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ImportCall parameter list forwards the Yield production parameter - invalid IdentifierReference +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall[Yield, Await]: + import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) +features: [dynamic-import, import-assertions] +flags: [onlyStrict] +negative: + phase: parse + type: SyntaxError +---*/ +$DONOTEVALUATE(); + +import('./empty_FIXTURE.js', yield); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param-yield-ident-valid.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param-yield-ident-valid.js new file mode 100644 index 0000000000..39a8fe7d6e --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param-yield-ident-valid.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ImportCall parameter list forwards the Yield production parameter - valid IdentifierReference +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall[Yield, Await]: + import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) +features: [dynamic-import, import-assertions] +flags: [async, noStrict] +---*/ + +var yield; + +import('./2nd-param_FIXTURE.js', yield) + .then(function(module) { + assert.sameValue(module.default, 262); + }) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param_FIXTURE.js b/test/language/expressions/dynamic-import/import-attributes/2nd-param_FIXTURE.js new file mode 100644 index 0000000000..fc9f2fa021 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param_FIXTURE.js @@ -0,0 +1,3 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +export default 262; diff --git a/test/language/expressions/dynamic-import/import-attributes/2nd-param_FIXTURE.json b/test/language/expressions/dynamic-import/import-attributes/2nd-param_FIXTURE.json new file mode 100644 index 0000000000..5484d82917 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/2nd-param_FIXTURE.json @@ -0,0 +1 @@ +262 diff --git a/test/language/expressions/dynamic-import/import-attributes/trailing-comma-fulfill.js b/test/language/expressions/dynamic-import/import-attributes/trailing-comma-fulfill.js new file mode 100644 index 0000000000..0d3689b37e --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/trailing-comma-fulfill.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ImportCall parameter list supports an optional trailing comma (fulfillment + semantics) +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall[Yield, Await]: + import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) +features: [dynamic-import, import-assertions] +flags: [async] +---*/ + +import('./2nd-param_FIXTURE.js',) + .then(function(module) { + assert.sameValue(module.default, 262); + }) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/import-attributes/trailing-comma-reject.js b/test/language/expressions/dynamic-import/import-attributes/trailing-comma-reject.js new file mode 100644 index 0000000000..d257eccc32 --- /dev/null +++ b/test/language/expressions/dynamic-import/import-attributes/trailing-comma-reject.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ImportCall parameter list supports an optional trailing comma (rejection + semantics) +esid: sec-import-call-runtime-semantics-evaluation +info: | + ImportCall[Yield, Await]: + import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) +features: [dynamic-import, import-assertions] +flags: [async] +---*/ + +var thrown = new Test262Error(); + +import({toString: function() { throw thrown; } },) + .then(function() { + throw new Test262Error('Expected promise to be rejected, but it was fulfilled.'); + }, function(caught) { + assert.sameValue(thrown, caught); + }) + .then($DONE, $DONE); diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-arrow-assignment-expression-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-arrow-assignment-expression-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..ee70c0c753 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-arrow-assignment-expression-import-attributes-trailing-comma-first.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-arrow-assignment-expression.template +/*--- +description: ImportCall trailing comma following first parameter (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +let f = () => import('./empty_FIXTURE.js',); diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-arrow-assignment-expression-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-arrow-assignment-expression-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..8cdc0083d6 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-arrow-assignment-expression-import-attributes-trailing-comma-second.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-arrow-assignment-expression.template +/*--- +description: ImportCall trailing comma following second parameter (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +let f = () => import('./empty_FIXTURE.js', {},); diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-arrow-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-arrow-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..2c1fd57c1a --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-arrow-import-attributes-trailing-comma-first.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-arrow.template +/*--- +description: ImportCall trailing comma following first parameter (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +let f = () => { + import('./empty_FIXTURE.js',); +}; diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-arrow-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-arrow-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..ab306e90b1 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-arrow-import-attributes-trailing-comma-second.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-arrow.template +/*--- +description: ImportCall trailing comma following second parameter (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +let f = () => { + import('./empty_FIXTURE.js', {},); +}; diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-async-arrow-function-await-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-async-arrow-function-await-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..1e67cd0508 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-async-arrow-function-await-import-attributes-trailing-comma-first.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-async-arrow-fn-await.template +/*--- +description: ImportCall trailing comma following first parameter (nested in async arrow function) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +(async () => { + await import('./empty_FIXTURE.js',) +}); diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-async-arrow-function-await-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-async-arrow-function-await-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..3aa524423f --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-async-arrow-function-await-import-attributes-trailing-comma-second.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-async-arrow-fn-await.template +/*--- +description: ImportCall trailing comma following second parameter (nested in async arrow function) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +(async () => { + await import('./empty_FIXTURE.js', {},) +}); diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..11cea95efd --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-import-attributes-trailing-comma-first.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-async-arrow-fn-return-await.template +/*--- +description: ImportCall trailing comma following first parameter (nested in async arrow function, returned) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +(async () => await import('./empty_FIXTURE.js',)); diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..71eb1dfec5 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-async-arrow-function-return-await-import-attributes-trailing-comma-second.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-async-arrow-fn-return-await.template +/*--- +description: ImportCall trailing comma following second parameter (nested in async arrow function, returned) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +(async () => await import('./empty_FIXTURE.js', {},)); diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-await-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-await-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..46a3fc62f9 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-await-import-attributes-trailing-comma-first.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-async-function-await.template +/*--- +description: ImportCall trailing comma following first parameter (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +async function f() { + await import('./empty_FIXTURE.js',); +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-await-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-await-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..94d52ebae5 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-await-import-attributes-trailing-comma-second.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-async-function-await.template +/*--- +description: ImportCall trailing comma following second parameter (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +async function f() { + await import('./empty_FIXTURE.js', {},); +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..00529863f2 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-import-attributes-trailing-comma-first.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-async-function.template +/*--- +description: ImportCall trailing comma following first parameter (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +async function f() { + import('./empty_FIXTURE.js',); +} + diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..6e5bf9c128 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-import-attributes-trailing-comma-second.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-async-function.template +/*--- +description: ImportCall trailing comma following second parameter (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +async function f() { + import('./empty_FIXTURE.js', {},); +} + diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-return-await-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-return-await-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..e4875c8f16 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-return-await-import-attributes-trailing-comma-first.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-async-function-return-await.template +/*--- +description: ImportCall trailing comma following first parameter (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +async function f() { + return await import('./empty_FIXTURE.js',); +} + diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-return-await-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-return-await-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..1425fe5c66 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-async-function-return-await-import-attributes-trailing-comma-second.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-async-function-return-await.template +/*--- +description: ImportCall trailing comma following second parameter (nested arrow syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +async function f() { + return await import('./empty_FIXTURE.js', {},); +} + diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-async-gen-await-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-async-gen-await-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..5a75b28375 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-async-gen-await-import-attributes-trailing-comma-first.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-async-generator-await.template +/*--- +description: ImportCall trailing comma following first parameter (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import, async-iteration] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +async function * f() { + await import('./empty_FIXTURE.js',) +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-async-gen-await-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-async-gen-await-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..246d23c35d --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-async-gen-await-import-attributes-trailing-comma-second.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-async-generator-await.template +/*--- +description: ImportCall trailing comma following second parameter (nested in async generator, awaited) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import, async-iteration] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +async function * f() { + await import('./empty_FIXTURE.js', {},) +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-block-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-block-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..98a6cb4c79 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-block-import-attributes-trailing-comma-first.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-block.template +/*--- +description: ImportCall trailing comma following first parameter (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +{ + import('./empty_FIXTURE.js',); +}; diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-block-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-block-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..8b500f33fe --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-block-import-attributes-trailing-comma-second.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-block.template +/*--- +description: ImportCall trailing comma following second parameter (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +{ + import('./empty_FIXTURE.js', {},); +}; diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-block-labeled-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-block-labeled-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..f4428b8b02 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-block-labeled-import-attributes-trailing-comma-first.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-block-labeled.template +/*--- +description: ImportCall trailing comma following first parameter (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +label: { + import('./empty_FIXTURE.js',); +}; diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-block-labeled-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-block-labeled-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..0b9ba0a533 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-block-labeled-import-attributes-trailing-comma-second.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-block-labeled.template +/*--- +description: ImportCall trailing comma following second parameter (nested block syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +label: { + import('./empty_FIXTURE.js', {},); +}; diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-do-while-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-do-while-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..8103467af0 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-do-while-import-attributes-trailing-comma-first.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-do-while.template +/*--- +description: ImportCall trailing comma following first parameter (nested do while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +do { + import('./empty_FIXTURE.js',); +} while (false); diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-do-while-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-do-while-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..c324831202 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-do-while-import-attributes-trailing-comma-second.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-do-while.template +/*--- +description: ImportCall trailing comma following second parameter (nested do while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +do { + import('./empty_FIXTURE.js', {},); +} while (false); diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-else-braceless-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-else-braceless-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..21137c2ab8 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-else-braceless-import-attributes-trailing-comma-first.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-else-braceless.template +/*--- +description: ImportCall trailing comma following first parameter (nested else syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +if (false) { + +} else import('./empty_FIXTURE.js',); diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-else-braceless-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-else-braceless-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..da4e95b116 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-else-braceless-import-attributes-trailing-comma-second.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-else-braceless.template +/*--- +description: ImportCall trailing comma following second parameter (nested else syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +if (false) { + +} else import('./empty_FIXTURE.js', {},); diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-else-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-else-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..ab16626725 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-else-import-attributes-trailing-comma-first.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-else.template +/*--- +description: ImportCall trailing comma following first parameter (nested else syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +if (false) { + +} else { + import('./empty_FIXTURE.js',); +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-else-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-else-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..2520e5aedf --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-else-import-attributes-trailing-comma-second.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-else.template +/*--- +description: ImportCall trailing comma following second parameter (nested else syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +if (false) { + +} else { + import('./empty_FIXTURE.js', {},); +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-function-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-function-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..e9b4dad9f7 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-function-import-attributes-trailing-comma-first.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-function.template +/*--- +description: ImportCall trailing comma following first parameter (nested function syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +function fn() { + import('./empty_FIXTURE.js',); +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-function-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-function-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..03d133540c --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-function-import-attributes-trailing-comma-second.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-function.template +/*--- +description: ImportCall trailing comma following second parameter (nested function syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +function fn() { + import('./empty_FIXTURE.js', {},); +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-function-return-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-function-return-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..1256271ff1 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-function-return-import-attributes-trailing-comma-first.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-function-return.template +/*--- +description: ImportCall trailing comma following first parameter (nested function syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +function fn() { + return import('./empty_FIXTURE.js',); +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-function-return-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-function-return-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..41c9930b3f --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-function-return-import-attributes-trailing-comma-second.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-function-return.template +/*--- +description: ImportCall trailing comma following second parameter (nested function syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +function fn() { + return import('./empty_FIXTURE.js', {},); +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-if-braceless-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-if-braceless-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..c85961252b --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-if-braceless-import-attributes-trailing-comma-first.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-if-braceless.template +/*--- +description: ImportCall trailing comma following first parameter (nested if syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +if (true) import('./empty_FIXTURE.js',); diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-if-braceless-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-if-braceless-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..92d250490a --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-if-braceless-import-attributes-trailing-comma-second.js @@ -0,0 +1,30 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-if-braceless.template +/*--- +description: ImportCall trailing comma following second parameter (nested if syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +if (true) import('./empty_FIXTURE.js', {},); diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-if-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-if-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..340e2fad6b --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-if-import-attributes-trailing-comma-first.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-if.template +/*--- +description: ImportCall trailing comma following first parameter (nested if syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +if (true) { + import('./empty_FIXTURE.js',); +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-if-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-if-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..d841ee6160 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-if-import-attributes-trailing-comma-second.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-if.template +/*--- +description: ImportCall trailing comma following second parameter (nested if syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +if (true) { + import('./empty_FIXTURE.js', {},); +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-while-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-while-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..e1aad9016a --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-while-import-attributes-trailing-comma-first.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-while.template +/*--- +description: ImportCall trailing comma following first parameter (nested while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +let x = 0; +while (!x) { + x++; + import('./empty_FIXTURE.js',); +}; diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-while-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-while-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..a7535d99a9 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-while-import-attributes-trailing-comma-second.js @@ -0,0 +1,34 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-while.template +/*--- +description: ImportCall trailing comma following second parameter (nested while syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +let x = 0; +while (!x) { + x++; + import('./empty_FIXTURE.js', {},); +}; diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-with-expression-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-with-expression-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..dcb3aa71ce --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-with-expression-import-attributes-trailing-comma-first.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-with-expression.template +/*--- +description: ImportCall trailing comma following first parameter (nested with syntax in the expression position) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated, noStrict] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +with (import('./empty_FIXTURE.js',)) { + assert.sameValue(then, Promise.prototype.then); + assert.sameValue(constructor, Promise); +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-with-expression-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-with-expression-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..c9d9aa33b6 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-with-expression-import-attributes-trailing-comma-second.js @@ -0,0 +1,33 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-with-expression.template +/*--- +description: ImportCall trailing comma following second parameter (nested with syntax in the expression position) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated, noStrict] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +with (import('./empty_FIXTURE.js', {},)) { + assert.sameValue(then, Promise.prototype.then); + assert.sameValue(constructor, Promise); +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-with-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/nested-with-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..7fce790cee --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-with-import-attributes-trailing-comma-first.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/nested-with.template +/*--- +description: ImportCall trailing comma following first parameter (nested with syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated, noStrict] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +with ({}) { + import('./empty_FIXTURE.js',); +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/nested-with-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/nested-with-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..45ee6f7241 --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/nested-with-import-attributes-trailing-comma-second.js @@ -0,0 +1,32 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/nested-with.template +/*--- +description: ImportCall trailing comma following second parameter (nested with syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated, noStrict] +info: | + ImportCall : + import( AssignmentExpression ) + + 1. Let referencingScriptOrModule be ! GetActiveScriptOrModule(). + 2. Assert: referencingScriptOrModule is a Script Record or Module Record (i.e. is not null). + 3. Let argRef be the result of evaluating AssignmentExpression. + 4. Let specifier be ? GetValue(argRef). + 5. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 6. Let specifierString be ToString(specifier). + 7. IfAbruptRejectPromise(specifierString, promiseCapability). + 8. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability). + 9. Return promiseCapability.[[Promise]]. + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +with ({}) { + import('./empty_FIXTURE.js', {},); +} diff --git a/test/language/expressions/dynamic-import/syntax/valid/top-level-import-attributes-trailing-comma-first.js b/test/language/expressions/dynamic-import/syntax/valid/top-level-import-attributes-trailing-comma-first.js new file mode 100644 index 0000000000..e4d9de675b --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/top-level-import-attributes-trailing-comma-first.js @@ -0,0 +1,20 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-first.case +// - src/dynamic-import/syntax/valid/top-level.template +/*--- +description: ImportCall trailing comma following first parameter (top level syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +import('./empty_FIXTURE.js',); diff --git a/test/language/expressions/dynamic-import/syntax/valid/top-level-import-attributes-trailing-comma-second.js b/test/language/expressions/dynamic-import/syntax/valid/top-level-import-attributes-trailing-comma-second.js new file mode 100644 index 0000000000..9d8a68613f --- /dev/null +++ b/test/language/expressions/dynamic-import/syntax/valid/top-level-import-attributes-trailing-comma-second.js @@ -0,0 +1,20 @@ +// This file was procedurally generated from the following sources: +// - src/dynamic-import/import-attributes-trailing-comma-second.case +// - src/dynamic-import/syntax/valid/top-level.template +/*--- +description: ImportCall trailing comma following second parameter (top level syntax) +esid: sec-import-call-runtime-semantics-evaluation +features: [import-assertions, dynamic-import] +flags: [generated] +info: | + ImportCall : + import( AssignmentExpression ) + + + ImportCall : + import( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) + +---*/ + +import('./empty_FIXTURE.js', {},); diff --git a/test/language/import/import-attributes/json-extensibility-array.js b/test/language/import/import-attributes/json-extensibility-array.js new file mode 100644 index 0000000000..4dc80018b9 --- /dev/null +++ b/test/language/import/import-attributes/json-extensibility-array.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-parse-json-module +description: Creates extensible arrays +flags: [module] +includes: [propertyHelper.js] +features: [import-assertions, json-modules] +---*/ + +import value from './json-value-array_FIXTURE.json' assert { type: 'json' }; + +value.test262property = 'test262 value'; + +verifyProperty(value, 'test262property', { + value: 'test262 value', + writable: true, + enumerable: true, + configurable: true +}); diff --git a/test/language/import/import-attributes/json-extensibility-object.js b/test/language/import/import-attributes/json-extensibility-object.js new file mode 100644 index 0000000000..fb4c8ed2c4 --- /dev/null +++ b/test/language/import/import-attributes/json-extensibility-object.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-parse-json-module +description: Creates extensible objects +flags: [module] +includes: [propertyHelper.js] +features: [import-assertions, json-modules] +---*/ + +import value from './json-value-object_FIXTURE.json' assert { type: 'json' }; + +value.test262property = 'test262 value'; + +verifyProperty(value, 'test262property', { + value: 'test262 value', + writable: true, + enumerable: true, + configurable: true +}); diff --git a/test/language/import/import-attributes/json-idempotency-indirect_FIXTURE.js b/test/language/import/import-attributes/json-idempotency-indirect_FIXTURE.js new file mode 100644 index 0000000000..61c440b333 --- /dev/null +++ b/test/language/import/import-attributes/json-idempotency-indirect_FIXTURE.js @@ -0,0 +1,6 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +import value from './json-idempotency_FIXTURE.json' assert { type: 'json' }; + +globalThis.viaSecondModule = value; diff --git a/test/language/import/import-attributes/json-idempotency.js b/test/language/import/import-attributes/json-idempotency.js new file mode 100644 index 0000000000..54832a1cad --- /dev/null +++ b/test/language/import/import-attributes/json-idempotency.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-parse-json-module +description: The same object representation is returned to all import sites +flags: [module, async] +features: [import-assertions, json-modules, globalThis, dynamic-import] +---*/ + +import viaStaticImport1 from './json-idempotency_FIXTURE.json' assert { type: 'json' }; +import {default as viaStaticImport2} from './json-idempotency_FIXTURE.json' assert { type: 'json' }; +import './json-idempotency-indirect_FIXTURE.js'; + +assert.sameValue(viaStaticImport1, viaStaticImport2); +assert.sameValue(globalThis.viaSecondModule, viaStaticImport1); + +import('./json-idempotency_FIXTURE.json', { assert: { type: 'json' } }) + .then(function(viaDynamicImport) { + assert.sameValue(viaDynamicImport.default, viaStaticImport1); + }) + .then($DONE, $DONE); diff --git a/test/language/import/import-attributes/json-idempotency_FIXTURE.json b/test/language/import/import-attributes/json-idempotency_FIXTURE.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/test/language/import/import-attributes/json-idempotency_FIXTURE.json @@ -0,0 +1 @@ +{} diff --git a/test/language/import/import-attributes/json-invalid.js b/test/language/import/import-attributes/json-invalid.js new file mode 100644 index 0000000000..855d8566f7 --- /dev/null +++ b/test/language/import/import-attributes/json-invalid.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-parse-json-module +description: Does not define +info: | + # 1.4 ParseJSONModule ( source ) + + The abstract operation ParseJSONModule takes a single argument source which + is a String representing the contents of a module. + + 1. Let json be ? Call(%JSON.parse%, undefined, « source »). + 2. Return CreateDefaultExportSyntheticModule(json). +flags: [module] +features: [import-assertions, json-modules] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +import value from './json-invalid_FIXTURE.json' assert { type: 'json' }; diff --git a/test/language/import/import-attributes/json-invalid_FIXTURE.json b/test/language/import/import-attributes/json-invalid_FIXTURE.json new file mode 100644 index 0000000000..64809bccc4 --- /dev/null +++ b/test/language/import/import-attributes/json-invalid_FIXTURE.json @@ -0,0 +1,3 @@ +{ + notJson: 0 +} diff --git a/test/language/import/import-attributes/json-named-bindings.js b/test/language/import/import-attributes/json-named-bindings.js new file mode 100644 index 0000000000..7900fe38f8 --- /dev/null +++ b/test/language/import/import-attributes/json-named-bindings.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-parse-json-module +description: Does not define named bindings +info: | + In the early design of JSON modules, contributors considered allowing the + properties of object values in JSON modules to be imported directly by name. + This was ultimately rejected, so attempting to import in this way should + produce a SyntaxError. +flags: [module] +features: [import-assertions, json-modules] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +import {name} from './json-named-bindings_FIXTURE.json' assert { type: 'json' }; diff --git a/test/language/import/import-attributes/json-named-bindings_FIXTURE.json b/test/language/import/import-attributes/json-named-bindings_FIXTURE.json new file mode 100644 index 0000000000..ead2bb7c66 --- /dev/null +++ b/test/language/import/import-attributes/json-named-bindings_FIXTURE.json @@ -0,0 +1,3 @@ +{ + "name": 0 +} diff --git a/test/language/import/import-attributes/json-value-array.js b/test/language/import/import-attributes/json-value-array.js new file mode 100644 index 0000000000..90d64b96d9 --- /dev/null +++ b/test/language/import/import-attributes/json-value-array.js @@ -0,0 +1,47 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-parse-json-module +description: Correctly parses the JSON representation of an array +info: | + # 1.4 ParseJSONModule ( source ) + + The abstract operation ParseJSONModule takes a single argument source which + is a String representing the contents of a module. + + 1. Let json be ? Call(%JSON.parse%, undefined, « source »). + 2. Return CreateDefaultExportSyntheticModule(json). + + To more fully verify parsing correctness, the source text of the imported + module record includes non-printable characters (specifically, all four forms + of JSON's so-called "whitespace" token) both before and after the "value." +flags: [module] +features: [import-assertions, json-modules] +---*/ + +import value from './json-value-array_FIXTURE.json' assert { type: 'json' }; + +assert(Array.isArray(value), 'the exported value is an array'); +assert.sameValue( + Object.getPrototypeOf(value), + Array.prototype, + 'the exported value is not a subclass of Array' +); +assert.sameValue(Object.getOwnPropertyNames(value).length, 7); +assert.sameValue(value.length, 6); + +assert.sameValue(value[0], -1.2345); +assert.sameValue(value[1], true); +assert.sameValue(value[2], 'a string value'); +assert.sameValue(value[3], null); + +assert.sameValue(Object.getPrototypeOf(value[4]), Object.prototype); +assert.sameValue(Object.getOwnPropertyNames(value[4]).length, 0); + +assert(Array.isArray(value[5]), 'the fifth element is an array'); +assert.sameValue( + Object.getPrototypeOf(value[5]), + Array.prototype, + 'the fifth element is not a subclass of Array' +); +assert.sameValue(Object.getOwnPropertyNames(value[5]).length, 1); diff --git a/test/language/import/import-attributes/json-value-array_FIXTURE.json b/test/language/import/import-attributes/json-value-array_FIXTURE.json new file mode 100644 index 0000000000..9520048793 --- /dev/null +++ b/test/language/import/import-attributes/json-value-array_FIXTURE.json @@ -0,0 +1,10 @@ + + [ + -1234.500e-003, + true, + "a string value", + null, + {}, + [] +] + diff --git a/test/language/import/import-attributes/json-value-boolean.js b/test/language/import/import-attributes/json-value-boolean.js new file mode 100644 index 0000000000..0ab3fd371e --- /dev/null +++ b/test/language/import/import-attributes/json-value-boolean.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-parse-json-module +description: Correctly parses the JSON representation of a boolean +info: | + # 1.4 ParseJSONModule ( source ) + + The abstract operation ParseJSONModule takes a single argument source which + is a String representing the contents of a module. + + 1. Let json be ? Call(%JSON.parse%, undefined, « source »). + 2. Return CreateDefaultExportSyntheticModule(json). +flags: [module] +features: [import-assertions, json-modules] +---*/ + +import value from './json-value-boolean_FIXTURE.json' assert { type: 'json' }; + +assert.sameValue(value, true); diff --git a/test/language/import/import-attributes/json-value-boolean_FIXTURE.json b/test/language/import/import-attributes/json-value-boolean_FIXTURE.json new file mode 100644 index 0000000000..27ba77ddaf --- /dev/null +++ b/test/language/import/import-attributes/json-value-boolean_FIXTURE.json @@ -0,0 +1 @@ +true diff --git a/test/language/import/import-attributes/json-value-null.js b/test/language/import/import-attributes/json-value-null.js new file mode 100644 index 0000000000..cb651b33b0 --- /dev/null +++ b/test/language/import/import-attributes/json-value-null.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-parse-json-module +description: Correctly parses the JSON representation of null +info: | + # 1.4 ParseJSONModule ( source ) + + The abstract operation ParseJSONModule takes a single argument source which + is a String representing the contents of a module. + + 1. Let json be ? Call(%JSON.parse%, undefined, « source »). + 2. Return CreateDefaultExportSyntheticModule(json). +flags: [module] +features: [import-assertions, json-modules] +---*/ + +import value from './json-value-null_FIXTURE.json' assert { type: 'json' }; + +assert.sameValue(value, null); diff --git a/test/language/import/import-attributes/json-value-null_FIXTURE.json b/test/language/import/import-attributes/json-value-null_FIXTURE.json new file mode 100644 index 0000000000..19765bd501 --- /dev/null +++ b/test/language/import/import-attributes/json-value-null_FIXTURE.json @@ -0,0 +1 @@ +null diff --git a/test/language/import/import-attributes/json-value-number.js b/test/language/import/import-attributes/json-value-number.js new file mode 100644 index 0000000000..da4cada9d2 --- /dev/null +++ b/test/language/import/import-attributes/json-value-number.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-parse-json-module +description: Correctly parses the JSON representation of a number +info: | + # 1.4 ParseJSONModule ( source ) + + The abstract operation ParseJSONModule takes a single argument source which + is a String representing the contents of a module. + + 1. Let json be ? Call(%JSON.parse%, undefined, « source »). + 2. Return CreateDefaultExportSyntheticModule(json). +flags: [module] +features: [import-assertions, json-modules] +---*/ + +import value from './json-value-number_FIXTURE.json' assert { type: 'json' }; + +assert.sameValue(value, -1.2345); diff --git a/test/language/import/import-attributes/json-value-number_FIXTURE.json b/test/language/import/import-attributes/json-value-number_FIXTURE.json new file mode 100644 index 0000000000..859603baed --- /dev/null +++ b/test/language/import/import-attributes/json-value-number_FIXTURE.json @@ -0,0 +1 @@ +-1234.500e-003 diff --git a/test/language/import/import-attributes/json-value-object.js b/test/language/import/import-attributes/json-value-object.js new file mode 100644 index 0000000000..815ab9f896 --- /dev/null +++ b/test/language/import/import-attributes/json-value-object.js @@ -0,0 +1,67 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-parse-json-module +description: Correctly parses the JSON representation of an ordinary object +info: | + # 1.4 ParseJSONModule ( source ) + + The abstract operation ParseJSONModule takes a single argument source which + is a String representing the contents of a module. + + 1. Let json be ? Call(%JSON.parse%, undefined, « source »). + 2. Return CreateDefaultExportSyntheticModule(json). + + To more fully verify parsing correctness, the source text of the imported + module record includes non-printable characters (specifically, all four forms + of JSON's so-called "whitespace" token) both before and after the "value." +flags: [module] +includes: [propertyHelper.js] +features: [import-assertions, json-modules] +---*/ + +import value from './json-value-object_FIXTURE.json' assert { type: 'json' }; + +assert.sameValue(Object.getPrototypeOf(value), Object.prototype); +assert.sameValue(Object.getOwnPropertyNames(value).length, 6); + +verifyProperty(value, 'number', { + value: -1.2345, + writable: true, + enumerable: true, + configurable: true +}); + +verifyProperty(value, 'boolean', { + value: true, + writable: true, + enumerable: true, + configurable: true +}); + +verifyProperty(value, 'string', { + value: 'a string value', + writable: true, + enumerable: true, + configurable: true +}); + +verifyProperty(value, 'null', { + value: null, + writable: true, + enumerable: true, + configurable: true +}); + +assert.sameValue(Object.getPrototypeOf(value.object), Object.prototype); +assert.sameValue(Object.getOwnPropertyNames(value.object).length, 0); + +assert( + Array.isArray(value.array), 'the value of the "array" property is an array' +); +assert.sameValue( + Object.getPrototypeOf(value.array), + Array.prototype, + 'the value of the "array" property is not a subclass of Array' +); +assert.sameValue(Object.getOwnPropertyNames(value.array).length, 1); diff --git a/test/language/import/import-attributes/json-value-object_FIXTURE.json b/test/language/import/import-attributes/json-value-object_FIXTURE.json new file mode 100644 index 0000000000..814ec45e4d --- /dev/null +++ b/test/language/import/import-attributes/json-value-object_FIXTURE.json @@ -0,0 +1,10 @@ + + { + "number": -1234.500e-003, + "boolean": true, + "string": "a string value", + "null": null, + "object": {}, + "array": [] +} + diff --git a/test/language/import/import-attributes/json-value-string.js b/test/language/import/import-attributes/json-value-string.js new file mode 100644 index 0000000000..ce0ebcf323 --- /dev/null +++ b/test/language/import/import-attributes/json-value-string.js @@ -0,0 +1,20 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-parse-json-module +description: Correctly parses the JSON representation of a string +info: | + # 1.4 ParseJSONModule ( source ) + + The abstract operation ParseJSONModule takes a single argument source which + is a String representing the contents of a module. + + 1. Let json be ? Call(%JSON.parse%, undefined, « source »). + 2. Return CreateDefaultExportSyntheticModule(json). +flags: [module] +features: [import-assertions, json-modules] +---*/ + +import value from './json-value-string_FIXTURE.json' assert { type: 'json' }; + +assert.sameValue(value, 'a string value'); diff --git a/test/language/import/import-attributes/json-value-string_FIXTURE.json b/test/language/import/import-attributes/json-value-string_FIXTURE.json new file mode 100644 index 0000000000..d98e333143 --- /dev/null +++ b/test/language/import/import-attributes/json-value-string_FIXTURE.json @@ -0,0 +1 @@ +"a string value" diff --git a/test/language/import/import-attributes/json-via-namespace.js b/test/language/import/import-attributes/json-via-namespace.js new file mode 100644 index 0000000000..f0eedb379b --- /dev/null +++ b/test/language/import/import-attributes/json-via-namespace.js @@ -0,0 +1,13 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-parse-json-module +description: May be imported via a module namespace object +flags: [module] +features: [import-assertions, json-modules] +---*/ + +import * as ns from './json-via-namespace_FIXTURE.json' assert { type: 'json' }; + +assert.sameValue(Object.getOwnPropertyNames(ns).length, 1); +assert.sameValue(ns.default, 262); diff --git a/test/language/import/import-attributes/json-via-namespace_FIXTURE.json b/test/language/import/import-attributes/json-via-namespace_FIXTURE.json new file mode 100644 index 0000000000..5484d82917 --- /dev/null +++ b/test/language/import/import-attributes/json-via-namespace_FIXTURE.json @@ -0,0 +1 @@ +262 diff --git a/test/language/module-code/import-attributes/early-dup-attribute-key-export.js b/test/language/module-code/import-attributes/early-dup-attribute-key-export.js new file mode 100644 index 0000000000..9f44e359a0 --- /dev/null +++ b/test/language/module-code/import-attributes/early-dup-attribute-key-export.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: WithClause may not have duplicate keys (export declaration) +esid: sec-modules +info: | + WithClause: AttributesKeyword { WithEntries,opt } + + - It is a Syntax Error if WithClauseToAttributes of WithClause has two + entries a and b such that a.[[Key]] is b.[[Key]]. +features: [import-assertions] +flags: [module] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +export * from './import-assertion-3_FIXTURE.js' assert { + type: 'json', + 'typ\u0065': '' +}; diff --git a/test/language/module-code/import-attributes/early-dup-attribute-key-import-nobinding.js b/test/language/module-code/import-attributes/early-dup-attribute-key-import-nobinding.js new file mode 100644 index 0000000000..7c48699630 --- /dev/null +++ b/test/language/module-code/import-attributes/early-dup-attribute-key-import-nobinding.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + WithClause may not have duplicate keys (import declaration without binding) +esid: sec-modules +info: | + WithClause: AttributesKeyword { WithEntries,opt } + + - It is a Syntax Error if WithClauseToAttributes of WithClause has two + entries a and b such that a.[[Key]] is b.[[Key]]. +features: [import-assertions] +flags: [module] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +import './import-assertion-2_FIXTURE.js' assert { + type: 'json', + 'typ\u0065': '' +}; diff --git a/test/language/module-code/import-attributes/early-dup-attribute-key-import-withbinding.js b/test/language/module-code/import-attributes/early-dup-attribute-key-import-withbinding.js new file mode 100644 index 0000000000..0874455882 --- /dev/null +++ b/test/language/module-code/import-attributes/early-dup-attribute-key-import-withbinding.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + WithClause may not have duplicate keys (import declaration with binding) +esid: sec-modules +info: | + WithClause: AttributesKeyword { WithEntries,opt } + + - It is a Syntax Error if WithClauseToAttributes of WithClause has two + entries a and b such that a.[[Key]] is b.[[Key]]. +features: [import-assertions] +flags: [module] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +import x from './import-assertion-1_FIXTURE.js' assert { + type: 'json', + 'typ\u0065': '' +}; diff --git a/test/language/module-code/import-attributes/ensure-linking-error_FIXTURE.js b/test/language/module-code/import-attributes/ensure-linking-error_FIXTURE.js new file mode 100644 index 0000000000..e1eebf9cf2 --- /dev/null +++ b/test/language/module-code/import-attributes/ensure-linking-error_FIXTURE.js @@ -0,0 +1,9 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// When imported, this file will ensure that a linking error happens by +// importing a non-existent binding. +// It can be used to assert that there is a linking error, which means +// that there are no parsing errors. + +import { nonExistent } from "./ensure-linking-error_FIXTURE.js"; diff --git a/test/language/module-code/import-attributes/eval-gtbndng-indirect-faux-attribute.js b/test/language/module-code/import-attributes/eval-gtbndng-indirect-faux-attribute.js new file mode 100644 index 0000000000..46b6069510 --- /dev/null +++ b/test/language/module-code/import-attributes/eval-gtbndng-indirect-faux-attribute.js @@ -0,0 +1,47 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + `assert` AttributesKeyword in WithClause in ImportDeclaration may not + be preceded by a line terminator +esid: sec-modules +info: | + ImportDeclaration: + import ModuleSpecifier[no LineTerminator here] WithClause; + + WithClause: + AttributesKeyword {} + AttributesKeyword { WithEntries ,opt } + + AttributesKeyword: + with + [no LineTerminator here] assert + + The restriction LineTerminator could be verified more simply with a negative + syntax test. This test is designed to parse successfully in order to verify + the restriction more precisely. +features: [import-assertions, globalThis] +flags: [module, raw] +---*/ + +var callCount = 0; + +// Define a property on the global "this" value so that the effect of the +// expected IdentifierReference can be observed. +Object.defineProperty(globalThis, 'assert', { + get: function() { + callCount += 1; + } +}); + +import * as x from './import-assertion-1_FIXTURE.js' +assert +{ type: 'json' }; + +if (x.default !== 262.1) { + throw 'module value incorrectly imported - first declaration'; +} + +if (callCount !== 1) { + throw 'IdentifierReference not recognized - first declaration'; +} diff --git a/test/language/module-code/import-attributes/import-attribute-1_FIXTURE.js b/test/language/module-code/import-attributes/import-attribute-1_FIXTURE.js new file mode 100644 index 0000000000..3e4b8af7ff --- /dev/null +++ b/test/language/module-code/import-attributes/import-attribute-1_FIXTURE.js @@ -0,0 +1,3 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +export default 262.1; diff --git a/test/language/module-code/import-attributes/import-attribute-2_FIXTURE.js b/test/language/module-code/import-attributes/import-attribute-2_FIXTURE.js new file mode 100644 index 0000000000..a717e7ac57 --- /dev/null +++ b/test/language/module-code/import-attributes/import-attribute-2_FIXTURE.js @@ -0,0 +1,3 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +export default 262.2; diff --git a/test/language/module-code/import-attributes/import-attribute-3_FIXTURE.js b/test/language/module-code/import-attributes/import-attribute-3_FIXTURE.js new file mode 100644 index 0000000000..376f79094d --- /dev/null +++ b/test/language/module-code/import-attributes/import-attribute-3_FIXTURE.js @@ -0,0 +1,3 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +export default 262.3; diff --git a/test/language/module-code/import-attributes/import-attribute-empty.js b/test/language/module-code/import-attributes/import-attribute-empty.js new file mode 100644 index 0000000000..11ba46ac7c --- /dev/null +++ b/test/language/module-code/import-attributes/import-attribute-empty.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: WithClause in ImportDeclaration may be empty +esid: sec-modules +info: | + ImportDeclaration: + import ModuleSpecifier[no LineTerminator here] WithClause; + + WithClause: + assert {} + assert {WithEntries ,opt} + + WithEntries: + AttributeKey : StringLiteral + AttributeKey : StringLiteral , WithEntries + + AttributeKey: + IdentifierName + StringLiteral +features: [import-assertions, globalThis] +flags: [module] +---*/ + +import x from './import-assertion-1_FIXTURE.js' assert {}; +import './import-assertion-2_FIXTURE.js' assert {}; +export * from './import-assertion-3_FIXTURE.js' assert {}; + +assert.sameValue(x, 262.1); diff --git a/test/language/module-code/import-attributes/import-attribute-key-identifiername.js b/test/language/module-code/import-attributes/import-attribute-key-identifiername.js new file mode 100644 index 0000000000..605b49f739 --- /dev/null +++ b/test/language/module-code/import-attributes/import-attribute-key-identifiername.js @@ -0,0 +1,37 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + WithClause in ImportDeclaration may use any valid IdentifierName as a key +esid: sec-modules +info: | + ImportDeclaration: + import ModuleSpecifier[no LineTerminator here] WithClause; + + WithClause: + assert {} + assert {WithEntries ,opt} + + WithEntries: + AttributeKey : StringLiteral + AttributeKey : StringLiteral , WithEntries + + AttributeKey: + IdentifierName + StringLiteral +negative: + phase: resolution + type: SyntaxError +features: [import-assertions] +flags: [module] +---*/ + +$DONOTEVALUATE(); + +import "./ensure-linking-error_FIXTURE.js"; + +import x from './import-assertion-1_FIXTURE.js' assert {if:''}; +import './import-assertion-2_FIXTURE.js' assert {if:''}; +export * from './import-assertion-3_FIXTURE.js' assert {if:''}; + +assert.sameValue(x, 262.1); diff --git a/test/language/module-code/import-attributes/import-attribute-key-string-double.js b/test/language/module-code/import-attributes/import-attribute-key-string-double.js new file mode 100644 index 0000000000..0a6491686a --- /dev/null +++ b/test/language/module-code/import-attributes/import-attribute-key-string-double.js @@ -0,0 +1,37 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + WithClause in ImportDeclaration may use a string literal as a key (delimited with U+0022) +esid: sec-modules +info: | + ImportDeclaration: + import ModuleSpecifier[no LineTerminator here] WithClause; + + WithClause: + assert {} + assert {WithEntries ,opt} + + WithEntries: + AttributeKey : StringLiteral + AttributeKey : StringLiteral , WithEntries + + AttributeKey: + IdentifierName + StringLiteral +negative: + phase: resolution + type: SyntaxError +features: [import-assertions, globalThis] +flags: [module] +---*/ + +$DONOTEVALUATE(); + +import "./ensure-linking-error_FIXTURE.js"; + +import x from './import-assertion-1_FIXTURE.js' assert {"test262\u0078":''}; +import './import-assertion-2_FIXTURE.js' assert {"test262\u0078":''}; +export * from './import-assertion-3_FIXTURE.js' assert {"test262\u0078":''}; + +assert.sameValue(x, 262.1); diff --git a/test/language/module-code/import-attributes/import-attribute-key-string-single.js b/test/language/module-code/import-attributes/import-attribute-key-string-single.js new file mode 100644 index 0000000000..edccfeb08e --- /dev/null +++ b/test/language/module-code/import-attributes/import-attribute-key-string-single.js @@ -0,0 +1,37 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + WithClause in ImportDeclaration may use a string literal as a key (delimited with U+0027) +esid: sec-modules +info: | + ImportDeclaration: + import ModuleSpecifier[no LineTerminator here] WithClause; + + WithClause: + assert {} + assert {WithEntries ,opt} + + WithEntries: + AttributeKey : StringLiteral + AttributeKey : StringLiteral , WithEntries + + AttributeKey: + IdentifierName + StringLiteral +negative: + phase: resolution + type: SyntaxError +features: [import-assertions, globalThis] +flags: [module] +---*/ + +$DONOTEVALUATE(); + +import "./ensure-linking-error_FIXTURE.js"; + +import x from './import-assertion-1_FIXTURE.js' assert {'test262\u0078':''}; +import './import-assertion-2_FIXTURE.js' assert {'test262\u0078':''}; +export * from './import-assertion-3_FIXTURE.js' assert {'test262\u0078':''}; + +assert.sameValue(x, 262.1); diff --git a/test/language/module-code/import-attributes/import-attribute-many.js b/test/language/module-code/import-attributes/import-attribute-many.js new file mode 100644 index 0000000000..fccf8be5c2 --- /dev/null +++ b/test/language/module-code/import-attributes/import-attribute-many.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + WithClause in ImportDeclaration may contain multiple WithEntries +esid: sec-modules +info: | + ImportDeclaration: + import ModuleSpecifier[no LineTerminator here] WithClause; + + WithClause: + assert {} + assert {WithEntries ,opt} + + WithEntries: + AttributeKey : StringLiteral + AttributeKey : StringLiteral , WithEntries + + AttributeKey: + IdentifierName + StringLiteral +negative: + phase: resolution + type: SyntaxError +features: [import-assertions, globalThis] +flags: [module] +---*/ + +$DONOTEVALUATE(); + +import "./ensure-linking-error_FIXTURE.js"; + +import x from './import-assertion-1_FIXTURE.js' assert {test262_1:'',test262_2:'',test262_3:'',test262_4:''}; +import './import-assertion-2_FIXTURE.js' assert {test262_1:'',test262_2:'',test262_3:'',test262_4:''}; +export * from './import-assertion-3_FIXTURE.js' assert {test262_1:'',test262_2:'',test262_3:'',test262_4:''}; diff --git a/test/language/module-code/import-attributes/import-attribute-newlines.js b/test/language/module-code/import-attributes/import-attribute-newlines.js new file mode 100644 index 0000000000..10cfba52a4 --- /dev/null +++ b/test/language/module-code/import-attributes/import-attribute-newlines.js @@ -0,0 +1,71 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + WithClause in ImportDeclaration may include line terminators +esid: sec-modules +info: | + ImportDeclaration: + import ModuleSpecifier[no LineTerminator here] WithClause; + + WithClause: + assert {} + assert {WithEntries ,opt} + + WithEntries: + AttributeKey : StringLiteral + AttributeKey : StringLiteral , WithEntries + + AttributeKey: + IdentifierName + StringLiteral + + This test uses all four LineFeed characters in order to completely verify the + grammar. +negative: + phase: resolution + type: SyntaxError +features: [import-assertions, globalThis] +flags: [module] +---*/ + +$DONOTEVALUATE(); + +import "./ensure-linking-error_FIXTURE.js"; + +import x from './import-assertion-1_FIXTURE.js' assert + +

{ + +

test262 + +

: + +

'' + +

}; +import './import-assertion-2_FIXTURE.js' assert + +

{ + +

test262 + +

: + +

'' + +

}; +export * from './import-assertion-3_FIXTURE.js' assert + +

{ + +

test262 + +

: + +

'' + +

}; + +assert.sameValue(x, 262.1); +assert.sameValue(globalThis.test262, 262.2); diff --git a/test/language/module-code/import-attributes/import-attribute-trlng-comma.js b/test/language/module-code/import-attributes/import-attribute-trlng-comma.js new file mode 100644 index 0000000000..323c61fac4 --- /dev/null +++ b/test/language/module-code/import-attributes/import-attribute-trlng-comma.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + WithClause in ImportDeclaration may contain a trailing comma +esid: sec-modules +info: | + ImportDeclaration: + import ModuleSpecifier[no LineTerminator here] WithClause; + + WithClause: + assert {} + assert {WithEntries ,opt} + + WithEntries: + AttributeKey : StringLiteral + AttributeKey : StringLiteral , WithEntries + + AttributeKey: + IdentifierName + StringLiteral +negative: + phase: resolution + type: SyntaxError +features: [import-assertions, globalThis] +flags: [module] +---*/ + +$DONOTEVALUATE(); + +import "./ensure-linking-error_FIXTURE.js"; + +import x from './import-assertion-1_FIXTURE.js' assert {test262:'',}; +import './import-assertion-2_FIXTURE.js' assert {test262:'',}; +export * from './import-assertion-3_FIXTURE.js' assert {test262:'',}; diff --git a/test/language/module-code/import-attributes/import-attribute-value-string-double.js b/test/language/module-code/import-attributes/import-attribute-value-string-double.js new file mode 100644 index 0000000000..fc24b2e269 --- /dev/null +++ b/test/language/module-code/import-attributes/import-attribute-value-string-double.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + WithClause in ImportDeclaration may use a string literal as a value (delimited with U+0022) +esid: sec-modules +info: | + ImportDeclaration: + import ModuleSpecifier[no LineTerminator here] WithClause; + + WithClause: + assert {} + assert {WithEntries ,opt} + + WithEntries: + AttributeKey : StringLiteral + AttributeKey : StringLiteral , WithEntries + + AttributeKey: + IdentifierName + StringLiteral +negative: + phase: resolution + type: SyntaxError +features: [import-assertions, globalThis] +flags: [module] +---*/ + +$DONOTEVALUATE(); + +import "./ensure-linking-error_FIXTURE.js"; + +import x from './import-assertion-1_FIXTURE.js' assert {test262:"\u0078"}; +import './import-assertion-2_FIXTURE.js' assert {test262:"\u0078"}; +export * from './import-assertion-3_FIXTURE.js' assert {test262:"\u0078"}; diff --git a/test/language/module-code/import-attributes/import-attribute-value-string-single.js b/test/language/module-code/import-attributes/import-attribute-value-string-single.js new file mode 100644 index 0000000000..0e0ef844bf --- /dev/null +++ b/test/language/module-code/import-attributes/import-attribute-value-string-single.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + WithClause in ImportDeclaration may use a string literal as a value (delimited with U+0027) +esid: sec-modules +info: | + ImportDeclaration: + import ModuleSpecifier[no LineTerminator here] WithClause; + + WithClause: + assert {} + assert {WithEntries ,opt} + + WithEntries: + AttributeKey : StringLiteral + AttributeKey : StringLiteral , WithEntries + + AttributeKey: + IdentifierName + StringLiteral +features: [import-assertions, globalThis] +negative: + phase: resolution + type: SyntaxError +flags: [module] +---*/ + +$DONOTEVALUATE(); + +import "./ensure-linking-error_FIXTURE.js"; + +import x from './import-assertion-1_FIXTURE.js' assert {test262:'\u0078'}; +import './import-assertion-2_FIXTURE.js' assert {test262:'\u0078'}; +export * from './import-assertion-3_FIXTURE.js' assert {test262:'\u0078'};