Fix bad test coverage
One typo, one debug test Also stop producing those object files, use in memory io
This commit is contained in:
parent
42ed70b50b
commit
701890f625
@ -67,10 +67,20 @@ module Elf
|
|||||||
@symbol_table.add_func_symbol name, offset, @text, linkage
|
@symbol_table.add_func_symbol name, offset, @text, linkage
|
||||||
end
|
end
|
||||||
|
|
||||||
def save(filename)
|
# save to either file or io
|
||||||
to = File.open(filename, 'wb')
|
# Pass Filename as string
|
||||||
@object.write to
|
# or any io object
|
||||||
to.close
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -10,10 +10,10 @@ module Elf
|
|||||||
def as_main(input)
|
def as_main(input)
|
||||||
in_space("def main(arg);#{input};end")
|
in_space("def main(arg);#{input};end")
|
||||||
end
|
end
|
||||||
def check(input, file)
|
def check(input)
|
||||||
linker = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_binary( input , :arm )
|
linker = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_binary( input , :arm )
|
||||||
writer = Elf::ObjectWriter.new(linker)
|
writer = Elf::ObjectWriter.new(linker)
|
||||||
writer.save "test/#{file}.o"
|
writer.save StringIO.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -23,7 +23,7 @@ module Elf
|
|||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@exit_code = 4
|
@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
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,7 @@ module Elf
|
|||||||
preload = "class Word < Data8;def putstring;X.putstring;end;end;"
|
preload = "class Word < Data8;def putstring;X.putstring;end;end;"
|
||||||
@stdout = hello
|
@stdout = hello
|
||||||
@exit_code = hello.length
|
@exit_code = hello.length
|
||||||
check preload + as_main(input), "hello"
|
check preload + as_main(input)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,8 +11,12 @@ module Elf
|
|||||||
|
|
||||||
def test_empty_translate
|
def test_empty_translate
|
||||||
writer = Elf::ObjectWriter.new(@linker )
|
writer = Elf::ObjectWriter.new(@linker )
|
||||||
writer.save "test/zero.o"
|
writer.save StringIO.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_empty_translate_with_debug
|
||||||
|
writer = Elf::ObjectWriter.new(@linker , debug: true )
|
||||||
|
writer.save StringIO.new
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,7 +2,7 @@ require_relative "helper"
|
|||||||
|
|
||||||
module RubyX
|
module RubyX
|
||||||
module Macro
|
module Macro
|
||||||
class TestObjectGet < MiniTest::Test
|
class TestObjectSet < MiniTest::Test
|
||||||
include MacroHelper
|
include MacroHelper
|
||||||
def source
|
def source
|
||||||
<<GET
|
<<GET
|
||||||
|
Loading…
x
Reference in New Issue
Block a user