Package com.google.errorprone

Examples of com.google.errorprone.CompilationTestHelper


  protected void writeFile(String fileName, String... lines) {
    filesToCompile.add(new FileToCompile(fileName, lines));
  }

  protected void assertCompiles(Scanner scanner) {
    final CompilationTestHelper compilationHelper = CompilationTestHelper.newInstance(scanner);
    List<JavaFileObject> fileObjects =
        Lists.transform(filesToCompile, new Function<FileToCompile, JavaFileObject>() {
          @Override
          public JavaFileObject apply(FileToCompile file) {
            return compilationHelper.fileManager().forSourceLines(file.name, file.lines);
          }
        });
    compilationHelper.assertCompileSucceeds(fileObjects);
  }
View Full Code Here


  }

  @Test
  public void testFlags() throws Exception {
    SelfEquals checker;
    CompilationTestHelper compilationHelper;
    // Both checks off.
    try {
      new SelfEquals(false, false);
      fail();
    } catch (IllegalArgumentException e) {
      // Expected to get an exception.
    }

    // Both checks on.
    checker = new SelfEquals(true, true);
    compilationHelper = CompilationTestHelper.newInstance(checker);
    compilationHelper.assertCompileFailsWithMessages(positiveCase1);
    compilationHelper = CompilationTestHelper.newInstance(checker);
    compilationHelper.assertCompileFailsWithMessages(positiveCase2);

    // Guava on, Eauals off.
    checker = new SelfEquals(true, false);
    compilationHelper = CompilationTestHelper.newInstance(checker);
    compilationHelper.assertCompileFailsWithMessages(positiveCase1);
    compilationHelper = CompilationTestHelper.newInstance(checker);
    compilationHelper.assertCompileSucceeds(positiveCase2);

    // Equals on, Guava off.
    checker = new SelfEquals(false, true);
    compilationHelper = CompilationTestHelper.newInstance(checker);
    compilationHelper.assertCompileSucceeds(positiveCase1);
    compilationHelper = CompilationTestHelper.newInstance(checker);
    compilationHelper.assertCompileFailsWithMessages(positiveCase2);
  }
View Full Code Here

TOP

Related Classes of com.google.errorprone.CompilationTestHelper

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.