-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bounds generation for generics in derive(Arbitrary)
The implementation of UseTracker expects that iteration over items of used_map gives items in insertion order. However, the order of BTreeSet is based on Ord, not insertion. I use a Vec of tuples. An alternative would be indexmap crate, but since the maps are supposed to be very small, it is probably not worthy. There already was a mention about the crate in the comments worrying about compile times.
- Loading branch information
1 parent
52d3a38
commit 35f0c68
Showing
2 changed files
with
47 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2018 The proptest developers | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use std::marker::PhantomData; | ||
|
||
use proptest::prelude::Arbitrary; | ||
use proptest_derive::Arbitrary; | ||
|
||
#[derive(Debug)] | ||
struct NotArbitrary; | ||
|
||
#[derive(Debug, Arbitrary)] | ||
// Generic types are not in alphabetical order on purpose. | ||
struct Foo<V, T, U> { | ||
v: V, | ||
t: T, | ||
u: PhantomData<U>, | ||
} | ||
|
||
#[test] | ||
fn asserting_arbitrary() { | ||
fn assert_arbitrary<T: Arbitrary>() {} | ||
|
||
assert_arbitrary::<Foo<i32, i32, NotArbitrary>>(); | ||
} |