Rename SlotDefinition to Slot
And the derived XXDefinitions to XXSlot Just to be more consistent And possibly free the Definition for the Language side
This commit is contained in:
@ -3,7 +3,7 @@ require_relative "helper"
|
||||
module SlotMachine
|
||||
class TestArgumentTransfer < SlotMachineInstructionTest
|
||||
def instruction
|
||||
receiver = MessageDefinition.new( [:receiver])
|
||||
receiver = MessageSlot.new( [:receiver])
|
||||
arg = SlotLoad.new("test", [:message, :caller] , [:message,:type] )
|
||||
ArgumentTransfer.new("" , receiver ,[arg])
|
||||
end
|
||||
|
@ -2,11 +2,11 @@ require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
|
||||
class TestSlotDefinitionConstant < MiniTest::Test
|
||||
class TestSlotConstant < MiniTest::Test
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = Risc::FakeCompiler.new
|
||||
@definition = SlotDefinition.for(StringConstant.new("hi") , [])
|
||||
@definition = Slot.for(StringConstant.new("hi") , [])
|
||||
@register = @definition.to_register(@compiler , InstructionMock.new)
|
||||
@instruction = @compiler.instructions.first
|
||||
end
|
||||
@ -23,11 +23,11 @@ module SlotMachine
|
||||
assert_equal "[StringConstant]" , @definition.to_s
|
||||
end
|
||||
end
|
||||
class TestSlotDefinitionConstantType < MiniTest::Test
|
||||
class TestSlotConstantType < MiniTest::Test
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = Risc::FakeCompiler.new
|
||||
@definition = SlotDefinition.for(StringConstant.new("hi") , [:type])
|
||||
@definition = Slot.for(StringConstant.new("hi") , [:type])
|
||||
@register = @definition.to_register(@compiler , InstructionMock.new)
|
||||
@instruction = @compiler.instructions.first
|
||||
end
|
@ -1,10 +1,10 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
class TestSlotDefinitionBasics < MiniTest::Test
|
||||
class TestSlotBasics < MiniTest::Test
|
||||
|
||||
def slot(slot = :caller)
|
||||
MessageDefinition.new(slot)
|
||||
MessageSlot.new(slot)
|
||||
end
|
||||
def test_create_ok1
|
||||
assert_equal :message , slot.known_object
|
@ -3,7 +3,7 @@ require_relative "helper"
|
||||
module SlotMachine
|
||||
class TestNotSameCheck < SlotMachineInstructionTest
|
||||
def instruction
|
||||
target = SlotDefinition.for(:message , :caller)
|
||||
target = Slot.for(:message , :caller)
|
||||
NotSameCheck.new(target , target , Label.new("ok" , "target"))
|
||||
end
|
||||
def test_len
|
||||
|
23
test/slot_machine/instruction/test_slot.rb
Normal file
23
test/slot_machine/instruction/test_slot.rb
Normal file
@ -0,0 +1,23 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
class TestSlotBasics < MiniTest::Test
|
||||
|
||||
def slot(slot = :caller)
|
||||
MessageSlot.new(slot)
|
||||
end
|
||||
def test_create_ok1
|
||||
assert_equal :message , slot.known_object
|
||||
end
|
||||
def test_create_ok2
|
||||
assert_equal Array , slot.slots.class
|
||||
assert_equal :caller , slot.slots.first
|
||||
end
|
||||
def test_to_s
|
||||
assert_equal "[message, caller]" , slot.to_s
|
||||
end
|
||||
def test_create_fail_none
|
||||
assert_raises {slot(nil)}
|
||||
end
|
||||
end
|
||||
end
|
@ -1,11 +1,11 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
class TestSlotDefinitionKnown1 < MiniTest::Test
|
||||
class TestSlotKnown1 < MiniTest::Test
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = Risc::FakeCompiler.new
|
||||
@definition = MessageDefinition.new( :caller)
|
||||
@definition = MessageSlot.new( :caller)
|
||||
@register = @definition.to_register(@compiler , "fake source")
|
||||
@instruction = @compiler.instructions.first
|
||||
end
|
@ -1,27 +0,0 @@
|
||||
require_relative "helper"
|
||||
|
||||
module SlotMachine
|
||||
class TestSlotDefinitionKnown2 < MiniTest::Test
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@compiler = Risc::FakeCompiler.new
|
||||
@definition = MessageDefinition.new( [:caller , :type])
|
||||
@register = @definition.to_register(@compiler , InstructionMock.new)
|
||||
end
|
||||
def test_def_next_class
|
||||
assert_equal Risc::SlotToReg , @compiler.instructions[1].class
|
||||
end
|
||||
def test_def_next_next_class
|
||||
assert_equal NilClass , @compiler.instructions[2].class
|
||||
end
|
||||
def test_def_next_index
|
||||
assert_equal 0 , @compiler.instructions[1].index
|
||||
end
|
||||
def test_def_next_register
|
||||
assert_equal :r1 , @compiler.instructions[1].register.symbol
|
||||
end
|
||||
def test_def_next_array
|
||||
assert_equal :r1 , @compiler.instructions[1].array.symbol
|
||||
end
|
||||
end
|
||||
end
|
@ -3,7 +3,7 @@ require_relative "helper"
|
||||
module SlotMachine
|
||||
class TestSameCheck < SlotMachineInstructionTest
|
||||
def instruction
|
||||
target = MessageDefinition.new( :caller)
|
||||
target = MessageSlot.new( :caller)
|
||||
TruthCheck.new(target , Label.new("ok" , "target"))
|
||||
end
|
||||
def test_len
|
||||
|
Reference in New Issue
Block a user