mirror of https://github.com/tc39/test262.git
Dynamic Imports: eval export default class imports
This commit is contained in:
parent
a3eef3f39f
commit
90e69a3b59
|
@ -0,0 +1,36 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Default "anonymous" class declaration is correctly initialized upon
|
||||
evaluation
|
||||
esid: sec-moduleevaluation
|
||||
info: |
|
||||
[...]
|
||||
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
|
||||
[...]
|
||||
|
||||
Runtime Semantics: Evaluation
|
||||
|
||||
ExportDeclaration : export default ClassDeclaration
|
||||
|
||||
[...]
|
||||
3. Let className be the sole element of BoundNames of ClassDeclaration.
|
||||
4. If className is "*default*", then
|
||||
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
|
||||
b. If hasNameProperty is false, perform SetFunctionName(value,
|
||||
"default").
|
||||
c. Let env be the running execution context's LexicalEnvironment.
|
||||
d. Perform ? InitializeBoundName("*default*", value, env).
|
||||
5. Return NormalCompletion(empty).
|
||||
flags: [async, module]
|
||||
features: [dynamic-import]
|
||||
---*/
|
||||
|
||||
export default class { valueOf() { return 45; } }
|
||||
import('./eval-export-dflt-cls-anon.js').then(imported => {
|
||||
assert.sameValue(new imported.default().valueOf(), 45, 'binding initialized');
|
||||
assert.sameValue(imported.default.name, 'default', 'correct name is assigned');
|
||||
}).then($DONE, $DONE).catch($DONE);
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Default "anonymous" class declaration containing a static `name` method is
|
||||
correctly initialized upon evaluation
|
||||
esid: sec-moduleevaluation
|
||||
info: |
|
||||
[...]
|
||||
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
|
||||
[...]
|
||||
|
||||
15.2.3.11 Runtime Semantics: Evaluation
|
||||
|
||||
ExportDeclaration : export default ClassDeclaration
|
||||
|
||||
[...]
|
||||
3. Let className be the sole element of BoundNames of ClassDeclaration.
|
||||
4. If className is "*default*", then
|
||||
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
|
||||
b. If hasNameProperty is false, perform SetFunctionName(value,
|
||||
"default").
|
||||
c. Let env be the running execution context's LexicalEnvironment.
|
||||
d. Perform ? InitializeBoundName("*default*", value, env).
|
||||
5. Return NormalCompletion(empty).
|
||||
flags: [async, module]
|
||||
features: [dynamic-import]
|
||||
---*/
|
||||
|
||||
export default class { static name() { return 'name method'; } }
|
||||
import('./eval-export-dflt-cls-name-meth.js').then(imported => {
|
||||
assert.sameValue(imported.default.name(), 'name method', '`name` property is not over-written');
|
||||
}).then($DONE, $DONE).catch($DONE);
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Default "named" class declaration is correctly initialized upon
|
||||
evaluation
|
||||
esid: sec-moduleevaluation
|
||||
info: |
|
||||
[...]
|
||||
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
|
||||
[...]
|
||||
|
||||
15.2.3.11 Runtime Semantics: Evaluation
|
||||
|
||||
ExportDeclaration : export default ClassDeclaration
|
||||
|
||||
[...]
|
||||
3. Let className be the sole element of BoundNames of ClassDeclaration.
|
||||
4. If className is "*default*", then
|
||||
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
|
||||
b. If hasNameProperty is false, perform SetFunctionName(value,
|
||||
"default").
|
||||
c. Let env be the running execution context's LexicalEnvironment.
|
||||
d. Perform ? InitializeBoundName("*default*", value, env).
|
||||
5. Return NormalCompletion(empty).
|
||||
flags: [async, module]
|
||||
features: [dynamic-import]
|
||||
---*/
|
||||
|
||||
export default class cName { valueOf() { return 45; } }
|
||||
import('./eval-export-dflt-cls-named.js').then(imported => {
|
||||
assert.sameValue(new imported.default().valueOf(), 45, 'binding initialized');
|
||||
assert.sameValue(imported.default.name, 'cName', 'correct name is assigned');
|
||||
}).then($DONE, $DONE).catch($DONE);
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Default AssignmentExpression (which can be recognized as an "anonymous"
|
||||
class declaration) is correctly initialized upon evaluation
|
||||
esid: sec-moduleevaluation
|
||||
info: |
|
||||
[...]
|
||||
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
|
||||
[...]
|
||||
|
||||
15.2.3.11 Runtime Semantics: Evaluation
|
||||
|
||||
ExportDeclaration : export default AssignmentExpression;
|
||||
|
||||
[...]
|
||||
3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
|
||||
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
|
||||
b. If hasNameProperty is false, perform SetFunctionName(value,
|
||||
"default").
|
||||
4. Let env be the running execution context's LexicalEnvironment.
|
||||
5. Perform ? InitializeBoundName("*default*", value, env).
|
||||
[...]
|
||||
flags: [async, module]
|
||||
features: [dynamic-import]
|
||||
---*/
|
||||
|
||||
export default (class { valueOf() { return 45; } });
|
||||
import('./eval-export-dflt-expr-cls-anon.js').then(imported => {
|
||||
assert.sameValue(new imported.default().valueOf(), 45, 'binding initialized');
|
||||
assert.sameValue(imported.default.name, 'default', 'correct name is assigned');
|
||||
}).then($DONE, $DONE).catch($DONE);
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Default AssignmentExpression (which can be recognized as an "anonymous"
|
||||
class declaration with a static `name` method) is correctly initialized
|
||||
upon evaluation
|
||||
esid: sec-moduleevaluation
|
||||
info: |
|
||||
[...]
|
||||
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
|
||||
[...]
|
||||
|
||||
15.2.3.11 Runtime Semantics: Evaluation
|
||||
|
||||
ExportDeclaration : export default ClassDeclaration
|
||||
|
||||
[...]
|
||||
3. Let className be the sole element of BoundNames of ClassDeclaration.
|
||||
4. If className is "*default*", then
|
||||
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
|
||||
b. If hasNameProperty is false, perform SetFunctionName(value,
|
||||
"default").
|
||||
c. Let env be the running execution context's LexicalEnvironment.
|
||||
d. Perform ? InitializeBoundName("*default*", value, env).
|
||||
5. Return NormalCompletion(empty).
|
||||
flags: [async, module]
|
||||
features: [dynamic-import]
|
||||
---*/
|
||||
|
||||
export default (class { static name() { return 'name method'; } });
|
||||
import('./eval-export-dflt-expr-cls-name-meth.js').then(imported => {
|
||||
assert.sameValue(imported.default.name(), 'name method', '`name` property is not over-written');
|
||||
}).then($DONE, $DONE).catch($DONE);
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Default AssignmentExpression (which can be recognized as a "named" class
|
||||
declaration) is correctly initialized upon evaluation
|
||||
esid: sec-moduleevaluation
|
||||
info: |
|
||||
[...]
|
||||
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
|
||||
[...]
|
||||
|
||||
15.2.3.11 Runtime Semantics: Evaluation
|
||||
|
||||
ExportDeclaration : export default AssignmentExpression;
|
||||
|
||||
[...]
|
||||
3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
|
||||
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
|
||||
b. If hasNameProperty is false, perform SetFunctionName(value,
|
||||
"default").
|
||||
4. Let env be the running execution context's LexicalEnvironment.
|
||||
5. Perform ? InitializeBoundName("*default*", value, env).
|
||||
[...]
|
||||
flags: [async, module]
|
||||
features: [dynamic-import]
|
||||
---*/
|
||||
|
||||
export default (class cName { valueOf() { return 45; } });
|
||||
import('./eval-export-dflt-expr-cls-named.js').then(imported => {
|
||||
assert.sameValue(new imported.default().valueOf(), 45, 'binding initialized');
|
||||
assert.sameValue(imported.default.name, 'cName', 'correct name is assigned');
|
||||
}).then($DONE, $DONE).catch($DONE);
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Default AssignmentExpression (which can be recognized as an "anonymous"
|
||||
function declaration) is correctly initialized upon evaluation
|
||||
esid: sec-moduleevaluation
|
||||
info: |
|
||||
[...]
|
||||
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
|
||||
[...]
|
||||
|
||||
15.2.3.11 Runtime Semantics: Evaluation
|
||||
|
||||
ExportDeclaration : export default AssignmentExpression;
|
||||
|
||||
[...]
|
||||
3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
|
||||
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
|
||||
b. If hasNameProperty is false, perform SetFunctionName(value,
|
||||
"default").
|
||||
4. Let env be the running execution context's LexicalEnvironment.
|
||||
5. Perform ? InitializeBoundName("*default*", value, env).
|
||||
[...]
|
||||
flags: [async, module]
|
||||
features: [dynamic-import]
|
||||
---*/
|
||||
|
||||
export default (function() { return 99; });
|
||||
import('./eval-export-dflt-expr-fn-anon.js').then(imported => {
|
||||
assert.sameValue(imported.default(), 99, 'binding initialized');
|
||||
assert.sameValue(imported.default.name, 'default', 'correct name is assigned');
|
||||
}).then($DONE, $DONE).catch($DONE);
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Default AssignmentExpression (which can be recognized as a "named" function
|
||||
declaration) is correctly initialized upon evaluation
|
||||
esid: sec-moduleevaluation
|
||||
info: |
|
||||
[...]
|
||||
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
|
||||
[...]
|
||||
|
||||
15.2.3.11 Runtime Semantics: Evaluation
|
||||
|
||||
ExportDeclaration : export default AssignmentExpression;
|
||||
|
||||
[...]
|
||||
3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
|
||||
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
|
||||
b. If hasNameProperty is false, perform SetFunctionName(value,
|
||||
"default").
|
||||
4. Let env be the running execution context's LexicalEnvironment.
|
||||
5. Perform ? InitializeBoundName("*default*", value, env).
|
||||
[...]
|
||||
flags: [async, module]
|
||||
features: [dynamic-import]
|
||||
---*/
|
||||
|
||||
export default (function fName() { return 7; });
|
||||
import('./eval-export-dflt-expr-fn-named.js').then(imported => {
|
||||
assert.sameValue(imported.default(), 7, 'binding initialized');
|
||||
assert.sameValue(imported.default.name, 'fName', 'correct name is assigned');
|
||||
}).then($DONE, $DONE).catch($DONE);
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Default AssignmentExpression (which can be recognized as an "anonymous"
|
||||
generator function declaration) is correctly initialized upon evaluation
|
||||
esid: sec-moduleevaluation
|
||||
info: |
|
||||
[...]
|
||||
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
|
||||
[...]
|
||||
|
||||
15.2.3.11 Runtime Semantics: Evaluation
|
||||
|
||||
ExportDeclaration : export default AssignmentExpression;
|
||||
|
||||
[...]
|
||||
3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
|
||||
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
|
||||
b. If hasNameProperty is false, perform SetFunctionName(value,
|
||||
"default").
|
||||
4. Let env be the running execution context's LexicalEnvironment.
|
||||
5. Perform ? InitializeBoundName("*default*", value, env).
|
||||
[...]
|
||||
flags: [async, module]
|
||||
features: [dynamic-import, generators]
|
||||
---*/
|
||||
|
||||
export default (function* () { return 24601; });
|
||||
import('./eval-export-dflt-expr-gen-anon.js').then(imported => {
|
||||
assert.sameValue(imported.default().next().value, 24601, 'binding initialized');
|
||||
assert.sameValue(imported.default.name, 'default', 'correct name is assigned');
|
||||
}).then($DONE, $DONE).catch($DONE);
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Default AssignmentExpression (which can be recognized as a "named"
|
||||
generator function declaration) is correctly initialized upon evaluation
|
||||
esid: sec-moduleevaluation
|
||||
info: |
|
||||
[...]
|
||||
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
|
||||
[...]
|
||||
|
||||
15.2.3.11 Runtime Semantics: Evaluation
|
||||
|
||||
ExportDeclaration : export default AssignmentExpression;
|
||||
|
||||
[...]
|
||||
3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
|
||||
a. Let hasNameProperty be ? HasOwnProperty(value, "name").
|
||||
b. If hasNameProperty is false, perform SetFunctionName(value,
|
||||
"default").
|
||||
4. Let env be the running execution context's LexicalEnvironment.
|
||||
5. Perform ? InitializeBoundName("*default*", value, env).
|
||||
[...]
|
||||
flags: [async, module]
|
||||
features: [dynamic-import, generators]
|
||||
---*/
|
||||
|
||||
export default (function* gName() { return 42; });
|
||||
import('./eval-export-dflt-expr-gen-named.js').then(imported => {
|
||||
assert.sameValue(imported.default().next().value, 42, 'binding initialized');
|
||||
assert.sameValue(imported.default.name, 'gName', 'correct name is assigned');
|
||||
}).then($DONE, $DONE).catch($DONE);
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
The `in` operator may occur within an exported AssignmentExpression
|
||||
esid: sec-moduleevaluation
|
||||
info: |
|
||||
[...]
|
||||
16. Let result be the result of evaluating module.[[ECMAScriptCode]].
|
||||
[...]
|
||||
|
||||
15.2.3 Exports
|
||||
|
||||
Syntax
|
||||
|
||||
ExportDeclaration :
|
||||
|
||||
export default [lookahead ∉ { function, class }] AssignmentExpression[In];
|
||||
flags: [async, module]
|
||||
features: [dynamic-import]
|
||||
---*/
|
||||
var x = { x: true };
|
||||
|
||||
export default 'x' in x;
|
||||
import('./eval-export-dflt-expr-in.js').then(imported => {
|
||||
assert.sameValue(imported.default, true);
|
||||
}).then($DONE, $DONE).catch($DONE);
|
|
@ -1,9 +0,0 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
var x = 1;
|
||||
export { x };
|
||||
|
||||
Function('return this;')().test262update = function() {
|
||||
x = 2;
|
||||
};
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Modifications to default binding that occur after dependency has been
|
||||
evaluated are reflected in local binding
|
||||
info: |
|
||||
8.1.1.5.1 GetBindingValue (N, S)
|
||||
|
||||
[...]
|
||||
3. If the binding for N is an indirect binding, then
|
||||
a. Let M and N2 be the indirection values provided when this binding for
|
||||
N was created.
|
||||
b. Let targetEnv be M.[[Environment]].
|
||||
c. If targetEnv is undefined, throw a ReferenceError exception.
|
||||
d. Let targetER be targetEnv's EnvironmentRecord.
|
||||
e. Return ? targetER.GetBindingValue(N2, S).
|
||||
flags: [async, module]
|
||||
features: [dynamic-import]
|
||||
---*/
|
||||
|
||||
import('./eval-gtbndng-indirect-update-dflt_FIXTURE.js').then(imported => {
|
||||
assert.sameValue(imported.default(), 1);
|
||||
assert.sameValue(imported.default, 2);
|
||||
}).then($DONE, $DONE).catch($DONE);
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Modifications to named bindings that occur after dependency has been
|
||||
evaluated are reflected in local binding
|
||||
esid: sec-moduleevaluation
|
||||
info: |
|
||||
8.1.1.5.1 GetBindingValue (N, S)
|
||||
|
||||
[...]
|
||||
3. If the binding for N is an indirect binding, then
|
||||
a. Let M and N2 be the indirection values provided when this binding for
|
||||
N was created.
|
||||
b. Let targetEnv be M.[[Environment]].
|
||||
c. If targetEnv is undefined, throw a ReferenceError exception.
|
||||
d. Let targetER be targetEnv's EnvironmentRecord.
|
||||
e. Return ? targetER.GetBindingValue(N2, S).
|
||||
includes: [fnGlobalObject.js]
|
||||
flags: [async, module]
|
||||
features: [dynamic-import]
|
||||
---*/
|
||||
|
||||
import('./eval-gtbndng-indirect-update_FIXTURE.js').then(imported => {
|
||||
assert.sameValue(imported.x, 1);
|
||||
|
||||
// This function is exposed on the global scope (instead of as an exported
|
||||
// binding) in order to avoid possible false positives from assuming correct
|
||||
// behavior of the semantics under test.
|
||||
fnGlobalObject().test262update();
|
||||
|
||||
assert.sameValue(imported.x, 2);
|
||||
});
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (C) 2018 Rick Waldron. All rights reserved.
|
||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
Abrupt completion during module evaluation precludes further evaluation
|
||||
esid: sec-moduleevaluation
|
||||
info: |
|
||||
[...]
|
||||
6. For each String required that is an element of
|
||||
module.[[RequestedModules]] do,
|
||||
a. Let requiredModule be ? HostResolveImportedModule(module, required).
|
||||
b. Perform ? requiredModule.ModuleEvaluation().
|
||||
flags: [async, module]
|
||||
features: [dynamic-import]
|
||||
---*/
|
||||
|
||||
import('./eval-rqstd-abrupt-err-type_FIXTURE.js').then($DONE, error => {
|
||||
// negative:
|
||||
// phase: runtime
|
||||
// type: TypeError
|
||||
assert.sameValue(error instanceof TypeError, true);
|
||||
}).then($DONE, $DONE).catch($DONE);
|
Loading…
Reference in New Issue