From 02c12996b3baeef70b9c4628318035cb79bf9b41 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 22 Mar 2018 02:38:41 +0530 Subject: [PATCH] return test for risc --- test/mom/test_return_simple.rb | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/mom/test_return_simple.rb diff --git a/test/mom/test_return_simple.rb b/test/mom/test_return_simple.rb new file mode 100644 index 00000000..62e47010 --- /dev/null +++ b/test/mom/test_return_simple.rb @@ -0,0 +1,36 @@ +require_relative "helper" + +module Risc + class TestReturnSimple < MiniTest::Test + include Statements + + def setup + super + @input = "return 5" + @expect = [LoadConstant, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg , + Transfer, SlotToReg, FunctionReturn] + end + + def test_return_instructions + assert_nil msg = check_nil , msg + end + def test_function_return + produced = produce_body + assert_equal FunctionReturn , produced.next(8).class + end + def test_load_5 + produced = produce_body + assert_equal 5 , produced.constant.value + end + def pest_cache_check + produced = produce_body + assert_equal NotSame , produced.next(3).class + assert_equal produced.next(34) , produced.next(3).label + end + def pest_check_resolve + produced = produce_body + assert_equal FunctionCall , produced.next(30).class + assert_equal :resolve_method ,produced.next(30).method.name + end + end +end