Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
boopathi committed Jan 25, 2017
1 parent bad06b9 commit 64db587
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Expand Up @@ -2421,4 +2421,13 @@ describe("dce-plugin", () => {

expect(transform(source)).toBe(expected);
});

it("should deopt impure expressions in if statements", () => {
const source = unpad(`
if (a.b(), true) {
foo();
}
`);
expect(transform(source)).toBe(source);
});
});
14 changes: 14 additions & 0 deletions packages/babel-preset-babili/__tests__/preset-tests.js
Expand Up @@ -61,4 +61,18 @@ describe("preset", () => {
`);
expect(transform(source)).toBe(expected);
});

it("should fix issue#385 - impure if statements with Sequence and DCE", () => {
const source = unpad(`
a = b;
c = d;
if (false) {
const x = y
}
`);
const expected = unpad(`
a = b, c = d;
`);
expect(transform(source)).toBe(expected);
});
});

0 comments on commit 64db587

Please sign in to comment.