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