rubyx/test/soml/expressions/test_ops.rb

46 lines
1.1 KiB
Ruby
Raw Normal View History

2015-11-07 11:18:08 +01:00
require_relative "helper"
2015-10-15 08:32:47 +02:00
2015-10-22 17:16:29 +02:00
module Register
2015-10-15 08:32:47 +02:00
class TestOps < MiniTest::Test
2015-11-07 11:18:08 +01:00
include ExpressionHelper
2015-10-15 08:32:47 +02:00
def setup
2015-10-22 17:16:29 +02:00
Register.machine.boot
2015-10-15 08:32:47 +02:00
@root = :operator_value
@output = Register::RegisterValue
end
def operators
["+" , "-" , "*" , "/" , "=="]
end
def test_ints
operators.each do |op|
@string_input = '2 + 3'.sub("+" , op)
check
end
end
def test_local_int
2015-10-22 17:16:29 +02:00
Register.machine.space.get_main.ensure_local(:bar , :Integer)
2015-10-15 08:32:47 +02:00
@string_input = 'bar + 3'
check
end
def test_int_local
2015-10-22 17:16:29 +02:00
Register.machine.space.get_main.ensure_local(:bar , :Integer)
2015-10-15 08:32:47 +02:00
@string_input = '3 + bar'
check
end
def test_field_int
2015-11-07 11:18:08 +01:00
Register.machine.space.get_class_by_name(:Object).object_layout.add_instance_variable(:bro,:int)
2015-10-15 08:32:47 +02:00
@string_input = "self.bro + 3"
check
end
def test_int_field
2015-11-07 11:18:08 +01:00
Register.machine.space.get_class_by_name(:Object).object_layout.add_instance_variable(:bro,:int)
2015-10-15 08:32:47 +02:00
@string_input = "3 + self.bro"
check
end
end
end