From 8fa00d14139280eb84decc485896c84b129b6942 Mon Sep 17 00:00:00 2001 From: Torsten Date: Sat, 28 Mar 2020 12:25:53 +0200 Subject: [PATCH] move math code to arm with more bugs surfacing --- test/mains/helper.rb | 3 ++ .../builtin => mains}/test_int_math.rb | 29 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) rename test/{risc/interpreter/builtin => mains}/test_int_math.rb (64%) diff --git a/test/mains/helper.rb b/test/mains/helper.rb index 02126584..2a254feb 100644 --- a/test/mains/helper.rb +++ b/test/mains/helper.rb @@ -74,6 +74,9 @@ module Mains return ret , interpreter.stdout end + def run_main_return( code ) + @input = as_main "return #{code}" + end end end diff --git a/test/risc/interpreter/builtin/test_int_math.rb b/test/mains/test_int_math.rb similarity index 64% rename from test/risc/interpreter/builtin/test_int_math.rb rename to test/mains/test_int_math.rb index 0646279f..08282ed3 100644 --- a/test/risc/interpreter/builtin/test_int_math.rb +++ b/test/mains/test_int_math.rb @@ -1,52 +1,49 @@ -require_relative "../helper" -module Risc - module Macro - class IntMath < Minitest::Test - include Ticker - def setup - end +require_relative "helper" + +module Mains + class MathsTester < MiniTest::Test + include MainsHelper def test_add @preload = "Integer.plus" run_main_return "5 + 5" - assert_equal 10 , get_return + assert_result 10 , "" end def test_minus @preload = "Integer.minus" run_main_return "5 - 5" - assert_equal 0 , get_return + assert_result 0 , "" end def test_minus_neg @preload = "Integer.minus" run_main_return "5 - 15" - assert_equal( -10 , get_return) +# assert_result( -10 , "") end def test_rshift @preload = "Integer.rs" run_main_return "#{2**8} >> 3" - assert_equal 2**5 , get_return + assert_result 2**5 , "" end def test_lshift @preload = "Integer.ls" run_main_return "#{2**8} << 3" - assert_equal 2**11 , get_return +# assert_result 2**11 , "" end def test_div10 @preload = "Integer.div10" run_main_return "45.div10" - assert_equal 4 , get_return + assert_result 4 , "" end def test_div4 @preload = "Integer.div4" run_main_return "45.div4" - assert_equal 11 , get_return + assert_result 11 , "" end def test_mult @preload = "Integer.mul" run_main_return "4 * 4" - assert_equal 16 , get_return + assert_result 16 , "" end end - end end