|
1 | 1 | import type { LiteralNode, OptionalNode } from '../../src/pattern/Nodes';
|
2 | 2 | import { SyntaxKind } from '../../src/pattern/Nodes';
|
3 |
| -import type { SimpleNode } from '../../src/pattern/Simplifier'; |
4 |
| -import { |
5 |
| - compilePatternToRegExp, |
6 |
| - computePatternMatchLength, |
7 |
| - getRegExpStringForNode, |
8 |
| - groupByNodeType, |
9 |
| - potentiallyMatchesEmptyString, |
10 |
| -} from '../../src/pattern/Util'; |
| 3 | +import { compilePatternToRegExp, getRegExpStringForNode, potentiallyMatchesEmptyString } from '../../src/pattern/Util'; |
11 | 4 | import { CharacterIterator } from '../../src/util/CharacterIterator';
|
12 | 5 |
|
13 | 6 | function toLiteralNode(str: string): LiteralNode {
|
@@ -123,63 +116,3 @@ describe('getRegExpStringForNode()', () => {
|
123 | 116 | });
|
124 | 117 | });
|
125 | 118 | });
|
126 |
| - |
127 |
| -describe('computePatternMatchLength()', () => { |
128 |
| - it('should return 0 if given an empty array', () => { |
129 |
| - expect(computePatternMatchLength([])).toBe(0); |
130 |
| - }); |
131 |
| - |
132 |
| - it('should return the total number of chars in literal nodes plus 1 for each wildcard node', () => { |
133 |
| - const nodes: SimpleNode[] = [ |
134 |
| - { kind: SyntaxKind.Literal, chars: [0, 0] }, |
135 |
| - { kind: SyntaxKind.Wildcard }, |
136 |
| - { kind: SyntaxKind.Literal, chars: [0, 0, 0] }, |
137 |
| - ]; |
138 |
| - expect(computePatternMatchLength(nodes)).toBe(6); |
139 |
| - }); |
140 |
| -}); |
141 |
| - |
142 |
| -describe('groupByNodeType()', () => { |
143 |
| - it('should return an empty array if nodes=[]', () => { |
144 |
| - expect(groupByNodeType([])).toStrictEqual([]); |
145 |
| - }); |
146 |
| - |
147 |
| - it('should return one literal group if there are only literal nodes in the input', () => { |
148 |
| - const nodes: SimpleNode[] = [ |
149 |
| - { kind: SyntaxKind.Literal, chars: [1, 2, 3] }, |
150 |
| - { kind: SyntaxKind.Literal, chars: [2, 3, 4] }, |
151 |
| - ]; |
152 |
| - expect(groupByNodeType(nodes)).toStrictEqual([{ isLiteralGroup: true, literals: nodes }]); |
153 |
| - }); |
154 |
| - |
155 |
| - it('should return one wildcard group if there are only wildcards in the input', () => { |
156 |
| - const nodes: SimpleNode[] = [ |
157 |
| - { kind: SyntaxKind.Wildcard }, |
158 |
| - { kind: SyntaxKind.Wildcard }, |
159 |
| - { kind: SyntaxKind.Wildcard }, |
160 |
| - ]; |
161 |
| - expect(groupByNodeType(nodes)).toStrictEqual([{ isLiteralGroup: false, wildcardCount: 3 }]); |
162 |
| - }); |
163 |
| - |
164 |
| - it('should group literals and wildcards together', () => { |
165 |
| - const literal0: LiteralNode = { kind: SyntaxKind.Literal, chars: [1, 2, 3] }; |
166 |
| - const literal1: LiteralNode = { kind: SyntaxKind.Literal, chars: [2, 3, 4] }; |
167 |
| - const literal2: LiteralNode = { kind: SyntaxKind.Literal, chars: [3, 4, 5] }; |
168 |
| - const nodes: SimpleNode[] = [ |
169 |
| - { kind: SyntaxKind.Wildcard }, |
170 |
| - literal0, |
171 |
| - literal1, |
172 |
| - { kind: SyntaxKind.Wildcard }, |
173 |
| - literal2, |
174 |
| - { kind: SyntaxKind.Wildcard }, |
175 |
| - { kind: SyntaxKind.Wildcard }, |
176 |
| - ]; |
177 |
| - expect(groupByNodeType(nodes)).toStrictEqual([ |
178 |
| - { isLiteralGroup: false, wildcardCount: 1 }, |
179 |
| - { isLiteralGroup: true, literals: [literal0, literal1] }, |
180 |
| - { isLiteralGroup: false, wildcardCount: 1 }, |
181 |
| - { isLiteralGroup: true, literals: [literal2] }, |
182 |
| - { isLiteralGroup: false, wildcardCount: 2 }, |
183 |
| - ]); |
184 |
| - }); |
185 |
| -}); |
0 commit comments