2018-06-01 18:13:53 +02:00
|
|
|
require_relative "helper"
|
2018-05-17 19:13:33 +02:00
|
|
|
|
2018-06-02 20:59:41 +02:00
|
|
|
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
|
2018-06-15 21:00:49 +02:00
|
|
|
@pos = Position.new(self )
|
2018-06-02 22:48:12 +02:00
|
|
|
end
|
2018-06-02 20:59:41 +02:00
|
|
|
def test_new
|
2018-06-02 22:48:12 +02:00
|
|
|
assert @pos
|
2018-06-02 20:59:41 +02:00
|
|
|
end
|
2018-06-06 00:16:00 +02:00
|
|
|
def test_invalid
|
|
|
|
assert !@pos.valid?
|
|
|
|
end
|
2018-06-02 20:59:41 +02:00
|
|
|
def test_next_slot
|
|
|
|
mov = Arm::ArmMachine.mov(:r1 , :r1)
|
2018-06-15 21:00:49 +02:00
|
|
|
position = Position.new(mov ).set(0)
|
2018-06-02 20:59:41 +02:00
|
|
|
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
|
2018-06-02 20:59:41 +02:00
|
|
|
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
|
2018-06-02 20:59:41 +02:00
|
|
|
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
|
2018-06-02 20:59:41 +02:00
|
|
|
end
|
2018-06-02 22:48:12 +02:00
|
|
|
def test_set
|
2018-06-15 21:00:49 +02:00
|
|
|
assert_equal 0 , @pos.set(0).at
|
2018-06-02 20:59:41 +02:00
|
|
|
end
|
2018-06-02 22:48:12 +02:00
|
|
|
end
|
2018-05-17 19:13:33 +02:00
|
|
|
end
|