convert tail call test to kotlin

This commit is contained in:
Mike Cifelli 2018-08-10 18:52:08 -04:00
parent c08edda548
commit 4c8342a9f7
2 changed files with 20 additions and 31 deletions

View File

@ -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<Object> tailCall = new TailCall<Object>() {
@Override
public TailCall<Object> apply() {
return null;
}
};
tailCall.result();
}
@Test(expected = UnsupportedOperationException.class)
public void doneDoesNotSupportApply() {
done(null).apply();
}
@Test
public void TailCallsCoverage() {
new TailCalls();
}
}

View File

@ -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<Any> { null }
assertThrows(UnsupportedOperationException::class.java) { tailCall.result() }
}
@Test
fun `done does not support apply`() {
assertThrows(UnsupportedOperationException::class.java) { done<Any>(null).apply() }
}
}