2015-11-07 11:18:08 +01:00
|
|
|
require_relative "helper"
|
2015-09-27 10:28:06 +02:00
|
|
|
|
2017-01-19 08:02:29 +01:00
|
|
|
module Risc
|
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
|
2017-01-19 08:02:29 +01:00
|
|
|
Risc.machine.boot
|
2015-10-13 15:42:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_field_not_defined
|
|
|
|
@root = :field_access
|
2017-01-16 08:34:47 +01:00
|
|
|
@input = s(:field_access, s(:receiver, s(:known, :self)), s(:field, s(:ivar, :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
|
2017-01-16 08:34:47 +01:00
|
|
|
@input = s(:field_access, s(:receiver, s(:known, :self)), s(:field, s(:ivar, :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
|
2017-01-16 08:34:47 +01:00
|
|
|
@input = s(:field_access,s(:receiver, s(:known, :self)),s(:field,s(:ivar, :bro)))
|
2017-01-19 08:02:29 +01:00
|
|
|
@output = Risc::RiscValue
|
2015-10-14 20:34:18 +02:00
|
|
|
check
|
2015-10-13 15:42:53 +02:00
|
|
|
end
|
2015-09-27 10:28:06 +02:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|