2015-11-07 11:18:08 +01:00
|
|
|
require_relative "helper"
|
2015-09-27 10:28:06 +02:00
|
|
|
|
2015-10-22 17:16:29 +02:00
|
|
|
module Register
|
2015-10-13 15:42:53 +02:00
|
|
|
class TestFields < MiniTest::Test
|
2015-11-07 11:18:08 +01:00
|
|
|
include ExpressionHelper
|
2016-12-10 14:18:37 +01:00
|
|
|
include AST::Sexp
|
2015-09-27 10:28:06 +02:00
|
|
|
|
2015-10-13 15:42:53 +02:00
|
|
|
def setup
|
2015-10-22 17:16:29 +02:00
|
|
|
Register.machine.boot
|
2015-10-13 15:42:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_field_not_defined
|
|
|
|
@root = :field_access
|
2016-12-10 14:18:37 +01:00
|
|
|
@input = s(:field_access, s(:receiver, s(:name, :self)), s(:field, s(:name, :a)))
|
2015-10-13 15:42:53 +02:00
|
|
|
assert_raises(RuntimeError) { check }
|
2015-09-27 10:28:06 +02:00
|
|
|
end
|
|
|
|
|
2015-11-07 11:18:08 +01:00
|
|
|
def test_field_not_space
|
|
|
|
@root = :field_access
|
2016-12-10 22:07:04 +01:00
|
|
|
@input = s(:field_access, s(:receiver, s(:name, :self)), s(:field, s(:name, :space)))
|
2016-12-10 14:18:37 +01:00
|
|
|
|
2015-11-07 11:18:08 +01:00
|
|
|
assert_raises(RuntimeError) { check }
|
|
|
|
end
|
|
|
|
|
2015-10-13 15:42:53 +02:00
|
|
|
def test_field
|
2016-12-10 17:07:38 +01:00
|
|
|
add_space_field(:bro,:Object)
|
2015-10-13 15:42:53 +02:00
|
|
|
@root = :field_access
|
2016-12-10 22:07:04 +01:00
|
|
|
@input = s(:field_access,s(:receiver, s(:name, :self)),s(:field,s(:name, :bro)))
|
2015-10-14 20:34:18 +02:00
|
|
|
@output = Register::RegisterValue
|
|
|
|
check
|
2015-10-13 15:42:53 +02:00
|
|
|
end
|
2015-09-27 10:28:06 +02:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|