@@ -2,38 +2,38 @@ describe('flag x', () => {
2
2
describe ( 'in default context' , ( ) => {
3
3
it ( 'should treat whitespace as insignificant' , ( ) => {
4
4
const ws = '\t\n\v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF' ;
5
- expect ( 'ab' ) . toMatch ( Regex . make ( { raw : [ `^a${ ws } b$` ] } , [ ] ) ) ;
5
+ expect ( 'ab' ) . toMatch ( regex ( { raw : [ `^a${ ws } b$` ] } , [ ] ) ) ;
6
6
} ) ;
7
7
8
8
it ( 'should start line comments with # that continue until the next \\n' , ( ) => {
9
- expect ( 'ab' ) . toMatch ( Regex . make `^a#comment\nb$` ) ;
9
+ expect ( 'ab' ) . toMatch ( regex `^ a # c o m m e n t \nb $ ` ) ;
10
10
} ) ;
11
11
12
12
it ( 'should not end line comments with newlines other than \\n' , ( ) => {
13
13
const newlines = [ '\r' , '\u2028' , '\u2029' ] ;
14
14
newlines . forEach ( n => {
15
- expect ( 'ab' ) . not . toMatch ( Regex . make ( { raw : [ `^a#comment${ n } b\n$` ] } , [ ] ) ) ;
15
+ expect ( 'ab' ) . not . toMatch ( regex ( { raw : [ `^a#comment${ n } b\n$` ] } , [ ] ) ) ;
16
16
} ) ;
17
17
} ) ;
18
18
19
19
it ( 'should start line comments with # that continue until the end of the string if there are no following newlines' , ( ) => {
20
- expect ( 'ac' ) . toMatch ( Regex . make `^a#comment b$` ) ;
20
+ expect ( 'ac' ) . toMatch ( regex `^ a # c o m m e n t b $ ` ) ;
21
21
} ) ;
22
22
23
23
it ( 'should allow mixing whitespace and line comments' , function ( ) {
24
- expect ( 'ab' ) . toMatch ( Regex . make ( { raw : [ '\f^ a \t\n ##comment\n #\nb $ # ignored' ] } , [ ] ) ) ;
24
+ expect ( 'ab' ) . toMatch ( regex ( { raw : [ '\f^ a \t\n ##comment\n #\nb $ # ignored' ] } , [ ] ) ) ;
25
25
} ) ;
26
26
27
27
it ( 'should apply a quantifier following whitespace or line comments to the preceding token' , function ( ) {
28
- expect ( 'aaa' ) . toMatch ( Regex . make `^a +$` ) ;
29
- expect ( 'aaa' ) . toMatch ( Regex . make ( { raw : [ '^a#comment\n+$' ] } , [ ] ) ) ;
30
- expect ( 'aaa' ) . toMatch ( Regex . make ( { raw : [ '^a #comment\n +$' ] } , [ ] ) ) ;
28
+ expect ( 'aaa' ) . toMatch ( regex `^ a + $ ` ) ;
29
+ expect ( 'aaa' ) . toMatch ( regex ( { raw : [ '^a#comment\n+$' ] } , [ ] ) ) ;
30
+ expect ( 'aaa' ) . toMatch ( regex ( { raw : [ '^a #comment\n +$' ] } , [ ] ) ) ;
31
31
} ) ;
32
32
33
33
it ( 'should not let the token following whitespace or line comments modify the preceding token' , ( ) => {
34
- expect ( '\u{0}0' ) . toMatch ( Regex . make `\0 0` ) ;
35
- expect ( '\u{0}1' ) . toMatch ( Regex . make `\0 1` ) ;
36
- expect ( '\u{0}1' ) . toMatch ( Regex . make ( { raw : [ '\0#\n1' ] } , [ ] ) ) ;
34
+ expect ( '\u{0}0' ) . toMatch ( regex `\0 0 ` ) ;
35
+ expect ( '\u{0}1' ) . toMatch ( regex `\0 1 ` ) ;
36
+ expect ( '\u{0}1' ) . toMatch ( regex ( { raw : [ '\0#\n1' ] } , [ ] ) ) ;
37
37
} ) ;
38
38
39
39
it ( 'should preserve the error status of incomplete tokens separated from their completing chars by whitespace' , ( ) => {
@@ -47,47 +47,47 @@ describe('flag x', () => {
47
47
'\\x0 0' ,
48
48
] ;
49
49
values . forEach ( v => {
50
- expect ( ( ) => Regex . make ( { raw : [ v ] } , [ ] ) ) . withContext ( v ) . toThrow ( ) ;
50
+ expect ( ( ) => regex ( { raw : [ v ] } , [ ] ) ) . withContext ( v ) . toThrow ( ) ;
51
51
} ) ;
52
52
} ) ;
53
53
54
54
it ( 'should allow escaping whitespace to make it significant' , ( ) => {
55
- expect ( ' ' ) . toMatch ( Regex . make `\ ` ) ;
56
- expect ( ' ' ) . toMatch ( Regex . make ` \ \ ` ) ;
55
+ expect ( ' ' ) . toMatch ( regex `\ ` ) ;
56
+ expect ( ' ' ) . toMatch ( regex ` \ \ ` ) ;
57
57
} ) ;
58
58
59
59
it ( 'should allow escaping # to make it significant' , ( ) => {
60
- expect ( '#' ) . toMatch ( Regex . make `\#` ) ;
61
- expect ( '##' ) . toMatch ( Regex . make ` \# \# ` ) ;
60
+ expect ( '#' ) . toMatch ( regex `\#` ) ;
61
+ expect ( '##' ) . toMatch ( regex ` \# \# ` ) ;
62
62
} ) ;
63
63
} ) ;
64
64
65
65
describe ( 'in character class context' , ( ) => {
66
66
it ( 'should treat space and tab characters as insignificant' , ( ) => {
67
- expect ( ' ' ) . not . toMatch ( Regex . make `[ a]` ) ;
68
- expect ( '\t' ) . not . toMatch ( Regex . make ( { raw : [ '[\ta]' ] } , [ ] ) ) ;
67
+ expect ( ' ' ) . not . toMatch ( regex `[ a ] ` ) ;
68
+ expect ( '\t' ) . not . toMatch ( regex ( { raw : [ '[\ta]' ] } , [ ] ) ) ;
69
69
} ) ;
70
70
71
71
it ( 'should not treat whitespace characters apart from space and tab as insignificant' , ( ) => {
72
- expect ( '\n' ) . toMatch ( Regex . make ( { raw : [ '[\na]' ] } , [ ] ) ) ;
73
- expect ( '\xA0' ) . toMatch ( Regex . make ( { raw : [ '[\xA0a]' ] } , [ ] ) ) ;
74
- expect ( '\u2028' ) . toMatch ( Regex . make ( { raw : [ '[\u2028a]' ] } , [ ] ) ) ;
72
+ expect ( '\n' ) . toMatch ( regex ( { raw : [ '[\na]' ] } , [ ] ) ) ;
73
+ expect ( '\xA0' ) . toMatch ( regex ( { raw : [ '[\xA0a]' ] } , [ ] ) ) ;
74
+ expect ( '\u2028' ) . toMatch ( regex ( { raw : [ '[\u2028a]' ] } , [ ] ) ) ;
75
75
} ) ;
76
76
77
77
it ( 'should not start comments with #' , ( ) => {
78
- expect ( '#' ) . toMatch ( Regex . make `[#a]` ) ;
78
+ expect ( '#' ) . toMatch ( regex `[ # a ] ` ) ;
79
79
} ) ;
80
80
81
81
it ( 'should not let a leading ^ following whitespace change the character class type' , ( ) => {
82
- expect ( '^' ) . toMatch ( Regex . make `[ ^]` ) ;
83
- expect ( '_' ) . not . toMatch ( Regex . make `[ ^]` ) ;
84
- expect ( '^' ) . toMatch ( Regex . make `[ ^a]` ) ;
85
- expect ( '_' ) . not . toMatch ( Regex . make `[ ^a]` ) ;
82
+ expect ( '^' ) . toMatch ( regex `[ ^ ] ` ) ;
83
+ expect ( '_' ) . not . toMatch ( regex `[ ^ ] ` ) ;
84
+ expect ( '^' ) . toMatch ( regex `[ ^ a ] ` ) ;
85
+ expect ( '_' ) . not . toMatch ( regex `[ ^ a ] ` ) ;
86
86
} ) ;
87
87
88
88
it ( 'should not let the token following whitespace modify the preceding token' , ( ) => {
89
- expect ( '0' ) . toMatch ( Regex . make `[\0 0]` ) ;
90
- expect ( '1' ) . toMatch ( Regex . make `[\0 1]` ) ;
89
+ expect ( '0' ) . toMatch ( regex `[ \0 0 ] ` ) ;
90
+ expect ( '1' ) . toMatch ( regex `[ \0 1 ] ` ) ;
91
91
} ) ;
92
92
93
93
it ( 'should preserve the error status of incomplete tokens separated from their completing chars by whitespace' , ( ) => {
@@ -101,7 +101,7 @@ describe('flag x', () => {
101
101
'[\\x0 0]' ,
102
102
] ;
103
103
values . forEach ( v => {
104
- expect ( ( ) => Regex . make ( { raw : [ v ] } , [ ] ) ) . withContext ( v ) . toThrow ( ) ;
104
+ expect ( ( ) => regex ( { raw : [ v ] } , [ ] ) ) . withContext ( v ) . toThrow ( ) ;
105
105
} ) ;
106
106
} ) ;
107
107
@@ -121,17 +121,17 @@ describe('flag x', () => {
121
121
'[a - - b]' ,
122
122
] ;
123
123
values . forEach ( v => {
124
- expect ( ( ) => Regex . make ( { raw : [ v ] } , [ ] ) ) . withContext ( v ) . toThrow ( ) ;
124
+ expect ( ( ) => regex ( { raw : [ v ] } , [ ] ) ) . withContext ( v ) . toThrow ( ) ;
125
125
} ) ;
126
126
} ) ;
127
127
128
128
it ( 'should allow set operators to be offset by whitespace' , ( ) => {
129
- expect ( 'a' ) . toMatch ( Regex . make `[\w -- _]` ) ;
130
- expect ( 'a' ) . toMatch ( Regex . make `[\w-- _]` ) ;
131
- expect ( 'a' ) . toMatch ( Regex . make `[\w --_]` ) ;
132
- expect ( 'a' ) . toMatch ( Regex . make `[\w && [a-z]]` ) ;
133
- expect ( 'a' ) . toMatch ( Regex . make `[\w&& [a-z]]` ) ;
134
- expect ( 'a' ) . toMatch ( Regex . make `[\w &&[a-z]]` ) ;
129
+ expect ( 'a' ) . toMatch ( regex `[ \w - - _ ] ` ) ;
130
+ expect ( 'a' ) . toMatch ( regex `[ \w- - _ ] ` ) ;
131
+ expect ( 'a' ) . toMatch ( regex `[ \w - - _ ] ` ) ;
132
+ expect ( 'a' ) . toMatch ( regex `[ \w & & [ a - z ] ] ` ) ;
133
+ expect ( 'a' ) . toMatch ( regex `[ \w& & [ a - z ] ] ` ) ;
134
+ expect ( 'a' ) . toMatch ( regex `[ \w & & [ a - z ] ] ` ) ;
135
135
} ) ;
136
136
137
137
it ( 'should match (as a literal character) a lone double-punctuator character separated from its partner by whitespace' , ( ) => {
@@ -157,21 +157,21 @@ describe('flag x', () => {
157
157
'~' ,
158
158
] ;
159
159
doublePunctuatorChars . forEach ( c => {
160
- expect ( c ) . withContext ( `[a${ c } ${ c } b]` ) . toMatch ( Regex . make ( { raw : [ `[a${ c } ${ c } b]` ] } , [ ] ) ) ;
161
- expect ( c ) . withContext ( `[a${ c } ${ c } b]` ) . toMatch ( Regex . make ( { raw : [ `[a${ c } ${ c } b]` ] } , [ ] ) ) ;
162
- expect ( c ) . withContext ( `[a ${ c } ${ c } b]` ) . toMatch ( Regex . make ( { raw : [ `[a ${ c } ${ c } b]` ] } , [ ] ) ) ;
163
- expect ( c ) . withContext ( `[a ${ c } ${ c } b]` ) . toMatch ( Regex . make ( { raw : [ `[a ${ c } ${ c } b]` ] } , [ ] ) ) ;
160
+ expect ( c ) . withContext ( `[a${ c } ${ c } b]` ) . toMatch ( regex ( { raw : [ `[a${ c } ${ c } b]` ] } , [ ] ) ) ;
161
+ expect ( c ) . withContext ( `[a${ c } ${ c } b]` ) . toMatch ( regex ( { raw : [ `[a${ c } ${ c } b]` ] } , [ ] ) ) ;
162
+ expect ( c ) . withContext ( `[a ${ c } ${ c } b]` ) . toMatch ( regex ( { raw : [ `[a ${ c } ${ c } b]` ] } , [ ] ) ) ;
163
+ expect ( c ) . withContext ( `[a ${ c } ${ c } b]` ) . toMatch ( regex ( { raw : [ `[a ${ c } ${ c } b]` ] } , [ ] ) ) ;
164
164
} ) ;
165
165
} ) ;
166
166
167
167
it ( 'should allow escaping whitespace to make it significant' , ( ) => {
168
- expect ( ' ' ) . toMatch ( Regex . make `[ \ ]` ) ;
169
- expect ( ' ' ) . toMatch ( Regex . make `[\q{ \ }]` ) ;
168
+ expect ( ' ' ) . toMatch ( regex `[ \ ] ` ) ;
169
+ expect ( ' ' ) . toMatch ( regex `[ \q{ \ } ] ` ) ;
170
170
} ) ;
171
171
} ) ;
172
172
173
173
it ( 'should set flag x status with an experimental option' , ( ) => {
174
- expect ( 'a b' ) . not . toMatch ( Regex . make ( { __flagX : true } ) `a b` ) ;
175
- expect ( 'a b' ) . toMatch ( Regex . make ( { __flagX : false } ) `a b` ) ;
174
+ expect ( 'a b' ) . not . toMatch ( regex ( { __flagX : true } ) `a b` ) ;
175
+ expect ( 'a b' ) . toMatch ( regex ( { __flagX : false } ) `a b` ) ;
176
176
} ) ;
177
177
} ) ;
0 commit comments