Skip to content

Commit

Permalink
Add one more test
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Oct 5, 2022
1 parent 5518972 commit 1d85256
Showing 1 changed file with 53 additions and 24 deletions.
77 changes: 53 additions & 24 deletions crates/swc_ecma_minifier/tests/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10135,32 +10135,61 @@ fn feedback_regex_range() {
fn issue_6039_1() {
run_default_exec_test(
r###"
function foo() {
let walker = 0;
let arr = [];
function bar(defaultValue) {
const myIndex = walker;
walker += 1;
console.log({ arr });
if (arr.length < myIndex + 1) {
arr[myIndex] = defaultValue;
function foo() {
let walker = 0;
let arr = [];
function bar(defaultValue) {
const myIndex = walker;
walker += 1;
console.log({ arr });
if (arr.length < myIndex + 1) {
arr[myIndex] = defaultValue;
}
}
return bar;
}
return bar;
}
const bar = foo();
bar(null);
bar(null);
bar(null);
bar(null);
bar(null);
const bar = foo();
bar(null);
bar(null);
bar(null);
bar(null);
bar(null);
"###,
);
}

#[test]
fn issue_6039_2() {
run_default_exec_test(
r###"
var foo = function foo() {
var walker = 0;
var arr = [];
function bar(defaultValue) {
var myIndex = walker;
walker += 1;
console.log({
arr: arr
});
if (arr.length < myIndex + 1) {
arr[myIndex] = defaultValue;
}
}
return bar;
};
var bar = foo();
bar(null);
bar(null);
bar(null);
bar(null);
bar(null);
"###,
);
}

0 comments on commit 1d85256

Please sign in to comment.