public void test_entryPoint_none() throws Exception {
   Source source =
       addNamedSource(
           "/one.dart",
           createSource( //
               "library one;"));
   LibraryElement library = resolve(source);
   assertNotNull(library);
   assertNull(library.getEntryPoint());
   assertNoErrors(source);
   verify(source);
 }
 public void test_entryPoint_local() throws Exception {
   Source source =
       addNamedSource(
           "/one.dart",
           createSource( //
               "library one;", "main() {}"));
   LibraryElement library = resolve(source);
   assertNotNull(library);
   FunctionElement main = library.getEntryPoint();
   assertNotNull(main);
   assertSame(library, main.getLibrary());
   assertNoErrors(source);
   verify(source);
 }
Exemplo n.º 3
0
  public void test_empty() throws Exception {
    Source librarySource = addSource("/lib.dart", "library lib;");

    LibraryElement element = buildLibrary(librarySource);
    assertNotNull(element);
    assertEquals("lib", element.getName());
    assertNull(element.getEntryPoint());
    assertLength(0, element.getImportedLibraries());
    assertLength(0, element.getImports());
    assertNull(element.getLibrary());
    assertLength(0, element.getPrefixes());
    assertLength(0, element.getParts());

    CompilationUnitElement unit = element.getDefiningCompilationUnit();
    assertNotNull(unit);
    assertEquals("lib.dart", unit.getName());
    assertEquals(element, unit.getLibrary());
    assertLength(0, unit.getAccessors());
    assertLength(0, unit.getFields());
    assertLength(0, unit.getFunctions());
    assertLength(0, unit.getTypeAliases());
    assertLength(0, unit.getTypes());
  }