test: add fibonacci golden test, expand GOLDEN_TESTS
This commit is contained in:
@@ -78,7 +78,7 @@ selfhost: build
|
|||||||
|
|
||||||
.PHONY: test-golden
|
.PHONY: test-golden
|
||||||
|
|
||||||
GOLDEN_TESTS := hello
|
GOLDEN_TESTS := hello fibonacci
|
||||||
|
|
||||||
test-golden: build
|
test-golden: build
|
||||||
@echo "=== Golden tests ==="
|
@echo "=== Golden tests ==="
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[Package]
|
||||||
|
Name = "fibonacci"
|
||||||
|
Version = "0.1.0"
|
||||||
|
Type = "bin"
|
||||||
|
[Build]
|
||||||
|
Output = "Bin"
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
|||||||
|
// Fibonacci - Recursive function with while loop
|
||||||
|
import Std::Io::{PrintLine};
|
||||||
|
import Std::Fmt::{Fmt_Fmt1};
|
||||||
|
|
||||||
|
func Fibonacci(n: int) -> int {
|
||||||
|
if n <= 1 {
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
return Fibonacci(n - 1) + Fibonacci(n - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
func Main() -> int {
|
||||||
|
PrintLine("Fibonacci sequence:");
|
||||||
|
|
||||||
|
var i: int = 0;
|
||||||
|
while i < 10 {
|
||||||
|
let fib: int = Fibonacci(i);
|
||||||
|
PrintLine(Fmt_Fmt1("{0}", String_FromInt(fib)));
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user