move the methods test to mains

previous commit made the mains tests more general
this joins methods tests here
so we can run them on arm too
fix #11
This commit is contained in:
Torsten Ruger
2018-08-18 20:06:15 +03:00
parent 80264c5322
commit 5b2c7745fe
13 changed files with 78 additions and 118 deletions

View File

@ -1,5 +0,0 @@
# Method Testing
Test the calling of several methods (including Builtin)
All in one class though. Using the Interpreter.

View File

@ -1,8 +0,0 @@
require_relative '../helper'
module Methods
class MethodsTest < MiniTest::Test
include Risc::Ticker
def setup;end
end
end

View File

@ -1,30 +0,0 @@
require_relative 'helper'
module Methods
class TestCallCond < MethodsTest
def if_cond( arg )
str = <<HERE
def called( n )
if( n < 10)
return 10
else
return 20
end
end
def main(arg)
return called( ARG )
end
HERE
str.sub("ARG" , arg.to_s)
end
def test_call_sm
run_space if_cond(8)
assert_equal 10 , get_return
end
def test_call_lg
run_space if_cond(18)
assert_equal 20 , get_return
end
end
end

View File

@ -1,43 +0,0 @@
require_relative 'helper'
module Methods
class TestFibo < MethodsTest
def test_count_down
run_space <<HERE
def down( n )
if( n < 2 )
return n
else
a = down(n - 1)
return a
end
end
def main(arg)
return down(8)
end
HERE
assert_equal 1 , get_return
end
def test_fibo
run_space <<HERE
def fibo_r( n )
if( n < 2 )
return n
else
a = fibo_r(n - 1)
b = fibo_r(n - 2)
return a + b
end
end
def main(arg)
return fibo_r(6)
end
HERE
assert_equal 8 , get_return
end
end
end

View File

@ -1,31 +0,0 @@
require_relative 'helper'
module Methods
class TestCallSimple < MethodsTest
def test_simple
run_space <<HERE
def same( n )
return n
end
def main(arg)
return same(8)
end
HERE
assert_equal 8 , get_return
end
def test_call_with_call
run_space <<HERE
def same( n )
return n
end
def main(arg)
a = same(8 - 1)
return a
end
HERE
assert_equal 7 , get_return
end
end
end