コード例 #1
0
def test_basic():
    # Basic math operations
    assert jseval("1 + 1") == "2"
    assert jseval("1.45 * 1") == "1.45"
    assert jseval("-5 / 5") == "-1"

    compiler.compile(file = "tests/scripts/jsfile.py")
コード例 #2
0
def jseval(text, bare = True):
    jscode = compiler.compile(text, bare = bare)
    result = subprocess.check_output(["node", "--eval", jscode, "--print"])
    return result.decode("utf-8").strip()