diff --git a/test/register/interpreter/test_all.rb b/test/register/interpreter/test_all.rb index 332f49ce..761b562d 100644 --- a/test/register/interpreter/test_all.rb +++ b/test/register/interpreter/test_all.rb @@ -1,4 +1,5 @@ require_relative "test_add" +require_relative "test_change" require_relative "test_if" require_relative "test_puts" require_relative "test_plus" diff --git a/test/register/interpreter/test_change.rb b/test/register/interpreter/test_change.rb new file mode 100644 index 00000000..6856d28a --- /dev/null +++ b/test/register/interpreter/test_change.rb @@ -0,0 +1,45 @@ +require_relative "helper" + +class AddChange < MiniTest::Test + include Ticker + + def setup + @input = s(:statements, s(:class, :Space, s(:derives, nil), s(:statements, s(:function, :Integer, s(:name, :main), s(:parameters), s(:statements, s(:return, s(:operator_value, :+, s(:int, 5), s(:int, 7)))))))) + @state_events = {} + @instruction_events = [] + super + end + + def state_changed( a , b) + @state_events[:state_changed] = [a , b] + end + + def instruction_changed(was , is ) + @instruction_events << was + end + + def test_state_change + @interpreter.register_event :state_changed , self + ticks 30 + assert @state_events[:state_changed] + assert_equal 2 , @state_events[:state_changed].length + assert_equal :running, @state_events[:state_changed][0] + @interpreter.unregister_event :state_changed , self + end + + def test_instruction_events + @interpreter.register_event :instruction_changed , self + ticks 30 + assert_equal 17 , @instruction_events.length + @interpreter.unregister_event :instruction_changed , self + end + + def test_chain + #show_ticks # get output of what is + check_chain ["Branch","Label","LoadConstant","GetSlot","SetSlot", + "LoadConstant","SetSlot","FunctionCall","Label","LoadConstant", + "LoadConstant","OperatorInstruction","SetSlot","Label","FunctionReturn", + "RegisterTransfer","Syscall","NilClass"] + end + +end diff --git a/test/test_all.rb b/test/test_all.rb index 7cb5a78b..04562ca8 100644 --- a/test/test_all.rb +++ b/test/test_all.rb @@ -2,6 +2,8 @@ require_relative "elf/test_all" require_relative "lib/test_all" +require_relative "melon/test_all" + require_relative "register/test_all" require_relative "typed/test_all"