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:
@ -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
|
||||
|
26
test/risc/position/test_code_listener1.rb
Normal file
26
test/risc/position/test_code_listener1.rb
Normal 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
|
Reference in New Issue
Block a user