Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #299 from square/jwilson_0705_imports_bug
Browse files Browse the repository at this point in the history
Test conflicting simple names in the same file.
  • Loading branch information
JakeWharton committed Jul 5, 2015
2 parents b099108 + 12ffaab commit dfa195e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/test/java/com/squareup/javapoet/JavaFileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.Date;
import javax.lang.model.element.Modifier;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down Expand Up @@ -116,6 +117,43 @@ public final class JavaFileTest {
+ "}\n");
}

@Ignore("https://github.com/square/javapoet/issues/298")
@Test public void conflictingSimpleNames() throws Exception {
String source = JavaFile.builder("com.squareup.tacos",
TypeSpec.classBuilder("A")
.addType(TypeSpec.classBuilder("B")
.addType(TypeSpec.classBuilder("Twin").build())
.addType(TypeSpec.classBuilder("C")
.addField(ClassName.get("com.squareup.tacos", "A", "Twin", "D"), "d")
.build())
.build())
.addType(TypeSpec.classBuilder("Twin")
.addType(TypeSpec.classBuilder("D")
.build())
.build())
.build())
.build()
.toString();
assertThat(source).isEqualTo(""
+ "package com.squareup.tacos;\n"
+ "\n"
+ "class A {\n"
+ " class B {\n"
+ " class Twin {\n"
+ " }\n"
+ "\n"
+ " class C {\n"
+ " A.Twin.D d;\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " class Twin {\n"
+ " class D {\n"
+ " }\n"
+ " }\n"
+ "}\n");
}

@Test public void defaultPackage() throws Exception {
String source = JavaFile.builder("",
TypeSpec.classBuilder("HelloWorld")
Expand Down

0 comments on commit dfa195e

Please sign in to comment.