test/com/google/javascript/jscomp/IntegrationTestCase.java
/**
   * Asserts that when compiling with the given compiler options,
   * there is an error or warning.
   */
Asserts that when compiling with the given compiler options,
there is an error or warning.
Asserts that when compiling with the given compiler options there is an error or warning .
protected void test(CompilerOptions options,
      String[] original, String[] compiled, DiagnosticType warning) {
    Compiler compiler = compile(options, original);
    checkUnexpectedErrorsOrWarnings(compiler, 1);
    assertWithMessage("Expected exactly one warning or error")
        .that(compiler.getErrors().length + compiler.getWarnings().length)
        .isEqualTo(1);
    if (compiler.getErrors().length > 0) {
      assertError(compiler.getErrors()[0]).hasType(warning);
    } else {
      assertError(compiler.getWarnings()[0]).hasType(warning);
    }
    if (compiled != null) {
      Node root = compiler.getRoot().getLastChild();
      Node expectedRoot = parseExpectedCode(compiled, options, normalizeResults);
      String explanation = expectedRoot.checkTreeEquals(root);
      assertWithMessage(
              "\nExpected: "
                  + compiler.toSource(expectedRoot)
                  + "\nResult: "
                  + compiler.toSource(root)
                  + "\n"
                  + explanation)
          .that(explanation)
          .isNull();
    }
  }
protected void test ( CompilerOptions options , String [ ] original , String [ ] compiled , DiagnosticType warning ) { Compiler compiler = compile ( options , original ) ; checkUnexpectedErrorsOrWarnings ( compiler , 1 ) ; assertWithMessage ( "Expected exactly one warning or error" ) . that ( compiler . getErrors ( ) . length + compiler . getWarnings ( ) . length ) . isEqualTo ( 1 ) ; if ( compiler . getErrors ( ) . length > 0 ) { assertError ( compiler . getErrors ( ) [ 0 ] ) . hasType ( warning ) ; } else { assertError ( compiler . getWarnings ( ) [ 0 ] ) . hasType ( warning ) ; } if ( compiled != null ) { Node root = compiler . getRoot ( ) . getLastChild ( ) ; Node expectedRoot = parseExpectedCode ( compiled , options , normalizeResults ) ; String explanation = expectedRoot . checkTreeEquals ( root ) ; assertWithMessage ( "\nExpected: " + compiler . toSource ( expectedRoot ) + "\nResult: " + compiler . toSource ( root ) + "\n" + explanation ) . that ( explanation ) . isNull ( ) ; } }
Asserts that when compiling with the given compiler options,
 there is an error or warning.
Asserts that when compiling with the given compiler options there is an error or warning .