|
| 1 | +#![feature(core_intrinsics)] |
| 2 | + |
| 3 | +use std::intrinsics::{ |
| 4 | + fadd_algebraic, fdiv_algebraic, fmul_algebraic, frem_algebraic, fsub_algebraic, |
| 5 | +}; |
| 6 | + |
| 7 | +#[inline(never)] |
| 8 | +pub fn test_operations_f64(a: f64, b: f64) { |
| 9 | + // make sure they all map to the correct operation |
| 10 | + assert_eq!(fadd_algebraic(a, b), a + b); |
| 11 | + assert_eq!(fsub_algebraic(a, b), a - b); |
| 12 | + assert_eq!(fmul_algebraic(a, b), a * b); |
| 13 | + assert_eq!(fdiv_algebraic(a, b), a / b); |
| 14 | + assert_eq!(frem_algebraic(a, b), a % b); |
| 15 | +} |
| 16 | + |
| 17 | +#[inline(never)] |
| 18 | +pub fn test_operations_f32(a: f32, b: f32) { |
| 19 | + // make sure they all map to the correct operation |
| 20 | + assert_eq!(fadd_algebraic(a, b), a + b); |
| 21 | + assert_eq!(fsub_algebraic(a, b), a - b); |
| 22 | + assert_eq!(fmul_algebraic(a, b), a * b); |
| 23 | + assert_eq!(fdiv_algebraic(a, b), a / b); |
| 24 | + assert_eq!(frem_algebraic(a, b), a % b); |
| 25 | +} |
| 26 | + |
| 27 | +fn main() { |
| 28 | + test_operations_f64(1., 2.); |
| 29 | + test_operations_f64(10., 5.); |
| 30 | + test_operations_f32(11., 2.); |
| 31 | + test_operations_f32(10., 15.); |
| 32 | +} |
0 commit comments