fix ivar test by actually creating ivar first

nice to know one gets errors for using an ivar that was not assigned to
This commit is contained in:
Torsten Ruger 2018-03-18 22:38:49 +05:30
parent e2729513ed
commit ed902c343c

View File

@ -6,29 +6,29 @@ module Vool
def setup def setup
Risc.machine.boot Risc.machine.boot
@stats = compile_first_method( "local = 5") @ins = compile_first_method( "local = 5")
end end
def test_class_compiles def test_class_compiles
assert_equal Mom::SlotLoad , @stats.class , @stats assert_equal Mom::SlotLoad , @ins.class , @ins
end end
def test_slot_is_set def test_slot_is_set
assert @stats.left assert @ins.left
end end
def test_slot_starts_at_message def test_slot_starts_at_message
assert_equal :message , @stats.left.known_object assert_equal :message , @ins.left.known_object
end end
def test_slot_gets_self def test_slot_gets_self
assert_equal :frame , @stats.left.slots[0] assert_equal :frame , @ins.left.slots[0]
end end
def test_slot_assigns_to_local def test_slot_assigns_to_local
assert_equal :local , @stats.left.slots[-1] assert_equal :local , @ins.left.slots[-1]
end end
def test_slot_assigns_something def test_slot_assigns_something
assert @stats.right assert @ins.right
end end
def test_slot_assigns_int def test_slot_assigns_int
assert_equal Mom::IntegerConstant , @stats.right.known_object.class assert_equal Mom::IntegerConstant , @ins.right.known_object.class
end end
end end
@ -37,10 +37,10 @@ module Vool
include MomCompile include MomCompile
def setup def setup
Risc.machine.boot Risc.machine.boot
@stats = compile_first_method( "local = @a") @ins = compile_first_method( "@a = 5 ; local = @a")
end end
def test_class_compiles def test_class_compiles
assert_equal Mom::SlotLoad , @stats.class , @stats assert_equal Mom::SlotLoad , @ins.next.class , @ins
end end
end end
@ -50,23 +50,23 @@ module Vool
def setup def setup
Risc.machine.boot Risc.machine.boot
@stats = compile_first_method( "arg = 5") @ins = compile_first_method( "arg = 5")
end end
def test_class_compiles def test_class_compiles
assert_equal Mom::SlotLoad , @stats.class , @stats assert_equal Mom::SlotLoad , @ins.class , @ins
end end
def test_slot_is_set def test_slot_is_set
assert @stats.left assert @ins.left
end end
def test_slot_starts_at_message def test_slot_starts_at_message
assert_equal :message , @stats.left.known_object assert_equal :message , @ins.left.known_object
end end
def test_slot_gets_self def test_slot_gets_self
assert_equal :arguments , @stats.left.slots[0] assert_equal :arguments , @ins.left.slots[0]
end end
def test_slot_assigns_to_local def test_slot_assigns_to_local
assert_equal :arg , @stats.left.slots[-1] assert_equal :arg , @ins.left.slots[-1]
end end
end end
@ -76,14 +76,14 @@ module Vool
Risc.machine.boot Risc.machine.boot
end end
def test_assigns_const def test_assigns_const
@stats = compile_first_method( "@a = 5") @ins = compile_first_method( "@a = 5")
assert_equal Mom::SlotLoad , @stats.class , @stats assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal Mom::IntegerConstant , @stats.right.known_object.class , @stats assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins
end end
def test_assigns_move def test_assigns_move
@stats = compile_first_method( "@a = arg") @ins = compile_first_method( "@a = arg")
assert_equal Mom::SlotLoad , @stats.class , @stats assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal Mom::SlotDefinition , @stats.right.class , @stats assert_equal Mom::SlotDefinition , @ins.right.class , @ins
end end
end end