Skip to content

Commit

Permalink
run more class lowering tests with bundling on
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jun 12, 2023
1 parent c12cc90 commit 70e59c3
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions scripts/end-to-end-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3590,14 +3590,14 @@ for (let [code, expected] of [
}

// Class lowering tests
for (let flags of [[], ['--target=es6']]) {
for (let flags of [[], ['--target=es6'], ['--bundle'], ['--bundle', '--target=es6']]) {
// Skip running these tests untransformed. I believe V8 actually has a bug
// here and esbuild is correct, both because SpiderMonkey and JavaScriptCore
// run this code fine and because the specification says that the left operand
// of the assignment operator should be evaluated first but V8 appears to be
// evaluating it later on. The bug with V8 has been filed here for reference:
// https://bugs.chromium.org/p/v8/issues/detail?id=12352
if (flags.length > 0) {
if (flags.includes('--target=es6')) {
tests.push(
test(['in.js', '--outfile=node.js'].concat(flags), {
'in.js': `
Expand Down Expand Up @@ -3636,6 +3636,11 @@ for (let flags of [[], ['--target=es6']]) {
)
}

// This log message is only an error during bundling
const assignToConstantMessage = flags.includes('--bundle')
? `✘ [ERROR] Cannot assign to "Foo" because it is a constant`
: `▲ [WARNING] This assignment will throw because "Foo" is a constant [assign-to-constant]`

tests.push(
test(['in.js', '--outfile=node.js'].concat(flags), {
'in.js': `
Expand Down Expand Up @@ -3870,7 +3875,7 @@ for (let flags of [[], ['--target=es6']]) {
try {
fn()
} catch (e) {
${flags.length > 0
${flags.includes('--target=es6')
// Only check the exact error message for esbuild
? `if (e instanceof TypeError && e.message === msg) return`
// For node, just check whether a type error is thrown
Expand Down Expand Up @@ -4085,7 +4090,7 @@ for (let flags of [[], ['--target=es6']]) {
}
`,
}, {
expectedStderr: `▲ [WARNING] This assignment will throw because "Foo" is a constant [assign-to-constant]
expectedStderr: assignToConstantMessage + `
in.js:5:26:
5 │ static #foo = Foo = class Bar {}
Expand Down Expand Up @@ -4114,7 +4119,7 @@ for (let flags of [[], ['--target=es6']]) {
}
`,
}, {
expectedStderr: `▲ [WARNING] This assignment will throw because "Foo" is a constant [assign-to-constant]
expectedStderr: assignToConstantMessage + `
in.js:4:26:
4 │ static #foo() { Foo = class Bar{} }
Expand Down Expand Up @@ -4538,12 +4543,6 @@ for (let flags of [[], ['--target=es6']]) {
if (!(it instanceof Foo)) throw 'fail'
`,
}),
)
}

// Class lowering tests with bundling
for (let flags of [[], ['--target=es6'], ['--bundle'], ['--bundle', '--target=es6']]) {
tests.push(
test(['in.js', '--outfile=node.js'].concat(flags), {
'in.js': `
const order = []
Expand Down

0 comments on commit 70e59c3

Please sign in to comment.