d396da16e3
page was maybe a too low level name pages may be the unit of the syscall, but after that objects desolve (maybe later to be added on from different pages) Factory has the job of handing out a new instance of a type it keeps a freelist for that and a reserve
48 lines
1.1 KiB
Ruby
48 lines
1.1 KiB
Ruby
require_relative "helper"
|
|
|
|
module Parfait
|
|
class TestPage < ParfaitTest
|
|
|
|
def setup
|
|
super
|
|
@factory = Factory.new Parfait.object_space.get_type_by_class_name(:Integer)
|
|
end
|
|
def test_ok
|
|
assert @factory
|
|
end
|
|
def test_name_ok
|
|
assert @factory.attribute_name.to_s.start_with?("next")
|
|
end
|
|
def test_get_next
|
|
assert_nil @factory.get_next_for( Integer.new(1))
|
|
end
|
|
def test_no_next
|
|
assert_nil @factory.next_object
|
|
assert_nil @factory.last_object
|
|
assert_nil @factory.reserve
|
|
end
|
|
def test_get_next_object
|
|
assert_equal Parfait::Integer , @factory.get_next_object.class
|
|
end
|
|
def test_chain_length
|
|
count = 0
|
|
start = @factory.get_next_object
|
|
while( start )
|
|
start = start.next_integer
|
|
count += 1
|
|
end
|
|
assert_equal 1024 - 10 , count
|
|
end
|
|
def test_reserve_length
|
|
count = 0
|
|
start = @factory.get_next_object
|
|
start = @factory.reserve
|
|
while( start )
|
|
start = start.next_integer
|
|
count += 1
|
|
end
|
|
assert_equal 11 , count
|
|
end
|
|
end
|
|
end
|