Add fib21 test
This commit is contained in:
parent
f0ff14e5b5
commit
10cc5e6e89
2 changed files with 30 additions and 0 deletions
20
test/all.d
Executable file
20
test/all.d
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/env rdmd
|
||||
|
||||
import std.process;
|
||||
import std.conv;
|
||||
|
||||
void main(){
|
||||
string fib21(){
|
||||
string r = "";
|
||||
double a = 0;
|
||||
double temp;
|
||||
for(double b = 1; a < 10000; b = temp + b){
|
||||
r ~= a.to!string ~ "\n";
|
||||
temp = a;
|
||||
a = b;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
assert([ "./lox", "test/fib21.lox" ].execute.output == fib21());
|
||||
}
|
||||
|
||||
10
test/fib21.lox
Normal file
10
test/fib21.lox
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
var a = 0;
|
||||
var temp;
|
||||
|
||||
for(var b = 1; a < 10000; b = temp + b){
|
||||
print a;
|
||||
temp = a;
|
||||
a = b;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue