2017-01-01 20:51:23 +01:00
|
|
|
require_relative "../helper"
|
|
|
|
|
2017-01-19 08:02:29 +01:00
|
|
|
module Risc
|
2017-01-01 20:51:23 +01:00
|
|
|
class TestAssembler < MiniTest::Test
|
|
|
|
|
|
|
|
def setup
|
2017-01-19 08:02:29 +01:00
|
|
|
@machine = Risc.machine.boot
|
2017-01-01 20:51:23 +01:00
|
|
|
end
|
|
|
|
def test_no_object
|
|
|
|
@assembler = Assembler.new(@machine , {})
|
2018-03-18 18:07:15 +01:00
|
|
|
assert @machine.translate_arm
|
2017-01-01 20:51:23 +01:00
|
|
|
end
|
|
|
|
def test_space
|
|
|
|
@assembler = Assembler.new(@machine , Collector.collect_space)
|
2018-03-18 18:07:15 +01:00
|
|
|
assert @machine.translate_arm
|
2017-01-01 20:51:23 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_write_fails
|
|
|
|
@assembler = Assembler.new(@machine , {})
|
|
|
|
assert_raises{ @assembler.assemble} #must translate first
|
|
|
|
end
|
|
|
|
def test_assemble_no_objects
|
|
|
|
@assembler = Assembler.new(@machine , {})
|
2018-03-18 18:07:15 +01:00
|
|
|
assert @machine.translate_arm
|
2017-01-01 20:51:23 +01:00
|
|
|
assert @assembler.assemble
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_translate_space
|
|
|
|
@assembler = Assembler.new(@machine , Collector.collect_space)
|
2018-03-18 18:07:15 +01:00
|
|
|
assert @machine.translate_arm
|
2017-01-01 20:51:23 +01:00
|
|
|
end
|
|
|
|
def test_assemble_space
|
|
|
|
@assembler = Assembler.new(@machine , Collector.collect_space)
|
2018-03-18 18:07:15 +01:00
|
|
|
assert @machine.translate_arm
|
2017-01-01 20:51:23 +01:00
|
|
|
assert @assembler.assemble
|
|
|
|
end
|
2018-03-25 17:23:00 +02:00
|
|
|
def pest_write_space
|
2017-01-01 20:51:23 +01:00
|
|
|
@assembler = Assembler.new(@machine , Collector.collect_space)
|
2018-03-18 18:07:15 +01:00
|
|
|
assert @machine.translate_arm
|
2017-01-01 20:51:23 +01:00
|
|
|
assert @assembler.write_as_string
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|