Add fib test to FIR resolve tests
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
|||||||
|
fun fibIterative(n: Int): Int {
|
||||||
|
if (n < 2) return 1
|
||||||
|
var current = 1
|
||||||
|
var prev = 1
|
||||||
|
for (i in 2..n) {
|
||||||
|
val temp = current
|
||||||
|
current += prev
|
||||||
|
prev = temp
|
||||||
|
}
|
||||||
|
return current
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
FILE: fib.kt
|
||||||
|
public final fun fibIterative(n: R|kotlin/Int|): R|kotlin/Int| {
|
||||||
|
when () {
|
||||||
|
<(R|<local>/n|, Int(2)) -> {
|
||||||
|
^fibIterative Int(1)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lvar current: R|kotlin/Int| = Int(1)
|
||||||
|
lvar prev: R|kotlin/Int| = Int(1)
|
||||||
|
lval <range>: R|kotlin/ranges/IntRange| = Int(2).R|kotlin/Int.rangeTo|(R|<local>/n|)
|
||||||
|
lval <iterator>: R|kotlin/collections/IntIterator| = R|<local>/<range>|.R|kotlin/ranges/IntProgression.iterator|()
|
||||||
|
while(R|<local>/<iterator>|.R|FakeOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()) {
|
||||||
|
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
|
||||||
|
lval temp: R|kotlin/Int| = R|<local>/current|
|
||||||
|
R|<local>/current| += R|<local>/prev|
|
||||||
|
R|<local>/prev| = R|<local>/temp|
|
||||||
|
}
|
||||||
|
|
||||||
|
^fibIterative R|<local>/current|
|
||||||
|
}
|
||||||
+5
@@ -64,6 +64,11 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase {
|
|||||||
runTest("compiler/fir/resolve/testData/resolve/fakeRecursiveTypealias.kt");
|
runTest("compiler/fir/resolve/testData/resolve/fakeRecursiveTypealias.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fib.kt")
|
||||||
|
public void testFib() throws Exception {
|
||||||
|
runTest("compiler/fir/resolve/testData/resolve/fib.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ft.kt")
|
@TestMetadata("ft.kt")
|
||||||
public void testFt() throws Exception {
|
public void testFt() throws Exception {
|
||||||
runTest("compiler/fir/resolve/testData/resolve/ft.kt");
|
runTest("compiler/fir/resolve/testData/resolve/ft.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user