-
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor test cases for minify simplily. (#799)
- Loading branch information
1 parent
5f3ce6a
commit 6546ad1
Showing
233 changed files
with
1,321 additions
and
2,228 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
packages/babel-plugin-minify-simplify/__tests__/fixtures/arrow-block-empty/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const a = () => {}; | ||
const b = () => {return;}; |
2 changes: 2 additions & 0 deletions
2
packages/babel-plugin-minify-simplify/__tests__/fixtures/arrow-block-empty/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const a = () => {}; | ||
const b = () => {}; |
2 changes: 2 additions & 0 deletions
2
packages/babel-plugin-minify-simplify/__tests__/fixtures/arrow-block/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const a = () => {return (3, 4);}; | ||
const b = () => {return 3;}; |
2 changes: 2 additions & 0 deletions
2
packages/babel-plugin-minify-simplify/__tests__/fixtures/arrow-block/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const a = () => (3, 4); | ||
const b = () => 3; |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-minify-simplify/__tests__/fixtures/arrow-short-hand/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const f = () => a; |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-minify-simplify/__tests__/fixtures/arrow-short-hand/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const f = () => a; |
10 changes: 10 additions & 0 deletions
10
packages/babel-plugin-minify-simplify/__tests__/fixtures/bail-multiple-statements/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function foo() { | ||
if(window.self != window.top) { | ||
if(__DEV__) { | ||
console.log('lol', name); | ||
} | ||
return; | ||
} | ||
lol(); | ||
try { lol() } catch (e) {} | ||
} |
8 changes: 8 additions & 0 deletions
8
...ages/babel-plugin-minify-simplify/__tests__/fixtures/bail-multiple-statements/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function foo() { | ||
if (window.self != window.top) return void (__DEV__ && console.log('lol', name)); | ||
lol(); | ||
|
||
try { | ||
lol(); | ||
} catch (e) {} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/babel-plugin-minify-simplify/__tests__/fixtures/block-to-sequence/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
for (var x = 0; x < 10; x++) { | ||
console.log(x); | ||
console.log(x); | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-minify-simplify/__tests__/fixtures/block-to-sequence/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
for (var x = 0; x < 10; x++) console.log(x), console.log(x); |
12 changes: 12 additions & 0 deletions
12
packages/babel-plugin-minify-simplify/__tests__/fixtures/combine-returns/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function foo() { | ||
if (a) { | ||
if (a.b) { | ||
if(a.b.c) { | ||
if(a.b.c()){ | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
for (; true;) wat(); | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-minify-simplify/__tests__/fixtures/combine-returns/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function foo() { | ||
if (!(a && a.b && a.b.c && a.b.c())) for (; true;) wat(); | ||
} |
16 changes: 16 additions & 0 deletions
16
...lugin-minify-simplify/__tests__/fixtures/common-conditional-expression-patterns/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function f1() { return a == b ? true : x; } | ||
function f2() { return a == b ? false : x; } | ||
function f3() { return a < b ? !0 : x; } | ||
function f4() { return a < b ? !1 : x; } | ||
function f5() { return c ? !0 : x; } | ||
function f6() { return c ? false : x; } | ||
function f7() { return !c ? true : x; } | ||
function f8() { return !c ? !1 : x; } | ||
function g1() { return a == b ? x : true; } | ||
function g2() { return a == b ? x : false; } | ||
function g3() { return a < b ? x : !0; } | ||
function g4() { return a < b ? x : !1; } | ||
function g5() { return c ? x : true; } | ||
function g6() { return c ? x : !1; } | ||
function g7() { return !c ? x : !0; } | ||
function g8() { return !c ? x : false; } |
48 changes: 48 additions & 0 deletions
48
...gin-minify-simplify/__tests__/fixtures/common-conditional-expression-patterns/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
function f1() { | ||
return !(a != b) || x; | ||
} | ||
function f2() { | ||
return a != b && x; | ||
} | ||
function f3() { | ||
return !!(a < b) || x; | ||
} | ||
function f4() { | ||
return !(a < b) && x; | ||
} | ||
function f5() { | ||
return !!c || x; | ||
} | ||
function f6() { | ||
return !c && x; | ||
} | ||
function f7() { | ||
return !c || x; | ||
} | ||
function f8() { | ||
return !!c && x; | ||
} | ||
function g1() { | ||
return a != b || x; | ||
} | ||
function g2() { | ||
return !(a != b) && x; | ||
} | ||
function g3() { | ||
return !(a < b) || x; | ||
} | ||
function g4() { | ||
return !!(a < b) && x; | ||
} | ||
function g5() { | ||
return !c || x; | ||
} | ||
function g6() { | ||
return !!c && x; | ||
} | ||
function g7() { | ||
return !!c || x; | ||
} | ||
function g8() { | ||
return !c && x; | ||
} |
1 change: 1 addition & 0 deletions
1
...s/babel-plugin-minify-simplify/__tests__/fixtures/common-conditional-operations/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
function h1() { return a && b ? (foo(), true) : false } |
3 changes: 3 additions & 0 deletions
3
...babel-plugin-minify-simplify/__tests__/fixtures/common-conditional-operations/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function h1() { | ||
return !!(a && b) && (foo(), true); | ||
} |
4 changes: 4 additions & 0 deletions
4
...s/babel-plugin-minify-simplify/__tests__/fixtures/convert-gaurded-nots-to-ors-2/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
if (!foo && foo !== bar) { | ||
wow(); | ||
such(); | ||
} |
1 change: 1 addition & 0 deletions
1
...babel-plugin-minify-simplify/__tests__/fixtures/convert-gaurded-nots-to-ors-2/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!foo && foo !== bar && (wow(), such()); |
2 changes: 2 additions & 0 deletions
2
...ges/babel-plugin-minify-simplify/__tests__/fixtures/convert-gaurded-nots-to-ors/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
x(); | ||
if (!foo.bar) foo.bar = wat; |
1 change: 1 addition & 0 deletions
1
...s/babel-plugin-minify-simplify/__tests__/fixtures/convert-gaurded-nots-to-ors/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
x(), !foo.bar && (foo.bar = wat); |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-minify-simplify/__tests__/fixtures/do-while/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
do { | ||
foo(); | ||
} while (1); |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-minify-simplify/__tests__/fixtures/do-while/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
do foo(); while (1); |
6 changes: 6 additions & 0 deletions
6
packages/babel-plugin-minify-simplify/__tests__/fixtures/early-return-2/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
function foo() { | ||
wow(); | ||
if (x) { | ||
return; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/babel-plugin-minify-simplify/__tests__/fixtures/early-return-2/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function foo() { | ||
wow(); | ||
x; | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/babel-plugin-minify-simplify/__tests__/fixtures/early-returns/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function foo(a) { | ||
if (lol) return; | ||
doThings(); | ||
doOtherThings(); | ||
} | ||
function bar(a) { | ||
if (lol) { | ||
return; | ||
} | ||
try { | ||
doThings(); | ||
} catch (e) { | ||
doOtherThings(); | ||
} | ||
} | ||
function baz() { | ||
while (wow) if (lol) return; | ||
boo(); | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/babel-plugin-minify-simplify/__tests__/fixtures/early-returns/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function foo(a) { | ||
lol || (doThings(), doOtherThings()); | ||
} | ||
function bar(a) { | ||
if (!lol) try { | ||
doThings(); | ||
} catch (e) { | ||
doOtherThings(); | ||
} | ||
} | ||
function baz() { | ||
for (; wow;) if (lol) return; | ||
|
||
boo(); | ||
} |
6 changes: 6 additions & 0 deletions
6
...abel-plugin-minify-simplify/__tests__/fixtures/empty-blocks-to-empty-statements/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
function foo() { | ||
for (i in p) {} | ||
for (; ;) {} | ||
switch(1) {} | ||
try { a } catch(e) {} | ||
} |
8 changes: 8 additions & 0 deletions
8
...el-plugin-minify-simplify/__tests__/fixtures/empty-blocks-to-empty-statements/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function foo() { | ||
for (i in p); | ||
for (;;); | ||
switch (1) {} | ||
try { | ||
a; | ||
} catch (e) {} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/babel-plugin-minify-simplify/__tests__/fixtures/empty-return/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function foo() { | ||
lol(); | ||
return; | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-minify-simplify/__tests__/fixtures/empty-return/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function foo() { | ||
lol(); | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-minify-simplify/__tests__/fixtures/empty-vars-first/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var x = 1, y, z = 2, zx, a; |
5 changes: 5 additions & 0 deletions
5
packages/babel-plugin-minify-simplify/__tests__/fixtures/empty-vars-first/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var y, | ||
zx, | ||
a, | ||
x = 1, | ||
z = 2; |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-minify-simplify/__tests__/fixtures/flip-binary-expressions/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
if (!(!a && b == a && !b && b < a)) for(;;) a(); |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-minify-simplify/__tests__/fixtures/flip-binary-expressions/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
if (a || b != a || b || !(b < a)) for (;;) a(); |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-minify-simplify/__tests__/fixtures/flip-conditionals/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!foo ? 'foo' : 'bar'; |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-minify-simplify/__tests__/fixtures/flip-conditionals/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foo ? 'bar' : 'foo'; |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-minify-simplify/__tests__/fixtures/flip-logical-expr-2/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
if (!(1 !== foo || !bar)) for (;;); |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-minify-simplify/__tests__/fixtures/flip-logical-expr-2/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
if (1 === foo && bar) for (;;); |
2 changes: 2 additions & 0 deletions
2
packages/babel-plugin-minify-simplify/__tests__/fixtures/flip-logical-expr/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
!x && foo(); | ||
if (!(null == r)) for (;;); |
2 changes: 2 additions & 0 deletions
2
packages/babel-plugin-minify-simplify/__tests__/fixtures/flip-logical-expr/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
if (!x && foo(), null != r) for (;;); |
5 changes: 5 additions & 0 deletions
5
packages/babel-plugin-minify-simplify/__tests__/fixtures/for-sequence/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function foo() { | ||
x = 1; | ||
a(); | ||
for (var a in b) wow(); | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-minify-simplify/__tests__/fixtures/for-sequence/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function foo() { | ||
for (var a in x = 1, a(), b) wow(); | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/babel-plugin-minify-simplify/__tests__/fixtures/handle-to-boolean-2/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function x(a, b) { | ||
a = a || b; | ||
return b === a || !a; | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-minify-simplify/__tests__/fixtures/handle-to-boolean-2/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function x(a, b) { | ||
return a = a || b, b === a || !a; | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-minify-simplify/__tests__/fixtures/handle-to-boolean/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function x(a) { | ||
return !!a; | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-minify-simplify/__tests__/fixtures/handle-to-boolean/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function x(a) { | ||
return !!a; | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/babel-plugin-minify-simplify/__tests__/fixtures/handle-void-returns-2/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
function foo(a) { | ||
if (a && a.b != null) { | ||
if ((a.c--) === 1) { | ||
return; | ||
} | ||
return a.b; | ||
} | ||
return bar(a); | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-minify-simplify/__tests__/fixtures/handle-void-returns-2/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function foo(a) { | ||
return a && a.b != null ? a.c-- === 1 ? void 0 : a.b : bar(a); | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/babel-plugin-minify-simplify/__tests__/fixtures/handle-void-returns/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function foo() { | ||
if (a) { | ||
return; | ||
} | ||
|
||
return wow; | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-minify-simplify/__tests__/fixtures/handle-void-returns/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function foo() { | ||
return a ? void 0 : wow; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/babel-plugin-minify-simplify/__tests__/fixtures/hoist-functions/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function foo() { | ||
a(); | ||
function bar() {} | ||
b(); | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/babel-plugin-minify-simplify/__tests__/fixtures/hoist-functions/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function foo() { | ||
function bar() {} | ||
a(), b(); | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/babel-plugin-minify-simplify/__tests__/fixtures/if-break-2/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
for (i = 1; i <= j; i++) { | ||
foo(); | ||
if (bar) break; | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-minify-simplify/__tests__/fixtures/if-break-2/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
for (i = 1; i <= j && (foo(), !bar); i++); |
8 changes: 8 additions & 0 deletions
8
packages/babel-plugin-minify-simplify/__tests__/fixtures/if-break-3/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
for (i = 1; i <= j; i++) { | ||
if (bar) { | ||
break; | ||
} else { | ||
wat(); | ||
if (x) throw 1 | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-minify-simplify/__tests__/fixtures/if-break-3/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
for (i = 1; i <= j && !bar; i++) if (wat(), x) throw 1; |
8 changes: 8 additions & 0 deletions
8
packages/babel-plugin-minify-simplify/__tests__/fixtures/if-break-4/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
for (i = 1; i <= j; i++) { | ||
if (bar) { | ||
wat(); | ||
if (x) throw 1; | ||
} else { | ||
break; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-minify-simplify/__tests__/fixtures/if-break-4/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
for (i = 1; i <= j && !!bar; i++) if (wat(), x) throw 1; |
Oops, something went wrong.