예제 #1
0
def test_serialize_if_else():
    if_else = js.if_(
        js.ref("x"),
        [js.ret(js.ref("y"))],
        [js.ret(js.ref("z"))],
    )
    assert_equal("if (x) { return y; } else { return z; }", _dumps(if_else))
예제 #2
0
 def bodies_of_if_else_are_indented(self):
     node = js.if_(
         js.ref("condition"),
         [js.expression_statement(js.ref("y"))],
         [js.expression_statement(js.ref("x"))]
     )
     assert_equal("if (condition) {\n    y;\n} else {\n    x;\n}\n", self._dumps(node))
예제 #3
0
def test_transform_if_else():
    _assert_transform(
        cc.if_(
            cc.ref("x"),
            [cc.ret(cc.ref("y"))],
            [cc.ret(cc.ref("z"))],
        ),
        js.if_(
            js.ref("x"),
            [js.ret(js.ref("y"))],
            [js.ret(js.ref("z"))],
        )
    )