예제 #1
0
        public void Eval(TestCase t)
        {
            var actual = Expr.Eval(t.Program, t.Arg);

            Assert.That(actual, Is.EqualTo(t.ExpectedValue), string.Format("Was: 0x{0:x}", actual));
        }
예제 #2
0
 public void ConverterToBinaryCorrect(string s)
 {
     Assert.AreEqual(Expr.ParseExpr(s).GetUnified().ToSExpr(), Expr.ParseExpr(s).GetUnified().ToBinExp().ToArray().ToSExpr().Item1);
 }
예제 #3
0
 public void Parse()
 {
     Assert.AreEqual("0", Expr.ParseExpr("0").ToSExpr());
     Assert.AreEqual("(shl1 1)", Expr.ParseExpr(" ( shl1      1) ").ToSExpr());
     Assert.AreEqual("(fold 0 0 (lambda (x i) (shl1 x)))", Expr.ParseExpr("(fold 0 0 (lambda (x   i )  ( shl1  x ) ))").ToSExpr());
 }
예제 #4
0
 public void ParseCorrect(string s)
 {
     Assert.AreEqual(s, Expr.ParseExpr(s).ToSExpr());
 }
예제 #5
0
 public void Tokenize()
 {
     CollectionAssert.AreEqual(new[] { "(", "x", ")" }, Expr.Tokenize("(x)"));
     CollectionAssert.AreEqual(new[] { "x" }, Expr.Tokenize("x"));
     CollectionAssert.AreEqual(new[] { "(", ")" }, Expr.Tokenize("()"));
     CollectionAssert.AreEqual(new[] { "(", ")" }, Expr.Tokenize("( )"));
     CollectionAssert.AreEqual(new[] { "(", ")" }, Expr.Tokenize("(\t\r\n)"));
     CollectionAssert.AreEqual(new[] { "(", "x", ")" }, Expr.Tokenize("(\t\r\n x)"));
     CollectionAssert.AreEqual(new[] { "(", "lambda", "(", "x", ")", "(", "shl1", "x", ")", ")" }, Expr.Tokenize("(lambda (x) (shl1 x))"));
 }