diff --git a/test/mains/test_conditional.rb b/test/mains/test_conditional.rb new file mode 100644 index 00000000..9b3ee1b5 --- /dev/null +++ b/test/mains/test_conditional.rb @@ -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 diff --git a/test/risc/interpreter/conditional/test_if_greater.rb b/test/risc/interpreter/conditional/test_if_greater.rb deleted file mode 100644 index cc4c5528..00000000 --- a/test/risc/interpreter/conditional/test_if_greater.rb +++ /dev/null @@ -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 diff --git a/test/risc/interpreter/conditional/test_if_greater_or.rb b/test/risc/interpreter/conditional/test_if_greater_or.rb deleted file mode 100644 index 6997dadf..00000000 --- a/test/risc/interpreter/conditional/test_if_greater_or.rb +++ /dev/null @@ -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 diff --git a/test/risc/interpreter/conditional/test_if_smaller.rb b/test/risc/interpreter/conditional/test_if_smaller.rb deleted file mode 100644 index b0445a66..00000000 --- a/test/risc/interpreter/conditional/test_if_smaller.rb +++ /dev/null @@ -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 diff --git a/test/risc/interpreter/conditional/test_if_smaller_or.rb b/test/risc/interpreter/conditional/test_if_smaller_or.rb deleted file mode 100644 index 0acf5047..00000000 --- a/test/risc/interpreter/conditional/test_if_smaller_or.rb +++ /dev/null @@ -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 diff --git a/test/risc/interpreter/conditional/test_if_constant.rb b/test/risc/interpreter/test_if_constant.rb similarity index 97% rename from test/risc/interpreter/conditional/test_if_constant.rb rename to test/risc/interpreter/test_if_constant.rb index 363b0f73..2eb20c0c 100644 --- a/test/risc/interpreter/conditional/test_if_constant.rb +++ b/test/risc/interpreter/test_if_constant.rb @@ -1,4 +1,4 @@ -require_relative "../helper" +require_relative "helper" module Risc class InterpreterIfConstant < MiniTest::Test