diff options
Diffstat (limited to 'tests/run/for_in_break_continue_T533.pyx')
-rw-r--r-- | tests/run/for_in_break_continue_T533.pyx | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/run/for_in_break_continue_T533.pyx b/tests/run/for_in_break_continue_T533.pyx index 0baa9fa49..20dfa4caa 100644 --- a/tests/run/for_in_break_continue_T533.pyx +++ b/tests/run/for_in_break_continue_T533.pyx @@ -1,4 +1,6 @@ -# ticket: 533 +# mode: run +# ticket: t533 +# ticket: gh1093 def for_in(): """ @@ -20,6 +22,7 @@ def for_in(): break return i + def for_from(): """ >>> for_from() @@ -39,3 +42,27 @@ def for_from(): print "BREAK", i break return i + + +def for_in_break2(data, avoid): + """ + >>> for_in_break2([1,2,3,None], avoid=[1,2,3]) + 3 + >>> for_in_break2([1,2,3,None], avoid=[1]) + 1 + >>> for_in_break2([1,2,3,None], avoid=[1]) + 1 + """ + data_iter = iter(data) + value = None + while 1: + match = next(data_iter) + if match is None: + break + for value in avoid: + if match == value: + break + else: + break + + return value |