]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/numeric-method-autoexport.rs
rustdoc: Replace no-pretty-expanded with pretty-expanded
[rust.git] / src / test / run-pass / numeric-method-autoexport.rs
1 // Copyright 2012-2014 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 // no-pretty-expanded
12
13 // This file is intended to test only that methods are automatically
14 // reachable for each numeric type, for each exported impl, with no imports
15 // necessary. Testing the methods of the impls is done within the source
16 // file for each numeric type.
17
18 // pretty-expanded FIXME #23616
19
20 #![feature(core)]
21
22 use std::ops::Add;
23 use std::num::ToPrimitive;
24
25 pub fn main() {
26 // ints
27     // num
28     assert_eq!(15_isize.add(6_isize), 21_isize);
29     assert_eq!(15_i8.add(6i8), 21_i8);
30     assert_eq!(15_i16.add(6i16), 21_i16);
31     assert_eq!(15_i32.add(6i32), 21_i32);
32     assert_eq!(15_i64.add(6i64), 21_i64);
33
34 // uints
35     // num
36     assert_eq!(15_usize.add(6_usize), 21_usize);
37     assert_eq!(15_u8.add(6u8), 21_u8);
38     assert_eq!(15_u16.add(6u16), 21_u16);
39     assert_eq!(15_u32.add(6u32), 21_u32);
40     assert_eq!(15_u64.add(6u64), 21_u64);
41
42 // floats
43     // num
44     assert_eq!(10_f32.to_i32().unwrap(), 10);
45     assert_eq!(10_f64.to_i32().unwrap(), 10);
46 }