From c43c9d8448ecb270a8460f1fb3f7db629b0fe1ae Mon Sep 17 00:00:00 2001 From: Bradley Farias Date: Tue, 29 Sep 2020 15:32:01 -0500 Subject: [PATCH] Exports can be Arbitrary Strings --- .../early-export-ill-formed-string.js | 24 +++++++++++++++++++ .../export-expname-binding-string.js | 17 +++++++++++++ .../export-expname-from-binding-string.js | 22 +++++++++++++++++ .../export-expname-from-star-string.js | 19 +++++++++++++++ .../module-code/export-expname-from-star.js | 16 +++++++++++++ .../export-expname-from-string-binding.js | 20 ++++++++++++++++ .../export-expname-from-string-string.js | 20 ++++++++++++++++ .../module-code/export-expname-from-string.js | 21 ++++++++++++++++ .../export-expname-import-string-binding.js | 16 +++++++++++++ .../module-code/export-expname_FIXTURE.js | 9 +++++++ 10 files changed, 184 insertions(+) create mode 100644 test/language/module-code/early-export-ill-formed-string.js create mode 100644 test/language/module-code/export-expname-binding-string.js create mode 100644 test/language/module-code/export-expname-from-binding-string.js create mode 100644 test/language/module-code/export-expname-from-star-string.js create mode 100644 test/language/module-code/export-expname-from-star.js create mode 100644 test/language/module-code/export-expname-from-string-binding.js create mode 100644 test/language/module-code/export-expname-from-string-string.js create mode 100644 test/language/module-code/export-expname-from-string.js create mode 100644 test/language/module-code/export-expname-import-string-binding.js create mode 100644 test/language/module-code/export-expname_FIXTURE.js diff --git a/test/language/module-code/early-export-ill-formed-string.js b/test/language/module-code/early-export-ill-formed-string.js new file mode 100644 index 0000000000..904e0a93ac --- /dev/null +++ b/test/language/module-code/early-export-ill-formed-string.js @@ -0,0 +1,24 @@ +// Copyright (C) 2020 Bradley Farias. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Ill formed unicode cannot be an exported name +esid: sec-module-semantics +info: | + ModuleExportName : StringLiteral + + It is a Syntax Error if IsStringWellFormedUnicode of the StringValue of StringLiteral is *false*. +negative: + flags: module + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +// 🌙 is '\uD83C\uDF19' +export {Moon as "\uD83C",} from "./early-export-ill-formed-string.js"; +export {"\uD83C"} from "./early-export-ill-formed-string.js"; +import {'\uD83C' as Usagi} from "./early-export-ill-formed-string.js"; + +function Moon() {} diff --git a/test/language/module-code/export-expname-binding-string.js b/test/language/module-code/export-expname-binding-string.js new file mode 100644 index 0000000000..b73d1a55b2 --- /dev/null +++ b/test/language/module-code/export-expname-binding-string.js @@ -0,0 +1,17 @@ +// Copyright (C) 2020 Bradley Farias. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Module Namespace Objects can have non-Identifier properties +esid: prod-ExportSpecifier +info: + ExportSpecifier[From] : + IdentifierName `as` ModuleExportName + + ModuleExportName : StringLiteral + +flags: [module] +---*/ +import * as Scouts from "./export-expname_FIXTURE.js"; + +assert.sameValue(Scouts.Mercury, undefined); +assert.sameValue(Scouts["☿"], globalThis.Mercury); diff --git a/test/language/module-code/export-expname-from-binding-string.js b/test/language/module-code/export-expname-from-binding-string.js new file mode 100644 index 0000000000..207eb9bb30 --- /dev/null +++ b/test/language/module-code/export-expname-from-binding-string.js @@ -0,0 +1,22 @@ +// Copyright (C) 2020 Bradley Farias. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ExportSpecifier : ModuleExportName + esid: prod-ExportSpecifier +info: | + ExportFromClause : + NamedExports[+From] + + ExportSpecifier[From] : + IdentifierName `as` ModuleExportName + + ModuleExportName : StringLiteral + +flags: [module] +---*/ +import * as Scouts from "./export-expname-from-binding-string.js"; +export { Mercury as "☿" } from "./export-expname_FIXTURE.js"; + +assert.sameValue(Scouts.Mercury, undefined); +assert.sameValue(Scouts["☿"], globalThis.Mercury); diff --git a/test/language/module-code/export-expname-from-star-string.js b/test/language/module-code/export-expname-from-star-string.js new file mode 100644 index 0000000000..c75c155293 --- /dev/null +++ b/test/language/module-code/export-expname-from-star-string.js @@ -0,0 +1,19 @@ +// Copyright (C) 2020 Bradley Farias. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ExportFromClause : `*` `as` ModuleExportName + esid: prod-ExportFromClause +info: | + ExportFromClause : + `*` `as` ModuleExportName + + ModuleExportName : StringLiteral + +flags: [module] +---*/ +import * as Scouts from "./export-expname-from-star-string.js"; +export * as "All" from "./export-expname_FIXTURE.js"; + +assert.sameValue(Scouts["☿"], undefined); +assert.sameValue(Scouts.All["☿"], globalThis.Mercury); diff --git a/test/language/module-code/export-expname-from-star.js b/test/language/module-code/export-expname-from-star.js new file mode 100644 index 0000000000..e490d7d1fe --- /dev/null +++ b/test/language/module-code/export-expname-from-star.js @@ -0,0 +1,16 @@ +// Copyright (C) 2020 Bradley Farias. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ExportFromClause : `*` + esid: prod-ExportFromClause +info: | + ExportFromClause : + `*` + +flags: [module] +---*/ +import * as Scouts from "./export-expname-from-star.js"; +export * from "./export-expname_FIXTURE.js"; + +assert.sameValue(Scouts["☿"], globalThis.Mercury); diff --git a/test/language/module-code/export-expname-from-string-binding.js b/test/language/module-code/export-expname-from-string-binding.js new file mode 100644 index 0000000000..514920b2c8 --- /dev/null +++ b/test/language/module-code/export-expname-from-string-binding.js @@ -0,0 +1,20 @@ +// Copyright (C) 2020 Bradley Farias. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ExportFromClause : NamedExports + esid: prod-ExportFromClause +info: | + ExportFromClause : + NamedExports[+From] + + NamedExports[From] : + [+From] ModuleExportName as IdentifierName + +flags: [module] +---*/ +import * as Scouts from "./export-expname-from-string-binding.js"; +export { "☿" as Ami } from "./export-expname_FIXTURE.js"; + +assert.sameValue(Scouts["☿"], undefined); +assert.sameValue(Scouts.Ami, globalThis.Mercury); diff --git a/test/language/module-code/export-expname-from-string-string.js b/test/language/module-code/export-expname-from-string-string.js new file mode 100644 index 0000000000..efca8c9363 --- /dev/null +++ b/test/language/module-code/export-expname-from-string-string.js @@ -0,0 +1,20 @@ +// Copyright (C) 2020 Bradley Farias. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ExportFromClause : NamedExports + esid: prod-ExportFromClause +info: | + ExportFromClause : + NamedExports[+From] + + NamedExports[From] : + [+From] ModuleExportName as ModuleExportName + +flags: [module] +---*/ +import * as Scouts from "./export-expname-from-string-string.js"; +export { "☿" as "Ami" } from "./export-expname_FIXTURE.js"; + +assert.sameValue(Scouts["☿"], undefined); +assert.sameValue(Scouts.Ami, globalThis.Mercury); diff --git a/test/language/module-code/export-expname-from-string.js b/test/language/module-code/export-expname-from-string.js new file mode 100644 index 0000000000..bc0ab0ea05 --- /dev/null +++ b/test/language/module-code/export-expname-from-string.js @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Bradley Farias. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ExportFromClause : NamedExports + esid: prod-ExportFromClause +info: | + ExportFromClause : + NamedExports[+From] + + NamedExports[From] : + [+From] ModuleExportName + + ModuleExportName : StringLiteral + +flags: [module] +---*/ +import * as Scouts from "./export-expname-from-string.js"; +export { "☿" } from "./export-expname_FIXTURE.js"; + +assert.sameValue(typeof Scouts["☿"], "function"); diff --git a/test/language/module-code/export-expname-import-string-binding.js b/test/language/module-code/export-expname-import-string-binding.js new file mode 100644 index 0000000000..3210b3b7af --- /dev/null +++ b/test/language/module-code/export-expname-import-string-binding.js @@ -0,0 +1,16 @@ +// Copyright (C) 2020 Bradley Farias. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + ImportSpecifier : + ModuleExportName `as` IdentifierName + esid: prod-ImportSpecifier +info: | + ImportSpecifier : + ModuleExportName `as` IdentifierName + +flags: [module] +---*/ +import { "☿" as Ami } from "./export-expname_FIXTURE.js"; + +assert.sameValue(Ami, globalThis.Mercury); diff --git a/test/language/module-code/export-expname_FIXTURE.js b/test/language/module-code/export-expname_FIXTURE.js new file mode 100644 index 0000000000..dcad7fb802 --- /dev/null +++ b/test/language/module-code/export-expname_FIXTURE.js @@ -0,0 +1,9 @@ +// Copyright (C) 2020 Bradley Farias. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +flags: [module] +---*/ + +export { Mercury as "☿" }; +function Mercury() {} +globalThis.Mercury = Mercury;