rubyx/test/soml/expressions/test_field_access.rb

62 lines
1.3 KiB
Ruby
Raw Normal View History

2015-11-07 11:18:08 +01:00
require_relative "helper"
2015-10-22 17:16:29 +02:00
module Register
class TestFields < MiniTest::Test
2015-11-07 11:18:08 +01:00
include ExpressionHelper
def setup
2015-10-22 17:16:29 +02:00
Register.machine.boot
end
def test_field_not_defined
@root = :field_access
@string_input = <<HERE
self.a
HERE
assert_raises(RuntimeError) { check }
end
2015-11-07 11:18:08 +01:00
def test_field_not_space
@root = :field_access
@string_input = <<HERE
self.space
HERE
assert_raises(RuntimeError) { check }
end
def test_field
Register.machine.space.get_class_by_name(:Object).object_type.add_instance_variable(:bro,:Object)
@root = :field_access
@string_input = <<HERE
self.bro
HERE
@output = Register::RegisterValue
2015-10-14 20:34:18 +02:00
check
end
def test_local
2015-10-22 17:16:29 +02:00
Register.machine.space.get_main.ensure_local(:bar , :Integer)
2015-10-14 20:34:18 +02:00
@root = :name
@string_input = 'bar '
@output = Register::RegisterValue
check
end
2015-11-07 11:18:08 +01:00
def test_space
@root = :name
@string_input = 'space '
@output = Register::RegisterValue
check
end
2015-10-14 20:34:18 +02:00
def test_args
2015-10-22 17:16:29 +02:00
Register.machine.space.get_main.arguments.push Parfait::Variable.new(:Integer , :bar)
2015-10-14 20:34:18 +02:00
@root = :name
@string_input = 'bar '
@output = Register::RegisterValue
check
end
end
end