finish assign test
start ifs
This commit is contained in:
parent
3c1137066b
commit
f624e38dbb
@ -0,0 +1 @@
|
||||
require_relative "../helper"
|
@ -19,11 +19,8 @@ module VoolBlocks
|
||||
def test_slot_starts_at_message
|
||||
assert_equal :message , @ins.left.known_object
|
||||
end
|
||||
def test_slot_gets_self
|
||||
assert_equal :frame , @ins.left.slots[0]
|
||||
end
|
||||
def test_slot_assigns_to_local
|
||||
assert_equal :local , @ins.left.slots[-1]
|
||||
def test_slots_left
|
||||
assert_equal [:frame , :local] , @ins.left.slots
|
||||
end
|
||||
def test_slot_assigns_something
|
||||
assert @ins.right
|
||||
@ -33,41 +30,39 @@ module VoolBlocks
|
||||
end
|
||||
end
|
||||
|
||||
#otherwise as above, but assigning instance, so should get a SlotLoad
|
||||
class TestAssignMomInstanceToLocal < MiniTest::Test
|
||||
include MomCompile
|
||||
def setup
|
||||
Parfait.boot!
|
||||
@ins = compile_first_block( "local = @a" , "@a = 5")
|
||||
@ins = compile_first_block( "local = @a" , "@a = 5") #second arg in method scope
|
||||
end
|
||||
def test_class_compiles
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
end
|
||||
def test_slots_left
|
||||
assert_equal [:frame, :local] , @ins.left.slots
|
||||
end
|
||||
def test_slots_right
|
||||
assert_equal [:receiver, :a] , @ins.right.slots
|
||||
end
|
||||
end
|
||||
|
||||
#compiling to an argument should result in different second parameter in the slot array
|
||||
class TestAssignToArg < MiniTest::Test
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
@ins = compile_first_method( "arg = 5")
|
||||
@ins = compile_first_block( "arg = 5")
|
||||
end
|
||||
|
||||
def pest_class_compiles
|
||||
def test_class_compiles
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
end
|
||||
def pest_slot_is_set
|
||||
def test_slot_is_set
|
||||
assert @ins.left
|
||||
end
|
||||
def pest_slot_starts_at_message
|
||||
assert_equal :message , @ins.left.known_object
|
||||
end
|
||||
def pest_slot_gets_self
|
||||
assert_equal :arguments , @ins.left.slots[0]
|
||||
end
|
||||
def pest_slot_assigns_to_local
|
||||
assert_equal :arg , @ins.left.slots[-1]
|
||||
def test_slots_left
|
||||
assert_equal [:caller, :arguments, :arg] , @ins.left.slots
|
||||
end
|
||||
end
|
||||
|
||||
@ -76,12 +71,12 @@ module VoolBlocks
|
||||
def setup
|
||||
Parfait.boot!
|
||||
end
|
||||
def pest_assigns_const
|
||||
def test_assigns_const
|
||||
@ins = compile_first_method( "@a = 5")
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins
|
||||
end
|
||||
def pest_assigns_move
|
||||
def test_assigns_move
|
||||
@ins = compile_first_method( "@a = arg")
|
||||
assert_equal Mom::SlotLoad , @ins.class , @ins
|
||||
assert_equal Mom::SlotDefinition , @ins.right.class , @ins
|
||||
|
30
test/vool/blocks/test_if_condition.rb
Normal file
30
test/vool/blocks/test_if_condition.rb
Normal file
@ -0,0 +1,30 @@
|
||||
require_relative "helper"
|
||||
|
||||
module VoolBlocks
|
||||
class TestConditionIfMom #< MiniTest::Test
|
||||
include MomCompile
|
||||
include Mom
|
||||
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc::Builtin.boot_functions
|
||||
@ins = compile_first_block( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end")
|
||||
end
|
||||
|
||||
def test_condition
|
||||
assert_equal TruthCheck , @ins.next(4).class
|
||||
end
|
||||
def test_condition_is_slot
|
||||
assert_equal SlotDefinition , @ins.next(4).condition.class , @ins
|
||||
end
|
||||
def test_hoisted_dynamic_call
|
||||
assert_equal SimpleCall , @ins.next(2).class
|
||||
assert_equal :div4 , @ins.next(2).method.name
|
||||
end
|
||||
def test_array
|
||||
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, TruthCheck, Label ,
|
||||
SlotLoad, Jump, Label, SlotLoad, Label] , @ins
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,4 +1,3 @@
|
||||
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
|
Loading…
Reference in New Issue
Block a user