From b530b0b027c47954961bf8f222d773248d2917f1 Mon Sep 17 00:00:00 2001 From: Scott Olson Date: Mon, 7 Mar 2016 08:27:19 -0600 Subject: [PATCH] Write new-value-repr branch tests over old tests. --- test/basic.rs | 233 ++++++++++++++++++++++++--------------------- test/new_values.rs | 197 -------------------------------------- 2 files changed, 127 insertions(+), 303 deletions(-) delete mode 100644 test/new_values.rs diff --git a/test/basic.rs b/test/basic.rs index 70bb9c3bb88..b3da0562fc5 100644 --- a/test/basic.rs +++ b/test/basic.rs @@ -1,51 +1,74 @@ #![feature(custom_attribute)] #![allow(dead_code, unused_attributes)] -#[miri_run(expected = "Int(1)")] +#[miri_run] fn ret() -> i32 { 1 } -#[miri_run(expected = "Int(-1)")] +#[miri_run] fn neg() -> i32 { -1 } -#[miri_run(expected = "Int(3)")] +#[miri_run] fn add() -> i32 { 1 + 2 } -#[miri_run(expected = "Int(3)")] +#[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(expected = "Int(25)")] +#[miri_run] fn arith() -> i32 { 3*3 + 4*4 } -#[miri_run(expected = "Int(0)")] +#[miri_run] +fn boolean() -> bool { + true +} + +#[miri_run] fn if_false() -> i32 { if false { 1 } else { 0 } } -#[miri_run(expected = "Int(1)")] +#[miri_run] fn if_true() -> i32 { if true { 1 } else { 0 } } -#[miri_run(expected = "Int(2)")] -fn call() -> i32 { - fn increment(x: i32) -> i32 { - x + 1 - } +// #[miri_run(expected = "Int(2)")] +// fn call() -> i32 { +// fn increment(x: i32) -> i32 { +// x + 1 +// } - increment(1) -} +// increment(1) +// } // #[miri_run(expected = "Int(3628800)")] // fn factorial_loop() -> i32 { @@ -60,29 +83,29 @@ fn call() -> i32 { // product // } -#[miri_run(expected = "Int(3628800)")] -fn factorial_recursive() -> i32 { - fn fact(n: i32) -> i32 { - if n == 0 { - 1 - } else { - n * fact(n - 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) -} +// fact(10) +// } -#[miri_run(expected = "Int(1)")] -fn match_bool() -> i32 { - let b = true; - match b { - true => 1, - false => 0, - } -} +// #[miri_run] +// fn match_bool() -> i32 { +// let b = true; +// match b { +// true => 1, +// false => 0, +// } +// } -#[miri_run(expected = "Int(20)")] +#[miri_run] fn match_int() -> i32 { let n = 2; match n { @@ -94,83 +117,81 @@ fn match_int() -> i32 { } } -#[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(1)")] +// fn one_line_ref() -> i32 { +// *&1 // } -#[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, - } -} +// #[miri_run(expected = "Int(1)")] +// fn basic_ref() -> i32 { +// let x = &1; +// *x +// } -enum MyOption { - Some { data: T }, - None, -} +// #[miri_run(expected = "Int(3)")] +// fn basic_ref_mut() -> i32 { +// let x = &mut 1; +// *x += 2; +// *x +// } -#[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(3)")] +// // fn basic_ref_mut_var() -> i32 { +// // let mut a = 1; +// // { +// // let x = &mut a; +// // *x += 2; +// // } +// // a +// // } -#[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(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, +// } +// } -#[miri_run(expected = "Int(13)")] -fn match_opt_some() -> i32 { - let x = Some(13); - match x { - Some(data) => data, - None => 42, - } -} +// enum MyOption { +// Some { data: T }, +// None, +// } -/// 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 } -} +// #[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, +// } +// } -fn main() {} +// #[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/new_values.rs b/test/new_values.rs deleted file mode 100644 index b3da0562fc5..00000000000 --- a/test/new_values.rs +++ /dev/null @@ -1,197 +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 } -} - -// #[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 } -// }