diff --git a/test/function/builtin/APPLYTester.java b/test/function/builtin/APPLYTester.java index 70338c3..3547ab3 100644 --- a/test/function/builtin/APPLYTester.java +++ b/test/function/builtin/APPLYTester.java @@ -13,21 +13,21 @@ public class APPLYTester { public void testApply() { String input = "(apply '+ '(1 2 3))"; - assertSExpressionsMatch(evaluateString(input), parseString("6")); + assertSExpressionsMatch(parseString("6"), evaluateString(input)); } @Test public void testApplyWithLambdaExpression() { String input = "(apply (lambda (x) (+ x 1)) '(25))"; - assertSExpressionsMatch(evaluateString(input), parseString("26")); + assertSExpressionsMatch(parseString("26"), evaluateString(input)); } @Test public void testApplyWithQuotedLambdaExpression() { String input = "(apply '(lambda (x) (+ x 1)) '(25))"; - assertSExpressionsMatch(evaluateString(input), parseString("26")); + assertSExpressionsMatch(parseString("26"), evaluateString(input)); } @Test @@ -35,7 +35,7 @@ public class APPLYTester { String argumentList = "(+ (25 10))"; Cons parsedArgumentList = (Cons) parseString(argumentList); - assertSExpressionsMatch(APPLY.apply(parsedArgumentList), parseString("35")); + assertSExpressionsMatch(parseString("35"), APPLY.apply(parsedArgumentList)); } @Test(expected = RuntimeException.class) diff --git a/test/function/builtin/EVALTester.java b/test/function/builtin/EVALTester.java index def4bf4..e1f0e78 100644 --- a/test/function/builtin/EVALTester.java +++ b/test/function/builtin/EVALTester.java @@ -15,26 +15,26 @@ public class EVALTester { public void testEval() { String input = "(eval 9)"; - assertSExpressionsMatch(evaluateString(input), parseString("9")); + assertSExpressionsMatch(parseString("9"), evaluateString(input)); } @Test public void testEvalNil() { String input = "(eval ())"; - assertSExpressionsMatch(evaluateString(input), parseString("()")); + assertSExpressionsMatch(parseString("()"), evaluateString(input)); } @Test public void testLookupSymbol() { String symbol = ":symbol"; - assertSExpressionsMatch(EVAL.lookupSymbol(symbol), parseString(symbol)); + assertSExpressionsMatch(parseString(symbol), EVAL.lookupSymbol(symbol)); } @Test public void testLookupT() { String symbol = "T"; - assertSExpressionsMatch(EVAL.lookupSymbol(symbol), parseString(symbol)); + assertSExpressionsMatch(parseString(symbol), EVAL.lookupSymbol(symbol)); } @Test diff --git a/test/function/builtin/FUNCALLTester.java b/test/function/builtin/FUNCALLTester.java index 71d4e06..f14bee7 100644 --- a/test/function/builtin/FUNCALLTester.java +++ b/test/function/builtin/FUNCALLTester.java @@ -12,7 +12,7 @@ public class FUNCALLTester { public void testFuncallWithNumbers() { String input = "(funcall '+ 1 2 3)"; - assertSExpressionsMatch(evaluateString(input), parseString("6")); + assertSExpressionsMatch(parseString("6"), evaluateString(input)); } @Test @@ -21,7 +21,7 @@ public class FUNCALLTester { String input = "(funcall 'x 2 30)"; evaluateString(defineUserFunction); - assertSExpressionsMatch(evaluateString(input), parseString("32")); + assertSExpressionsMatch(parseString("32"), evaluateString(input)); } @Test(expected = TooFewArgumentsException.class) diff --git a/test/function/builtin/LOADTester.java b/test/function/builtin/LOADTester.java index 90c4d66..beee965 100644 --- a/test/function/builtin/LOADTester.java +++ b/test/function/builtin/LOADTester.java @@ -9,6 +9,7 @@ import org.junit.*; import environment.Environment; import function.ArgumentValidator.*; +import sexpression.*; public class LOADTester { @@ -32,7 +33,7 @@ public class LOADTester { public void loadGoodFile_ReturnsTAndPrintsNothing() { String input = "(load \"test/function/builtin/test-files/load-good.lisp\")"; - assertSExpressionsMatch(parseString("T"), evaluateString(input)); + assertSExpressionsMatch(Symbol.T, evaluateString(input)); assertNothingPrinted(); } @@ -40,7 +41,7 @@ public class LOADTester { public void loadBadFile_ReturnsNilAndPrintsError() { String input = "(load \"test/function/builtin/test-files/load-bad.lisp\")"; - assertSExpressionsMatch(parseString("nil"), evaluateString(input)); + assertSExpressionsMatch(Nil.getInstance(), evaluateString(input)); assertPrinted("LOAD: expression begins with ')' - line 1, column 1\n"); } @@ -48,7 +49,7 @@ public class LOADTester { public void loadNonExistentFile_ReturnsNilAndPrintsError() { String input = "(load \"doesNotExist.lisp\")"; - assertSExpressionsMatch(parseString("nil"), evaluateString(input)); + assertSExpressionsMatch(Nil.getInstance(), evaluateString(input)); assertPrinted("LOAD: could not open 'doesNotExist.lisp'\n"); } diff --git a/test/function/builtin/cons/CARTester.java b/test/function/builtin/cons/CARTester.java index 9a67c33..5d2d7fe 100644 --- a/test/function/builtin/cons/CARTester.java +++ b/test/function/builtin/cons/CARTester.java @@ -12,21 +12,21 @@ public class CARTester { public void testCarWithNil() { String input = "(car nil)"; - assertSExpressionsMatch(evaluateString(input), parseString("()")); + assertSExpressionsMatch(parseString("()"), evaluateString(input)); } @Test public void testCarWithList() { String input = "(car '(1 2 3))"; - assertSExpressionsMatch(evaluateString(input), parseString("1")); + assertSExpressionsMatch(parseString("1"), evaluateString(input)); } @Test public void testNestedCarWithList() { String input = "(car (car '((1 2) 3)))"; - assertSExpressionsMatch(evaluateString(input), parseString("1")); + assertSExpressionsMatch(parseString("1"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) diff --git a/test/function/builtin/cons/CDRTester.java b/test/function/builtin/cons/CDRTester.java index 394a01c..22b27dd 100644 --- a/test/function/builtin/cons/CDRTester.java +++ b/test/function/builtin/cons/CDRTester.java @@ -12,21 +12,21 @@ public class CDRTester { public void testCdrWithNil() { String input = "(cdr nil)"; - assertSExpressionsMatch(evaluateString(input), parseString("()")); + assertSExpressionsMatch(parseString("()"), evaluateString(input)); } @Test public void testCdrWithList() { String input = "(cdr '(1 2 3))"; - assertSExpressionsMatch(evaluateString(input), parseString("(2 3)")); + assertSExpressionsMatch(parseString("(2 3)"), evaluateString(input)); } @Test public void testNestedCdrWithList() { String input = "(cdr (cdr '(1 2 3)))"; - assertSExpressionsMatch(evaluateString(input), parseString("(3)")); + assertSExpressionsMatch(parseString("(3)"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) diff --git a/test/function/builtin/cons/CONSTester.java b/test/function/builtin/cons/CONSTester.java index 09526f9..98f06f2 100644 --- a/test/function/builtin/cons/CONSTester.java +++ b/test/function/builtin/cons/CONSTester.java @@ -13,27 +13,27 @@ public class CONSTester { public void testConsWithNilValues() { String input = "(cons () nil)"; - assertSExpressionsMatch(evaluateString(input), parseString("(())")); + assertSExpressionsMatch(parseString("(())"), evaluateString(input)); } @Test public void testConsWithTwoSymbols() { String input = "(cons 'a 'b)"; - assertSExpressionsMatch(evaluateString(input), new Cons(new Symbol("A"), new Symbol("B"))); + assertSExpressionsMatch(new Cons(new Symbol("A"), new Symbol("B")), evaluateString(input)); } @Test public void testConsWithListAsCdr() { String input = "(cons 1 '(2 3))"; - assertSExpressionsMatch(evaluateString(input), parseString("(1 2 3)")); + assertSExpressionsMatch(parseString("(1 2 3)"), evaluateString(input)); } @Test public void testConsWithTwoLists() { String input = "(cons '(1 2) '(3 4))"; - assertSExpressionsMatch(evaluateString(input), parseString("((1 2) 3 4)")); + assertSExpressionsMatch(parseString("((1 2) 3 4)"), evaluateString(input)); } @@ -41,7 +41,7 @@ public class CONSTester { public void testConsWithList() { String input = "(cons nil '(2 3))"; - assertSExpressionsMatch(evaluateString(input), parseString("(nil 2 3)")); + assertSExpressionsMatch(parseString("(nil 2 3)"), evaluateString(input)); } @Test(expected = TooManyArgumentsException.class) diff --git a/test/function/builtin/cons/LENGTHTester.java b/test/function/builtin/cons/LENGTHTester.java index 5786680..c42ed12 100644 --- a/test/function/builtin/cons/LENGTHTester.java +++ b/test/function/builtin/cons/LENGTHTester.java @@ -12,21 +12,21 @@ public class LENGTHTester { public void testLengthOfNil() { String input = "(length '())"; - assertSExpressionsMatch(evaluateString(input), parseString("0")); + assertSExpressionsMatch(parseString("0"), evaluateString(input)); } @Test public void testLengthOfListOfOneElement() { String input = "(length '(1))"; - assertSExpressionsMatch(evaluateString(input), parseString("1")); + assertSExpressionsMatch(parseString("1"), evaluateString(input)); } @Test public void testLengthOfListOfManyElements() { String input = "(length '(1 2 3 4 5))"; - assertSExpressionsMatch(evaluateString(input), parseString("5")); + assertSExpressionsMatch(parseString("5"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) diff --git a/test/function/builtin/cons/LISTTester.java b/test/function/builtin/cons/LISTTester.java index 0c6b891..95e591c 100644 --- a/test/function/builtin/cons/LISTTester.java +++ b/test/function/builtin/cons/LISTTester.java @@ -10,47 +10,47 @@ public class LISTTester { public void testListWithNoArguments() { String input = "(list)"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testListWithOneArgument() { String input = "(list 1)"; - assertSExpressionsMatch(evaluateString(input), parseString("(1)")); + assertSExpressionsMatch(parseString("(1)"), evaluateString(input)); } @Test public void testListWithTwoArguments() { String input = "(list 2 3)"; - assertSExpressionsMatch(evaluateString(input), parseString("(2 3)")); + assertSExpressionsMatch(parseString("(2 3)"), evaluateString(input)); } @Test public void testListWithManyArguments() { String input = "(list 'm 'a 'n 'y 'a 'r 'g 's)"; - assertSExpressionsMatch(evaluateString(input), parseString("(m a n y a r g s)")); + assertSExpressionsMatch(parseString("(m a n y a r g s)"), evaluateString(input)); } @Test public void testListWithOneListArgument() { String input = "(list '(1))"; - assertSExpressionsMatch(evaluateString(input), parseString("((1))")); + assertSExpressionsMatch(parseString("((1))"), evaluateString(input)); } @Test public void testListWithManyListArguments() { String input = "(list '(1) '(2 3) ())"; - assertSExpressionsMatch(evaluateString(input), parseString("((1) (2 3) ())")); + assertSExpressionsMatch(parseString("((1) (2 3) ())"), evaluateString(input)); } @Test public void testMakeList() { - assertSExpressionsMatch(LIST.makeList(parseString("22")), parseString("(22)")); + assertSExpressionsMatch(parseString("(22)"), LIST.makeList(parseString("22"))); } } diff --git a/test/function/builtin/math/DIVIDETester.java b/test/function/builtin/math/DIVIDETester.java index 682c24e..ebe778b 100644 --- a/test/function/builtin/math/DIVIDETester.java +++ b/test/function/builtin/math/DIVIDETester.java @@ -12,42 +12,42 @@ public class DIVIDETester { public void testDivideWithOne() { String input = "(/ 1)"; - assertSExpressionsMatch(evaluateString(input), parseString("1")); + assertSExpressionsMatch(parseString("1"), evaluateString(input)); } @Test public void testDivideWithTwo() { String input = "(/ 2)"; - assertSExpressionsMatch(evaluateString(input), parseString("0")); + assertSExpressionsMatch(parseString("0"), evaluateString(input)); } @Test public void testDivideTwoNumbers() { String input = "(/ 24 3)"; - assertSExpressionsMatch(evaluateString(input), parseString("8")); + assertSExpressionsMatch(parseString("8"), evaluateString(input)); } @Test public void testDivideSeveralNumbers() { String input = "(/ 256 2 2 8)"; - assertSExpressionsMatch(evaluateString(input), parseString("8")); + assertSExpressionsMatch(parseString("8"), evaluateString(input)); } @Test public void testDivideTwoNumbersWithRemainder() { String input = "(/ 9 2)"; - assertSExpressionsMatch(evaluateString(input), parseString("4")); + assertSExpressionsMatch(parseString("4"), evaluateString(input)); } @Test public void testDivideSeveralNumbersWithRemainder() { String input = "(/ 19 2 5)"; - assertSExpressionsMatch(evaluateString(input), parseString("1")); + assertSExpressionsMatch(parseString("1"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) diff --git a/test/function/builtin/math/MINUSTester.java b/test/function/builtin/math/MINUSTester.java index 87e7b89..0b5fe2e 100644 --- a/test/function/builtin/math/MINUSTester.java +++ b/test/function/builtin/math/MINUSTester.java @@ -13,28 +13,28 @@ public class MINUSTester { public void testMinusWithOneNumber() { String input = "(- 27)"; - assertSExpressionsMatch(evaluateString(input), new LispNumber("-27")); + assertSExpressionsMatch(new LispNumber("-27"), evaluateString(input)); } @Test public void testMinusWithTwoNumbers() { String input = "(- 5 3)"; - assertSExpressionsMatch(evaluateString(input), new LispNumber("2")); + assertSExpressionsMatch(new LispNumber("2"), evaluateString(input)); } @Test public void testMinusWithManyNumbers_PositiveResult() { String input = "(- 200 100 10 5)"; - assertSExpressionsMatch(evaluateString(input), new LispNumber("85")); + assertSExpressionsMatch(new LispNumber("85"), evaluateString(input)); } @Test public void testMinusWithManyNumbers_NegativeResult() { String input = "(- 100 200 20 5)"; - assertSExpressionsMatch(evaluateString(input), new LispNumber("-125")); + assertSExpressionsMatch(new LispNumber("-125"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) diff --git a/test/function/builtin/math/MULTIPLYTester.java b/test/function/builtin/math/MULTIPLYTester.java index e8a2ee0..766470a 100644 --- a/test/function/builtin/math/MULTIPLYTester.java +++ b/test/function/builtin/math/MULTIPLYTester.java @@ -13,35 +13,35 @@ public class MULTIPLYTester { public void testMultiplyWithNoArguments() { String input = "(*)"; - assertSExpressionsMatch(evaluateString(input), new LispNumber("1")); + assertSExpressionsMatch(new LispNumber("1"), evaluateString(input)); } @Test public void testMultiplyWithOneNumber() { String input = "(* 8)"; - assertSExpressionsMatch(evaluateString(input), new LispNumber("8")); + assertSExpressionsMatch(new LispNumber("8"), evaluateString(input)); } @Test public void testMultiplyWithTwoNumbers() { String input = "(* 5 3)"; - assertSExpressionsMatch(evaluateString(input), new LispNumber("15")); + assertSExpressionsMatch(new LispNumber("15"), evaluateString(input)); } @Test public void testMultiplyWithManyNumbers_PositiveResult() { String input = "(* 2 3 5 1)"; - assertSExpressionsMatch(evaluateString(input), new LispNumber("30")); + assertSExpressionsMatch(new LispNumber("30"), evaluateString(input)); } @Test public void testMultiplyWithManyNumbers_NegativeResult() { String input = "(* 3 (- 2) 10 2)"; - assertSExpressionsMatch(evaluateString(input), new LispNumber("-120")); + assertSExpressionsMatch(new LispNumber("-120"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) diff --git a/test/function/builtin/math/PLUSTester.java b/test/function/builtin/math/PLUSTester.java index a23b793..e2c9260 100644 --- a/test/function/builtin/math/PLUSTester.java +++ b/test/function/builtin/math/PLUSTester.java @@ -13,35 +13,35 @@ public class PLUSTester { public void testPlusWithNoArguments() { String input = "(+)"; - assertSExpressionsMatch(evaluateString(input), new LispNumber("0")); + assertSExpressionsMatch(new LispNumber("0"), evaluateString(input)); } @Test public void testPlusWithOneNumber() { String input = "(+ 27)"; - assertSExpressionsMatch(evaluateString(input), new LispNumber("27")); + assertSExpressionsMatch(new LispNumber("27"), evaluateString(input)); } @Test public void testPlusWithTwoNumbers() { String input = "(+ 5 3)"; - assertSExpressionsMatch(evaluateString(input), new LispNumber("8")); + assertSExpressionsMatch(new LispNumber("8"), evaluateString(input)); } @Test public void testPlusWithManyNumbers_PositiveResult() { String input = "(+ 200 100 10 5)"; - assertSExpressionsMatch(evaluateString(input), new LispNumber("315")); + assertSExpressionsMatch(new LispNumber("315"), evaluateString(input)); } @Test public void testPlusWithManyNumbers_NegativeResult() { String input = "(+ 100 (- 200) 20 5)"; - assertSExpressionsMatch(evaluateString(input), new LispNumber("-75")); + assertSExpressionsMatch(new LispNumber("-75"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) diff --git a/test/function/builtin/predicate/ATOMTester.java b/test/function/builtin/predicate/ATOMTester.java index 08666bf..30fc55d 100644 --- a/test/function/builtin/predicate/ATOMTester.java +++ b/test/function/builtin/predicate/ATOMTester.java @@ -12,14 +12,14 @@ public class ATOMTester { public void testAtom_ReturnsTrue() { String input = "(atom 'a)"; - assertSExpressionsMatch(evaluateString(input), parseString("T")); + assertSExpressionsMatch(parseString("T"), evaluateString(input)); } @Test public void testAtom_ReturnsFalse() { String input = "(atom '(1 2 3))"; - assertSExpressionsMatch(evaluateString(input), parseString("()")); + assertSExpressionsMatch(parseString("()"), evaluateString(input)); } @Test(expected = TooManyArgumentsException.class) diff --git a/test/function/builtin/predicate/EQTester.java b/test/function/builtin/predicate/EQTester.java index c5e8660..02e5853 100644 --- a/test/function/builtin/predicate/EQTester.java +++ b/test/function/builtin/predicate/EQTester.java @@ -12,20 +12,20 @@ public class EQTester { public void testEqWithEqualAtoms() { String input = "(eq 1 1)"; - assertSExpressionsMatch(evaluateString(input), parseString("t")); + assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test public void testEqWithUnequalAtoms() { String input = "(eq 1 2)"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testEqWithAtomAndList() { String input = "(eq 1 '(2))"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test @@ -37,21 +37,21 @@ public class EQTester { evaluateString(initializeL1); evaluateString(initializeL2); - assertSExpressionsMatch(evaluateString(input), parseString("t")); + assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test public void testEqWithEqualLists() { String input = "(eq '(1 2) '(1 2))"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testEqWithUnequalLists() { String input = "(eq '(1 2) '(3 4))"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test(expected = TooManyArgumentsException.class) diff --git a/test/function/builtin/predicate/EQUALSPTester.java b/test/function/builtin/predicate/EQUALSPTester.java index 1372411..8941c35 100644 --- a/test/function/builtin/predicate/EQUALSPTester.java +++ b/test/function/builtin/predicate/EQUALSPTester.java @@ -12,35 +12,35 @@ public class EQUALSPTester { public void testEqualspWithOneNumber() { String input = "(= 1)"; - assertSExpressionsMatch(evaluateString(input), parseString("t")); + assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test public void testEqualspWithEqualNumbers() { String input = "(= 1 1)"; - assertSExpressionsMatch(evaluateString(input), parseString("t")); + assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test public void testEqualspWithNonEqualNumbers() { String input = "(= 1 2)"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testEqualspWithManyEqualNumbers() { String input = "(= 4 4 4 4 4 4 4 4 4 4)"; - assertSExpressionsMatch(evaluateString(input), parseString("t")); + assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test public void testEqualspWithManyNonEqualNumbers() { String input = "(= 4 4 4 4 5 4 4 4 4 4)"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) diff --git a/test/function/builtin/predicate/EQUALTester.java b/test/function/builtin/predicate/EQUALTester.java index a0681b8..a7276ee 100644 --- a/test/function/builtin/predicate/EQUALTester.java +++ b/test/function/builtin/predicate/EQUALTester.java @@ -12,49 +12,49 @@ public class EQUALTester { public void testEqualWithTwoEqualAtoms() { String input = "(equal 'a 'a)"; - assertSExpressionsMatch(evaluateString(input), parseString("t")); + assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test public void testEqualWithTwoUnequalAtoms() { String input = "(equal 'a 'b)"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testEqualWithAtomAndList() { String input = "(equal \"string\" '(m i k e))"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testEqualWithListAndAtom() { String input = "(equal '(m i k e) \"string\")"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testEqualWithTwoEqualLists() { String input = "(equal '(1 2 3) '(1 2 3))"; - assertSExpressionsMatch(evaluateString(input), parseString("t")); + assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test public void testEqualWithTwoUnequalLists() { String input = "(equal '(1 2 3) '(1 3 3))"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testEqualWithTwoEqualNestedLists() { String input = "(equal '(1 ((2) 3)) '(1 ((2) 3)))"; - assertSExpressionsMatch(evaluateString(input), parseString("t")); + assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test(expected = TooManyArgumentsException.class) diff --git a/test/function/builtin/predicate/GREATERPTester.java b/test/function/builtin/predicate/GREATERPTester.java index 607743d..26ab718 100644 --- a/test/function/builtin/predicate/GREATERPTester.java +++ b/test/function/builtin/predicate/GREATERPTester.java @@ -12,35 +12,35 @@ public class GREATERPTester { public void testGreaterpWithOneNumber_ReturnsT() { String input = "(> 1)"; - assertSExpressionsMatch(evaluateString(input), parseString("t")); + assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test public void testGreaterpWithTwoNumbers_ReturnsNil() { String input = "(> 1 2)"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testGreaterpWithTwoNumbers_ReturnsT() { String input = "(> 3 2)"; - assertSExpressionsMatch(evaluateString(input), parseString("t")); + assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test public void testGreaterpWithManyNumbers_ReturnsNil() { String input = "(> 4 3 2 5 1)"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testGreaterpWithManyNumbers_ReturnsT() { String input = "(> 4 3 2 1 0)"; - assertSExpressionsMatch(evaluateString(input), parseString("t")); + assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) diff --git a/test/function/builtin/predicate/LESSPTester.java b/test/function/builtin/predicate/LESSPTester.java index d4152fc..3dcc6aa 100644 --- a/test/function/builtin/predicate/LESSPTester.java +++ b/test/function/builtin/predicate/LESSPTester.java @@ -12,35 +12,35 @@ public class LESSPTester { public void testLesspWithOneNumber_ReturnsT() { String input = "(< 1)"; - assertSExpressionsMatch(evaluateString(input), parseString("t")); + assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test public void testLesspWithTwoNumbers_ReturnsNil() { String input = "(< 2 1)"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testLesspWithTwoNumbers_ReturnsT() { String input = "(< 2 3)"; - assertSExpressionsMatch(evaluateString(input), parseString("t")); + assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test public void testLesspWithManyNumbers_ReturnsNil() { String input = "(< 4 3 2 5 1)"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testLesspWithManyNumbers_ReturnsT() { String input = "(< 0 1 2 3 4)"; - assertSExpressionsMatch(evaluateString(input), parseString("t")); + assertSExpressionsMatch(parseString("t"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) diff --git a/test/function/builtin/predicate/LISTPTester.java b/test/function/builtin/predicate/LISTPTester.java index e75e337..6f78838 100644 --- a/test/function/builtin/predicate/LISTPTester.java +++ b/test/function/builtin/predicate/LISTPTester.java @@ -12,14 +12,14 @@ public class LISTPTester { public void testListpWithList_ReturnsT() { String input = "(listp '(1))"; - assertSExpressionsMatch(evaluateString(input), parseString("T")); + assertSExpressionsMatch(parseString("T"), evaluateString(input)); } @Test public void testListWithNonList_ReturnsNil() { String input = "(listp 1)"; - assertSExpressionsMatch(evaluateString(input), parseString("NIL")); + assertSExpressionsMatch(parseString("NIL"), evaluateString(input)); } @Test(expected = TooFewArgumentsException.class) diff --git a/test/function/builtin/predicate/NULLTester.java b/test/function/builtin/predicate/NULLTester.java index 2ee7913..585525b 100644 --- a/test/function/builtin/predicate/NULLTester.java +++ b/test/function/builtin/predicate/NULLTester.java @@ -12,14 +12,14 @@ public class NULLTester { public void testNilIsNull() { String input = "(null ())"; - assertSExpressionsMatch(evaluateString(input), parseString("T")); + assertSExpressionsMatch(parseString("T"), evaluateString(input)); } @Test public void testListIsNotNull() { String input = "(null '(1))"; - assertSExpressionsMatch(evaluateString(input), parseString("NIL")); + assertSExpressionsMatch(parseString("NIL"), evaluateString(input)); } @Test(expected = TooFewArgumentsException.class) diff --git a/test/function/builtin/special/CONDTester.java b/test/function/builtin/special/CONDTester.java index 5c764c0..acd7063 100644 --- a/test/function/builtin/special/CONDTester.java +++ b/test/function/builtin/special/CONDTester.java @@ -12,56 +12,56 @@ public class CONDTester { public void testCondWithNoArguments() { String input = "(cond)"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test public void testCondWithTrue() { String input = "(cond (T))"; - assertSExpressionsMatch(evaluateString(input), parseString("T")); + assertSExpressionsMatch(parseString("T"), evaluateString(input)); } @Test public void testCondWithSingleExpression() { String input = "(cond (T \"true\"))"; - assertSExpressionsMatch(evaluateString(input), parseString("\"true\"")); + assertSExpressionsMatch(parseString("\"true\""), evaluateString(input)); } @Test public void testCondWithMultipleExpressions() { String input = "(cond ((= 1 2) 2) ((= 1 2) 2) ((= 1 1) 3))"; - assertSExpressionsMatch(evaluateString(input), parseString("3")); + assertSExpressionsMatch(parseString("3"), evaluateString(input)); } @Test public void testCondWithMultipleConditionsMatching_ReturnFirstOne() { String input = "(cond ((= 1 1) 2) ((= 1 1) 3))"; - assertSExpressionsMatch(evaluateString(input), parseString("2")); + assertSExpressionsMatch(parseString("2"), evaluateString(input)); } @Test public void testCondWithMultipleConditionsMatching_OnlyEvaluatesFirstOne() { String input = "(cond ((= 1 1) 2) ((= 1 1) x))"; - assertSExpressionsMatch(evaluateString(input), parseString("2")); + assertSExpressionsMatch(parseString("2"), evaluateString(input)); } @Test public void testCondWithMultipleResultValues_OnlyReturnsLast() { String input = "(cond ((= 1 1) 2 3 4))"; - assertSExpressionsMatch(evaluateString(input), parseString("4")); + assertSExpressionsMatch(parseString("4"), evaluateString(input)); } @Test public void testCondWithNoConditionMatching_ReturnsNil() { String input = "(cond ((= 1 2) T) ((= 1 3) T))"; - assertSExpressionsMatch(evaluateString(input), parseString("nil")); + assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) diff --git a/test/function/builtin/special/DEFUNTester.java b/test/function/builtin/special/DEFUNTester.java index f580e01..4705fd2 100644 --- a/test/function/builtin/special/DEFUNTester.java +++ b/test/function/builtin/special/DEFUNTester.java @@ -12,8 +12,8 @@ public class DEFUNTester { public void testDefun() { String input = "(defun f () nil)"; - assertSExpressionsMatch(evaluateString(input), parseString("f")); - assertSExpressionsMatch(evaluateString("(f)"), parseString("()")); + assertSExpressionsMatch(parseString("f"), evaluateString(input)); + assertSExpressionsMatch(parseString("()"), evaluateString("(f)")); } @Test(expected = DottedArgumentListException.class) diff --git a/test/function/builtin/special/QUOTETester.java b/test/function/builtin/special/QUOTETester.java index fe042e3..4cf959d 100644 --- a/test/function/builtin/special/QUOTETester.java +++ b/test/function/builtin/special/QUOTETester.java @@ -12,14 +12,14 @@ public class QUOTETester { public void testQuoteSymbol() { String input = "'a"; - assertSExpressionsMatch(evaluateString(input), parseString("a")); + assertSExpressionsMatch(parseString("a"), evaluateString(input)); } @Test public void testQuoteList() { String input = "'(l i s t)"; - assertSExpressionsMatch(evaluateString(input), parseString("(l i s t)")); + assertSExpressionsMatch(parseString("(l i s t)"), evaluateString(input)); } @Test(expected = TooFewArgumentsException.class) diff --git a/test/function/builtin/special/SETFTester.java b/test/function/builtin/special/SETFTester.java index aa55dab..ca0fde6 100644 --- a/test/function/builtin/special/SETFTester.java +++ b/test/function/builtin/special/SETFTester.java @@ -20,13 +20,13 @@ public class SETFTester { @Test public void testSetf() { evaluateString("(setf a 23)"); - assertSExpressionsMatch(evaluateString("23"), evaluateString("a")); + assertSExpressionsMatch(new LispNumber("23"), evaluateString("a")); } @Test public void lookupDefinedSymbol() { evaluateString("(setf a 23)"); - assertSExpressionsMatch(evaluateString("23"), SETF.lookupSymbolValue("A")); + assertSExpressionsMatch(new LispNumber("23"), SETF.lookupSymbolValue("A")); } @Test @@ -42,7 +42,7 @@ public class SETFTester { evaluateString("(setf a 94)"); SETF.setSymbolTable(global); - assertSExpressionsMatch(evaluateString("94"), evaluateString("a")); + assertSExpressionsMatch(new LispNumber("94"), evaluateString("a")); } @Test(expected = UndefinedSymbolException.class) @@ -65,7 +65,7 @@ public class SETFTester { evaluateString("(setf a 94)"); SETF.setSymbolTable(global); - assertSExpressionsMatch(evaluateString("94"), evaluateString("a")); + assertSExpressionsMatch(new LispNumber("94"), evaluateString("a")); } @Test(expected = BadArgumentTypeException.class)