public void Do_DoNotHoldLastValueBetweenCalls() { using var lisp = new SoltysLispVM(); var result = lisp.Do(@"(+ 10 1)"); Assert.Equal(11, (int)result); var newResult = lisp.Do(@"()"); Assert.Equal("nil", (string)newResult); }
public void TwoDo_DefineFunctionWithConstantValue_ReturnConstantValue() { using var lisp = new SoltysLispVM(); lisp.Initialize(); var result = lisp.Do(@"(def! x 42)"); result = lisp.Do(@"(+ 8 x)"); Assert.IsType <int>(result); var intValue = (int)result; Assert.Equal(50, intValue); }
public void TwoDo_RedefineMethod() { using var lisp = new SoltysLispVM(); lisp.Initialize(); var result = lisp.Do( @"(def! x (* 5 5)) (def! y (* 10 x))"); result = lisp.Do( @"(def! x (* 6 6)) (y)"); Assert.IsType <int>(result); var intValue = (int)result; Assert.Equal(360, intValue); }
public void Do_Println_ResultIsNil() { using var lisp = new SoltysLispVM(); lisp.Initialize(); var result = lisp.Do(@"(println ""Hello, World!"")"); Assert.Equal("nil", result); }
public void Do_MathOnDoubles_ExpectDoubleResult(string input, double expectedResult) { using var lisp = new SoltysLispVM(); lisp.Initialize(); var result = lisp.Do(input); Assert.IsType <double>(result); var doubleValue = (double)result; Assert.Equal(expectedResult, doubleValue, 5); }
public void Do_MathOnIntegers_ExpectIntegerResult(string input, int expectedResult) { using var lisp = new SoltysLispVM(); lisp.Initialize(); var result = lisp.Do(input); Assert.IsType <int>(result); var intValue = (int)result; Assert.Equal(expectedResult, intValue); }
public void Do_QuoteFunction_ResultIsListItself(string input) { using var lisp = new SoltysLispVM(); lisp.Initialize(); var result = lisp.Do(input); Assert.IsType <List <object> >(result); var theList = (List <object>)result; Assert.Equal(3, theList.Count); Assert.Equal(new object[] { 1, 2, 3 }, theList); }
public void Do_MultipleFunctionsCall() { using var lisp = new SoltysLispVM(); lisp.Initialize(); var result = lisp.Do( @"(def! x (* 4 10)) (+ x (/ x x))"); Assert.IsType <int>(result); var intValue = (int)result; Assert.Equal(41, intValue); }
public void Do_DefineFunctionWithMathOperation_ReturnMathResult() { using var lisp = new SoltysLispVM(); lisp.Initialize(); var result = lisp.Do( @"(def! x (* 4 10)) (+ x 8)"); Assert.IsType <int>(result); var intValue = (int)result; Assert.Equal(48, intValue); }