com.google.javascript.rhino.testing
Class TestErrorReporter

java.lang.Object
  extended by junit.framework.Assert
      extended by com.google.javascript.rhino.testing.TestErrorReporter
All Implemented Interfaces:
ErrorReporter

public final class TestErrorReporter
extends junit.framework.Assert
implements ErrorReporter

An error reporter for testing that verifies that messages reported to the reporter are expected.

Sample use

 TestErrorReporter e =
   new TestErrorReporter(null, new String[] { "first warning" });
 ...
 assertTrue(e.hasEncounteredAllWarnings());
 


Constructor Summary
TestErrorReporter(String[] errors, String[] warnings)
           
 
Method Summary
 void error(String message, String sourceName, int line, int lineOffset)
          Report an error.
static TestErrorReporter forNoExpectedReports()
           
 boolean hasEncounteredAllErrors()
          Returns whether all errors were reported to this reporter.
 boolean hasEncounteredAllWarnings()
          Returns whether all warnings were reported to this reporter.
 void setErrors(String[] errors)
           
 void setWarnings(String[] warnings)
           
 void warning(String message, String sourceName, int line, int lineOffset)
          Report a warning.
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestErrorReporter

public TestErrorReporter(String[] errors,
                         String[] warnings)
Method Detail

forNoExpectedReports

public static TestErrorReporter forNoExpectedReports()

setErrors

public void setErrors(String[] errors)

setWarnings

public void setWarnings(String[] warnings)

error

public void error(String message,
                  String sourceName,
                  int line,
                  int lineOffset)
Description copied from interface: ErrorReporter
Report an error. The implementing class is free to throw an exception if it desires. If execution has not yet begun, the JavaScript engine is free to find additional errors rather than terminating the translation. It will not execute a script that had errors, however.

Specified by:
error in interface ErrorReporter
Parameters:
message - a String describing the error
sourceName - a String describing the JavaScript source where the error occured; typically a filename or URL
line - the line number associated with the error
lineOffset - the offset into lineSource where problem was detected

warning

public void warning(String message,
                    String sourceName,
                    int line,
                    int lineOffset)
Description copied from interface: ErrorReporter
Report a warning. The implementing class may choose to ignore the warning if it desires.

Specified by:
warning in interface ErrorReporter
Parameters:
message - a String describing the warning
sourceName - a String describing the JavaScript source where the warning occured; typically a filename or URL
line - the line number associated with the warning
lineOffset - the offset into lineSource where problem was detected

hasEncounteredAllWarnings

public boolean hasEncounteredAllWarnings()
Returns whether all warnings were reported to this reporter.


hasEncounteredAllErrors

public boolean hasEncounteredAllErrors()
Returns whether all errors were reported to this reporter.