2020-02-17 08:27:42 +01:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module SlotMachine
|
|
|
|
|
|
|
|
class TestSlottedObjectType < MiniTest::Test
|
2020-03-12 21:20:38 +01:00
|
|
|
include Risc::HasCompiler
|
2020-02-17 08:27:42 +01:00
|
|
|
def setup
|
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2020-03-12 21:20:38 +01:00
|
|
|
@compiler = Risc.test_compiler
|
2020-03-02 16:50:03 +01:00
|
|
|
@slotted = Slotted.for(Parfait.object_space , slot2)
|
2020-03-12 21:20:38 +01:00
|
|
|
register = @slotted.to_register(@compiler , InstructionMock.new)
|
2020-02-17 08:27:42 +01:00
|
|
|
end
|
2020-03-02 16:50:03 +01:00
|
|
|
def slot2
|
|
|
|
[:type]
|
2020-02-17 08:27:42 +01:00
|
|
|
end
|
2020-03-02 16:50:03 +01:00
|
|
|
def test_load
|
2020-03-12 21:20:38 +01:00
|
|
|
assert_load 1 , Parfait::Space , "id_"
|
2020-02-17 08:27:42 +01:00
|
|
|
end
|
|
|
|
def test_to_s
|
2020-03-02 16:50:03 +01:00
|
|
|
assert_equal "Space." + slot2.join(".") , @slotted.to_s
|
2020-02-17 08:27:42 +01:00
|
|
|
end
|
|
|
|
def test_def_register2
|
2020-03-12 21:20:38 +01:00
|
|
|
assert_slot_to_reg 2 , "id_" , 0 , "id_.type"
|
2020-02-17 08:27:42 +01:00
|
|
|
end
|
|
|
|
end
|
2020-03-02 16:50:03 +01:00
|
|
|
class TestSlottedObjectType2 < TestSlottedObjectType
|
|
|
|
def slot2
|
|
|
|
[:type , :type]
|
2020-02-29 16:19:53 +01:00
|
|
|
end
|
2020-03-02 16:50:03 +01:00
|
|
|
def test_def_register3
|
2020-03-12 21:20:38 +01:00
|
|
|
assert_slot_to_reg 3 , "id_.type" , 0 , "id_.type.type"
|
2020-02-29 16:19:53 +01:00
|
|
|
end
|
|
|
|
end
|
2020-03-02 16:50:03 +01:00
|
|
|
class TestSlottedObjectType3 < TestSlottedObjectType
|
|
|
|
def slot2
|
|
|
|
[:type , :type , :type ]
|
2020-02-29 16:19:53 +01:00
|
|
|
end
|
|
|
|
def test_def_register3
|
2020-03-12 21:20:38 +01:00
|
|
|
assert_slot_to_reg 4 , "id_.type.type" , 0 , "id_.type.type.type"
|
2020-02-29 16:19:53 +01:00
|
|
|
end
|
|
|
|
end
|
2020-02-17 08:27:42 +01:00
|
|
|
end
|