Split tests into multiple files.
This commit is contained in:
parent
346618cd2b
commit
11d4bf9b95
9 changed files with 224 additions and 204 deletions
204
test/basic.rs
204
test/basic.rs
|
@ -1,204 +0,0 @@
|
||||||
#![feature(custom_attribute)]
|
|
||||||
#![allow(dead_code, unused_attributes)]
|
|
||||||
|
|
||||||
#[miri_run]
|
|
||||||
fn ret() -> i32 {
|
|
||||||
1
|
|
||||||
}
|
|
||||||
|
|
||||||
#[miri_run]
|
|
||||||
fn neg() -> i32 {
|
|
||||||
-1
|
|
||||||
}
|
|
||||||
|
|
||||||
#[miri_run]
|
|
||||||
fn add() -> i32 {
|
|
||||||
1 + 2
|
|
||||||
}
|
|
||||||
|
|
||||||
#[miri_run]
|
|
||||||
fn empty() {}
|
|
||||||
|
|
||||||
#[miri_run]
|
|
||||||
fn tuple() -> (i32,) {
|
|
||||||
(1,)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[miri_run]
|
|
||||||
fn tuple_2() -> (i32, i32) {
|
|
||||||
(1, 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[miri_run]
|
|
||||||
fn tuple_5() -> (i32, i32, i32, i32, i32) {
|
|
||||||
(1, 2, 3, 4, 5)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[miri_run]
|
|
||||||
fn indirect_add() -> i32 {
|
|
||||||
let x = 1;
|
|
||||||
let y = 2;
|
|
||||||
x + y
|
|
||||||
}
|
|
||||||
|
|
||||||
#[miri_run]
|
|
||||||
fn arith() -> i32 {
|
|
||||||
3*3 + 4*4
|
|
||||||
}
|
|
||||||
|
|
||||||
#[miri_run]
|
|
||||||
fn boolean() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
#[miri_run]
|
|
||||||
fn if_false() -> i32 {
|
|
||||||
if false { 1 } else { 0 }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[miri_run]
|
|
||||||
fn if_true() -> i32 {
|
|
||||||
if true { 1 } else { 0 }
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Pair { x: i64, y: i64 }
|
|
||||||
|
|
||||||
#[miri_run]
|
|
||||||
fn pair() -> Pair {
|
|
||||||
Pair { x: 10, y: 20 }
|
|
||||||
}
|
|
||||||
|
|
||||||
// #[miri_run(expected = "Int(2)")]
|
|
||||||
// fn call() -> i32 {
|
|
||||||
// fn increment(x: i32) -> i32 {
|
|
||||||
// x + 1
|
|
||||||
// }
|
|
||||||
|
|
||||||
// increment(1)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[miri_run(expected = "Int(3628800)")]
|
|
||||||
// fn factorial_loop() -> i32 {
|
|
||||||
// let mut product = 1;
|
|
||||||
// let mut i = 1;
|
|
||||||
|
|
||||||
// while i <= 10 {
|
|
||||||
// product *= i;
|
|
||||||
// i += 1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// product
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[miri_run(expected = "Int(3628800)")]
|
|
||||||
// fn factorial_recursive() -> i32 {
|
|
||||||
// fn fact(n: i32) -> i32 {
|
|
||||||
// if n == 0 {
|
|
||||||
// 1
|
|
||||||
// } else {
|
|
||||||
// n * fact(n - 1)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fact(10)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[miri_run]
|
|
||||||
// fn match_bool() -> i32 {
|
|
||||||
// let b = true;
|
|
||||||
// match b {
|
|
||||||
// true => 1,
|
|
||||||
// false => 0,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
#[miri_run]
|
|
||||||
fn match_int() -> i32 {
|
|
||||||
let n = 2;
|
|
||||||
match n {
|
|
||||||
0 => 0,
|
|
||||||
1 => 10,
|
|
||||||
2 => 20,
|
|
||||||
3 => 30,
|
|
||||||
_ => 100,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// #[miri_run(expected = "Int(1)")]
|
|
||||||
// fn one_line_ref() -> i32 {
|
|
||||||
// *&1
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[miri_run(expected = "Int(1)")]
|
|
||||||
// fn basic_ref() -> i32 {
|
|
||||||
// let x = &1;
|
|
||||||
// *x
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[miri_run(expected = "Int(3)")]
|
|
||||||
// fn basic_ref_mut() -> i32 {
|
|
||||||
// let x = &mut 1;
|
|
||||||
// *x += 2;
|
|
||||||
// *x
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // #[miri_run(expected = "Int(3)")]
|
|
||||||
// // fn basic_ref_mut_var() -> i32 {
|
|
||||||
// // let mut a = 1;
|
|
||||||
// // {
|
|
||||||
// // let x = &mut a;
|
|
||||||
// // *x += 2;
|
|
||||||
// // }
|
|
||||||
// // a
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// #[miri_run(expected = "Int(4)")]
|
|
||||||
// fn match_int_range() -> i32 {
|
|
||||||
// let n = 42;
|
|
||||||
// match n {
|
|
||||||
// 0...9 => 0,
|
|
||||||
// 10...19 => 1,
|
|
||||||
// 20...29 => 2,
|
|
||||||
// 30...39 => 3,
|
|
||||||
// 40...49 => 4,
|
|
||||||
// _ => 5,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// enum MyOption<T> {
|
|
||||||
// Some { data: T },
|
|
||||||
// None,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[miri_run(expected = "Int(13)")]
|
|
||||||
// fn match_my_opt_some() -> i32 {
|
|
||||||
// let x = MyOption::Some { data: 13 };
|
|
||||||
// match x {
|
|
||||||
// MyOption::Some { data } => data,
|
|
||||||
// MyOption::None => 42,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[miri_run(expected = "Int(42)")]
|
|
||||||
// fn match_my_opt_none() -> i32 {
|
|
||||||
// let x = MyOption::None;
|
|
||||||
// match x {
|
|
||||||
// MyOption::Some { data } => data,
|
|
||||||
// MyOption::None => 42,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[miri_run(expected = "Int(13)")]
|
|
||||||
// fn match_opt_some() -> i32 {
|
|
||||||
// let x = Some(13);
|
|
||||||
// match x {
|
|
||||||
// Some(data) => data,
|
|
||||||
// None => 42,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /// Test calling a very simple function from the standard library.
|
|
||||||
// #[miri_run(expected = "Int(1)")]
|
|
||||||
// fn cross_crate_fn_call() -> i32 {
|
|
||||||
// if 1i32.is_positive() { 1 } else { 0 }
|
|
||||||
// }
|
|
26
test/bools.rs
Executable file
26
test/bools.rs
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#![feature(custom_attribute)]
|
||||||
|
#![allow(dead_code, unused_attributes)]
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn boolean() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn if_false() -> i32 {
|
||||||
|
if false { 1 } else { 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn if_true() -> i32 {
|
||||||
|
if true { 1 } else { 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
// #[miri_run]
|
||||||
|
// fn match_bool() -> i32 {
|
||||||
|
// let b = true;
|
||||||
|
// match b {
|
||||||
|
// true => 1,
|
||||||
|
// false => 0,
|
||||||
|
// }
|
||||||
|
// }
|
30
test/calls.rs
Normal file
30
test/calls.rs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#![feature(custom_attribute)]
|
||||||
|
#![allow(dead_code, unused_attributes)]
|
||||||
|
|
||||||
|
// #[miri_run(expected = "Int(2)")]
|
||||||
|
// fn call() -> i32 {
|
||||||
|
// fn increment(x: i32) -> i32 {
|
||||||
|
// x + 1
|
||||||
|
// }
|
||||||
|
|
||||||
|
// increment(1)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[miri_run(expected = "Int(3628800)")]
|
||||||
|
// fn factorial_recursive() -> i32 {
|
||||||
|
// fn fact(n: i32) -> i32 {
|
||||||
|
// if n == 0 {
|
||||||
|
// 1
|
||||||
|
// } else {
|
||||||
|
// n * fact(n - 1)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// fact(10)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Test calling a very simple function from the standard library.
|
||||||
|
// #[miri_run(expected = "Int(1)")]
|
||||||
|
// fn cross_crate_fn_call() -> i32 {
|
||||||
|
// if 1i32.is_positive() { 1 } else { 0 }
|
||||||
|
// }
|
54
test/ints.rs
Normal file
54
test/ints.rs
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#![feature(custom_attribute)]
|
||||||
|
#![allow(dead_code, unused_attributes)]
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn ret() -> i32 {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn neg() -> i32 {
|
||||||
|
-1
|
||||||
|
}
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn add() -> i32 {
|
||||||
|
1 + 2
|
||||||
|
}
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn indirect_add() -> i32 {
|
||||||
|
let x = 1;
|
||||||
|
let y = 2;
|
||||||
|
x + y
|
||||||
|
}
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn arith() -> i32 {
|
||||||
|
3*3 + 4*4
|
||||||
|
}
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn match_int() -> i32 {
|
||||||
|
let n = 2;
|
||||||
|
match n {
|
||||||
|
0 => 0,
|
||||||
|
1 => 10,
|
||||||
|
2 => 20,
|
||||||
|
3 => 30,
|
||||||
|
_ => 100,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// #[miri_run(expected = "Int(4)")]
|
||||||
|
// fn match_int_range() -> i32 {
|
||||||
|
// let n = 42;
|
||||||
|
// match n {
|
||||||
|
// 0...9 => 0,
|
||||||
|
// 10...19 => 1,
|
||||||
|
// 20...29 => 2,
|
||||||
|
// 30...39 => 3,
|
||||||
|
// 40...49 => 4,
|
||||||
|
// _ => 5,
|
||||||
|
// }
|
||||||
|
// }
|
15
test/loops.rs
Normal file
15
test/loops.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#![feature(custom_attribute)]
|
||||||
|
#![allow(dead_code, unused_attributes)]
|
||||||
|
|
||||||
|
// #[miri_run(expected = "Int(3628800)")]
|
||||||
|
// fn factorial_loop() -> i32 {
|
||||||
|
// let mut product = 1;
|
||||||
|
// let mut i = 1;
|
||||||
|
|
||||||
|
// while i <= 10 {
|
||||||
|
// product *= i;
|
||||||
|
// i += 1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// product
|
||||||
|
// }
|
30
test/pointers.rs
Normal file
30
test/pointers.rs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#![feature(custom_attribute)]
|
||||||
|
#![allow(dead_code, unused_attributes)]
|
||||||
|
|
||||||
|
// #[miri_run(expected = "Int(1)")]
|
||||||
|
// fn one_line_ref() -> i32 {
|
||||||
|
// *&1
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[miri_run(expected = "Int(1)")]
|
||||||
|
// fn basic_ref() -> i32 {
|
||||||
|
// let x = &1;
|
||||||
|
// *x
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[miri_run(expected = "Int(3)")]
|
||||||
|
// fn basic_ref_mut() -> i32 {
|
||||||
|
// let x = &mut 1;
|
||||||
|
// *x += 2;
|
||||||
|
// *x
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[miri_run(expected = "Int(3)")]
|
||||||
|
// fn basic_ref_mut_var() -> i32 {
|
||||||
|
// let mut a = 1;
|
||||||
|
// {
|
||||||
|
// let x = &mut a;
|
||||||
|
// *x += 2;
|
||||||
|
// }
|
||||||
|
// a
|
||||||
|
// }
|
24
test/products.rs
Normal file
24
test/products.rs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#![feature(custom_attribute)]
|
||||||
|
#![allow(dead_code, unused_attributes)]
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn tuple() -> (i32,) {
|
||||||
|
(1,)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn tuple_2() -> (i32, i32) {
|
||||||
|
(1, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn tuple_5() -> (i32, i32, i32, i32, i32) {
|
||||||
|
(1, 2, 3, 4, 5)
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Pair { x: i64, y: i64 }
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn pair() -> Pair {
|
||||||
|
Pair { x: 10, y: 20 }
|
||||||
|
}
|
34
test/sums.rs
Normal file
34
test/sums.rs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#![feature(custom_attribute)]
|
||||||
|
#![allow(dead_code, unused_attributes)]
|
||||||
|
|
||||||
|
// enum MyOption<T> {
|
||||||
|
// Some { data: T },
|
||||||
|
// None,
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[miri_run(expected = "Int(13)")]
|
||||||
|
// fn match_my_opt_some() -> i32 {
|
||||||
|
// let x = MyOption::Some { data: 13 };
|
||||||
|
// match x {
|
||||||
|
// MyOption::Some { data } => data,
|
||||||
|
// MyOption::None => 42,
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[miri_run(expected = "Int(42)")]
|
||||||
|
// fn match_my_opt_none() -> i32 {
|
||||||
|
// let x = MyOption::None;
|
||||||
|
// match x {
|
||||||
|
// MyOption::Some { data } => data,
|
||||||
|
// MyOption::None => 42,
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #[miri_run(expected = "Int(13)")]
|
||||||
|
// fn match_opt_some() -> i32 {
|
||||||
|
// let x = Some(13);
|
||||||
|
// match x {
|
||||||
|
// Some(data) => data,
|
||||||
|
// None => 42,
|
||||||
|
// }
|
||||||
|
// }
|
11
test/trivial.rs
Normal file
11
test/trivial.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#![feature(custom_attribute)]
|
||||||
|
#![allow(dead_code, unused_attributes)]
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn empty() {}
|
||||||
|
|
||||||
|
#[miri_run]
|
||||||
|
fn unit_var() {
|
||||||
|
let x = ();
|
||||||
|
x
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue