393ac873c9
as it was before blocks (thought blocks would make reuse of messages impossible, but was wrong, this only appilies to lambdas) (too) many tests affected
53 lines
1.4 KiB
Ruby
53 lines
1.4 KiB
Ruby
require_relative "../helper"
|
|
|
|
module Risc
|
|
class TestTextWriter < MiniTest::Test
|
|
|
|
def setup
|
|
Parfait.boot!
|
|
Risc.boot!
|
|
@linker = Mom::MomCompiler.new.translate(:arm)
|
|
end
|
|
def test_init
|
|
@text_writer = TextWriter.new(@linker)
|
|
end
|
|
def test_write_fails
|
|
@text_writer = TextWriter.new(@linker)
|
|
assert_raises{ @text_writer.write_as_string} #must translate first
|
|
end
|
|
end
|
|
class TestTextWriterPositions < MiniTest::Test
|
|
|
|
def setup
|
|
Parfait.boot!
|
|
Risc.boot!
|
|
@linker = Mom::MomCompiler.new.translate(:arm)
|
|
@linker.position_all
|
|
@linker.create_binary
|
|
@text_writer = TextWriter.new(@linker)
|
|
end
|
|
def test_write_all
|
|
assert @text_writer.write_as_string
|
|
end
|
|
def test_sorted_class
|
|
assert_equal Array , @text_writer.sorted_objects.class
|
|
end
|
|
def test_sorted_positions1
|
|
sorted_objects = @text_writer.sorted_objects
|
|
check_positions(sorted_objects)
|
|
end
|
|
def test_sorted_positions2
|
|
sorted_objects = @text_writer.sorted_objects
|
|
sorted_objects.shift
|
|
check_positions(sorted_objects)
|
|
end
|
|
def check_positions(objects)
|
|
objects.each_slice(2) do |l,r|
|
|
next unless r
|
|
next if l.is_a?(Label) or r.is_a?(Label)
|
|
#assert Position.get(l).at < Position.get(r).at , "#{Position.get(l)} < #{Position.get(r)} , #{l.object_id.to_s(16)}, #{r.object_id.to_s(16)}, #{l.class}, #{r.class}"
|
|
end
|
|
end
|
|
end
|
|
end
|