move straight to rb files, fixed runner
This commit is contained in:
parent
2fdbb9f3ae
commit
c1a6003704
@ -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 )
|
8
test/runners/fibo_recursice.rb
Normal file
8
test/runners/fibo_recursice.rb
Normal 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)
|
@ -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 )
|
12
test/runners/fibo_times.rb
Normal file
12
test/runners/fibo_times.rb
Normal 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
3
test/runners/foo.rb
Normal file
@ -0,0 +1,3 @@
|
||||
def foo(x)
|
||||
a = 5
|
||||
end
|
@ -5,7 +5,7 @@ class TestRunner < MiniTest::Test
|
||||
# this creates test methods dynamically , one for each file in runners directory
|
||||
def self.runnable_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
|
||||
name = "test_#{meth}"
|
||||
methods << name
|
||||
|
Loading…
Reference in New Issue
Block a user