From 47ff6b3cb517590fa162ef8260cdb363ceecbfac Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Tue, 26 Oct 2021 13:06:11 -0700 Subject: [PATCH] Move over last test --- schala-lang/language/src/eval/test.rs | 31 ------------------ .../language/src/tree_walk_eval/test.rs | 32 +++++++++++++++++++ 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/schala-lang/language/src/eval/test.rs b/schala-lang/language/src/eval/test.rs index c43f73a..d2b667e 100644 --- a/schala-lang/language/src/eval/test.rs +++ b/schala-lang/language/src/eval/test.rs @@ -29,35 +29,4 @@ macro_rules! test_in_fresh_env { -#[test] -fn prim_obj_pattern() { - let source = r#" -type Stuff = Mulch(Nat) | Jugs(Nat, String) | Mardok -let a = Stuff::Mulch(20) -let b = Stuff::Jugs(1, "haha") -let c = Stuff::Mardok - -let x = if a { - is Stuff::Mulch(20) then "x", - is _ then "ERR" -} - -let y = if b { - is Stuff::Mulch(n) then "ERR", - is Stuff::Jugs(2, _) then "ERR", - is Stuff::Jugs(1, s) then s, - is _ then "ERR", -} - -let z = if c { - is Stuff::Jugs(_, _) then "ERR", - is Stuff::Mardok then "NIGH", - is _ then "ERR", -} - -(x, y, z) -"#; -test_in_fresh_env!(source, r#"("x", "haha", "NIGH")"#); -} - diff --git a/schala-lang/language/src/tree_walk_eval/test.rs b/schala-lang/language/src/tree_walk_eval/test.rs index a71cc60..3a434b6 100644 --- a/schala-lang/language/src/tree_walk_eval/test.rs +++ b/schala-lang/language/src/tree_walk_eval/test.rs @@ -264,6 +264,38 @@ if (1, 5) { eval_assert(source, "5"); } + +#[test] +fn prim_obj_pattern() { + let source = r#" +type Stuff = Mulch(Nat) | Jugs(Nat, String) | Mardok +let a = Stuff::Mulch(20) +let b = Stuff::Jugs(1, "haha") +let c = Stuff::Mardok + +let x = if a { + is Stuff::Mulch(20) then "x", + is _ then "ERR" +} + +let y = if b { + is Stuff::Mulch(n) then "ERR", + is Stuff::Jugs(2, _) then "ERR", + is Stuff::Jugs(1, s) then s, + is _ then "ERR", +} + +let z = if c { + is Stuff::Jugs(_, _) then "ERR", + is Stuff::Mardok then "NIGH", + is _ then "ERR", +} + +(x, y, z) +"#; + eval_assert(source, r#"("x", "haha", "NIGH")"#); +} + #[test] fn basic_lambda_evaluation_1() { let source = r#"