From 2bd0c1a67419f59e08bd8af90ef2a73373905999 Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Thu, 2 Mar 2017 09:54:23 -0500 Subject: [PATCH] Major Refactor - Static constants and test case names --- src/function/UserDefinedFunction.java | 3 +- src/function/builtin/EVAL.java | 9 ++- src/function/builtin/EXIT.java | 4 +- src/function/builtin/LOAD.java | 4 +- src/function/builtin/cons/LIST.java | 6 +- src/function/builtin/math/MULTIPLY.java | 4 +- src/function/builtin/math/PLUS.java | 4 +- src/function/builtin/predicate/ATOM.java | 5 +- src/function/builtin/predicate/EQ.java | 7 ++- src/function/builtin/predicate/EQUAL.java | 5 +- src/function/builtin/predicate/LISTP.java | 5 +- src/function/builtin/predicate/NULL.java | 5 +- .../builtin/predicate/NUMERIC_EQUAL.java | 7 ++- .../builtin/predicate/NUMERIC_GREATER.java | 7 ++- .../builtin/predicate/NUMERIC_LESS.java | 7 ++- src/function/builtin/special/AND.java | 3 +- src/function/builtin/special/CASE.java | 8 ++- src/function/builtin/special/COND.java | 5 +- src/function/builtin/special/LET.java | 3 +- src/function/builtin/special/PROGN.java | 3 +- src/sexpression/Nil.java | 6 +- src/token/QuoteMark.java | 4 +- src/token/RightParenthesis.java | 6 +- test/function/ArgumentValidatorTester.java | 40 ++++++------ test/function/UserDefinedFunctionTester.java | 21 +++---- test/function/builtin/APPLYTester.java | 21 ++++--- test/function/builtin/EVALTester.java | 35 ++++++----- test/function/builtin/EXITTester.java | 2 +- test/function/builtin/FUNCALLTester.java | 6 +- test/function/builtin/LOADTester.java | 6 +- test/function/builtin/PRINTTester.java | 4 +- test/function/builtin/SETTester.java | 8 +-- .../builtin/SYMBOL_FUNCTIONTester.java | 18 +++--- test/function/builtin/cons/CONSTester.java | 14 ++--- test/function/builtin/cons/LENGTHTester.java | 12 ++-- test/function/builtin/cons/LISTTester.java | 17 ++--- test/function/builtin/math/DIVIDETester.java | 16 ++--- test/function/builtin/math/MINUSTester.java | 12 ++-- .../function/builtin/math/MULTIPLYTester.java | 12 ++-- test/function/builtin/math/PLUSTester.java | 12 ++-- .../builtin/special/LAMBDATester.java | 15 ++--- test/function/builtin/special/LETTester.java | 5 +- test/parser/LispParserTester.java | 10 +-- test/sexpression/SExpressionTester.java | 63 ++++++++++--------- test/table/ExecutionContextTester.java | 22 +++---- test/table/FunctionTableTester.java | 18 +++--- test/table/SymbolTableTester.java | 20 +++--- test/testutil/TypeAssertions.java | 8 ++- test/token/TokenFactoryTester.java | 26 ++++---- test/util/CharactersTester.java | 2 +- 50 files changed, 309 insertions(+), 256 deletions(-) diff --git a/src/function/UserDefinedFunction.java b/src/function/UserDefinedFunction.java index 82b72f7..4ff189e 100644 --- a/src/function/UserDefinedFunction.java +++ b/src/function/UserDefinedFunction.java @@ -1,6 +1,7 @@ package function; import static function.builtin.EVAL.eval; +import static sexpression.Nil.NIL; import java.text.MessageFormat; import java.util.ArrayList; @@ -113,7 +114,7 @@ public class UserDefinedFunction extends LispFunction { } private SExpression evaluateBody() { - SExpression lastEvaluation = Nil.getInstance(); + SExpression lastEvaluation = NIL; for (Cons expression = body; expression.isCons(); expression = (Cons) expression.getRest()) lastEvaluation = eval(expression.getFirst()); diff --git a/src/function/builtin/EVAL.java b/src/function/builtin/EVAL.java index 54b7733..c372404 100644 --- a/src/function/builtin/EVAL.java +++ b/src/function/builtin/EVAL.java @@ -1,5 +1,8 @@ package function.builtin; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; + import java.text.MessageFormat; import error.LispException; @@ -32,9 +35,9 @@ public class EVAL extends LispFunction { public static SExpression lookupSymbol(String symbolName) { if (symbolName.equals("NIL")) - return Nil.getInstance(); + return NIL; else if (symbolName.equals("T")) - return Symbol.T; + return T; else if (symbolName.startsWith(":")) return new Symbol(symbolName); @@ -97,7 +100,7 @@ public class EVAL extends LispFunction { private Cons evaluateArgList(Cons arguments) { if (arguments.isNull()) - return Nil.getInstance(); + return NIL; SExpression first = eval(arguments.getFirst()); SExpression rest = arguments.getRest(); diff --git a/src/function/builtin/EXIT.java b/src/function/builtin/EXIT.java index ba2f176..70f076e 100644 --- a/src/function/builtin/EXIT.java +++ b/src/function/builtin/EXIT.java @@ -1,5 +1,7 @@ package function.builtin; +import static sexpression.Nil.NIL; + import environment.RuntimeEnvironment; import function.*; import sexpression.*; @@ -20,7 +22,7 @@ public class EXIT extends LispFunction { argumentValidator.validate(argumentList); environment.terminateSuccessfully(); - return Nil.getInstance(); + return NIL; } } diff --git a/src/function/builtin/LOAD.java b/src/function/builtin/LOAD.java index 153d881..aaf232e 100644 --- a/src/function/builtin/LOAD.java +++ b/src/function/builtin/LOAD.java @@ -1,6 +1,8 @@ package function.builtin; import static function.builtin.EVAL.eval; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; import java.io.*; import java.text.MessageFormat; @@ -44,7 +46,7 @@ public class LOAD extends LispFunction { if (parser != null) wasSuccessful = isSuccessfulEvaluation(parser); - return wasSuccessful ? Symbol.T : Nil.getInstance(); + return wasSuccessful ? T : NIL; } private LispParser attemptToCreateParserOnFile(String fileName) { diff --git a/src/function/builtin/cons/LIST.java b/src/function/builtin/cons/LIST.java index 612b2fa..506c0fb 100644 --- a/src/function/builtin/cons/LIST.java +++ b/src/function/builtin/cons/LIST.java @@ -1,5 +1,7 @@ package function.builtin.cons; +import static sexpression.Nil.NIL; + import function.*; import sexpression.*; @@ -13,7 +15,7 @@ public class LIST extends LispFunction { } public static Cons makeList(SExpression sexpr) { - return new Cons(sexpr, Nil.getInstance()); + return new Cons(sexpr, NIL); } public Cons call(Cons argumentList) { @@ -24,7 +26,7 @@ public class LIST extends LispFunction { private Cons callRecursive(Cons argumentList) { if (argumentList.isNull()) - return Nil.getInstance(); + return NIL; SExpression firstArgument = argumentList.getFirst(); Cons remainingArguments = (Cons) argumentList.getRest(); diff --git a/src/function/builtin/math/MULTIPLY.java b/src/function/builtin/math/MULTIPLY.java index 5ada86e..23e6818 100644 --- a/src/function/builtin/math/MULTIPLY.java +++ b/src/function/builtin/math/MULTIPLY.java @@ -1,5 +1,7 @@ package function.builtin.math; +import static sexpression.LispNumber.ONE; + import function.*; import sexpression.*; @@ -18,7 +20,7 @@ public class MULTIPLY extends LispFunction { public LispNumber call(Cons argumentList) { argumentValidator.validate(argumentList); - return mathFunction.callTailRecursive(new Cons(LispNumber.ONE, argumentList)); + return mathFunction.callTailRecursive(new Cons(ONE, argumentList)); } private LispNumber multiply(LispNumber number1, LispNumber number2) { diff --git a/src/function/builtin/math/PLUS.java b/src/function/builtin/math/PLUS.java index 8e20c08..eb49441 100644 --- a/src/function/builtin/math/PLUS.java +++ b/src/function/builtin/math/PLUS.java @@ -1,5 +1,7 @@ package function.builtin.math; +import static sexpression.LispNumber.ZERO; + import function.*; import sexpression.*; @@ -18,7 +20,7 @@ public class PLUS extends LispFunction { public LispNumber call(Cons argumentList) { argumentValidator.validate(argumentList); - return mathFunction.callTailRecursive(new Cons(LispNumber.ZERO, argumentList)); + return mathFunction.callTailRecursive(new Cons(ZERO, argumentList)); } private LispNumber add(LispNumber number1, LispNumber number2) { diff --git a/src/function/builtin/predicate/ATOM.java b/src/function/builtin/predicate/ATOM.java index a6bdb36..79aec95 100644 --- a/src/function/builtin/predicate/ATOM.java +++ b/src/function/builtin/predicate/ATOM.java @@ -1,5 +1,8 @@ package function.builtin.predicate; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; + import function.*; import sexpression.*; @@ -17,7 +20,7 @@ public class ATOM extends LispFunction { argumentValidator.validate(argumentList); SExpression argument = argumentList.getFirst(); - return argument.isAtom() ? Symbol.T : Nil.getInstance(); + return argument.isAtom() ? T : NIL; } } diff --git a/src/function/builtin/predicate/EQ.java b/src/function/builtin/predicate/EQ.java index e305dd9..add9adb 100644 --- a/src/function/builtin/predicate/EQ.java +++ b/src/function/builtin/predicate/EQ.java @@ -1,5 +1,8 @@ package function.builtin.predicate; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; + import function.*; import sexpression.*; @@ -35,7 +38,7 @@ public class EQ extends LispFunction { } private SExpression atomEq(SExpression firstArgument, SExpression secondArgument) { - return isEq(firstArgument, secondArgument) ? Symbol.T : Nil.getInstance(); + return isEq(firstArgument, secondArgument) ? T : NIL; } private boolean isEq(SExpression firstArgument, SExpression secondArgument) { @@ -43,7 +46,7 @@ public class EQ extends LispFunction { } private SExpression listEq(SExpression firstArgument, SExpression secondArgument) { - return (firstArgument == secondArgument) ? Symbol.T : Nil.getInstance(); + return (firstArgument == secondArgument) ? T : NIL; } } diff --git a/src/function/builtin/predicate/EQUAL.java b/src/function/builtin/predicate/EQUAL.java index 6ad5efe..537f011 100644 --- a/src/function/builtin/predicate/EQUAL.java +++ b/src/function/builtin/predicate/EQUAL.java @@ -1,5 +1,8 @@ package function.builtin.predicate; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; + import function.*; import sexpression.*; @@ -28,7 +31,7 @@ public class EQUAL extends LispFunction { } private SExpression equal(SExpression firstArgument, SExpression secondArgument) { - return isEqual(firstArgument, secondArgument) ? Symbol.T : Nil.getInstance(); + return isEqual(firstArgument, secondArgument) ? T : NIL; } } diff --git a/src/function/builtin/predicate/LISTP.java b/src/function/builtin/predicate/LISTP.java index d465b6b..446102d 100644 --- a/src/function/builtin/predicate/LISTP.java +++ b/src/function/builtin/predicate/LISTP.java @@ -1,5 +1,8 @@ package function.builtin.predicate; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; + import function.*; import sexpression.*; @@ -16,7 +19,7 @@ public class LISTP extends LispFunction { public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); - return argumentList.getFirst().isList() ? Symbol.T : Nil.getInstance(); + return argumentList.getFirst().isList() ? T : NIL; } } diff --git a/src/function/builtin/predicate/NULL.java b/src/function/builtin/predicate/NULL.java index 74f67fe..a013ae3 100644 --- a/src/function/builtin/predicate/NULL.java +++ b/src/function/builtin/predicate/NULL.java @@ -1,5 +1,8 @@ package function.builtin.predicate; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; + import function.*; import sexpression.*; @@ -16,7 +19,7 @@ public class NULL extends LispFunction { public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); - return argumentList.getFirst().isNull() ? Symbol.T : Nil.getInstance(); + return argumentList.getFirst().isNull() ? T : NIL; } } diff --git a/src/function/builtin/predicate/NUMERIC_EQUAL.java b/src/function/builtin/predicate/NUMERIC_EQUAL.java index 452b18b..578e800 100644 --- a/src/function/builtin/predicate/NUMERIC_EQUAL.java +++ b/src/function/builtin/predicate/NUMERIC_EQUAL.java @@ -1,5 +1,8 @@ package function.builtin.predicate; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; + import function.*; import sexpression.*; @@ -24,7 +27,7 @@ public class NUMERIC_EQUAL extends LispFunction { Cons remainingArguments = (Cons) argumentList.getRest(); if (remainingArguments.isNull()) - return Symbol.T; + return T; SExpression firstArgument = argumentList.getFirst(); LispNumber number1 = (LispNumber) firstArgument; @@ -32,7 +35,7 @@ public class NUMERIC_EQUAL extends LispFunction { LispNumber number2 = (LispNumber) secondArgument; if (!isEqual(number1, number2)) - return Nil.getInstance(); + return NIL; return callTailRecursive(remainingArguments); } diff --git a/src/function/builtin/predicate/NUMERIC_GREATER.java b/src/function/builtin/predicate/NUMERIC_GREATER.java index 4d2bd37..42f0b2b 100644 --- a/src/function/builtin/predicate/NUMERIC_GREATER.java +++ b/src/function/builtin/predicate/NUMERIC_GREATER.java @@ -1,5 +1,8 @@ package function.builtin.predicate; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; + import function.*; import sexpression.*; @@ -24,7 +27,7 @@ public class NUMERIC_GREATER extends LispFunction { Cons remainingArguments = (Cons) argumentList.getRest(); if (remainingArguments.isNull()) - return Symbol.T; + return T; SExpression firstArgument = argumentList.getFirst(); SExpression secondArgument = remainingArguments.getFirst(); @@ -32,7 +35,7 @@ public class NUMERIC_GREATER extends LispFunction { LispNumber number2 = (LispNumber) secondArgument; if (!isFirstGreater(number1, number2)) - return Nil.getInstance(); + return NIL; return callTailRecursive(remainingArguments); } diff --git a/src/function/builtin/predicate/NUMERIC_LESS.java b/src/function/builtin/predicate/NUMERIC_LESS.java index ec7f2b8..976e6d6 100644 --- a/src/function/builtin/predicate/NUMERIC_LESS.java +++ b/src/function/builtin/predicate/NUMERIC_LESS.java @@ -1,5 +1,8 @@ package function.builtin.predicate; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; + import function.*; import sexpression.*; @@ -24,7 +27,7 @@ public class NUMERIC_LESS extends LispFunction { Cons remainingArguments = (Cons) argumentList.getRest(); if (remainingArguments.isNull()) - return Symbol.T; + return T; SExpression firstArgument = argumentList.getFirst(); SExpression secondArgument = remainingArguments.getFirst(); @@ -32,7 +35,7 @@ public class NUMERIC_LESS extends LispFunction { LispNumber number2 = (LispNumber) secondArgument; if (!isFirstLesser(number1, number2)) - return Nil.getInstance(); + return NIL; return callTailRecursive(remainingArguments); } diff --git a/src/function/builtin/special/AND.java b/src/function/builtin/special/AND.java index 9d33d40..263d368 100644 --- a/src/function/builtin/special/AND.java +++ b/src/function/builtin/special/AND.java @@ -1,6 +1,7 @@ package function.builtin.special; import static function.builtin.EVAL.eval; +import static sexpression.Symbol.T; import function.*; import sexpression.*; @@ -17,7 +18,7 @@ public class AND extends LispSpecialFunction { public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); - return callTailRecursive(argumentList, Symbol.T); + return callTailRecursive(argumentList, T); } private SExpression callTailRecursive(Cons argumentList, SExpression lastValue) { diff --git a/src/function/builtin/special/CASE.java b/src/function/builtin/special/CASE.java index 60da96b..d8fa4ac 100644 --- a/src/function/builtin/special/CASE.java +++ b/src/function/builtin/special/CASE.java @@ -2,6 +2,8 @@ package function.builtin.special; import static function.builtin.EVAL.eval; import static function.builtin.predicate.EQUAL.isEqual; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; import function.*; import sexpression.*; @@ -27,7 +29,7 @@ public class CASE extends LispSpecialFunction { private SExpression callTailRecursive(SExpression key, Cons argumentList) { if (argumentList.isNull()) - return Nil.getInstance(); + return NIL; Cons clause = (Cons) argumentList.getFirst(); Cons remainingClauses = (Cons) argumentList.getRest(); @@ -57,7 +59,7 @@ public class CASE extends LispSpecialFunction { } private boolean isKeyListT(SExpression keyList) { - return isEqual(Symbol.T, keyList); + return isEqual(T, keyList); } private SExpression advanceCons(SExpression knownCons) { @@ -69,7 +71,7 @@ public class CASE extends LispSpecialFunction { } private SExpression evaluateConsequents(SExpression consequentList) { - SExpression lastConsequentValue = Nil.getInstance(); + SExpression lastConsequentValue = NIL; for (; consequentList.isCons(); consequentList = advanceCons(consequentList)) lastConsequentValue = eval(getFirst(consequentList)); diff --git a/src/function/builtin/special/COND.java b/src/function/builtin/special/COND.java index 8429453..b34f1c7 100644 --- a/src/function/builtin/special/COND.java +++ b/src/function/builtin/special/COND.java @@ -1,6 +1,7 @@ package function.builtin.special; import static function.builtin.EVAL.eval; +import static sexpression.Nil.NIL; import function.*; import sexpression.*; @@ -24,7 +25,7 @@ public class COND extends LispSpecialFunction { private SExpression callTailRecursive(Cons argumentList) { if (argumentList.isNull()) - return Nil.getInstance(); + return NIL; Cons clause = (Cons) argumentList.getFirst(); Cons remainingClauses = (Cons) argumentList.getRest(); @@ -37,7 +38,7 @@ public class COND extends LispSpecialFunction { } private boolean isTestSuccessful(SExpression test) { - return test != Nil.getInstance(); + return test != NIL; } private SExpression evaluateConsequents(SExpression consequentList, SExpression test) { diff --git a/src/function/builtin/special/LET.java b/src/function/builtin/special/LET.java index 839dd2e..db8a5a4 100644 --- a/src/function/builtin/special/LET.java +++ b/src/function/builtin/special/LET.java @@ -1,6 +1,7 @@ package function.builtin.special; import static function.builtin.EVAL.eval; +import static sexpression.Nil.NIL; import function.*; import sexpression.*; @@ -71,7 +72,7 @@ public class LET extends LispSpecialFunction { } private SExpression evaluateBody(Cons body) { - SExpression lastEvaluation = Nil.getInstance(); + SExpression lastEvaluation = NIL; for (; body.isCons(); body = (Cons) body.getRest()) lastEvaluation = eval(body.getFirst()); diff --git a/src/function/builtin/special/PROGN.java b/src/function/builtin/special/PROGN.java index ca9882c..c11a5f1 100644 --- a/src/function/builtin/special/PROGN.java +++ b/src/function/builtin/special/PROGN.java @@ -1,6 +1,7 @@ package function.builtin.special; import static function.builtin.EVAL.eval; +import static sexpression.Nil.NIL; import function.*; import sexpression.*; @@ -17,7 +18,7 @@ public class PROGN extends LispSpecialFunction { public SExpression call(Cons argumentList) { argumentValidator.validate(argumentList); - return callTailRecursive(argumentList, Nil.getInstance()); + return callTailRecursive(argumentList, NIL); } private SExpression callTailRecursive(Cons argumentList, SExpression lastValue) { diff --git a/src/sexpression/Nil.java b/src/sexpression/Nil.java index 2b54191..dd2dc80 100644 --- a/src/sexpression/Nil.java +++ b/src/sexpression/Nil.java @@ -3,11 +3,7 @@ package sexpression; @DisplayName("nil") public class Nil extends Cons { - private static Nil uniqueInstance = new Nil(); - - public static Nil getInstance() { - return uniqueInstance; - } + public static final Nil NIL = new Nil(); private Nil() { super(null, null); diff --git a/src/token/QuoteMark.java b/src/token/QuoteMark.java index 660bd5d..bdbca45 100644 --- a/src/token/QuoteMark.java +++ b/src/token/QuoteMark.java @@ -1,5 +1,7 @@ package token; +import static sexpression.Nil.NIL; + import java.util.function.Supplier; import file.FilePosition; @@ -16,7 +18,7 @@ public class QuoteMark extends Token { Token nextToken = getNextToken.get(); SExpression argument = nextToken.parseSExpression(getNextToken); - return new Cons(Symbol.createQuote(), new Cons(argument, Nil.getInstance())); + return new Cons(Symbol.createQuote(), new Cons(argument, NIL)); } } diff --git a/src/token/RightParenthesis.java b/src/token/RightParenthesis.java index 26ac921..20f2818 100644 --- a/src/token/RightParenthesis.java +++ b/src/token/RightParenthesis.java @@ -1,10 +1,12 @@ package token; +import static sexpression.Nil.NIL; + import java.util.function.Supplier; import error.LineColumnException; import file.FilePosition; -import sexpression.*; +import sexpression.SExpression; public class RightParenthesis extends Token { @@ -19,7 +21,7 @@ public class RightParenthesis extends Token { @Override public SExpression parseSExpressionTail(Supplier getNextToken) { - return Nil.getInstance(); + return NIL; } public static class StartsWithRightParenthesisException extends LineColumnException { diff --git a/test/function/ArgumentValidatorTester.java b/test/function/ArgumentValidatorTester.java index 24bf0e5..5ea4969 100644 --- a/test/function/ArgumentValidatorTester.java +++ b/test/function/ArgumentValidatorTester.java @@ -2,6 +2,8 @@ package function; import static error.ErrorManager.Severity.ERROR; import static org.junit.Assert.*; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; import org.junit.*; @@ -13,10 +15,10 @@ public class ArgumentValidatorTester { private ArgumentValidator validator; private Cons makeArgumentListOfSize(int size) { - Cons argumentList = Nil.getInstance(); + Cons argumentList = NIL; for (int i = 0; i < size; i++) - argumentList = new Cons(Nil.getInstance(), argumentList); + argumentList = new Cons(NIL, argumentList); return argumentList; } @@ -73,14 +75,14 @@ public class ArgumentValidatorTester { @Test public void tooManyArgumentsException_HasCorrectSeverity() { - TooManyArgumentsException e = new TooManyArgumentsException("TEST", Nil.getInstance()); + TooManyArgumentsException e = new TooManyArgumentsException("TEST", NIL); assertEquals(ERROR, e.getSeverity()); } @Test public void tooManyArgumentsException_HasMessageText() { - TooManyArgumentsException e = new TooManyArgumentsException("TEST", Nil.getInstance()); + TooManyArgumentsException e = new TooManyArgumentsException("TEST", NIL); assertNotNull(e.getMessage()); assertTrue(e.getMessage().length() > 0); @@ -88,14 +90,14 @@ public class ArgumentValidatorTester { @Test public void tooFewArgumentsException_HasCorrectSeverity() { - TooFewArgumentsException e = new TooFewArgumentsException("TEST", Nil.getInstance()); + TooFewArgumentsException e = new TooFewArgumentsException("TEST", NIL); assertEquals(ERROR, e.getSeverity()); } @Test public void tooFewArgumentsException_HasMessageText() { - TooFewArgumentsException e = new TooFewArgumentsException("TEST", Nil.getInstance()); + TooFewArgumentsException e = new TooFewArgumentsException("TEST", NIL); assertNotNull(e.getMessage()); assertTrue(e.getMessage().length() > 0); @@ -103,14 +105,14 @@ public class ArgumentValidatorTester { @Test public void BadArgumentTypeException_HasCorrectSeverity() { - BadArgumentTypeException e = new BadArgumentTypeException("TEST", Nil.getInstance(), SExpression.class); + BadArgumentTypeException e = new BadArgumentTypeException("TEST", NIL, SExpression.class); assertEquals(ERROR, e.getSeverity()); } @Test public void BadArgumentTypeException_HasMessageText() { - BadArgumentTypeException e = new BadArgumentTypeException("TEST", Nil.getInstance(), SExpression.class); + BadArgumentTypeException e = new BadArgumentTypeException("TEST", NIL, SExpression.class); assertNotNull(e.getMessage()); assertTrue(e.getMessage().length() > 0); @@ -130,7 +132,7 @@ public class ArgumentValidatorTester { @Test public void correctFirstAndRestArgumentTypes_DoesNotThrowException() { - Cons argumentList = new Cons(Symbol.T, new Cons(Nil.getInstance(), Nil.getInstance())); + Cons argumentList = new Cons(T, new Cons(NIL, NIL)); validator.setFirstArgumentExpectedType(Symbol.class); validator.setTrailingArgumentExpectedType(Cons.class); @@ -139,7 +141,7 @@ public class ArgumentValidatorTester { @Test(expected = BadArgumentTypeException.class) public void badFirstArgumentType_ThrowsException() { - Cons argumentList = new Cons(Symbol.T, new Cons(Nil.getInstance(), Nil.getInstance())); + Cons argumentList = new Cons(T, new Cons(NIL, NIL)); validator.setFirstArgumentExpectedType(Cons.class); validator.setTrailingArgumentExpectedType(Cons.class); @@ -148,7 +150,7 @@ public class ArgumentValidatorTester { @Test(expected = BadArgumentTypeException.class) public void badTrailingArgumentType_ThrowsException() { - Cons argumentList = new Cons(Symbol.T, new Cons(Nil.getInstance(), Nil.getInstance())); + Cons argumentList = new Cons(T, new Cons(NIL, NIL)); validator.setFirstArgumentExpectedType(Symbol.class); validator.setTrailingArgumentExpectedType(Symbol.class); @@ -157,7 +159,7 @@ public class ArgumentValidatorTester { @Test public void expectedTypeWithNoDisplayName_DoesNotCauseNPE() { - Cons argumentList = new Cons(Symbol.T, new Cons(Nil.getInstance(), Nil.getInstance())); + Cons argumentList = new Cons(T, new Cons(NIL, NIL)); SExpression withoutDisplayName = new SExpression() {}; validator.setEveryArgumentExpectedType(withoutDisplayName.getClass()); @@ -172,28 +174,28 @@ public class ArgumentValidatorTester { @Test(expected = DottedArgumentListException.class) public void givenDottedArgumentList_ThrowsException() { - Cons argumentList = new Cons(Symbol.T, Symbol.T); + Cons argumentList = new Cons(T, T); validator.validate(argumentList); } @Test(expected = DottedArgumentListException.class) public void givenLargeDottedArgumentList_ThrowsException() { - Cons argumentList = new Cons(Symbol.T, new Cons(Symbol.T, Symbol.T)); + Cons argumentList = new Cons(T, new Cons(T, T)); validator.validate(argumentList); } @Test public void DottedArgumentListException_HasCorrectSeverity() { - DottedArgumentListException e = new DottedArgumentListException("TEST", Nil.getInstance()); + DottedArgumentListException e = new DottedArgumentListException("TEST", NIL); assertEquals(ERROR, e.getSeverity()); } @Test public void dottedArgumentListException_HasMessageText() { - DottedArgumentListException e = new DottedArgumentListException("TEST", Nil.getInstance()); + DottedArgumentListException e = new DottedArgumentListException("TEST", NIL); assertNotNull(e.getMessage()); assertTrue(e.getMessage().length() > 0); @@ -202,19 +204,19 @@ public class ArgumentValidatorTester { @Test(expected = BadArgumentTypeException.class) public void doNotAcceptNil_ThrowsExceptionOnNilArgument() { validator.doNotAcceptNil(); - validator.validate(new Cons(Symbol.T, new Cons(Nil.getInstance(), Nil.getInstance()))); + validator.validate(new Cons(T, new Cons(NIL, NIL))); } @Test public void doNotAcceptNil_AllowsEmptyArgumentList() { validator.doNotAcceptNil(); - validator.validate(Nil.getInstance()); + validator.validate(NIL); } @Test public void doNotAcceptNil_AllowsProperList() { validator.doNotAcceptNil(); - validator.validate(new Cons(Symbol.T, new Cons(Symbol.T, Nil.getInstance()))); + validator.validate(new Cons(T, new Cons(T, NIL))); } } diff --git a/test/function/UserDefinedFunctionTester.java b/test/function/UserDefinedFunctionTester.java index 980e880..e93736f 100644 --- a/test/function/UserDefinedFunctionTester.java +++ b/test/function/UserDefinedFunctionTester.java @@ -1,6 +1,7 @@ package function; import static org.junit.Assert.*; +import static sexpression.Nil.NIL; import static testutil.TestUtilities.assertSExpressionsMatch; import org.junit.Test; @@ -15,27 +16,24 @@ public class UserDefinedFunctionTester { private static final String FUNCTION_NAME = "TEST"; private UserDefinedFunction createNoArgumentFunctionThatReturnsNil() { - return new UserDefinedFunction(FUNCTION_NAME, Nil.getInstance(), - new Cons(Nil.getInstance(), Nil.getInstance())); + return new UserDefinedFunction(FUNCTION_NAME, NIL, new Cons(NIL, NIL)); } private UserDefinedFunction createOneArgumentFunctionThatReturnsArgument() { - return new UserDefinedFunction(FUNCTION_NAME, new Cons(new Symbol("X"), Nil.getInstance()), - new Cons(new Symbol("X"), Nil.getInstance())); + return new UserDefinedFunction(FUNCTION_NAME, new Cons(new Symbol("X"), NIL), new Cons(new Symbol("X"), NIL)); } @Test public void nilFunctionCall() { UserDefinedFunction function = createNoArgumentFunctionThatReturnsNil(); - assertEquals(Nil.getInstance(), function.call(Nil.getInstance())); + assertEquals(NIL, function.call(NIL)); } @Test public void nilFunctionToString() { UserDefinedFunction function = createNoArgumentFunctionThatReturnsNil(); - Cons expected = new Cons(new Symbol(FUNCTION_NAME), - new Cons(Nil.getInstance(), new Cons(Nil.getInstance(), Nil.getInstance()))); + Cons expected = new Cons(new Symbol(FUNCTION_NAME), new Cons(NIL, new Cons(NIL, NIL))); assertSExpressionsMatch(expected, function.getLambdaExpression()); } @@ -44,7 +42,7 @@ public class UserDefinedFunctionTester { public void oneArgumentFunction_ReturnsCorrectValue() { UserDefinedFunction function = createOneArgumentFunctionThatReturnsArgument(); SExpression argument = new LispNumber("23"); - Cons argumentList = new Cons(argument, Nil.getInstance()); + Cons argumentList = new Cons(argument, NIL); assertSExpressionsMatch(argument, function.call(argumentList)); } @@ -53,7 +51,7 @@ public class UserDefinedFunctionTester { public void oneArgumentFunction_ThrowsExceptionWithTooManyArguments() { UserDefinedFunction function = createOneArgumentFunctionThatReturnsArgument(); SExpression argument = new LispNumber("23"); - Cons argumentList = new Cons(argument, new Cons(argument, Nil.getInstance())); + Cons argumentList = new Cons(argument, new Cons(argument, NIL)); function.call(argumentList); } @@ -62,13 +60,12 @@ public class UserDefinedFunctionTester { public void oneArgumentFunction_ThrowsExceptionWithTooFewArguments() { UserDefinedFunction function = createOneArgumentFunctionThatReturnsArgument(); - function.call(Nil.getInstance()); + function.call(NIL); } @Test public void illegalKeywordRestPositionException_HasCorrectAttributes() { - IllegalKeywordRestPositionException e = new IllegalKeywordRestPositionException(FUNCTION_NAME, - Nil.getInstance()); + IllegalKeywordRestPositionException e = new IllegalKeywordRestPositionException(FUNCTION_NAME, NIL); assertNotNull(e.getMessage()); assertTrue(e.getMessage().length() > 0); diff --git a/test/function/builtin/APPLYTester.java b/test/function/builtin/APPLYTester.java index 90a4aa0..d88ca4e 100644 --- a/test/function/builtin/APPLYTester.java +++ b/test/function/builtin/APPLYTester.java @@ -1,5 +1,6 @@ package function.builtin; +import static function.builtin.APPLY.apply; import static testutil.TestUtilities.*; import org.junit.Test; @@ -11,56 +12,56 @@ import sexpression.Cons; public class APPLYTester { @Test - public void testApply() { + public void applyWithSymbol() { String input = "(apply '+ '(1 2 3))"; assertSExpressionsMatch(parseString("6"), evaluateString(input)); } @Test - public void testApplyWithLambdaExpression() { + public void applyWithLambdaExpression() { String input = "(apply (lambda (x) (+ x 1)) '(25))"; assertSExpressionsMatch(parseString("26"), evaluateString(input)); } @Test - public void testApplyWithQuotedLambdaExpression() { + public void applyWithQuotedLambdaExpression() { String input = "(apply '(lambda (x) (+ x 1)) '(25))"; assertSExpressionsMatch(parseString("26"), evaluateString(input)); } @Test - public void testStaticApplyCall() { + public void staticApplyCall() { String argumentList = "(+ (25 10))"; Cons parsedArgumentList = (Cons) parseString(argumentList); - assertSExpressionsMatch(parseString("35"), APPLY.apply(parsedArgumentList)); + assertSExpressionsMatch(parseString("35"), apply(parsedArgumentList)); } @Test(expected = UndefinedFunctionException.class) - public void testApplyWithUndefinedFunction() { + public void applyWithUndefinedFunction() { evaluateString("(apply 'f '(1 2 3))"); } @Test(expected = BadArgumentTypeException.class) - public void testApplyWithNonListSecondArgument() { + public void applyWithNonListSecondArgument() { evaluateString("(apply '+ '2)"); } @Test(expected = TooManyArgumentsException.class) - public void testApplyWithTooManyArguments() { + public void applyWithTooManyArguments() { evaluateString("(apply '1 '2 '3)"); } @Test(expected = TooFewArgumentsException.class) - public void testApplyWithTooFewArguments() { + public void applyWithTooFewArguments() { evaluateString("(apply '1)"); } @Test(expected = DottedArgumentListException.class) - public void testCondWithDottedArgumentList_ThrowsException() { + public void applyWithDottedArgumentList_ThrowsException() { evaluateString("(apply 'apply (cons 'T 'T))"); } diff --git a/test/function/builtin/EVALTester.java b/test/function/builtin/EVALTester.java index 1e9e77b..6635a44 100644 --- a/test/function/builtin/EVALTester.java +++ b/test/function/builtin/EVALTester.java @@ -1,87 +1,88 @@ package function.builtin; +import static function.builtin.EVAL.lookupSymbol; import static org.junit.Assert.*; +import static sexpression.Nil.NIL; import static testutil.TestUtilities.*; import org.junit.Test; import function.ArgumentValidator.*; import function.builtin.EVAL.*; -import sexpression.Nil; public class EVALTester { @Test - public void testEval() { + public void evalNumber() { String input = "(eval 9)"; assertSExpressionsMatch(parseString("9"), evaluateString(input)); } @Test - public void testEvalNil() { + public void evalNil() { String input = "(eval ())"; assertSExpressionsMatch(parseString("()"), evaluateString(input)); } @Test - public void testLookupSymbol() { + public void lookupKeywordSymbol() { String symbol = ":symbol"; - assertSExpressionsMatch(parseString(symbol), EVAL.lookupSymbol(symbol)); + assertSExpressionsMatch(parseString(symbol), lookupSymbol(symbol)); } @Test - public void testLookupT() { + public void lookupT() { String symbol = "T"; - assertSExpressionsMatch(parseString(symbol), EVAL.lookupSymbol(symbol)); + assertSExpressionsMatch(parseString(symbol), lookupSymbol(symbol)); } @Test - public void testLookupNil() { + public void lookupNil() { String symbol = "NIL"; - assertSExpressionsMatch(parseString(symbol), EVAL.lookupSymbol(symbol)); + assertSExpressionsMatch(parseString(symbol), lookupSymbol(symbol)); } @Test - public void testLookupUndefinedSymbol() { + public void lookupUndefinedSymbol() { assertNull(EVAL.lookupSymbol("undefined")); } @Test(expected = UndefinedFunctionException.class) - public void testEvalUndefinedFunction() { + public void evalUndefinedFunction() { String input = "(funcall 'eval '(undefined))"; evaluateString(input); } @Test(expected = UndefinedSymbolException.class) - public void testEvalUndefinedSymbol() { + public void evalUndefinedSymbol() { String input = "(eval undefined)"; evaluateString(input); } @Test(expected = DottedArgumentListException.class) - public void testEvalWithDottedLambdaList() { + public void evalWithDottedLambdaList() { String input = "(funcall 'eval (cons '+ 1))"; evaluateString(input); } @Test(expected = TooManyArgumentsException.class) - public void testEvalWithTooManyArguments() { + public void evalWithTooManyArguments() { evaluateString("(eval '1 '2 '3)"); } @Test(expected = TooFewArgumentsException.class) - public void testEvalWithTooFewArguments() { + public void evalWithTooFewArguments() { evaluateString("(eval)"); } @Test public void undefinedFunctionException_HasMessageText() { - UndefinedFunctionException e = new UndefinedFunctionException(Nil.getInstance()); + UndefinedFunctionException e = new UndefinedFunctionException(NIL); assertNotNull(e.getMessage()); assertTrue(e.getMessage().length() > 0); @@ -89,7 +90,7 @@ public class EVALTester { @Test public void undefinedSymbolException_HasMessageText() { - UndefinedSymbolException e = new UndefinedSymbolException(Nil.getInstance()); + UndefinedSymbolException e = new UndefinedSymbolException(NIL); assertNotNull(e.getMessage()); assertTrue(e.getMessage().length() > 0); diff --git a/test/function/builtin/EXITTester.java b/test/function/builtin/EXITTester.java index 4964402..0c41e5d 100644 --- a/test/function/builtin/EXITTester.java +++ b/test/function/builtin/EXITTester.java @@ -41,7 +41,7 @@ public class EXITTester { } @Test(expected = TooManyArgumentsException.class) - public void testExitWithTooManyArguments() { + public void exitWithTooManyArguments() { evaluateString("(exit 1)"); } diff --git a/test/function/builtin/FUNCALLTester.java b/test/function/builtin/FUNCALLTester.java index 7c2d676..9a37d4c 100644 --- a/test/function/builtin/FUNCALLTester.java +++ b/test/function/builtin/FUNCALLTester.java @@ -20,14 +20,14 @@ public class FUNCALLTester { } @Test - public void testFuncallWithNumbers() { + public void funcallWithNumbers() { String input = "(funcall '+ 1 2 3)"; assertSExpressionsMatch(parseString("6"), evaluateString(input)); } @Test - public void testFuncallWithUserDefinedFunction() { + public void funcallWithUserDefinedFunction() { String defineUserFunction = "(defun x (n m) (+ n m))"; String input = "(funcall 'x 2 30)"; @@ -36,7 +36,7 @@ public class FUNCALLTester { } @Test(expected = TooFewArgumentsException.class) - public void testFuncallWithTooFewArguments() { + public void funcallWithTooFewArguments() { evaluateString("(funcall)"); } diff --git a/test/function/builtin/LOADTester.java b/test/function/builtin/LOADTester.java index cb4b6dc..5041cdc 100644 --- a/test/function/builtin/LOADTester.java +++ b/test/function/builtin/LOADTester.java @@ -75,17 +75,17 @@ public class LOADTester { } @Test(expected = BadArgumentTypeException.class) - public void testLoadWithBadArgumentType() { + public void loadWithBadArgumentType() { evaluateString("(load '1)"); } @Test(expected = TooManyArgumentsException.class) - public void testLoadWithTooManyArguments() { + public void loadWithTooManyArguments() { evaluateString("(load \"1\" \"2\")"); } @Test(expected = TooFewArgumentsException.class) - public void testLoadWithTooFewArguments() { + public void loadWithTooFewArguments() { evaluateString("(load)"); } diff --git a/test/function/builtin/PRINTTester.java b/test/function/builtin/PRINTTester.java index 2bce16d..e802fcb 100644 --- a/test/function/builtin/PRINTTester.java +++ b/test/function/builtin/PRINTTester.java @@ -42,12 +42,12 @@ public class PRINTTester { } @Test(expected = TooManyArgumentsException.class) - public void testPrintWithTooManyArguments() { + public void printWithTooManyArguments() { evaluateString("(print '1 '2)"); } @Test(expected = TooFewArgumentsException.class) - public void testPrintWithTooFewArguments() { + public void printWithTooFewArguments() { evaluateString("(print)"); } diff --git a/test/function/builtin/SETTester.java b/test/function/builtin/SETTester.java index 5ab4d23..9db08ab 100644 --- a/test/function/builtin/SETTester.java +++ b/test/function/builtin/SETTester.java @@ -29,7 +29,7 @@ public class SETTester { } @Test - public void testSet() { + public void set() { evaluateString("(set 'a 23)"); assertSExpressionsMatch(new LispNumber("23"), evaluateString("a")); } @@ -80,17 +80,17 @@ public class SETTester { } @Test(expected = BadArgumentTypeException.class) - public void testSetWithNonSymbol() { + public void setWithNonSymbol() { evaluateString("(set '1 2)"); } @Test(expected = TooFewArgumentsException.class) - public void testSetWithTooFewArguments() { + public void setWithTooFewArguments() { evaluateString("(set 'x)"); } @Test(expected = TooManyArgumentsException.class) - public void testSetWithTooManyArguments() { + public void setWithTooManyArguments() { evaluateString("(set 'a 'b 'c)"); } diff --git a/test/function/builtin/SYMBOL_FUNCTIONTester.java b/test/function/builtin/SYMBOL_FUNCTIONTester.java index 583ce93..5321d14 100644 --- a/test/function/builtin/SYMBOL_FUNCTIONTester.java +++ b/test/function/builtin/SYMBOL_FUNCTIONTester.java @@ -1,13 +1,13 @@ package function.builtin; import static org.junit.Assert.*; +import static sexpression.Nil.NIL; import static testutil.TestUtilities.evaluateString; import org.junit.*; import function.ArgumentValidator.*; import function.builtin.SYMBOL_FUNCTION.UndefinedSymbolFunctionException; -import sexpression.Nil; import table.FunctionTable; public class SYMBOL_FUNCTIONTester { @@ -23,21 +23,21 @@ public class SYMBOL_FUNCTIONTester { } @Test - public void testSymbolFunction_BuiltInFunction() { + public void symbolFunction_BuiltInFunction() { String input = "(symbol-function '+)"; assertEquals("#", evaluateString(input).toString()); } @Test - public void testSymbolFunction_BuiltInSpecialFunction() { + public void symbolFunction_BuiltInSpecialFunction() { String input = "(symbol-function 'if)"; assertEquals("#", evaluateString(input).toString()); } @Test - public void testSymbolFunction_UserDefinedFunction() { + public void symbolFunction_UserDefinedFunction() { String defineUserFunction = "(defun y (n m) (+ n m))"; String input = "(symbol-function 'y)"; @@ -46,30 +46,30 @@ public class SYMBOL_FUNCTIONTester { } @Test(expected = UndefinedSymbolFunctionException.class) - public void testSymbolFunction_NonFunction() { + public void symbolFunction_NonFunction() { String input = "(symbol-function 'a)"; evaluateString(input); } @Test(expected = BadArgumentTypeException.class) - public void testSymbolFunctionWithBadArgumentType() { + public void symbolFunctionWithBadArgumentType() { evaluateString("(symbol-function 2)"); } @Test(expected = TooManyArgumentsException.class) - public void testSymbolFunctionWithTooManyArguments() { + public void symbolFunctionWithTooManyArguments() { evaluateString("(symbol-function 'a 'b)"); } @Test(expected = TooFewArgumentsException.class) - public void testSymbolFunctionWithTooFewArguments() { + public void symbolFunctionWithTooFewArguments() { evaluateString("(symbol-function)"); } @Test public void undefinedSymbolFunctionException_HasMessageText() { - UndefinedSymbolFunctionException e = new UndefinedSymbolFunctionException(Nil.getInstance()); + UndefinedSymbolFunctionException e = new UndefinedSymbolFunctionException(NIL); assertNotNull(e.getMessage()); assertTrue(e.getMessage().length() > 0); diff --git a/test/function/builtin/cons/CONSTester.java b/test/function/builtin/cons/CONSTester.java index 22e1eb2..c6ecaa9 100644 --- a/test/function/builtin/cons/CONSTester.java +++ b/test/function/builtin/cons/CONSTester.java @@ -10,49 +10,49 @@ import sexpression.*; public class CONSTester { @Test - public void testConsWithNilValues() { + public void consWithNilValues() { String input = "(cons () nil)"; assertSExpressionsMatch(parseString("(())"), evaluateString(input)); } @Test - public void testConsWithTwoSymbols() { + public void consWithTwoSymbols() { String input = "(cons 'a 'b)"; assertSExpressionsMatch(new Cons(new Symbol("A"), new Symbol("B")), evaluateString(input)); } @Test - public void testConsWithListAsRest() { + public void consWithListAsRest() { String input = "(cons 1 '(2 3))"; assertSExpressionsMatch(parseString("(1 2 3)"), evaluateString(input)); } @Test - public void testConsWithTwoLists() { + public void consWithTwoLists() { String input = "(cons '(1 2) '(3 4))"; assertSExpressionsMatch(parseString("((1 2) 3 4)"), evaluateString(input)); } @Test - public void testConsWithList() { + public void consWithList() { String input = "(cons nil '(2 3))"; assertSExpressionsMatch(parseString("(nil 2 3)"), evaluateString(input)); } @Test(expected = TooManyArgumentsException.class) - public void testConsWithTooManyArguments() { + public void consWithTooManyArguments() { String input = "(cons 1 2 3)"; evaluateString(input); } @Test(expected = TooFewArgumentsException.class) - public void testConsWithTooFewArguments() { + public void consWithTooFewArguments() { String input = "(cons 1)"; evaluateString(input); diff --git a/test/function/builtin/cons/LENGTHTester.java b/test/function/builtin/cons/LENGTHTester.java index c42ed12..acd53b6 100644 --- a/test/function/builtin/cons/LENGTHTester.java +++ b/test/function/builtin/cons/LENGTHTester.java @@ -9,38 +9,38 @@ import function.ArgumentValidator.*; public class LENGTHTester { @Test - public void testLengthOfNil() { + public void lengthOfNil() { String input = "(length '())"; assertSExpressionsMatch(parseString("0"), evaluateString(input)); } @Test - public void testLengthOfListOfOneElement() { + public void lengthOfListOfOneElement() { String input = "(length '(1))"; assertSExpressionsMatch(parseString("1"), evaluateString(input)); } @Test - public void testLengthOfListOfManyElements() { + public void lengthOfListOfManyElements() { String input = "(length '(1 2 3 4 5))"; assertSExpressionsMatch(parseString("5"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) - public void testLengthWithNonList() { + public void lengthWithNonList() { evaluateString("(length 'x)"); } @Test(expected = TooManyArgumentsException.class) - public void testLengthWithTooManyArguments() { + public void lengthWithTooManyArguments() { evaluateString("(length '(1 2) '(1 2))"); } @Test(expected = TooFewArgumentsException.class) - public void testLengthWithTooFewArguments() { + public void lengthWithTooFewArguments() { evaluateString("(length)"); } diff --git a/test/function/builtin/cons/LISTTester.java b/test/function/builtin/cons/LISTTester.java index 95e591c..a6cb4d8 100644 --- a/test/function/builtin/cons/LISTTester.java +++ b/test/function/builtin/cons/LISTTester.java @@ -1,5 +1,6 @@ package function.builtin.cons; +import static function.builtin.cons.LIST.makeList; import static testutil.TestUtilities.*; import org.junit.Test; @@ -7,50 +8,50 @@ import org.junit.Test; public class LISTTester { @Test - public void testListWithNoArguments() { + public void listWithNoArguments() { String input = "(list)"; assertSExpressionsMatch(parseString("nil"), evaluateString(input)); } @Test - public void testListWithOneArgument() { + public void listWithOneArgument() { String input = "(list 1)"; assertSExpressionsMatch(parseString("(1)"), evaluateString(input)); } @Test - public void testListWithTwoArguments() { + public void listWithTwoArguments() { String input = "(list 2 3)"; assertSExpressionsMatch(parseString("(2 3)"), evaluateString(input)); } @Test - public void testListWithManyArguments() { + public void listWithManyArguments() { String input = "(list 'm 'a 'n 'y 'a 'r 'g 's)"; assertSExpressionsMatch(parseString("(m a n y a r g s)"), evaluateString(input)); } @Test - public void testListWithOneListArgument() { + public void listWithOneListArgument() { String input = "(list '(1))"; assertSExpressionsMatch(parseString("((1))"), evaluateString(input)); } @Test - public void testListWithManyListArguments() { + public void listWithManyListArguments() { String input = "(list '(1) '(2 3) ())"; assertSExpressionsMatch(parseString("((1) (2 3) ())"), evaluateString(input)); } @Test - public void testMakeList() { - assertSExpressionsMatch(parseString("(22)"), LIST.makeList(parseString("22"))); + public void staticMakeList() { + assertSExpressionsMatch(parseString("(22)"), makeList(parseString("22"))); } } diff --git a/test/function/builtin/math/DIVIDETester.java b/test/function/builtin/math/DIVIDETester.java index ebe778b..41c9775 100644 --- a/test/function/builtin/math/DIVIDETester.java +++ b/test/function/builtin/math/DIVIDETester.java @@ -9,54 +9,54 @@ import function.ArgumentValidator.*; public class DIVIDETester { @Test - public void testDivideWithOne() { + public void divideWithOne() { String input = "(/ 1)"; assertSExpressionsMatch(parseString("1"), evaluateString(input)); } @Test - public void testDivideWithTwo() { + public void divideWithTwo() { String input = "(/ 2)"; assertSExpressionsMatch(parseString("0"), evaluateString(input)); } @Test - public void testDivideTwoNumbers() { + public void divideTwoNumbers() { String input = "(/ 24 3)"; assertSExpressionsMatch(parseString("8"), evaluateString(input)); } @Test - public void testDivideSeveralNumbers() { + public void divideSeveralNumbers() { String input = "(/ 256 2 2 8)"; assertSExpressionsMatch(parseString("8"), evaluateString(input)); } @Test - public void testDivideTwoNumbersWithRemainder() { + public void divideTwoNumbersWithRemainder() { String input = "(/ 9 2)"; assertSExpressionsMatch(parseString("4"), evaluateString(input)); } @Test - public void testDivideSeveralNumbersWithRemainder() { + public void divideSeveralNumbersWithRemainder() { String input = "(/ 19 2 5)"; assertSExpressionsMatch(parseString("1"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) - public void testDivideWithNonNumber() { + public void divideWithNonNumber() { evaluateString("(/ 'x)"); } @Test(expected = TooFewArgumentsException.class) - public void testDivideWithTooFewArguments() { + public void divideWithTooFewArguments() { evaluateString("(/)"); } diff --git a/test/function/builtin/math/MINUSTester.java b/test/function/builtin/math/MINUSTester.java index 0b5fe2e..35184c9 100644 --- a/test/function/builtin/math/MINUSTester.java +++ b/test/function/builtin/math/MINUSTester.java @@ -10,40 +10,40 @@ import sexpression.LispNumber; public class MINUSTester { @Test - public void testMinusWithOneNumber() { + public void minusWithOneNumber() { String input = "(- 27)"; assertSExpressionsMatch(new LispNumber("-27"), evaluateString(input)); } @Test - public void testMinusWithTwoNumbers() { + public void minusWithTwoNumbers() { String input = "(- 5 3)"; assertSExpressionsMatch(new LispNumber("2"), evaluateString(input)); } @Test - public void testMinusWithManyNumbers_PositiveResult() { + public void minusWithManyNumbers_PositiveResult() { String input = "(- 200 100 10 5)"; assertSExpressionsMatch(new LispNumber("85"), evaluateString(input)); } @Test - public void testMinusWithManyNumbers_NegativeResult() { + public void minusWithManyNumbers_NegativeResult() { String input = "(- 100 200 20 5)"; assertSExpressionsMatch(new LispNumber("-125"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) - public void testMinusWithNonNumber() { + public void minusWithNonNumber() { evaluateString("(- 'a 'b)"); } @Test(expected = TooFewArgumentsException.class) - public void testMinusWithTooFewArguments() { + public void minusWithTooFewArguments() { evaluateString("(-)"); } diff --git a/test/function/builtin/math/MULTIPLYTester.java b/test/function/builtin/math/MULTIPLYTester.java index 766470a..397dad6 100644 --- a/test/function/builtin/math/MULTIPLYTester.java +++ b/test/function/builtin/math/MULTIPLYTester.java @@ -10,42 +10,42 @@ import sexpression.LispNumber; public class MULTIPLYTester { @Test - public void testMultiplyWithNoArguments() { + public void multiplyWithNoArguments() { String input = "(*)"; assertSExpressionsMatch(new LispNumber("1"), evaluateString(input)); } @Test - public void testMultiplyWithOneNumber() { + public void multiplyWithOneNumber() { String input = "(* 8)"; assertSExpressionsMatch(new LispNumber("8"), evaluateString(input)); } @Test - public void testMultiplyWithTwoNumbers() { + public void multiplyWithTwoNumbers() { String input = "(* 5 3)"; assertSExpressionsMatch(new LispNumber("15"), evaluateString(input)); } @Test - public void testMultiplyWithManyNumbers_PositiveResult() { + public void multiplyWithManyNumbers_PositiveResult() { String input = "(* 2 3 5 1)"; assertSExpressionsMatch(new LispNumber("30"), evaluateString(input)); } @Test - public void testMultiplyWithManyNumbers_NegativeResult() { + public void multiplyWithManyNumbers_NegativeResult() { String input = "(* 3 (- 2) 10 2)"; assertSExpressionsMatch(new LispNumber("-120"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) - public void testMultiplyWithNonNumber() { + public void multiplyWithNonNumber() { evaluateString("(* 'a 'b)"); } diff --git a/test/function/builtin/math/PLUSTester.java b/test/function/builtin/math/PLUSTester.java index e2c9260..8f2a496 100644 --- a/test/function/builtin/math/PLUSTester.java +++ b/test/function/builtin/math/PLUSTester.java @@ -10,42 +10,42 @@ import sexpression.LispNumber; public class PLUSTester { @Test - public void testPlusWithNoArguments() { + public void plusWithNoArguments() { String input = "(+)"; assertSExpressionsMatch(new LispNumber("0"), evaluateString(input)); } @Test - public void testPlusWithOneNumber() { + public void plusWithOneNumber() { String input = "(+ 27)"; assertSExpressionsMatch(new LispNumber("27"), evaluateString(input)); } @Test - public void testPlusWithTwoNumbers() { + public void plusWithTwoNumbers() { String input = "(+ 5 3)"; assertSExpressionsMatch(new LispNumber("8"), evaluateString(input)); } @Test - public void testPlusWithManyNumbers_PositiveResult() { + public void plusWithManyNumbers_PositiveResult() { String input = "(+ 200 100 10 5)"; assertSExpressionsMatch(new LispNumber("315"), evaluateString(input)); } @Test - public void testPlusWithManyNumbers_NegativeResult() { + public void plusWithManyNumbers_NegativeResult() { String input = "(+ 100 (- 200) 20 5)"; assertSExpressionsMatch(new LispNumber("-75"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) - public void testPlusWithNonNumber() { + public void plusWithNonNumber() { evaluateString("(+ 'a 'b)"); } diff --git a/test/function/builtin/special/LAMBDATester.java b/test/function/builtin/special/LAMBDATester.java index 9dbe5ba..5183048 100644 --- a/test/function/builtin/special/LAMBDATester.java +++ b/test/function/builtin/special/LAMBDATester.java @@ -1,6 +1,9 @@ package function.builtin.special; import static org.junit.Assert.*; +import static sexpression.LispNumber.ONE; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; import static testutil.TestUtilities.*; import org.junit.Test; @@ -26,21 +29,19 @@ public class LAMBDATester { @Test public void lambdaExpressionIsLambdaExpression() { - Cons lambdaExpression = new Cons(new Symbol("LAMBDA"), - new Cons(Nil.getInstance(), new Cons(Nil.getInstance(), Nil.getInstance()))); + Cons lambdaExpression = new Cons(new Symbol("LAMBDA"), new Cons(NIL, new Cons(NIL, NIL))); assertTrue(LAMBDA.isLambdaExpression(lambdaExpression)); } @Test public void somethingElseIsNotLambdaExpression() { - assertFalse(LAMBDA.isLambdaExpression(Symbol.T)); + assertFalse(LAMBDA.isLambdaExpression(T)); } @Test public void createLambdaExpression() { - Cons lambdaExpression = new Cons(new Symbol("LAMBDA"), - new Cons(Nil.getInstance(), new Cons(Nil.getInstance(), Nil.getInstance()))); + Cons lambdaExpression = new Cons(new Symbol("LAMBDA"), new Cons(NIL, new Cons(NIL, NIL))); assertSExpressionsMatch(parseString("(:LAMBDA () ())"), LAMBDA.createFunction(lambdaExpression).getLambdaExpression()); @@ -62,14 +63,14 @@ public class LAMBDATester { @Test(expected = DottedArgumentListException.class) public void createFunctionWithDottedArgumentList() { - Cons lambdaExpression = new Cons(new Symbol("LAMBDA"), new Cons(Nil.getInstance(), LispNumber.ONE)); + Cons lambdaExpression = new Cons(new Symbol("LAMBDA"), new Cons(NIL, ONE)); LAMBDA.createFunction(lambdaExpression); } @Test(expected = BadArgumentTypeException.class) public void createFunctionWithNonList() { - Cons lambdaExpression = new Cons(new Symbol("LAMBDA"), LispNumber.ONE); + Cons lambdaExpression = new Cons(new Symbol("LAMBDA"), ONE); LAMBDA.createFunction(lambdaExpression); } diff --git a/test/function/builtin/special/LETTester.java b/test/function/builtin/special/LETTester.java index 3445959..2cce131 100644 --- a/test/function/builtin/special/LETTester.java +++ b/test/function/builtin/special/LETTester.java @@ -1,12 +1,13 @@ package function.builtin.special; +import static sexpression.Nil.NIL; import static testutil.TestUtilities.*; import org.junit.*; import function.ArgumentValidator.*; import function.builtin.EVAL.UndefinedSymbolException; -import sexpression.*; +import sexpression.LispNumber; import table.ExecutionContext; public class LETTester { @@ -38,7 +39,7 @@ public class LETTester { public void emptyLet_ReturnsNil() { String input = "(let ())"; - assertSExpressionsMatch(Nil.getInstance(), evaluateString(input)); + assertSExpressionsMatch(NIL, evaluateString(input)); } @Test diff --git a/test/parser/LispParserTester.java b/test/parser/LispParserTester.java index fcf4b78..1c438fb 100644 --- a/test/parser/LispParserTester.java +++ b/test/parser/LispParserTester.java @@ -29,7 +29,7 @@ public class LispParserTester { } @Test - public void testEofMethod_ReturnsTrueWithNoInput() { + public void eofMethod_ReturnsTrueWithNoInput() { String input = ""; LispParser parser = createLispParser(input); @@ -37,7 +37,7 @@ public class LispParserTester { } @Test - public void testEofMethod_ReturnsFalseWithSomeInput() { + public void eofMethod_ReturnsFalseWithSomeInput() { String input = "abc"; LispParser parser = createLispParser(input); @@ -45,7 +45,7 @@ public class LispParserTester { } @Test - public void testEofMethod_ReturnsTrueAfterSomeInput() { + public void eofMethod_ReturnsTrueAfterSomeInput() { String input = "(yyz 9 9 9)"; LispParser parser = createLispParser(input); @@ -54,7 +54,7 @@ public class LispParserTester { } @Test - public void testEofMethod_ReturnsFalseAfterMultipleExpressions() { + public void eofMethod_ReturnsFalseAfterMultipleExpressions() { String input = "()()()"; LispParser parser = createLispParser(input); @@ -66,7 +66,7 @@ public class LispParserTester { } @Test - public void testEofMethod_ReturnsTrueAfterMultipleExpressions() { + public void eofMethod_ReturnsTrueAfterMultipleExpressions() { String input = "()()()"; LispParser parser = createLispParser(input); diff --git a/test/sexpression/SExpressionTester.java b/test/sexpression/SExpressionTester.java index d768ce0..5209aa8 100644 --- a/test/sexpression/SExpressionTester.java +++ b/test/sexpression/SExpressionTester.java @@ -2,6 +2,7 @@ package sexpression; import static error.ErrorManager.Severity.ERROR; import static org.junit.Assert.*; +import static sexpression.Nil.NIL; import java.math.BigInteger; @@ -20,59 +21,59 @@ public class SExpressionTester { public void setUp() throws Exception {} @Test - public void testNilToString() { + public void nilToString() { String input = "NIL"; - assertSExpressionMatchesString(input, Nil.getInstance()); + assertSExpressionMatchesString(input, NIL); } @Test - public void testNumberToString() { + public void numberToString() { String input = "12"; assertSExpressionMatchesString(input, new LispNumber(input)); } @Test - public void testNumberValueToString() { + public void numberValueToString() { String expected = "12"; assertSExpressionMatchesString(expected, new LispNumber("12")); } @Test - public void testStringToString() { + public void stringToString() { String input = "\"hi\""; assertSExpressionMatchesString(input, new LispString(input)); } @Test - public void testSymbolToString() { + public void symbolToString() { String input = "symbol"; assertSExpressionMatchesString(input.toUpperCase(), new Symbol(input)); } @Test - public void testSimpleConsToString() { + public void simpleConsToString() { String expected = "(1)"; - Cons cons = new Cons(new LispNumber("1"), Nil.getInstance()); + Cons cons = new Cons(new LispNumber("1"), NIL); assertSExpressionMatchesString(expected, cons); } @Test - public void testComplexConsToString() { + public void complexConsToString() { String expected = "(1 A \"string\")"; Cons list = new Cons(new LispNumber("1"), - new Cons(new Symbol("a"), new Cons(new LispString("\"string\""), Nil.getInstance()))); + new Cons(new Symbol("a"), new Cons(new LispString("\"string\""), NIL))); assertSExpressionMatchesString(expected, list); } @Test - public void testImproperListToString() { + public void improperListToString() { String expected = "(A . B)"; Cons list = new Cons(new Symbol("A"), new Symbol("B")); @@ -80,58 +81,58 @@ public class SExpressionTester { } @Test - public void testLambdaExpressionToString() { + public void lambdaExpressionToString() { String expected = "(LAMBDA)"; - LambdaExpression lambda = new LambdaExpression(new Cons(new Symbol("lambda"), Nil.getInstance()), null); + LambdaExpression lambda = new LambdaExpression(new Cons(new Symbol("lambda"), NIL), null); assertSExpressionMatchesString(expected, lambda); } @Test - public void testLambdaExpressionGetLambdaExpression() { + public void lambdaExpressionGetLambdaExpression() { String expected = "(LAMBDA)"; - LambdaExpression lambda = new LambdaExpression(new Cons(new Symbol("lambda"), Nil.getInstance()), null); + LambdaExpression lambda = new LambdaExpression(new Cons(new Symbol("lambda"), NIL), null); assertSExpressionMatchesString(expected, lambda.getLambdaExpression()); } @Test - public void testLambdaExpressionGetFunction() { + public void lambdaExpressionGetFunction() { String expected = "(LAMBDA)"; - UserDefinedFunction function = new UserDefinedFunction(expected, Nil.getInstance(), Nil.getInstance()); - LambdaExpression lambda = new LambdaExpression(new Cons(new Symbol("lambda"), Nil.getInstance()), function); + UserDefinedFunction function = new UserDefinedFunction(expected, NIL, NIL); + LambdaExpression lambda = new LambdaExpression(new Cons(new Symbol("lambda"), NIL), function); assertEquals(function, lambda.getFunction()); } @Test - public void testFirstOfNilIsNil() { - assertEquals(Nil.getInstance(), Nil.getInstance().getFirst()); + public void firstOfNilIsNil() { + assertEquals(NIL, NIL.getFirst()); } @Test - public void testRestOfNilIsNil() { - assertEquals(Nil.getInstance(), Nil.getInstance().getRest()); + public void restOfNilIsNil() { + assertEquals(NIL, NIL.getRest()); } @Test public void afterSettingFirstOfNil_ShouldStillBeNil() { - Cons nil = Nil.getInstance(); + Cons nil = NIL; nil.setFirst(new LispNumber("2")); - assertEquals(Nil.getInstance(), nil.getFirst()); + assertEquals(NIL, nil.getFirst()); } @Test public void afterSettingRestOfNil_ShouldStillBeNil() { - Cons nil = Nil.getInstance(); + Cons nil = NIL; nil.setRest(new LispNumber("2")); - assertEquals(Nil.getInstance(), nil.getRest()); + assertEquals(NIL, nil.getRest()); } @Test - public void testNumberValue() { + public void numberValue() { BigInteger value = new BigInteger("12"); LispNumber number = new LispNumber(value.toString()); @@ -139,12 +140,12 @@ public class SExpressionTester { } @Test(expected = InvalidNumberException.class) - public void testInvalidNumberText_ThrowsException() { + public void invalidNumberText_ThrowsException() { new LispNumber("a"); } @Test - public void testInvalidNumberException_HasCorrectSeverity() { + public void invalidNumberException_HasCorrectSeverity() { try { new LispNumber("a"); } catch (InvalidNumberException e) { @@ -153,7 +154,7 @@ public class SExpressionTester { } @Test - public void testInvalidNumberException_HasMessageText() { + public void invalidNumberException_HasMessageText() { try { new LispNumber("a"); } catch (InvalidNumberException e) { @@ -165,7 +166,7 @@ public class SExpressionTester { } @Test - public void testLispNumberConstants() { + public void lispNumberConstants() { assertEquals(BigInteger.ZERO, LispNumber.ZERO.getValue()); assertEquals(BigInteger.ONE, LispNumber.ONE.getValue()); } diff --git a/test/table/ExecutionContextTester.java b/test/table/ExecutionContextTester.java index 2da0d9e..c875de0 100644 --- a/test/table/ExecutionContextTester.java +++ b/test/table/ExecutionContextTester.java @@ -1,11 +1,11 @@ package table; import static org.junit.Assert.*; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; import org.junit.*; -import sexpression.*; - public class ExecutionContextTester { private ExecutionContext executionContext; @@ -45,40 +45,40 @@ public class ExecutionContextTester { @Test public void lookupVariable() { - executionContext.getScope().put("test", Symbol.T); + executionContext.getScope().put("test", T); - assertEquals(Symbol.T, executionContext.lookupSymbolValue("test")); + assertEquals(T, executionContext.lookupSymbolValue("test")); } @Test public void lookupLocalVariable() { SymbolTable scope = new SymbolTable(executionContext.getScope()); - scope.put("local", Symbol.T); + scope.put("local", T); executionContext.setScope(scope); - assertEquals(Symbol.T, executionContext.lookupSymbolValue("local")); + assertEquals(T, executionContext.lookupSymbolValue("local")); } @Test public void lookupGlobalVariable() { SymbolTable scope = new SymbolTable(executionContext.getScope()); - executionContext.getScope().put("global", Symbol.T); + executionContext.getScope().put("global", T); executionContext.setScope(scope); - assertEquals(Symbol.T, executionContext.lookupSymbolValue("global")); + assertEquals(T, executionContext.lookupSymbolValue("global")); } @Test public void lookupShadowedVariable() { SymbolTable scope = new SymbolTable(executionContext.getScope()); - scope.put("shadowed", Nil.getInstance()); - executionContext.getScope().put("shadowed", Symbol.T); + scope.put("shadowed", NIL); + executionContext.getScope().put("shadowed", T); executionContext.setScope(scope); - assertEquals(Nil.getInstance(), executionContext.lookupSymbolValue("shadowed")); + assertEquals(NIL, executionContext.lookupSymbolValue("shadowed")); } } diff --git a/test/table/FunctionTableTester.java b/test/table/FunctionTableTester.java index 91e2896..8293003 100644 --- a/test/table/FunctionTableTester.java +++ b/test/table/FunctionTableTester.java @@ -1,6 +1,8 @@ package table; import static org.junit.Assert.*; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; import java.util.*; @@ -18,7 +20,7 @@ public class FunctionTableTester { @Override public SExpression call(Cons argList) { - return Nil.getInstance(); + return NIL; } } @@ -31,15 +33,15 @@ public class FunctionTableTester { @Override public SExpression call(Cons argList) { - return Nil.getInstance(); + return NIL; } } - public static class NamelessFunction extends LispFunction { + public static class UglyFunction extends LispFunction { @Override public SExpression call(Cons argList) { - return Nil.getInstance(); + return NIL; } } @@ -48,7 +50,7 @@ public class FunctionTableTester { @Override public SExpression call(Cons argList) { - return Symbol.T; + return T; } }; } @@ -140,12 +142,12 @@ public class FunctionTableTester { @Test public void namelessBuiltIn_DoesNotCauseNPE() { Set> namelessBuiltins = new HashSet<>(); - namelessBuiltins.add(NamelessFunction.class); + namelessBuiltins.add(UglyFunction.class); FunctionTable.reset(namelessBuiltins); - assertFalse(FunctionTable.isAlreadyDefined("NAMELESS")); - assertNull(FunctionTable.lookupFunction("NAMELESS")); + assertFalse(FunctionTable.isAlreadyDefined("UGLY")); + assertNull(FunctionTable.lookupFunction("UGLY")); } } diff --git a/test/table/SymbolTableTester.java b/test/table/SymbolTableTester.java index 85f98b4..f5291ce 100644 --- a/test/table/SymbolTableTester.java +++ b/test/table/SymbolTableTester.java @@ -1,11 +1,11 @@ package table; import static org.junit.Assert.*; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; import org.junit.*; -import sexpression.*; - public class SymbolTableTester { private SymbolTable symbolTable; @@ -22,24 +22,24 @@ public class SymbolTableTester { @Test public void lookupSymbolInTable() { - symbolTable.put("symbol", Symbol.T); + symbolTable.put("symbol", T); assertTrue(symbolTable.contains("symbol")); } @Test public void retrieveSymbolValue() { - symbolTable.put("symbol", Symbol.T); + symbolTable.put("symbol", T); - assertEquals(Symbol.T, symbolTable.get("symbol")); + assertEquals(T, symbolTable.get("symbol")); } @Test public void redefineSymbolValue() { - symbolTable.put("symbol", Symbol.T); - symbolTable.put("symbol", Nil.getInstance()); + symbolTable.put("symbol", T); + symbolTable.put("symbol", NIL); - assertEquals(Nil.getInstance(), symbolTable.get("symbol")); + assertEquals(NIL, symbolTable.get("symbol")); } @Test @@ -51,11 +51,11 @@ public class SymbolTableTester { @Test public void lookupSymbolInParentTable() { - symbolTable.put("symbol", Symbol.T); + symbolTable.put("symbol", T); SymbolTable childTable = new SymbolTable(symbolTable); SymbolTable parentTable = childTable.getParent(); - assertEquals(Symbol.T, parentTable.get("symbol")); + assertEquals(T, parentTable.get("symbol")); } } diff --git a/test/testutil/TypeAssertions.java b/test/testutil/TypeAssertions.java index a00a756..cb78f56 100644 --- a/test/testutil/TypeAssertions.java +++ b/test/testutil/TypeAssertions.java @@ -1,8 +1,10 @@ package testutil; import static org.junit.Assert.*; +import static sexpression.Nil.NIL; +import static sexpression.Symbol.T; -import sexpression.*; +import sexpression.SExpression; public final class TypeAssertions { @@ -18,7 +20,7 @@ public final class TypeAssertions { } public static void assertNil(SExpression sExpression) { - assertEquals(Nil.getInstance(), sExpression); + assertEquals(NIL, sExpression); assertTrue(sExpression.isAtom()); assertFalse(sExpression.isCons()); @@ -65,7 +67,7 @@ public final class TypeAssertions { } public static void assertT(SExpression sExpression) { - assertEquals(Symbol.T, sExpression); + assertEquals(T, sExpression); } } diff --git a/test/token/TokenFactoryTester.java b/test/token/TokenFactoryTester.java index 651678c..f374656 100644 --- a/test/token/TokenFactoryTester.java +++ b/test/token/TokenFactoryTester.java @@ -26,65 +26,65 @@ public class TokenFactoryTester { } @Test - public void testEofTokenCreation() { + public void eofTokenCreation() { assertTrue(tokenFactory.createEofToken(testPosition) instanceof Eof); } @Test - public void testLeftParenthesisCreation() { + public void leftParenthesisCreation() { String text = "("; assertTrue(createToken(text) instanceof LeftParenthesis); } @Test - public void testRightParenthesisCreation() { + public void rightParenthesisCreation() { String text = ")"; assertTrue(createToken(text) instanceof RightParenthesis); } @Test - public void testQuoteMarkCreation() { + public void quoteMarkCreation() { String text = "'"; assertTrue(createToken(text) instanceof QuoteMark); } @Test - public void testNumberCreation() { + public void numberCreation() { String text = "987"; assertTrue(createToken(text) instanceof Number); } @Test - public void testPrefixedNumberCreation() { + public void prefixedNumberCreation() { String text = "-987"; assertTrue(createToken(text) instanceof Number); } @Test - public void testIdentifierCreation() { + public void identifierCreation() { String text = "identifier"; assertTrue(createToken(text) instanceof Identifier); } @Test - public void testPrefixedIdentifierCreation() { + public void prefixedIdentifierCreation() { String text = "-identifier"; assertTrue(createToken(text) instanceof Identifier); } @Test - public void testStringCreation() { + public void stringCreation() { String text = "\"string\""; assertTrue(createToken(text) instanceof QuotedString); } @Test(expected = EmptyTokenTextException.class) - public void testEmptyString_ThrowsException() { + public void emptyString_ThrowsException() { createToken(""); } @Test - public void EmptyTokenTextException_ContainsCorrectSeverity() { + public void emptyTokenTextException_ContainsCorrectSeverity() { try { createToken(""); } catch (EmptyTokenTextException e) { @@ -93,7 +93,7 @@ public class TokenFactoryTester { } @Test - public void EmptyTokenTextException_ContainsMessage() { + public void emptyTokenTextException_ContainsMessage() { try { createToken(""); } catch (EmptyTokenTextException e) { @@ -104,7 +104,7 @@ public class TokenFactoryTester { } @Test(expected = BadCharacterException.class) - public void testBadCharacter_ThrowsException() { + public void badCharacter_ThrowsException() { createToken("[abc]"); } diff --git a/test/util/CharactersTester.java b/test/util/CharactersTester.java index 8de40c6..4f413e3 100644 --- a/test/util/CharactersTester.java +++ b/test/util/CharactersTester.java @@ -9,7 +9,7 @@ import org.junit.Test; public class CharactersTester { @Test - public void testConstructorIsPrivate() throws Exception { + public void constructorIsPrivate() throws Exception { Constructor constructor = Characters.class.getDeclaredConstructor(); assertTrue(Modifier.isPrivate(constructor.getModifiers()));