Added more tests
This commit is contained in:
23
tests/programs/factorial.q
Normal file
23
tests/programs/factorial.q
Normal file
@ -0,0 +1,23 @@
|
||||
main() {
|
||||
for i := 0..10 {
|
||||
assert fac1(i) == fac2(i)
|
||||
}
|
||||
}
|
||||
|
||||
fac1(n int) -> int {
|
||||
x := 1
|
||||
|
||||
for i := 1..n+1 {
|
||||
x = x * i
|
||||
}
|
||||
|
||||
return x
|
||||
}
|
||||
|
||||
fac2(n int) -> int {
|
||||
if n <= 1 {
|
||||
return 1
|
||||
}
|
||||
|
||||
return n * fac2(n - 1)
|
||||
}
|
@ -62,6 +62,7 @@ var programs = []struct {
|
||||
{"loop-lifetime", 0},
|
||||
{"loop-in-loop", 0},
|
||||
{"for", 0},
|
||||
{"factorial", 0},
|
||||
{"fibonacci", 0},
|
||||
{"memory-free", 0},
|
||||
{"out-of-memory", 0},
|
||||
|
Reference in New Issue
Block a user