2016-12-31 20:05:19 +01:00
|
|
|
require_relative "../helper"
|
|
|
|
|
2017-01-19 08:02:29 +01:00
|
|
|
module Risc
|
2016-12-31 20:05:19 +01:00
|
|
|
class TestCollector < MiniTest::Test
|
2018-03-26 18:43:03 +02:00
|
|
|
|
|
|
|
def setup
|
2019-02-08 22:03:23 +01:00
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2018-07-01 13:12:42 +02:00
|
|
|
Risc.boot!
|
2019-08-12 23:13:29 +02:00
|
|
|
@linker = Mom::MomCollection.new.to_risc.translate(:arm)
|
2018-03-26 18:43:03 +02:00
|
|
|
end
|
|
|
|
|
2016-12-31 20:05:19 +01:00
|
|
|
def test_simple_collect
|
2018-07-01 13:12:42 +02:00
|
|
|
objects = Collector.collect_space(@linker)
|
2019-08-22 22:10:29 +02:00
|
|
|
assert_equal 602 , objects.length , objects.length.to_s
|
2016-12-31 20:05:19 +01:00
|
|
|
end
|
2018-03-26 18:43:03 +02:00
|
|
|
|
|
|
|
def test_collect_all_types
|
2018-07-01 13:12:42 +02:00
|
|
|
Collector.collect_space(@linker).each do |objekt , position|
|
2018-03-26 18:43:03 +02:00
|
|
|
next unless objekt.is_a?( Parfait::Type )
|
|
|
|
assert Parfait.object_space.get_type_for( objekt.hash ) , objekt.hash
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-27 18:06:16 +02:00
|
|
|
def test_allowed_types
|
2018-07-01 13:12:42 +02:00
|
|
|
Collector.collect_space(@linker).each do |objekt , position|
|
2018-03-27 18:06:16 +02:00
|
|
|
next if objekt.is_a?( Parfait::Object )
|
|
|
|
next if objekt.is_a?( Symbol )
|
2018-06-15 20:54:21 +02:00
|
|
|
assert false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def test_positions
|
2018-07-01 13:12:42 +02:00
|
|
|
Collector.collect_space(@linker).each do |objekt , position|
|
2018-06-15 20:54:21 +02:00
|
|
|
assert_equal Position , position.class
|
|
|
|
assert !position.valid?
|
2018-03-27 18:06:16 +02:00
|
|
|
end
|
|
|
|
end
|
2019-07-28 15:42:40 +02:00
|
|
|
def test_integer_positions
|
|
|
|
objects = Collector.collect_space(@linker)
|
|
|
|
int = Parfait.object_space.get_next_for(:Integer)
|
|
|
|
while(int)
|
|
|
|
assert Position.set?(int) , "INt #{int.object_id}"
|
|
|
|
int = int.next_integer
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class TestBigCollector < MiniTest::Test
|
|
|
|
|
|
|
|
def setup
|
|
|
|
opt = Parfait.default_test_options
|
2019-08-12 23:13:29 +02:00
|
|
|
opt[:factory] = 400
|
2019-07-28 15:42:40 +02:00
|
|
|
Parfait.boot!(opt)
|
|
|
|
Risc.boot!
|
2019-08-12 23:13:29 +02:00
|
|
|
@linker = Mom::MomCollection.new.to_risc.translate(:arm)
|
2019-07-28 15:42:40 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_simple_collect
|
|
|
|
objects = Collector.collect_space(@linker)
|
2019-08-22 22:10:29 +02:00
|
|
|
assert_equal 2402, objects.length , objects.length.to_s
|
2019-07-28 15:42:40 +02:00
|
|
|
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} , count #{count}"
|
|
|
|
int = int.next_integer
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-12-31 20:05:19 +01:00
|
|
|
end
|
|
|
|
end
|