small arm fixes etc
This commit is contained in:
@ -6,6 +6,7 @@ module Risc
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@binary = Parfait::BinaryCode.new(1)
|
||||
@bin_pos = Position.new(@binary,0)
|
||||
@instruction = DummyInstruction.new(DummyInstruction.new)
|
||||
@position = InstructionListener.init(@instruction , @binary)
|
||||
end
|
||||
@ -41,13 +42,34 @@ module Risc
|
||||
Position.get(label).set(10)
|
||||
assert_equal 10 , Position.get(@instruction).at
|
||||
end
|
||||
def test_label_at
|
||||
branch = Branch.new("b" , @label)
|
||||
Position.new(@label , 8 )
|
||||
def test_label_at_branch
|
||||
label = Label.new("Hi","Ho" , FakeAddress.new(5) , @instruction)
|
||||
branch = Branch.new("b" , label)
|
||||
Position.new(label , 8 )
|
||||
Position.new(branch , 8 )
|
||||
at_8 = Position.at(8)
|
||||
assert_equal Position , at_8.class
|
||||
assert_equal Branch , at_8.object.class
|
||||
end
|
||||
end
|
||||
class TestInstructionListenerBig < MiniTest::Test
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@binary = Parfait::BinaryCode.new(1)
|
||||
@bin_pos = Position.new(@binary,0)
|
||||
@instruction = DummyInstruction.new
|
||||
13.times {@instruction.last.insert(DummyInstruction.new) }
|
||||
@position = InstructionListener.init(@instruction , @binary)
|
||||
@position.set(8)
|
||||
end
|
||||
def test_padding
|
||||
assert_equal 64 , @binary.padded_length
|
||||
end
|
||||
def test_last
|
||||
assert_equal 72 , Position.get(@instruction.last).at
|
||||
end
|
||||
def test_next
|
||||
assert @binary.next
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -49,6 +49,9 @@ module Risc
|
||||
res = @pos - Position.new(@pos,4)
|
||||
assert_equal 1 , res
|
||||
end
|
||||
def test_lg
|
||||
assert @pos > Position.new(@pos,4)
|
||||
end
|
||||
def test_tos
|
||||
assert_equal "0x5" , @pos.to_s
|
||||
end
|
||||
|
Reference in New Issue
Block a user