Add unit test for LOAD

This commit is contained in:
Mike Cifelli 2017-03-05 10:41:49 -05:00
parent 04cb46e94d
commit 8a719c8e44
2 changed files with 11 additions and 3 deletions

View File

@ -66,7 +66,7 @@ public class LOAD extends LispFunction {
try {
parser = new LispParser(new FileInputStream(fileName), fileName);
} catch (FileNotFoundException e) {
this.environment.getErrorManager().handle(new CouldNotLoadFileWarning(fileName));
environment.getErrorManager().handle(new CouldNotLoadFileWarning(fileName));
}
return parser;
@ -89,7 +89,7 @@ public class LOAD extends LispFunction {
try {
eval(parser.getNextSExpression());
} catch (LispException e) {
this.environment.getErrorManager().handle(e);
environment.getErrorManager().handle(e);
return false;
}
}

View File

@ -57,6 +57,14 @@ public class LOADTester {
environment.reset();
}
@Test
public void loadEmptyFileName_ReturnsNilAndPrintsWarning() {
String input = "(load \"\")";
assertNil(evaluateString(input));
assertWarningMessagePrinted();
}
@Test
public void loadGoodFile_ReturnsTAndPrintsNothing() {
String input = "(load \"test/function/builtin/test-files/load-good.lisp\")";
@ -74,7 +82,7 @@ public class LOADTester {
}
@Test
public void loadNonExistentFile_ReturnsNilAndPrintsError() {
public void loadNonExistentFile_ReturnsNilAndPrintsWarning() {
String input = "(load \"doesNotExist.lisp\")";
assertNil(evaluateString(input));