Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Commit

Permalink
feat: add contiguous anchors simulation for test
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Sep 12, 2024
1 parent fdf6926 commit 5ff1971
Show file tree
Hide file tree
Showing 14 changed files with 778 additions and 1,588 deletions.
2 changes: 2 additions & 0 deletions src/textmate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export function loweringTextmateGrammar<T extends TextmateGrammarBasic>(
a.begin = handle(a.begin)
if (a.end)
a.end = handle(a.end)
if (a.while)
a.while = handle(a.while)
if (a.patterns) {
a.patterns.forEach((j: any) => {
traverse(j)
Expand Down
85 changes: 15 additions & 70 deletions test-generated/astro.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,9 @@ it('unexpected match: 0', () => {
30,
)
expect.soft(regex.source).toMatchInlineSnapshot(`"(?<=^|---|>|})"`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dgm"`)
expect.soft(match).toMatchInlineSnapshot(`
[
"",
]
`)
expect.soft(indices).toMatchInlineSnapshot(`
[
[
31,
31,
],
]
`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dg"`)
expect.soft(match).toMatchInlineSnapshot(`null`)
expect.soft(indices).toMatchInlineSnapshot(`[]`)
expect(match).toBe(null)
})

Expand All @@ -32,20 +21,9 @@ it('unexpected match: 1', () => {
48,
)
expect.soft(regex.source).toMatchInlineSnapshot(`"(?<=^|---|>|})"`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dgm"`)
expect.soft(match).toMatchInlineSnapshot(`
[
"",
]
`)
expect.soft(indices).toMatchInlineSnapshot(`
[
[
49,
49,
],
]
`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dg"`)
expect.soft(match).toMatchInlineSnapshot(`null`)
expect.soft(indices).toMatchInlineSnapshot(`[]`)
expect(match).toBe(null)
})

Expand All @@ -56,20 +34,9 @@ it('unexpected match: 2', () => {
76,
)
expect.soft(regex.source).toMatchInlineSnapshot(`"(?<=^|---|>|})"`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dgm"`)
expect.soft(match).toMatchInlineSnapshot(`
[
"",
]
`)
expect.soft(indices).toMatchInlineSnapshot(`
[
[
77,
77,
],
]
`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dg"`)
expect.soft(match).toMatchInlineSnapshot(`null`)
expect.soft(indices).toMatchInlineSnapshot(`[]`)
expect(match).toBe(null)
})

Expand All @@ -80,20 +47,9 @@ it('unexpected match: 3', () => {
38,
)
expect.soft(regex.source).toMatchInlineSnapshot(`"(?<=^|---|>|})"`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dgm"`)
expect.soft(match).toMatchInlineSnapshot(`
[
"",
]
`)
expect.soft(indices).toMatchInlineSnapshot(`
[
[
39,
39,
],
]
`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dg"`)
expect.soft(match).toMatchInlineSnapshot(`null`)
expect.soft(indices).toMatchInlineSnapshot(`[]`)
expect(match).toBe(null)
})

Expand All @@ -104,19 +60,8 @@ it('unexpected match: 4', () => {
30,
)
expect.soft(regex.source).toMatchInlineSnapshot(`"(?<=^|---|>|})"`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dgm"`)
expect.soft(match).toMatchInlineSnapshot(`
[
"",
]
`)
expect.soft(indices).toMatchInlineSnapshot(`
[
[
31,
31,
],
]
`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dg"`)
expect.soft(match).toMatchInlineSnapshot(`null`)
expect.soft(indices).toMatchInlineSnapshot(`[]`)
expect(match).toBe(null)
})
132 changes: 18 additions & 114 deletions test-generated/beancount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,9 @@ it('unexpected match: 0', () => {
43,
)
expect.soft(regex.source).toMatchInlineSnapshot(`"(?=(^\\s*$|^\\S))"`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dgm"`)
expect.soft(match).toMatchInlineSnapshot(`
[
"",
"",
]
`)
expect.soft(indices).toMatchInlineSnapshot(`
[
[
43,
43,
],
[
43,
43,
],
]
`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dg"`)
expect.soft(match).toMatchInlineSnapshot(`null`)
expect.soft(indices).toMatchInlineSnapshot(`[]`)
expect(match).toBe(null)
})

Expand All @@ -37,25 +21,9 @@ it('unexpected match: 1', () => {
47,
)
expect.soft(regex.source).toMatchInlineSnapshot(`"(?=(^\\s*$|^\\S|^\\s*[A-Z]))"`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dgm"`)
expect.soft(match).toMatchInlineSnapshot(`
[
"",
"",
]
`)
expect.soft(indices).toMatchInlineSnapshot(`
[
[
48,
48,
],
[
48,
48,
],
]
`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dg"`)
expect.soft(match).toMatchInlineSnapshot(`null`)
expect.soft(indices).toMatchInlineSnapshot(`[]`)
expect(match).toBe(null)
})

Expand All @@ -66,25 +34,9 @@ it('unexpected match: 2', () => {
47,
)
expect.soft(regex.source).toMatchInlineSnapshot(`"(?=(^\\s*$|^\\S|^\\s*[A-Z]))"`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dgm"`)
expect.soft(match).toMatchInlineSnapshot(`
[
"",
"",
]
`)
expect.soft(indices).toMatchInlineSnapshot(`
[
[
48,
48,
],
[
48,
48,
],
]
`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dg"`)
expect.soft(match).toMatchInlineSnapshot(`null`)
expect.soft(indices).toMatchInlineSnapshot(`[]`)
expect(match).toBe(null)
})

Expand All @@ -95,25 +47,9 @@ it('unexpected match: 3', () => {
45,
)
expect.soft(regex.source).toMatchInlineSnapshot(`"(?=(^\\s*$|^\\S))"`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dgm"`)
expect.soft(match).toMatchInlineSnapshot(`
[
"",
"",
]
`)
expect.soft(indices).toMatchInlineSnapshot(`
[
[
45,
45,
],
[
45,
45,
],
]
`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dg"`)
expect.soft(match).toMatchInlineSnapshot(`null`)
expect.soft(indices).toMatchInlineSnapshot(`[]`)
expect(match).toBe(null)
})

Expand All @@ -124,25 +60,9 @@ it('unexpected match: 4', () => {
58,
)
expect.soft(regex.source).toMatchInlineSnapshot(`"(?=(^\\s*$|^\\S|^\\s*[A-Z]))"`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dgm"`)
expect.soft(match).toMatchInlineSnapshot(`
[
"",
"",
]
`)
expect.soft(indices).toMatchInlineSnapshot(`
[
[
59,
59,
],
[
59,
59,
],
]
`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dg"`)
expect.soft(match).toMatchInlineSnapshot(`null`)
expect.soft(indices).toMatchInlineSnapshot(`[]`)
expect(match).toBe(null)
})

Expand All @@ -153,24 +73,8 @@ it('unexpected match: 5', () => {
47,
)
expect.soft(regex.source).toMatchInlineSnapshot(`"(?=(^\\s*$|^\\S|^\\s*[A-Z]))"`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dgm"`)
expect.soft(match).toMatchInlineSnapshot(`
[
"",
"",
]
`)
expect.soft(indices).toMatchInlineSnapshot(`
[
[
48,
48,
],
[
48,
48,
],
]
`)
expect.soft(regex.flags).toMatchInlineSnapshot(`"dg"`)
expect.soft(match).toMatchInlineSnapshot(`null`)
expect.soft(indices).toMatchInlineSnapshot(`[]`)
expect(match).toBe(null)
})
Loading

0 comments on commit 5ff1971

Please sign in to comment.