@@ -1376,6 +1376,15 @@ mod tests {
1376
1376
) ;
1377
1377
}
1378
1378
1379
+ const IF_DIRECTIVE : TT = TT :: ConditionalDirective ( CDK :: If ) ;
1380
+ const IFDEF_DIRECTIVE : TT = TT :: ConditionalDirective ( CDK :: Ifdef ) ;
1381
+ const IFNDEF_DIRECTIVE : TT = TT :: ConditionalDirective ( CDK :: Ifndef ) ;
1382
+ const IFOPT_DIRECTIVE : TT = TT :: ConditionalDirective ( CDK :: Ifopt ) ;
1383
+ const ELSEIF_DIRECTIVE : TT = TT :: ConditionalDirective ( CDK :: Elseif ) ;
1384
+ const ELSE_DIRECTIVE : TT = TT :: ConditionalDirective ( CDK :: Else ) ;
1385
+ const IFEND_DIRECTIVE : TT = TT :: ConditionalDirective ( CDK :: Ifend ) ;
1386
+ const ENDIF_DIRECTIVE : TT = TT :: ConditionalDirective ( CDK :: Endif ) ;
1387
+
1379
1388
#[ test]
1380
1389
fn lex_compiler_directives ( ) {
1381
1390
run_test (
@@ -1387,34 +1396,22 @@ mod tests {
1387
1396
] ,
1388
1397
) ;
1389
1398
[
1390
- (
1391
- "{$if}" ,
1392
- TT :: ConditionalDirective ( ConditionalDirectiveKind :: If ) ,
1393
- ) ,
1394
- ( "{$ifdef}" , TT :: ConditionalDirective ( CDK :: Ifdef ) ) ,
1395
- ( "{$ifndef}" , TT :: ConditionalDirective ( CDK :: Ifndef ) ) ,
1396
- ( "{$ifopt}" , TT :: ConditionalDirective ( CDK :: Ifopt ) ) ,
1397
- ( "{$elseif}" , TT :: ConditionalDirective ( CDK :: Elseif ) ) ,
1398
- (
1399
- "{$else}" ,
1400
- TT :: ConditionalDirective ( ConditionalDirectiveKind :: Else ) ,
1401
- ) ,
1402
- ( "{$ifend}" , TT :: ConditionalDirective ( CDK :: Ifend ) ) ,
1403
- ( "{$endif}" , TT :: ConditionalDirective ( CDK :: Endif ) ) ,
1404
- (
1405
- "(*$if*)" ,
1406
- TT :: ConditionalDirective ( ConditionalDirectiveKind :: If ) ,
1407
- ) ,
1408
- ( "(*$ifdef*)" , TT :: ConditionalDirective ( CDK :: Ifdef ) ) ,
1409
- ( "(*$ifndef*)" , TT :: ConditionalDirective ( CDK :: Ifndef ) ) ,
1410
- ( "(*$ifopt*)" , TT :: ConditionalDirective ( CDK :: Ifopt ) ) ,
1411
- ( "(*$elseif*)" , TT :: ConditionalDirective ( CDK :: Elseif ) ) ,
1412
- (
1413
- "(*$else*)" ,
1414
- TT :: ConditionalDirective ( ConditionalDirectiveKind :: Else ) ,
1415
- ) ,
1416
- ( "(*$ifend*)" , TT :: ConditionalDirective ( CDK :: Ifend ) ) ,
1417
- ( "(*$endif*)" , TT :: ConditionalDirective ( CDK :: Endif ) ) ,
1399
+ ( "{$if}" , IF_DIRECTIVE ) ,
1400
+ ( "{$ifdef}" , IFDEF_DIRECTIVE ) ,
1401
+ ( "{$ifndef}" , IFNDEF_DIRECTIVE ) ,
1402
+ ( "{$ifopt}" , IFOPT_DIRECTIVE ) ,
1403
+ ( "{$elseif}" , ELSEIF_DIRECTIVE ) ,
1404
+ ( "{$else}" , ELSE_DIRECTIVE ) ,
1405
+ ( "{$ifend}" , IFEND_DIRECTIVE ) ,
1406
+ ( "{$endif}" , ENDIF_DIRECTIVE ) ,
1407
+ ( "(*$if*)" , IF_DIRECTIVE ) ,
1408
+ ( "(*$ifdef*)" , IFDEF_DIRECTIVE ) ,
1409
+ ( "(*$ifndef*)" , IFNDEF_DIRECTIVE ) ,
1410
+ ( "(*$ifopt*)" , IFOPT_DIRECTIVE ) ,
1411
+ ( "(*$elseif*)" , ELSEIF_DIRECTIVE ) ,
1412
+ ( "(*$else*)" , ELSE_DIRECTIVE ) ,
1413
+ ( "(*$ifend*)" , IFEND_DIRECTIVE ) ,
1414
+ ( "(*$endif*)" , ENDIF_DIRECTIVE ) ,
1418
1415
]
1419
1416
. into_iter ( )
1420
1417
. for_each ( run_casing_test) ;
@@ -1430,10 +1427,7 @@ mod tests {
1430
1427
1431
1428
"
1432
1429
} ,
1433
- & [ (
1434
- "{$if\n // other comment\n Foo;" ,
1435
- TT :: ConditionalDirective ( ConditionalDirectiveKind :: If ) ,
1436
- ) ] ,
1430
+ & [ ( "{$if\n // other comment\n Foo;" , IF_DIRECTIVE ) ] ,
1437
1431
) ;
1438
1432
run_test (
1439
1433
indoc ! { "
@@ -1443,10 +1437,7 @@ mod tests {
1443
1437
1444
1438
"
1445
1439
} ,
1446
- & [ (
1447
- "(*$if\n // other comment\n Foo;" ,
1448
- TT :: ConditionalDirective ( ConditionalDirectiveKind :: If ) ,
1449
- ) ] ,
1440
+ & [ ( "(*$if\n // other comment\n Foo;" , IF_DIRECTIVE ) ] ,
1450
1441
) ;
1451
1442
}
1452
1443
@@ -2041,7 +2032,7 @@ mod tests {
2041
2032
( "RBX" , TT :: Identifier ) ,
2042
2033
( "," , TT :: Op ( OK :: Comma ) ) ,
2043
2034
( "RBX" , TT :: Identifier ) ,
2044
- ( "{$ifdef End}" , TT :: ConditionalDirective ( CDK :: Ifdef ) ) ,
2035
+ ( "{$ifdef End}" , IFDEF_DIRECTIVE ) ,
2045
2036
( "end" , TT :: Keyword ( KK :: End ) ) ,
2046
2037
] ,
2047
2038
) ;
0 commit comments