From 1be3b17baea2efeb8f92f1156076fee09c0b834d Mon Sep 17 00:00:00 2001 From: redxef Date: Fri, 25 Oct 2024 02:18:38 +0200 Subject: [PATCH] Add another tokenizer test. --- Tests/Tests.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Tests/Tests.cs b/Tests/Tests.cs index e37a975..6c94b12 100644 --- a/Tests/Tests.cs +++ b/Tests/Tests.cs @@ -20,8 +20,8 @@ namespace Tests public class Test { [Fact] - public static void StringTokenStreamTest() { - StringTokenStream sts = StringTokenStream.generate("(\"some literal string\" def ghj +100 -+300 1)"); + public static void TestTokenizer() { + StringTokenStream sts = StringTokenStream.generate("(\"some literal string\" def ghj +100 -+300 1 ++ !=)"); Assert.Equal(sts.get().value, "("); Assert.Equal(sts.get().value, "\""); Assert.Equal(sts.get().value, "some"); @@ -43,28 +43,33 @@ namespace Tests Assert.Equal(sts.get().value, "300"); Assert.Equal(sts.get().value, " "); Assert.Equal(sts.get().value, "1"); + Assert.Equal(sts.get().value, " "); + Assert.Equal(sts.get().value, "++"); + Assert.Equal(sts.get().value, " "); + Assert.Equal(sts.get().value, "!="); Assert.Equal(sts.get().value, ")"); sts.commit(); Assert.Equal(sts.available(), 0); } [Fact] - public static void ParserTest() { - string program = "( + 1 ( * 2 3))"; + public static void TestParser() { + string program = "(+ 1 (* 2 3))"; StringTokenStream sts = StringTokenStream.generate(program); Parser p = new Parser(sts); Assert.Equal(program, string.Format("{0}", p.parse())); - program = "( haskeys o \"i\" \"b\")"; + program = "(haskeys o \"i\" \"b\")"; sts = StringTokenStream.generate(program); p = new Parser(sts); Assert.Equal(program, string.Format("{0}", p.parse())); } [Fact] - public static void EvaluateTest() { - Expression e = new Executor().eval("(+ 5 (+ 1 2 3))"); - Assert.Equal(((Integer) e).value, 11); + public static void TestFunctions() { + IList> cases = new List>(); + Expression e = new Executor().eval("(+ 10 20)"); + Assert.Equal(((Integer) e).value, 30); e = new Executor().eval("(> 1 2)"); Assert.Equal(((Lisp_Boolean) e).value, false);