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