rubyx/stash/test_vm/method_compiler/test_field_access.rb

35 lines
813 B
Ruby
Raw Normal View History

2015-11-07 11:18:08 +01:00
require_relative "helper"
module Risc
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
def setup
Risc.machine.boot
end
def test_field_not_defined
@root = :field_access
@input = s(:field_access, s(:receiver, s(:known, :self)), s(:field, s(:ivar, :a)))
assert_raises(RuntimeError) { check }
end
2015-11-07 11:18:08 +01:00
def test_field_not_space
@root = :field_access
@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
def test_field
2016-12-10 17:07:38 +01:00
add_space_field(:bro,:Object)
@root = :field_access
@input = s(:field_access,s(:receiver, s(:known, :self)),s(:field,s(:ivar, :bro)))
@output = Risc::RiscValue
2015-10-14 20:34:18 +02:00
check
end
end
end