diff options
author | cushon <cushon@google.com> | 2018-10-23 13:45:50 -0700 |
---|---|---|
committer | Liam Miller-Cushon <cushon@google.com> | 2018-10-23 14:04:26 -0700 |
commit | 394540567b87ce2019d061532c92ec3ae210b3c8 (patch) | |
tree | a38a11406100c70ef9961bffb6686c7247b2f5c5 /javatests | |
parent | 7ef841275f620043690128b9aba1f9476609f449 (diff) | |
download | turbine-394540567b87ce2019d061532c92ec3ae210b3c8.tar.gz |
Use AutoValue for Type module objects
in order to get equals and hashCode implementations.
MOE_MIGRATED_REVID=218399705
Diffstat (limited to 'javatests')
5 files changed, 54 insertions, 44 deletions
diff --git a/javatests/com/google/turbine/binder/BinderErrorTest.java b/javatests/com/google/turbine/binder/BinderErrorTest.java index bd2bfb0..8d2dfce 100644 --- a/javatests/com/google/turbine/binder/BinderErrorTest.java +++ b/javatests/com/google/turbine/binder/BinderErrorTest.java @@ -501,7 +501,7 @@ public class BinderErrorTest { TURBINE_BOOTCLASSPATH, /* moduleVersion=*/ Optional.empty()) .units(); - fail(); + fail(Joiner.on('\n').join(source)); } catch (TurbineError e) { assertThat(e.getMessage()).isEqualTo(lines(expected)); } diff --git a/javatests/com/google/turbine/binder/ClassPathBinderTest.java b/javatests/com/google/turbine/binder/ClassPathBinderTest.java index c2122b6..95ef9c8 100644 --- a/javatests/com/google/turbine/binder/ClassPathBinderTest.java +++ b/javatests/com/google/turbine/binder/ClassPathBinderTest.java @@ -105,7 +105,7 @@ public class ClassPathBinderTest { c.interfaceTypes().stream() .filter(i -> i.sym().equals(new ClassSymbol("java/util/List"))) .collect(onlyElement()); - assertThat(getLast(listInterface.classes).targs()).hasSize(1); + assertThat(getLast(listInterface.classes()).targs()).hasSize(1); } @Test diff --git a/javatests/com/google/turbine/binder/bytecode/BytecodeBoundClassTest.java b/javatests/com/google/turbine/binder/bytecode/BytecodeBoundClassTest.java index 5529e30..ea0feb2 100644 --- a/javatests/com/google/turbine/binder/bytecode/BytecodeBoundClassTest.java +++ b/javatests/com/google/turbine/binder/bytecode/BytecodeBoundClassTest.java @@ -62,14 +62,14 @@ public class BytecodeBoundClassTest { assertThat(rawInterfaces.interfaceTypes()).hasSize(1); assertThat(rawInterfaces.interfaceTypes().get(0).sym()) .isEqualTo(new ClassSymbol("java/io/Serializable")); - assertThat(getLast(rawInterfaces.interfaceTypes().get(0).classes).targs()).isEmpty(); + assertThat(getLast(rawInterfaces.interfaceTypes().get(0).classes()).targs()).isEmpty(); assertThat(genericInterfaces.interfaceTypes()).hasSize(1); assertThat(genericInterfaces.interfaceTypes().get(0).sym()) .isEqualTo(new ClassSymbol("java/util/List")); - assertThat(getLast(genericInterfaces.interfaceTypes().get(0).classes).targs()).hasSize(1); + assertThat(getLast(genericInterfaces.interfaceTypes().get(0).classes()).targs()).hasSize(1); assertThat( - ((ClassTy) getLast(genericInterfaces.interfaceTypes().get(0).classes).targs().get(0)) + ((ClassTy) getLast(genericInterfaces.interfaceTypes().get(0).classes()).targs().get(0)) .sym()) .isEqualTo(new ClassSymbol("java/lang/String")); } diff --git a/javatests/com/google/turbine/lower/LowerSignatureTest.java b/javatests/com/google/turbine/lower/LowerSignatureTest.java index 59698e3..5ccbf01 100644 --- a/javatests/com/google/turbine/lower/LowerSignatureTest.java +++ b/javatests/com/google/turbine/lower/LowerSignatureTest.java @@ -25,6 +25,13 @@ import com.google.turbine.bytecode.sig.SigWriter; import com.google.turbine.model.TurbineConstantTypeKind; import com.google.turbine.type.Type; import com.google.turbine.type.Type.ArrayTy; +import com.google.turbine.type.Type.ClassTy; +import com.google.turbine.type.Type.ClassTy.SimpleClassTy; +import com.google.turbine.type.Type.PrimTy; +import com.google.turbine.type.Type.TyVar; +import com.google.turbine.type.Type.WildLowerBoundedTy; +import com.google.turbine.type.Type.WildUnboundedTy; +import com.google.turbine.type.Type.WildUpperBoundedTy; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -34,9 +41,9 @@ public class LowerSignatureTest { @Test public void simple() { Type.ClassTy type = - new Type.ClassTy( + ClassTy.create( ImmutableList.of( - new Type.ClassTy.SimpleClassTy( + SimpleClassTy.create( new ClassSymbol("java/util/List"), ImmutableList.of(), ImmutableList.of()))); assertThat(SigWriter.type(new LowerSignature().signature(type))).isEqualTo("Ljava/util/List;"); } @@ -47,13 +54,13 @@ public class LowerSignatureTest { SigWriter.type( new LowerSignature() .signature( - new Type.ClassTy( + ClassTy.create( ImmutableList.of( - new Type.ClassTy.SimpleClassTy( + SimpleClassTy.create( new ClassSymbol("test/Outer"), ImmutableList.of(), ImmutableList.of()), - new Type.ClassTy.SimpleClassTy( + SimpleClassTy.create( new ClassSymbol("test/Outer$Inner"), ImmutableList.of(), ImmutableList.of())))))) @@ -63,15 +70,15 @@ public class LowerSignatureTest { @Test public void genericEnclosing() { Type.ClassTy type = - new Type.ClassTy( + ClassTy.create( ImmutableList.of( - new Type.ClassTy.SimpleClassTy( + SimpleClassTy.create( new ClassSymbol("test/Outer"), - ImmutableList.of(Type.ClassTy.OBJECT), + ImmutableList.of(ClassTy.OBJECT), ImmutableList.of()), - new Type.ClassTy.SimpleClassTy( + SimpleClassTy.create( new ClassSymbol("test/Outer$Inner"), - ImmutableList.of(Type.ClassTy.OBJECT), + ImmutableList.of(ClassTy.OBJECT), ImmutableList.of()))); assertThat(SigWriter.type(new LowerSignature().signature(type))) .isEqualTo("Ltest/Outer<Ljava/lang/Object;>.Inner<Ljava/lang/Object;>;"); @@ -85,13 +92,13 @@ public class LowerSignatureTest { SigWriter.type( new LowerSignature() .signature( - new Type.ClassTy( + ClassTy.create( ImmutableList.of( - new Type.ClassTy.SimpleClassTy( + SimpleClassTy.create( new ClassSymbol("Outer"), ImmutableList.of(), ImmutableList.of()), - new Type.ClassTy.SimpleClassTy( + SimpleClassTy.create( new ClassSymbol("Outer$Inner"), ImmutableList.of(), ImmutableList.of())))))) @@ -104,16 +111,16 @@ public class LowerSignatureTest { SigWriter.type( new LowerSignature() .signature( - new Type.ClassTy( + ClassTy.create( ImmutableList.of( - new Type.ClassTy.SimpleClassTy( + SimpleClassTy.create( new ClassSymbol("test/Test"), ImmutableList.of( - new Type.WildUnboundedTy(ImmutableList.of()), - new Type.WildLowerBoundedTy( - Type.ClassTy.OBJECT, ImmutableList.of()), - new Type.WildUpperBoundedTy( - Type.ClassTy.OBJECT, ImmutableList.of())), + WildUnboundedTy.create(ImmutableList.of()), + WildLowerBoundedTy.create( + ClassTy.OBJECT, ImmutableList.of()), + WildUpperBoundedTy.create( + ClassTy.OBJECT, ImmutableList.of())), ImmutableList.of())))))) .isEqualTo("Ltest/Test<*-Ljava/lang/Object;+Ljava/lang/Object;>;"); } @@ -124,7 +131,7 @@ public class LowerSignatureTest { SigWriter.type( new LowerSignature() .signature( - new Type.TyVar( + TyVar.create( new TyVarSymbol(ClassSymbol.OBJECT, "X"), ImmutableList.of())))) .isEqualTo("TX;"); } @@ -134,8 +141,7 @@ public class LowerSignatureTest { assertThat( SigWriter.type( new LowerSignature() - .signature( - new Type.PrimTy(TurbineConstantTypeKind.BOOLEAN, ImmutableList.of())))) + .signature(PrimTy.create(TurbineConstantTypeKind.BOOLEAN, ImmutableList.of())))) .isEqualTo("Z"); } @@ -150,10 +156,10 @@ public class LowerSignatureTest { SigWriter.type( new LowerSignature() .signature( - new Type.ArrayTy( - new ArrayTy( - new ArrayTy( - new Type.PrimTy( + ArrayTy.create( + ArrayTy.create( + ArrayTy.create( + PrimTy.create( TurbineConstantTypeKind.BOOLEAN, ImmutableList.of()), ImmutableList.of()), ImmutableList.of()), diff --git a/javatests/com/google/turbine/lower/LowerTest.java b/javatests/com/google/turbine/lower/LowerTest.java index fed2743..4e6a38a 100644 --- a/javatests/com/google/turbine/lower/LowerTest.java +++ b/javatests/com/google/turbine/lower/LowerTest.java @@ -43,6 +43,10 @@ import com.google.turbine.model.TurbineTyKind; import com.google.turbine.parse.Parser; import com.google.turbine.testing.AsmUtils; import com.google.turbine.type.Type; +import com.google.turbine.type.Type.ClassTy; +import com.google.turbine.type.Type.ClassTy.SimpleClassTy; +import com.google.turbine.type.Type.PrimTy; +import com.google.turbine.type.Type.TyVar; import java.io.IOException; import java.io.OutputStream; import java.nio.file.Files; @@ -77,12 +81,12 @@ public class LowerTest { ImmutableList<Type.ClassTy> interfaceTypes = ImmutableList.of( - new Type.ClassTy( + ClassTy.create( ImmutableList.of( - new Type.ClassTy.SimpleClassTy( + SimpleClassTy.create( new ClassSymbol("java/util/List"), ImmutableList.of( - new Type.TyVar( + TyVar.create( new TyVarSymbol(new ClassSymbol("test/Test"), "V"), ImmutableList.of())), ImmutableList.of())))); @@ -91,9 +95,9 @@ public class LowerTest { ImmutableMap.of( new TyVarSymbol(new ClassSymbol("test/Test"), "V"), new SourceTypeBoundClass.TyVarInfo( - new Type.ClassTy( + ClassTy.create( ImmutableList.of( - new Type.ClassTy.SimpleClassTy( + SimpleClassTy.create( new ClassSymbol("test/Test$Inner"), ImmutableList.of(), ImmutableList.of()))), @@ -105,7 +109,7 @@ public class LowerTest { new SourceTypeBoundClass.MethodInfo( new MethodSymbol(new ClassSymbol("test/Test"), "f"), ImmutableMap.of(), - new Type.PrimTy(TurbineConstantTypeKind.INT, ImmutableList.of()), + PrimTy.create(TurbineConstantTypeKind.INT, ImmutableList.of()), ImmutableList.of(), ImmutableList.of(), TurbineFlag.ACC_STATIC | TurbineFlag.ACC_PUBLIC, @@ -120,18 +124,18 @@ public class LowerTest { new SourceTypeBoundClass.TyVarInfo( null, ImmutableList.of( - new Type.ClassTy( + ClassTy.create( ImmutableList.of( - new Type.ClassTy.SimpleClassTy( + SimpleClassTy.create( new ClassSymbol("java/lang/Runnable"), ImmutableList.of(), ImmutableList.of())))), ImmutableList.of()), new TyVarSymbol(new MethodSymbol(new ClassSymbol("test/Test"), "g"), "E"), new SourceTypeBoundClass.TyVarInfo( - new Type.ClassTy( + ClassTy.create( ImmutableList.of( - new Type.ClassTy.SimpleClassTy( + SimpleClassTy.create( new ClassSymbol("java/lang/Error"), ImmutableList.of(), ImmutableList.of()))), @@ -140,12 +144,12 @@ public class LowerTest { Type.VOID, ImmutableList.of( new SourceTypeBoundClass.ParamInfo( - new Type.PrimTy(TurbineConstantTypeKind.INT, ImmutableList.of()), + PrimTy.create(TurbineConstantTypeKind.INT, ImmutableList.of()), "foo", ImmutableList.of(), 0)), ImmutableList.of( - new Type.TyVar( + TyVar.create( new TyVarSymbol(new MethodSymbol(new ClassSymbol("test/Test"), "g"), "E"), ImmutableList.of())), TurbineFlag.ACC_PUBLIC, |