]> git.lizzy.rs Git - rust.git/blob - src/libcore/tests/num/flt2dec/strategy/dragon.rs
Ignore some failing test on wasm32-unknown-emscripten
[rust.git] / src / libcore / tests / num / flt2dec / strategy / dragon.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use std::prelude::v1::*;
12 use super::super::*;
13 use core::num::bignum::Big32x40 as Big;
14 use core::num::flt2dec::strategy::dragon::*;
15
16 #[test]
17 fn test_mul_pow10() {
18     let mut prevpow10 = Big::from_small(1);
19     for i in 1..340 {
20         let mut curpow10 = Big::from_small(1);
21         mul_pow10(&mut curpow10, i);
22         assert_eq!(curpow10, *prevpow10.clone().mul_small(10));
23         prevpow10 = curpow10;
24     }
25 }
26
27 #[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630
28 #[test]
29 fn shortest_sanity_test() {
30     f64_shortest_sanity_test(format_shortest);
31     f32_shortest_sanity_test(format_shortest);
32     more_shortest_sanity_test(format_shortest);
33 }
34
35 #[test]
36 fn exact_sanity_test() {
37     // This test ends up running what I can only assume is some corner-ish case
38     // of the `exp2` library function, defined in whatever C runtime we're
39     // using. In VS 2013 this function apparently had a bug as this test fails
40     // when linked, but with VS 2015 the bug appears fixed as the test runs just
41     // fine.
42     //
43     // The bug seems to be a difference in return value of `exp2(-1057)`, where
44     // in VS 2013 it returns a double with the bit pattern 0x2 and in VS 2015 it
45     // returns 0x20000.
46     //
47     // For now just ignore this test entirely on MSVC as it's tested elsewhere
48     // anyway and we're not super interested in testing each platform's exp2
49     // implementation.
50     if !cfg!(target_env = "msvc") {
51         f64_exact_sanity_test(format_exact);
52     }
53     f32_exact_sanity_test(format_exact);
54 }
55
56 #[test]
57 fn test_to_shortest_str() {
58     to_shortest_str_test(format_shortest);
59 }
60
61 #[test]
62 fn test_to_shortest_exp_str() {
63     to_shortest_exp_str_test(format_shortest);
64 }
65
66 #[test]
67 fn test_to_exact_exp_str() {
68     to_exact_exp_str_test(format_exact);
69 }
70
71 #[test]
72 fn test_to_exact_fixed_str() {
73     to_exact_fixed_str_test(format_exact);
74 }
75