2016-12-31 20:05:19 +01:00
|
|
|
require_relative "../helper"
|
|
|
|
|
2017-01-19 08:02:29 +01:00
|
|
|
module Risc
|
2019-09-10 19:40:41 +02:00
|
|
|
module CollectT
|
2019-09-13 13:07:12 +02:00
|
|
|
include ScopeHelper
|
|
|
|
|
2019-09-10 19:40:41 +02:00
|
|
|
def boot( num )
|
|
|
|
opt = Parfait.default_test_options
|
|
|
|
if(num)
|
|
|
|
opt[:Integer] = 400
|
|
|
|
opt[:Message] = 400
|
|
|
|
end
|
2019-09-13 13:07:12 +02:00
|
|
|
compiler = compiler_with_main({parfait: opt})
|
|
|
|
@linker = compiler.to_target( :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-09-10 19:40:41 +02:00
|
|
|
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
|
2019-09-30 16:09:13 +02:00
|
|
|
1426
|
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 )
|
2019-09-22 23:07:30 +02:00
|
|
|
assert Parfait.object_space.types[ objekt.hash] , objekt.hash
|
2018-03-26 18:43:03 +02:00
|
|
|
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 )
|
2019-09-13 13:07:12 +02:00
|
|
|
assert false , objekt.class.name
|
2018-06-15 20:54:21 +02:00
|
|
|
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
|
2019-09-13 13:07:12 +02:00
|
|
|
assert !position.valid? , objekt.class.name
|
2018-03-27 18:06:16 +02:00
|
|
|
end
|
|
|
|
end
|
2019-07-28 15:42:40 +02:00
|
|
|
end
|
|
|
|
class TestBigCollector < MiniTest::Test
|
2019-09-10 19:40:41 +02:00
|
|
|
include CollectT
|
2019-07-28 15:42:40 +02:00
|
|
|
|
|
|
|
def setup
|
2019-09-10 19:40:41 +02:00
|
|
|
boot(400)
|
2019-07-28 15:42:40 +02:00
|
|
|
end
|
|
|
|
|
2019-09-10 19:40:41 +02:00
|
|
|
def len
|
2019-09-30 16:09:13 +02:00
|
|
|
2906
|
2019-07-28 15:42:40 +02:00
|
|
|
end
|
2016-12-31 20:05:19 +01:00
|
|
|
end
|
|
|
|
end
|