Skip to content

Commit

Permalink
add more tests for DCE'ing conditional expressions (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdesjardins authored and kangax committed Oct 23, 2016
1 parent f2ec0ae commit ace753d
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,30 @@ describe("dce-plugin", () => {
expect(transform(source).trim()).toBe(expected);
});

it("should evaluate conditional expressions 3", () => {
const source = "'foo' ? a() : b();";
const expected = "a();";
expect(transform(source).trim()).toBe(expected);
});

it("should evaluate conditional expressions 4", () => {
const source = "null ? a() : b();";
const expected = "b();";
expect(transform(source).trim()).toBe(expected);
});

it("should evaluate conditional expressions 5", () => {
const source = "'foo' === 'foo' ? a() : b();";
const expected = "a();";
expect(transform(source).trim()).toBe(expected);
});

it("should evaluate conditional expressions 6", () => {
const source = "'foo' !== 'bar' ? a() : b();";
const expected = "a();";
expect(transform(source).trim()).toBe(expected);
});

it("should not remove needed expressions", () => {
const source = unpad(`
var n = 1;
Expand Down

0 comments on commit ace753d

Please sign in to comment.