@@ -463,6 +463,9 @@ closedendpoints(I::MyUnitInterval) = (I.isleftclosed,I.isrightclosed)
463
463
@test Interval {:open,:closed} (i2) ∩ OpenInterval (i3) ≡ OpenInterval (i3) ∩ Interval {:open,:closed} (i2) ≡ Interval {:open,:closed} (d)
464
464
@test Interval {:open,:closed} (i2) ∩ Interval {:closed,:open} (i3) ≡ Interval {:closed,:open} (i3) ∩ Interval {:open,:closed} (i2) ≡ d
465
465
466
+ # - intersection of custom intervals
467
+ @test intersect (MyUnitInterval (true ,true ), MyUnitInterval (false ,false )) == OpenInterval (0 ,1 )
468
+ @test intersect (MyUnitInterval (true ,true ), OpenInterval (0 ,1 )) == OpenInterval (0 ,1 )
466
469
467
470
# - union of non-overlapping intervals
468
471
@test_throws ArgumentError i1 ∪ i4
@@ -472,8 +475,6 @@ closedendpoints(I::MyUnitInterval) = (I.isleftclosed,I.isrightclosed)
472
475
@test_throws ArgumentError Interval {:closed,:open} (i1) ∪ i4
473
476
@test_throws ArgumentError Interval {:closed,:open} (i1) ∪ OpenInterval (i4)
474
477
475
-
476
-
477
478
# - union of almost-overlapping intervals
478
479
@test_throws ArgumentError i1 ∪ i5
479
480
@test_throws ArgumentError i5 ∪ i1
@@ -577,6 +578,7 @@ closedendpoints(I::MyUnitInterval) = (I.isleftclosed,I.isrightclosed)
577
578
@test Interval {:closed,:open} (I) === convert (Interval{:closed ,:open }, I) ===
578
579
Interval {:closed,:open,Int} (I) === convert (Interval{:closed ,:open ,Int}, I) ===
579
580
convert (Interval, I) === Interval (I) === Interval {:closed,:open} (0 .. 1 )
581
+ @test convert (AbstractInterval, I) === convert (AbstractInterval{Int}, I) === I
580
582
end
581
583
582
584
@testset " Custom typed endpoints interval" begin
@@ -597,4 +599,42 @@ closedendpoints(I::MyUnitInterval) = (I.isleftclosed,I.isrightclosed)
597
599
@test issubset (1.1 , 0.0 .. 1.0 ) == false
598
600
@test issubset (0.0 , nextfloat (0.0 ).. 1.0 ) == false
599
601
end
602
+
603
+ @testset " complex in" begin
604
+ @test 0 + im ∉ 0 .. 2
605
+ @test 0 + 0im ∈ 0 .. 2
606
+ @test 0 + eps ()im ∉ 0 .. 2
607
+
608
+ @test 0 + im ∉ OpenInterval (0 ,2 )
609
+ @test 0 + 0im ∉ OpenInterval (0 ,2 )
610
+ @test 1 + 0im ∈ OpenInterval (0 ,2 )
611
+ @test 1 + eps ()im ∉ OpenInterval (0 ,2 )
612
+
613
+ @test 0 + im ∉ Interval {:closed,:open} (0 ,2 )
614
+ @test 0 + 0im ∈ Interval {:closed,:open} (0 ,2 )
615
+ @test 1 + 0im ∈ Interval {:closed,:open} (0 ,2 )
616
+ @test 1 + eps ()im ∉ Interval {:closed,:open} (0 ,2 )
617
+
618
+ @test 0 + im ∉ Interval {:open,:closed} (0 ,2 )
619
+ @test 0 + 0im ∉ Interval {:open,:closed} (0 ,2 )
620
+ @test 1 + 0im ∈ Interval {:open,:closed} (0 ,2 )
621
+ @test 1 + eps ()im ∉ Interval {:open,:closed} (0 ,2 )
622
+ end
623
+
624
+ @testset " closedendpoints" begin
625
+ @test closedendpoints (0 .. 1 ) == closedendpoints (MyClosedUnitInterval ()) == (true ,true )
626
+ @test closedendpoints (Interval {:open,:closed} (0 ,1 )) == (false ,true )
627
+ @test closedendpoints (Interval {:closed,:open} (0 ,1 )) == (true ,false )
628
+ @test closedendpoints (OpenInterval (0 ,1 )) == (false ,false )
629
+ end
630
+
631
+ @testset " OneTo" begin
632
+ @test_throws ArgumentError Base. OneTo {Int} (0 .. 5 )
633
+ @test_throws ArgumentError Base. OneTo (0 .. 5 )
634
+ @test Base. OneTo (1 .. 5 ) == Base. OneTo {Int} (1 .. 5 ) == Base. OneTo (5 )
635
+ end
636
+
637
+ @testset " IteratorSize" begin
638
+ @test Base. IteratorSize (ClosedInterval) == Base. SizeUnknown ()
639
+ end
600
640
end
0 commit comments