|
@@ -1,3 +1,7 @@
|
|
|
+// makes configuration easier
|
|
|
+#![allow(unused_macros)]
|
|
|
+
|
|
|
+use compiler_builtins::float::Float;
|
|
|
use testcrate::*;
|
|
|
|
|
|
/// Make sure that the the edge case tester and randomized tester don't break, and list examples of
|
|
@@ -89,15 +93,37 @@ fn leading_zeros() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+macro_rules! extend {
|
|
|
+ ($fX:ident, $fD:ident, $fn:ident) => {
|
|
|
+ fuzz_float(N, |x: $fX| {
|
|
|
+ let tmp0 = x as $fD;
|
|
|
+ let tmp1: $fD = $fn(x);
|
|
|
+ if !Float::eq_repr(tmp0, tmp1) {
|
|
|
+ panic!(
|
|
|
+ "{}({}): std: {}, builtins: {}",
|
|
|
+ stringify!($fn),
|
|
|
+ x,
|
|
|
+ tmp0,
|
|
|
+ tmp1
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
#[test]
|
|
|
fn float_extend() {
|
|
|
- fuzz_float(N, |x: f32| {
|
|
|
- let tmp0 = x as f64;
|
|
|
- let tmp1: f64 = compiler_builtins::float::extend::__extendsfdf2(x);
|
|
|
- if !compiler_builtins::float::Float::eq_repr(tmp0, tmp1) {
|
|
|
- panic!("__extendsfdf2({}): std: {}, builtins: {}", x, tmp0, tmp1);
|
|
|
- }
|
|
|
- });
|
|
|
+ use compiler_builtins::float::extend::__extendsfdf2;
|
|
|
+
|
|
|
+ extend!(f32, f64, __extendsfdf2);
|
|
|
+}
|
|
|
+
|
|
|
+#[cfg(target_arch = "arm")]
|
|
|
+#[test]
|
|
|
+fn float_extend_arm() {
|
|
|
+ use compiler_builtins::float::extend::__extendsfdf2vfp;
|
|
|
+
|
|
|
+ extend!(f32, f64, __extendsfdf2vfp);
|
|
|
}
|
|
|
|
|
|
// This doesn't quite work because of issues related to
|
|
@@ -108,14 +134,16 @@ macro_rules! pow {
|
|
|
($($f:ty, $fn:ident);*;) => {
|
|
|
$(
|
|
|
fuzz_float_2(N, |x: $f, y: $f| {
|
|
|
- let n = y as i32;
|
|
|
- let tmp0: $f = x.powi(n);
|
|
|
- let tmp1: $f = $fn(x, n);
|
|
|
- if tmp0 != tmp1 {
|
|
|
- panic!(
|
|
|
- "{}({}, {}): std: {}, builtins: {}",
|
|
|
- stringify!($fn), x, y, tmp0, tmp1
|
|
|
- );
|
|
|
+ if !(Float::is_subnormal(x) || Float::is_subnormal(y) || x < 0. || y < 0.) {
|
|
|
+ let n = y as i32;
|
|
|
+ let tmp0: $f = x.powi(n);
|
|
|
+ let tmp1: $f = $fn(x, n);
|
|
|
+ if tmp0 != tmp1 {
|
|
|
+ panic!(
|
|
|
+ "{}({}, {}): std: {}, builtins: {}",
|
|
|
+ stringify!($fn), x, y, tmp0, tmp1
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
)*
|
|
@@ -132,3 +160,11 @@ fn float_pow() {
|
|
|
);
|
|
|
}
|
|
|
*/
|
|
|
+
|
|
|
+// placeholder test to make sure basic functionality works
|
|
|
+#[test]
|
|
|
+fn float_pow() {
|
|
|
+ use compiler_builtins::float::pow::{__powidf2, __powisf2};
|
|
|
+ assert_eq!(__powisf2(-3.0, 3), -27.0);
|
|
|
+ assert_eq!(__powidf2(-3.0, 3), -27.0);
|
|
|
+}
|