/**
  * Verifies that the compiler pass's JS output is the same as its input and (optionally) that an
  * expected warning is issued.
  *
  * @param externs Externs input
  * @param js Input and output
  * @param diag Expected error or warning, or null if none is expected
  * @param error true if diag is an error, false if it is a warning
  */
 public void testSame(String externs, String js, DiagnosticType diag, boolean error) {
   if (error) {
     test(externs, js, js, diag, null);
   } else {
     test(externs, js, js, null, diag);
   }
 }
 /**
  * Verifies that the compiler pass's JS output is the same as its input and (optionally) that an
  * expected warning and description is issued.
  *
  * @param externs Externs input
  * @param js Input and output
  * @param warning Expected warning, or null if no warning is expected
  * @param description The description of the expected warning, or null if no warning is expected
  *     or if the warning's description should not be examined
  */
 public void testSame(
     String externs, String js, DiagnosticType type, String description, boolean error) {
   List<SourceFile> externsInputs = ImmutableList.of(SourceFile.fromCode("externs", externs));
   if (error) {
     test(externsInputs, js, js, type, null, description);
   } else {
     test(externsInputs, js, js, null, type, description);
   }
 }
 /**
  * Verifies that the compiler pass's JS output matches the expected output and (optionally) that
  * an expected warning is issued. Or, if an error is expected, this method just verifies that the
  * error is encountered.
  *
  * @param js Inputs
  * @param expected Expected JS output
  * @param error Expected error, or null if no error is expected
  * @param warning Expected warning, or null if no warning is expected
  */
 public void test(
     List<SourceFile> js,
     List<SourceFile> expected,
     DiagnosticType error,
     DiagnosticType warning) {
   test(js, expected, error, warning, null);
 }
 /**
  * Verifies that the compiler pass's JS output matches the expected output and (optionally) that
  * an expected warning is issued. Or, if an error is expected, this method just verified that the
  * error is encountered.
  *
  * @param compiler A compiler that has been initialized via {@link Compiler#init}
  * @param expected Expected output, or null if an error is expected
  * @param error Expected error, or null if no error is expected
  * @param warning Expected warning, or null if no warning is expected
  */
 private void test(
     Compiler compiler,
     String[] expected,
     DiagnosticType error,
     DiagnosticType warning,
     String description) {
   if (expected == null) {
     test(compiler, (List<SourceFile>) null, error, warning, description);
   } else {
     List<SourceFile> inputs = Lists.newArrayList();
     for (int i = 0; i < expected.length; i++) {
       inputs.add(SourceFile.fromCode("expected" + i, expected[i]));
     }
     test(compiler, inputs, error, warning, description);
   }
 }
  /**
   * Verifies that the compiler pass's JS output matches the expected output and (optionally) that
   * an expected warning is issued. Or, if an error is expected, this method just verifies that the
   * error is encountered.
   *
   * @param modules Module inputs
   * @param expected Expected JS outputs (one per module)
   * @param error Expected error, or null if no error is expected
   * @param warning Expected warning, or null if no warning is expected
   */
  public void test(
      JSModule[] modules, String[] expected, DiagnosticType error, DiagnosticType warning) {
    Compiler compiler = createCompiler();
    lastCompiler = compiler;

    compiler.initModules(externsInputs, Lists.newArrayList(modules), getOptions());
    test(compiler, expected, error, warning);
  }
 /**
  * Verifies that the compiler pass's JS output matches the expected output, or that an expected
  * error is encountered.
  *
  * @param js Input
  * @param expected Expected output, or null if an error is expected
  * @param error Expected error, or null if no error is expected
  * @param warning Expected warning, or null if no warning is expected
  * @param description The content of the error expected
  */
 public void test(
     String js,
     String expected,
     DiagnosticType error,
     DiagnosticType warning,
     String description) {
   test(externsInputs, js, expected, error, warning, description);
 }
 /**
  * Verifies that the compiler pass's JS output matches the expected output and (optionally) that
  * an expected warning is issued. Or, if an error is expected, this method just verifies that the
  * error is encountered.
  *
  * @param externs Externs input
  * @param js Input
  * @param expected Expected output, or null if an error is expected
  * @param error Expected error, or null if no error is expected
  * @param warning Expected warning, or null if no warning is expected
  * @param description The description of the expected warning, or null if no warning is expected
  *     or if the warning's description should not be examined
  */
 public void test(
     String externs,
     String js,
     String expected,
     DiagnosticType error,
     DiagnosticType warning,
     String description) {
   SourceFile externsFile = SourceFile.fromCode("externs", externs);
   externsFile.setIsExtern(true);
   List<SourceFile> externsInputs = ImmutableList.of(externsFile);
   test(externsInputs, js, expected, error, warning, description);
 }
  /**
   * Verifies that the compiler pass's JS output matches the expected output and (optionall) that an
   * expected warning is issued. Or, if an error is expected, this method just verifies that the
   * error is encountered.
   *
   * @param inputs Inputs
   * @param expected Expected JS output
   * @param error Expected error, or null if no error is expected
   * @param description The description of the expected warning, or null if no warning is expected
   *     or if the warning's description should no be examined
   */
  public void test(
      List<SourceFile> inputs,
      String[] expected,
      DiagnosticType error,
      DiagnosticType warning,
      String description) {
    Compiler compiler = createCompiler();
    lastCompiler = compiler;

    compiler.init(externsInputs, inputs, getOptions());
    test(compiler, expected, error, warning, description);
  }
 /**
  * Verifies that the compiler pass's JS output matches the expected output and (optionally) that
  * an expected warning is issued. Or, if an error is expected, this method just verifies that the
  * error is encountered.
  *
  * @param js Inputs
  * @param expected Expected JS output
  * @param error Expected error, or null if no error is expected
  * @param warning Expected warning, or null if no warning is expected
  * @param description The description of the expected warning, or null if no warning is expected
  *     or if the warning's description should not be examined
  */
 public void test(
     String[] js,
     String[] expected,
     DiagnosticType error,
     DiagnosticType warning,
     String description) {
   List<SourceFile> inputs = Lists.newArrayList();
   for (int i = 0; i < js.length; i++) {
     inputs.add(SourceFile.fromCode("input" + i, js[i]));
   }
   test(inputs, expected, error, warning, description);
 }
Exemplo n.º 10
0
 /**
  * Verifies that the compiler pass's JS output is the same as the input.
  *
  * @param modules Module inputs
  * @param warning A warning, or null for no expected warning.
  */
 public void testSame(JSModule[] modules, DiagnosticType warning) {
   try {
     String[] expected = new String[modules.length];
     for (int i = 0; i < modules.length; i++) {
       expected[i] = "";
       for (CompilerInput input : modules[i].getInputs()) {
         expected[i] += input.getSourceFile().getCode();
       }
     }
     test(modules, expected, null, warning);
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }
Exemplo n.º 11
0
 /**
  * Verifies that the compiler pass's JS output matches the expected output and (optionally) that
  * an expected warning is issued. Or, if an error is expected, this method just verifies that the
  * error is encountered.
  *
  * @param externs Externs inputs
  * @param js Input
  * @param expected Expected output, or null if an error is expected
  * @param error Expected error, or null if no error is expected
  * @param warning Expected warning, or null if no warning is expected
  * @param description The description of the expected warning, or null if no warning is expected
  *     or if the warning's description should not be examined
  */
 public void test(
     List<SourceFile> externs,
     String js,
     String expected,
     DiagnosticType error,
     DiagnosticType warning,
     String description) {
   test(
       externs,
       ImmutableList.of(SourceFile.fromCode(filename, js)),
       expected,
       error,
       warning,
       description);
 }
Exemplo n.º 12
0
  /**
   * Verifies that the compiler pass's JS output matches the expected output and (optionally) that
   * an expected warning is issued. Or, if an error is expected, this method just verifies that the
   * error is encountered.
   *
   * @param externs Externs inputs
   * @param js Inputs
   * @param expected Expected output, or null if an error is expected
   * @param error Expected error, or null if no error is expected
   * @param warning Expected warning, or null if no warning is expected
   * @param description The description of the expected warning, or null if no warning is expected
   *     or if the warning's description should not be examined
   */
  private void test(
      List<SourceFile> externs,
      List<SourceFile> js,
      String expected,
      DiagnosticType error,
      DiagnosticType warning,
      String description) {
    Compiler compiler = createCompiler();
    lastCompiler = compiler;

    CompilerOptions options = getOptions();

    options.setLanguageIn(acceptedLanguage);
    // Note that in this context, turning on the checkTypes option won't
    // actually cause the type check to run.
    options.checkTypes = parseTypeInfo;
    compiler.init(externs, js, options);

    BaseJSTypeTestCase.addNativeProperties(compiler.getTypeRegistry());

    test(compiler, maybeCreateArray(expected), error, warning, description);
  }
Exemplo n.º 13
0
 /**
  * Verifies that the compiler pass's JS output is the same as its input, and emits the given error
  * and warning.
  *
  * @param js Inputs and outputs
  * @param error Expected error, or null if no error is expected
  * @param warning Expected warning, or null if no warning is expected
  */
 public void testSame(String[] js, DiagnosticType error, DiagnosticType warning) {
   test(js, js, error, warning);
 }
Exemplo n.º 14
0
 /**
  * Verifies that the compiler pass's JS output is the same as its input, and emits the given
  * error.
  *
  * @param js Inputs and outputs
  * @param error Expected error, or null if no error is expected
  */
 public void testSame(String[] js, DiagnosticType error) {
   test(js, js, error);
 }
Exemplo n.º 15
0
 /**
  * Verifies that the compiler pass's JS output is the same as its input.
  *
  * @param js Inputs and outputs
  */
 public void testSame(List<SourceFile> js) {
   test(js, js);
 }
Exemplo n.º 16
0
 /**
  * Verifies that the compiler pass's JS output is the same as its input.
  *
  * @param js Inputs and outputs
  */
 public void testSame(String[] js) {
   test(js, js);
 }
Exemplo n.º 17
0
 /**
  * Verifies that the compiler pass's JS output matches the expected output and (optionally) that
  * an expected warning is issued. Or, if an error is expected, this method just verifies that the
  * error is encountered.
  *
  * @param externs Externs input
  * @param js Input
  * @param expected Expected output, or null if an error is expected
  * @param error Expected error, or null if no error is expected
  * @param warning Expected warning, or null if no warning is expected
  */
 public void test(
     String externs, String js, String expected, DiagnosticType error, DiagnosticType warning) {
   test(externs, js, expected, error, warning, null);
 }
Exemplo n.º 18
0
 /**
  * Verifies that the compiler pass's JS output is the same as its input and (optionally) that an
  * expected warning is issued.
  *
  * @param js Input and output
  * @param warning Expected warning, or null if no warning is expected
  */
 public void testSame(String js, DiagnosticType warning) {
   test(js, js, null, warning);
 }
Exemplo n.º 19
0
 /**
  * Verifies that the compiler pass's JS output matches the expected output, or that an expected
  * error is encountered.
  *
  * @param modules Module inputs
  * @param expected Expected JS outputs (one per module)
  * @param error Expected error, or null if no error is expected
  */
 public void test(JSModule[] modules, String[] expected, DiagnosticType error) {
   test(modules, expected, error, null);
 }
Exemplo n.º 20
0
 /**
  * Verifies that the compiler pass's JS output matches the expected output, or that an expected
  * error is encountered.
  *
  * @param js Input
  * @param expected Expected output, or null if an error is expected
  * @param error Expected error, or null if no error is expected
  */
 public void test(String js, String expected, DiagnosticType error) {
   test(js, expected, error, null);
 }
Exemplo n.º 21
0
 /**
  * Verifies that the compiler pass's JS output matches the expected output and (optionally) that
  * an expected warning is issued. Or, if an error is expected, this method just verifies that the
  * error is encountered.
  *
  * @param compiler A compiler that has been initialized via {@link Compiler#init}
  * @param expected Expected output, or null if an error is expected
  * @param error Expected error, or null if no error is expected
  * @param warning Expected warning, or null if no warning is expected
  */
 protected void test(
     Compiler compiler, String[] expected, DiagnosticType error, DiagnosticType warning) {
   test(compiler, expected, error, warning, null);
 }
Exemplo n.º 22
0
 /**
  * Verifies that the compiler pass's JS output matches the expected output.
  *
  * @param js Inputs
  * @param expected Expected JS output
  */
 public void test(String[] js, String[] expected) {
   test(js, expected, null);
 }
Exemplo n.º 23
0
 /**
  * Verifies that the compiler pass's JS output matches the expected output and (optionally) that
  * an expected warning is issued. Or, if an error is expected, this method just verifies that the
  * error is encountered.
  *
  * @param js Inputs
  * @param expected Expected JS output
  * @param error Expected error, or null if no error is expected
  * @param warning Expected warning, or null if no warning is expected
  */
 public void test(String[] js, String[] expected, DiagnosticType error, DiagnosticType warning) {
   test(js, expected, error, warning, null);
 }
Exemplo n.º 24
0
 /**
  * Verifies that the compiler pass's JS output matches the expected output.
  *
  * @param js Inputs
  * @param expected Expected JS output
  */
 public void test(List<SourceFile> js, List<SourceFile> expected) {
   test(js, expected, null);
 }
Exemplo n.º 25
0
 /**
  * Verifies that the compiler pass's JS output matches the expected output.
  *
  * @param modules Module inputs
  * @param expected Expected JS outputs (one per module)
  */
 public void test(JSModule[] modules, String[] expected) {
   test(modules, expected, null);
 }
 /**
  * Verifies that the compiler pass's JS output is the same as its input and (optionally) that an
  * expected warning and description is issued.
  *
  * @param externs Externs input
  * @param js Input and output
  * @param warning Expected warning, or null if no warning is expected
  * @param description The description of the expected warning, or null if no warning is expected
  *     or if the warning's description should not be examined
  */
 public void testSame(String externs, String js, DiagnosticType warning, String description) {
   List<SourceFile> externsInputs = ImmutableList.of(SourceFile.fromCode("externs", externs));
   test(externsInputs, js, js, null, warning, description);
 }