From 0825d1ee96ca5d9bcaed3c5b911e0547a1a2c214 Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Sun, 26 Nov 2017 15:11:41 -0500 Subject: [PATCH] Increase test coverage --- fitnesse/FitNesseRoot/RecentChanges.wiki | 2 +- .../TranscendentalLisp/Recursion.wiki | 2 +- src/token/TokenFactoryImpl.java | 5 ++- test/recursion/TailCallTest.java | 32 +++++++++++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 test/recursion/TailCallTest.java diff --git a/fitnesse/FitNesseRoot/RecentChanges.wiki b/fitnesse/FitNesseRoot/RecentChanges.wiki index 5b73d8f..b8bef6f 100644 --- a/fitnesse/FitNesseRoot/RecentChanges.wiki +++ b/fitnesse/FitNesseRoot/RecentChanges.wiki @@ -1,4 +1,4 @@ -|TranscendentalLisp.Recursion||10:09:13 Sun, Nov 26, 2017| +|TranscendentalLisp.Recursion||15:06:26 Sun, Nov 26, 2017| |TranscendentalLisp||16:15:14 Fri, Mar 17, 2017| |TranscendentalLisp.Macros||10:10:15 Mon, Mar 13, 2017| |TranscendentalLisp.MacroTests||10:07:00 Mon, Mar 13, 2017| diff --git a/fitnesse/FitNesseRoot/TranscendentalLisp/Recursion.wiki b/fitnesse/FitNesseRoot/TranscendentalLisp/Recursion.wiki index 52cc1e7..5c865e2 100644 --- a/fitnesse/FitNesseRoot/TranscendentalLisp/Recursion.wiki +++ b/fitnesse/FitNesseRoot/TranscendentalLisp/Recursion.wiki @@ -26,4 +26,4 @@ Test recursion capabilities of various functions. | check | evaluate text | (eval (append `(let ,(list-of '(x 20) 10000)) big-list)) | 1 | | check | evaluate text | (apply 'cond (list-of '((= 1 2) 1) 10000)) | NIL | | check | evaluate text | (eval (append '(case :a) (list-of '((:b :c :d) 1) 10000))) | NIL | -| check | evaluate text | (nested-list 2000) | =~/\)\)$/ | +| check | evaluate text | (nested-list 1500) | =~/\)\)$/ | diff --git a/src/token/TokenFactoryImpl.java b/src/token/TokenFactoryImpl.java index cb557e0..706df21 100644 --- a/src/token/TokenFactoryImpl.java +++ b/src/token/TokenFactoryImpl.java @@ -38,11 +38,10 @@ public class TokenFactoryImpl implements TokenFactory { case COMMA: return new Comma(text, position); default: - if (isNumeric(firstCharacter, text)) { + if (isNumeric(firstCharacter, text)) return new Number(text, position); - } else if (isLegalIdentifierCharacter(firstCharacter)) { + else if (isLegalIdentifierCharacter(firstCharacter)) return new Identifier(text, position); - } } throw new BadCharacterException(text, position); diff --git a/test/recursion/TailCallTest.java b/test/recursion/TailCallTest.java new file mode 100644 index 0000000..c192067 --- /dev/null +++ b/test/recursion/TailCallTest.java @@ -0,0 +1,32 @@ +package recursion; + +import static recursion.TailCalls.done; + +import org.junit.Test; + +public class TailCallTest { + + @Test(expected = UnsupportedOperationException.class) + public void tailCallDoesNotSupportResult() { + TailCall tailCall = new TailCall() { + + @Override + public TailCall apply() { + return null; + } + }; + + tailCall.result(); + } + + @Test(expected = UnsupportedOperationException.class) + public void doneDoesNotSupportApply() { + done(null).apply(); + } + + @Test + public void TailCallsCoverage() { + new TailCalls(); + } + +}