2015-07-19 09:54:36 +02:00
|
|
|
require_relative "../helper"
|
|
|
|
|
2016-12-15 21:15:20 +01:00
|
|
|
class TestPosition
|
|
|
|
include Positioned
|
|
|
|
end
|
|
|
|
|
2015-07-19 09:54:36 +02:00
|
|
|
class TestPositioning < MiniTest::Test
|
2015-10-16 16:13:08 +02:00
|
|
|
def setup
|
2015-10-22 17:16:29 +02:00
|
|
|
Register.machine.boot unless Register.machine.booted
|
2015-10-16 16:13:08 +02:00
|
|
|
end
|
2015-07-19 09:54:36 +02:00
|
|
|
def test_list1
|
2015-11-18 10:55:29 +01:00
|
|
|
list = Parfait.new_list([1])
|
2016-02-25 20:50:10 +01:00
|
|
|
list.set_type( Parfait::Type.new Object)
|
2015-11-04 09:33:10 +01:00
|
|
|
assert_equal 32 , list.padded_length
|
2015-07-19 09:54:36 +02:00
|
|
|
end
|
|
|
|
def test_list5
|
2015-11-18 10:55:29 +01:00
|
|
|
list = Parfait.new_list([1,2,3,4,5])
|
2016-02-25 20:50:10 +01:00
|
|
|
list.set_type( Parfait::Type.new Object)
|
2015-11-04 09:33:10 +01:00
|
|
|
assert_equal 32 , list.padded_length
|
2015-07-19 09:54:36 +02:00
|
|
|
end
|
2016-02-25 20:50:10 +01:00
|
|
|
def test_type
|
|
|
|
type = Parfait::Type.new Object
|
|
|
|
type.set_type( Parfait::Type.new Object)
|
|
|
|
type.push 5
|
|
|
|
assert_equal 32 , type.padded_length
|
2015-07-19 09:54:36 +02:00
|
|
|
end
|
2015-11-03 15:21:50 +01:00
|
|
|
def test_word
|
|
|
|
word = Parfait::Word.new(12)
|
2015-11-04 09:33:10 +01:00
|
|
|
assert_equal 32 , word.padded_length
|
2015-11-03 15:21:50 +01:00
|
|
|
end
|
2016-12-15 21:15:20 +01:00
|
|
|
def test_raises_no_init
|
|
|
|
assert_raises { TestPosition.new.position}
|
|
|
|
end
|
|
|
|
def test_raises_set_nil
|
|
|
|
assert_raises { TestPosition.new.position = nil}
|
|
|
|
end
|
|
|
|
def test_raises_reset_far
|
|
|
|
assert_raises do
|
|
|
|
test = TestPosition.new
|
|
|
|
test.position = 0
|
|
|
|
test.position = 12000
|
|
|
|
end
|
|
|
|
end
|
2015-07-19 09:54:36 +02:00
|
|
|
end
|