moving more tests to arm

and guess what, finding bugs (index ones)
not fixed though
This commit is contained in:
Torsten 2020-03-27 20:18:14 +02:00
parent c29bb44159
commit 06944142d6
2 changed files with 55 additions and 3 deletions

View File

@ -48,9 +48,7 @@ module Arm
end
def byte_args_for( code )
args = slot_args_for( code )
args.pop if(code.index.is_a? Numeric)
args
[ code.register , code.array , code.index ]
end
def translate_ByteToReg( code )

View File

@ -0,0 +1,54 @@
require_relative "helper"
module Mains
class CallTester < MiniTest::Test
include MainsHelper
def test_plus
@preload = "Integer.plus"
@input = as_main("return 5 + 5")
assert_result 10 , ""
end
def test_minus
@preload = "Integer.minus"
@input = as_main("return 6 - 5")
assert_result 1 , ""
end
def test_mult
@preload = "Integer.mul"
@input = as_main "return #{2**31} * #{2**31}"
assert_result 0 , ""
end
def test_div
@preload = "Integer.div10"
@input = as_main "return 25.div10"
assert_result 2 , ""
end
def test_mod
@preload = "Integer.div4"
@input = as_main "return 9.div4"
assert_result 2 , ""
end
def test_puts
@preload = "Word.put"
@input = as_main(" return 'Hello again'.putstring ")
assert_result 11 , "Hello again"
end
#FIXME these next two are broken due to a logic error
# with indexes. Interpreter uses get_char, not get_internal_byte to
# make it look as if. but no. index haas to be adjusted, or logic changed
def est_get_byte
@preload = "Word.get_byte"
@input = as_main("return 'Hello'.get_internal_byte(0)")
assert_result "H".ord , ""
end
def est_set_byte
@preload = "Word.set_byte"
@input = as_main("return 'Hello'.set_internal_byte(0,75)")
assert_result "K".ord , ""
end
end
end