Skip to content

Commit bee66f2

Browse files
More tests for 'x' flag
1 parent 0fa590b commit bee66f2

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/parser/__tests__/parser-extended-test.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,56 @@ describe('extended', () => {
101101
},
102102
flags: 'x'
103103
});
104+
});
105+
106+
it('escaped space and # with x flag', () => {
107+
const re = '/\\ \\#/x';
108+
109+
expect(parser.parse(re)).toEqual({
110+
type: 'RegExp',
111+
body: {
112+
type: 'Alternative',
113+
expressions: [
114+
{
115+
type: 'Char',
116+
value: ' ',
117+
kind: 'simple',
118+
escaped: true,
119+
},
120+
{
121+
type: 'Char',
122+
value: '#',
123+
kind: 'simple',
124+
escaped: true,
125+
},
126+
],
127+
},
128+
flags: 'x'
129+
});
130+
});
131+
132+
it('non-escaped space and # in class with x flag', () => {
133+
const re = '/[ #]/x';
104134

135+
expect(parser.parse(re)).toEqual({
136+
type: 'RegExp',
137+
body: {
138+
type: 'CharacterClass',
139+
expressions: [
140+
{
141+
type: 'Char',
142+
value: ' ',
143+
kind: 'simple',
144+
},
145+
{
146+
type: 'Char',
147+
value: '#',
148+
kind: 'simple',
149+
},
150+
],
151+
},
152+
flags: 'x'
153+
});
105154
});
106155

107156
});

0 commit comments

Comments
 (0)