rust/test/calls.rs

41 lines
747 B
Rust
Raw Normal View History

2016-03-12 21:32:24 -06:00
#![feature(custom_attribute)]
#![allow(dead_code, unused_attributes)]
#[miri_run]
fn call() -> i32 {
fn increment(x: i32) -> i32 {
x + 1
}
increment(1)
}
2016-03-12 21:32:24 -06:00
#[miri_run]
fn factorial_recursive() -> i64 {
fn fact(n: i64) -> i64 {
if n == 0 {
1
} else {
n * fact(n - 1)
}
}
fact(10)
}
2016-03-12 21:32:24 -06:00
2016-03-13 19:33:26 -05:00
#[miri_run]
fn call_generic() -> (i16, bool) {
fn id<T>(t: T) -> T { t }
(id(42), id(true))
}
2016-03-12 21:32:24 -06:00
// Test calling a very simple function from the standard library.
#[miri_run]
fn cross_crate_fn_call() -> i64 {
if 1i32.is_positive() { 1 } else { 0 }
}
2016-03-15 01:45:25 -05:00
// Test one of the simplest intrinsics.
#[miri_run]
fn test_size_of() -> usize {
::std::mem::size_of::<Option<i32>>()
}