Debian Codegraph @

js/src/tests/test262/language/expressions/dynamic-import/import-attributes/2nd-param-non-object.js

raw
1 // |reftest| shell-option(--enable-import-attributes) skip-if(!xulRuntime.shell) async -- requires shell-options
2 // Copyright (C) 2021 the V8 project authors. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 description: >
6 Rejects promise when the second argument is neither undefined nor an object
7 esid: sec-import-call-runtime-semantics-evaluation
8 info: |
9 2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] )
10 [...]
11 6. Let promiseCapability be ! NewPromiseCapability(%Promise%).
12 7. Let specifierString be ToString(specifier).
13 8. IfAbruptRejectPromise(specifierString, promiseCapability).
14 9. Let assertions be a new empty List.
15 10. If options is not undefined, then
16 a. If Type(options) is not Object,
17 i. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
18 ii. Return promiseCapability.[[Promise]].
19 [...]
20 features: [dynamic-import, import-attributes, Symbol, BigInt]
21 flags: [async]
22 ---*/
23
24 function test(promise, valueType) {
25 return promise.then(function() {
26 throw new Test262Error('Promise for ' + valueType + ' was not rejected.');
27 }, function(error) {
28 assert.sameValue(error.constructor, TypeError, valueType);
29 });
30 }
31
32 Promise.all([
33 test(import('./2nd-param_FIXTURE.js', null), 'null'),
34 test(import('./2nd-param_FIXTURE.js', false), 'boolean'),
35 test(import('./2nd-param_FIXTURE.js', 23), 'number'),
36 test(import('./2nd-param_FIXTURE.js', ''), 'string'),
37 test(import('./2nd-param_FIXTURE.js', Symbol('')), 'symbol'),
38 test(import('./2nd-param_FIXTURE.js', 23n), 'bigint')
39 ])
40 .then(function() {})
41 .then($DONE, $DONE);