From 81cc109d1e4146fd1410f792bb197daf339d8808 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 31 Jul 2018 19:44:40 +0300 Subject: [PATCH] more block tests instance and arg access --- .../interpreter/blocks/test_assign_arg.rb | 28 +++++++++++++++++++ .../interpreter/blocks/test_call_simple.rb | 15 ++++++++++ 2 files changed, 43 insertions(+) create mode 100644 test/risc/interpreter/blocks/test_assign_arg.rb create mode 100644 test/risc/interpreter/blocks/test_call_simple.rb diff --git a/test/risc/interpreter/blocks/test_assign_arg.rb b/test/risc/interpreter/blocks/test_assign_arg.rb new file mode 100644 index 00000000..cba6ae57 --- /dev/null +++ b/test/risc/interpreter/blocks/test_assign_arg.rb @@ -0,0 +1,28 @@ +require_relative "../helper" + +module Risc + class BlockAssignArg < MiniTest::Test + include Ticker + + def setup + @string_input = block_main("yielder {arg = 10 ; return 15} ; return arg") + super + end + + def test_chain + run_all + assert_equal 10 , get_return + end + end + class BlockAssignInst < MiniTest::Test + include Ticker + def setup + @string_input = block_main("yielder {@nil_object = 1 ; return 15} ; return @nil_object") + super + end + def test_chain + run_all + assert_equal 1 , get_return + end + end +end diff --git a/test/risc/interpreter/blocks/test_call_simple.rb b/test/risc/interpreter/blocks/test_call_simple.rb new file mode 100644 index 00000000..b64b5dd4 --- /dev/null +++ b/test/risc/interpreter/blocks/test_call_simple.rb @@ -0,0 +1,15 @@ +require_relative "../helper" + +module Risc + class BlockCallSimple < MiniTest::Test + include Ticker + def setup + @string_input = block_main("a = yielder {return 16.div4} ; return a") + super + end + def test_chain + run_all + assert_equal 4 , get_return + end + end +end