Package

Source Code of BugsTester

import jscover.util.IoUtils;
import org.mozilla.javascript.CompilerEnvirons;
import org.mozilla.javascript.Parser;
import org.mozilla.javascript.ast.AstRoot;

import java.io.IOException;
import java.io.StringReader;

public class BugsTester {
    private static IoUtils ioUtils = IoUtils.getInstance();
    public static void main(String[] args) throws IOException {
//        parseAndPrintSource("void window.open();");
//        parseAndPrintSource("debugger;");
//        parseAndPrintSource("if (true)\n  x++;");
        parseAndPrintSource(ioUtils.loadFromClassPath("/test.js"));
//        parseAndPrintSource("/^(\\w+)$/.exec(url);");
        //parseAndPrintSource("if (true)\n  ;\nx++;");
    }

    private static void parseAndPrintSource(String source) throws IOException {
        CompilerEnvirons compilerEnv = new CompilerEnvirons();
        compilerEnv.setLanguageVersion(180);
//        compilerEnv.setStrictMode(false);
        Parser parser = new Parser(compilerEnv);
        AstRoot astRoot = parser.parse(new StringReader(source), null, 1);
        System.out.println(astRoot.toSource());
    }
}
TOP

Related Classes of BugsTester

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.