From 512c5008103d4a8e5693831d0958d125c58c2dea Mon Sep 17 00:00:00 2001 From: Berbe <4251220+Berbe@users.noreply.github.com> Date: Mon, 10 Oct 2022 04:54:19 +0200 Subject: [PATCH] Add: Tests: CONTINUE in else block in a for loop --- .../07_for_if_else-continue.pyc | Bin 0 -> 962 bytes .../bug27+/07_for_if_else-continue.py | 33 ++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 test/bytecode_2.7_run/07_for_if_else-continue.pyc create mode 100644 test/simple_source/bug27+/07_for_if_else-continue.py diff --git a/test/bytecode_2.7_run/07_for_if_else-continue.pyc b/test/bytecode_2.7_run/07_for_if_else-continue.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e4894c380486739a4e84ddc28e0ec8960f35589f GIT binary patch literal 962 zcmb`E&u-H|5XNWiG-)CIBSEhyy;(vbP!;u3wV<|$UQA_zDpf)zU2jq=jyLSCMUm1& zfhXa>3-SVdvq{yaa6w>uza7nvXJ>vB{#?HIKpjX)vnRm*0?Yn@WJIUX8fAjM2|5kD z9e6t=6_BdYK+spg#xNkeM{a?#kUd}EM9g&nk_;EgewYtHhWaeSEZ}NB02%HCe4h)z zUvHxYuJ;k7d!F0Y*yw@jjao3RD*A1CuH-N;2OE-m3$b|L$Fe(+i{~^UI(Xlv%YY^U znFi~npmLQyHproW-y!;$p2CUmWFl}gXNv7Q=X(=(kK%WStx~&IUl)b`q_Rlh#H~PH zTC0r9b$MuvHW63h_^{{Ics+~YATM@{1C(_gn~%nYO0BMpRGqVGu(|!X^K?7yYm?^v zR25dWr7m4wR_e+4Gw@G;eCDC7aYnH$>S8GfMH72N{Ep!SK^MnU46ko6-0A+$Joc|? z;o4iM{)$k-ReB}~Gf9|g!ifGSkWFS`A3{73;8>j@SrTi)@{o>7sf|$*1H|~^r~#j2 zNz+WrG<7xDu`X4@M&ePk)iss!J$U-BdYH*g<^MR(MdaTZ>8vW$F5hLFkh*BzZ?0?z Get!YW;k$qU literal 0 HcmV?d00001 diff --git a/test/simple_source/bug27+/07_for_if_else-continue.py b/test/simple_source/bug27+/07_for_if_else-continue.py new file mode 100644 index 00000000..3944232a --- /dev/null +++ b/test/simple_source/bug27+/07_for_if_else-continue.py @@ -0,0 +1,33 @@ +# Issue #413 on 2.7 +# Bug in handling CONTINUE in else block of if-then-else in a for loop + +"""This program is self-checking!""" +def test1(a, r = None): + for b in a: + if b: + r = b + else: + continue + raise AssertionError("CONTINUE not followed") + if b: + pass + return r + +def test2(a, r = None): + for b in a: + if b: + #pass # No payload + continue + raise AssertionError("CONTINUE not followed") + else: + continue + raise AssertionError("CONTINUE not followed") + if b: + r = b + raise AssertionError("CONTINUE not followed") + return r + +assert test1([True]) == True, "Incorrect flow" +assert test2([True]) is None, "Incorrect flow" +assert test1([False]) is None, "Incorrect flow" +assert test2([False]) is None, "Incorrect flow"