Fix bad test coverage

One typo, one debug test
Also stop producing those object files, use in memory io
This commit is contained in:
Torsten Rüger 2019-09-25 01:14:00 +03:00
parent 42ed70b50b
commit 701890f625
6 changed files with 24 additions and 10 deletions

View File

@ -67,10 +67,20 @@ module Elf
@symbol_table.add_func_symbol name, offset, @text, linkage
end
def save(filename)
to = File.open(filename, 'wb')
@object.write to
to.close
# save to either file or io
# Pass Filename as string
# or any io object
def save(file)
case file
when String
io = File.open(file, 'wb')
when IO , StringIO
io = file
else
raise "must pass io or filename, not #{file}"
end
@object.write io
io.close
end
end

View File

@ -10,10 +10,10 @@ module Elf
def as_main(input)
in_space("def main(arg);#{input};end")
end
def check(input, file)
def check(input)
linker = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_binary( input , :arm )
writer = Elf::ObjectWriter.new(linker)
writer.save "test/#{file}.o"
writer.save StringIO.new
end
end
end

View File

@ -23,7 +23,7 @@ module Elf
end
HERE
@exit_code = 4
check get_preload("Integer.lt;Integer.plus") + in_space(input) , "fibo"
check get_preload("Integer.lt;Integer.plus") + in_space(input)
end
end
end

View File

@ -9,7 +9,7 @@ module Elf
preload = "class Word < Data8;def putstring;X.putstring;end;end;"
@stdout = hello
@exit_code = hello.length
check preload + as_main(input), "hello"
check preload + as_main(input)
end
end
end

View File

@ -11,8 +11,12 @@ module Elf
def test_empty_translate
writer = Elf::ObjectWriter.new(@linker )
writer.save "test/zero.o"
writer.save StringIO.new
end
def test_empty_translate_with_debug
writer = Elf::ObjectWriter.new(@linker , debug: true )
writer.save StringIO.new
end
end
end

View File

@ -2,7 +2,7 @@ require_relative "helper"
module RubyX
module Macro
class TestObjectGet < MiniTest::Test
class TestObjectSet < MiniTest::Test
include MacroHelper
def source
<<GET