Exports can be Arbitrary Strings

This commit is contained in:
Bradley Farias 2020-09-29 15:32:01 -05:00 committed by Rick Waldron
parent 2fade3db47
commit c43c9d8448
10 changed files with 184 additions and 0 deletions

View File

@ -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() {}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -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;