Rename test helper
This commit is contained in:
parent
50d5176b45
commit
d57a8045a9
@ -442,7 +442,7 @@ mod eval_tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! fresh_env {
|
macro_rules! test_in_fresh_env {
|
||||||
($string:expr, $correct:expr) => {
|
($string:expr, $correct:expr) => {
|
||||||
{
|
{
|
||||||
let all_output = all_output!($string);
|
let all_output = all_output!($string);
|
||||||
@ -454,16 +454,16 @@ mod eval_tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_basic_eval() {
|
fn test_basic_eval() {
|
||||||
fresh_env!("1 + 2", "3");
|
test_in_fresh_env!("1 + 2", "3");
|
||||||
fresh_env!("let mut a = 1; a = 2", "Unit");
|
test_in_fresh_env!("let mut a = 1; a = 2", "Unit");
|
||||||
fresh_env!("let mut a = 1; a = 2; a", "2");
|
test_in_fresh_env!("let mut a = 1; a = 2; a", "2");
|
||||||
fresh_env!(r#"("a", 1 + 2)"#, r#"("a", 3)"#);
|
test_in_fresh_env!(r#"("a", 1 + 2)"#, r#"("a", 3)"#);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_eval() {
|
fn function_eval() {
|
||||||
fresh_env!("fn oi(x) { x + 1 }; oi(4)", "5");
|
test_in_fresh_env!("fn oi(x) { x + 1 }; oi(4)", "5");
|
||||||
fresh_env!("fn oi(x) { x + 1 }; oi(1+2)", "4");
|
test_in_fresh_env!("fn oi(x) { x + 1 }; oi(1+2)", "4");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -476,7 +476,7 @@ mod eval_tests {
|
|||||||
}
|
}
|
||||||
haha()
|
haha()
|
||||||
"#;
|
"#;
|
||||||
fresh_env!(scope_ok, "10");
|
test_in_fresh_env!(scope_ok, "10");
|
||||||
let scope_ok = r#"
|
let scope_ok = r#"
|
||||||
let a = 20
|
let a = 20
|
||||||
fn haha() {
|
fn haha() {
|
||||||
@ -485,7 +485,7 @@ mod eval_tests {
|
|||||||
}
|
}
|
||||||
a
|
a
|
||||||
"#;
|
"#;
|
||||||
fresh_env!(scope_ok, "20");
|
test_in_fresh_env!(scope_ok, "20");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -493,12 +493,12 @@ mod eval_tests {
|
|||||||
let source = r#"
|
let source = r#"
|
||||||
type Option<T> = Some(T) | None
|
type Option<T> = Some(T) | None
|
||||||
let x = Some(9); if x is Some(q) then { q } else { 0 }"#;
|
let x = Some(9); if x is Some(q) then { q } else { 0 }"#;
|
||||||
fresh_env!(source, "9");
|
test_in_fresh_env!(source, "9");
|
||||||
|
|
||||||
let source = r#"
|
let source = r#"
|
||||||
type Option<T> = Some(T) | None
|
type Option<T> = Some(T) | None
|
||||||
let x = None; if x is Some(q) then { q } else { 0 }"#;
|
let x = None; if x is Some(q) then { q } else { 0 }"#;
|
||||||
fresh_env!(source, "0");
|
test_in_fresh_env!(source, "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -508,25 +508,25 @@ type Option<T> = Some(T) | None
|
|||||||
let a = None
|
let a = None
|
||||||
if a { is None -> 4, is Some(x) -> x }
|
if a { is None -> 4, is Some(x) -> x }
|
||||||
"#;
|
"#;
|
||||||
fresh_env!(source, "4");
|
test_in_fresh_env!(source, "4");
|
||||||
|
|
||||||
let source = r#"
|
let source = r#"
|
||||||
type Option<T> = Some(T) | None
|
type Option<T> = Some(T) | None
|
||||||
let a = Some(99)
|
let a = Some(99)
|
||||||
if a { is None -> 4, is Some(x) -> x }
|
if a { is None -> 4, is Some(x) -> x }
|
||||||
"#;
|
"#;
|
||||||
fresh_env!(source, "99");
|
test_in_fresh_env!(source, "99");
|
||||||
|
|
||||||
let source = r#"
|
let source = r#"
|
||||||
let a = 10
|
let a = 10
|
||||||
if a { is 10 -> "x", is 4 -> "y" }
|
if a { is 10 -> "x", is 4 -> "y" }
|
||||||
"#;
|
"#;
|
||||||
fresh_env!(source, "\"x\"");
|
test_in_fresh_env!(source, "\"x\"");
|
||||||
|
|
||||||
let source = r#"
|
let source = r#"
|
||||||
let a = 10
|
let a = 10
|
||||||
if a { is 15 -> "x", is 10 -> "y" }
|
if a { is 15 -> "x", is 10 -> "y" }
|
||||||
"#;
|
"#;
|
||||||
fresh_env!(source, "\"y\"");
|
test_in_fresh_env!(source, "\"y\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user