Continue testing mom instructions
especially with the custom asserts, gadda say mesa lika disa
This commit is contained in:
parent
6f108f67d7
commit
5ab021de5a
@ -96,7 +96,7 @@ module Mom
|
||||
# type information inferred from their names / type hierachy
|
||||
def sym_to_risc(compiler , source)
|
||||
slots = @slots.dup
|
||||
raise "Not Message #{object}" unless @known_object == :message
|
||||
raise "Not Message #{@known_object}" unless @known_object == :message
|
||||
left = Risc.message_reg
|
||||
left = left.resolve_and_add( slots.shift , compiler)
|
||||
reg = compiler.current.register
|
||||
|
@ -12,7 +12,7 @@ module Mom
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@instruction = instruction
|
||||
@compiler = Risc::MethodCompiler.new(FakeCallable.new , Label.new("source","start"))
|
||||
@compiler = Risc::MethodCompiler.new(Risc::FakeCallable.new , Label.new("source","start"))
|
||||
@instruction.to_risc(@compiler)
|
||||
@risc = @compiler.risc_instructions
|
||||
end
|
||||
|
29
test/mom/instruction/test_argument_transfer.rb
Normal file
29
test/mom/instruction/test_argument_transfer.rb
Normal file
@ -0,0 +1,29 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestArgumentTransfer < MomInstructionTest
|
||||
def instruction
|
||||
receiver = SlotDefinition.new(:message , [:receiver])
|
||||
arg = SlotLoad.new("test", [:message, :caller] , [:message,:type] )
|
||||
ArgumentTransfer.new("" , receiver ,[arg])
|
||||
end
|
||||
def test_len
|
||||
assert_equal 6 , all.length , all_str
|
||||
end
|
||||
def test_1_slot
|
||||
assert_slot_to_reg risc(1) ,:r0 , 2 , :r2
|
||||
end
|
||||
def test_2_slot
|
||||
assert_slot_to_reg risc(2) ,:r0 , 1 , :r3
|
||||
end
|
||||
def test_3_reg
|
||||
assert_reg_to_slot risc(3) , :r2 , :r3 , 2
|
||||
end
|
||||
def test_4_slot
|
||||
assert_slot_to_reg risc(4) ,:r0 , 0 , :r2
|
||||
end
|
||||
def test_5_reg
|
||||
assert_reg_to_slot risc(5) , :r2 , :r0 , 6
|
||||
end
|
||||
end
|
||||
end
|
35
test/mom/instruction/test_block_yield.rb
Normal file
35
test/mom/instruction/test_block_yield.rb
Normal file
@ -0,0 +1,35 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TesBlockYield < MomInstructionTest
|
||||
def instruction
|
||||
BlockYield.new("source",1)
|
||||
end
|
||||
def test_len
|
||||
assert_equal 8 , all.length , all_str
|
||||
end
|
||||
def test_1_slot
|
||||
assert_slot_to_reg risc(1) ,:r0 , 1 , :r1
|
||||
end
|
||||
def test_2_load
|
||||
assert_load risc(2) , Risc::Label , :r2
|
||||
assert_label risc(2).constant , "continue_"
|
||||
end
|
||||
def test_3_reg
|
||||
assert_reg_to_slot risc(3) , :r2 , :r1 , 4
|
||||
end
|
||||
def test_4_slot
|
||||
assert_slot_to_reg risc(4) ,:r0 , 9 , :r3
|
||||
end
|
||||
def test_5_slot
|
||||
assert_slot_to_reg risc(5) ,:r0 , 1 , :r0
|
||||
end
|
||||
def test_6_jump
|
||||
assert_equal Risc::DynamicJump , risc(6).class
|
||||
assert_equal :r3 , risc(6).register.symbol
|
||||
end
|
||||
def test_7_label
|
||||
assert_label risc(7) , "continue_"
|
||||
end
|
||||
end
|
||||
end
|
@ -10,6 +10,7 @@ module Mom
|
||||
end
|
||||
def test_1_load
|
||||
assert_load risc(1) , Risc::Label , :r1
|
||||
assert_label risc(1).constant , "continue_"
|
||||
end
|
||||
def test_2_slot
|
||||
assert_slot_to_reg risc(2) ,:r0 , 1 , :r2
|
||||
|
@ -8,7 +8,7 @@ module Mom
|
||||
class TestCallableCompiler < MiniTest::Test
|
||||
|
||||
def setup
|
||||
@compiler = FakeCallableCompiler.new(FakeCallable.new)
|
||||
@compiler = FakeCallableCompiler.new(Risc::FakeCallable.new)
|
||||
end
|
||||
def test_ok
|
||||
assert @compiler
|
||||
|
@ -1,7 +1,5 @@
|
||||
require_relative "helper"
|
||||
module Risc
|
||||
class FakeCallable
|
||||
end
|
||||
class FakeCallableCompiler < CallableCompiler
|
||||
def initialize(a,c)
|
||||
super(a,c)
|
||||
|
@ -1,6 +1,9 @@
|
||||
class FakeCallable
|
||||
end
|
||||
module Risc
|
||||
class FakeCallable
|
||||
def self_type
|
||||
Parfait.object_space.types.values.first
|
||||
end
|
||||
end
|
||||
class FakeCompiler
|
||||
attr_reader :instructions
|
||||
def initialize
|
||||
|
Loading…
Reference in New Issue
Block a user