From 8ceaa734d24b022f6267a8993bf5387fc5f5a49c Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Mon, 25 Oct 2021 02:46:10 -0700 Subject: [PATCH] Add back another test revealing a scope error --- TODO.md | 2 ++ .../language/src/tree_walk_eval/test.rs | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/TODO.md b/TODO.md index c45ff05..565629f 100644 --- a/TODO.md +++ b/TODO.md @@ -2,6 +2,8 @@ ## Symbols +* Add some good printf-debugging impls for SymbolTable-related items + * the symbol table should probably *only* be for global definitions (maybe rename it to reflect this?) * dealing with variable lookup w/in functions/closures should probably happen in AST -> ReducedAST * b/c that's where we go from a string name to a canonical ID (for e.g. 2nd param in 3rd enclosing scope) diff --git a/schala-lang/language/src/tree_walk_eval/test.rs b/schala-lang/language/src/tree_walk_eval/test.rs index a92962d..ff33b94 100644 --- a/schala-lang/language/src/tree_walk_eval/test.rs +++ b/schala-lang/language/src/tree_walk_eval/test.rs @@ -62,3 +62,27 @@ fn scopes() { eval_assert(scope_ok, "20"); } + +#[test] +fn basic_lambda_evaluation_1() { + 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) +"#; + +eval_assert(source, r"(10, 6)"); +} + +#[test] +fn basic_lambda_evaluation_2() { + let source = r#" +fn milta() { + \(x) { x + 33 } +} +milta()(10) + "#; + + eval_assert(source, "43"); + }