示例#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))
示例#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))
示例#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"], []),
    )
示例#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"))]),
    )