def test_if(): with xsc.build(): with xsc.Frag() as e: with defblock(func="gurk(arg)"): +detox.if_("arg>2") +detox.expr("str(2*arg)") +detox.else_() +detox.expr("str(3*arg)") +detox.end("if") assert makeoutput(e, "gurk", 0) == "0" assert makeoutput(e, "gurk", 1) == "3" assert makeoutput(e, "gurk", 2) == "6" assert makeoutput(e, "gurk", 3) == "6" assert makeoutput(e, "gurk", 4) == "8"
def test_if(): with xsc.build(): with xsc.Frag() as e: with defblock(func="gurk(arg)"): +detox.if_("arg>2") +detox.expr("str(2*arg)") +detox.else_() +detox.expr("str(3*arg)") +detox.end("if") assert makeoutput(e, "gurk", 0) == "0" assert makeoutput(e, "gurk", 1) == "3" assert makeoutput(e, "gurk", 2) == "6" assert makeoutput(e, "gurk", 3) == "6" assert makeoutput(e, "gurk", 4) == "8"
def test_expr(): with xsc.build(): with xsc.Frag() as e: with defblock(func="gurk(arg)"): +detox.expr("arg") assert makeoutput(e, "gurk", "hurz") == "hurz"
def test_expr(): with xsc.build(): with xsc.Frag() as e: with defblock(func="gurk(arg)"): +detox.expr("arg") assert makeoutput(e, "gurk", "hurz") == "hurz"
def test_for(): with xsc.build(): with xsc.Frag() as e: with defblock(func="gurk(arg)"): with forblock(loop="i in range(arg)"): +detox.expr("str(i)") assert makeoutput(e, "gurk", 3) == "012"
def test_for(): with xsc.build(): with xsc.Frag() as e: with defblock(func="gurk(arg)"): with forblock(loop="i in range(arg)"): +detox.expr("str(i)") assert makeoutput(e, "gurk", 3) == "012"
def test_while(): with xsc.build(): with xsc.Frag() as e: with defblock(func="gurk(arg)"): +detox.code("i = 0") with whileblock(loop="i < arg"): +detox.expr("str(i)") +detox.code("i += 1") assert makeoutput(e, "gurk", 3) == "012"
def test_while(): with xsc.build(): with xsc.Frag() as e: with defblock(func="gurk(arg)"): +detox.code("i = 0") with whileblock(loop="i < arg"): +detox.expr("str(i)") +detox.code("i += 1") assert makeoutput(e, "gurk", 3) == "012"