Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
c410-f3r committed Nov 2, 2024
1 parent a850f63 commit 1fbd5d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
9 changes: 9 additions & 0 deletions library/kani/tests/ops.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use core::ops::{Bound, Range, RangeFrom, RangeInclusive, RangeTo, RangeToInclusive};

fn _has_range_implementations() {
let _: Bound<u8> = kani::any();
let _: RangeFrom<u8> = kani::any();
let _: RangeInclusive<u8> = kani::any();
let _: RangeTo<u8> = kani::any();
let _: RangeToInclusive<u8> = kani::any();
}
23 changes: 5 additions & 18 deletions library/kani_core/src/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ macro_rules! generate_arbitrary {
T: Arbitrary,
{
fn any() -> Self {
match u8::any() % 3 {
match u8::any() {
0 => Bound::Included(T::any()),
1 => Bound::Excluded(T::any()),
_ => Bound::Unbounded,
Expand All @@ -218,12 +218,10 @@ macro_rules! generate_arbitrary {

impl<T> Arbitrary for Range<T>
where
T: Arbitrary + PartialOrd,
T: Arbitrary,
{
fn any() -> Self {
let (mut first, mut second) = (T::any(), T::any());
adjust(&mut first, &mut second);
first..second
T::any()..T::any()
}
}

Expand All @@ -238,12 +236,10 @@ macro_rules! generate_arbitrary {

impl<T> Arbitrary for RangeInclusive<T>
where
T: Arbitrary + PartialOrd,
T: Arbitrary,
{
fn any() -> Self {
let (mut first, mut second) = (T::any(), T::any());
adjust(&mut first, &mut second);
first..=second
T::any()..=T::any()
}
}

Expand All @@ -264,15 +260,6 @@ macro_rules! generate_arbitrary {
..=T::any()
}
}

fn adjust<T>(first: &mut T, second: &mut T)
where
T: PartialOrd,
{
if first > second {
mem::swap(first, second);
}
}
}
};
}
Expand Down

0 comments on commit 1fbd5d8

Please sign in to comment.