some extra assembler tests
This commit is contained in:
parent
06cfbdf066
commit
b8b387d498
@ -1,5 +1,6 @@
|
||||
require_relative "interpreter/test_all"
|
||||
|
||||
require_relative "test_assembler"
|
||||
require_relative "test_collector"
|
||||
require_relative "test_compat"
|
||||
require_relative "test_instructions"
|
||||
|
43
test/register/test_assembler.rb
Normal file
43
test/register/test_assembler.rb
Normal file
@ -0,0 +1,43 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Register
|
||||
class TestAssembler < MiniTest::Test
|
||||
|
||||
def setup
|
||||
@machine = Register.machine.boot
|
||||
end
|
||||
def test_no_object
|
||||
@assembler = Assembler.new(@machine , {})
|
||||
assert_nil @machine.translate_arm
|
||||
end
|
||||
def test_space
|
||||
@assembler = Assembler.new(@machine , Collector.collect_space)
|
||||
assert_nil @machine.translate_arm
|
||||
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 , {})
|
||||
assert_nil @machine.translate_arm
|
||||
assert @assembler.assemble
|
||||
end
|
||||
|
||||
def test_translate_space
|
||||
@assembler = Assembler.new(@machine , Collector.collect_space)
|
||||
assert_nil @machine.translate_arm
|
||||
end
|
||||
def test_assemble_space
|
||||
@assembler = Assembler.new(@machine , Collector.collect_space)
|
||||
assert_nil @machine.translate_arm
|
||||
assert @assembler.assemble
|
||||
end
|
||||
def test_write_space
|
||||
@assembler = Assembler.new(@machine , Collector.collect_space)
|
||||
assert_nil @machine.translate_arm
|
||||
assert @assembler.write_as_string
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user