Ejemplo n.º 1
0
def no_test_function_def():
    snippet = """
function f() { 
    return 0; 
}
"""
    res = parse(snippet)
    assert str(res) == snippet+"// x"
    
Ejemplo n.º 2
0
def main(argv):
    try:
        filename = argv[1]
        source = file(filename, "r").read()
    except:
        print "Usage: %s <source.js>" % argv[0]

    print str(js.parse(source, filename))

    return 0
Ejemplo n.º 3
0
def main(argv):
    try:
        testfiles = [argv[1]]
    except:
        testfiles = [os.path.join("source", x) for x in os.listdir("source")
                                               if x[-3:] == ".js"]

    for testfile in testfiles:
        try:
            sexp.convert(ecmatic.parse(file(testfile, 'r').read()))
        except Exception, e:
            print "Failure in converting %s to s-expressions\n%s" % (testfile,
                    e)
            return 1
        sys.stdout.write(".")
        sys.stdout.flush()
Ejemplo n.º 4
0
def test_blank():
    res = parse("")
    assert str(res) == ""