2018-05-08 18:59:43 +02:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
module Risc
|
|
|
|
# tests that require a boot and test propagation
|
|
|
|
class TestPositionBasic < MiniTest::Test
|
|
|
|
def setup
|
|
|
|
Risc.machine.boot
|
|
|
|
@binary = Parfait::BinaryCode.new(1)
|
|
|
|
@label = Label.new("hi","ho")
|
|
|
|
end
|
|
|
|
def test_set_instr
|
|
|
|
pos = Position.set( @label , 0 , @binary)
|
|
|
|
assert_equal IPosition , pos.class
|
|
|
|
end
|
|
|
|
def test_set_bin
|
|
|
|
pos = Position.set( @binary , 0 , Parfait.object_space.get_main)
|
|
|
|
assert_equal BPosition , pos.class
|
|
|
|
end
|
|
|
|
def test_ins_propagates
|
|
|
|
@label.set_next Arm::ArmMachine.b( @label)
|
|
|
|
Position.set( @label , 0 , @binary)
|
|
|
|
assert_equal 0 , Position.get(@label.next).at
|
|
|
|
end
|
2018-05-08 19:53:48 +02:00
|
|
|
def test_ins_propagates_again
|
|
|
|
second = Arm::ArmMachine.b( @label)
|
|
|
|
@label.set_next(second)
|
|
|
|
Position.set( @label , 0 , @binary)
|
|
|
|
Position.set(second , 2 , @binary)
|
|
|
|
Position.set( @label , 0 , @binary)
|
|
|
|
assert_equal 0 , Position.get(@label.next).at
|
|
|
|
end
|
2018-05-08 18:59:43 +02:00
|
|
|
def test_bin_propagates
|
|
|
|
@binary.extend_to(16)
|
|
|
|
Position.set( @binary , 0 , Parfait.object_space.get_main)
|
|
|
|
assert_equal @binary.padded_length , Position.get(@binary.next).at
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|