2018-04-26 11:31:37 +02:00
|
|
|
require_relative "helper"
|
2018-04-01 10:56:04 +02:00
|
|
|
|
|
|
|
module Parfait
|
2018-04-26 11:31:37 +02:00
|
|
|
class TestInteger < ParfaitTest
|
2018-04-01 10:56:04 +02:00
|
|
|
|
|
|
|
def setup
|
2018-04-26 11:31:37 +02:00
|
|
|
super
|
2018-04-01 10:56:04 +02:00
|
|
|
@int = Integer.new(10)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_class
|
|
|
|
assert_equal :Integer, @int.get_type.object_class.name
|
|
|
|
end
|
|
|
|
def test_next_nil
|
|
|
|
assert_nil @int.next_integer
|
|
|
|
end
|
|
|
|
def test_next_not_nil
|
|
|
|
int2 = Integer.new(0 , @int)
|
|
|
|
assert_equal Integer, int2.next_integer.class
|
|
|
|
end
|
|
|
|
def test_value_10
|
|
|
|
assert_equal 10 , @int.value
|
|
|
|
end
|
|
|
|
def test_word_value_10
|
|
|
|
assert_equal 10 , @int.get_internal_word( Integer.integer_index )
|
|
|
|
end
|
|
|
|
def test_word_settable
|
|
|
|
assert_equal 20 , @int.set_internal_word( Integer.integer_index , 20 )
|
|
|
|
end
|
|
|
|
def test_word_set
|
|
|
|
assert_equal 20 , @int.set_internal_word( Integer.integer_index , 20 )
|
|
|
|
assert_equal 20 , @int.get_internal_word( Integer.integer_index )
|
|
|
|
end
|
|
|
|
def test_integer_first
|
|
|
|
assert Parfait.object_space.next_integer
|
|
|
|
end
|
|
|
|
def test_integer_20
|
|
|
|
int = Parfait.object_space.next_integer
|
|
|
|
20.times do
|
|
|
|
assert int
|
|
|
|
assert_equal Parfait::Integer , int.class
|
2018-05-14 10:55:01 +02:00
|
|
|
assert int.get_internal_word(1)
|
2018-04-01 10:56:04 +02:00
|
|
|
int = int.next_integer
|
|
|
|
end
|
|
|
|
end
|
2018-05-29 16:03:55 +02:00
|
|
|
def test_set
|
|
|
|
@int.set_value(1)
|
|
|
|
assert_equal 1 , @int.value
|
|
|
|
end
|
2018-04-01 10:56:04 +02:00
|
|
|
end
|
2018-05-30 22:49:01 +02:00
|
|
|
class AddressTest < ParfaitTest
|
|
|
|
def test_address
|
|
|
|
assert ReturnAddress.new(55)
|
|
|
|
end
|
|
|
|
def test_value
|
|
|
|
assert_equal 55 , ReturnAddress.new(55).value
|
|
|
|
end
|
|
|
|
def test_value_set
|
|
|
|
addr = ReturnAddress.new(55)
|
|
|
|
addr.set_value(33)
|
|
|
|
assert_equal 33 , addr.value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-01 10:56:04 +02:00
|
|
|
end
|