diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..2a51304
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 0e0b4d2..1e6b5d8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,9 +11,14 @@
UTF-8
1.2.30
+ 5.1.0
+ false
+
+
+
org.apache.maven.plugins
@@ -91,7 +96,27 @@
org.apache.maven.plugins
maven-surefire-plugin
- 2.20.1
+ 2.19.1
+
+
+ org.junit.platform
+ junit-platform-surefire-provider
+ 1.0.1
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit5.version}
+
+
+ org.junit.vintage
+ junit-vintage-engine
+ ${junit5.version}
+
+
+
+ ${skipTests}
+
@@ -145,9 +170,23 @@
- org.jetbrains.kotlin
- kotlin-test
- ${kotlin.version}
+ org.assertj
+ assertj-core
+ 3.9.1
+ test
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit5.version}
+ test
+
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ ${junit5.version}
test
diff --git a/src/test/java/table/FunctionTableTest.java b/src/test/java/table/FunctionTableTest.java
deleted file mode 100644
index 266166e..0000000
--- a/src/test/java/table/FunctionTableTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package table;
-
-import error.Severity;
-import function.FunctionNames;
-import function.LispFunction;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import sexpression.Cons;
-import sexpression.SExpression;
-import table.FunctionTable.LispFunctionInstantiationException;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static sexpression.Nil.NIL;
-import static sexpression.Symbol.T;
-import static table.FunctionTable.defineFunction;
-import static table.FunctionTable.isAlreadyDefined;
-import static table.FunctionTable.lookupFunction;
-import static table.FunctionTable.resetFunctionTable;
-
-public class FunctionTableTest {
-
- @FunctionNames({ "GOOD" })
- public static class GoodFunction extends LispFunction {
-
- public GoodFunction(String name) {}
-
- @Override
- public SExpression call(Cons argumentList) {
- return NIL;
- }
- }
-
- @FunctionNames({ "BAD" })
- public static class BadFunction extends LispFunction {
-
- @Override
- public SExpression call(Cons argumentList) {
- return NIL;
- }
- }
-
- public static class UglyFunction extends LispFunction {
-
- @Override
- public SExpression call(Cons argumentList) {
- return NIL;
- }
- }
-
- private LispFunction createLispFunction() {
- return new LispFunction() {
-
- @Override
- public SExpression call(Cons argumentList) {
- return T;
- }
- };
- }
-
- @Before
- public void setUp() {
- resetFunctionTable();
- }
-
- @After
- public void tearDown() {
- resetFunctionTable();
- }
-
- @Test
- public void builtInFunctionIsDefined() {
- assertTrue(isAlreadyDefined("CONS"));
- }
-
- @Test
- public void undefinedFunctionIsNotDefined() {
- assertFalse(isAlreadyDefined("undefined"));
- }
-
- @Test
- public void lookupBuiltInFunction_ReturnsFunction() {
- assertNotNull(lookupFunction("CONS"));
- }
-
- @Test
- public void lookupUndefinedFunction_ReturnsNull() {
- assertNull(lookupFunction("undefined"));
- }
-
- @Test
- public void defineFunctionWorks() {
- String functionName = "testFunction";
- LispFunction testFunction = createLispFunction();
-
- assertNull(lookupFunction(functionName));
- assertFalse(isAlreadyDefined(functionName));
-
- defineFunction(functionName, testFunction);
-
- assertTrue(isAlreadyDefined(functionName));
- assertEquals(testFunction, lookupFunction(functionName));
- }
-
- @Test
- public void resetFunctionTableWorks() {
- String functionName = "testFunction";
- LispFunction testFunction = createLispFunction();
- defineFunction(functionName, testFunction);
-
- resetFunctionTable();
-
- assertFalse(isAlreadyDefined(functionName));
- assertNull(lookupFunction(functionName));
- }
-
- @Test
- public void resetWithCustomBuitIns() {
- Set> goodBuiltIns = new HashSet<>();
- goodBuiltIns.add(GoodFunction.class);
-
- resetFunctionTable(goodBuiltIns);
-
- assertTrue(isAlreadyDefined("GOOD"));
- assertNotNull(lookupFunction("GOOD"));
- }
-
- @Test(expected = LispFunctionInstantiationException.class)
- public void unableToInitializeBuiltIn() {
- Set> badBuiltIns = new HashSet<>();
- badBuiltIns.add(BadFunction.class);
-
- resetFunctionTable(badBuiltIns);
- }
-
- @Test
- public void lispFunctionInstantiationException_HasCorrectAttributes() {
- LispFunctionInstantiationException e = new LispFunctionInstantiationException("Bad");
-
- assertNotNull(e.getMessage());
- assertTrue(e.getMessage().length() > 0);
- assertEquals(Severity.CRITICAL, e.getSeverity());
- }
-
- @Test
- public void namelessBuiltIn_DoesNotCauseNPE() {
- Set> namelessBuiltins = new HashSet<>();
- namelessBuiltins.add(UglyFunction.class);
-
- resetFunctionTable(namelessBuiltins);
-
- assertFalse(isAlreadyDefined("UGLY"));
- assertNull(lookupFunction("UGLY"));
- }
-}
diff --git a/src/test/java/table/FunctionTableTest.kt b/src/test/java/table/FunctionTableTest.kt
new file mode 100644
index 0000000..5ef4c12
--- /dev/null
+++ b/src/test/java/table/FunctionTableTest.kt
@@ -0,0 +1,141 @@
+package table
+
+import error.Severity
+import function.FunctionNames
+import function.LispFunction
+import org.assertj.core.api.Assertions.assertThat
+import org.junit.jupiter.api.AfterEach
+import org.junit.jupiter.api.Assertions.assertThrows
+import org.junit.jupiter.api.BeforeEach
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.TestInstance
+import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
+import sexpression.Cons
+import sexpression.Nil
+import sexpression.Nil.NIL
+import sexpression.Symbol.T
+import table.FunctionTable.LispFunctionInstantiationException
+import table.FunctionTable.defineFunction
+import table.FunctionTable.isAlreadyDefined
+import table.FunctionTable.lookupFunction
+import table.FunctionTable.resetFunctionTable
+import java.util.HashSet
+
+@TestInstance(PER_CLASS)
+class FunctionTableTest {
+
+ @FunctionNames("GOOD")
+ class GoodFunction(name: String) : LispFunction() {
+
+ override fun call(argumentList: Cons): Nil = NIL
+ }
+
+ @FunctionNames("BAD")
+ class BadFunction : LispFunction() {
+
+ override fun call(argumentList: Cons): Nil = NIL
+ }
+
+ class UglyFunction : LispFunction() {
+
+ override fun call(argumentList: Cons): Nil = NIL
+ }
+
+ private fun createLispFunction() = object : LispFunction() {
+ override fun call(argumentList: Cons) = T
+ }
+
+ @BeforeEach
+ fun initialize() {
+ resetFunctionTable()
+ }
+
+ @AfterEach
+ fun tearDown() {
+ resetFunctionTable()
+ }
+
+ @Test
+ fun builtInFunctionIsDefined() {
+ assertThat(isAlreadyDefined("CONS")).isTrue()
+ }
+
+ @Test
+ fun undefinedFunctionIsNotDefined() {
+ assertThat(isAlreadyDefined("undefined")).isFalse()
+ }
+
+ @Test
+ fun lookupBuiltInFunction_ReturnsFunction() {
+ assertThat(lookupFunction("CONS")).isNotNull()
+ }
+
+ @Test
+ fun lookupUndefinedFunction_ReturnsNull() {
+ assertThat(lookupFunction("undefined")).isNull()
+ }
+
+ @Test
+ fun defineFunctionWorks() {
+ val functionName = "testFunction"
+ val testFunction = createLispFunction()
+
+ assertThat(lookupFunction(functionName)).isNull()
+ assertThat(isAlreadyDefined(functionName)).isFalse()
+
+ defineFunction(functionName, testFunction)
+
+ assertThat(isAlreadyDefined(functionName)).isTrue()
+ assertThat(lookupFunction(functionName)).isEqualTo(testFunction)
+ }
+
+ @Test
+ fun resetFunctionTableWorks() {
+ val functionName = "testFunction"
+ val testFunction = createLispFunction()
+ defineFunction(functionName, testFunction)
+
+ resetFunctionTable()
+
+ assertThat(lookupFunction(functionName)).isNull()
+ assertThat(isAlreadyDefined(functionName)).isFalse()
+ }
+
+ @Test
+ fun resetWithCustomBuitIns() {
+ val goodBuiltIns = HashSet>()
+ goodBuiltIns.add(GoodFunction::class.java)
+
+ resetFunctionTable(goodBuiltIns)
+
+ assertThat(isAlreadyDefined("GOOD")).isTrue()
+ assertThat(lookupFunction("GOOD")).isNotNull()
+ }
+
+ @Test
+ fun unableToInitializeBuiltIn() {
+ val badBuiltIns = HashSet>()
+ badBuiltIns.add(BadFunction::class.java)
+
+ assertThrows(LispFunctionInstantiationException::class.java) { resetFunctionTable(badBuiltIns) }
+ }
+
+ @Test
+ fun lispFunctionInstantiationException_HasCorrectAttributes() {
+ val e = LispFunctionInstantiationException("Bad")
+
+ assertThat(e.message).isNotEmpty()
+ assertThat(e.severity).isEqualTo(Severity.CRITICAL)
+ }
+
+ @Test
+ fun namelessBuiltIn_DoesNotCauseNPE() {
+ val namelessBuiltins = HashSet>()
+ namelessBuiltins.add(UglyFunction::class.java)
+
+ resetFunctionTable(namelessBuiltins)
+
+ assertThat(isAlreadyDefined("UGLY")).isFalse()
+ assertThat(lookupFunction("UGLY")).isNull()
+ }
+}
diff --git a/src/test/java/table/SymbolTableTest.java b/src/test/java/table/SymbolTableTest.java
deleted file mode 100644
index 21da004..0000000
--- a/src/test/java/table/SymbolTableTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package table;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static sexpression.Nil.NIL;
-import static sexpression.Symbol.T;
-
-public class SymbolTableTest {
-
- private SymbolTable symbolTable;
-
- @Before
- public void setUp() {
- symbolTable = new SymbolTable();
- }
-
- @Test
- public void lookupSymbolNotInTable() {
- assertFalse(symbolTable.contains("symbol"));
- }
-
- @Test
- public void lookupSymbolInTable() {
- symbolTable.put("symbol", T);
-
- assertTrue(symbolTable.contains("symbol"));
- }
-
- @Test
- public void retrieveSymbolValue() {
- symbolTable.put("symbol", T);
-
- assertEquals(T, symbolTable.get("symbol"));
- }
-
- @Test
- public void redefineSymbolValue() {
- symbolTable.put("symbol", T);
- symbolTable.put("symbol", NIL);
-
- assertEquals(NIL, symbolTable.get("symbol"));
- }
-
- @Test
- public void checkParentTableIsCorrect() {
- SymbolTable childTable = new SymbolTable(symbolTable);
-
- assertEquals(symbolTable, childTable.getParent());
- }
-
- @Test
- public void lookupSymbolInParentTable() {
- symbolTable.put("symbol", T);
- SymbolTable childTable = new SymbolTable(symbolTable);
- SymbolTable parentTable = childTable.getParent();
-
- assertEquals(T, parentTable.get("symbol"));
- }
-}
diff --git a/src/test/java/table/SymbolTableTest.kt b/src/test/java/table/SymbolTableTest.kt
new file mode 100644
index 0000000..334fb77
--- /dev/null
+++ b/src/test/java/table/SymbolTableTest.kt
@@ -0,0 +1,63 @@
+package table
+
+import org.assertj.core.api.Assertions.assertThat
+import org.junit.jupiter.api.BeforeEach
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.TestInstance
+import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS
+import sexpression.Nil.NIL
+import sexpression.Symbol.T
+
+@TestInstance(PER_CLASS)
+class SymbolTableTest {
+
+ private lateinit var symbolTable: SymbolTable
+
+ @BeforeEach
+ fun initialize() {
+ symbolTable = SymbolTable()
+ }
+
+ @Test
+ fun `lookup a symbol that does not exist`() {
+ assertThat(symbolTable.contains("symbol")).isFalse()
+ }
+
+ @Test
+ fun `lookup a symbol that exists`() {
+ symbolTable.put("symbol", T)
+
+ assertThat(symbolTable.contains("symbol")).isTrue()
+ }
+
+ @Test
+ fun `get the value of a symbol`() {
+ symbolTable.put("symbol", T)
+
+ assertThat(symbolTable.get("symbol")).isEqualTo(T)
+ }
+
+ @Test
+ fun `redefine the value of a symbol`() {
+ symbolTable.put("symbol", T)
+ symbolTable.put("symbol", NIL)
+
+ assertThat(symbolTable.get("symbol")).isEqualTo(NIL)
+ }
+
+ @Test
+ fun `check the value of a parent table`() {
+ val childTable = SymbolTable(symbolTable)
+
+ assertThat(childTable.parent).isEqualTo(symbolTable)
+ }
+
+ @Test
+ fun `lookup a symbol in a parent table`() {
+ symbolTable.put("symbol", T)
+ val childTable = SymbolTable(symbolTable)
+ val parentTable = childTable.parent
+
+ assertThat(parentTable.get("symbol")).isEqualTo(T)
+ }
+}