fix helper
and start on arg test
This commit is contained in:
@ -52,8 +52,8 @@ module Risc
|
||||
#full_expect = expect
|
||||
begin
|
||||
should = full_expect[index]
|
||||
return "No instruction at #{real_index(index)}\n#{should(all)}" unless should
|
||||
return "Expected at #{real_index(index)}\n#{should(all)} was #{instruction.to_s}" unless instruction.class == should
|
||||
return "No instruction at #{real_index(index)}\n#{should(all)[0..100]}" unless should
|
||||
return "Expected at #{real_index(index)}\n#{should(all)} was #{instruction.to_s[0..100]}" unless instruction.class == should
|
||||
#puts instruction.to_s if (index > preamble.length) and (index + postamble.length <= full_expect.length)
|
||||
index += 1
|
||||
instruction = instruction.next
|
||||
@ -63,10 +63,11 @@ module Risc
|
||||
def should( all )
|
||||
preamble.each {all.shift}
|
||||
postamble.each {all.pop}
|
||||
str = all.to_s.gsub("Risc::","")
|
||||
str = all.collect{|i| i.class.name}.join(", ").gsub("Risc::","")
|
||||
str = "[#{str}]"
|
||||
ret = ""
|
||||
str.split(",").each_slice(5).each do |line|
|
||||
ret += " " + line.join(",") + " ,\n"
|
||||
ret += " " + line.join(",") + ",\n"
|
||||
end
|
||||
ret
|
||||
end
|
||||
|
@ -7,11 +7,12 @@ module Risc
|
||||
def setup
|
||||
super
|
||||
@input = "5.mod4"
|
||||
@expect = [LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant ,
|
||||
FunctionCall, Label]
|
||||
@expect = [LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
|
||||
SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
|
||||
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
|
||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant,
|
||||
SlotToReg, RegToSlot, SlotToReg, LoadConstant, FunctionCall,
|
||||
Label]
|
||||
end
|
||||
|
||||
def test_send_instructions
|
||||
|
44
test/mom/test_send_simple_args.rb
Normal file
44
test/mom/test_send_simple_args.rb
Normal file
@ -0,0 +1,44 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Risc
|
||||
class TestCallSimpleArgs < MiniTest::Test
|
||||
include Statements
|
||||
|
||||
def setup
|
||||
super
|
||||
@input = "5.get_internal_word(1)"
|
||||
@expect = [LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
|
||||
SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
|
||||
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
|
||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant,
|
||||
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
||||
RegToSlot, SlotToReg, LoadConstant, FunctionCall, Label]
|
||||
end
|
||||
|
||||
def test_send_instructions
|
||||
assert_nil msg = check_nil , msg
|
||||
end
|
||||
def pest_function_call
|
||||
produced = produce_body
|
||||
assert_equal FunctionCall , produced.next(24).class
|
||||
assert_equal :mod4 , produced.next(24).method.name
|
||||
end
|
||||
def pest_check_continue
|
||||
produced = produce_body
|
||||
assert produced.next(25).name.start_with?("continue_")
|
||||
end
|
||||
def pest_load_label
|
||||
produced = produce_body
|
||||
assert_equal Label , produced.next(19).constant.class
|
||||
end
|
||||
def pest_load_5
|
||||
produced = produce_body
|
||||
assert_equal 5 , produced.next(16).constant.value
|
||||
end
|
||||
def pest_call_reg_setup
|
||||
produced = produce_body
|
||||
assert_equal produced.next(23).register , produced.next(24).register
|
||||
end
|
||||
#TODO check the message setup, type and frame moves
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user