seperate different Position classes into own files
also tests and have Position module keep all positions (singletons should be at module, not class level)
This commit is contained in:
31
test/risc/position/test_instruction_position.rb
Normal file
31
test/risc/position/test_instruction_position.rb
Normal file
@ -0,0 +1,31 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Risc
|
||||
module Position
|
||||
# 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 InstructionPosition , 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_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
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user