nichtich/Plack-Middleware-Headers — pull request #1 by mla (2014-03-21 21:54:59+00:00)
Title: prevent when sub from modifying when conditions arrayref

Major problem with the "when" logic.

The splice loop in the generated when() subroutine was removing all elements from the @when array. It worked on the first call, but on subsequent calls, @when was empty.

That fact was not being exposed by test t/04_when.t due to the $has arrayref being modified by the tests themselves. I changed it to make a copy of the $hash array ref for each test and was able to reproduce (and fix) the bug.