rubyx/test/elf/test_zero.rb

37 lines
919 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
Parfait.boot!
@machine = Risc.machine.boot
2016-12-31 14:08:32 +01:00
@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
@objects = Risc::Collector.collect_space
2016-12-31 14:08:32 +01:00
end
def keeper name
name == :main or name == :__init__
end
2018-06-25 19:21:15 +02:00
def test_empty_translate
2018-05-01 18:19:37 +02:00
assert_equal 2 , @space.get_all_methods.length
@machine.translate(:arm)
2018-06-25 19:21:15 +02:00
@machine.position_all
@machine.create_binary
writer = Elf::ObjectWriter.new(@machine )
2016-12-31 14:08:32 +01:00
writer.save "test/zero.o"
end
def test_methods_match_objects
2018-05-01 18:19:37 +02:00
assert_equal 2 , @space.get_all_methods.length
@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