rubyx/test/elf/test_zero.rb

34 lines
829 B
Ruby
Raw Normal View History

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 |
type.method_names.each do |method|
2016-12-31 14:08:32 +01:00
type.remove_method(method) unless keeper(method)
end
end
2016-12-31 14:08:32 +01:00
@machine.collect_space
end
def keeper name
name == :main or name == :__init__
end
def test_empty_translate
assert_equal 2 , @space.collect_methods.length
@machine.translate_arm
writer = Elf::ObjectWriter.new
writer.save "test/zero.o"
end
def test_methods_match_objects
assert_equal 2 , @space.collect_methods.length
@machine.objects.each do |id , objekt|
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