check the instructions that are produced in mom

This commit is contained in:
Torsten Ruger 2017-09-09 23:36:43 +03:00
parent d86282b007
commit c5ac24c850
3 changed files with 25 additions and 0 deletions

View File

@ -23,5 +23,8 @@ module Mom
def test_length def test_length
assert_equal 9 , @stats.length assert_equal 9 , @stats.length
end end
def test_array
check_array [SlotConstant,TruthCheck,Label,SimpleCall,SlotConstant,Label,SimpleCall,SlotConstant,Label] , @stats
end
end end
end end

View File

@ -23,5 +23,8 @@ module Mom
def test_length def test_length
assert_equal 4 , @stats.length assert_equal 4 , @stats.length
end end
def test_array
check_array [Label,SlotConstant,TruthCheck,Label] , @stats
end
end end
end end

View File

@ -34,6 +34,25 @@ module MomCompile
def compile_first_method_flat(input) def compile_first_method_flat(input)
compile_first_method(input).flatten compile_first_method(input).flatten
end end
def check_array( should , is )
index = 0
test = is
while(test)
assert_equal should[index] , test.class , "Wrong class for #{index+1}, #{dump(is)}"
index += 1
test = test.next
end
end
def dump(is)
res =[]
while(is)
res << is.class.name.split("::").last
is = is.next
end
"[#{res.join(',')}]"
end
end end