code.append(" public static void onModuleLoad() {}\n");
code.append("}\n");
// Compiles EntryPoint to JS.
compileSnippet(code.toString());
TextOutput text = new DefaultTextOutput(true);
JsSourceGenerationVisitor jsSourceGenerationVisitor = new JsSourceGenerationVisitor(text);
jsSourceGenerationVisitor.accept(jsProgram);
// Verifies that the EntryPoint class, SomeInterface interface and some other classes were
// delimited in the output by getClassRanges().
List<NamedRange> classRanges = jsSourceGenerationVisitor.getClassRanges();
Map<String, NamedRange> classRangesByName = Maps.newHashMap();
for (NamedRange classRange : classRanges) {
classRangesByName.put(classRange.getName(), classRange);
}
assertTrue(classRangesByName.containsKey("test.EntryPoint"));
assertTrue(classRangesByName.containsKey("test.EntryPoint$SomeInterface"));
assertTrue(classRangesByName.size() > 2);
NamedRange programClassRange = jsSourceGenerationVisitor.getProgramClassRange();
// Verifies there is a preamble before the program class range.
assertTrue(programClassRange.getStartPosition() > 0);
// Verifies there is an epilogue after the program class range.
assertTrue(programClassRange.getEndPosition() < text.getPosition());
}