@@ -394,7 +394,8 @@ pub fn is_entirely_after(self: Interval<Int>, point: Int) -> Bool {
394
394
} else {
395
395
point <= low
396
396
}
397
- _ -> False
397
+ NegativeInfinity -> False
398
+ PositiveInfinity -> True
398
399
}
399
400
}
400
401
@@ -434,6 +435,22 @@ test is_entirely_after_9() {
434
435
!is_entirely_after(entirely_before(10), 5)
435
436
}
436
437
438
+ test is_entirely_after_10() {
439
+ is_entirely_after(
440
+ Interval {
441
+ lower_bound: IntervalBound {
442
+ bound_type: PositiveInfinity,
443
+ is_inclusive: True,
444
+ },
445
+ upper_bound: IntervalBound {
446
+ bound_type: PositiveInfinity,
447
+ is_inclusive: False,
448
+ },
449
+ },
450
+ 1,
451
+ )
452
+ }
453
+
437
454
/// Check whether the interval is entirely before the point "a"
438
455
///
439
456
/// ```aiken
@@ -450,7 +467,8 @@ pub fn is_entirely_before(self: Interval<Int>, point: Int) -> Bool {
450
467
} else {
451
468
hi <= point
452
469
}
453
- _ -> False
470
+ PositiveInfinity -> False
471
+ NegativeInfinity -> True
454
472
}
455
473
}
456
474
@@ -490,6 +508,158 @@ test is_entirely_before_9() {
490
508
!is_entirely_before(entirely_after(10), 5)
491
509
}
492
510
511
+ test is_entirely_before_10() {
512
+ is_entirely_before(
513
+ Interval {
514
+ lower_bound: IntervalBound {
515
+ bound_type: NegativeInfinity,
516
+ is_inclusive: True,
517
+ },
518
+ upper_bound: IntervalBound {
519
+ bound_type: NegativeInfinity,
520
+ is_inclusive: False,
521
+ },
522
+ },
523
+ 1,
524
+ )
525
+ }
526
+
527
+ /// Check whether the interval starts on or after the point.
528
+ ///
529
+ /// ```aiken
530
+ /// interval.is_hereafter(interval.after(10), 5) == True
531
+ /// interval.is_hereafter(interval.after(10), 10) == True
532
+ /// interval.is_hereafter(interval.after(10), 15) == False
533
+ /// interval.is_hereafter(interval.between(10, 20), 30) == False
534
+ /// interval.is_hereafter(interval.between(10, 20), 5) == True
535
+ pub fn is_hereafter(self: Interval<Int>, point: Int) -> Bool {
536
+ when self.lower_bound.bound_type is {
537
+ Finite(lo) -> point <= lo
538
+ NegativeInfinity -> False
539
+ PositiveInfinity -> True
540
+ }
541
+ }
542
+
543
+ test is_hereafter_1() {
544
+ is_hereafter(after(10), 5)
545
+ }
546
+
547
+ test is_hereafter_2() {
548
+ is_hereafter(after(10), 10)
549
+ }
550
+
551
+ test is_hereafter_3() {
552
+ !is_hereafter(after(10), 15)
553
+ }
554
+
555
+ test is_hereafter_4() {
556
+ !is_hereafter(between(10, 20), 30)
557
+ }
558
+
559
+ test is_hereafter_5() {
560
+ is_hereafter(between(10, 20), 5)
561
+ }
562
+
563
+ test is_hereafter_6() {
564
+ is_hereafter(entirely_after(10), 10)
565
+ }
566
+
567
+ test is_hereafter_7() {
568
+ !is_hereafter(before(10), 5)
569
+ }
570
+
571
+ test is_hereafter_8() {
572
+ !is_hereafter(before(10), 15)
573
+ }
574
+
575
+ test is_hereafter_9() {
576
+ !is_hereafter(entirely_before(10), 5)
577
+ }
578
+
579
+ test is_hereafter_10() {
580
+ is_hereafter(
581
+ Interval {
582
+ lower_bound: IntervalBound {
583
+ bound_type: PositiveInfinity,
584
+ is_inclusive: True,
585
+ },
586
+ upper_bound: IntervalBound {
587
+ bound_type: PositiveInfinity,
588
+ is_inclusive: False,
589
+ },
590
+ },
591
+ 1,
592
+ )
593
+ }
594
+
595
+ /// Check whether the interval ends on or before the point.
596
+ ///
597
+ /// ```aiken
598
+ /// interval.is_herebefore(interval.before(10), 15) == True
599
+ /// interval.is_herebefore(interval.before(10), 10) == True
600
+ /// interval.is_herebefore(interval.before(10), 5) == False
601
+ /// interval.is_herebefore(interval.between(10, 20), 30) == True
602
+ /// interval.is_herebefore(interval.between(10, 20), 5) == False
603
+ pub fn is_herebefore(self: Interval<Int>, point: Int) -> Bool {
604
+ when self.upper_bound.bound_type is {
605
+ Finite(hi) -> hi <= point
606
+ PositiveInfinity -> False
607
+ NegativeInfinity -> True
608
+ }
609
+ }
610
+
611
+ test is_herebefore_1() {
612
+ is_herebefore(before(10), 15)
613
+ }
614
+
615
+ test is_herebefore_2() {
616
+ is_herebefore(before(10), 10)
617
+ }
618
+
619
+ test is_herebefore_3() {
620
+ !is_herebefore(before(10), 5)
621
+ }
622
+
623
+ test is_herebefore_4() {
624
+ is_herebefore(between(10, 20), 30)
625
+ }
626
+
627
+ test is_herebefore_5() {
628
+ !is_herebefore(between(10, 20), 5)
629
+ }
630
+
631
+ test is_herebefore_6() {
632
+ is_herebefore(entirely_before(10), 10)
633
+ }
634
+
635
+ test is_herebefore_7() {
636
+ !is_herebefore(after(10), 15)
637
+ }
638
+
639
+ test is_herebefore_8() {
640
+ !is_herebefore(after(10), 5)
641
+ }
642
+
643
+ test is_herebefore_9() {
644
+ !is_herebefore(entirely_after(10), 5)
645
+ }
646
+
647
+ test is_herebefore_10() {
648
+ is_herebefore(
649
+ Interval {
650
+ lower_bound: IntervalBound {
651
+ bound_type: NegativeInfinity,
652
+ is_inclusive: True,
653
+ },
654
+ upper_bound: IntervalBound {
655
+ bound_type: NegativeInfinity,
656
+ is_inclusive: False,
657
+ },
658
+ },
659
+ 1,
660
+ )
661
+ }
662
+
493
663
// ## Combining
494
664
495
665
/// Computes the smallest interval containing the two given intervals, if any
0 commit comments