unroll loops in tests

to get one executable per test (before they were overwritten)
This commit is contained in:
Torsten Ruger 2015-11-18 11:29:37 +02:00
parent 0643b96641
commit ac620f8ea0
2 changed files with 67 additions and 24 deletions

View File

@ -37,6 +37,7 @@ HERE
assert_equal ret , @interpreter.get_register(:r0).return_value , "exit wrong #{@string_input}"
end
check_remote ret
file = write_object_file
end
def connected
@ -54,6 +55,7 @@ HERE
end
def check_remote ret
return unless box = connected
return unless ret.is_a?(Numeric)
file = write_object_file
r_file = file.sub("./" , "salama/")
box.file_upload file , r_file
@ -67,7 +69,7 @@ HERE
assert_equal "" , ret.stderr.join , "remote had error"
if ret
should = @interpreter.get_register(:r0).return_value
assert_equal ret.exit_status.to_i ,should , "remote exit failed for #{@string_input}"
assert_equal should , ret.exit_status.to_i , "remote exit failed for #{@string_input}"
end
end

View File

@ -3,11 +3,29 @@ require_relative 'helper'
class TestPutiRT < MiniTest::Test
include RuntimeTests
def test_mod4
[2,3,4,5,10,12].each do |m|
@string_input = "return #{m}.mod4()"
check_return m % 4
def test_mod4_2
@string_input = "return 2.mod4()"
check_return 2 % 4
end
def test_mod4_3
@string_input = "return 3.mod4()"
check_return 3 % 4
end
def test_mod4_4
@string_input = "return 4.mod4()"
check_return 4 % 4
end
def test_mod4_5
@string_input = "return 5.mod4()"
check_return 5 % 4
end
def test_mod4_12
@string_input = "return 12.mod4()"
check_return 12 % 4
end
def test_mod4_10
@string_input = "return 10.mod4()"
check_return 10 % 4
end
# if you multiply i by "by" the return is the high 32 bits
@ -26,31 +44,54 @@ class TestPutiRT < MiniTest::Test
return (by & 0xffffffff)
end
def test_hightimes2
@string_input = "return #{2}.high_times(12 , 333)"
check_return high_times(2,12,333)
end
def test_hightimes3456
@string_input = "return #{3456}.high_times(12 , 333)"
check_return high_times(3456,12,333)
end
def test_hightimes234567
@string_input = "return #{234567}.high_times(12 , 333)"
check_return high_times(2,12,333)
end
def test_hightimes
# [2,3,4,5,10,121212 , 12345 , 3456 , 234567].each do |m|
[2, 3456 , 234567].each do |m|
@string_input = "return #{m}.high_times(12 , 333)"
check_return high_times(m,12,333)
@string_input = "return #{234567}.high_times(12 , 333)"
check_return high_times(234567,12,333)
end
def test_lowtimes2
@string_input = "return #{2}.low_times(14 , 33)"
check_return low_times(2,14,33)
end
def test_lowtimes
#[2,3,4,5,10 , 3456 , 12345 , 121212 , 234567].each do |m|
[2 , 3456 ,234567].each do |m|
@string_input = "return #{m}.low_times(14 , 33)"
check_return low_times(m,14,33)
def test_lowtimes3456
@string_input = "return #{3456}.low_times(14 , 33)"
check_return low_times(3456,14,33)
end
def test_lowtimes234567
@string_input = "return #{234567}.low_times(14 , 33)"
check_return low_times(234567,14,33)
end
# finally settled on the long version in http://www.sciencezero.org/index.php?title=ARM:_Division_by_10
# also the last looked good, but some bug is admittedly in all the ones i tried
# (off course the bug is not included in the test, but easy to achieve with random numbers )
# for high numbers with ending 0 they are all 1 low. Possibly Interpreter bug ?
def test_div10
#[2,3,4,5,10 , 3456 , 12345 , 121212 , 234567].each do |m|
[2,10 , 12345 ,234567].each do |m|
@string_input = "return #{m}.div10()"
check_return m / 10
def test_div10_2
@string_input = "return 2.div10()"
check_return 2 / 10
end
def test_div10_10
@string_input = "return 10.div10()"
check_return 10 / 10
end
def test_div10_12345
@string_input = "return 12345.div10()"
check_return 12345 / 10
end
def test_div10_234567
@string_input = "return 234567.div10()"
check_return 234567 / 10
end
def test_as_char1