mirror of https://github.com/tc39/test262.git
Add more cases for import.meta and new promise instances
This commit is contained in:
parent
bcdc613df7
commit
91bf2474c2
|
@ -0,0 +1,34 @@
|
|||
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
description: >
|
||||
ImportCall returns a new instance of Promise
|
||||
esid: sec-import-call-runtime-semantics-evaluation
|
||||
info: |
|
||||
Import Calls
|
||||
|
||||
Runtime Semantics: Evaluation
|
||||
|
||||
ImportCall : import(AssignmentExpression)
|
||||
|
||||
1. Let referencingScriptOrModule be ! GetActiveScriptOrModule().
|
||||
2. Let argRef be the result of evaluating AssignmentExpression.
|
||||
3. Let specifier be ? GetValue(argRef).
|
||||
4. Let promiseCapability be ! NewPromiseCapability(%Promise%).
|
||||
5. Let specifierString be ToString(specifier).
|
||||
6. IfAbruptRejectPromise(specifierString, promiseCapability).
|
||||
7. Perform ! HostImportModuleDynamically(referencingScriptOrModule, specifierString, promiseCapability).
|
||||
8. Return promiseCapability.[[Promise]].
|
||||
features: [dynamic-import]
|
||||
---*/
|
||||
|
||||
const p1 = import('./dynamic-import-module_FIXTURE.js');
|
||||
const p2 = import('./dynamic-import-module_FIXTURE.js');
|
||||
|
||||
assert.notSameValue(p1, p2, 'the returned promises are not the same, regardless the reference and specifier pair');
|
||||
|
||||
assert.sameValue(p1.constructor, Promise, 'p1 constructor is %Promise%');
|
||||
assert.sameValue(Object.getPrototypeOf(p1), Promise.prototype, 'p1 prototype is %PromisePrototype%');
|
||||
|
||||
assert.sameValue(p2.constructor, Promise, 'p2 constructor is %Promise%');
|
||||
assert.sameValue(Object.getPrototypeOf(p2), Promise.prototype, 'p2 prototype is %PromisePrototype%');
|
|
@ -0,0 +1,36 @@
|
|||
// 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 (ImportMeta)
|
||||
esid: prod-ImportCall
|
||||
info: |
|
||||
ImportCall [Yield]:
|
||||
import ( AssignmentExpression[+In, ?Yield] )
|
||||
|
||||
Runtime Semantics: Evaluation
|
||||
|
||||
ImportCall : import ( AssignmentExpression )
|
||||
|
||||
...
|
||||
5. Let specifierString be ToString(specifier).
|
||||
6. IfAbruptRejectPromise(specifierString, promiseCapability).
|
||||
features: [dynamic-import, import.meta]
|
||||
flags: [module, async]
|
||||
---*/
|
||||
|
||||
const p = import(import.meta);
|
||||
|
||||
// We can at least assert p is a promise.
|
||||
assert.sameValue(Promise.resolve(p), p, 'Assert that p is a promise');
|
||||
|
||||
// The keys of import.meta are implementation defined, but we know its
|
||||
// [[Prototype]] is null. In this case, import() should reject the
|
||||
// promise it returns, unless a toPrimitive related method is set.
|
||||
if (!Object.prototype.hasOwnProperty.call(import.meta, 'toString') &&
|
||||
!Object.prototype.hasOwnProperty.call(import.meta, 'valueOf') &&
|
||||
!Object.prototype.hasOwnProperty.call(import.meta, Symbol.toPrimitive)) {
|
||||
p.catch(error => assert.sameValue(error.constructor, TypeError, 'import() cannot resolve import.meta')).then($DONE, $DONE);
|
||||
} else {
|
||||
$DONE();
|
||||
}
|
Loading…
Reference in New Issue