From 8a719c8e44cd3423e79dfa36c700ccb12aa3eb28 Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Sun, 5 Mar 2017 10:41:49 -0500 Subject: [PATCH] Add unit test for LOAD --- src/function/builtin/LOAD.java | 4 ++-- test/function/builtin/LOADTester.java | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/function/builtin/LOAD.java b/src/function/builtin/LOAD.java index 5c5d618..709fcff 100644 --- a/src/function/builtin/LOAD.java +++ b/src/function/builtin/LOAD.java @@ -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; } } diff --git a/test/function/builtin/LOADTester.java b/test/function/builtin/LOADTester.java index b7a481b..dc55fa6 100644 --- a/test/function/builtin/LOADTester.java +++ b/test/function/builtin/LOADTester.java @@ -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));