[PEAK] PEAK-Rules, problem with comparison?

Phillip J. Eby pje at telecommunity.com
Fri Jan 25 09:53:49 EST 2008


At 12:51 PM 1/25/2008 +0100, Alberto Valverde wrote:
>Hi,
>
>After seeing in the last post in this list that PEAK-Rules now supports
>predicate dispatch I couldn't resist to try it out :) I think I might
>found a bug with comparison, the following doctest reproduces it:
>
><doctest>
> >>> from peak.rules import when
> >>> def add_two(a, b): pass
> >>> __ = when(add_two, "a > 5")(lambda a,b: a)
> >>> add_two(6,6)
>6
> >>> add_two(4,6)
> >>> add_two(5,6)
></doctest>
>
>As I undersand it, last statement should produce None, however, 5 is
>produced instead. This is with a fresh checkout, r2492

Fixed in SVN; another situation where my visual check of a test 
result was wrong.  Range indexes weren't being built properly in the 
case where you have a single > condition for a value.  If you had 
other comparisons against the same value (e.g. <=5, ==5, !=5, >=5, 
etc.) then it worked correctly.  Thanks for the catch!




More information about the PEAK mailing list