From 11d4bf9b954d9fe3cdba1971b56ef7b69e708b24 Mon Sep 17 00:00:00 2001 From: Scott Olson Date: Sat, 12 Mar 2016 21:32:24 -0600 Subject: [PATCH] Split tests into multiple files. --- test/basic.rs | 204 ----------------------------------------------- test/bools.rs | 26 ++++++ test/calls.rs | 30 +++++++ test/ints.rs | 54 +++++++++++++ test/loops.rs | 15 ++++ test/pointers.rs | 30 +++++++ test/products.rs | 24 ++++++ test/sums.rs | 34 ++++++++ test/trivial.rs | 11 +++ 9 files changed, 224 insertions(+), 204 deletions(-) delete mode 100644 test/basic.rs create mode 100755 test/bools.rs create mode 100644 test/calls.rs create mode 100644 test/ints.rs create mode 100644 test/loops.rs create mode 100644 test/pointers.rs create mode 100644 test/products.rs create mode 100644 test/sums.rs create mode 100644 test/trivial.rs diff --git a/test/basic.rs b/test/basic.rs deleted file mode 100644 index 795915a50411..000000000000 --- a/test/basic.rs +++ /dev/null @@ -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 { -// 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 } -// } diff --git a/test/bools.rs b/test/bools.rs new file mode 100755 index 000000000000..afa71d3a7e85 --- /dev/null +++ b/test/bools.rs @@ -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, +// } +// } diff --git a/test/calls.rs b/test/calls.rs new file mode 100644 index 000000000000..548acb49c665 --- /dev/null +++ b/test/calls.rs @@ -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 } +// } diff --git a/test/ints.rs b/test/ints.rs new file mode 100644 index 000000000000..0c89b6e5a833 --- /dev/null +++ b/test/ints.rs @@ -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, +// } +// } diff --git a/test/loops.rs b/test/loops.rs new file mode 100644 index 000000000000..3a5a66e40ac4 --- /dev/null +++ b/test/loops.rs @@ -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 +// } diff --git a/test/pointers.rs b/test/pointers.rs new file mode 100644 index 000000000000..af825a1f2efa --- /dev/null +++ b/test/pointers.rs @@ -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 +// } diff --git a/test/products.rs b/test/products.rs new file mode 100644 index 000000000000..287b64339aef --- /dev/null +++ b/test/products.rs @@ -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 } +} diff --git a/test/sums.rs b/test/sums.rs new file mode 100644 index 000000000000..4f0b9a8eb7c2 --- /dev/null +++ b/test/sums.rs @@ -0,0 +1,34 @@ +#![feature(custom_attribute)] +#![allow(dead_code, unused_attributes)] + +// enum MyOption { +// 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, +// } +// } diff --git a/test/trivial.rs b/test/trivial.rs new file mode 100644 index 000000000000..99a1ef06186a --- /dev/null +++ b/test/trivial.rs @@ -0,0 +1,11 @@ +#![feature(custom_attribute)] +#![allow(dead_code, unused_attributes)] + +#[miri_run] +fn empty() {} + +#[miri_run] +fn unit_var() { + let x = (); + x +}