2016-12-30 12:15:08 +01:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
class TestZeroCode < MiniTest::Test
|
|
|
|
|
2016-12-31 14:08:32 +01:00
|
|
|
def setup
|
|
|
|
@machine = Register.machine.boot
|
|
|
|
@space = Parfait.object_space
|
|
|
|
@space.each_type do | type |
|
2016-12-30 20:00:18 +01:00
|
|
|
type.method_names.each do |method|
|
2016-12-31 14:08:32 +01:00
|
|
|
type.remove_method(method) unless keeper(method)
|
2016-12-30 20:00:18 +01:00
|
|
|
end
|
|
|
|
end
|
2016-12-31 18:54:18 +01:00
|
|
|
@objects = Register::Collector.collect_space
|
2016-12-31 14:08:32 +01:00
|
|
|
end
|
|
|
|
def keeper name
|
|
|
|
name == :main or name == :__init__
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_empty_translate
|
|
|
|
assert_equal 2 , @space.collect_methods.length
|
|
|
|
@machine.translate_arm
|
2016-12-31 17:46:17 +01:00
|
|
|
writer = Elf::ObjectWriter.new(@machine , @objects )
|
2016-12-31 14:08:32 +01:00
|
|
|
writer.save "test/zero.o"
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_methods_match_objects
|
|
|
|
assert_equal 2 , @space.collect_methods.length
|
2016-12-31 17:46:17 +01:00
|
|
|
@objects.each do |id , objekt|
|
2016-12-31 14:08:32 +01:00
|
|
|
next unless objekt.is_a? Parfait::TypedMethod
|
|
|
|
assert keeper(objekt.name) , "CODE1 #{objekt.name}"
|
|
|
|
end
|
2016-12-30 12:15:08 +01:00
|
|
|
end
|
|
|
|
end
|