a little more minimal elf tests
This commit is contained in:
parent
fb414cecd6
commit
a2ece04b6d
@ -21,10 +21,10 @@ module Elf
|
|||||||
set_text assembler.write_as_string
|
set_text assembler.write_as_string
|
||||||
|
|
||||||
# for debug add labels for labels
|
# for debug add labels for labels
|
||||||
Parfait.object_space.types.values.each do |type|
|
Parfait.object_space.each_type do |type|
|
||||||
type.methods.each do |f|
|
type.methods.each do |f|
|
||||||
f.instructions.each_label do |label|
|
f.instructions.each_label do |label|
|
||||||
add_symbol "#{clazz.name}::#{f.name}:#{label.name}" , label.position
|
add_symbol "#{type.name}::#{f.name}:#{label.name}" , label.position
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,7 +11,7 @@ module Register
|
|||||||
class Assembler
|
class Assembler
|
||||||
include Padding
|
include Padding
|
||||||
include Logging
|
include Logging
|
||||||
log_level :debug
|
log_level :info
|
||||||
|
|
||||||
MARKER = 0xA51AF00D
|
MARKER = 0xA51AF00D
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ module Register
|
|||||||
|
|
||||||
def write_object_indexed(object)
|
def write_object_indexed(object)
|
||||||
written = 0
|
written = 0
|
||||||
if( object.is_a? Parfait::Indexed)
|
if( object.is_a? Parfait::List)
|
||||||
object.each do |inst|
|
object.each do |inst|
|
||||||
write_ref_for(inst)
|
write_ref_for(inst)
|
||||||
written += 4
|
written += 4
|
||||||
|
@ -14,7 +14,7 @@ module Register
|
|||||||
class Machine
|
class Machine
|
||||||
include Collector
|
include Collector
|
||||||
include Logging
|
include Logging
|
||||||
log_level :debug
|
log_level :info
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@objects = {}
|
@objects = {}
|
||||||
|
@ -6,7 +6,7 @@ class HelloTest < MiniTest::Test
|
|||||||
def check
|
def check
|
||||||
machine = Register.machine.boot
|
machine = Register.machine.boot
|
||||||
Typed.compile( @input )
|
Typed.compile( @input )
|
||||||
machine.collect
|
machine.collect_space
|
||||||
machine.translate_arm
|
machine.translate_arm
|
||||||
writer = Elf::ObjectWriter.new
|
writer = Elf::ObjectWriter.new
|
||||||
writer.save "test/hello.o"
|
writer.save "test/hello.o"
|
||||||
@ -15,6 +15,6 @@ class HelloTest < MiniTest::Test
|
|||||||
def test_string_put
|
def test_string_put
|
||||||
@input = s(:statements, s(:return, s(:call, s(:name, :putstring), s(:arguments),
|
@input = s(:statements, s(:return, s(:call, s(:name, :putstring), s(:arguments),
|
||||||
s(:receiver, s(:string, "Hello again\\n")))))
|
s(:receiver, s(:string, "Hello again\\n")))))
|
||||||
# check
|
check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,18 +2,32 @@ require_relative "../helper"
|
|||||||
|
|
||||||
class TestZeroCode < MiniTest::Test
|
class TestZeroCode < MiniTest::Test
|
||||||
|
|
||||||
def test_string_put
|
def setup
|
||||||
machine = Register.machine.boot
|
@machine = Register.machine.boot
|
||||||
space = Parfait.object_space
|
@space = Parfait.object_space
|
||||||
space.each_type do | type |
|
@space.each_type do | type |
|
||||||
type.method_names.each do |method|
|
type.method_names.each do |method|
|
||||||
type.remove_method(method)
|
type.remove_method(method) unless keeper(method)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
assert_equal 0 , space.collect_methods.length
|
@machine.collect_space
|
||||||
machine.collect_space
|
end
|
||||||
machine.translate_arm
|
def keeper name
|
||||||
# writer = Elf::ObjectWriter.new
|
name == :main or name == :__init__
|
||||||
# writer.save "test/zero.o"
|
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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user