move conditional test to arm

This commit is contained in:
Torsten 2020-03-28 11:51:16 +02:00
parent 2b467fc555
commit e51cd8420b
6 changed files with 37 additions and 73 deletions

View File

@ -0,0 +1,36 @@
require_relative "helper"
module Mains
class ConditionalTester < MiniTest::Test
include MainsHelper
def test_simple
@preload = "Integer.ge"
@input = code("5 >= 5")
assert_result 1 , ""
end
def test_const
@input = code("10")
assert_result 1 , ""
end
def test_greater
@preload = "Integer.gt"
@input = code("5 > 5")
assert_result 2 , ""
end
def test_smaller
@preload = "Integer.lt"
@input = code("5 < 5")
assert_result 2 , ""
end
def test_smaller_eq
@preload = "Integer.le"
@input = code("5 <= 5")
assert_result 1 , ""
end
def code( cond , tru = "return 1" , fals = "return 2")
as_main "if(#{cond}) ; #{tru} ; else ; #{fals} ; end"
end
end
end

View File

@ -1,18 +0,0 @@
require_relative "../helper"
module Risc
class InterpreterIfGreater < MiniTest::Test
include Ticker
def setup
@preload = "Integer.gt"
@string_input = as_main 'if( 5 > 5 ); return 1;else;return 2;end'
super
end
def test_if
run_all
assert_equal 2 , get_return
end
end
end

View File

@ -1,18 +0,0 @@
require_relative "../helper"
module Risc
class InterpreterIfGreaterOr < MiniTest::Test
include Ticker
def setup
@preload = "Integer.ge"
@string_input = as_main 'if( 5 >= 5 ); return 1;else;return 2;end'
super
end
def test_if
run_all
assert_equal 1 , get_return
end
end
end

View File

@ -1,18 +0,0 @@
require_relative "../helper"
module Risc
class InterpreterIfSmaller < MiniTest::Test
include Ticker
def setup
@preload = "Integer.lt"
@string_input = as_main 'if( 5 < 5 ); return 1;else;return 2;end'
super
end
def test_if
run_all
assert_equal 2 , get_return
end
end
end

View File

@ -1,18 +0,0 @@
require_relative "../helper"
module Risc
class InterpreterIfSmallerOr < MiniTest::Test
include Ticker
def setup
@preload = "Integer.le"
@string_input = as_main 'if( 5 <= 5 ); return 1;else;return 2;end'
super
end
def test_if
run_all
assert_equal 1 , get_return
end
end
end

View File

@ -1,4 +1,4 @@
require_relative "../helper"
require_relative "helper"
module Risc
class InterpreterIfConstant < MiniTest::Test