From 727069a306b89af7a31f873f704bb78f4a3223e0 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 1 Apr 2018 12:00:59 +0300 Subject: [PATCH] perfectly adding two numbers with only 7k lines of code :-) --- test/risc/interpreter/test_plus.rb | 31 +++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/test/risc/interpreter/test_plus.rb b/test/risc/interpreter/test_plus.rb index 5f76a7a9..114f4724 100644 --- a/test/risc/interpreter/test_plus.rb +++ b/test/risc/interpreter/test_plus.rb @@ -26,7 +26,7 @@ module Risc SlotToReg, OperatorInstruction, LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, Label, NilClass] assert_equal Parfait::Integer , get_return.class -# assert_equal 10 , get_return.value + assert_equal 10 , get_return.value end def test_load_5 lod = ticks( 46 ) @@ -70,5 +70,34 @@ module Risc assert_equal 5 , @interpreter.get_register(:r2) assert_equal 10 , @interpreter.get_register(:r1) end + def test_load_int_space + cons = ticks(63) + assert_equal LoadConstant , cons.class + assert_equal Parfait::Space , cons.constant.class + assert_equal :r3 , cons.register.symbol + end + def test_load_int_next_space + sl = ticks(64) + assert_equal SlotToReg , sl.class + assert_equal :r3 , sl.array.symbol #load from space + assert_equal 5 , sl.index + assert_equal :r2 , sl.register.symbol + assert_equal Parfait::Integer , @interpreter.get_register(:r2).class + end + def test_load_int_next_int + sl = ticks(65) + assert_equal SlotToReg , sl.class + assert_equal :r2 , sl.array.symbol #load from next_int + assert_equal 2 , sl.index + assert_equal :r4 , sl.register.symbol + assert_equal Parfait::Integer , @interpreter.get_register(:r4).class + end + def test_load_int_next_int2 + sl = ticks(66) + assert_equal RegToSlot , sl.class + assert_equal :r3 , sl.array.symbol #store to space + assert_equal 5 , sl.index + assert_equal :r4 , sl.register.symbol + end end end