2018-07-31 17:00:42 +02:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
module Risc
|
|
|
|
class BloclAssignOuter < MiniTest::Test
|
|
|
|
include Ticker
|
|
|
|
|
|
|
|
def setup
|
|
|
|
@string_input = block_main("a = 15 ;yielder {a = 10 ; return 15} ; return a")
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
2018-08-02 16:37:27 +02:00
|
|
|
def test_pest_chain
|
2018-07-31 17:00:42 +02:00
|
|
|
#show_main_ticks # get output of what is
|
|
|
|
check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
|
|
|
RegToSlot, LoadConstant, LoadConstant, SlotToReg, RegToSlot,
|
|
|
|
RegToSlot, SlotToReg, SlotToReg, Branch, RegToSlot,
|
|
|
|
SlotToReg, SlotToReg, RegToSlot, RegToSlot, SlotToReg,
|
|
|
|
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
|
|
|
|
SlotToReg, SlotToReg, Branch, SlotToReg, RegToSlot,
|
|
|
|
LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall,
|
|
|
|
LoadConstant, SlotToReg, OperatorInstruction, IsZero, SlotToReg,
|
|
|
|
SlotToReg, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
|
|
|
|
SlotToReg, SlotToReg, RegToSlot, Branch, SlotToReg,
|
|
|
|
SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot,
|
|
|
|
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
|
|
|
RegToSlot, SlotToReg, Branch, SlotToReg, SlotToReg,
|
|
|
|
DynamicJump, LoadConstant, SlotToReg, SlotToReg, SlotToReg,
|
2018-08-02 16:37:27 +02:00
|
|
|
RegToSlot, LoadConstant, RegToSlot, Branch, SlotToReg,
|
|
|
|
SlotToReg, RegToSlot, SlotToReg, SlotToReg, Branch,
|
|
|
|
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
|
|
|
|
SlotToReg, SlotToReg, RegToSlot, Branch, SlotToReg,
|
|
|
|
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg,
|
|
|
|
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
|
|
|
|
Branch, SlotToReg, SlotToReg, Branch, RegToSlot,
|
|
|
|
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer,
|
|
|
|
SlotToReg, SlotToReg, Branch, Syscall, NilClass]
|
2018-07-31 17:00:42 +02:00
|
|
|
assert_equal 10 , get_return
|
|
|
|
end
|
|
|
|
|
2018-08-02 16:37:27 +02:00
|
|
|
def test_pest_block_jump
|
2018-07-31 17:00:42 +02:00
|
|
|
load_ins = main_ticks(66)
|
|
|
|
assert_equal DynamicJump , load_ins.class
|
|
|
|
assert_equal Parfait::Block , @interpreter.get_register(load_ins.register).class
|
|
|
|
end
|
2018-08-02 16:37:27 +02:00
|
|
|
def test_pest_block_load
|
2018-07-31 17:00:42 +02:00
|
|
|
load_ins = main_ticks(67)
|
|
|
|
assert_load load_ins , Parfait::Integer , :r1
|
|
|
|
assert_equal 10 , @interpreter.get_register(load_ins.register).value
|
|
|
|
end
|
2018-08-02 16:37:27 +02:00
|
|
|
def test_pest_block_slot1
|
2018-07-31 17:00:42 +02:00
|
|
|
assert_slot_to_reg main_ticks(68) ,:r0 , 6 , :r2
|
|
|
|
end
|
2018-08-02 16:37:27 +02:00
|
|
|
def test_pest_block_slot2
|
2018-07-31 17:00:42 +02:00
|
|
|
assert_slot_to_reg main_ticks(69) ,:r2 , 6 , :r2
|
|
|
|
end
|
2018-08-02 16:37:27 +02:00
|
|
|
def test_pest_block_slot3
|
2018-07-31 17:00:42 +02:00
|
|
|
assert_slot_to_reg main_ticks(70) ,:r2 , 3 , :r2
|
|
|
|
end
|
2018-08-02 16:37:27 +02:00
|
|
|
def test_pest_block_reg
|
2018-07-31 17:00:42 +02:00
|
|
|
assert_reg_to_slot main_ticks(71) ,:r1 , :r2 , 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|