test262/test/language/module-code/dynamic-import/assign-expr-get-value-abrupt-throws.js
Leo Balter b0ec060e62 Add more cases for Dynamic Imports usage
- Add cases for mixing module and script code
- Rename test case from return promise to thenable
- Fix script code case with valid loaded fixture
- Add a test to assert a promise return
- Add case for specifier toString rejection
- Add case for specifier toString
- Test Assignment expression abrupt completion
- Test Promise return
2018-10-11 11:09:47 -04:00

38 lines
1.2 KiB
JavaScript

// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Return Abrupt from the GetValue evaluation on the given AssignmentExpression
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 obj = {
get err() {
throw new Test262Error('catpure this on evaluation')
}
}
assert.throws(Test262Error, function() {
import(obj.err);
}, 'Custom Error getting property value');
assert.throws(ReferenceError, function() {
import(refErr);
}, 'bad reference');