Package org.mozilla.javascript.testing

Examples of org.mozilla.javascript.testing.TestErrorReporter


        boolean jsdoc) {
        CompilerEnvirons environment = new CompilerEnvirons();
        environment.setAllowKeywordAsObjectPropertyName(
            allowKeywordsAsObjectLiteralsKeys);

        TestErrorReporter testErrorReporter =
            new TestErrorReporter(errors, warnings) {
          @Override
          public EvaluatorException runtimeError(
               String message, String sourceName, int line, String lineSource,
               int lineOffset) {
             if (errors == null) {
               throw new UnsupportedOperationException();
             }
             return new EvaluatorException(
               message, sourceName, line, lineSource, lineOffset);
           }
        };
        environment.setErrorReporter(testErrorReporter);

        environment.setRecordingComments(true);
        environment.setRecordingLocalJsDocComments(jsdoc);

        Parser p = new Parser(environment, testErrorReporter);
        AstRoot script = null;
        try {
          script = p.parse(string, null, 0);
        } catch (EvaluatorException e) {
          if (errors == null) {
            // EvaluationExceptions should not occur when we aren't expecting
            // errors.
            throw e;
          }
        }

        assertTrue(testErrorReporter.hasEncounteredAllErrors());
        assertTrue(testErrorReporter.hasEncounteredAllWarnings());

        return script;
    }
View Full Code Here


    }

    private AstRoot parseAsReader(String string) throws IOException {
        CompilerEnvirons environment = new CompilerEnvirons();

        TestErrorReporter testErrorReporter = new TestErrorReporter(null, null);
        environment.setErrorReporter(testErrorReporter);

        environment.setRecordingComments(true);
        environment.setRecordingLocalJsDocComments(true);

        Parser p = new Parser(environment, testErrorReporter);
        AstRoot script = p.parse(new StringReader(string), null, 0);

        assertTrue(testErrorReporter.hasEncounteredAllErrors());
        assertTrue(testErrorReporter.hasEncounteredAllWarnings());

        return script;
    }
View Full Code Here

    }

    private AstRoot parse(String string, boolean jsdoc) {
        CompilerEnvirons environment = new CompilerEnvirons();

        TestErrorReporter testErrorReporter = new TestErrorReporter(null, null);
        environment.setErrorReporter(testErrorReporter);

        environment.setRecordingComments(true);
        environment.setRecordingLocalJsDocComments(jsdoc);

        Parser p = new Parser(environment, testErrorReporter);
        AstRoot script = p.parse(string, null, 0);

        assertTrue(testErrorReporter.hasEncounteredAllErrors());
        assertTrue(testErrorReporter.hasEncounteredAllWarnings());

        return script;
    }
View Full Code Here

    }

    private AstRoot parseAsReader(String string) throws IOException {
        CompilerEnvirons environment = new CompilerEnvirons();

        TestErrorReporter testErrorReporter = new TestErrorReporter(null, null);
        environment.setErrorReporter(testErrorReporter);

        environment.setRecordingComments(true);
        environment.setRecordingLocalJsDocComments(true);

        Parser p = new Parser(environment, testErrorReporter);
        AstRoot script = p.parse(new StringReader(string), null, 0);

        assertTrue(testErrorReporter.hasEncounteredAllErrors());
        assertTrue(testErrorReporter.hasEncounteredAllWarnings());

        return script;
    }
View Full Code Here

    }

    private AstRoot parse(
        String string, final String [] errors, final String [] warnings,
        boolean jsdoc) {
        TestErrorReporter testErrorReporter =
            new TestErrorReporter(errors, warnings) {
          @Override
          public EvaluatorException runtimeError(
               String message, String sourceName, int line, String lineSource,
               int lineOffset) {
             if (errors == null) {
               throw new UnsupportedOperationException();
             }
             return new EvaluatorException(
               message, sourceName, line, lineSource, lineOffset);
           }
        };
        environment.setErrorReporter(testErrorReporter);

        environment.setRecordingComments(true);
        environment.setRecordingLocalJsDocComments(jsdoc);

        Parser p = new Parser(environment, testErrorReporter);
        AstRoot script = null;
        try {
          script = p.parse(string, null, 0);
        } catch (EvaluatorException e) {
          if (errors == null) {
            // EvaluationExceptions should not occur when we aren't expecting
            // errors.
            throw e;
          }
        }

        assertTrue(testErrorReporter.hasEncounteredAllErrors());
        assertTrue(testErrorReporter.hasEncounteredAllWarnings());

        return script;
    }
View Full Code Here

        return script;
    }

    private AstRoot parseAsReader(String string) throws IOException {
        TestErrorReporter testErrorReporter = new TestErrorReporter(null, null);
        environment.setErrorReporter(testErrorReporter);

        environment.setRecordingComments(true);
        environment.setRecordingLocalJsDocComments(true);

        Parser p = new Parser(environment, testErrorReporter);
        AstRoot script = p.parse(new StringReader(string), null, 0);

        assertTrue(testErrorReporter.hasEncounteredAllErrors());
        assertTrue(testErrorReporter.hasEncounteredAllWarnings());

        return script;
    }
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.testing.TestErrorReporter

Copyright © 2018 www.massapicom. 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.