def no_test_function_def(): snippet = """ function f() { return 0; } """ res = parse(snippet) assert str(res) == snippet+"// x"
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
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()
def test_blank(): res = parse("") assert str(res) == ""