From a4d102e020ded6eb83cfbeb9aa1fa55ea398f653 Mon Sep 17 00:00:00 2001 From: Leo Balter <leonardo.balter@gmail.com> Date: Thu, 18 Oct 2018 16:14:02 -0400 Subject: [PATCH] Add tests for Assignment Expressions in Dynamic Imports (#1865) --- .../assign-expr/additive-expr.js | 40 ++++++++++++++++ .../assign-expr/array-literal.js | 38 +++++++++++++++ .../assign-expr/arrow-function.js | 31 ++++++++++++ .../dynamic-import/assign-expr/await-expr.js | 37 +++++++++++++++ .../assign-expr/await-identifier.js | 33 +++++++++++++ .../assign-expr/call-expr-arguments.js | 45 ++++++++++++++++++ .../assign-expr/call-expr-expr.js | 44 +++++++++++++++++ .../assign-expr/call-expr-identifier.js | 47 +++++++++++++++++++ .../assign-expr/cover-call-expr.js | 45 ++++++++++++++++++ .../assign-expr/cover-parenthesized-expr.js | 37 +++++++++++++++ .../dynamic-import/assign-expr/identifier.js | 37 +++++++++++++++ .../lhs-assign-operator-assign-expr.js | 40 ++++++++++++++++ .../assign-expr/lhs-eq-assign-expr.js | 42 +++++++++++++++++ .../assign-expr/logical-and-expr.js | 38 +++++++++++++++ .../assign-expr/logical-or-expr.js | 37 +++++++++++++++ .../dynamic-import/assign-expr/member-expr.js | 41 ++++++++++++++++ .../assign-expr/module-code-other_FIXTURE.js | 10 ++++ .../assign-expr/module-code_FIXTURE.js | 10 ++++ .../dynamic-import/assign-expr/new-target.js | 35 ++++++++++++++ .../assign-expr/object-literal.js | 38 +++++++++++++++ .../assign-expr/tagged-function-call.js | 37 +++++++++++++++ .../dynamic-import/assign-expr/ternary.js | 37 +++++++++++++++ .../dynamic-import/assign-expr/this.js | 32 +++++++++++++ .../dynamic-import/assign-expr/unary-expr.js | 32 +++++++++++++ .../assign-expr/yield-assign-expr.js | 47 +++++++++++++++++++ .../dynamic-import/assign-expr/yield-expr.js | 47 +++++++++++++++++++ .../assign-expr/yield-identifier.js | 31 ++++++++++++ .../dynamic-import/assign-expr/yield-star.js | 24 ++++++++++ 28 files changed, 1012 insertions(+) create mode 100644 test/language/module-code/dynamic-import/assign-expr/additive-expr.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/array-literal.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/arrow-function.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/await-expr.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/await-identifier.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/call-expr-arguments.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/call-expr-expr.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/call-expr-identifier.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/cover-call-expr.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/cover-parenthesized-expr.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/identifier.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/lhs-assign-operator-assign-expr.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/lhs-eq-assign-expr.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/logical-and-expr.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/logical-or-expr.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/member-expr.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/module-code-other_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/module-code_FIXTURE.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/new-target.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/object-literal.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/tagged-function-call.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/ternary.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/this.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/unary-expr.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/yield-assign-expr.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/yield-expr.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/yield-identifier.js create mode 100644 test/language/module-code/dynamic-import/assign-expr/yield-star.js diff --git a/test/language/module-code/dynamic-import/assign-expr/additive-expr.js b/test/language/module-code/dynamic-import/assign-expr/additive-expr.js new file mode 100644 index 0000000000..ec0f39fae3 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/additive-expr.js @@ -0,0 +1,40 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (Additive Expression) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +let x = './module-code'; +let y = './module-code'; + +const a = '_FIXTURE.js'; +const b = '-other_FIXTURE.js'; + +async function fn() { + const ns1 = await import(x + a); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + const ns2 = await import(y + b); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/array-literal.js b/test/language/module-code/dynamic-import/assign-expr/array-literal.js new file mode 100644 index 0000000000..0e0d697630 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/array-literal.js @@ -0,0 +1,38 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (Array Literal) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +const a = './module-code_FIXTURE.js'; +const b = './module-code-other_FIXTURE.js'; + +async function fn() { + const ns1 = await import([a]); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + Array.prototype.toString = () => b; + const ns2 = await import([]); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/arrow-function.js b/test/language/module-code/dynamic-import/assign-expr/arrow-function.js new file mode 100644 index 0000000000..91dad3ebec --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/arrow-function.js @@ -0,0 +1,31 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (ArrowFunction) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +Function.prototype.toString = () => './module-code_FIXTURE.js'; + +async function fn() { + const ns = await import(() => {}); + + assert.sameValue(ns.local1, 'Test262'); + assert.sameValue(ns.default, 42); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/await-expr.js b/test/language/module-code/dynamic-import/assign-expr/await-expr.js new file mode 100644 index 0000000000..c84f2e5e22 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/await-expr.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (AwaitExpression) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +const a = './module-code_FIXTURE.js'; +const b = './module-code-other_FIXTURE.js'; + +async function fn() { + const ns1 = await import(await a); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + const ns2 = await import(await b); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/await-identifier.js b/test/language/module-code/dynamic-import/assign-expr/await-identifier.js new file mode 100644 index 0000000000..1715cd70ff --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/await-identifier.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (IdentifierReference: await) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +const await = './module-code_FIXTURE.js'; + +const getpromise = () => import(await); + +async function fn() { + const ns1 = await getpromise(); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/call-expr-arguments.js b/test/language/module-code/dynamic-import/assign-expr/call-expr-arguments.js new file mode 100644 index 0000000000..e5da082d73 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/call-expr-arguments.js @@ -0,0 +1,45 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (CallExpression Arguments) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await, +Tagged] +flags: [async] +features: [dynamic-import] +---*/ + +const a = () => () => './module-code_FIXTURE.js'; +const b = () => () => './module-code-other_FIXTURE.js'; + +async function fn() { + const ns1 = await import(a()()); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + const ns2 = await import(b()()); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/call-expr-expr.js b/test/language/module-code/dynamic-import/assign-expr/call-expr-expr.js new file mode 100644 index 0000000000..a4ab9866e7 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/call-expr-expr.js @@ -0,0 +1,44 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (CallExpression [ Expression ]) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await, +Tagged] +flags: [async] +features: [dynamic-import] +---*/ + +const a = () => ['./module-code_FIXTURE.js', './module-code-other_FIXTURE.js']; + +async function fn() { + const ns1 = await import(a()[0]); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + const ns2 = await import(a()[0, 1]); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/call-expr-identifier.js b/test/language/module-code/dynamic-import/assign-expr/call-expr-identifier.js new file mode 100644 index 0000000000..7e801d8a29 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/call-expr-identifier.js @@ -0,0 +1,47 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (CallExpression . IdentifierName) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await, +Tagged] +flags: [async] +features: [dynamic-import] +---*/ + +const a = () => ({ + x: './module-code_FIXTURE.js', + y: './module-code-other_FIXTURE.js' +}); + +async function fn() { + const ns1 = await import(a().x); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + const ns2 = await import(a().y); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/cover-call-expr.js b/test/language/module-code/dynamic-import/assign-expr/cover-call-expr.js new file mode 100644 index 0000000000..baa8b576c4 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/cover-call-expr.js @@ -0,0 +1,45 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (CoverCallExpressionAndAsyncArrowHeadn) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] + + CallExpression[Yield, Await]: + CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] + SuperCall[?Yield, ?Await] + CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await] + CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]] + CallExpression[?Yield, ?Await].IdentifierName + CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await, +Tagged] +flags: [async] +features: [dynamic-import] +---*/ + +const a = () => './module-code_FIXTURE.js'; +const b = () => './module-code-other_FIXTURE.js'; + +async function fn() { + const ns1 = await import(a()); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + const ns2 = await import(b()); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/cover-parenthesized-expr.js b/test/language/module-code/dynamic-import/assign-expr/cover-parenthesized-expr.js new file mode 100644 index 0000000000..8eefa4f3c4 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/cover-parenthesized-expr.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (CoverParenthesizedExpressionAndArrowParameterList) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] + + CoverParenthesizedExpressionAndArrowParameterList[Yield, Await]: + (Expression[+In, ?Yield, ?Await]) +flags: [async] +features: [dynamic-import] +---*/ + +async function fn() { + const ns1 = await import((((((('./module-code_FIXTURE.js'))))))); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + const ns2 = await import((1, 0, './module-code-other_FIXTURE.js')); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/identifier.js b/test/language/module-code/dynamic-import/assign-expr/identifier.js new file mode 100644 index 0000000000..08692b13e8 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/identifier.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (Identifier) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +const a = './module-code_FIXTURE.js'; +const b = './module-code-other_FIXTURE.js'; + +async function fn() { + const ns1 = await import(a); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + const ns2 = await import(b); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/lhs-assign-operator-assign-expr.js b/test/language/module-code/dynamic-import/assign-expr/lhs-assign-operator-assign-expr.js new file mode 100644 index 0000000000..3f8f1bcfb9 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/lhs-assign-operator-assign-expr.js @@ -0,0 +1,40 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (LHS Expr AssignmentOperator AssignmentExpression) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +let x = './module-code'; +let y = './module-code'; + +const a = '_FIXTURE.js'; +const b = '-other_FIXTURE.js'; + +async function fn() { + const ns1 = await import(x += a); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + const ns2 = await import(y += b); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/lhs-eq-assign-expr.js b/test/language/module-code/dynamic-import/assign-expr/lhs-eq-assign-expr.js new file mode 100644 index 0000000000..e293252e4e --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/lhs-eq-assign-expr.js @@ -0,0 +1,42 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (LHS Expr = AssignmentExpression) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +let x = 'foo'; +const y = { + z: 0 +}; +Object.freeze(y); +const a = './module-code_FIXTURE.js'; +const b = './module-code-other_FIXTURE.js'; + +async function fn() { + const ns1 = await import(x = a); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + const ns2 = await import(y.z = b); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/logical-and-expr.js b/test/language/module-code/dynamic-import/assign-expr/logical-and-expr.js new file mode 100644 index 0000000000..3c2adcca92 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/logical-and-expr.js @@ -0,0 +1,38 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (LogicalANDExpression) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +const a = './module-code_FIXTURE.js'; +const b = './module-code-other_FIXTURE.js'; + +async function fn() { + const ns1 = await import(b && a); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + // mix it in with Unary Expressions + const ns2 = await import(delete void typeof +-~! 0 && b); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/logical-or-expr.js b/test/language/module-code/dynamic-import/assign-expr/logical-or-expr.js new file mode 100644 index 0000000000..0c4dd3e784 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/logical-or-expr.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (LogicalORExpression) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +const a = './module-code_FIXTURE.js'; +const b = './module-code-other_FIXTURE.js'; + +async function fn() { + const ns1 = await import(a || b); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + const ns2 = await import(false || b); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/member-expr.js b/test/language/module-code/dynamic-import/assign-expr/member-expr.js new file mode 100644 index 0000000000..55021c2d58 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/member-expr.js @@ -0,0 +1,41 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (Object properties from MemberExpressions) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +const obj = { + a: './module-code_FIXTURE.js', + b: './module-code-other_FIXTURE.js' +} + +async function fn() { + // MemberExpression [ Expression ] + const ns1 = await import(obj['a']); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + // MemberExpression . IdentifierName + const ns2 = await import(obj.b); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/module-code-other_FIXTURE.js b/test/language/module-code/dynamic-import/assign-expr/module-code-other_FIXTURE.js new file mode 100644 index 0000000000..284528dbb0 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/module-code-other_FIXTURE.js @@ -0,0 +1,10 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// exports: default === 1612, local1 === 'one six one two', renamed === 'star', indirect === 'one six one two' + +export var local1 = 'one six one two'; +var local2 = 'star'; +export { local2 as renamed }; +export { local1 as indirect } from './module-code_FIXTURE.js'; +export default 1612; diff --git a/test/language/module-code/dynamic-import/assign-expr/module-code_FIXTURE.js b/test/language/module-code/dynamic-import/assign-expr/module-code_FIXTURE.js new file mode 100644 index 0000000000..62cb5ae821 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/module-code_FIXTURE.js @@ -0,0 +1,10 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +// exports: default === 42, local1 === 'Test262', renamed === 'TC39', indirect === 'Test262' + +export var local1 = 'Test262'; +var local2 = 'TC39'; +export { local2 as renamed }; +export { local1 as indirect } from './module-code_FIXTURE.js'; +export default 42; diff --git a/test/language/module-code/dynamic-import/assign-expr/new-target.js b/test/language/module-code/dynamic-import/assign-expr/new-target.js new file mode 100644 index 0000000000..b2c7dfc1be --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/new-target.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (NewTarget) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +function ctor() { + return import(new.target); +} + +ctor.toString = () => './module-code_FIXTURE.js'; + +async function fn() { + const ns = await new ctor(); + + assert.sameValue(ns.local1, 'Test262'); + assert.sameValue(ns.default, 42); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/object-literal.js b/test/language/module-code/dynamic-import/assign-expr/object-literal.js new file mode 100644 index 0000000000..3d746cf940 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/object-literal.js @@ -0,0 +1,38 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (Object Literal) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +const a = './module-code_FIXTURE.js'; +const b = './module-code-other_FIXTURE.js'; + +async function fn() { + const ns1 = await import({ toString() { return a; } }); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + Object.prototype.toString = () => b; + const ns2 = await import({}); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/tagged-function-call.js b/test/language/module-code/dynamic-import/assign-expr/tagged-function-call.js new file mode 100644 index 0000000000..5e54a692c9 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/tagged-function-call.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (MemberExpression TemplateLiteral) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +const a = './module-code_FIXTURE.js'; +const b = './module-code-other_FIXTURE.js'; + +function tag(arg) { + return arg[0]; +} + +async function fn() { + // MemberExpression TemplateLiteral + const ns = await import(tag`./module-code-other_FIXTURE.js`); + + assert.sameValue(ns.local1, 'one six one two'); + assert.sameValue(ns.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/ternary.js b/test/language/module-code/dynamic-import/assign-expr/ternary.js new file mode 100644 index 0000000000..cbb7cd66cb --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/ternary.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (Ternary) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +const a = './module-code_FIXTURE.js'; +const b = './module-code-other_FIXTURE.js'; + +async function fn() { + const ns1 = await import(true ? a : b); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + const ns2 = await import(false ? a : b); + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/this.js b/test/language/module-code/dynamic-import/assign-expr/this.js new file mode 100644 index 0000000000..c50cff64b8 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/this.js @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (this) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] + + PrimaryExpression[Yield, Await]: + this +flags: [async] +features: [dynamic-import] +---*/ + +async function fn() { + const ns1 = await import(this); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); +} + +fn.call('./module-code_FIXTURE.js').then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/unary-expr.js b/test/language/module-code/dynamic-import/assign-expr/unary-expr.js new file mode 100644 index 0000000000..2121d3f764 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/unary-expr.js @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (UnaryExpressions) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +features: [dynamic-import] +---*/ + +const obj = { + prop: 42 +}; + +import(delete obj.prop); +import(void 0); +import(typeof {}); +import(+void 0); +import(-void 0); +import(!void 0); +import(~void 0); +import(delete void typeof +-~! 0); diff --git a/test/language/module-code/dynamic-import/assign-expr/yield-assign-expr.js b/test/language/module-code/dynamic-import/assign-expr/yield-assign-expr.js new file mode 100644 index 0000000000..08661ca371 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/yield-assign-expr.js @@ -0,0 +1,47 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (yield [no LineTerminator here] AssignmentExpression) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +const a = './module-code_FIXTURE.js'; +const b = './module-code-other_FIXTURE.js'; + +function *g() { + return import(yield 42); +} + +async function *fn() { + let iter = g(); + assert.sameValue(iter.next().value, 42); + + const ns1 = await iter.next(a).value; + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + iter = g(); + assert.sameValue(iter.next().value, 42); + + const ns2 = await iter.next(b).value; + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().next(a).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/yield-expr.js b/test/language/module-code/dynamic-import/assign-expr/yield-expr.js new file mode 100644 index 0000000000..4a621fee49 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/yield-expr.js @@ -0,0 +1,47 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (YieldExpression) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async] +features: [dynamic-import] +---*/ + +const a = './module-code_FIXTURE.js'; +const b = './module-code-other_FIXTURE.js'; + +function *g() { + return import(yield); +} + +async function *fn() { + let iter = g(); + iter.next(); + + const ns1 = await iter.next(a).value; + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); + + iter = g(); + iter.next(); + + const ns2 = await iter.next(b).value; + + assert.sameValue(ns2.local1, 'one six one two'); + assert.sameValue(ns2.default, 1612); +} + +fn().next(a).then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/yield-identifier.js b/test/language/module-code/dynamic-import/assign-expr/yield-identifier.js new file mode 100644 index 0000000000..1cc9799e0a --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/yield-identifier.js @@ -0,0 +1,31 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (IdentifierReference: yield) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +flags: [async, noStrict] +features: [dynamic-import] +---*/ + +const yield = './module-code_FIXTURE.js'; + +async function fn() { + const ns1 = await import(yield); + + assert.sameValue(ns1.local1, 'Test262'); + assert.sameValue(ns1.default, 42); +} + +fn().then($DONE, $DONE).catch($DONE); diff --git a/test/language/module-code/dynamic-import/assign-expr/yield-star.js b/test/language/module-code/dynamic-import/assign-expr/yield-star.js new file mode 100644 index 0000000000..cebc9c9689 --- /dev/null +++ b/test/language/module-code/dynamic-import/assign-expr/yield-star.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Dynamic Import receives an AssignmentExpression (yield [no LineTerminator here] AssignmentExpression) +esid: prod-ImportCall +info: | + ImportCall [Yield]: + import ( AssignmentExpression[+In, ?Yield] ) + + AssignmentExpression[In, Yield, Await]: + ConditionalExpression[?In, ?Yield, ?Await] + [+Yield]YieldExpression[?In, ?Await] + ArrowFunction[?In, ?Yield, ?Await] + AsyncArrowFunction[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] + LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] +features: [dynamic-import] +---*/ + +// Asserts valid syntax, return is not asserted for the undefined value of yield * +function *g() { + import(yield * ['Roberta Flack', 'Donny Hathaway', 'Frank Sinatra']); +} -- GitLab