diff --git a/schala-lang/language/src/eval/test.rs b/schala-lang/language/src/eval/test.rs index e13cde8..c43f73a 100644 --- a/schala-lang/language/src/eval/test.rs +++ b/schala-lang/language/src/eval/test.rs @@ -28,91 +28,6 @@ macro_rules! test_in_fresh_env { } -#[test] -fn string_pattern() { - let source = r#" -let a = "foo" -if a { is "foo" then "x", is _ then "y" } -"#; -test_in_fresh_env!(source, "\"x\""); -} - -#[test] -fn boolean_pattern() { - let source = r#" -let a = true -if a { - is true then "x", - is false then "y" -} -"#; -test_in_fresh_env!(source, "\"x\""); -} - -#[test] -fn boolean_pattern_2() { - let source = r#" -let a = false -if a { is true then "x", is false then "y" } -"#; -test_in_fresh_env!(source, "\"y\""); -} - -#[test] -fn ignore_pattern() { - let source = r#" -type Option = Some(T) | None -if Option::Some(10) { - is _ then "hella" -} -"#; -test_in_fresh_env!(source, "\"hella\""); -} - -#[test] -fn tuple_pattern() { - let source = r#" -if (1, 2) { - is (1, x) then x, - is _ then 99 -} -"#; -test_in_fresh_env!(source, 2); -} - - -#[test] -fn tuple_pattern_2() { - let source = r#" -if (1, 2) { - is (10, x) then x, - is (y, x) then x + y -} -"#; -test_in_fresh_env!(source, 3); -} - -#[test] -fn tuple_pattern_3() { - let source = r#" -if (1, 5) { - is (10, x) then x, - is (1, x) then x -} -"#; -test_in_fresh_env!(source, 5); -} - -#[test] -fn tuple_pattern_4() { - let source = r#" -if (1, 5) { - is (10, x) then x, - is (1, x) then x, -} -"#; -test_in_fresh_env!(source, 5); -} #[test] fn prim_obj_pattern() { diff --git a/schala-lang/language/src/tree_walk_eval/test.rs b/schala-lang/language/src/tree_walk_eval/test.rs index 56c5974..a71cc60 100644 --- a/schala-lang/language/src/tree_walk_eval/test.rs +++ b/schala-lang/language/src/tree_walk_eval/test.rs @@ -177,6 +177,92 @@ if a { is 15 then "x", is 10 then "y" } eval_assert(source, "\"y\""); } +//TODO - I can probably cut down some of these +#[test] +fn string_pattern() { + let source = r#" +let a = "foo" +if a { is "foo" then "x", is _ then "y" } + "#; + eval_assert(source, "\"x\""); +} + +#[test] +fn boolean_pattern() { + let source = r#" +let a = true +if a { + is true then "x", + is false then "y" +} +"#; + eval_assert(source, "\"x\""); +} + +#[test] +fn boolean_pattern_2() { + let source = r#" +let a = false +if a { is true then "x", is false then "y" } +"#; + eval_assert(source, "\"y\""); +} + +#[test] +fn ignore_pattern() { + let source = r#" +type Option = Some(T) | None +if Option::Some(10) { + is _ then "hella" +} +"#; + eval_assert(source, "\"hella\""); +} + +#[test] +fn tuple_pattern() { + let source = r#" +if (1, 2) { + is (1, x) then x, + is _ then 99 +} +"#; + eval_assert(source, "2"); +} + + +#[test] +fn tuple_pattern_2() { + let source = r#" +if (1, 2) { + is (10, x) then x, + is (y, x) then x + y +} +"#; + eval_assert(source, "3"); +} + +#[test] +fn tuple_pattern_3() { + let source = r#" +if (1, 5) { + is (10, x) then x, + is (1, x) then x +} +"#; + eval_assert(source, "5"); +} + +#[test] +fn tuple_pattern_4() { + let source = r#" +if (1, 5) { + is (10, x) then x, + is (1, x) then x, +} +"#; + eval_assert(source, "5"); +} #[test] fn basic_lambda_evaluation_1() {