mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
chore(codegen): add more tests for comments from esbuild (#6357)
Copy from https://github.com/rolldown-rs/rolldown/blob/main/crates/rolldown/tests/esbuild/dce/remove_unused_pure_comment_calls/entry.js
This commit is contained in:
parent
84b2d072e8
commit
585cdd5bcd
2 changed files with 182 additions and 0 deletions
|
|
@ -133,6 +133,68 @@ const defineSSRCustomElement = () => {
|
||||||
const Component = // #__PURE__
|
const Component = // #__PURE__
|
||||||
React.forwardRef((props, ref) => {});
|
React.forwardRef((props, ref) => {});
|
||||||
",
|
",
|
||||||
|
// Copy from <https://github.com/rolldown-rs/rolldown/blob/main/crates/rolldown/tests/esbuild/dce/remove_unused_pure_comment_calls/entry.js>
|
||||||
|
"
|
||||||
|
function bar() {}
|
||||||
|
let bare = foo(bar);
|
||||||
|
|
||||||
|
let at_yes = /* @__PURE__ */ foo(bar);
|
||||||
|
let at_no = /* @__PURE__ */ foo(bar());
|
||||||
|
let new_at_yes = /* @__PURE__ */ new foo(bar);
|
||||||
|
let new_at_no = /* @__PURE__ */ new foo(bar());
|
||||||
|
|
||||||
|
let nospace_at_yes = /*@__PURE__*/ foo(bar);
|
||||||
|
let nospace_at_no = /*@__PURE__*/ foo(bar());
|
||||||
|
let nospace_new_at_yes = /*@__PURE__*/ new foo(bar);
|
||||||
|
let nospace_new_at_no = /*@__PURE__*/ new foo(bar());
|
||||||
|
|
||||||
|
let num_yes = /* #__PURE__ */ foo(bar);
|
||||||
|
let num_no = /* #__PURE__ */ foo(bar());
|
||||||
|
let new_num_yes = /* #__PURE__ */ new foo(bar);
|
||||||
|
let new_num_no = /* #__PURE__ */ new foo(bar());
|
||||||
|
|
||||||
|
let nospace_num_yes = /*#__PURE__*/ foo(bar);
|
||||||
|
let nospace_num_no = /*#__PURE__*/ foo(bar());
|
||||||
|
let nospace_new_num_yes = /*#__PURE__*/ new foo(bar);
|
||||||
|
let nospace_new_num_no = /*#__PURE__*/ new foo(bar());
|
||||||
|
|
||||||
|
let dot_yes = /* @__PURE__ */ foo(sideEffect()).dot(bar);
|
||||||
|
let dot_no = /* @__PURE__ */ foo(sideEffect()).dot(bar());
|
||||||
|
let new_dot_yes = /* @__PURE__ */ new foo(sideEffect()).dot(bar);
|
||||||
|
let new_dot_no = /* @__PURE__ */ new foo(sideEffect()).dot(bar());
|
||||||
|
|
||||||
|
let nested_yes = [1, /* @__PURE__ */ foo(bar), 2];
|
||||||
|
let nested_no = [1, /* @__PURE__ */ foo(bar()), 2];
|
||||||
|
let new_nested_yes = [1, /* @__PURE__ */ new foo(bar), 2];
|
||||||
|
let new_nested_no = [1, /* @__PURE__ */ new foo(bar()), 2];
|
||||||
|
|
||||||
|
let single_at_yes = // @__PURE__
|
||||||
|
foo(bar);
|
||||||
|
let single_at_no = // @__PURE__
|
||||||
|
foo(bar());
|
||||||
|
let new_single_at_yes = // @__PURE__
|
||||||
|
new foo(bar);
|
||||||
|
let new_single_at_no = // @__PURE__
|
||||||
|
new foo(bar());
|
||||||
|
|
||||||
|
let single_num_yes = // #__PURE__
|
||||||
|
foo(bar);
|
||||||
|
let single_num_no = // #__PURE__
|
||||||
|
foo(bar());
|
||||||
|
let new_single_num_yes = // #__PURE__
|
||||||
|
new foo(bar);
|
||||||
|
let new_single_num_no = // #__PURE__
|
||||||
|
new foo(bar());
|
||||||
|
|
||||||
|
let bad_no = /* __PURE__ */ foo(bar);
|
||||||
|
let new_bad_no = /* __PURE__ */ new foo(bar);
|
||||||
|
|
||||||
|
let parens_no = (/* @__PURE__ */ foo)(bar);
|
||||||
|
let new_parens_no = new (/* @__PURE__ */ foo)(bar);
|
||||||
|
|
||||||
|
let exp_no = /* @__PURE__ */ foo() ** foo();
|
||||||
|
let new_exp_no = /* @__PURE__ */ new foo() ** foo();
|
||||||
|
",
|
||||||
];
|
];
|
||||||
|
|
||||||
snapshot("pure_comments", &cases);
|
snapshot("pure_comments", &cases);
|
||||||
|
|
|
||||||
|
|
@ -277,3 +277,123 @@ const defineSSRCustomElement = () => {
|
||||||
|
|
||||||
----------
|
----------
|
||||||
const Component = /* #__PURE__*/ React.forwardRef((props, ref) => {});
|
const Component = /* #__PURE__*/ React.forwardRef((props, ref) => {});
|
||||||
|
|
||||||
|
########## 21
|
||||||
|
|
||||||
|
function bar() {}
|
||||||
|
let bare = foo(bar);
|
||||||
|
|
||||||
|
let at_yes = /* @__PURE__ */ foo(bar);
|
||||||
|
let at_no = /* @__PURE__ */ foo(bar());
|
||||||
|
let new_at_yes = /* @__PURE__ */ new foo(bar);
|
||||||
|
let new_at_no = /* @__PURE__ */ new foo(bar());
|
||||||
|
|
||||||
|
let nospace_at_yes = /*@__PURE__*/ foo(bar);
|
||||||
|
let nospace_at_no = /*@__PURE__*/ foo(bar());
|
||||||
|
let nospace_new_at_yes = /*@__PURE__*/ new foo(bar);
|
||||||
|
let nospace_new_at_no = /*@__PURE__*/ new foo(bar());
|
||||||
|
|
||||||
|
let num_yes = /* #__PURE__ */ foo(bar);
|
||||||
|
let num_no = /* #__PURE__ */ foo(bar());
|
||||||
|
let new_num_yes = /* #__PURE__ */ new foo(bar);
|
||||||
|
let new_num_no = /* #__PURE__ */ new foo(bar());
|
||||||
|
|
||||||
|
let nospace_num_yes = /*#__PURE__*/ foo(bar);
|
||||||
|
let nospace_num_no = /*#__PURE__*/ foo(bar());
|
||||||
|
let nospace_new_num_yes = /*#__PURE__*/ new foo(bar);
|
||||||
|
let nospace_new_num_no = /*#__PURE__*/ new foo(bar());
|
||||||
|
|
||||||
|
let dot_yes = /* @__PURE__ */ foo(sideEffect()).dot(bar);
|
||||||
|
let dot_no = /* @__PURE__ */ foo(sideEffect()).dot(bar());
|
||||||
|
let new_dot_yes = /* @__PURE__ */ new foo(sideEffect()).dot(bar);
|
||||||
|
let new_dot_no = /* @__PURE__ */ new foo(sideEffect()).dot(bar());
|
||||||
|
|
||||||
|
let nested_yes = [1, /* @__PURE__ */ foo(bar), 2];
|
||||||
|
let nested_no = [1, /* @__PURE__ */ foo(bar()), 2];
|
||||||
|
let new_nested_yes = [1, /* @__PURE__ */ new foo(bar), 2];
|
||||||
|
let new_nested_no = [1, /* @__PURE__ */ new foo(bar()), 2];
|
||||||
|
|
||||||
|
let single_at_yes = // @__PURE__
|
||||||
|
foo(bar);
|
||||||
|
let single_at_no = // @__PURE__
|
||||||
|
foo(bar());
|
||||||
|
let new_single_at_yes = // @__PURE__
|
||||||
|
new foo(bar);
|
||||||
|
let new_single_at_no = // @__PURE__
|
||||||
|
new foo(bar());
|
||||||
|
|
||||||
|
let single_num_yes = // #__PURE__
|
||||||
|
foo(bar);
|
||||||
|
let single_num_no = // #__PURE__
|
||||||
|
foo(bar());
|
||||||
|
let new_single_num_yes = // #__PURE__
|
||||||
|
new foo(bar);
|
||||||
|
let new_single_num_no = // #__PURE__
|
||||||
|
new foo(bar());
|
||||||
|
|
||||||
|
let bad_no = /* __PURE__ */ foo(bar);
|
||||||
|
let new_bad_no = /* __PURE__ */ new foo(bar);
|
||||||
|
|
||||||
|
let parens_no = (/* @__PURE__ */ foo)(bar);
|
||||||
|
let new_parens_no = new (/* @__PURE__ */ foo)(bar);
|
||||||
|
|
||||||
|
let exp_no = /* @__PURE__ */ foo() ** foo();
|
||||||
|
let new_exp_no = /* @__PURE__ */ new foo() ** foo();
|
||||||
|
|
||||||
|
----------
|
||||||
|
function bar() {}
|
||||||
|
let bare = foo(bar);
|
||||||
|
let at_yes = /* @__PURE__ */ foo(bar);
|
||||||
|
let at_no = /* @__PURE__ */ foo(bar());
|
||||||
|
let new_at_yes = /* @__PURE__ */ new foo(bar);
|
||||||
|
let new_at_no = /* @__PURE__ */ new foo(bar());
|
||||||
|
let nospace_at_yes = /*@__PURE__*/ foo(bar);
|
||||||
|
let nospace_at_no = /*@__PURE__*/ foo(bar());
|
||||||
|
let nospace_new_at_yes = /*@__PURE__*/ new foo(bar);
|
||||||
|
let nospace_new_at_no = /*@__PURE__*/ new foo(bar());
|
||||||
|
let num_yes = /* #__PURE__ */ foo(bar);
|
||||||
|
let num_no = /* #__PURE__ */ foo(bar());
|
||||||
|
let new_num_yes = /* #__PURE__ */ new foo(bar);
|
||||||
|
let new_num_no = /* #__PURE__ */ new foo(bar());
|
||||||
|
let nospace_num_yes = /*#__PURE__*/ foo(bar);
|
||||||
|
let nospace_num_no = /*#__PURE__*/ foo(bar());
|
||||||
|
let nospace_new_num_yes = /*#__PURE__*/ new foo(bar);
|
||||||
|
let nospace_new_num_no = /*#__PURE__*/ new foo(bar());
|
||||||
|
let dot_yes = /* @__PURE__ */ foo(sideEffect()).dot(bar);
|
||||||
|
let dot_no = /* @__PURE__ */ foo(sideEffect()).dot(bar());
|
||||||
|
let new_dot_yes = /* @__PURE__ */ new foo(sideEffect()).dot(bar);
|
||||||
|
let new_dot_no = /* @__PURE__ */ new foo(sideEffect()).dot(bar());
|
||||||
|
let nested_yes = [
|
||||||
|
1,
|
||||||
|
/* @__PURE__ */ foo(bar),
|
||||||
|
2
|
||||||
|
];
|
||||||
|
let nested_no = [
|
||||||
|
1,
|
||||||
|
/* @__PURE__ */ foo(bar()),
|
||||||
|
2
|
||||||
|
];
|
||||||
|
let new_nested_yes = [
|
||||||
|
1,
|
||||||
|
/* @__PURE__ */ new foo(bar),
|
||||||
|
2
|
||||||
|
];
|
||||||
|
let new_nested_no = [
|
||||||
|
1,
|
||||||
|
/* @__PURE__ */ new foo(bar()),
|
||||||
|
2
|
||||||
|
];
|
||||||
|
let single_at_yes = /* @__PURE__*/ foo(bar);
|
||||||
|
let single_at_no = /* @__PURE__*/ foo(bar());
|
||||||
|
let new_single_at_yes = /* @__PURE__*/ new foo(bar);
|
||||||
|
let new_single_at_no = /* @__PURE__*/ new foo(bar());
|
||||||
|
let single_num_yes = /* #__PURE__*/ foo(bar);
|
||||||
|
let single_num_no = /* #__PURE__*/ foo(bar());
|
||||||
|
let new_single_num_yes = /* #__PURE__*/ new foo(bar);
|
||||||
|
let new_single_num_no = /* #__PURE__*/ new foo(bar());
|
||||||
|
let bad_no = foo(bar);
|
||||||
|
let new_bad_no = new foo(bar);
|
||||||
|
let parens_no = foo(bar);
|
||||||
|
let new_parens_no = new foo(bar);
|
||||||
|
let exp_no = /* @__PURE__ */ foo() ** foo();
|
||||||
|
let new_exp_no = /* @__PURE__ */ new foo() ** foo();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue