start passing positions along inside the position code
This commit is contained in:
@ -1,12 +1,9 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Risc
|
||||
# tests that do no require a boot and only test basic positioning
|
||||
class TestPositionBasic < MiniTest::Test
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@binary = Parfait::BinaryCode.new(1)
|
||||
end
|
||||
def test_creation_ok
|
||||
assert Position.new(0)
|
||||
end
|
||||
@ -29,10 +26,6 @@ module Risc
|
||||
pos = Position.set(self , 5)
|
||||
assert_equal 5 , pos.at
|
||||
end
|
||||
def test_set_instr
|
||||
pos = Position.set( Risc::Label.new("hi","ho") , 0 , @binary)
|
||||
assert_equal IPosition , pos.class
|
||||
end
|
||||
def tet_tos
|
||||
assert_equal "0x10" , Position.set(self).to_s
|
||||
end
|
||||
|
30
test/risc/test_position2.rb
Normal file
30
test/risc/test_position2.rb
Normal file
@ -0,0 +1,30 @@
|
||||
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
|
||||
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
|
Reference in New Issue
Block a user