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
|
2016-12-10 14:18:37 +01:00
|
|
|
include AST::Sexp
|
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
|
2016-12-10 14:18:37 +01:00
|
|
|
[:+ , :- , :* , :/ , :== ]
|
2015-10-15 08:32:47 +02:00
|
|
|
end
|
|
|
|
def test_ints
|
|
|
|
operators.each do |op|
|
2016-12-10 14:18:37 +01:00
|
|
|
@input = s(:operator_value, op , s(:int, 2), s(:int, 3))
|
2015-10-15 08:32:47 +02:00
|
|
|
check
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def test_local_int
|
2016-12-30 13:10:49 +01:00
|
|
|
Parfait.object_space.get_main.add_local(:bar , :Integer)
|
2017-01-16 08:34:47 +01:00
|
|
|
@input = s(:operator_value, :+, s(:local, :bar), s(:int, 3))
|
2015-10-15 08:32:47 +02:00
|
|
|
check
|
|
|
|
end
|
|
|
|
def test_int_local
|
2016-12-30 13:10:49 +01:00
|
|
|
Parfait.object_space.get_main.add_local(:bar , :Integer)
|
2017-01-16 08:34:47 +01:00
|
|
|
@input = s(:operator_value, :+, s(:int, 3), s(:local, :bar))
|
2015-10-15 08:32:47 +02:00
|
|
|
check
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_field_int
|
2016-12-28 17:25:14 +01:00
|
|
|
add_space_field(:bro,:Integer)
|
2017-01-16 08:34:47 +01:00
|
|
|
@input = s(:operator_value, :+, s(:field_access,s(:receiver, s(:known, :self)), s(:field, s(:ivar, :bro))), s(:int, 3))
|
2015-10-15 08:32:47 +02:00
|
|
|
check
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_int_field
|
2016-12-28 17:25:14 +01:00
|
|
|
add_space_field(:bro,:Integer)
|
2017-01-16 08:34:47 +01:00
|
|
|
@input = s(:operator_value, :+, s(:int, 3), s(:field_access, s(:receiver, s(:known, :self)), s(:field,s(:ivar, :bro))))
|
2015-10-15 08:32:47 +02:00
|
|
|
check
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|