rust/test/ints.rs

55 lines
687 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 ret() -> i64 {
2016-03-12 21:32:24 -06:00
1
}
#[miri_run]
fn neg() -> i64 {
2016-03-12 21:32:24 -06:00
-1
}
#[miri_run]
fn add() -> i64 {
2016-03-12 21:32:24 -06:00
1 + 2
}
#[miri_run]
fn indirect_add() -> i64 {
2016-03-12 21:32:24 -06:00
let x = 1;
let y = 2;
x + y
}
#[miri_run]
2016-03-13 05:50:16 -05:00
fn arith() -> i32 {
2016-03-12 21:32:24 -06:00
3*3 + 4*4
}
#[miri_run]
2016-03-13 05:50:16 -05:00
fn match_int() -> i16 {
let n = 2;
2016-03-12 21:32:24 -06:00
match n {
0 => 0,
1 => 10,
2 => 20,
3 => 30,
_ => 100,
}
}
2016-03-13 09:32:30 -05:00
#[miri_run]
fn match_int_range() -> i64 {
let n = 42;
match n {
0...9 => 0,
10...19 => 1,
20...29 => 2,
30...39 => 3,
40...49 => 4,
_ => 5,
}
}