From 4aeb6806425530138558bbc71a4c4520a94d6fe8 Mon Sep 17 00:00:00 2001 From: Melvic Ybanez Date: Thu, 26 Oct 2023 23:06:23 +0800 Subject: [PATCH] Add test case to check that lhs isn't undefined --- src/test/scala/com/melvic/dry/tests/ParserSpec.scala | 2 +- tests/test_assignment.dry | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/test/scala/com/melvic/dry/tests/ParserSpec.scala b/src/test/scala/com/melvic/dry/tests/ParserSpec.scala index 4436991..14994a5 100644 --- a/src/test/scala/com/melvic/dry/tests/ParserSpec.scala +++ b/src/test/scala/com/melvic/dry/tests/ParserSpec.scala @@ -11,7 +11,7 @@ import org.scalatest.matchers.should import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks /** - * Houses the test cases for the parsing phase that are difficult to implement using Dry's tests (because the + * Houses the test cases for the parsing phase that are difficult to implement in Dry (because the * parser would fail in the first place). * * Note: many of the test cases here are based on the lox test suite: diff --git a/tests/test_assignment.dry b/tests/test_assignment.dry index 093bed5..e5f6575 100644 --- a/tests/test_assignment.dry +++ b/tests/test_assignment.dry @@ -13,11 +13,19 @@ def test_associativity() { def test_rhs() { let a = "before"; let c = a = "after"; + assert_equal("a = 'after'", a, "after"); assert_equal("c = 'after'", c, "after"); } +def test_lhs() { + assert_error("rhs should not be an undefined variable", Errors.UNDEFINED_VARIABLE, + lambda() { unknown = "what"; }); +} + test_associativity(); +test_rhs(); +test_lhs(); // global let a = "before";