work on jump insertion continues

Now registering CodeListener instead of PositionListener
Also instead of on the previous, in itself, which is simpler
and allows to react to insertion at end
This commit is contained in:
Torsten Ruger
2018-06-07 19:26:02 +03:00
parent 7fa8397b56
commit 2d218bbc48
5 changed files with 61 additions and 29 deletions

View File

@ -20,16 +20,19 @@ module Risc
def test_init_returns_position
assert_equal Position , CodeListener.init(@binary).class
end
def test_not_init_listner
pos = CodeListener.init(@binary)
assert CodeListener == pos.event_table[:position_changed].last.class
end
def test_init_listner
@binary.extend_one
CodeListener.init(@binary)
pos = Position.get(@binary)
assert !pos.event_table[:position_changed].empty?
assert_equal CodeListener , pos.event_table[:position_changed].first.class
end
def test_not_init_listner
def test_extends_creates_jump
@binary.extend_one
CodeListener.init(@binary)
pos = Position.get(@binary)
assert pos.event_table[:position_changed].empty?
end
end
end

View File

@ -0,0 +1,26 @@
require_relative "helper"
module Risc
# tests that require a boot and test propagation
class TestCodeListenerFull < MiniTest::Test
def setup
Risc.machine.boot
@binary = Parfait::BinaryCode.new(1)
@method = Parfait.object_space.types.values.first.methods
@label = Risc.label("hi","ho")
@machine.translate(:arm)
@machine.position_all
end
def test_listener_after_extend
CodeListener.init(@binary).set(0)
@binary.extend_one
pos = Position.get(@binary.next)
assert_equal CodeListener , pos.event_table[:position_changed].first.class
end
def test_extend_sets_next_pos
CodeListener.init(@binary).set(0)
@binary.extend_one
assert Position.get(@binary.next)
end
end
end