fix order of pops
slightly embarrassingly was popping (from the end) rather than shifting (from the start)
This commit is contained in:
parent
e0f6ba7bcf
commit
e6e8522b4e
@ -2,7 +2,7 @@ module Mom
|
|||||||
class Statement
|
class Statement
|
||||||
# flattening will change the structure from a tree to a linked list (and use
|
# flattening will change the structure from a tree to a linked list (and use
|
||||||
# nekst to do so)
|
# nekst to do so)
|
||||||
def flatten
|
def flatten(options = {})
|
||||||
raise "not implemented for #{self}"
|
raise "not implemented for #{self}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -11,9 +11,9 @@ module Mom
|
|||||||
include Common::Statements
|
include Common::Statements
|
||||||
|
|
||||||
def flatten( options = {} )
|
def flatten( options = {} )
|
||||||
flat = @statements.pop.flatten
|
flat = @statements.shift.flatten(options)
|
||||||
while( nekst = @statements.pop )
|
while( nekst = @statements.shift )
|
||||||
flat.append nekst.flatten()
|
flat.append nekst.flatten(options)
|
||||||
end
|
end
|
||||||
flat
|
flat
|
||||||
end
|
end
|
||||||
|
@ -23,7 +23,7 @@ module Mom
|
|||||||
assert_equal 7 , @stats.length
|
assert_equal 7 , @stats.length
|
||||||
end
|
end
|
||||||
def test_array
|
def test_array
|
||||||
check_array [SlotMove,TruthCheck,Label,MessageSetup,SimpleCall,ArgumentTransfer,Label], @stats
|
check_array [SlotMove,TruthCheck,Label,MessageSetup,ArgumentTransfer,SimpleCall,Label], @stats
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -24,7 +24,7 @@ module Mom
|
|||||||
assert_equal 11 , @stats.length
|
assert_equal 11 , @stats.length
|
||||||
end
|
end
|
||||||
def test_array
|
def test_array
|
||||||
check_array [SlotMove,TruthCheck,Label,SimpleCall,ArgumentTransfer,MessageSetup,Label,SimpleCall,ArgumentTransfer,MessageSetup,Label] , @stats
|
check_array [SlotMove,TruthCheck,Label,MessageSetup,ArgumentTransfer,SimpleCall,Label,MessageSetup,ArgumentTransfer,SimpleCall,Label] , @stats
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user