Skip to content

Commit 3bbd89d

Browse files
committed
---
yaml --- r: 36585 b: refs/heads/try2 c: ddfd1ea h: refs/heads/master i: 36583: a57d04d v: v3
1 parent ed8d2c8 commit 3bbd89d

File tree

2 files changed

+31
-27
lines changed

2 files changed

+31
-27
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 098f71d348bbb08e9832dd4c82bd531f511458f2
8+
refs/heads/try2: ddfd1eaeb5dcb75860768f5ab9f8bb8de5fad747
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/src/test/run-pass/intrinsics-math.rs

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
extern mod std;
2+
3+
use std::cmp::FuzzyEq;
4+
15
#[abi = "rust-intrinsic"]
26
extern mod rusti {
37
fn sqrtf32(x: f32) -> f32;
@@ -36,44 +40,44 @@ fn main() {
3640

3741
use rusti::*;
3842

39-
assert(sqrtf32(64f32) == 8f32);
40-
assert(sqrtf64(64f64) == 8f64);
43+
assert(sqrtf32(64f32).fuzzy_eq(&8f32));
44+
assert(sqrtf64(64f64).fuzzy_eq(&8f64));
4145

42-
assert(powif32(25f32, -2i32) == 0.0016f32);
43-
assert(powif64(23.2f64, 2i32) == 538.24f64);
46+
assert(powif32(25f32, -2i32).fuzzy_eq(&0.0016f32));
47+
assert(powif64(23.2f64, 2i32).fuzzy_eq(&538.24f64));
4448

45-
assert(sinf32(0f32) == 0f32);
46-
assert(sinf64(f64::consts::pi / 2f64) == 1f64);
49+
assert(sinf32(0f32).fuzzy_eq(&0f32));
50+
assert(sinf64(f64::consts::pi / 2f64).fuzzy_eq(&1f64));
4751

48-
assert(cosf32(0f32) == 1f32);
49-
assert(cosf64(f64::consts::pi * 2f64) == 1f64);
52+
assert(cosf32(0f32).fuzzy_eq(&1f32));
53+
assert(cosf64(f64::consts::pi * 2f64).fuzzy_eq(&1f64));
5054

51-
assert(powf32(25f32, -2f32) == 0.0016f32);
52-
assert(powf64(400f64, 0.5f64) == 20f64);
55+
assert(powf32(25f32, -2f32).fuzzy_eq(&0.0016f32));
56+
assert(powf64(400f64, 0.5f64).fuzzy_eq(&20f64));
5357

54-
assert(fabsf32(expf32(1f32) - f32::consts::e) < 0.000001f32);
55-
assert(expf64(1f64) == f64::consts::e);
58+
assert(fabsf32(expf32(1f32) - f32::consts::e).fuzzy_eq(&0f32));
59+
assert(expf64(1f64).fuzzy_eq(&f64::consts::e));
5660

57-
assert(exp2f32(10f32) == 1024f32);
58-
assert(exp2f64(50f64) == 1125899906842624f64);
61+
assert(exp2f32(10f32).fuzzy_eq(&1024f32));
62+
assert(exp2f64(50f64).fuzzy_eq(&1125899906842624f64));
5963

60-
assert(fabsf32(logf32(f32::consts::e) - 1f32) < 0.000001f32);
61-
assert(logf64(1f64) == 0f64);
64+
assert(fabsf32(logf32(f32::consts::e) - 1f32).fuzzy_eq(&0f32));
65+
assert(logf64(1f64).fuzzy_eq(&0f64));
6266

63-
assert(log10f32(10f32) == 1f32);
64-
assert(log10f64(f64::consts::e) == f64::consts::log10_e);
67+
assert(log10f32(10f32).fuzzy_eq(&1f32));
68+
assert(log10f64(f64::consts::e).fuzzy_eq(&f64::consts::log10_e));
6569

66-
assert(log2f32(8f32) == 3f32);
67-
assert(log2f64(f64::consts::e) == f64::consts::log2_e);
70+
assert(log2f32(8f32).fuzzy_eq(&3f32));
71+
assert(log2f64(f64::consts::e).fuzzy_eq(&f64::consts::log2_e));
6872

69-
assert(fmaf32(1.0f32, 2.0f32, 5.0f32) == 7.0f32);
70-
assert(fmaf64(0.0f64, -2.0f64, f64::consts::e) == f64::consts::e);
73+
assert(fmaf32(1.0f32, 2.0f32, 5.0f32).fuzzy_eq(&7.0f32));
74+
assert(fmaf64(0.0f64, -2.0f64, f64::consts::e).fuzzy_eq(&f64::consts::e));
7175

72-
assert(fabsf32(-1.0f32) == 1.0f32);
73-
assert(fabsf64(34.2f64) == 34.2f64);
76+
assert(fabsf32(-1.0f32).fuzzy_eq(&1.0f32));
77+
assert(fabsf64(34.2f64).fuzzy_eq(&34.2f64));
7478

75-
assert(floorf32(3.8f32) == 3.0f32);
76-
assert(floorf64(-1.1f64) == -2.0f64);
79+
assert(floorf32(3.8f32).fuzzy_eq(&3.0f32));
80+
assert(floorf64(-1.1f64).fuzzy_eq(&-2.0f64));
7781

7882
// Causes linker error
7983
// undefined reference to llvm.ceil.f32/64

0 commit comments

Comments
 (0)