]> git.lizzy.rs Git - rust.git/blob - tests/run-pass/calls.rs
0e9199f969df8d62f94f5c118186fbb4f7beba1e
[rust.git] / tests / run-pass / calls.rs
1 #![crate_type = "lib"]
2 #![feature(custom_attribute)]
3 #![allow(dead_code, unused_attributes)]
4
5 #[miri_run]
6 fn call() -> i32 {
7     fn increment(x: i32) -> i32 {
8         x + 1
9     }
10     increment(1)
11 }
12
13 #[miri_run]
14 fn factorial_recursive() -> i64 {
15     fn fact(n: i64) -> i64 {
16         if n == 0 {
17             1
18         } else {
19             n * fact(n - 1)
20         }
21     }
22     fact(10)
23 }
24
25 #[miri_run]
26 fn call_generic() -> (i16, bool) {
27     fn id<T>(t: T) -> T { t }
28     (id(42), id(true))
29 }
30
31 // Test calling a very simple function from the standard library.
32 #[miri_run]
33 fn cross_crate_fn_call() -> i64 {
34     if 1i32.is_positive() { 1 } else { 0 }
35 }
36
37 // Test one of the simplest intrinsics.
38 #[miri_run]
39 fn test_size_of() -> usize {
40     ::std::mem::size_of::<Option<i32>>()
41 }