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
This commit is contained in:
Torsten Ruger
2018-05-23 21:34:49 +03:00
parent f5d1090c39
commit 8ca70a6835
6 changed files with 39 additions and 31 deletions

View File

@ -6,22 +6,22 @@ module Risc
class TestPositionBasic < MiniTest::Test
def test_creation_ok
assert ObjectPosition.new(0,self)
assert ObjectPosition.new(self,0)
end
def test_creation_fail
assert_raises {Position.new("0")}
end
def test_add
res = ObjectPosition.new(0,self) + 5
res = ObjectPosition.new(self,0) + 5
assert_equal 5 , res
end
def test_sub
res = ObjectPosition.new(5,self) - 1
assert_equal 4 , res
res = ObjectPosition.new(self,0) - 1
assert_equal -1 , res
end
def test_sub_pos
res = ObjectPosition.new(5,self) - ObjectPosition.new(1,self)
assert_equal 4 , res
res = ObjectPosition.new(self,0) - ObjectPosition.new(self,0)
assert_equal 0 , res
end
def test_set
pos = Position.set(self , 5)