rubyx/test/risc/test_collector.rb
Torsten Rüger 2c4f040654 starting to move builtin into parfait
single object method for now
little framework next
2019-09-10 20:40:41 +03:00

77 lines
1.7 KiB
Ruby

require_relative "../helper"
module Risc
module CollectT
def boot( num )
opt = Parfait.default_test_options
if(num)
opt[:Integer] = 400
opt[:Message] = 400
end
Parfait.boot!(opt)
Mom.boot!
Risc.boot!
@linker = Mom::MomCollection.new.to_risc.translate(:arm)
end
def test_simple_collect
objects = Collector.collect_space(@linker)
assert_equal len , objects.length , objects.length.to_s
end
def test_integer_positions
objects = Collector.collect_space(@linker)
int = Parfait.object_space.get_next_for(:Integer)
count = 0
while(int)
count += 1
assert Position.set?(int) , "INT #{int.object_id.to_s(16)} , count #{count}"
int = int.next_integer
end
end
end
class TestCollector < MiniTest::Test
include CollectT
def setup
boot(nil)
end
def len
1564
end
def test_collect_all_types
Collector.collect_space(@linker).each do |objekt , position|
next unless objekt.is_a?( Parfait::Type )
assert Parfait.object_space.get_type_for( objekt.hash ) , objekt.hash
end
end
def test_allowed_types
Collector.collect_space(@linker).each do |objekt , position|
next if objekt.is_a?( Parfait::Object )
next if objekt.is_a?( Symbol )
assert false
end
end
def test_positions
Collector.collect_space(@linker).each do |objekt , position|
assert_equal Position , position.class
assert !position.valid?
end
end
end
class TestBigCollector < MiniTest::Test
include CollectT
def setup
boot(400)
end
def len
3044
end
end
end