2nd-param-with-value-non-string.js (2082B)
1 // |reftest| async 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 any property of the `assert` object is not a string 7 esid: sec-import-call-runtime-semantics-evaluation 8 info: | 9 2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] ) 10 [...] 11 10. If options is not undefined, then 12 [...] 13 d. If assertionsObj is not undefined, 14 [...] 15 ii. Let keys be EnumerableOwnPropertyNames(assertionsObj, key). 16 iii. IfAbruptRejectPromise(keys, promiseCapability). 17 iv. Let supportedAssertions be ! HostGetSupportedImportAssertions(). 18 v. For each String key of keys, 19 1. Let value be Get(assertionsObj, key). 20 2. IfAbruptRejectPromise(value, promiseCapability). 21 3. If Type(value) is not String, then 22 a. Perform ! Call(promiseCapability.[[Reject]], undefined, « a 23 newly created TypeError object »). 24 b. Return promiseCapability.[[Promise]]. 25 [...] 26 features: [dynamic-import, import-attributes, Symbol, BigInt] 27 flags: [async] 28 ---*/ 29 30 function test(promise, valueType) { 31 return promise.then(function() { 32 throw new Test262Error('Promise for ' + valueType + ' was not rejected.'); 33 }, function(error) { 34 assert.sameValue(error.constructor, TypeError, valueType); 35 }); 36 } 37 38 Promise.all([ 39 test(import('./2nd-param_FIXTURE.js', {with:{'': undefined}}), 'undefined'), 40 test(import('./2nd-param_FIXTURE.js', {with:{'': null}}), 'null'), 41 test(import('./2nd-param_FIXTURE.js', {with:{'': false}}), 'boolean'), 42 test(import('./2nd-param_FIXTURE.js', {with:{'': 23}}), 'number'), 43 test(import('./2nd-param_FIXTURE.js', {with:{'': Symbol('')}}), 'symbol'), 44 test(import('./2nd-param_FIXTURE.js', {with:{'': 23n}}), 'bigint'), 45 test(import('./2nd-param_FIXTURE.js', {with:{'': {}}}), 'object') 46 ]) 47 .then(function() {}) 48 .then($DONE, $DONE);