def test_serialize_function_declaration(): func = js.function_declaration( name="f", args=["x", "y"], body = [ js.expression_statement(js.ref("y")), js.expression_statement(js.ref("x")), ], ) assert_equal("function f(x, y) { y;x; }", _dumps(func))
def test_transform_function_declaration(): _assert_transform( cc.func( name="f", args=[cc.arg("x"), cc.arg("y")], body=[cc.ret(cc.ref("x"))], ), js.function_declaration( name="f", args=["x", "y"], body=[js.ret(js.ref("x"))], ) )
def body_of_function_declaration_is_indented(self): node = js.function_declaration("f", [], [js.ret(js.ref("x"))]) assert_equal("function f() {\n return x;\n}\n", self._dumps(node))