Beispiel #1
0
def test_functickformatter_from_coffeescript_with_args():
    coffee_code = "return slider.get('value') + tick"
    js_code = "\n  return slider.get('value') + tick;\n"

    slider = Slider()
    formatter = FuncTickFormatter.from_coffeescript(code=coffee_code, args={"slider": slider})

    function_wrapper = formatter.code.replace(js_code, "")
    assert function_wrapper == "var formatter;\n\nformatter = function() {};\n\nreturn formatter()"
    assert formatter.args == {"slider": slider}
Beispiel #2
0
def test_functickformatter_from_coffeescript_with_args():
    coffee_code = dedent("""
         return slider.get("value") // 2 + tick
         """)

    slider = Slider()
    formatter = FuncTickFormatter.from_coffeescript(code=coffee_code, args={"slider": slider})

    assert formatter.code == dedent("""\
        return Math.floor(slider.get("value") / 2) + tick;
        """)
    assert formatter.args == {"slider": slider}
def test_functickformatter_from_coffeescript_with_args():
    coffee_code = dedent("""
         return slider.get("value") // 2 + tick
         """)

    slider = Slider()
    formatter = FuncTickFormatter.from_coffeescript(code=coffee_code,
                                                    args={"slider": slider})

    assert formatter.code == dedent("""\
        return Math.floor(slider.get("value") / 2) + tick;
        """)
    assert formatter.args == {"slider": slider}
Beispiel #4
0
def test_functickformatter_from_coffeescript_no_arg():
    coffee_code = """
    square = (x) -> x * x
    return square(tick)
    """

    js_code = "\n  var square;\n  square = function(x) {\n    return x * x;\n  };\n  return square(tick);\n"

    formatter = FuncTickFormatter.from_coffeescript(code=coffee_code)
    function_wrapper = formatter.code.replace(js_code, "")

    assert function_wrapper == "var formatter;\n\nformatter = function() {};\n\nreturn formatter()"
    assert formatter.args == {}
Beispiel #5
0
def test_functickformatter_from_coffeescript_with_args():
    coffee_code = dedent("""
         return slider.get("value") // 2 + tick
         """)

    slider = Slider()
    formatter = FuncTickFormatter.from_coffeescript(code=coffee_code, args={"slider": slider})

    assert formatter.code == dedent("""\
        "use strict";
        Object.defineProperty(exports, "__esModule", { value: true });
        return Math.floor(slider.get("value") / 2) + tick;
        """)
    assert formatter.args == {"slider": slider}
def test_functickformatter_from_coffeescript_no_arg():
    coffee_code = dedent("""
        square = (x) -> x * x
        return square(tick)
        """)

    formatter = FuncTickFormatter.from_coffeescript(code=coffee_code)

    assert formatter.code == dedent("""\
        var square;
        square = function (x) {
            return x * x;
        };
        return square(tick);
        """)
    assert formatter.args == {}
Beispiel #7
0
def test_functickformatter_from_coffeescript_no_arg():
    coffee_code = dedent("""
        square = (x) -> x * x
        return square(tick)
        """)

    formatter = FuncTickFormatter.from_coffeescript(code=coffee_code)

    assert formatter.code == dedent("""\
        var square;
        square = function (x) {
            return x * x;
        };
        return square(tick);
        """)
    assert formatter.args == {}
Beispiel #8
0
def test_functickformatter_from_coffeescript_no_arg():
    coffee_code = """\
square = (x) -> x * x
return square(tick)
"""

    formatter = FuncTickFormatter.from_coffeescript(code=coffee_code)

    assert formatter.code == """\
"use strict";
var square;
square = function (x) {
    return x * x;
};
return square(tick);
"""
    assert formatter.args == {}
Beispiel #9
0
def test_functickformatter_from_coffeescript_no_arg():
    coffee_code = dedent("""
        square = (x) -> x * x
        return square(tick)
        """)

    formatter = FuncTickFormatter.from_coffeescript(code=coffee_code)

    assert formatter.code == dedent("""\
        "use strict";
        Object.defineProperty(exports, "__esModule", { value: true });
        var square;
        square = function (x) {
            return x * x;
        };
        return square(tick);
        """)
    assert formatter.args == {}