Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rust-lang/compiler-builtins
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4b6f32bdd59dab43540b0d50d119c41b4e339a0b
Choose a base ref
..
head repository: rust-lang/compiler-builtins
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8b135b37038bb4b693128099b977b86f4a39cb19
Choose a head ref
Showing with 32 additions and 32 deletions.
  1. +32 −32 src/qc.rs
64 changes: 32 additions & 32 deletions src/qc.rs
Original file line number Diff line number Diff line change
@@ -14,31 +14,31 @@ use float::Float;

// Generates values in the full range of the integer type
macro_rules! arbitrary {
($id:ident: $ty:ty) => {
($TY:ident : $ty:ident) => {
#[derive(Clone, Copy)]
pub struct $id(pub $ty);
pub struct $TY(pub $ty);

impl Arbitrary for $id {
fn arbitrary<G>(g: &mut G) -> $id
impl Arbitrary for $TY {
fn arbitrary<G>(g: &mut G) -> $TY
where G: Gen
{
$id(g.gen())
$TY(g.gen())
}

fn shrink(&self) -> Box<Iterator<Item=$id>> {
fn shrink(&self) -> Box<Iterator<Item=$TY>> {
struct Shrinker {
x: $ty,
}

impl Iterator for Shrinker {
type Item = $id;
type Item = $TY;

fn next(&mut self) -> Option<$id> {
fn next(&mut self) -> Option<$TY> {
self.x /= 2;
if self.x == 0 {
None
} else {
Some($id(self.x))
Some($TY(self.x))
}
}
}
@@ -51,7 +51,7 @@ macro_rules! arbitrary {
}
}

impl fmt::Debug for $id {
impl fmt::Debug for $TY {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.0, f)
}
@@ -70,37 +70,37 @@ arbitrary!(U32: u32);
// word or (c) generate both words randomly. This let's cover better the code paths in our
// intrinsics.
macro_rules! arbitrary_large {
($id:ident: $ty:ty) => {
($TY:ident : $ty:ident) => {
#[derive(Clone, Copy)]
pub struct $id(pub $ty);
pub struct $TY(pub $ty);

impl Arbitrary for $id {
fn arbitrary<G>(g: &mut G) -> $id
impl Arbitrary for $TY {
fn arbitrary<G>(g: &mut G) -> $TY
where G: Gen
{
if g.gen() {
$id(<$ty>::from_parts(g.gen(), g.gen()))
$TY($ty::from_parts(g.gen(), g.gen()))
} else if g.gen() {
$id(<$ty>::from_parts(0, g.gen()))
$TY($ty::from_parts(0, g.gen()))
} else {
$id(<$ty>::from_parts(g.gen(), 0))
$TY($ty::from_parts(g.gen(), 0))
}
}

fn shrink(&self) -> Box<Iterator<Item=$id>> {
fn shrink(&self) -> Box<Iterator<Item=$TY>> {
struct Shrinker {
x: $ty,
}

impl Iterator for Shrinker {
type Item = $id;
type Item = $TY;

fn next(&mut self) -> Option<$id> {
fn next(&mut self) -> Option<$TY> {
self.x /= 2;
if self.x == 0 {
None
} else {
Some($id(self.x))
Some($TY(self.x))
}
}
}
@@ -113,7 +113,7 @@ macro_rules! arbitrary_large {
}
}

impl fmt::Debug for $id {
impl fmt::Debug for $TY {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.0, f)
}
@@ -125,12 +125,12 @@ arbitrary_large!(I64: i64);
arbitrary_large!(U64: u64);

macro_rules! arbitrary_float {
($id:ident: $ty:ident) => {
($TY:ident : $ty:ident) => {
#[derive(Clone, Copy)]
pub struct $id(pub $ty);
pub struct $TY(pub $ty);

impl Arbitrary for $id {
fn arbitrary<G>(g: &mut G) -> $id
impl Arbitrary for $TY {
fn arbitrary<G>(g: &mut G) -> $TY
where G: Gen
{
let special = [
@@ -139,31 +139,31 @@ macro_rules! arbitrary_float {

if g.gen() { // Random special case
let index: usize = g.gen();
$id(special[index % special.len()])
$TY(special[index % special.len()])
} else if g.gen() { // Random anything
let sign: bool = g.gen();
let exponent: <$ty as Float>::Int = g.gen();
let significand: <$ty as Float>::Int = g.gen();
$id(<$ty>::from_parts(sign, exponent, significand))
$TY($ty::from_parts(sign, exponent, significand))
} else if g.gen() { // Denormalized
let sign: bool = g.gen();
let exponent: <$ty as Float>::Int = 0;
let significand: <$ty as Float>::Int = g.gen();
$id(<$ty>::from_parts(sign, exponent, significand))
$TY($ty::from_parts(sign, exponent, significand))
} else { // NaN variants
let sign: bool = g.gen();
let exponent: <$ty as Float>::Int = g.gen();
let significand: <$ty as Float>::Int = 0;
$id(<$ty>::from_parts(sign, exponent, significand))
$TY($ty::from_parts(sign, exponent, significand))
}
}

fn shrink(&self) -> Box<Iterator<Item=$id>> {
fn shrink(&self) -> Box<Iterator<Item=$TY>> {
::quickcheck::empty_shrinker()
}
}

impl fmt::Debug for $id {
impl fmt::Debug for $TY {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.0, f)
}