Add another tokenizer test.
This commit is contained in:
parent
faca13d393
commit
1be3b17bae
1 changed files with 13 additions and 8 deletions
|
@ -20,8 +20,8 @@ namespace Tests
|
||||||
|
|
||||||
public class Test {
|
public class Test {
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void StringTokenStreamTest() {
|
public static void TestTokenizer() {
|
||||||
StringTokenStream sts = StringTokenStream.generate("(\"some literal string\" def ghj +100 -+300 1)");
|
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, "\"");
|
Assert.Equal(sts.get().value, "\"");
|
||||||
Assert.Equal(sts.get().value, "some");
|
Assert.Equal(sts.get().value, "some");
|
||||||
|
@ -43,13 +43,17 @@ namespace Tests
|
||||||
Assert.Equal(sts.get().value, "300");
|
Assert.Equal(sts.get().value, "300");
|
||||||
Assert.Equal(sts.get().value, " ");
|
Assert.Equal(sts.get().value, " ");
|
||||||
Assert.Equal(sts.get().value, "1");
|
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, ")");
|
Assert.Equal(sts.get().value, ")");
|
||||||
sts.commit();
|
sts.commit();
|
||||||
Assert.Equal(sts.available(), 0);
|
Assert.Equal(sts.available(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void ParserTest() {
|
public static void TestParser() {
|
||||||
string program = "(+ 1 (* 2 3))";
|
string program = "(+ 1 (* 2 3))";
|
||||||
StringTokenStream sts = StringTokenStream.generate(program);
|
StringTokenStream sts = StringTokenStream.generate(program);
|
||||||
Parser p = new Parser(sts);
|
Parser p = new Parser(sts);
|
||||||
|
@ -62,9 +66,10 @@ namespace Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public static void EvaluateTest() {
|
public static void TestFunctions() {
|
||||||
Expression e = new Executor().eval("(+ 5 (+ 1 2 3))");
|
IList<Tuple<string, Expression>> cases = new List<Tuple<string, Expression>>();
|
||||||
Assert.Equal(((Integer) e).value, 11);
|
Expression e = new Executor().eval("(+ 10 20)");
|
||||||
|
Assert.Equal(((Integer) e).value, 30);
|
||||||
|
|
||||||
e = new Executor().eval("(> 1 2)");
|
e = new Executor().eval("(> 1 2)");
|
||||||
Assert.Equal(((Lisp_Boolean) e).value, false);
|
Assert.Equal(((Lisp_Boolean) e).value, false);
|
||||||
|
|
Loading…
Reference in a new issue