Skip to content
Permalink
Browse files

fixed bug that could lead to an infinite recursion

when searching for possible moves
  • Loading branch information...
SKoschnicke committed Nov 22, 2017
1 parent 0dce1ee commit 988e40659d1f7cd82aa5fe997e8a3524f28a6d13
Showing with 14 additions and 1 deletion.
  1. +1 −1 lib/software_challenge_client/action.rb
  2. +13 −0 spec/game_rules_spec.rb
@@ -110,7 +110,7 @@ def perform!(gamestate)
raise "Unknown card type #{card_type.inspect}!"
end
gamestate.set_last_action(self)
gamestate.current_player.cards.delete(self.type)
gamestate.current_player.cards.delete(card_type)
end

def type
@@ -127,4 +127,17 @@
end
end
end

it 'should not enter a infinite loop (stack level to deep)' do
state_from_string!('bC C H r1 H G', gamestate)
gamestate.current_player_color = PlayerColor::BLUE
gamestate.current_player.carrots = 49
gamestate.current_player.salads = 0
gamestate.current_player.cards = [
CardType::TAKE_OR_DROP_CARROTS,
CardType::HURRY_AHEAD,
CardType::FALL_BACK
]
expect { gamestate.possible_moves }.not_to raise_error
end
end

0 comments on commit 988e406

Please sign in to comment.
You can’t perform that action at this time.