@@ -400,12 +400,13 @@ public void UciUnit_LogicImpOperator(string operands, string expected)
400
400
401
401
[ TestCase ( "Not_False" , "True" ) ]
402
402
[ TestCase ( "Not_True" , "False" ) ]
403
+ [ TestCase ( "Not_1" , "True" ) ]
403
404
[ Category ( "Inspections" ) ]
404
405
public void UciUnit_LogicUnaryConstants ( string operands , string expected )
405
406
{
406
407
GetUnaryOpValues ( operands , out IParseTreeValue theValue , out string opSymbol ) ;
407
408
408
- var result = Calculator . Evaluate ( theValue , opSymbol ) ;
409
+ var result = Calculator . Evaluate ( theValue , opSymbol , Tokens . Boolean ) ;
409
410
410
411
Assert . AreEqual ( expected , result . ValueText ) ;
411
412
Assert . IsTrue ( result . ParsesToConstantValue , "Expected IsConstantValue field to be 'True'" ) ;
@@ -415,14 +416,17 @@ public void UciUnit_LogicUnaryConstants(string operands, string expected)
415
416
[ TestCase ( "-_23.78" , "-23.78" ) ]
416
417
[ TestCase ( "-_True" , "True?Boolean" ) ]
417
418
[ TestCase ( "-_False" , "False?Boolean" ) ]
419
+ [ TestCase ( "-_True" , "1?Integer" ) ]
420
+ [ TestCase ( "-_-1" , "1?Long" ) ]
421
+ [ TestCase ( "-_0" , "False?Boolean" ) ]
418
422
[ TestCase ( "-_1?Double" , "-1?Double" ) ]
419
423
[ TestCase ( "-_-1?Double" , "1?Double" ) ]
420
424
[ Category ( "Inspections" ) ]
421
425
public void UciUnit_MinusUnaryOp ( string operands , string expected )
422
426
{
423
427
var expectedVal = CreateInspValueFrom ( expected ) ;
424
428
GetUnaryOpValues ( operands , out IParseTreeValue LHS , out string opSymbol ) ;
425
- var result = Calculator . Evaluate ( LHS , opSymbol ) ;
429
+ var result = Calculator . Evaluate ( LHS , opSymbol , expectedVal . TypeName ) ;
426
430
427
431
Assert . AreEqual ( expectedVal . ValueText , result . ValueText ) ;
428
432
Assert . IsTrue ( result . ParsesToConstantValue ) ;
@@ -440,12 +444,13 @@ public void UciUnit_MinusUnaryOp(string operands, string expected)
440
444
[ Category ( "Inspections" ) ]
441
445
public void UciUnit_ToString ( string firstCase , string secondCase , string expected )
442
446
{
443
- var filters = RangeDescriptorsToFilters ( new string [ ] { firstCase , secondCase /*, expectedClauses*/ } , Tokens . Long ) ;
447
+ var filters = RangeDescriptorsToFilters ( new string [ ] { firstCase , secondCase } , Tokens . Long ) ;
444
448
filters [ 0 ] . Add ( filters [ 1 ] ) ;
445
449
446
450
Assert . AreEqual ( expected , filters [ 0 ] . ToString ( ) ) ;
447
451
}
448
452
453
+ [ TestCase ( "50?Long_To_50?Long" , "Long" , "Single=50" ) ]
449
454
[ TestCase ( "50?Long_To_x?Long" , "Long" , "Range=50:x" ) ]
450
455
[ TestCase ( "50?Long_To_100?Long" , "Long" , "Range=50:100" ) ]
451
456
[ TestCase ( "Soup?String_To_Nuts?String" , "String" , "Range=Nuts:Soup" ) ]
@@ -735,12 +740,13 @@ private IParseTreeValue TestBinaryOp(string opSymbol, string operands, string ex
735
740
736
741
if ( typeName . Equals ( Tokens . Double ) || typeName . Equals ( Tokens . Single ) || typeName . Equals ( Tokens . Currency ) )
737
742
{
738
- Assert . IsTrue ( Math . Abs ( double . Parse ( result . ValueText ) - double . Parse ( expected ) ) < .001 , $ "Actual={ result . ValueText } Expected={ expected } ") ;
743
+ var compareLength = expected . Length > 5 ? 5 : expected . Length ;
744
+ Assert . IsTrue ( Math . Abs ( double . Parse ( result . ValueText . Substring ( 0 , compareLength ) ) - double . Parse ( expected . Substring ( 0 , compareLength ) ) ) <= double . Epsilon , $ "Actual={ result . ValueText } Expected={ expected } ") ;
739
745
}
740
746
else if ( typeName . Equals ( Tokens . String ) )
741
747
{
742
- var toComp = expected . Length > 5 ? 5 : expected . Length ;
743
- Assert . AreEqual ( expected . Substring ( 0 , toComp ) , result . ValueText . Substring ( 0 , toComp ) ) ;
748
+ var compareLength = expected . Length > 5 ? 5 : expected . Length ;
749
+ Assert . AreEqual ( expected . Substring ( 0 , compareLength ) , result . ValueText . Substring ( 0 , compareLength ) ) ;
744
750
}
745
751
else
746
752
{
@@ -851,7 +857,7 @@ End Select
851
857
Assert . AreEqual ( expected , result ) ;
852
858
}
853
859
854
- [ TestCase ( "Not x" , "x As Long" , "Boolean " ) ]
860
+ [ TestCase ( "Not x" , "x As Long" , "Long " ) ]
855
861
[ TestCase ( "x" , "x As Long" , "Long" ) ]
856
862
[ TestCase ( "x < 5" , "x As Long" , "Boolean" ) ]
857
863
[ TestCase ( "ToLong(True) * .0035" , "x As Byte" , "Double" ) ]
@@ -1466,6 +1472,30 @@ End Select
1466
1472
CheckActualResultsEqualsExpected ( inputCode , unreachable : 1 ) ;
1467
1473
}
1468
1474
1475
+ [ Test ]
1476
+ [ Category ( "Inspections" ) ]
1477
+ public void UciFunctional_SingleValueRange ( )
1478
+ {
1479
+ const string inputCode =
1480
+ @"Sub Foo( x As Long)
1481
+
1482
+ private const y As Double = 0.5
1483
+
1484
+ Select Case x
1485
+ Case 55
1486
+ 'OK
1487
+ Case 55 To 55
1488
+ 'Unreachable
1489
+ Case 95
1490
+ 'OK
1491
+ Case Else
1492
+ 'OK
1493
+ End Select
1494
+
1495
+ End Sub" ;
1496
+ CheckActualResultsEqualsExpected ( inputCode , unreachable : 1 ) ;
1497
+ }
1498
+
1469
1499
[ Test ]
1470
1500
[ Category ( "Inspections" ) ]
1471
1501
public void UciFunctional_LongCollisionUnaryMathOperation ( )
@@ -1477,7 +1507,7 @@ Select Case -x
1477
1507
Case x > -3000
1478
1508
'OK
1479
1509
Case y > -3000
1480
- 'Cannot disqualify other, or be disqualified, except by another y > ** statement
1510
+ 'OK
1481
1511
Case x < y
1482
1512
'OK - indeterminant
1483
1513
Case 95
0 commit comments