From 4c8342a9f77fd201cf0cc09a6340583262313729 Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Fri, 10 Aug 2018 18:52:08 -0400 Subject: [PATCH] convert tail call test to kotlin --- src/test/kotlin/recursion/TailCallTest.java | 31 --------------------- src/test/kotlin/recursion/TailCallTest.kt | 20 +++++++++++++ 2 files changed, 20 insertions(+), 31 deletions(-) delete mode 100644 src/test/kotlin/recursion/TailCallTest.java create mode 100644 src/test/kotlin/recursion/TailCallTest.kt diff --git a/src/test/kotlin/recursion/TailCallTest.java b/src/test/kotlin/recursion/TailCallTest.java deleted file mode 100644 index f8dd401..0000000 --- a/src/test/kotlin/recursion/TailCallTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package recursion; - -import org.junit.Test; - -import static recursion.TailCalls.done; - -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(); - } -} diff --git a/src/test/kotlin/recursion/TailCallTest.kt b/src/test/kotlin/recursion/TailCallTest.kt new file mode 100644 index 0000000..9e0ef74 --- /dev/null +++ b/src/test/kotlin/recursion/TailCallTest.kt @@ -0,0 +1,20 @@ +package recursion + +import org.junit.jupiter.api.Assertions.assertThrows +import org.junit.jupiter.api.Test +import recursion.TailCalls.done + +class TailCallTest { + + @Test + fun `tailCall does not support result`() { + val tailCall = TailCall { null } + + assertThrows(UnsupportedOperationException::class.java) { tailCall.result() } + } + + @Test + fun `done does not support apply`() { + assertThrows(UnsupportedOperationException::class.java) { done(null).apply() } + } +}