Skip to content

Commit 1ab05d5

Browse files
committed
test: add test for caseInsensitive + formatting
1 parent f07f736 commit 1ab05d5

File tree

2 files changed

+39
-32
lines changed

2 files changed

+39
-32
lines changed

packages/ohm-js/src/UnicodeCategories.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,37 @@
99
| awk '{printf "\x27%s\x27,\n",$1}'
1010
*/
1111
export const UnicodeCategories = Object.fromEntries(
12-
[
13-
'Cc',
14-
'Cf',
15-
'Cn',
16-
'Co',
17-
'Cs',
18-
'Ll',
19-
'Lm',
20-
'Lo',
21-
'Lt',
22-
'Lu',
23-
'Mc',
24-
'Me',
25-
'Mn',
26-
'Nd',
27-
'Nl',
28-
'No',
29-
'Pc',
30-
'Pd',
31-
'Pe',
32-
'Pf',
33-
'Pi',
34-
'Po',
35-
'Ps',
36-
'Sc',
37-
'Sk',
38-
'Sm',
39-
'So',
40-
'Zl',
41-
'Zp',
42-
'Zs'
43-
].map(alias => [alias, new RegExp(String.raw`\p{${alias}}`, 'u')])
12+
[
13+
'Cc',
14+
'Cf',
15+
'Cn',
16+
'Co',
17+
'Cs',
18+
'Ll',
19+
'Lm',
20+
'Lo',
21+
'Lt',
22+
'Lu',
23+
'Mc',
24+
'Me',
25+
'Mn',
26+
'Nd',
27+
'Nl',
28+
'No',
29+
'Pc',
30+
'Pd',
31+
'Pe',
32+
'Pf',
33+
'Pi',
34+
'Po',
35+
'Ps',
36+
'Sc',
37+
'Sk',
38+
'Sm',
39+
'So',
40+
'Zl',
41+
'Zp',
42+
'Zs',
43+
].map(alias => [alias, new RegExp(String.raw`\p{${alias}}`, 'u')]),
4444
);
4545
UnicodeCategories['Ltmo'] = /\p{Lt}|\p{Lm}|\p{Lo}/u;

packages/ohm-js/test/test-built-in-rules.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ test('case-insensitive matching', t => {
7272
{message: /Incorrect argument type/},
7373
'throws when argument is a Range',
7474
);
75+
76+
const g2 = ohm.grammar(`
77+
G2 {
78+
start = caseInsensitive<"!">
79+
caseInsensitive<x> := x
80+
}`);
81+
t.is(g2.match('!').succeeded(), true, 'caseInsensitive can be overridden');
7582
});
7683

7784
test('applySyntactic - basics', t => {

0 commit comments

Comments
 (0)