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)); }
public void ConverterToBinaryCorrect(string s) { Assert.AreEqual(Expr.ParseExpr(s).GetUnified().ToSExpr(), Expr.ParseExpr(s).GetUnified().ToBinExp().ToArray().ToSExpr().Item1); }
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()); }
public void ParseCorrect(string s) { Assert.AreEqual(s, Expr.ParseExpr(s).ToSExpr()); }
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))")); }