mirror of
https://github.com/tc39/test262.git
synced 2025-09-25 11:08:49 +02:00
Replace SpiderMonkey-specific parseModule in expressions/optional-chain-first-expression.js
This commit is contained in:
parent
0ee9b57cba
commit
d90061929a
@ -0,0 +1,43 @@
|
||||
// Copyright (C) 2024 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
flags:
|
||||
- module
|
||||
---*/
|
||||
// Verify bytecode emitter accepts all valid optional chain first expressions.
|
||||
|
||||
// Evaluate `import.meta` in an expression context.
|
||||
assert.throws(TypeError, function() {
|
||||
void (import.meta?.());
|
||||
});
|
||||
assert.throws(TypeError, function() {
|
||||
void (import.meta?.p());
|
||||
});
|
||||
|
||||
// Also try `import.meta` parenthesized.
|
||||
assert.throws(TypeError, function() {
|
||||
void ((import.meta)?.());
|
||||
});
|
||||
assert.throws(TypeError, function() {
|
||||
void ((import.meta)?.p());
|
||||
});
|
||||
|
||||
// Evaluate `import()` in an expression context.
|
||||
assert.throws(TypeError, function() {
|
||||
void (import("./optional-chain-first-expression-module_FIXTURE.js")?.());
|
||||
});
|
||||
assert.throws(TypeError, function() {
|
||||
void (import("./optional-chain-first-expression-module_FIXTURE.js")?.p());
|
||||
});
|
||||
|
||||
// Also try `import()` parenthesized.
|
||||
assert.throws(TypeError, function() {
|
||||
void ((import("./optional-chain-first-expression-module_FIXTURE.js"))?.());
|
||||
});
|
||||
assert.throws(TypeError, function() {
|
||||
void ((import("./optional-chain-first-expression-module_FIXTURE.js"))?.p());
|
||||
});
|
@ -0,0 +1,4 @@
|
||||
// Copyright (C) 2024 Mozilla Corporation. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
// Intentionally left empty.
|
@ -47,12 +47,8 @@ const expressions = [
|
||||
"a?.``",
|
||||
];
|
||||
|
||||
function tryParse(s, f = Function) {
|
||||
try { f(s); } catch {}
|
||||
}
|
||||
|
||||
function tryRun(s, f = Function) {
|
||||
try { f(s)(); } catch {}
|
||||
function tryRun(s) {
|
||||
try { Function(s)(); } catch {}
|
||||
}
|
||||
|
||||
for (let expr of expressions) {
|
||||
@ -78,21 +74,3 @@ for (let expr of ["super[a]", "super.a", "super()"]) {
|
||||
tryRun(inClassConstructor(`void ((${expr})?.());`));
|
||||
tryRun(inClassConstructor(`void ((${expr})?.p());`));
|
||||
}
|
||||
|
||||
if (typeof parseModule === "function") {
|
||||
const expressions = [
|
||||
"import.meta",
|
||||
"import('')",
|
||||
];
|
||||
|
||||
for (let expr of expressions) {
|
||||
// Evaluate in an expression context.
|
||||
tryParse(`void (${expr}?.());`, parseModule);
|
||||
tryParse(`void (${expr}?.p());`, parseModule);
|
||||
|
||||
// Also try parenthesized.
|
||||
tryParse(`void ((${expr})?.());`, parseModule);
|
||||
tryParse(`void ((${expr})?.p());`, parseModule);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user