unroll loops in tests
to get one executable per test (before they were overwritten)
This commit is contained in:
parent
0643b96641
commit
ac620f8ea0
@ -37,6 +37,7 @@ HERE
|
|||||||
assert_equal ret , @interpreter.get_register(:r0).return_value , "exit wrong #{@string_input}"
|
assert_equal ret , @interpreter.get_register(:r0).return_value , "exit wrong #{@string_input}"
|
||||||
end
|
end
|
||||||
check_remote ret
|
check_remote ret
|
||||||
|
file = write_object_file
|
||||||
end
|
end
|
||||||
|
|
||||||
def connected
|
def connected
|
||||||
@ -54,6 +55,7 @@ HERE
|
|||||||
end
|
end
|
||||||
def check_remote ret
|
def check_remote ret
|
||||||
return unless box = connected
|
return unless box = connected
|
||||||
|
return unless ret.is_a?(Numeric)
|
||||||
file = write_object_file
|
file = write_object_file
|
||||||
r_file = file.sub("./" , "salama/")
|
r_file = file.sub("./" , "salama/")
|
||||||
box.file_upload file , r_file
|
box.file_upload file , r_file
|
||||||
@ -67,7 +69,7 @@ HERE
|
|||||||
assert_equal "" , ret.stderr.join , "remote had error"
|
assert_equal "" , ret.stderr.join , "remote had error"
|
||||||
if ret
|
if ret
|
||||||
should = @interpreter.get_register(:r0).return_value
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3,11 +3,29 @@ require_relative 'helper'
|
|||||||
class TestPutiRT < MiniTest::Test
|
class TestPutiRT < MiniTest::Test
|
||||||
include RuntimeTests
|
include RuntimeTests
|
||||||
|
|
||||||
def test_mod4
|
def test_mod4_2
|
||||||
[2,3,4,5,10,12].each do |m|
|
@string_input = "return 2.mod4()"
|
||||||
@string_input = "return #{m}.mod4()"
|
check_return 2 % 4
|
||||||
check_return m % 4
|
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
# if you multiply i by "by" the return is the high 32 bits
|
# if you multiply i by "by" the return is the high 32 bits
|
||||||
@ -26,31 +44,54 @@ class TestPutiRT < MiniTest::Test
|
|||||||
return (by & 0xffffffff)
|
return (by & 0xffffffff)
|
||||||
end
|
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
|
def test_hightimes
|
||||||
# [2,3,4,5,10,121212 , 12345 , 3456 , 234567].each do |m|
|
@string_input = "return #{234567}.high_times(12 , 333)"
|
||||||
[2, 3456 , 234567].each do |m|
|
check_return high_times(234567,12,333)
|
||||||
@string_input = "return #{m}.high_times(12 , 333)"
|
|
||||||
check_return high_times(m,12,333)
|
|
||||||
end
|
end
|
||||||
|
def test_lowtimes2
|
||||||
|
@string_input = "return #{2}.low_times(14 , 33)"
|
||||||
|
check_return low_times(2,14,33)
|
||||||
end
|
end
|
||||||
def test_lowtimes
|
def test_lowtimes3456
|
||||||
#[2,3,4,5,10 , 3456 , 12345 , 121212 , 234567].each do |m|
|
@string_input = "return #{3456}.low_times(14 , 33)"
|
||||||
[2 , 3456 ,234567].each do |m|
|
check_return low_times(3456,14,33)
|
||||||
@string_input = "return #{m}.low_times(14 , 33)"
|
|
||||||
check_return low_times(m,14,33)
|
|
||||||
end
|
end
|
||||||
|
def test_lowtimes234567
|
||||||
|
@string_input = "return #{234567}.low_times(14 , 33)"
|
||||||
|
check_return low_times(234567,14,33)
|
||||||
end
|
end
|
||||||
|
|
||||||
# finally settled on the long version in http://www.sciencezero.org/index.php?title=ARM:_Division_by_10
|
# 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
|
# 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 )
|
# (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 ?
|
# for high numbers with ending 0 they are all 1 low. Possibly Interpreter bug ?
|
||||||
def test_div10
|
def test_div10_2
|
||||||
#[2,3,4,5,10 , 3456 , 12345 , 121212 , 234567].each do |m|
|
@string_input = "return 2.div10()"
|
||||||
[2,10 , 12345 ,234567].each do |m|
|
check_return 2 / 10
|
||||||
@string_input = "return #{m}.div10()"
|
|
||||||
check_return m / 10
|
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def test_as_char1
|
def test_as_char1
|
||||||
|
Loading…
Reference in New Issue
Block a user