Exemplo n.º 1
0
def test_serialize_function_expression():
    func = js.function_expression(
        args=["x", "y"],
        body = [
            js.expression_statement(js.ref("y")),
            js.expression_statement(js.ref("x")),
        ],
    )
    assert_equal("function(x, y) { y;x; }", _dumps(func))
Exemplo n.º 2
0
 def closing_brace_of_function_expression_is_on_same_line_as_closing_paren_of_call(self):
     node = js.call(
         js.ref("f"),
         [js.function_expression([], [js.ret(js.ref("x"))])]
     )
     assert_equal("f(function() {\n    return x;\n})", self._dumps(node))
Exemplo n.º 3
0
def test_transform_function_expression_with_arguments():
    _assert_transform(
        cc.function_expression([cc.arg("x"), cc.arg("y")], []),
        js.function_expression(["x", "y"], []),
    )
Exemplo n.º 4
0
def test_transform_function_expression_with_body():
    _assert_transform(
        cc.function_expression([], [cc.ret(cc.ref("x"))]),
        js.function_expression([], [js.ret(js.ref("x"))]),
    )