-
Notifications
You must be signed in to change notification settings - Fork 464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests for export * as ns from 'foo'
syntax
#1498
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0860ca8
export-ns: update and add tests for semicolon production rules
03ce17d
export-ns: update info tags with new production
acf9bd9
export-ns: add tests for duplicate ExportedNames
52b3198
export-ns: success cases for 'import *' of module with 'export * (as …
6b59dbb
export-ns: case for not exporting default exports with
e5274c9
export-ns: add test case to instn-once.js and eval-self-once.js
95e8a64
export-ns: eval order/once
707a526
export-ns: default skipped for nested namespace
67e5a76
export-ns: success case for initializing nested namespace
fd9b982
export-ns: add feature
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2018 Valerie Young. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-module-semantics-static-semantics-early-errors | ||
description: > | ||
It is a Syntax Error if the ExportedNames of ModuleItemList contains any | ||
duplicate entries. | ||
flags: [module, export-star-as-namespace-from-module] | ||
negative: | ||
phase: parse | ||
type: SyntaxError | ||
---*/ | ||
|
||
throw "Test262: This statement should not be evaluated."; | ||
|
||
var x; | ||
export { x as z }; | ||
export * as z from "early-dup-export-as-star-as.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
test/language/module-code/early-dup-export-star-as-dflt.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2018 Valerie Young. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-module-semantics-static-semantics-early-errors | ||
description: > | ||
It is a Syntax Error if the ExportedNames of ModuleItemList contains any | ||
duplicate entries. | ||
flags: [module, export-star-as-namespace-from-module] | ||
negative: | ||
phase: parse | ||
type: SyntaxError | ||
---*/ | ||
|
||
throw "Test262: This statement should not be evaluated."; | ||
|
||
var x; | ||
export default x; | ||
export * as default from 'early-dup-export-start-as-dflt.js'; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright (C) 2018 Valerie Young. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
Function('return this;')().test262 += '9'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
test/language/module-code/instn-star-as-props-dflt-skip.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (C) 2018 Valerie Young. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
description: > | ||
Default exports are not included in an imported module namespace object when module exported with `* as namespace` | ||
esid: sec-moduledeclarationinstantiation | ||
info: | | ||
[...] | ||
4. Let result be InnerModuleInstantiation(module, stack, 0). | ||
[...] | ||
|
||
InnerModuleInstantiation( module, stack, index ) | ||
[...] | ||
10. Perform ? ModuleDeclarationEnvironmentSetup(module). | ||
[...] | ||
|
||
ModuleDeclarationEnvironmentSetup( module ) | ||
[...] | ||
c. If in.[[ImportName]] is "*", then | ||
[...] | ||
d. Else, | ||
i. Let resolution be ? importedModule.ResolveExport(in.[[ImportName]], « »). | ||
ii. If resolution is null or "ambiguous", throw a SyntaxError exception. | ||
iii. If resolution.[[BindingName]] is "*namespace*", then | ||
1. Let namespace be ? GetModuleNamespace(resolution.[[Module]]). | ||
[...] | ||
|
||
15.2.1.18 Runtime Semantics: GetModuleNamespace | ||
|
||
[...] | ||
3. If namespace is undefined, then | ||
a. Let exportedNames be ? module.GetExportedNames(« »). | ||
[...] | ||
|
||
15.2.1.16.2 GetExportedNames | ||
|
||
[...] | ||
7. For each ExportEntry Record e in module.[[StarExportEntries]], do | ||
[...] | ||
c. For each element n of starNames, do | ||
i. If SameValue(n, "default") is false, then | ||
[...] | ||
flags: [module, export-star-as-namespace-from-module] | ||
---*/ | ||
|
||
import named from './instn-star-props-dflt-skip-star-as-named_FIXTURE.js'; | ||
import production from './instn-star-props-dflt-skip-star-as-prod_FIXTURE.js'; | ||
|
||
assert('namedOther' in named); | ||
assert.sameValue( | ||
'default' in named, false, 'default specified via identifier' | ||
); | ||
|
||
assert('productionOther' in production); | ||
assert.sameValue( | ||
'default' in production, false, 'default specified via dedicated production' | ||
); |
6 changes: 6 additions & 0 deletions
6
test/language/module-code/instn-star-props-dflt-skip-star-as-named-end_FIXTURE.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (C) 2018 Valerie Young. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
var x; | ||
export var namedOther = null; | ||
export { x as default }; |
4 changes: 4 additions & 0 deletions
4
test/language/module-code/instn-star-props-dflt-skip-star-as-named_FIXTURE.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright (C) 2018 Valerie Young. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
export * as named from './instn-star-props-dflt-skip-star-as-named-end_FIXTURE.js'; |
5 changes: 5 additions & 0 deletions
5
test/language/module-code/instn-star-props-dflt-skip-star-as-prod-end_FIXTURE.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (C) 2018 Valerie Young. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
export var productionOther = null; | ||
export default null; |
4 changes: 4 additions & 0 deletions
4
test/language/module-code/instn-star-props-dflt-skip-star-as-prod_FIXTURE.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright (C) 2018 Valerie Young. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
export * as production from './instn-star-props-dflt-skip-star-as-prod-end_FIXTURE.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...guage/module-code/namespace/internals/get-nested-namespace-dflt-skip-named-end_FIXTURE.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (C) 2018 Valerie Young. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
var x; | ||
export var namedOther = null; | ||
export { x as default }; |
4 changes: 4 additions & 0 deletions
4
.../language/module-code/namespace/internals/get-nested-namespace-dflt-skip-named_FIXTURE.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright (C) 2018 Valerie Young. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
export * as namedns2 from './get-nested-namespace-dflt-skip-named-end_FIXTURE.js'; |
5 changes: 5 additions & 0 deletions
5
...nguage/module-code/namespace/internals/get-nested-namespace-dflt-skip-prod-end_FIXTURE.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (C) 2018 Valerie Young. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
export var productionOther = null; | ||
export default null; |
4 changes: 4 additions & 0 deletions
4
test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip-prod_FIXTURE.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright (C) 2018 Valerie Young. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
export * as productionns2 from './get-nested-namespace-dflt-skip-prod-end_FIXTURE.js'; |
42 changes: 42 additions & 0 deletions
42
test/language/module-code/namespace/internals/get-nested-namespace-dflt-skip.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (C) 2018 Valerie Young. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
description: > | ||
Default exports are not included in an imported module namespace object when a namespace object is created. | ||
esid: sec-module-namespace-exotic-objects-get-p-receiver | ||
info: | | ||
[...] | ||
6. Let binding be ! m.ResolveExport(P, « »). | ||
7. Assert: binding is a ResolvedBinding Record. | ||
8. Let targetModule be binding.[[Module]]. | ||
9. Assert: targetModule is not undefined. | ||
10. If binding.[[BindingName]] is "*namespace*", then | ||
11. Return ? GetModuleNamespace(targetModule). | ||
|
||
Runtime Semantics: GetModuleNamespace | ||
[...] | ||
3. If namespace is undefined, then | ||
a. Let exportedNames be ? module.GetExportedNames(« »). | ||
b. Let unambiguousNames be a new empty List. | ||
c. For each name that is an element of exportedNames, | ||
i. Let resolution be ? module.ResolveExport(name, « », « »). | ||
ii. If resolution is null, throw a SyntaxError exception. | ||
iii. If resolution is not "ambiguous", append name to | ||
unambiguousNames. | ||
d. Let namespace be ModuleNamespaceCreate(module, unambiguousNames). | ||
[...] | ||
flags: [module, export-star-as-namespace-from-module] | ||
---*/ | ||
|
||
import * as namedns1 from './get-nested-namespace-dflt-skip-named_FIXTURE.js'; | ||
import * as productionns1 from './get-nested-namespace-dflt-skip-prod_FIXTURE.js'; | ||
|
||
assert('namedOther' in namedns1.namedns2); | ||
assert.sameValue( | ||
'default' in namedns1.namedns2, false, 'default specified via identifier' | ||
); | ||
|
||
assert('productionOther' in productionns1.productionns2); | ||
assert.sameValue( | ||
'default' in productionns1.productionns2, false, 'default specified via dedicated production' | ||
); |
4 changes: 4 additions & 0 deletions
4
test/language/module-code/namespace/internals/get-nested-namespace-props-nrml-1_FIXTURE.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright (C) 2018 Valerie Young. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
export * as exportns from './get-nested-namespace-props-nrml-2_FIXTURE.js'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make sense to have a positive test case for
export * as default from
.