From e6e8522b4eddfdce8b8956902b0df65c50f89606 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 12 Mar 2018 18:13:07 +0530 Subject: [PATCH] fix order of pops slightly embarrassingly was popping (from the end) rather than shifting (from the start) --- lib/mom/statement.rb | 10 +++++----- test/mom/test_if_simple_statement.rb | 2 +- test/mom/test_if_statement.rb | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/mom/statement.rb b/lib/mom/statement.rb index 421adcfe..33d8a7af 100644 --- a/lib/mom/statement.rb +++ b/lib/mom/statement.rb @@ -2,7 +2,7 @@ module Mom class Statement # flattening will change the structure from a tree to a linked list (and use # nekst to do so) - def flatten + def flatten(options = {}) raise "not implemented for #{self}" end end @@ -10,10 +10,10 @@ module Mom class Statements < Statement include Common::Statements - def flatten( options = {} ) - flat = @statements.pop.flatten - while( nekst = @statements.pop ) - flat.append nekst.flatten() + def flatten( options = {} ) + flat = @statements.shift.flatten(options) + while( nekst = @statements.shift ) + flat.append nekst.flatten(options) end flat end diff --git a/test/mom/test_if_simple_statement.rb b/test/mom/test_if_simple_statement.rb index ef26a0de..7eae1144 100644 --- a/test/mom/test_if_simple_statement.rb +++ b/test/mom/test_if_simple_statement.rb @@ -23,7 +23,7 @@ module Mom assert_equal 7 , @stats.length end 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 diff --git a/test/mom/test_if_statement.rb b/test/mom/test_if_statement.rb index ecb30337..4afc0efe 100644 --- a/test/mom/test_if_statement.rb +++ b/test/mom/test_if_statement.rb @@ -24,7 +24,7 @@ module Mom assert_equal 11 , @stats.length end 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