Skip to content

Commit

Permalink
chore: debug parseDSL
Browse files Browse the repository at this point in the history
Able to reproduce a case that takes a long time to parse
  • Loading branch information
adriantam committed Oct 24, 2022
1 parent f13f60b commit c74b34a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/dsl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,42 @@ type app
`);
expect(result.length).toEqual(1);
});

it("should parse DSL in reasonable time", () => {
const time1 = new Date();
// Add in addition `define R as X from Y but not Z` to increase the time
const result = innerParseDSL(`type T1
relations
define A as A1 from A2 but not A3
define B as B1 from B2 but not B3
define C as C1 from C2 but not C3
define D as D1 from D2 but not D3
type T2
relations
define A as A1 from A2 but not A3
define B as B1 from B2 but not B3
define C as C1 from C2 but not C3
define D as D1 from D2 but not D3
type T3
relations
define A as A1 from A2 but not A3
define B as B1 from B2 but not B3
define C as C1 from C2 but not C3
define D as D1 from D2 but not D3
type T4
relations
define A as A1 from A2 but not A3
define B as B1 from B2 but not B3
define C as C1 from C2 but not C3
define D as D1 from D2 but not D3
type T5
relations
define A as A1 from A2 but not A3
`);
const time2 = new Date();
expect(result.length).toEqual(1);
expect(time2.getTime() - time1.getTime()).toBeLessThan(1000);
});
});

describe("checkDSL()", () => {
Expand Down

0 comments on commit c74b34a

Please sign in to comment.