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