fixing tests

This commit is contained in:
Torsten 2020-03-12 22:20:38 +02:00
parent 504fc3509e
commit 126466e9a9
4 changed files with 22 additions and 22 deletions

View File

@ -5,7 +5,7 @@ module RubyX
class TestIntegerSame < MiniTest::Test class TestIntegerSame < MiniTest::Test
include MacroHelper include MacroHelper
def op ; :== ; end def op ; :== ; end
def len ; 25 ; end def len ; 24 ; end
def source def source
<<GET <<GET
class Integer < Data4 class Integer < Data4
@ -31,11 +31,11 @@ GET
end end
class TestIntegerLg < TestIntegerSame class TestIntegerLg < TestIntegerSame
def op ; :> ; end def op ; :> ; end
def len ; 26 ; end def len ; 25 ; end
end end
class TestIntegerSm < TestIntegerSame class TestIntegerSm < TestIntegerSame
def op ; :< ; end def op ; :< ; end
def len ; 26 ; end def len ; 25 ; end
end end
class TestIntegerLe < TestIntegerSame class TestIntegerLe < TestIntegerSame
def op ; :>= ; end def op ; :>= ; end

View File

@ -43,7 +43,7 @@ module SlotMachine
end end
def test_has_risc_instructions def test_has_risc_instructions
assert_equal Risc::Label, compiler.risc_instructions.class assert_equal Risc::Label, compiler.risc_instructions.class
assert_equal 13, compiler.risc_instructions.length assert_equal 12, compiler.risc_instructions.length
end end
end end
end end

View File

@ -3,39 +3,39 @@ require_relative "helper"
module SlotMachine module SlotMachine
class TestSlotConstant < MiniTest::Test class TestSlotConstant < MiniTest::Test
include Risc::HasCompiler
def setup def setup
Parfait.boot!(Parfait.default_test_options) Parfait.boot!(Parfait.default_test_options)
compiler = Risc.test_compiler @compiler = Risc.test_compiler
@slotted = Slotted.for(StringConstant.new("hi") , nil) @slotted = Slotted.for(StringConstant.new("hi") , nil)
register = @slotted.to_register(compiler , InstructionMock.new) register = @slotted.to_register(@compiler , InstructionMock.new)
@instruction = compiler.risc_instructions.next
end end
def test_load def test_load
assert_load @instruction , Parfait::Word , "id_" assert_load 1 , Parfait::Word , "id_"
end end
def test_def_const def test_def_const
assert_equal "hi" , @instruction.constant.to_string assert_equal "hi" , risc(1).constant.to_string
end end
end end
class TestSlotConstantType < MiniTest::Test class TestSlotConstantType < MiniTest::Test
include Risc::HasCompiler
def setup def setup
Parfait.boot!(Parfait.default_test_options) Parfait.boot!(Parfait.default_test_options)
compiler = Risc.test_compiler @compiler = Risc.test_compiler
@slotted = Slotted.for(StringConstant.new("hi") , [:type]) @slotted = Slotted.for(StringConstant.new("hi") , [:type])
register = @slotted.to_register(compiler , InstructionMock.new) register = @slotted.to_register(@compiler , InstructionMock.new)
@instruction = compiler.risc_instructions.next
end end
def test_load def test_load
assert_load @instruction , Parfait::Word , "id_" assert_load 1 , Parfait::Word , "id_"
end end
def test_def_const def test_def_const
assert_equal "hi" , @instruction.constant.to_string assert_equal "hi" , risc(1).constant.to_string
end end
def test_to_s def test_to_s
assert_equal "StringConstant.type" , @slotted.to_s assert_equal "StringConstant.type" , @slotted.to_s
end end
def test_def_register2 def test_def_register2
assert_slot_to_reg @instruction.next , "id_" , 0 , "id_.0" assert_slot_to_reg 2 , "id_" , 0 , "id_.0"
end end
end end
end end

View File

@ -3,24 +3,24 @@ require_relative "helper"
module SlotMachine module SlotMachine
class TestSlottedObjectType < MiniTest::Test class TestSlottedObjectType < MiniTest::Test
include Risc::HasCompiler
def setup def setup
Parfait.boot!(Parfait.default_test_options) Parfait.boot!(Parfait.default_test_options)
compiler = Risc.test_compiler @compiler = Risc.test_compiler
@slotted = Slotted.for(Parfait.object_space , slot2) @slotted = Slotted.for(Parfait.object_space , slot2)
register = @slotted.to_register(compiler , InstructionMock.new) register = @slotted.to_register(@compiler , InstructionMock.new)
@instruction = compiler.risc_instructions.next
end end
def slot2 def slot2
[:type] [:type]
end end
def test_load def test_load
assert_load @instruction , Parfait::Space , "id_" assert_load 1 , Parfait::Space , "id_"
end end
def test_to_s def test_to_s
assert_equal "Space." + slot2.join(".") , @slotted.to_s assert_equal "Space." + slot2.join(".") , @slotted.to_s
end end
def test_def_register2 def test_def_register2
assert_slot_to_reg @instruction.next , "id_" , 0 , "id_.type" assert_slot_to_reg 2 , "id_" , 0 , "id_.type"
end end
end end
class TestSlottedObjectType2 < TestSlottedObjectType class TestSlottedObjectType2 < TestSlottedObjectType
@ -28,7 +28,7 @@ module SlotMachine
[:type , :type] [:type , :type]
end end
def test_def_register3 def test_def_register3
assert_slot_to_reg @instruction.next(2) , "id_.type" , 0 , "id_.type.type" assert_slot_to_reg 3 , "id_.type" , 0 , "id_.type.type"
end end
end end
class TestSlottedObjectType3 < TestSlottedObjectType class TestSlottedObjectType3 < TestSlottedObjectType
@ -36,7 +36,7 @@ module SlotMachine
[:type , :type , :type ] [:type , :type , :type ]
end end
def test_def_register3 def test_def_register3
assert_slot_to_reg @instruction.next(3) , "id_.type.type" , 0 , "id_.type.type.type" assert_slot_to_reg 4 , "id_.type.type" , 0 , "id_.type.type.type"
end end
end end
end end