Add tests for import assertions

This commit is contained in:
Mike Pennisi 2021-04-29 22:28:12 -04:00 committed by Rick Waldron
parent 219ad6ff01
commit 18834b2e19
43 changed files with 1145 additions and 18 deletions

View File

@ -307,3 +307,7 @@ class-fields-private-in
# Error cause
# https://github.com/tc39/proposal-error-cause
error-cause
# Import Assertions
# https://github.com/tc39/proposal-import-assertions/
import-assertions

View File

@ -5,7 +5,8 @@ desc: ImportCall is not extensible - no arguments list
template: syntax/invalid
info: |
ImportCall :
import( AssignmentExpression[+In, ?Yield] )
import( AssignmentExpression[+In, ?Yield, ?Await] ,opt )
import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt )
Forbidden Extensions
@ -13,4 +14,4 @@ info: |
---*/
//- import
import('', '')
import('./empty_FIXTURE.js', {}, '')

View File

@ -1,16 +0,0 @@
// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: ImportCall is not extensible - trailing comma
template: syntax/invalid
info: |
ImportCall :
import( AssignmentExpression[+In, ?Yield] )
Forbidden Extensions
- ImportCall must not be extended.
---*/
//- import
import('',)

View File

@ -0,0 +1,14 @@
// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: ImportCall trailing comma following first parameter
template: syntax/valid
info: |
ImportCall :
import( AssignmentExpression[+In, ?Yield, ?Await] ,opt )
import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt )
features: [import-assertions]
---*/
//- import
import('./empty_FIXTURE.js',)

View File

@ -0,0 +1,14 @@
// Copyright (C) 2021 V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: ImportCall trailing comma following second parameter
template: syntax/valid
info: |
ImportCall :
import( AssignmentExpression[+In, ?Yield, ?Await] ,opt )
import( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt )
features: [import-assertions]
---*/
//- import
import('./empty_FIXTURE.js', {},)

View File

@ -0,0 +1,43 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Reports abrupt completions produced by assertion enumeration
esid: sec-import-call-runtime-semantics-evaluation
info: |
2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] )
[...]
6. Let promiseCapability be ! NewPromiseCapability(%Promise%).
7. Let specifierString be ToString(specifier).
8. IfAbruptRejectPromise(specifierString, promiseCapability).
9. Let assertions be a new empty List.
10. If options is not undefined, then
a. If Type(options) is not Object,
[...]
b. Let assertionsObj be Get(options, "assert").
c. IfAbruptRejectPromise(assertionsObj, promiseCapability).
d. If assertionsObj is not undefined,
i. If Type(assertionsObj) is not Object,
[...]
ii. Let keys be EnumerableOwnPropertyNames(assertionsObj, key).
iii. IfAbruptRejectPromise(keys, promiseCapability).
[...]
features: [dynamic-import, import-assertions, Proxy]
flags: [async]
---*/
var thrown = new Test262Error();
var options = {
assert: new Proxy({}, {
ownKeys: function() {
throw thrown;
},
})
};
import('./2nd-param_FIXTURE.js', options)
.then(function() {
throw new Test262Error('Expected promise to be rejected, but promise was fulfilled.');
}, function(error) {
assert.sameValue(error, thrown);
})
.then($DONE, $DONE);

View File

@ -0,0 +1,68 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Follows the semantics of the EnumerableOwnPropertyNames abstract operation
during assertion enumeration
esid: sec-import-call-runtime-semantics-evaluation
info: |
2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] )
[...]
6. Let promiseCapability be ! NewPromiseCapability(%Promise%).
7. Let specifierString be ToString(specifier).
8. IfAbruptRejectPromise(specifierString, promiseCapability).
9. Let assertions be a new empty List.
10. If options is not undefined, then
a. If Type(options) is not Object,
[...]
b. Let assertionsObj be Get(options, "assert").
c. IfAbruptRejectPromise(assertionsObj, promiseCapability).
d. If assertionsObj is not undefined,
i. If Type(assertionsObj) is not Object,
[...]
ii. Let keys be EnumerableOwnPropertyNames(assertionsObj, key).
[...]
features: [dynamic-import, import-assertions, Symbol, Proxy]
flags: [async]
---*/
var symbol = Symbol('');
var target = {
enumerable1: '',
enumerable2: '',
[symbol]: '',
unreported: '',
nonEnumerable: ''
};
var descriptors = {
enumerable1: {configurable: true, enumerable: true},
enumerable2: {configurable: true, enumerable: true},
[symbol]: {configurable: true, enumerable: true},
nonEnumerable: {configurable: true, enumerable: false}
};
var log = [];
var options = {
assert: new Proxy({}, {
ownKeys: function() {
return ['enumerable1', symbol, 'nonEnumerable', 'absent', 'enumerable2'];
},
get(_, name) {
log.push(name);
return target[name];
},
getOwnPropertyDescriptor(target, name) {
return descriptors[name];
}
})
};
import('./2nd-param_FIXTURE.js', options)
.then(function(module) {
assert.sameValue(module.default, 262);
})
.then($DONE, $DONE);
assert.sameValue(log.length, 2);
assert.sameValue(log[0], 'enumerable1');
assert.sameValue(log[1], 'enumerable2');

View File

@ -0,0 +1,47 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Rejects promise when the `assert` property of the second argument is neither
undefined nor an object
esid: sec-import-call-runtime-semantics-evaluation
info: |
2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] )
[...]
6. Let promiseCapability be ! NewPromiseCapability(%Promise%).
7. Let specifierString be ToString(specifier).
8. IfAbruptRejectPromise(specifierString, promiseCapability).
9. Let assertions be a new empty List.
10. If options is not undefined, then
a. If Type(options) is not Object,
[...]
b. Let assertionsObj be Get(options, "assert").
c. IfAbruptRejectPromise(assertionsObj, promiseCapability).
d. If assertionsObj is not undefined,
i. If Type(assertionsObj) is not Object,
1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a
newly created TypeError object »).
2. Return promiseCapability.[[Promise]].
[...]
features: [dynamic-import, import-assertions, Symbol, BigInt]
flags: [async]
---*/
function test(promise, valueType) {
return promise.then(function() {
throw new Test262Error('Promise for ' + valueType + ' was not rejected.');
}, function(error) {
assert.sameValue(error.constructor, TypeError, valueType);
});
}
Promise.all([
test(import('./2nd-param_FIXTURE.js', {assert:null}), 'null'),
test(import('./2nd-param_FIXTURE.js', {assert:false}), 'boolean'),
test(import('./2nd-param_FIXTURE.js', {assert:23}), 'number'),
test(import('./2nd-param_FIXTURE.js', {assert:''}), 'string'),
test(import('./2nd-param_FIXTURE.js', {assert:Symbol('')}), 'symbol'),
test(import('./2nd-param_FIXTURE.js', {assert:23n}), 'bigint')
])
.then(function() {})
.then($DONE, $DONE);

View File

@ -0,0 +1,36 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Accepts undefined for the `assert` property of the second argument
esid: sec-import-call-runtime-semantics-evaluation
info: |
2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] )
[...]
6. Let promiseCapability be ! NewPromiseCapability(%Promise%).
7. Let specifierString be ToString(specifier).
8. IfAbruptRejectPromise(specifierString, promiseCapability).
9. Let assertions be a new empty List.
10. If options is not undefined, then
a. If Type(options) is not Object,
[...]
b. Let assertionsObj be Get(options, "assert").
c. IfAbruptRejectPromise(assertionsObj, promiseCapability).
d. If assertionsObj is not undefined,
i. If Type(assertionsObj) is not Object,
1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a
newly created TypeError object »).
2. Return promiseCapability.[[Promise]].
[...]
features: [dynamic-import, import-assertions, Symbol, BigInt]
flags: [async]
---*/
Promise.all([
import('./2nd-param_FIXTURE.js', {}),
import('./2nd-param_FIXTURE.js', {assert:undefined}),
])
.then(function(values) {
assert.sameValue(values[0].default, 262);
assert.sameValue(values[1].default, 262);
})
.then($DONE, $DONE);

View File

@ -0,0 +1,34 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Rejects promise when retrieving a value of the `assert` object produces an
abrupt completion
esid: sec-import-call-runtime-semantics-evaluation
info: |
2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] )
[...]
10. If options is not undefined, then
[...]
d. If assertionsObj is not undefined,
[...]
ii. Let keys be EnumerableOwnPropertyNames(assertionsObj, key).
iii. IfAbruptRejectPromise(keys, promiseCapability).
iv. Let supportedAssertions be ! HostGetSupportedImportAssertions().
v. For each String key of keys,
1. Let value be Get(assertionsObj, key).
2. IfAbruptRejectPromise(value, promiseCapability).
[...]
features: [dynamic-import, import-assertions]
flags: [async]
---*/
var thrown = new Test262Error();
import('./2nd-param_FIXTURE.js', {assert:{get ''() { throw thrown; }}})
.then(function() {
throw new Test262Error('Expected promise to be rejected, but it was fulfilled');
}, function(error) {
assert.sameValue(error, thrown);
})
.then($DONE, $DONE);

View File

@ -0,0 +1,47 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Rejects promise when any property of the `assert` object is not a string
esid: sec-import-call-runtime-semantics-evaluation
info: |
2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] )
[...]
10. If options is not undefined, then
[...]
d. If assertionsObj is not undefined,
[...]
ii. Let keys be EnumerableOwnPropertyNames(assertionsObj, key).
iii. IfAbruptRejectPromise(keys, promiseCapability).
iv. Let supportedAssertions be ! HostGetSupportedImportAssertions().
v. For each String key of keys,
1. Let value be Get(assertionsObj, key).
2. IfAbruptRejectPromise(value, promiseCapability).
3. If Type(value) is not String, then
a. Perform ! Call(promiseCapability.[[Reject]], undefined, « a
newly created TypeError object »).
b. Return promiseCapability.[[Promise]].
[...]
features: [dynamic-import, import-assertions, Symbol, BigInt]
flags: [async]
---*/
function test(promise, valueType) {
return promise.then(function() {
throw new Test262Error('Promise for ' + valueType + ' was not rejected.');
}, function(error) {
assert.sameValue(error.constructor, TypeError, valueType);
});
}
Promise.all([
test(import('./2nd-param_FIXTURE.js', {assert:{'': undefined}}), 'undefined'),
test(import('./2nd-param_FIXTURE.js', {assert:{'': null}}), 'null'),
test(import('./2nd-param_FIXTURE.js', {assert:{'': false}}), 'boolean'),
test(import('./2nd-param_FIXTURE.js', {assert:{'': 23}}), 'number'),
test(import('./2nd-param_FIXTURE.js', {assert:{'': Symbol('')}}), 'symbol'),
test(import('./2nd-param_FIXTURE.js', {assert:{'': 23n}}), 'bigint'),
test(import('./2nd-param_FIXTURE.js', {assert:{'': {}}}), 'object')
])
.then(function() {})
.then($DONE, $DONE);

View File

@ -0,0 +1,21 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
ImportCall parameter list forwards the Await production parameter - AwaitExpression
esid: sec-import-call-runtime-semantics-evaluation
info: |
ImportCall[Yield, Await]:
import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt )
import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt )
features: [dynamic-import, import-assertions, async-functions]
flags: [async]
---*/
(async function () {
return import('./2nd-param_FIXTURE.js', await undefined);
}())
.then(function(module) {
assert.sameValue(module.default, 262);
})
.then($DONE, $DONE);

View File

@ -0,0 +1,21 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
ImportCall parameter list forwards the Await production parameter - IdentifierReference
esid: sec-import-call-runtime-semantics-evaluation
info: |
ImportCall[Yield, Await]:
import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt )
import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt )
features: [dynamic-import, import-assertions, async-functions]
flags: [async]
---*/
function await() {}
import('./2nd-param_FIXTURE.js', await(undefined))
.then(function(module) {
assert.sameValue(module.default, 262);
})
.then($DONE, $DONE);

View File

@ -0,0 +1,30 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Forwards "return" completion when evaluating second parameter
esid: sec-import-call-runtime-semantics-evaluation
info: |
2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] )
1. Let referencingScriptOrModule be ! GetActiveScriptOrModule().
2. Let specifierRef be the result of evaluating specifierExpression.
3. Let specifier be ? GetValue(specifierRef).
4. If optionsExpression is present, then
a. Let optionsRef be the result of evaluating optionsExpression.
b. Let options be ? GetValue(optionsRef).
[...]
features: [dynamic-import, import-assertions]
---*/
var beforeCount = 0;
var afterCount = 0;
var iter = function*() {
beforeCount += 1, import('', yield), afterCount += 1;
}();
iter.next();
var result = iter.return(595);
assert.sameValue(result.done, true);
assert.sameValue(result.value, 595);
assert.sameValue(beforeCount, 1);
assert.sameValue(afterCount, 0);

View File

@ -0,0 +1,29 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Forwards "throw" completion when evaluating second parameter
esid: sec-import-call-runtime-semantics-evaluation
info: |
2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] )
1. Let referencingScriptOrModule be ! GetActiveScriptOrModule().
2. Let specifierRef be the result of evaluating specifierExpression.
3. Let specifier be ? GetValue(specifierRef).
4. If optionsExpression is present, then
a. Let optionsRef be the result of evaluating optionsExpression.
b. Let options be ? GetValue(optionsRef).
[...]
features: [dynamic-import, import-assertions]
---*/
var beforeCount = 0;
var afterCount = 0;
function throwError() {
throw new Test262Error();
}
assert.throws(Test262Error, function() {
beforeCount += 1, import('', throwError()), afterCount += 1;
});
assert.sameValue(beforeCount, 1);
assert.sameValue(afterCount, 0);

View File

@ -0,0 +1,25 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Evaluates parameters in correct sequence
esid: sec-import-call-runtime-semantics-evaluation
info: |
2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] )
1. Let referencingScriptOrModule be ! GetActiveScriptOrModule().
2. Let specifierRef be the result of evaluating specifierExpression.
3. Let specifier be ? GetValue(specifierRef).
4. If optionsExpression is present, then
a. Let optionsRef be the result of evaluating optionsExpression.
b. Let options be ? GetValue(optionsRef).
[...]
features: [dynamic-import, import-assertions]
---*/
var log = [];
import(log.push('first'), (log.push('second'), undefined))
.then(null, function() {});
assert.sameValue(log.length, 2);
assert.sameValue(log[0], 'first');
assert.sameValue(log[1], 'second');

View File

@ -0,0 +1,36 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Rejects promise when accessing "assert" property throws an error
esid: sec-import-call-runtime-semantics-evaluation
info: |
2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] )
[...]
6. Let promiseCapability be ! NewPromiseCapability(%Promise%).
7. Let specifierString be ToString(specifier).
8. IfAbruptRejectPromise(specifierString, promiseCapability).
9. Let assertions be a new empty List.
10. If options is not undefined, then
a. If Type(options) is not Object,
[...]
b. Let assertionsObj be Get(options, "assert").
c. IfAbruptRejectPromise(assertionsObj, promiseCapability).
[...]
features: [dynamic-import, import-assertions]
flags: [async]
---*/
var thrown = new Test262Error();
var options = {
get assert() {
throw thrown;
}
};
import('./2nd-param_FIXTURE.js', options)
.then(function() {
throw new Test262Error('Expected an error, but observed no error');
}, function(caught) {
assert.sameValue(thrown, caught);
})
.then($DONE, $DONE);

View File

@ -0,0 +1,22 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: ImportCall parameter list enables the Yield production parameter
esid: sec-import-call-runtime-semantics-evaluation
info: |
ImportCall[Yield, Await]:
import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt )
import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt )
features: [dynamic-import, import-assertions]
flags: [async]
---*/
var promise;
for (promise = import('./2nd-param_FIXTURE.js', 'test262' in {} || undefined); false; ) ;
promise
.then(function(module) {
assert.sameValue(module.default, 262);
})
.then($DONE, $DONE);

View File

@ -0,0 +1,40 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
Rejects promise when the second argument is neither undefined nor an object
esid: sec-import-call-runtime-semantics-evaluation
info: |
2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] )
[...]
6. Let promiseCapability be ! NewPromiseCapability(%Promise%).
7. Let specifierString be ToString(specifier).
8. IfAbruptRejectPromise(specifierString, promiseCapability).
9. Let assertions be a new empty List.
10. If options is not undefined, then
a. If Type(options) is not Object,
i. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
ii. Return promiseCapability.[[Promise]].
[...]
features: [dynamic-import, import-assertions, Symbol, BigInt]
flags: [async]
---*/
function test(promise, valueType) {
return promise.then(function() {
throw new Test262Error('Promise for ' + valueType + ' was not rejected.');
}, function(error) {
assert.sameValue(error.constructor, TypeError, valueType);
});
}
Promise.all([
test(import('./2nd-param_FIXTURE.js', null), 'null'),
test(import('./2nd-param_FIXTURE.js', false), 'boolean'),
test(import('./2nd-param_FIXTURE.js', 23), 'number'),
test(import('./2nd-param_FIXTURE.js', ''), 'string'),
test(import('./2nd-param_FIXTURE.js', Symbol('')), 'symbol'),
test(import('./2nd-param_FIXTURE.js', 23n), 'bigint')
])
.then(function() {})
.then($DONE, $DONE);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
ImportCall parameter list supports an optional trailing comma (fulfillment
semantics)
esid: sec-import-call-runtime-semantics-evaluation
info: |
ImportCall[Yield, Await]:
import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt )
import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt )
features: [dynamic-import, import-assertions]
flags: [async]
---*/
import('./2nd-param_FIXTURE.js', {},)
.then(function(module) {
assert.sameValue(module.default, 262);
})
.then($DONE, $DONE);

View File

@ -0,0 +1,24 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
ImportCall parameter list supports an optional trailing comma (rejection
semantics)
esid: sec-import-call-runtime-semantics-evaluation
info: |
ImportCall[Yield, Await]:
import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt )
import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt )
features: [dynamic-import, import-assertions]
flags: [async]
---*/
var thrown = new Test262Error();
import({toString: function() { throw thrown; } }, {},)
.then(function() {
throw new Test262Error('Expected promise to be rejected, but it was fulfilled.');
}, function(caught) {
assert.sameValue(thrown, caught);
})
.then($DONE, $DONE);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
ImportCall parameter list forwards the Yield production parameter - YieldExpression
esid: sec-import-call-runtime-semantics-evaluation
info: |
ImportCall[Yield, Await]:
import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt )
import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt )
features: [dynamic-import, import-assertions]
flags: [async]
---*/
var promise;
var iter = (function * () {
promise = import('./2nd-param_FIXTURE.js', yield);
}());
iter.next();
assert.sameValue(promise, undefined);
iter.next();
promise
.then(function(module) {
assert.sameValue(module.default, 262);
})
.then($DONE, $DONE);

View File

@ -0,0 +1,19 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
ImportCall parameter list forwards the Yield production parameter - invalid IdentifierReference
esid: sec-import-call-runtime-semantics-evaluation
info: |
ImportCall[Yield, Await]:
import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt )
import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt )
features: [dynamic-import, import-assertions]
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
---*/
$DONOTEVALUATE();
import('./empty_FIXTURE.js', yield);

View File

@ -0,0 +1,21 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
ImportCall parameter list forwards the Yield production parameter - valid IdentifierReference
esid: sec-import-call-runtime-semantics-evaluation
info: |
ImportCall[Yield, Await]:
import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt )
import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt )
features: [dynamic-import, import-assertions]
flags: [async, noStrict]
---*/
var yield;
import('./2nd-param_FIXTURE.js', yield)
.then(function(module) {
assert.sameValue(module.default, 262);
})
.then($DONE, $DONE);

View File

@ -0,0 +1,3 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export default 262;

View File

@ -0,0 +1,20 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
ImportCall parameter list supports an optional trailing comma (fulfillment
semantics)
esid: sec-import-call-runtime-semantics-evaluation
info: |
ImportCall[Yield, Await]:
import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt )
import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt )
features: [dynamic-import, import-assertions]
flags: [async]
---*/
import('./2nd-param_FIXTURE.js',)
.then(function(module) {
assert.sameValue(module.default, 262);
})
.then($DONE, $DONE);

View File

@ -0,0 +1,24 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
ImportCall parameter list supports an optional trailing comma (rejection
semantics)
esid: sec-import-call-runtime-semantics-evaluation
info: |
ImportCall[Yield, Await]:
import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt )
import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt )
features: [dynamic-import, import-assertions]
flags: [async]
---*/
var thrown = new Test262Error();
import({toString: function() { throw thrown; } },)
.then(function() {
throw new Test262Error('Expected promise to be rejected, but it was fulfilled.');
}, function(caught) {
assert.sameValue(thrown, caught);
})
.then($DONE, $DONE);

View File

@ -0,0 +1,24 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: AssertClause may not have duplicate keys (export declaration)
esid: sec-modules
info: |
AssertClause:assert{AssertEntries,opt}
- It is a Syntax Error if AssertClauseToAssertions of AssertClause has two
entries a and b such that a.[[Key]] is b.[[Key]].
features: [import-assertions]
flags: [module]
negative:
phase: parse
type: SyntaxError
---*/
$DONOTEVALUATE();
export * from './import-assertion-3_FIXTURE.js' assert {
test262_a: '',
test262_b: '',
'test262_\u0061': ''
};

View File

@ -0,0 +1,25 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
AssertClause may not have duplicate keys (import declaration without binding)
esid: sec-modules
info: |
AssertClause:assert{AssertEntries,opt}
- It is a Syntax Error if AssertClauseToAssertions of AssertClause has two
entries a and b such that a.[[Key]] is b.[[Key]].
features: [import-assertions]
flags: [module]
negative:
phase: parse
type: SyntaxError
---*/
$DONOTEVALUATE();
import './import-assertion-2_FIXTURE.js' assert {
test262_a: '',
test262_b: '',
'test262_\u0061': ''
};

View File

@ -0,0 +1,25 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
AssertClause may not have duplicate keys (import declaration with binding)
esid: sec-modules
info: |
AssertClause:assert{AssertEntries,opt}
- It is a Syntax Error if AssertClauseToAssertions of AssertClause has two
entries a and b such that a.[[Key]] is b.[[Key]].
features: [import-assertions]
flags: [module]
negative:
phase: parse
type: SyntaxError
---*/
$DONOTEVALUATE();
import x from './import-assertion-1_FIXTURE.js' assert {
test262_a: '',
test262_b: '',
'test262_\u0061': ''
};

View File

@ -0,0 +1,70 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
AssertClause in ImportDeclaration may not be preceded by a line terminator
esid: sec-modules
info: |
ImportDeclaration:
import ModuleSpecifier[no LineTerminator here] AssertClause;
AssertClause:
assert {}
assert {AssertEntries ,opt}
AssertEntries:
AssertionKey : StringLiteral
AssertionKey : StringLiteral , AssertEntries
AssertionKey:
IdentifierName
StringLiteral
The restriction LineTerminator could be verified more simply with a negative
syntax test. This test is designed to parse successfully in order to verify
the restriction more precisely.
features: [import-assertions, globalThis]
flags: [module, raw]
---*/
var callCount = 0;
// Define a property on the global "this" value so that the effect of the
// expected IdentifierReference can be observed.
Object.defineProperty(globalThis, 'assert', {
get: function() {
callCount += 1;
}
});
import x from './import-assertion-1_FIXTURE.js'
assert
{test262:''};
if (x !== 262.1) {
throw 'module value incorrectly imported - first declaration';
}
if (callCount !== 1) {
throw 'IdentifierReference not recognized - first declaration';
}
import './import-assertion-2_FIXTURE.js'
assert
{test262:''};
if (globalThis.test262 !== 262.2) {
throw 'module value incorrectly imported - second declaration';
}
if (callCount !== 2) {
throw 'IdentifierReference not recognized - second declaration';
}
export * from './import-assertion-3_FIXTURE.js'
assert
{test262:''};
if (callCount !== 3) {
throw 'IdentifierReference not recognized - third declaration';
}

View File

@ -0,0 +1,3 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export default 262.1;

View File

@ -0,0 +1,3 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
globalThis.test262 = 262.2;

View File

@ -0,0 +1,3 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
export default 262.3;

View File

@ -0,0 +1,30 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: AssertClause in ImportDeclaration may be empty
esid: sec-modules
info: |
ImportDeclaration:
import ModuleSpecifier[no LineTerminator here] AssertClause;
AssertClause:
assert {}
assert {AssertEntries ,opt}
AssertEntries:
AssertionKey : StringLiteral
AssertionKey : StringLiteral , AssertEntries
AssertionKey:
IdentifierName
StringLiteral
features: [import-assertions, globalThis]
flags: [module]
---*/
import x from './import-assertion-1_FIXTURE.js' assert {};
import './import-assertion-2_FIXTURE.js' assert {};
export * from './import-assertion-3_FIXTURE.js' assert {};
assert.sameValue(x, 262.1);
assert.sameValue(globalThis.test262, 262.2);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
AssertClause in ImportDeclaration may use any valid IdentifierName as a key
esid: sec-modules
info: |
ImportDeclaration:
import ModuleSpecifier[no LineTerminator here] AssertClause;
AssertClause:
assert {}
assert {AssertEntries ,opt}
AssertEntries:
AssertionKey : StringLiteral
AssertionKey : StringLiteral , AssertEntries
AssertionKey:
IdentifierName
StringLiteral
features: [import-assertions]
flags: [module]
---*/
import x from './import-assertion-1_FIXTURE.js' assert {if:''};
import './import-assertion-2_FIXTURE.js' assert {if:''};
export * from './import-assertion-3_FIXTURE.js' assert {if:''};
assert.sameValue(x, 262.1);
assert.sameValue(globalThis.test262, 262.2);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
AssertClause in ImportDeclaration may use a string literal as a key (delimited with U+0022)
esid: sec-modules
info: |
ImportDeclaration:
import ModuleSpecifier[no LineTerminator here] AssertClause;
AssertClause:
assert {}
assert {AssertEntries ,opt}
AssertEntries:
AssertionKey : StringLiteral
AssertionKey : StringLiteral , AssertEntries
AssertionKey:
IdentifierName
StringLiteral
features: [import-assertions, globalThis]
flags: [module]
---*/
import x from './import-assertion-1_FIXTURE.js' assert {"test262\u0078":''};
import './import-assertion-2_FIXTURE.js' assert {"test262\u0078":''};
export * from './import-assertion-3_FIXTURE.js' assert {"test262\u0078":''};
assert.sameValue(x, 262.1);
assert.sameValue(globalThis.test262, 262.2);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
AssertClause in ImportDeclaration may use a string literal as a key (delimited with U+0027)
esid: sec-modules
info: |
ImportDeclaration:
import ModuleSpecifier[no LineTerminator here] AssertClause;
AssertClause:
assert {}
assert {AssertEntries ,opt}
AssertEntries:
AssertionKey : StringLiteral
AssertionKey : StringLiteral , AssertEntries
AssertionKey:
IdentifierName
StringLiteral
features: [import-assertions, globalThis]
flags: [module]
---*/
import x from './import-assertion-1_FIXTURE.js' assert {'test262\u0078':''};
import './import-assertion-2_FIXTURE.js' assert {'test262\u0078':''};
export * from './import-assertion-3_FIXTURE.js' assert {'test262\u0078':''};
assert.sameValue(x, 262.1);
assert.sameValue(globalThis.test262, 262.2);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
AssertClause in ImportDeclaration may contain multiple AssertEntries
esid: sec-modules
info: |
ImportDeclaration:
import ModuleSpecifier[no LineTerminator here] AssertClause;
AssertClause:
assert {}
assert {AssertEntries ,opt}
AssertEntries:
AssertionKey : StringLiteral
AssertionKey : StringLiteral , AssertEntries
AssertionKey:
IdentifierName
StringLiteral
features: [import-assertions, globalThis]
flags: [module]
---*/
import x from './import-assertion-1_FIXTURE.js' assert {test262_1:'',test262_2:'',test262_3:'',test262_4:''};
import './import-assertion-2_FIXTURE.js' assert {test262_1:'',test262_2:'',test262_3:'',test262_4:''};
export * from './import-assertion-3_FIXTURE.js' assert {test262_1:'',test262_2:'',test262_3:'',test262_4:''};
assert.sameValue(x, 262.1);
assert.sameValue(globalThis.test262, 262.2);

View File

@ -0,0 +1,49 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
AssertClause in ImportDeclaration may include line terminators
esid: sec-modules
info: |
ImportDeclaration:
import ModuleSpecifier[no LineTerminator here] AssertClause;
AssertClause:
assert {}
assert {AssertEntries ,opt}
AssertEntries:
AssertionKey : StringLiteral
AssertionKey : StringLiteral , AssertEntries
AssertionKey:
IdentifierName
StringLiteral
This test uses all four LineFeed characters in order to completely verify the
grammar.
features: [import-assertions, globalThis]
flags: [module]
---*/
import x from './import-assertion-1_FIXTURE.js' assert
{
test262
:
''
};
import './import-assertion-2_FIXTURE.js' assert
{
test262
:
''
};
export * from './import-assertion-3_FIXTURE.js' assert
{
test262
:
''
};
assert.sameValue(x, 262.1);
assert.sameValue(globalThis.test262, 262.2);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
AssertClause in ImportDeclaration may contain a trailing comma
esid: sec-modules
info: |
ImportDeclaration:
import ModuleSpecifier[no LineTerminator here] AssertClause;
AssertClause:
assert {}
assert {AssertEntries ,opt}
AssertEntries:
AssertionKey : StringLiteral
AssertionKey : StringLiteral , AssertEntries
AssertionKey:
IdentifierName
StringLiteral
features: [import-assertions, globalThis]
flags: [module]
---*/
import x from './import-assertion-1_FIXTURE.js' assert {test262:'',};
import './import-assertion-2_FIXTURE.js' assert {test262:'',};
export * from './import-assertion-3_FIXTURE.js' assert {test262:'',};
assert.sameValue(x, 262.1);
assert.sameValue(globalThis.test262, 262.2);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
AssertClause in ImportDeclaration may use a string literal as a value (delimited with U+0022)
esid: sec-modules
info: |
ImportDeclaration:
import ModuleSpecifier[no LineTerminator here] AssertClause;
AssertClause:
assert {}
assert {AssertEntries ,opt}
AssertEntries:
AssertionKey : StringLiteral
AssertionKey : StringLiteral , AssertEntries
AssertionKey:
IdentifierName
StringLiteral
features: [import-assertions, globalThis]
flags: [module]
---*/
import x from './import-assertion-1_FIXTURE.js' assert {test262:"\u0078"};
import './import-assertion-2_FIXTURE.js' assert {test262:"\u0078"};
export * from './import-assertion-3_FIXTURE.js' assert {test262:"\u0078"};
assert.sameValue(x, 262.1);
assert.sameValue(globalThis.test262, 262.2);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
AssertClause in ImportDeclaration may use a string literal as a value (delimited with U+0027)
esid: sec-modules
info: |
ImportDeclaration:
import ModuleSpecifier[no LineTerminator here] AssertClause;
AssertClause:
assert {}
assert {AssertEntries ,opt}
AssertEntries:
AssertionKey : StringLiteral
AssertionKey : StringLiteral , AssertEntries
AssertionKey:
IdentifierName
StringLiteral
features: [import-assertions, globalThis]
flags: [module]
---*/
import x from './import-assertion-1_FIXTURE.js' assert {test262:'\u0078'};
import './import-assertion-2_FIXTURE.js' assert {test262:'\u0078'};
export * from './import-assertion-3_FIXTURE.js' assert {test262:'\u0078'};
assert.sameValue(x, 262.1);
assert.sameValue(globalThis.test262, 262.2);