Bring over a few more tests

This commit is contained in:
Greg Shuflin 2021-10-25 15:01:03 -07:00
parent d6fcc65392
commit b00df64f55
2 changed files with 24 additions and 29 deletions

View File

@ -186,33 +186,4 @@ let z = if c {
test_in_fresh_env!(source, r#"("x", "haha", "NIGH")"#); test_in_fresh_env!(source, r#"("x", "haha", "NIGH")"#);
} }
#[test]
fn basic_lambda_syntax() {
let source = r#"
let q = \(x, y) { x * y }
let x = q(5,2)
let y = \(m, n, o) { m + n + o }(1,2,3)
(x, y)
"#;
test_in_fresh_env!(source, r"(10, 6)");
}
#[test]
fn lambda_syntax_2() {
let source = r#"
fn milta() {
\(x) { x + 33 }
}
milta()(10)
"#;
test_in_fresh_env!(source, "43");
}
#[test]
fn import_all() {
let source = r#"
type Option<T> = Some(T) | None
import Option::*
let x = Some(9); if x is Some(q) then { q } else { 0 }"#;
test_in_fresh_env!(source, "9");
}

View File

@ -62,6 +62,21 @@ fn scopes() {
eval_assert(scope_ok, "20"); eval_assert(scope_ok, "20");
} }
#[test]
fn if_is_patterns() {
let source = r#"
type Option<T> = Some(T) | None
let x = Option::Some(9); if x is Option::Some(q) then { q } else { 0 }"#;
eval_assert(source, "9");
let source = r#"
type Option<T> = Some(T) | None
let x = Option::None; if x is Option::Some(q) then { q } else { 0 }"#;
eval_assert(source, "0");
}
#[test] #[test]
fn basic_lambda_evaluation_1() { fn basic_lambda_evaluation_1() {
@ -86,3 +101,12 @@ milta()(10)
eval_assert(source, "43"); eval_assert(source, "43");
} }
#[test]
fn import_all() {
let source = r#"
type Option<T> = Some(T) | None
import Option::*
let x = Some(9); if x is Some(q) then { q } else { 0 }"#;
//eval_assert(source, "9");
}