rubyx/test/risc/position/test_position.rb

46 lines
1.1 KiB
Ruby
Raw Normal View History

2018-06-01 18:13:53 +02:00
require_relative "helper"
module Risc
# tests that do no require a boot and only test basic positioning
class TestPosition < MiniTest::Test
2018-06-02 22:48:12 +02:00
def setup
@pos = Position.new(self )
2018-06-02 22:48:12 +02:00
end
def test_new
2018-06-02 22:48:12 +02:00
assert @pos
end
def test_invalid
assert !@pos.valid?
end
def test_next_slot
2019-02-08 22:03:23 +01:00
Parfait.boot!(Parfait.default_test_options)
mov = Arm::ArmMachine.mov(:r1 , :r1)
position = Position.new(mov ).set(0)
assert_equal 4, position.next_slot
end
def test_has_get_code
2018-06-02 22:48:12 +02:00
assert_nil @pos.get_code
end
2018-06-02 22:02:59 +02:00
def test_has_listeners_helper
2018-06-02 22:48:12 +02:00
assert_equal Array , @pos.position_listeners.class
end
2018-06-06 09:00:07 +02:00
def test_has_trigger_inserted
assert_equal [] , @pos.trigger_inserted
end
2018-06-06 09:19:18 +02:00
def test_has_trigger_changed
assert_equal [] , @pos.trigger_changed
end
2018-06-02 22:02:59 +02:00
def test_listeners_empty
2018-06-02 22:48:12 +02:00
assert @pos.position_listeners.empty?
2018-06-02 22:02:59 +02:00
end
def test_has_listener_helper
2018-06-02 22:48:12 +02:00
@pos.position_listener( self )
assert_equal 1 , @pos.position_listeners.length
end
2018-06-02 22:48:12 +02:00
def test_set
assert_equal 0 , @pos.set(0).at
end
2018-06-02 22:48:12 +02:00
end
end