From 5a8d7d313fa591493318dbe5aa3b71915303fd2f Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 3 Nov 2015 11:23:15 +0200 Subject: [PATCH] little more tests --- lib/interpreter/interpreter.rb | 7 +------ test/register/test_instructions.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/interpreter/interpreter.rb b/lib/interpreter/interpreter.rb index aa8641e1..e8a0c342 100644 --- a/lib/interpreter/interpreter.rb +++ b/lib/interpreter/interpreter.rb @@ -71,13 +71,9 @@ module Interpreter return unless @instruction @clock += 1 name = @instruction.class.name.split("::").last - puts name + #puts @instruction fetch = send "execute_#{name}" return unless fetch - fetch_next_intruction - end - - def fetch_next_intruction set_instruction @instruction.next end @@ -149,7 +145,6 @@ module Interpreter def execute_FunctionReturn object = object_for( @instruction.register ) link = object.internal_object_get( @instruction.index ) - puts "#{@instruction} #{object} link #{link}" @instruction = link # we jump back to the call instruction. so it is as if the call never happened and we continue true diff --git a/test/register/test_instructions.rb b/test/register/test_instructions.rb index d904fd61..38d744aa 100644 --- a/test/register/test_instructions.rb +++ b/test/register/test_instructions.rb @@ -56,5 +56,19 @@ module Register assert_equal @label, @instruction.next assert_equal 2 , @instruction.length , @instruction.to_ac end + def test_each_label1 + @instruction.set_next @label + start = Label.new("test" , "test" , @instruction) + count = 0 + start.each_label { |l| count += 1 } + assert_equal 2 , count + end + def test_each_label2 + @instruction.set_next @branch + start = Label.new("test" , "test" , @instruction) + count = 0 + start.each_label { |l| count += 1 } + assert_equal 2 , count + end end end