jump was written off the end of binary code, fixed

This commit is contained in:
Torsten Ruger
2018-05-28 11:45:04 +03:00
parent 1c09d4202f
commit be1bc63ff2
10 changed files with 58 additions and 27 deletions

View File

@ -80,17 +80,23 @@ module Parfait
assert @code.next.next
assert_nil @code.next.next.next
end
def test_each
def test_each_word
len = 0
@code.each_word(false){ len += 1}
assert_equal 13 , len
end
def test_each_word_all
len = 0
@code.each_word{ len += 1}
assert_equal 13 , len
assert_equal 14 , len
end
def test_each_set
(0..12).each{|i| @code.set_word(i,i)}
all = []
@code.each_word{ |w| all << w}
@code.each_word(false){ |w| all << w}
assert_equal 0 , all.first
assert_equal 12 , all.last
assert_nil @code.next
end
def test_set_word
assert_equal 1 , @code.set_word(1 , 1)
@ -103,9 +109,21 @@ module Parfait
@code.set_word(1 , 1)
assert_equal 1, @code.get_internal_word(@code.data_start + 1)
end
def test_set_13
@code.set_word(13 , 1)
assert_nil @code.next
end
def test_set_last_no_extend
@code.set_last(1)
assert_nil @code.next
end
def test_set_last_and_get
@code.set_last(1)
assert_equal 1, @code.get_word(BinaryCode.data_length)
end
def test_has_each
sum = 0
@code.each{ sum += 1}
@code.each_block{ sum += 1}
assert_equal sum , 1
end
end

View File

@ -37,5 +37,13 @@ module Risc
def test_cpu_label
assert_equal Position::InstructionPosition , Position.get(@machine.cpu_init.first).class
end
def test_first_binary_jump
bin = Parfait.object_space.get_init.binary
assert 0 != bin.get_word(14) , "index 0 is 0 #{bin.inspect}"
end
def test_second_binary_first
bin = Parfait.object_space.get_init.binary.next
assert 0 != bin.get_word(0) , "index 0 is 0 #{bin.inspect}"
end
end
end

View File

@ -40,10 +40,6 @@ module Risc
word = Parfait::Word.new(12)
assert_equal 32 , word.padded_length
end
def test_pos_arm
mov = Arm::ArmMachine.mov :r1, 128
Risc::Position.set(0,0)
end
end
end