2015-09-27 11:28:06 +03:00
|
|
|
require_relative "compiler_helper"
|
|
|
|
|
2015-10-22 18:16:29 +03:00
|
|
|
module Register
|
2015-10-13 16:42:53 +03:00
|
|
|
class TestFields < MiniTest::Test
|
|
|
|
include CompilerHelper
|
2015-09-27 11:28:06 +03:00
|
|
|
|
2015-10-13 16:42:53 +03:00
|
|
|
def setup
|
2015-10-22 18:16:29 +03:00
|
|
|
Register.machine.boot
|
2015-10-13 16:42:53 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_field_not_defined
|
|
|
|
@root = :field_access
|
2015-09-27 11:28:06 +03:00
|
|
|
@string_input = <<HERE
|
2015-10-13 16:42:53 +03:00
|
|
|
self.a
|
2015-09-27 11:28:06 +03:00
|
|
|
HERE
|
2015-10-13 16:42:53 +03:00
|
|
|
assert_raises(RuntimeError) { check }
|
2015-09-27 11:28:06 +03:00
|
|
|
end
|
|
|
|
|
2015-10-13 16:42:53 +03:00
|
|
|
def test_field
|
2015-10-29 12:45:29 +02:00
|
|
|
Register.machine.space.get_class_by_name(:Object).object_layout.add_instance_variable(:bro,:Object)
|
2015-10-13 16:42:53 +03:00
|
|
|
@root = :field_access
|
|
|
|
@string_input = <<HERE
|
|
|
|
self.bro
|
|
|
|
HERE
|
|
|
|
@output = Register::RegisterValue
|
2015-10-14 21:34:18 +03:00
|
|
|
check
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_local
|
2015-10-22 18:16:29 +03:00
|
|
|
Register.machine.space.get_main.ensure_local(:bar , :Integer)
|
2015-10-14 21:34:18 +03:00
|
|
|
@root = :name
|
|
|
|
@string_input = 'bar '
|
|
|
|
@output = Register::RegisterValue
|
|
|
|
check
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_args
|
2015-10-22 18:16:29 +03:00
|
|
|
Register.machine.space.get_main.arguments.push Parfait::Variable.new(:Integer , :bar)
|
2015-10-14 21:34:18 +03:00
|
|
|
@root = :name
|
|
|
|
@string_input = 'bar '
|
|
|
|
@output = Register::RegisterValue
|
|
|
|
check
|
2015-10-13 16:42:53 +03:00
|
|
|
end
|
2015-09-27 11:28:06 +03:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|