rubyx/test/vm/method_compiler/test_operator_expression.rb
Torsten Ruger aa79e41d1c rename register to risc
seems to fit the layer much better as we really have a very reduced
instruction set
2017-01-19 09:02:29 +02:00

47 lines
1.2 KiB
Ruby

require_relative "helper"
module Risc
class TestOps < MiniTest::Test
include ExpressionHelper
include AST::Sexp
def setup
Risc.machine.boot
@root = :operator_value
@output = Risc::RiscValue
end
def operators
[:+ , :- , :* , :/ , :== ]
end
def test_ints
operators.each do |op|
@input = s(:operator_value, op , s(:int, 2), s(:int, 3))
check
end
end
def test_local_int
Parfait.object_space.get_main.add_local(:bar , :Integer)
@input = s(:operator_value, :+, s(:local, :bar), s(:int, 3))
check
end
def test_int_local
Parfait.object_space.get_main.add_local(:bar , :Integer)
@input = s(:operator_value, :+, s(:int, 3), s(:local, :bar))
check
end
def test_field_int
add_space_field(:bro,:Integer)
@input = s(:operator_value, :+, s(:field_access,s(:receiver, s(:known, :self)), s(:field, s(:ivar, :bro))), s(:int, 3))
check
end
def test_int_field
add_space_field(:bro,:Integer)
@input = s(:operator_value, :+, s(:int, 3), s(:field_access, s(:receiver, s(:known, :self)), s(:field,s(:ivar, :bro))))
check
end
end
end