예제 #1
0
def test_serialize_call_with_one_arg():
    assert_equal("f(x)", _dumps(js.call(js.ref("f"), [js.ref("x")])))
예제 #2
0
def test_serialize_call_with_multiple_args():
    assert_equal("f(x, y)", _dumps(js.call(js.ref("f"), [js.ref("x"), js.ref("y")])))
예제 #3
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))
예제 #4
0
def test_serialize_call_with_no_args():
    assert_equal("f()", _dumps(js.call(js.ref("f"), [])))
예제 #5
0
def test_transform_reference_to_module_in_same_package():
    _assert_transform(
        cc.module_ref([".", "x"]),
        js.call(js.ref("$require"), [js.string("./x")]),
    )
예제 #6
0
def test_transform_reference_to_parent_package():
    _assert_transform(
        cc.module_ref([".."]),
        js.call(js.ref("$require"), [js.string("../")]),
    )
예제 #7
0
def test_transform_attribute_access():
    _assert_transform(
        cc.attr(cc.ref("x"), "y"),
        js.call(js.ref("$nope.builtins.getattr"), [js.ref("x"), js.string("y")])
    )
예제 #8
0
def test_transform_call_with_positional_arguments():
    _assert_transform(
        cc.call(cc.ref("f"), [cc.ref("x"), cc.ref("y")]),
        js.call(js.ref("f"), [js.ref("x"), js.ref("y")]),
    )
예제 #9
0
def test_transform_reference_to_top_level_module():
    _assert_transform(
        cc.module_ref("x"),
        js.call(js.ref("$require"), [js.string("x")]),
    )