From 49e145d098a8c7162213dd87998dae5610039182 Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Sun, 26 Feb 2017 12:39:08 -0500 Subject: [PATCH] Cleaned up some code --- src/interpreter/LispInterpreter.java | 2 +- src/interpreter/LispInterpreterBuilder.java | 4 ++-- .../LispInterpreterBuilderImpl.java | 2 +- .../LispInterpreterBuilderTester.java | 20 ++++++++++++++----- test/main/MainTester.java | 8 -------- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/interpreter/LispInterpreter.java b/src/interpreter/LispInterpreter.java index 9d42e57..7449b06 100644 --- a/src/interpreter/LispInterpreter.java +++ b/src/interpreter/LispInterpreter.java @@ -21,7 +21,7 @@ public class LispInterpreter { this.errorManager = this.environment.getErrorManager(); this.output = environment.getOutput(); } - + public void setInput(InputStream input, String inputName) { environment.setInput(input); environment.setInputName(inputName); diff --git a/src/interpreter/LispInterpreterBuilder.java b/src/interpreter/LispInterpreterBuilder.java index 801324e..e37f819 100644 --- a/src/interpreter/LispInterpreterBuilder.java +++ b/src/interpreter/LispInterpreterBuilder.java @@ -29,8 +29,8 @@ public interface LispInterpreterBuilder { void setCriticalOutputDecorator(Function criticalOutputDecorator); - default void reset() {} - LispInterpreter build(); + default void reset() {} + } diff --git a/src/interpreter/LispInterpreterBuilderImpl.java b/src/interpreter/LispInterpreterBuilderImpl.java index 76b7486..197f299 100644 --- a/src/interpreter/LispInterpreterBuilderImpl.java +++ b/src/interpreter/LispInterpreterBuilderImpl.java @@ -158,7 +158,7 @@ public class LispInterpreterBuilderImpl implements LispInterpreterBuilder { private LispInterpreter createInterpreter() { return isInteractive ? new InteractiveLispInterpreter() : new LispInterpreter(); } - + public static class InterpreterAlreadyBuiltException extends CriticalLispException { private static final long serialVersionUID = 1L; diff --git a/test/interpreter/LispInterpreterBuilderTester.java b/test/interpreter/LispInterpreterBuilderTester.java index c0cfb34..e0fa3df 100644 --- a/test/interpreter/LispInterpreterBuilderTester.java +++ b/test/interpreter/LispInterpreterBuilderTester.java @@ -67,12 +67,22 @@ public class LispInterpreterBuilderTester { builder.build(); builder.build(); } - + + @Test public void interpreterAlreadyBuiltException_HasMessage() { - InterpreterAlreadyBuiltException e = new InterpreterAlreadyBuiltException(); - - assertNotNull(e.getMessage()); - assertTrue(e.getMessage().length() > 0); + InterpreterAlreadyBuiltException e = new InterpreterAlreadyBuiltException(); + + assertNotNull(e.getMessage()); + assertTrue(e.getMessage().length() > 0); + } + + @Test(expected = InterpreterAlreadyBuiltException.class) + public void resetNormallyDoesNothing() { + builder = new LispInterpreterBuilderImpl(); + + builder.build(); + builder.reset(); + builder.build(); } } diff --git a/test/main/MainTester.java b/test/main/MainTester.java index 05c7b33..db401e4 100644 --- a/test/main/MainTester.java +++ b/test/main/MainTester.java @@ -1,10 +1,7 @@ package main; -import static org.junit.Assert.*; - import org.junit.*; - public class MainTester { @Before @@ -13,9 +10,4 @@ public class MainTester { @After public void tearDown() throws Exception {} - @Test - public void test() { - fail("Not yet implemented"); - } - }