@@ -1184,7 +1184,7 @@ describe('include', () => {
1184
1184
} )
1185
1185
1186
1186
1187
- describe ( 'RegExp flags ' , ( ) => {
1187
+ describe ( 'ignoreCase flag ' , ( ) => {
1188
1188
1189
1189
test ( "allows all rules to be /i" , ( ) => {
1190
1190
expect ( ( ) => compile ( { a : / f o o / i, b : / b a r / i } ) ) . not . toThrow ( )
@@ -1237,22 +1237,6 @@ describe('RegExp flags', () => {
1237
1237
} ) ) . not . toThrow ( )
1238
1238
} )
1239
1239
1240
- test ( "allows all rules to be /u" , ( ) => {
1241
- expect ( ( ) => compile ( { a : / f o o / u, b : / b a r / u, c : "quxx" } ) ) . not . toThrow ( )
1242
- expect ( ( ) => compile ( { a : / f o o / u, b : / b a r / , c : "quxx" } ) ) . toThrow ( "If one RegExp sets the unicode flag then all must" )
1243
- expect ( ( ) => compile ( { a : / f o o / , b : / b a r / u, c : "quxx" } ) ) . toThrow ( "If one RegExp sets the unicode flag then all must" )
1244
- } )
1245
-
1246
- test ( "allows all rules to be /ui" , ( ) => {
1247
- expect ( ( ) => compile ( { a : / f o o / ui, b : / b a r / ui } ) ) . not . toThrow ( )
1248
- expect ( ( ) => compile ( { a : / f o o / u, b : / b a r / i } ) ) . toThrow ( "If one rule ignores case then all must" )
1249
- expect ( ( ) => compile ( { a : / f o o / i, b : / b a r / u } ) ) . toThrow ( "If one rule ignores case then all must" )
1250
- expect ( ( ) => compile ( { a : / f o o / ui, b : / b a r / i } ) ) . toThrow ( "If one RegExp sets the unicode flag then all must" )
1251
- expect ( ( ) => compile ( { a : / f o o / ui, b : / b a r / u } ) ) . toThrow ( "If one rule ignores case then all must" )
1252
- expect ( ( ) => compile ( { a : / f o o / i, b : / b a r / ui } ) ) . toThrow ( "If one RegExp sets the unicode flag then all must" )
1253
- expect ( ( ) => compile ( { a : / f o o / u, b : / b a r / ui } ) ) . toThrow ( "If one rule ignores case then all must" )
1254
- } )
1255
-
1256
1240
test ( "supports ignoreCase for everything" , ( ) => {
1257
1241
const lexer = compile ( {
1258
1242
a : / f o o / i,
@@ -1278,3 +1262,42 @@ describe('RegExp flags', () => {
1278
1262
} )
1279
1263
1280
1264
} )
1265
+
1266
+
1267
+ describe ( "unicode flag" , ( ) => {
1268
+
1269
+ test ( "allows all rules to be /u" , ( ) => {
1270
+ expect ( ( ) => compile ( { a : / f o o / u, b : / b a r / u, c : "quxx" } ) ) . not . toThrow ( )
1271
+ expect ( ( ) => compile ( { a : / f o o / u, b : / b a r / , c : "quxx" } ) ) . toThrow ( "If one RegExp sets the unicode flag then all must" )
1272
+ expect ( ( ) => compile ( { a : / f o o / , b : / b a r / u, c : "quxx" } ) ) . toThrow ( "If one RegExp sets the unicode flag then all must" )
1273
+ } )
1274
+
1275
+ test ( "allows all rules to be /ui" , ( ) => {
1276
+ expect ( ( ) => compile ( { a : / f o o / ui, b : / b a r / ui } ) ) . not . toThrow ( )
1277
+ expect ( ( ) => compile ( { a : / f o o / u, b : / b a r / i } ) ) . toThrow ( "If one rule ignores case then all must" )
1278
+ expect ( ( ) => compile ( { a : / f o o / i, b : / b a r / u } ) ) . toThrow ( "If one rule ignores case then all must" )
1279
+ expect ( ( ) => compile ( { a : / f o o / ui, b : / b a r / i } ) ) . toThrow ( "If one RegExp sets the unicode flag then all must" )
1280
+ expect ( ( ) => compile ( { a : / f o o / ui, b : / b a r / u } ) ) . toThrow ( "If one rule ignores case then all must" )
1281
+ expect ( ( ) => compile ( { a : / f o o / i, b : / b a r / ui } ) ) . toThrow ( "If one RegExp sets the unicode flag then all must" )
1282
+ expect ( ( ) => compile ( { a : / f o o / u, b : / b a r / ui } ) ) . toThrow ( "If one rule ignores case then all must" )
1283
+ } )
1284
+
1285
+ test ( "supports unicode" , ( ) => {
1286
+ const lexer = compile ( {
1287
+ a : / [ 𝌆 ] / u,
1288
+ } )
1289
+ lexer . reset ( "𝌆" )
1290
+ expect ( lexer . next ( ) ) . toMatchObject ( { value : "𝌆" } )
1291
+ lexer . reset ( "𝌆" . charCodeAt ( 0 ) )
1292
+ expect ( ( ) => lexer . next ( ) ) . toThrow ( )
1293
+
1294
+ const lexer2 = compile ( {
1295
+ a : / \u{1D356} / u,
1296
+ } )
1297
+ lexer2 . reset ( "𝍖" )
1298
+ expect ( lexer2 . next ( ) ) . toMatchObject ( { value : "𝍖" } )
1299
+ lexer2 . reset ( "\\u{1D356}" )
1300
+ expect ( ( ) => lexer2 . next ( ) ) . toThrow ( )
1301
+ } )
1302
+
1303
+ } )
0 commit comments