@@ -553,19 +553,21 @@ end
553553@testset " StaticInt" begin
554554 @test iszero (StaticInt (0 ))
555555 @test ! iszero (StaticInt (1 ))
556+ @test ! isone (StaticInt (0 ))
557+ @test isone (StaticInt (1 ))
556558 @test @inferred (one (StaticInt (1 ))) === StaticInt (1 )
557559 @test @inferred (zero (StaticInt (1 ))) === StaticInt (0 )
558560 @test @inferred (one (StaticInt)) === StaticInt (1 )
559- @test @inferred (zero (StaticInt)) === StaticInt (0 )
561+ @test @inferred (zero (StaticInt)) === StaticInt (0 ) === StaticInt ( StaticInt ( Val ( 0 )))
560562 @test eltype (one (StaticInt)) <: Int
561563
562564 x = StaticInt (1 )
563565 @test @inferred (Bool (x)) isa Bool
564566 @test @inferred (BigInt (x)) isa BigInt
565567 @test @inferred (Integer (x)) === x
566568 # test for ambiguities and correctness
567- for i ∈ [StaticInt (0 ), StaticInt (1 ), StaticInt (2 ), 3 ]
568- for j ∈ [StaticInt (0 ), StaticInt (1 ), StaticInt (2 ), 3 ]
569+ for i ∈ Any [StaticInt (0 ), StaticInt (1 ), StaticInt (2 ), 3 ]
570+ for j ∈ Any [StaticInt (0 ), StaticInt (1 ), StaticInt (2 ), 3 ]
569571 i === j === 3 && continue
570572 for f ∈ [+ , - , * , ÷ , % , << , >> , >>> , & , | , ⊻ , == , ≤ , ≥ ]
571573 (iszero (j) && ((f === ÷ ) || (f === % ))) && continue # integer division error
@@ -574,10 +576,15 @@ end
574576 end
575577 i == 3 && break
576578 for f ∈ [+ , - , * , / , ÷ , % , == , ≤ , ≥ ]
577- x = f (convert (Int, i), 1.4 )
578- y = f (1.4 , convert (Int, i))
579- @test convert (typeof (x), @inferred (f (i, 1.4 ))) === x
580- @test convert (typeof (y), @inferred (f (1.4 , i))) === y # if f is division and i === StaticInt(0), returns `NaN`; hence use of ==== in check.
579+ w = f (convert (Int, i), 1.4 )
580+ x = f (1.4 , convert (Int, i))
581+ @test convert (typeof (w), @inferred (f (i, 1.4 ))) === w
582+ @test convert (typeof (x), @inferred (f (1.4 , i))) === x # if f is division and i === StaticInt(0), returns `NaN`; hence use of ==== in check.
583+ (((f === ÷ ) || (f === % )) && (i === StaticInt (0 ))) && continue
584+ y = f (convert (Int, i), 2 // 7 )
585+ z = f (2 // 7 , convert (Int, i))
586+ @test convert (typeof (y), @inferred (f (i, 2 // 7 ))) === y
587+ @test convert (typeof (z), @inferred (f (2 // 7 , i))) === z
581588 end
582589 end
583590end
0 commit comments