rubyx/test/risc/position/test_object_position.rb
Torsten Ruger 8ca70a6835 Steamline objectPosition init
check for resetting on the same position with different class, which
should not happen
Ie it’s ok for an object to push another object up,
but not for an instruction to land on code
2018-05-23 21:34:49 +03:00

53 lines
1.3 KiB
Ruby

require_relative "../helper"
module Risc
module Position
# tests that do no require a boot and only test basic positioning
class TestPositionBasic < MiniTest::Test
def test_creation_ok
assert ObjectPosition.new(self,0)
end
def test_creation_fail
assert_raises {Position.new("0")}
end
def test_add
res = ObjectPosition.new(self,0) + 5
assert_equal 5 , res
end
def test_sub
res = ObjectPosition.new(self,0) - 1
assert_equal -1 , res
end
def test_sub_pos
res = ObjectPosition.new(self,0) - ObjectPosition.new(self,0)
assert_equal 0 , res
end
def test_set
pos = Position.set(self , 5)
assert_equal 5 , pos.at
end
def tet_tos
assert_equal "0x10" , Position.set(self).to_s
end
def test_reset_ok
pos = Position.set(self , 5)
pos = Position.set(self , 10)
assert_equal 10 , pos.at
end
def test_reset_fail
Position.set(self , 5)
assert_raises{Position.set(self , 10000)}
end
def test_raises_set_nil
assert_raises { Position.set(self,nil)}
end
def test_at
pos = Position.set(self , 5)
pos = Position.at(5)
assert_equal 5 , pos.at
end
end
end
end