2015-09-27 10:28:06 +02:00
|
|
|
require_relative "compiler_helper"
|
|
|
|
|
|
|
|
module Virtual
|
2015-10-13 15:42:53 +02:00
|
|
|
class TestFields < MiniTest::Test
|
|
|
|
include CompilerHelper
|
2015-09-27 10:28:06 +02:00
|
|
|
|
2015-10-13 15:42:53 +02:00
|
|
|
def setup
|
|
|
|
Virtual.machine.boot
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_field_not_defined
|
|
|
|
@root = :field_access
|
2015-09-27 10:28:06 +02:00
|
|
|
@string_input = <<HERE
|
2015-10-13 15:42:53 +02:00
|
|
|
self.a
|
2015-09-27 10:28:06 +02:00
|
|
|
HERE
|
2015-10-13 15:42:53 +02:00
|
|
|
assert_raises(RuntimeError) { check }
|
2015-09-27 10:28:06 +02:00
|
|
|
end
|
|
|
|
|
2015-10-13 15:42:53 +02:00
|
|
|
def test_field
|
|
|
|
Virtual.machine.space.get_class_by_name(:Object).object_layout.add_instance_variable(:bro)
|
|
|
|
@root = :field_access
|
|
|
|
@string_input = <<HERE
|
|
|
|
self.bro
|
|
|
|
HERE
|
|
|
|
@output = Register::RegisterValue
|
|
|
|
check
|
|
|
|
end
|
2015-09-27 10:28:06 +02:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|