Add unit test for LOAD
This commit is contained in:
parent
04cb46e94d
commit
8a719c8e44
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue