Changeset 5322:23a99cbbf7f8 in livinglogic.python.xist for test/test_ul4.py

Show
Ignore:
Timestamp:
02/08/13 18:45:13 (7 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Rename <?exe?> back to <?code?>.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • test/test_ul4.py

    r5321 r5322  
    634634@pytest.mark.ul4 
    635635def test_color(r): 
    636     assert '255,255,255,255' == r('<?exe c = #fff?><?print c[0]?>,<?print c[1]?>,<?print c[2]?>,<?print c[3]?>') 
    637     assert '255,255,255,255' == r('<?exe c = #ffffff?><?print c[0]?>,<?print c[1]?>,<?print c[2]?>,<?print c[3]?>') 
    638     assert '18,52,86,255' == r('<?exe c = #123456?><?print c[0]?>,<?print c[1]?>,<?print c[2]?>,<?print c[3]?>') 
    639     assert '17,34,51,68' == r('<?exe c = #1234?><?print c[0]?>,<?print c[1]?>,<?print c[2]?>,<?print c[3]?>') 
    640     assert '18,52,86,120' == r('<?exe c = #12345678?><?print c[0]?>,<?print c[1]?>,<?print c[2]?>,<?print c[3]?>') 
     636    assert '255,255,255,255' == r('<?code c = #fff?><?print c[0]?>,<?print c[1]?>,<?print c[2]?>,<?print c[3]?>') 
     637    assert '255,255,255,255' == r('<?code c = #ffffff?><?print c[0]?>,<?print c[1]?>,<?print c[2]?>,<?print c[3]?>') 
     638    assert '18,52,86,255' == r('<?code c = #123456?><?print c[0]?>,<?print c[1]?>,<?print c[2]?>,<?print c[3]?>') 
     639    assert '17,34,51,68' == r('<?code c = #1234?><?print c[0]?>,<?print c[1]?>,<?print c[2]?>,<?print c[3]?>') 
     640    assert '18,52,86,120' == r('<?code c = #12345678?><?print c[0]?>,<?print c[1]?>,<?print c[2]?>,<?print c[3]?>') 
    641641    assert 'yes' == r('<?if #fff?>yes<?else?>no<?end if?>') 
    642642 
     
    655655@pytest.mark.ul4 
    656656def test_listcomp(r): 
    657     assert "[2, 6]" == r("<?exe d = [2*i for i in range(4) if i%2]?><?print d?>") 
    658     assert "[0, 2, 4, 6]" == r("<?exe d = [2*i for i in range(4)]?><?print d?>") 
     657    assert "[2, 6]" == r("<?code d = [2*i for i in range(4) if i%2]?><?print d?>") 
     658    assert "[0, 2, 4, 6]" == r("<?code d = [2*i for i in range(4)]?><?print d?>") 
    659659 
    660660    # Make sure that the loop variables doesn't leak into the surrounding scope 
    661     assert "undefined" == r("<?exe d = [2*i for i in range(4)]?><?print type(i)?>") 
     661    assert "undefined" == r("<?code d = [2*i for i in range(4)]?><?print type(i)?>") 
    662662 
    663663 
    664664@pytest.mark.ul4 
    665665def test_genexpr(r): 
    666     assert "2, 6:" == r("<?exe ge = (str(2*i) for i in range(4) if i%2)?><?print ', '.join(ge)?>:<?print ', '.join(ge)?>") 
     666    assert "2, 6:" == r("<?code ge = (str(2*i) for i in range(4) if i%2)?><?print ', '.join(ge)?>:<?print ', '.join(ge)?>") 
    667667    assert "2, 6" == r("<?print ', '.join(str(2*i) for i in range(4) if i%2)?>") 
    668668    assert "0, 2, 4, 6" == r("<?print ', '.join(str(2*i) for i in range(4))?>") 
     
    671671 
    672672    # Make sure that the loop variables doesn't leak into the surrounding scope 
    673     assert "undefined" == r("<?exe d = (2*i for i in range(4))?><?print type(i)?>") 
     673    assert "undefined" == r("<?code d = (2*i for i in range(4))?><?print type(i)?>") 
    674674 
    675675 
     
    689689 
    690690    # Make sure that the loop variables doesn't leak into the surrounding scope 
    691     assert "undefined" == r("<?exe d = {i: 2*i for i in range(4)}?><?print type(i)?>") 
     691    assert "undefined" == r("<?code d = {i: 2*i for i in range(4)}?><?print type(i)?>") 
    692692 
    693693 
     
    695695def test_dictcomp(r): 
    696696    # JS only supports string keys 
    697     assert "" == r("<?exe d = {str(i):2*i for i in range(10) if i%2}?><?if '2' in d?><?print d['2']?><?end if?>") 
    698     assert "6" == r("<?exe d = {str(i):2*i for i in range(10) if i%2}?><?if '3' in d?><?print d['3']?><?end if?>") 
    699     assert "6" == r("<?exe d = {str(i):2*i for i in range(10)}?><?print d['3']?>") 
     697    assert "" == r("<?code d = {str(i):2*i for i in range(10) if i%2}?><?if '2' in d?><?print d['2']?><?end if?>") 
     698    assert "6" == r("<?code d = {str(i):2*i for i in range(10) if i%2}?><?if '3' in d?><?print d['3']?><?end if?>") 
     699    assert "6" == r("<?code d = {str(i):2*i for i in range(10)}?><?print d['3']?>") 
    700700 
    701701 
     
    714714@pytest.mark.ul4 
    715715def test_storevar(r): 
    716     assert '42' == r('<?exe x = 42?><?print x?>') 
    717     assert 'xyzzy' == r('<?exe x = "xyzzy"?><?print x?>') 
    718     assert 'x,y' == r('<?exe (x, y) = "xy"?><?print x?>,<?print y?>') 
    719     assert '42' == r('<?exe (x,) = [42]?><?print x?>') 
    720     assert '17,23' == r('<?exe (x,y) = [17, 23]?><?print x?>,<?print y?>') 
    721     assert '17,23,37,42,105' == r('<?exe ((v, w), (x,), (y,), z) = [[17, 23], [37], [42], 105]?><?print v?>,<?print w?>,<?print x?>,<?print y?>,<?print z?>') 
     716    assert '42' == r('<?code x = 42?><?print x?>') 
     717    assert 'xyzzy' == r('<?code x = "xyzzy"?><?print x?>') 
     718    assert 'x,y' == r('<?code (x, y) = "xy"?><?print x?>,<?print y?>') 
     719    assert '42' == r('<?code (x,) = [42]?><?print x?>') 
     720    assert '17,23' == r('<?code (x,y) = [17, 23]?><?print x?>,<?print y?>') 
     721    assert '17,23,37,42,105' == r('<?code ((v, w), (x,), (y,), z) = [[17, 23], [37], [42], 105]?><?print v?>,<?print w?>,<?print x?>,<?print y?>,<?print z?>') 
    722722 
    723723 
     
    726726    for x in (17, 17., False, True): 
    727727        for y in (23, 23., False, True): 
    728             assert x + y == eval(r('<?exe x = {}?><?exe x += {}?><?print x?>'.format(x, y))) 
    729     assert 'xyzzy' == r('<?exe x = "xyz"?><?exe x += "zy"?><?print x?>') 
     728            assert x + y == eval(r('<?code x = {}?><?code x += {}?><?print x?>'.format(x, y))) 
     729    assert 'xyzzy' == r('<?code x = "xyz"?><?code x += "zy"?><?print x?>') 
    730730 
    731731 
     
    734734    for x in (17, 17., False, True): 
    735735        for y in (23, 23., False, True): 
    736             assert x - y == eval(r('<?exe x = {}?><?exe x -= {}?><?print x?>'.format(x, y))) 
     736            assert x - y == eval(r('<?code x = {}?><?code x -= {}?><?print x?>'.format(x, y))) 
    737737 
    738738 
     
    741741    for x in (17, 17., False, True): 
    742742        for y in (23, 23., False, True): 
    743             assert x * y == eval(r('<?exe x = {}?><?exe x *= {}?><?print x?>'.format(x, y))) 
     743            assert x * y == eval(r('<?code x = {}?><?code x *= {}?><?print x?>'.format(x, y))) 
    744744    for x in (17, False, True): 
    745745        y = "xyzzy" 
    746         assert x * y == r('<?exe x = {}?><?exe x *= {!r}?><?print x?>'.format(x, y)) 
    747     assert 17*"xyzzy" == r('<?exe x = "xyzzy"?><?exe x *= 17?><?print x?>') 
     746        assert x * y == r('<?code x = {}?><?code x *= {!r}?><?print x?>'.format(x, y)) 
     747    assert 17*"xyzzy" == r('<?code x = "xyzzy"?><?code x *= 17?><?print x?>') 
    748748 
    749749 
     
    752752    for x in (5, -5, 5.0, -5.0, 4, -4, 4.0, -4.0, False, True): 
    753753        for y in (2, -2, 2.0, -2.0, True): 
    754             assert x // y == eval(r('<?exe x = {}?><?exe x //= {}?><?print x?>'.format(x, y))) 
     754            assert x // y == eval(r('<?code x = {}?><?code x //= {}?><?print x?>'.format(x, y))) 
    755755 
    756756 
     
    759759    for x in (5, -5, 5.0, -5.0, 4, -4, 4.0, -4.0, False, True): 
    760760        for y in (2, -2, 2.0, -2.0, True): 
    761             assert x / y == eval(r('<?exe x = {}?><?exe x /= {}?><?print x?>'.format(x, y))) 
     761            assert x / y == eval(r('<?code x = {}?><?code x /= {}?><?print x?>'.format(x, y))) 
    762762 
    763763 
     
    766766    for x in (1729, 1729.0, -1729, -1729.0, False, True): 
    767767        for y in (23, 23., -23, -23.0, True): 
    768             assert x % y == eval(r('<?exe x = {}?><?exe x %= {}?><?print x?>'.format(x, y))) 
     768            assert x % y == eval(r('<?code x = {}?><?code x %= {}?><?print x?>'.format(x, y))) 
    769769 
    770770 
     
    884884        render_python('<?for?>') 
    885885    with raises("statement required"): 
    886         render_python('<?exe?>') 
     886        render_python('<?code?>') 
    887887 
    888888 
     
    895895        for y in values: 
    896896            assert x + y == eval(r(code, x=x, y=y)) # Using ``evaleq`` avoids problem with the nonexistant int/float distinction in JS 
    897     assert 'foobar' == r('<?exe x="foo"?><?exe y="bar"?><?print x+y?>') 
     897    assert 'foobar' == r('<?code x="foo"?><?code y="bar"?><?print x+y?>') 
    898898    assert '(f)(o)(o)(b)(a)(r)' == r('<?for i in data.foo+data.bar?>(<?print i?>)<?end for?>', data=dict(foo="foo", bar="bar")) 
    899899    assert "2012-10-18 00:00:00" == r(code, x=datetime.datetime(2012, 10, 17), y=datetime.timedelta(1)) 
     
    973973            assert x * y == eval(r(code, x=x, y=y)) 
    974974    assert 17*"foo" == r('<?print 17*"foo"?>') 
    975     assert 17*"foo" == r('<?exe x=17?><?exe y="foo"?><?print x*y?>') 
    976     assert "foo"*17 == r('<?exe x="foo"?><?exe y=17?><?print x*y?>') 
     975    assert 17*"foo" == r('<?code x=17?><?code y="foo"?><?print x*y?>') 
     976    assert "foo"*17 == r('<?code x="foo"?><?code y=17?><?print x*y?>') 
    977977    assert "foo"*17 == r('<?print "foo"*17?>') 
    978978    assert "(foo)(bar)(foo)(bar)(foo)(bar)" == r('<?for i in 3*data?>(<?print i?>)<?end for?>', data=["foo", "bar"]) 
     
    996996 
    997997    assert "0.5" == r('<?print 1/2?>') 
    998     assert "0.5" == r('<?exe x=1?><?exe y=2?><?print x/y?>') 
     998    assert "0.5" == r('<?code x=1?><?code y=2?><?print x/y?>') 
    999999    assert "0:00:00" == r(code, x=datetime.timedelta(), y=4) 
    10001000    assert "2 days, 0:00:00" == r(code, x=datetime.timedelta(8), y=4) 
     
    10121012def test_floordiv(r): 
    10131013    assert "0" == r('<?print 1//2?>') 
    1014     assert "0" == r('<?exe x=1?><?exe y=2?><?print x//y?>') 
     1014    assert "0" == r('<?code x=1?><?code y=2?><?print x//y?>') 
    10151015    assert "1 month" == r('<?print x//y?>', x=misc.monthdelta(3), y=2) 
    10161016 
     
    12521252 
    12531253    assert str(n) == r('<?print {}?>'.format(sc)) 
    1254     assert str(n) == r('<?exe x=4?><?print {}?>'.format(sv)) 
     1254    assert str(n) == r('<?code x=4?><?print {}?>'.format(sv)) 
    12551255 
    12561256 
     
    12901290 
    12911291    assert "4" == r('<?print {}?>'.format(sc)) 
    1292     assert "4" == r('<?exe x=4?><?print {}?>'.format(sv)) 
     1292    assert "4" == r('<?code x=4?><?print {}?>'.format(sv)) 
    12931293 
    12941294 
     
    13931393    with raises(argumentmismatchmessage): 
    13941394        r("<?print random(foo=1)?>") 
    1395     assert "ok" == r("<?exe r = random()?><?if r>=0 and r<1?>ok<?else?>fail<?end if?>") 
     1395    assert "ok" == r("<?code r = random()?><?if r>=0 and r<1?>ok<?else?>fail<?end if?>") 
    13961396 
    13971397 
     
    14021402    with raises(argumentmismatchmessage): 
    14031403        r("<?print randrange(foo=1)?>") 
    1404     assert "ok" == r("<?exe r = randrange(4)?><?if r>=0 and r<4?>ok<?else?>fail<?end if?>") 
    1405     assert "ok" == r("<?exe r = randrange(17, 23)?><?if r>=17 and r<23?>ok<?else?>fail<?end if?>") 
    1406     assert "ok" == r("<?exe r = randrange(17, 23, 2)?><?if r>=17 and r<23 and r%2?>ok<?else?>fail<?end if?>") 
     1404    assert "ok" == r("<?code r = randrange(4)?><?if r>=0 and r<4?>ok<?else?>fail<?end if?>") 
     1405    assert "ok" == r("<?code r = randrange(17, 23)?><?if r>=17 and r<23?>ok<?else?>fail<?end if?>") 
     1406    assert "ok" == r("<?code r = randrange(17, 23, 2)?><?if r>=17 and r<23 and r%2?>ok<?else?>fail<?end if?>") 
    14071407 
    14081408 
     
    14111411    with raises(argumentmismatchmessage): 
    14121412        r("<?print randchoice()?>") 
    1413     assert "ok" == r("<?exe r = randchoice('abc')?><?if r in 'abc'?>ok<?else?>fail<?end if?>") 
    1414     assert "ok" == r("<?exe s = [17, 23, 42]?><?exe r = randchoice(s)?><?if r in s?>ok<?else?>fail<?end if?>") 
    1415     assert "ok" == r("<?exe s = #12345678?><?exe sl = [0x12, 0x34, 0x56, 0x78]?><?exe r = randchoice(s)?><?if r in sl?>ok<?else?>fail<?end if?>") 
    1416  
    1417     # Make sure that the parameters have the same name in all implementations 
    1418     assert "ok" == r("<?exe s = [17, 23, 42]?><?exe r = randchoice(sequence=s)?><?if r in s?>ok<?else?>fail<?end if?>") 
     1413    assert "ok" == r("<?code r = randchoice('abc')?><?if r in 'abc'?>ok<?else?>fail<?end if?>") 
     1414    assert "ok" == r("<?code s = [17, 23, 42]?><?code r = randchoice(s)?><?if r in s?>ok<?else?>fail<?end if?>") 
     1415    assert "ok" == r("<?code s = #12345678?><?code sl = [0x12, 0x34, 0x56, 0x78]?><?code r = randchoice(s)?><?if r in sl?>ok<?else?>fail<?end if?>") 
     1416 
     1417    # Make sure that the parameters have the same name in all implementations 
     1418    assert "ok" == r("<?code s = [17, 23, 42]?><?code r = randchoice(sequence=s)?><?if r in s?>ok<?else?>fail<?end if?>") 
    14191419 
    14201420 
     
    28092809@pytest.mark.ul4 
    28102810def test_method_r_g_b_a(r): 
    2811     assert '0x11' == r('<?exe c = #123?><?print hex(c.r())?>') 
    2812     assert '0x22' == r('<?exe c = #123?><?print hex(c.g())?>') 
    2813     assert '0x33' == r('<?exe c = #123?><?print hex(c.b())?>') 
    2814     assert '0xff' == r('<?exe c = #123?><?print hex(c.a())?>') 
     2811    assert '0x11' == r('<?code c = #123?><?print hex(c.r())?>') 
     2812    assert '0x22' == r('<?code c = #123?><?print hex(c.g())?>') 
     2813    assert '0x33' == r('<?code c = #123?><?print hex(c.b())?>') 
     2814    assert '0xff' == r('<?code c = #123?><?print hex(c.a())?>') 
    28152815 
    28162816 
    28172817@pytest.mark.ul4 
    28182818def test_method_hls(r): 
    2819     assert '0' == r('<?exe c = #fff?><?print int(c.hls()[0])?>') 
    2820     assert '1' == r('<?exe c = #fff?><?print int(c.hls()[1])?>') 
    2821     assert '0' == r('<?exe c = #fff?><?print int(c.hls()[2])?>') 
     2819    assert '0' == r('<?code c = #fff?><?print int(c.hls()[0])?>') 
     2820    assert '1' == r('<?code c = #fff?><?print int(c.hls()[1])?>') 
     2821    assert '0' == r('<?code c = #fff?><?print int(c.hls()[2])?>') 
    28222822 
    28232823 
    28242824@pytest.mark.ul4 
    28252825def test_method_hlsa(r): 
    2826     assert '0' == r('<?exe c = #fff?><?print int(c.hlsa()[0])?>') 
    2827     assert '1' == r('<?exe c = #fff?><?print int(c.hlsa()[1])?>') 
    2828     assert '0' == r('<?exe c = #fff?><?print int(c.hlsa()[2])?>') 
    2829     assert '1' == r('<?exe c = #fff?><?print int(c.hlsa()[3])?>') 
     2826    assert '0' == r('<?code c = #fff?><?print int(c.hlsa()[0])?>') 
     2827    assert '1' == r('<?code c = #fff?><?print int(c.hlsa()[1])?>') 
     2828    assert '0' == r('<?code c = #fff?><?print int(c.hlsa()[2])?>') 
     2829    assert '1' == r('<?code c = #fff?><?print int(c.hlsa()[3])?>') 
    28302830 
    28312831 
    28322832@pytest.mark.ul4 
    28332833def test_method_hsv(r): 
    2834     assert '0' == r('<?exe c = #fff?><?print int(c.hsv()[0])?>') 
    2835     assert '0' == r('<?exe c = #fff?><?print int(c.hsv()[1])?>') 
    2836     assert '1' == r('<?exe c = #fff?><?print int(c.hsv()[2])?>') 
     2834    assert '0' == r('<?code c = #fff?><?print int(c.hsv()[0])?>') 
     2835    assert '0' == r('<?code c = #fff?><?print int(c.hsv()[1])?>') 
     2836    assert '1' == r('<?code c = #fff?><?print int(c.hsv()[2])?>') 
    28372837 
    28382838 
    28392839@pytest.mark.ul4 
    28402840def test_method_hsva(r): 
    2841     assert '0' == r('<?exe c = #fff?><?print int(c.hsva()[0])?>') 
    2842     assert '0' == r('<?exe c = #fff?><?print int(c.hsva()[1])?>') 
    2843     assert '1' == r('<?exe c = #fff?><?print int(c.hsva()[2])?>') 
    2844     assert '1' == r('<?exe c = #fff?><?print int(c.hsva()[3])?>') 
     2841    assert '0' == r('<?code c = #fff?><?print int(c.hsva()[0])?>') 
     2842    assert '0' == r('<?code c = #fff?><?print int(c.hsva()[1])?>') 
     2843    assert '1' == r('<?code c = #fff?><?print int(c.hsva()[2])?>') 
     2844    assert '1' == r('<?code c = #fff?><?print int(c.hsva()[3])?>') 
    28452845 
    28462846 
     
    30273027    t = ul4c.Template('<?print prefix?><?print data?><?print suffix?>') 
    30283028 
    3029     assert '(f)(o)(o)' == r('<?for c in data?><?exe t.render(data=c, prefix="(", suffix=")")?><?end for?>', t=t, data='foo') 
    3030     assert '(f)(o)(o)' == r('<?for c in data?><?exe t.render(data=c, **{"prefix": "(", "suffix": ")"})?><?end for?>', t=t, data='foo') 
     3029    assert '(f)(o)(o)' == r('<?for c in data?><?code t.render(data=c, prefix="(", suffix=")")?><?end for?>', t=t, data='foo') 
     3030    assert '(f)(o)(o)' == r('<?for c in data?><?code t.render(data=c, **{"prefix": "(", "suffix": ")"})?><?end for?>', t=t, data='foo') 
    30313031 
    30323032 
     
    30383038@pytest.mark.ul4 
    30393039def test_pass_function(r): 
    3040     assert "&lt;" == r("<?def x?><?print xe('<')?><?end def?><?exe x.render(xe=xmlescape)?>") 
    3041     assert "&lt;" == r("<?def xe?><?return xmlescape(s)?><?end def?><?def x?><?print xe(s='<')?><?end def?><?exe x.render(xe=xe)?>") 
    3042     assert "&lt;" == r("<?def xe?><?return xmlescape(s)?><?end def?><?def x?><?print xe(s='<')?><?end def?><?exe x.render()?>") 
     3040    assert "&lt;" == r("<?def x?><?print xe('<')?><?end def?><?code x.render(xe=xmlescape)?>") 
     3041    assert "&lt;" == r("<?def xe?><?return xmlescape(s)?><?end def?><?def x?><?print xe(s='<')?><?end def?><?code x.render(xe=xe)?>") 
     3042    assert "&lt;" == r("<?def xe?><?return xmlescape(s)?><?end def?><?def x?><?print xe(s='<')?><?end def?><?code x.render()?>") 
    30433043 
    30443044 
     
    30513051def test_nested_exceptions(r): 
    30523052    tmpl1 = ul4c.Template("<?print 2*x?>", "tmpl1") 
    3053     tmpl2 = ul4c.Template("<?exe tmpl1.render(x=x)?>", "tmpl2") 
    3054     tmpl3 = ul4c.Template("<?exe tmpl2.render(tmpl1=tmpl1, x=x)?>", "tmpl3") 
     3053    tmpl2 = ul4c.Template("<?code tmpl1.render(x=x)?>", "tmpl2") 
     3054    tmpl3 = ul4c.Template("<?code tmpl2.render(tmpl1=tmpl1, x=x)?>", "tmpl3") 
    30553055 
    30563056    with raises("unsupported operand type|not supported"): 
    3057         r("<?exe tmpl3.render(tmpl1=tmpl1, tmpl2=tmpl2, x=x)?>", tmpl1=tmpl1, tmpl2=tmpl2, tmpl3=tmpl3, x=None) 
     3057        r("<?code tmpl3.render(tmpl1=tmpl1, tmpl2=tmpl2, x=x)?>", tmpl1=tmpl1, tmpl2=tmpl2, tmpl3=tmpl3, x=None) 
    30583058 
    30593059 
     
    31043104            <?print i?>! 
    31053105        <?end def?> 
    3106         <?exe x.render()?> 
     3106        <?code x.render()?> 
    31073107    <?end for?> 
    31083108    """ 
     
    31123112    # so the following code will use ``i = 1`` instead of ``i = 2`` even if the subtemplate is called after the variable has been changed. 
    31133113    source = """ 
    3114     <?exe i = 1?> 
     3114    <?code i = 1?> 
    31153115    <?def x?> 
    31163116        <?print i?> 
    31173117    <?end def?> 
    3118     <?exe i = 2?> 
    3119     <?exe x.render()?> 
     3118    <?code i = 2?> 
     3119    <?code x.render()?> 
    31203120    """ 
    31213121    assert "1" == r(source, keepws=False) 
     
    31283128    <?def outer?> 
    31293129        <?def inner?> 
    3130             <?exe x += 1?> 
    3131             <?exe y += 1?> 
     3130            <?code x += 1?> 
     3131            <?code y += 1?> 
    31323132            <?print x?>! 
    31333133            <?print y?>! 
    31343134        <?end def?> 
    3135         <?exe x += 1?> 
    3136         <?exe y += 1?> 
    3137         <?exe inner.render(x=x)?> 
     3135        <?code x += 1?> 
     3136        <?code y += 1?> 
     3137        <?code inner.render(x=x)?> 
    31383138        <?print x?>! 
    31393139        <?print y?>! 
    31403140    <?end def?> 
    3141     <?exe x += 1?> 
    3142     <?exe y += 1?> 
    3143     <?exe outer.render(x=x)?> 
     3141    <?code x += 1?> 
     3142    <?code y += 1?> 
     3143    <?code outer.render(x=x)?> 
    31443144    <?print x?>! 
    31453145    <?print y?>! 
     
    31523152    return ul4c.Template(""" 
    31533153        text 
    3154         <?exe x = 'gurk'?> 
    3155         <?exe x = 42?> 
    3156         <?exe x = 4.2?> 
    3157         <?exe x = Undefined?> 
    3158         <?exe x = ReallyUndefined?> 
    3159         <?exe x = None?> 
    3160         <?exe x = False?> 
    3161         <?exe x = True?> 
    3162         <?exe x = @(2009-01-04)?> 
    3163         <?exe x = #0063a8?> 
    3164         <?exe x = [42]?> 
    3165         <?exe x = {"fortytwo": 42}?> 
    3166         <?exe x = {**{"fortytwo": 42}}?> 
    3167         <?exe x = [x for x in range(10) if i % 2]?> 
    3168         <?exe x = {x : x*x for x in range(10) if i % 2}?> 
    3169         <?exe x = (x for x in range(10) if i % 2)?> 
    3170         <?exe x = y?> 
    3171         <?exe x += 42?> 
    3172         <?exe x -= 42?> 
    3173         <?exe x *= 42?> 
    3174         <?exe x /= 42?> 
    3175         <?exe x //= 42?> 
    3176         <?exe x %= 42?> 
     3154        <?code x = 'gurk'?> 
     3155        <?code x = 42?> 
     3156        <?code x = 4.2?> 
     3157        <?code x = Undefined?> 
     3158        <?code x = ReallyUndefined?> 
     3159        <?code x = None?> 
     3160        <?code x = False?> 
     3161        <?code x = True?> 
     3162        <?code x = @(2009-01-04)?> 
     3163        <?code x = #0063a8?> 
     3164        <?code x = [42]?> 
     3165        <?code x = {"fortytwo": 42}?> 
     3166        <?code x = {**{"fortytwo": 42}}?> 
     3167        <?code x = [x for x in range(10) if i % 2]?> 
     3168        <?code x = {x : x*x for x in range(10) if i % 2}?> 
     3169        <?code x = (x for x in range(10) if i % 2)?> 
     3170        <?code x = y?> 
     3171        <?code x += 42?> 
     3172        <?code x -= 42?> 
     3173        <?code x *= 42?> 
     3174        <?code x /= 42?> 
     3175        <?code x //= 42?> 
     3176        <?code x %= 42?> 
    31773177        <?print x.gurk?> 
    31783178        <?print x["gurk"]?> 
     
    32123212        <?print x.find(1, 2, x=17, y=23, *args, **kwargs)?> 
    32133213        <?if x?>gurk<?elif y?>hurz<?else?>hinz<?end if?> 
    3214         <?exe x.render(a=1, b=2)?> 
     3214        <?code x.render(a=1, b=2)?> 
    32153215        <?def x?>foo<?end def?> 
    32163216        <?def x?><?return x?><?end def?> 
    3217         <?exe x.render()?> 
     3217        <?code x.render()?> 
    32183218    """) 
    32193219 
     
    32463246@pytest.mark.ul4 
    32473247def test_keepws_nested(r): 
    3248     s1 = "<?def nested1?>1n\n<?exe second.render()?><?end def?>1\n<?exe nested1.render(second=second)?>" 
    3249     s2 = "<?def nested2?>2n\n<?end def?>2\n<?exe nested2.render()?>" 
     3248    s1 = "<?def nested1?>1n\n<?code second.render()?><?end def?>1\n<?code nested1.render(second=second)?>" 
     3249    s2 = "<?def nested2?>2n\n<?end def?>2\n<?code nested2.render()?>" 
    32503250 
    32513251    assert "1\n1n\n22n" == r(s1, keepws=True, second=ul4c.Template(s2, keepws=False)) 
     
    32753275@pytest.mark.ul4 
    32763276def test_function_closure(c): 
    3277     assert 24 == c("<?exe y=3?><?def inner?><?return 2*x*y?><?end def?><?return inner(x=4)?>") 
    3278     assert 24 == c("<?def outer?><?exe y=3?><?def inner?><?return 2*x*y?><?end def?><?return inner?><?end def?><?return outer()(x=4)?>") 
     3277    assert 24 == c("<?code y=3?><?def inner?><?return 2*x*y?><?end def?><?return inner(x=4)?>") 
     3278    assert 24 == c("<?def outer?><?code y=3?><?def inner?><?return 2*x*y?><?end def?><?return inner?><?end def?><?return outer()(x=4)?>") 
    32793279 
    32803280