rubyx/test/risc/test_machine.rb
Torsten Ruger 8d510c2e7e getting instruction repositioning right
big bug hunt, involving complicated maths (%)
2018-05-24 14:27:53 +03:00

42 lines
1.1 KiB
Ruby

require_relative "helper"
module Risc
class TestMachineObjects < MiniTest::Test
def setup
@machine = Risc.machine.boot
end
def test_objects
objects = @machine.objects
assert_equal Hash , objects.class
assert 350 < objects.length
end
def test_constant_fail
assert_raises {@machine.add_constant( 1 )}
end
def test_constant
assert @machine.add_constant( Parfait::Integer.new(5) )
end
end
class TestMachineInit < MiniTest::Test
def setup
@machine = Risc.machine.boot
@machine.translate(:arm)
@machine.position_all
@machine.create_binary
end
def test_pos_cpu
assert_equal 0 , Position.get(@machine.cpu_init).at
end
def test_cpu_at
assert_equal "0x5714" , Position.get(@machine.cpu_init.first).to_s
end
def test_cpu_bin
assert_equal "0x570c" , Position.get(Position.get(@machine.cpu_init.first).binary).to_s
end
def test_cpu_label
assert_equal Position::InstructionPosition , Position.get(@machine.cpu_init.first).class
end
end
end