|
@@ -54,116 +54,70 @@ divmod!(__divmoddi4, __divdi3: i64);
|
|
|
mod tests {
|
|
|
use qc::{U32, U64};
|
|
|
|
|
|
- use gcc_s;
|
|
|
- use quickcheck::TestResult;
|
|
|
- use rand;
|
|
|
-
|
|
|
- quickcheck!{
|
|
|
- fn divdi3(n: U64, d: U64) -> TestResult {
|
|
|
+ check! {
|
|
|
+ fn __divdi3(f: extern fn(i64, i64) -> i64, n: U64, d: U64) -> Option<i64> {
|
|
|
let (n, d) = (n.0 as i64, d.0 as i64);
|
|
|
if d == 0 {
|
|
|
- TestResult::discard()
|
|
|
+ None
|
|
|
} else {
|
|
|
- let q = super::__divdi3(n, d);
|
|
|
-
|
|
|
- match gcc_s::divdi3() {
|
|
|
- Some(divdi3) if rand::random() => {
|
|
|
- TestResult::from_bool(q == unsafe { divdi3(n, d) })
|
|
|
- },
|
|
|
- _ => TestResult::from_bool(q == n / d),
|
|
|
- }
|
|
|
+ Some(f(n, d))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- fn moddi3(n: U64, d: U64) -> TestResult {
|
|
|
+ fn __moddi3(f: extern fn(i64, i64) -> i64, n: U64, d: U64) -> Option<i64> {
|
|
|
let (n, d) = (n.0 as i64, d.0 as i64);
|
|
|
if d == 0 {
|
|
|
- TestResult::discard()
|
|
|
+ None
|
|
|
} else {
|
|
|
- let r = super::__moddi3(n, d);
|
|
|
-
|
|
|
- match gcc_s::moddi3() {
|
|
|
- Some(moddi3) if rand::random() => {
|
|
|
- TestResult::from_bool(r == unsafe { moddi3(n, d) })
|
|
|
- },
|
|
|
- _ => TestResult::from_bool(r == n % d),
|
|
|
- }
|
|
|
+ Some(f(n, d))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- fn divmoddi4(n: U64, d: U64) -> TestResult {
|
|
|
+ fn __divmoddi4(f: extern fn(i64, i64, &mut i64) -> i64,
|
|
|
+ n: U64,
|
|
|
+ d: U64) -> Option<(i64, i64)> {
|
|
|
let (n, d) = (n.0 as i64, d.0 as i64);
|
|
|
if d == 0 {
|
|
|
- TestResult::discard()
|
|
|
+ None
|
|
|
} else {
|
|
|
let mut r = 0;
|
|
|
- let q = super::__divmoddi4(n, d, &mut r);
|
|
|
-
|
|
|
- match gcc_s::divmoddi4() {
|
|
|
- Some(divmoddi4) if rand::random() => {
|
|
|
- let mut gcc_s_r = 0;
|
|
|
- let gcc_s_q = unsafe {
|
|
|
- divmoddi4(n, d, &mut gcc_s_r)
|
|
|
- };
|
|
|
-
|
|
|
- TestResult::from_bool(q == gcc_s_q && r == gcc_s_r)
|
|
|
- },
|
|
|
- _ => TestResult::from_bool(q == n / d && r == n % d),
|
|
|
- }
|
|
|
+ let q = f(n, d, &mut r);
|
|
|
+ Some((q, r))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- fn divsi3(n: U32, d: U32) -> TestResult {
|
|
|
+ fn __divsi3(f: extern fn(i32, i32) -> i32,
|
|
|
+ n: U32,
|
|
|
+ d: U32) -> Option<i32> {
|
|
|
let (n, d) = (n.0 as i32, d.0 as i32);
|
|
|
if d == 0 {
|
|
|
- TestResult::discard()
|
|
|
+ None
|
|
|
} else {
|
|
|
- let q = super::__divsi3(n, d);
|
|
|
-
|
|
|
- match gcc_s::divsi3() {
|
|
|
- Some(divsi3) if rand::random() => {
|
|
|
- TestResult::from_bool(q == unsafe { divsi3(n, d)})
|
|
|
- },
|
|
|
- _ => TestResult::from_bool(q == n / d),
|
|
|
- }
|
|
|
+ Some(f(n, d))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- fn modsi3(n: U32, d: U32) -> TestResult {
|
|
|
+ fn __modsi3(f: extern fn(i32, i32) -> i32,
|
|
|
+ n: U32,
|
|
|
+ d: U32) -> Option<i32> {
|
|
|
let (n, d) = (n.0 as i32, d.0 as i32);
|
|
|
if d == 0 {
|
|
|
- TestResult::discard()
|
|
|
+ None
|
|
|
} else {
|
|
|
- let r = super::__modsi3(n, d);
|
|
|
-
|
|
|
- match gcc_s::modsi3() {
|
|
|
- Some(modsi3) if rand::random() => {
|
|
|
- TestResult::from_bool(r == unsafe { modsi3(n, d) })
|
|
|
- },
|
|
|
- _ => TestResult::from_bool(r == n % d),
|
|
|
- }
|
|
|
+ Some(f(n, d))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- fn divmodsi4(n: U32, d: U32) -> TestResult {
|
|
|
+ fn __divmodsi4(f: extern fn(i32, i32, &mut i32) -> i32,
|
|
|
+ n: U32,
|
|
|
+ d: U32) -> Option<(i32, i32)> {
|
|
|
let (n, d) = (n.0 as i32, d.0 as i32);
|
|
|
if d == 0 {
|
|
|
- TestResult::discard()
|
|
|
+ None
|
|
|
} else {
|
|
|
let mut r = 0;
|
|
|
- let q = super::__divmodsi4(n, d, &mut r);
|
|
|
-
|
|
|
- match gcc_s::divmodsi4() {
|
|
|
- Some(divmodsi4) if rand::random() => {
|
|
|
- let mut gcc_s_r = 0;
|
|
|
- let gcc_s_q = unsafe {
|
|
|
- divmodsi4(n, d, &mut gcc_s_r)
|
|
|
- };
|
|
|
-
|
|
|
- TestResult::from_bool(q == gcc_s_q && r == gcc_s_r)
|
|
|
- },
|
|
|
- _ => TestResult::from_bool(q == n / d && r == n % d),
|
|
|
- }
|
|
|
+ let q = f(n, d, &mut r);
|
|
|
+ Some((q, r))
|
|
|
}
|
|
|
}
|
|
|
}
|