Im trying to test the following function:
private tailrec fun findFixPoint(eps: Double = 5.0, x: Double = 1.0): Double = if (abs(x - cos(x)) < eps) x else findFixPoint(cos(x))
This is my test function:
@Test
fun testNewFeatures(){
TestCase.assertEquals(0.7390851332151611, findFixPoint())
}
The fix point is 0.7390851332151611
but the assertEquals
returns me 1.0
as Actualvalue
i can deduct the function is only being launch one time without recursion.
Any suggestion of how can be test a tailrec
function properly?
Hope anyone can help me with this. Thank you all in advance.
Aucun commentaire:
Enregistrer un commentaire