Skip to content

Commit

Permalink
Merge pull request #36 from japaric/fix-num
Browse files Browse the repository at this point in the history
Fix fallout of numeric reform
  • Loading branch information
BurntSushi committed Nov 15, 2014
2 parents 4f39bdd + 63bd8a6 commit 3ef9461
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion examples/sieve.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
extern crate quickcheck;

use std::iter;
use quickcheck::quickcheck;
use std::iter;
use std::num::Float;

fn sieve(n: uint) -> Vec<uint> {
if n <= 1 {
Expand Down
20 changes: 10 additions & 10 deletions src/arbitrary.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::TrieMap;
use std::mem;
use std::num;
use std::num::{Int, Primitive, SignedInt, UnsignedInt, mod};
use std::rand::Rng;

/// `Gen` wraps a `rand::Rng` with parameters to control the distribution of
Expand Down Expand Up @@ -416,26 +416,26 @@ struct SignedShrinker<A> {
i: A,
}

impl<A: Primitive + Signed + Send> SignedShrinker<A> {
impl<A: Primitive + SignedInt + Send> SignedShrinker<A> {
fn new(x: A) -> Box<Shrinker<A>+'static> {
if x.is_zero() {
if x == Int::zero() {
empty_shrinker()
} else {
let shrinker = SignedShrinker {
x: x,
i: half(x),
};
if shrinker.i.is_negative() {
box vec![num::zero(), shrinker.x.abs()]
box vec![Int::zero(), shrinker.x.abs()]
.into_iter().chain(shrinker)
} else {
box vec![num::zero()].into_iter().chain(shrinker)
box vec![Int::zero()].into_iter().chain(shrinker)
}
}
}
}

impl<A: Primitive + Signed> Iterator<A> for SignedShrinker<A> {
impl<A: Primitive + SignedInt> Iterator<A> for SignedShrinker<A> {
fn next(&mut self) -> Option<A> {
if (self.x - self.i).abs() < self.x.abs() {
let result = Some(self.x - self.i);
Expand All @@ -452,12 +452,12 @@ struct UnsignedShrinker<A> {
i: A,
}

impl<A: Primitive + Unsigned + Send> UnsignedShrinker<A> {
impl<A: Primitive + UnsignedInt + Send> UnsignedShrinker<A> {
fn new(x: A) -> Box<Shrinker<A>+'static> {
if x.is_zero() {
if x == Int::zero() {
empty_shrinker::<A>()
} else {
box vec![num::zero()].into_iter().chain(
box vec![Int::zero()].into_iter().chain(
UnsignedShrinker {
x: x,
i: half(x),
Expand All @@ -467,7 +467,7 @@ impl<A: Primitive + Unsigned + Send> UnsignedShrinker<A> {
}
}

impl<A: Primitive + Unsigned> Iterator<A> for UnsignedShrinker<A> {
impl<A: Primitive + UnsignedInt> Iterator<A> for UnsignedShrinker<A> {
fn next(&mut self) -> Option<A> {
if self.x - self.i < self.x {
let result = Some(self.x - self.i);
Expand Down
1 change: 1 addition & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::cmp::Ord;
use std::iter;
use std::num::Float;
use super::{QuickCheck, TestResult, quickcheck};

#[test]
Expand Down

0 comments on commit 3ef9461

Please sign in to comment.