@@ -395,8 +395,9 @@ class SemanticsSuite extends AnyFunSuite {
395
395
check(s, LessThan (FractionLiteral (4 , 2 ), FractionLiteral (7 , 1 )), BooleanLiteral (true ))
396
396
}
397
397
398
- val floatValues : Seq [Float ] = Seq (0f , - 0f , 0.1f , - 6.7f , Float .NaN , Float .MinValue , Float .MinValue , Float .PositiveInfinity , Float .NegativeInfinity )
399
- val doubleValues : Seq [Double ] = Seq (0d , - 0d , 0.1d , - 6.7d , Double .NaN , Double .MinValue , Double .MinValue , Double .PositiveInfinity , Double .NegativeInfinity )
398
+ import scala .collection .immutable .HashSet
399
+ val floatValues : Set [Float ] = HashSet (0f , - 0f , 0.1f , - 6.7f , Float .NaN , Float .MinValue , Float .MinValue , Float .PositiveInfinity , Float .NegativeInfinity )
400
+ val doubleValues : Set [Double ] = HashSet (0d , - 0d , 0.1d , - 6.7d , Double .NaN , Double .MinValue , Double .MinValue , Double .PositiveInfinity , Double .NegativeInfinity )
400
401
401
402
402
403
test(" Floating point literals" , filterSolvers(_, princess = true )) { ctx =>
@@ -453,6 +454,28 @@ class SemanticsSuite extends AnyFunSuite {
453
454
check(s, LessThan (Float32Literal (i), Float32Literal (j)), BooleanLiteral (i < j))
454
455
}
455
456
457
+ for (i <- floatValues.excl(0 )) {
458
+ check(s, FPIsNegative (Float32Literal (i)), BooleanLiteral (i < 0 ))
459
+ }
460
+ check(s, FPIsNegative (Float32Literal (- 0 )), BooleanLiteral (true ))
461
+ check(s, FPIsNegative (Float32Literal (0 )), BooleanLiteral (false ))
462
+
463
+ for (i <- floatValues.excl(0 )) {
464
+ check(s, FPIsPositive (Float32Literal (i)), BooleanLiteral (i > 0 ))
465
+ }
466
+ check(s, FPIsPositive (Float32Literal (0 )), BooleanLiteral (true ))
467
+ check(s, FPIsPositive (Float32Literal (- 0 )), BooleanLiteral (false ))
468
+
469
+ for (i <- floatValues) {
470
+ check(s, FPIsInfinite (Float32Literal (i)), BooleanLiteral (i == Float .PositiveInfinity || i == Float .NegativeInfinity ))
471
+ }
472
+
473
+ for (i <- floatValues) {
474
+ check(s, FPIsZero (Float32Literal (i)), BooleanLiteral (i == 0 ))
475
+ }
476
+
477
+ check(s, FPIsNaN (Float32Literal (Float .NaN )), BooleanLiteral (true ))
478
+
456
479
for (i <- doubleValues; j <- doubleValues) {
457
480
check(s, FPEquals (Float64Literal (i), Float64Literal (j)), BooleanLiteral (Float64Literal (i).semEquals(Float64Literal (j))))
458
481
check(s, FPEquals (Float64Literal (i), Float64Literal (j)), BooleanLiteral (i == j))
@@ -462,6 +485,30 @@ class SemanticsSuite extends AnyFunSuite {
462
485
check(s, LessThan (Float64Literal (i), Float64Literal (j)), BooleanLiteral (i < j))
463
486
}
464
487
488
+ for (i <- doubleValues.excl(0 )) {
489
+ check(s, FPIsNegative (Float64Literal (i)), BooleanLiteral (i < 0 ))
490
+ }
491
+ check(s, FPIsNegative (Float64Literal (- 0 )), BooleanLiteral (true ))
492
+ check(s, FPIsNegative (Float64Literal (0 )), BooleanLiteral (false ))
493
+
494
+ for (i <- doubleValues.excl(0 )) {
495
+ check(s, FPIsPositive (Float64Literal (i)), BooleanLiteral (i > 0 ))
496
+ }
497
+ check(s, FPIsPositive (Float64Literal (0 )), BooleanLiteral (true ))
498
+ check(s, FPIsPositive (Float64Literal (- 0 )), BooleanLiteral (false ))
499
+
500
+ for (i <- doubleValues) {
501
+ check(s, FPIsInfinite (Float64Literal (i)), BooleanLiteral (i == Double .PositiveInfinity || i == Double .NegativeInfinity ))
502
+ }
503
+
504
+ for (i <- doubleValues) {
505
+ check(s, FPIsZero (Float64Literal (i)), BooleanLiteral (i == 0 ))
506
+ }
507
+
508
+ check(s, FPIsNaN (Float64Literal (Double .NaN )), BooleanLiteral (true ))
509
+
510
+
511
+
465
512
}
466
513
test(" Let" ) { ctx =>
467
514
val s = solver(ctx)
0 commit comments