more assignment tests
move to writing code to Test class To use space as before one would have to implement re-opening classes
This commit is contained in:
parent
c0a7f1d284
commit
dda2ff9049
@ -28,8 +28,9 @@ module Risc
|
||||
end
|
||||
def produce_instructions
|
||||
assert @expect , "No output given"
|
||||
Vool::VoolCompiler.ruby_to_vool "class Space; def main(arg);#{@input};end;end"
|
||||
Parfait.object_space.get_main.instructions
|
||||
Vool::VoolCompiler.ruby_to_vool "class Test; def main(arg);#{@input};end;end"
|
||||
test = Parfait.object_space.get_class_by_name :Test
|
||||
test.instance_type.get_method( :main).instructions
|
||||
end
|
||||
def check_nil
|
||||
produced = produce_instructions
|
||||
@ -38,7 +39,8 @@ module Risc
|
||||
def check_return
|
||||
was = check_nil
|
||||
raise was if was
|
||||
Parfait.object_space.get_main.instructions
|
||||
test = Parfait.object_space.get_class_by_name :Test
|
||||
test.instance_type.get_method :main
|
||||
end
|
||||
def real_index(index)
|
||||
index - preamble.length
|
||||
|
27
test/mom/test_assign_ivar_const.rb
Normal file
27
test/mom/test_assign_ivar_const.rb
Normal file
@ -0,0 +1,27 @@
|
||||
require_relative 'helper'
|
||||
|
||||
module Risc
|
||||
class TestAssignIvarConst < MiniTest::Test
|
||||
include Statements
|
||||
|
||||
def setup
|
||||
super
|
||||
@input = "@ivar = 5"
|
||||
@expect = [LoadConstant, RegToSlot]
|
||||
end
|
||||
def test_local_assign_instructions
|
||||
assert_nil msg = check_nil , msg
|
||||
end
|
||||
|
||||
def test_constant_load
|
||||
produced = produce_body
|
||||
assert_equal 5 , produced.constant.known_object.value
|
||||
end
|
||||
|
||||
def test_slot_move
|
||||
produced = produce_body
|
||||
assert_equal produced.next.register , produced.register
|
||||
end
|
||||
|
||||
end
|
||||
end
|
27
test/mom/test_assign_local_ivar.rb
Normal file
27
test/mom/test_assign_local_ivar.rb
Normal file
@ -0,0 +1,27 @@
|
||||
require_relative 'helper'
|
||||
|
||||
module Risc
|
||||
class TestAssignLocalIvar < MiniTest::Test
|
||||
include Statements
|
||||
|
||||
def setup
|
||||
super
|
||||
@input = "@ivar = 5 ; r = @ivar"
|
||||
@expect = [LoadConstant, RegToSlot, SlotToReg, SlotToReg, RegToSlot]
|
||||
end
|
||||
def test_local_assign_instructions
|
||||
assert_nil msg = check_nil , msg
|
||||
end
|
||||
|
||||
def test_constant_load
|
||||
produced = produce_body
|
||||
assert_equal 5 , produced.constant.known_object.value
|
||||
end
|
||||
|
||||
def test_slot_move
|
||||
produced = produce_body
|
||||
assert_equal produced.next.register , produced.register
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user