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 {
|
||||
[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,13 +43,17 @@ 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() {
|
||||
public static void TestParser() {
|
||||
string program = "(+ 1 (* 2 3))";
|
||||
StringTokenStream sts = StringTokenStream.generate(program);
|
||||
Parser p = new Parser(sts);
|
||||
|
@ -62,9 +66,10 @@ namespace Tests
|
|||
}
|
||||
|
||||
[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<Tuple<string, Expression>> cases = new List<Tuple<string, Expression>>();
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue