move straight to rb files, fixed runner

This commit is contained in:
Torsten Ruger 2014-04-28 16:47:12 +03:00
parent 2fdbb9f3ae
commit c1a6003704
6 changed files with 24 additions and 16 deletions

View File

@ -1,6 +0,0 @@
def fibonacci_r( n )
return n if n <= 1
fibonacci_r( n - 1 ) + fibonacci_r( n - 2 )
end
puts fibonacci( 10 )

View File

@ -0,0 +1,8 @@
def fibonaccir( n , put )
return n if n <= 1
res = fibonaccir( n - 1 , put ) + fibonaccir( n - 2 , false )
puts(res) if put
res
end
fibonaccir( 10 , true)

View File

@ -1,9 +0,0 @@
def fibonacci_t(n)
a,b = 0,1
n.times do
printf("%d\n", a)
a,b = b,a+b
end
end
puts fibonacci_t( 10 )

View File

@ -0,0 +1,12 @@
def fibonaccit(n)
a = 0
b = 1
(n-1).times do
tmp = a
a = b
b = tmp + b
puts b
end
end
fibonaccit( 10 )

3
test/runners/foo.rb Normal file
View File

@ -0,0 +1,3 @@
def foo(x)
a = 5
end

View File

@ -5,7 +5,7 @@ class TestRunner < MiniTest::Test
# this creates test methods dynamically , one for each file in runners directory # this creates test methods dynamically , one for each file in runners directory
def self.runnable_methods def self.runnable_methods
methods = [] methods = []
Dir[File.join(File.dirname(__FILE__) , "runners" , "*.cr")].each do |file| Dir[File.join(File.dirname(__FILE__) , "runners" , "*.rb")].each do |file|
meth = File.basename(file).split(".").first meth = File.basename(file).split(".").first
name = "test_#{meth}" name = "test_#{meth}"
methods << name methods << name