Refactor common test set up and tear down code
This commit is contained in:
parent
84ccac0edb
commit
c8c9a477b7
|
@ -8,8 +8,9 @@ import org.junit.Test;
|
|||
import function.ArgumentValidator.*;
|
||||
import function.builtin.EVAL.UndefinedFunctionException;
|
||||
import sexpression.Cons;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class APPLYTest {
|
||||
public class APPLYTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void applyWithSymbol() {
|
||||
|
|
|
@ -10,8 +10,9 @@ import org.junit.Test;
|
|||
import function.ArgumentValidator.*;
|
||||
import function.builtin.BackquoteEvaluator.AtSignNotInCommaException;
|
||||
import function.builtin.EVAL.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class EVALTest {
|
||||
public class EVALTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void evalNumber() {
|
||||
|
|
|
@ -5,12 +5,13 @@ import static testutil.TestUtilities.evaluateString;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import environment.RuntimeEnvironment;
|
||||
import function.ArgumentValidator.TooManyArgumentsException;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class EXITTest {
|
||||
public class EXITTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
private static final String TERMINATED = "terminated";
|
||||
private RuntimeEnvironment environment;
|
||||
|
@ -28,15 +29,15 @@ public class EXITTest {
|
|||
assertFalse(indicatorSet.contains(TERMINATED));
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@Override
|
||||
public void additionalSetUp() {
|
||||
indicatorSet = new HashSet<>();
|
||||
environment.reset();
|
||||
environment.setTerminationFunction(() -> indicatorSet.add(TERMINATED));
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@Override
|
||||
public void additionalTearDown() {
|
||||
environment.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,13 @@
|
|||
package function.builtin;
|
||||
|
||||
import static table.FunctionTable.resetFunctionTable;
|
||||
import static testutil.TestUtilities.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.TooFewArgumentsException;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class FUNCALLTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
resetFunctionTable();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
resetFunctionTable();
|
||||
}
|
||||
public class FUNCALLTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void funcallWithNumbers() {
|
||||
|
|
|
@ -7,9 +7,10 @@ import static testutil.TypeAssertions.assertSymbol;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.TooManyArgumentsException;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
import token.TokenFactory.BadCharacterException;
|
||||
|
||||
public class GENSYMTest {
|
||||
public class GENSYMTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void gensymCreatesSymbol() {
|
||||
|
|
|
@ -6,13 +6,14 @@ import static testutil.TypeAssertions.*;
|
|||
|
||||
import java.io.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import environment.RuntimeEnvironment;
|
||||
import error.ErrorManager;
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class LOADTest {
|
||||
public class LOADTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
private ByteArrayOutputStream outputStream;
|
||||
private ByteArrayOutputStream errorOutputStream;
|
||||
|
@ -37,8 +38,8 @@ public class LOADTest {
|
|||
assertTrue(outputStream.toByteArray().length == 0);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@Override
|
||||
public void additionalSetUp() {
|
||||
outputStream = new ByteArrayOutputStream();
|
||||
errorOutputStream = new ByteArrayOutputStream();
|
||||
|
||||
|
@ -51,8 +52,8 @@ public class LOADTest {
|
|||
environment.setErrorOutputDecorator(s -> s);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@Override
|
||||
public void additionalTearDown() {
|
||||
environment.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,12 +6,13 @@ import static testutil.TestUtilities.evaluateString;
|
|||
|
||||
import java.io.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import environment.RuntimeEnvironment;
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class PRINTTest {
|
||||
public class PRINTTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
private RuntimeEnvironment environment;
|
||||
private ByteArrayOutputStream outputStream;
|
||||
|
@ -24,15 +25,15 @@ public class PRINTTest {
|
|||
assertEquals(expected, outputStream.toString());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@Override
|
||||
public void additionalSetUp() {
|
||||
outputStream = new ByteArrayOutputStream();
|
||||
environment.reset();
|
||||
environment.setOutput(new PrintStream(outputStream));
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@Override
|
||||
public void additionalTearDown() {
|
||||
environment.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,30 +3,15 @@ package function.builtin;
|
|||
import static org.junit.Assert.assertNull;
|
||||
import static testutil.TestUtilities.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import function.builtin.EVAL.UndefinedSymbolException;
|
||||
import sexpression.LispNumber;
|
||||
import table.*;
|
||||
import table.SymbolTable;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class SETTest {
|
||||
|
||||
private ExecutionContext executionContext;
|
||||
|
||||
public SETTest() {
|
||||
this.executionContext = ExecutionContext.getInstance();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
public class SETTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void set() {
|
||||
|
|
|
@ -3,25 +3,15 @@ package function.builtin;
|
|||
import static error.ErrorManager.Severity.ERROR;
|
||||
import static org.junit.Assert.*;
|
||||
import static sexpression.Nil.NIL;
|
||||
import static table.FunctionTable.resetFunctionTable;
|
||||
import static testutil.TestUtilities.evaluateString;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import function.builtin.SYMBOL_FUNCTION.UndefinedSymbolFunctionException;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class SYMBOL_FUNCTIONTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
resetFunctionTable();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
resetFunctionTable();
|
||||
}
|
||||
public class SYMBOL_FUNCTIONTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void symbolFunction_BuiltInFunction() {
|
||||
|
|
|
@ -6,8 +6,9 @@ import org.junit.Test;
|
|||
|
||||
import function.ArgumentValidator.*;
|
||||
import sexpression.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class CONSTest {
|
||||
public class CONSTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void consWithNilValues() {
|
||||
|
|
|
@ -5,8 +5,9 @@ import static testutil.TestUtilities.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class FIRSTTest {
|
||||
public class FIRSTTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void firstOfNil() {
|
||||
|
|
|
@ -5,8 +5,9 @@ import static testutil.TestUtilities.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class LENGTHTest {
|
||||
public class LENGTHTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void lengthOfNil() {
|
||||
|
|
|
@ -5,7 +5,9 @@ import static testutil.TestUtilities.*;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
public class LISTTest {
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class LISTTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void listWithNoArguments() {
|
||||
|
|
|
@ -5,8 +5,9 @@ import static testutil.TestUtilities.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class RESTTest {
|
||||
public class RESTTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void restOfNil() {
|
||||
|
|
|
@ -5,8 +5,9 @@ import static testutil.TestUtilities.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class DIVIDETest {
|
||||
public class DIVIDETest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void divideWithOne() {
|
||||
|
|
|
@ -6,8 +6,9 @@ import org.junit.Test;
|
|||
|
||||
import function.ArgumentValidator.*;
|
||||
import sexpression.LispNumber;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class MINUSTest {
|
||||
public class MINUSTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void minusWithOneNumber() {
|
||||
|
|
|
@ -6,8 +6,9 @@ import org.junit.Test;
|
|||
|
||||
import function.ArgumentValidator.BadArgumentTypeException;
|
||||
import sexpression.LispNumber;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class MULTIPLYTest {
|
||||
public class MULTIPLYTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void multiplyWithNoArguments() {
|
||||
|
|
|
@ -6,8 +6,9 @@ import org.junit.Test;
|
|||
|
||||
import function.ArgumentValidator.BadArgumentTypeException;
|
||||
import sexpression.LispNumber;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class PLUSTest {
|
||||
public class PLUSTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void plusWithNoArguments() {
|
||||
|
|
|
@ -6,8 +6,9 @@ import static testutil.TypeAssertions.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class ATOMTest {
|
||||
public class ATOMTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void atomIsAtom() {
|
||||
|
|
|
@ -6,8 +6,9 @@ import static testutil.TypeAssertions.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class EQTest {
|
||||
public class EQTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void eqWithEqualAtoms() {
|
||||
|
|
|
@ -6,8 +6,9 @@ import static testutil.TypeAssertions.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class EQUALTest {
|
||||
public class EQUALTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void equalWithTwoEqualAtoms() {
|
||||
|
|
|
@ -6,8 +6,9 @@ import static testutil.TypeAssertions.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class GENSYM_EQUALTest {
|
||||
public class GENSYM_EQUALTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void gensymEqualWithTwoEqualAtoms() {
|
||||
|
|
|
@ -6,8 +6,9 @@ import static testutil.TypeAssertions.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class LISTPTest {
|
||||
public class LISTPTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void listpWithList() {
|
||||
|
|
|
@ -6,8 +6,9 @@ import static testutil.TypeAssertions.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class NULLTest {
|
||||
public class NULLTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void nilIsNull() {
|
||||
|
|
|
@ -6,8 +6,9 @@ import static testutil.TypeAssertions.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class NUMERIC_EQUALTest {
|
||||
public class NUMERIC_EQUALTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void numericEqualWithOneNumber() {
|
||||
|
|
|
@ -6,8 +6,9 @@ import static testutil.TypeAssertions.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class NUMERIC_GREATERTest {
|
||||
public class NUMERIC_GREATERTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void greaterThanWithOneNumber_ReturnsT() {
|
||||
|
|
|
@ -6,8 +6,9 @@ import static testutil.TypeAssertions.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class NUMERIC_LESSTest {
|
||||
public class NUMERIC_LESSTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void lessThanWithOneNumber_ReturnsT() {
|
||||
|
|
|
@ -3,29 +3,13 @@ package function.builtin.special;
|
|||
import static testutil.TestUtilities.*;
|
||||
import static testutil.TypeAssertions.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import function.builtin.EVAL.UndefinedSymbolException;
|
||||
import sexpression.LispNumber;
|
||||
import table.ExecutionContext;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class ANDTest {
|
||||
|
||||
private ExecutionContext executionContext;
|
||||
|
||||
public ANDTest() {
|
||||
this.executionContext = ExecutionContext.getInstance();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
public class ANDTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void andByItself() {
|
||||
|
|
|
@ -2,28 +2,12 @@ package function.builtin.special;
|
|||
|
||||
import static testutil.TestUtilities.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import table.ExecutionContext;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class CASETest {
|
||||
|
||||
private ExecutionContext executionContext;
|
||||
|
||||
public CASETest() {
|
||||
this.executionContext = ExecutionContext.getInstance();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
public class CASETest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void caseWithKeyOnly() {
|
||||
|
|
|
@ -5,8 +5,9 @@ import static testutil.TestUtilities.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class CONDTest {
|
||||
public class CONDTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void condWithNoArguments() {
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package function.builtin.special;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static table.FunctionTable.resetFunctionTable;
|
||||
import static testutil.TestUtilities.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import environment.RuntimeEnvironment;
|
||||
import error.ErrorManager;
|
||||
import function.ArgumentValidator.*;
|
||||
import function.UserDefinedFunction.IllegalKeywordRestPositionException;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class DEFINE_SPECIALTest {
|
||||
public class DEFINE_SPECIALTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
private ByteArrayOutputStream outputStream;
|
||||
private RuntimeEnvironment environment;
|
||||
|
@ -26,21 +26,19 @@ public class DEFINE_SPECIALTest {
|
|||
assertTrue(outputStream.toByteArray().length > 0);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@Override
|
||||
public void additionalSetUp() {
|
||||
outputStream = new ByteArrayOutputStream();
|
||||
|
||||
environment.reset();
|
||||
environment.setOutput(new PrintStream(outputStream));
|
||||
environment.setErrorManager(new ErrorManager());
|
||||
environment.setWarningOutputDecorator(s -> s);
|
||||
resetFunctionTable();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@Override
|
||||
public void additionalTearDown() {
|
||||
environment.reset();
|
||||
resetFunctionTable();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package function.builtin.special;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static table.FunctionTable.resetFunctionTable;
|
||||
import static testutil.TestUtilities.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import environment.RuntimeEnvironment;
|
||||
import error.ErrorManager;
|
||||
import function.ArgumentValidator.*;
|
||||
import function.UserDefinedFunction.IllegalKeywordRestPositionException;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class DEFMACROTest {
|
||||
public class DEFMACROTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
private ByteArrayOutputStream outputStream;
|
||||
private RuntimeEnvironment environment;
|
||||
|
@ -26,21 +26,19 @@ public class DEFMACROTest {
|
|||
assertTrue(outputStream.toByteArray().length > 0);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@Override
|
||||
public void additionalSetUp() {
|
||||
outputStream = new ByteArrayOutputStream();
|
||||
|
||||
environment.reset();
|
||||
environment.setOutput(new PrintStream(outputStream));
|
||||
environment.setErrorManager(new ErrorManager());
|
||||
environment.setWarningOutputDecorator(s -> s);
|
||||
resetFunctionTable();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@Override
|
||||
public void additionalTearDown() {
|
||||
environment.reset();
|
||||
resetFunctionTable();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package function.builtin.special;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static table.FunctionTable.resetFunctionTable;
|
||||
import static testutil.TestUtilities.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import environment.RuntimeEnvironment;
|
||||
import error.ErrorManager;
|
||||
import function.ArgumentValidator.*;
|
||||
import function.UserDefinedFunction.IllegalKeywordRestPositionException;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class DEFUNTest {
|
||||
public class DEFUNTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
private ByteArrayOutputStream outputStream;
|
||||
private RuntimeEnvironment environment;
|
||||
|
@ -26,21 +26,19 @@ public class DEFUNTest {
|
|||
assertTrue(outputStream.toByteArray().length > 0);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@Override
|
||||
public void additionalSetUp() {
|
||||
outputStream = new ByteArrayOutputStream();
|
||||
|
||||
environment.reset();
|
||||
environment.setOutput(new PrintStream(outputStream));
|
||||
environment.setErrorManager(new ErrorManager());
|
||||
environment.setWarningOutputDecorator(s -> s);
|
||||
resetFunctionTable();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
@Override
|
||||
public void additionalTearDown() {
|
||||
environment.reset();
|
||||
resetFunctionTable();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -121,6 +119,11 @@ public class DEFUNTest {
|
|||
evaluateString("(defun f a ())");
|
||||
}
|
||||
|
||||
@Test(expected = BadArgumentTypeException.class)
|
||||
public void defunWithNonSymbolInLambdaList() {
|
||||
evaluateString("(defun f (1) ())");
|
||||
}
|
||||
|
||||
@Test(expected = TooFewArgumentsException.class)
|
||||
public void defunWithTooFewArguments() {
|
||||
evaluateString("(defun f)");
|
||||
|
|
|
@ -3,29 +3,13 @@ package function.builtin.special;
|
|||
import static testutil.TestUtilities.evaluateString;
|
||||
import static testutil.TypeAssertions.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import function.builtin.EVAL.UndefinedSymbolException;
|
||||
import table.ExecutionContext;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class IFTest {
|
||||
|
||||
private ExecutionContext executionContext;
|
||||
|
||||
public IFTest() {
|
||||
this.executionContext = ExecutionContext.getInstance();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
public class IFTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void ifWithOneExpression_ReturnsExpression() {
|
||||
|
|
|
@ -10,8 +10,9 @@ import org.junit.Test;
|
|||
|
||||
import function.ArgumentValidator.*;
|
||||
import sexpression.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class LAMBDATest {
|
||||
public class LAMBDATest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void lambda() {
|
||||
|
|
|
@ -3,30 +3,14 @@ package function.builtin.special;
|
|||
import static sexpression.Nil.NIL;
|
||||
import static testutil.TestUtilities.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import function.builtin.EVAL.UndefinedSymbolException;
|
||||
import sexpression.*;
|
||||
import table.ExecutionContext;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class LETTest {
|
||||
|
||||
private ExecutionContext executionContext;
|
||||
|
||||
public LETTest() {
|
||||
this.executionContext = ExecutionContext.getInstance();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
public class LETTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void simpleLet() {
|
||||
|
|
|
@ -3,30 +3,14 @@ package function.builtin.special;
|
|||
import static sexpression.Nil.NIL;
|
||||
import static testutil.TestUtilities.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import function.builtin.EVAL.UndefinedSymbolException;
|
||||
import sexpression.*;
|
||||
import table.ExecutionContext;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class LET_STARTest {
|
||||
|
||||
private ExecutionContext executionContext;
|
||||
|
||||
public LET_STARTest() {
|
||||
this.executionContext = ExecutionContext.getInstance();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
public class LET_STARTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void simpleLet() {
|
||||
|
|
|
@ -3,29 +3,13 @@ package function.builtin.special;
|
|||
import static testutil.TestUtilities.*;
|
||||
import static testutil.TypeAssertions.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import function.builtin.EVAL.UndefinedSymbolException;
|
||||
import sexpression.LispNumber;
|
||||
import table.ExecutionContext;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class ORTest {
|
||||
|
||||
private ExecutionContext executionContext;
|
||||
|
||||
public ORTest() {
|
||||
this.executionContext = ExecutionContext.getInstance();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
public class ORTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void orByItself() {
|
||||
|
|
|
@ -5,7 +5,9 @@ import static testutil.TypeAssertions.assertNil;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
public class PROGNTest {
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class PROGNTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void prognWithNoArguments() {
|
||||
|
|
|
@ -5,8 +5,9 @@ import static testutil.TestUtilities.*;
|
|||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class QUOTETest {
|
||||
public class QUOTETest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void quoteSymbol() {
|
||||
|
|
|
@ -3,30 +3,15 @@ package function.builtin.special;
|
|||
import static org.junit.Assert.assertNull;
|
||||
import static testutil.TestUtilities.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import function.ArgumentValidator.*;
|
||||
import function.builtin.EVAL.UndefinedSymbolException;
|
||||
import sexpression.LispNumber;
|
||||
import table.*;
|
||||
import table.SymbolTable;
|
||||
import testutil.SymbolAndFunctionCleaner;
|
||||
|
||||
public class SETQTest {
|
||||
|
||||
private ExecutionContext executionContext;
|
||||
|
||||
public SETQTest() {
|
||||
this.executionContext = ExecutionContext.getInstance();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
executionContext.clearContext();
|
||||
}
|
||||
public class SETQTest extends SymbolAndFunctionCleaner {
|
||||
|
||||
@Test
|
||||
public void setq() {
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package testutil;
|
||||
|
||||
import static table.FunctionTable.resetFunctionTable;
|
||||
|
||||
import org.junit.*;
|
||||
|
||||
import table.ExecutionContext;
|
||||
|
||||
public abstract class SymbolAndFunctionCleaner {
|
||||
|
||||
protected ExecutionContext executionContext;
|
||||
|
||||
public SymbolAndFunctionCleaner() {
|
||||
this.executionContext = ExecutionContext.getInstance();
|
||||
}
|
||||
|
||||
@Before
|
||||
public final void setUp() {
|
||||
executionContext.clearContext();
|
||||
resetFunctionTable();
|
||||
additionalSetUp();
|
||||
}
|
||||
|
||||
@After
|
||||
public final void tearDown() {
|
||||
executionContext.clearContext();
|
||||
resetFunctionTable();
|
||||
additionalTearDown();
|
||||
}
|
||||
|
||||
public void additionalSetUp() {}
|
||||
|
||||
public void additionalTearDown() {}
|
||||
|
||||
}
|
Loading…
Reference in New Issue