Skip to content

Commit 0987b71

Browse files
lauraharkercopybara-github
authored andcommitted
No public description
PiperOrigin-RevId: 717967765
1 parent d3fccfb commit 0987b71

File tree

1 file changed

+72
-32
lines changed

1 file changed

+72
-32
lines changed

test/com/google/javascript/jscomp/serialization/ColorSerializerTest.java

+72-32
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
import static com.google.common.collect.ImmutableSet.toImmutableSet;
2323
import static com.google.common.truth.Truth.assertThat;
2424
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
25+
import static java.util.Objects.requireNonNull;
2526

26-
import com.google.auto.value.AutoValue;
2727
import com.google.common.collect.HashMultimap;
2828
import com.google.common.collect.ImmutableList;
2929
import com.google.common.collect.ImmutableSet;
3030
import com.google.common.collect.SetMultimap;
3131
import com.google.common.truth.extensions.proto.ProtoSubject;
32+
import com.google.errorprone.annotations.InlineMe;
3233
import com.google.javascript.jscomp.colors.Color;
3334
import com.google.javascript.jscomp.colors.ColorId;
3435
import java.util.ArrayList;
@@ -480,14 +481,23 @@ public void avoidAddingDuplicateUnions() {
480481
/**
481482
* Represents a string that is stored in a StringPool, recording both its value and its offset.
482483
*/
483-
@AutoValue
484-
abstract static class PooledString {
485-
public abstract String getValue();
484+
record PooledString(String value, int poolOffset) {
485+
PooledString {
486+
requireNonNull(value, "value");
487+
}
488+
489+
@InlineMe(replacement = "this.value()")
490+
public String getValue() {
491+
return value();
492+
}
486493

487-
public abstract int getPoolOffset();
494+
@InlineMe(replacement = "this.poolOffset()")
495+
public int getPoolOffset() {
496+
return poolOffset();
497+
}
488498

489499
static PooledString create(String value, int poolOffset) {
490-
return new AutoValue_ColorSerializerTest_PooledString(value, poolOffset);
500+
return new PooledString(value, poolOffset);
491501
}
492502
}
493503

@@ -624,43 +634,68 @@ TestColor getAxiomaticTestColor(Color axiomaticColor) {
624634
return TestColor.create(axiomaticColor, null, poolOffset);
625635
}
626636

627-
/** Represents a Color that has been or will be added to the ColorSerializer. */
628-
@AutoValue
629-
abstract static class TestColor {
630-
// The Color that will be added to the ColorSerializer.
631-
public abstract Color getColor();
637+
/**
638+
* Represents a Color that has been or will be added to the ColorSerializer.
639+
*
640+
* @param nullableExpectedTypeProto The TypeProto we expect ColorSerializer to create for this
641+
* Color.
642+
* <p>For an axiomatic color this will return `null`, since those are never stored into a
643+
* `TypeProto`. Generally test code should call `getExpectedTypeProto()` instead in order to
644+
* get an exception if an attempt is made to serialize an axiomatic color.
645+
*/
646+
record TestColor(
647+
Color color, @Nullable TypeProto nullableExpectedTypeProto, int expectedTypePointer) {
648+
TestColor {
649+
requireNonNull(color, "color");
650+
}
632651

633-
/**
634-
* The TypeProto we expect ColorSerializer to create for this Color.
635-
*
636-
* <p>For an axiomatic color this will return `null`, since those are never stored into a
637-
* `TypeProto`. Generally test code should call `getExpectedTypeProto()` instead in order to get
638-
* an exception if an attempt is made to serialize an axiomatic color.
639-
*/
640-
public abstract @Nullable TypeProto getNullableExpectedTypeProto();
652+
@InlineMe(replacement = "this.color()")
653+
public Color getColor() {
654+
return color();
655+
}
656+
657+
@InlineMe(replacement = "this.nullableExpectedTypeProto()")
658+
public @Nullable TypeProto getNullableExpectedTypeProto() {
659+
return nullableExpectedTypeProto();
660+
}
661+
662+
@InlineMe(replacement = "this.expectedTypePointer()")
663+
public int getExpectedTypePointer() {
664+
return expectedTypePointer();
665+
}
666+
667+
// The Color that will be added to the ColorSerializer.
641668

642669
// The Integer we expect ColorSerializer to create for this Color.
643-
public abstract int getExpectedTypePointer();
644670

645671
public TypeProto getExpectedTypeProto() {
646672
return checkNotNull(getNullableExpectedTypeProto());
647673
}
648674

649675
static TestColor create(
650676
Color color, @Nullable TypeProto expectedTypeProto, int nullableExpectedTypePointer) {
651-
return new AutoValue_ColorSerializerTest_TestColor(
652-
color, expectedTypeProto, nullableExpectedTypePointer);
677+
return new TestColor(color, expectedTypeProto, nullableExpectedTypePointer);
653678
}
654679
}
655680

656681
/**
657682
* Represents a color/type mismatch both as it would appear in a ColorRegistry and in a TypePool.
658683
*/
659-
@AutoValue
660-
abstract static class TestMismatch {
661-
public abstract String getLocationString();
684+
record TestMismatch(String locationString, ImmutableList<TestColor> testColors) {
685+
TestMismatch {
686+
requireNonNull(locationString, "locationString");
687+
requireNonNull(testColors, "testColors");
688+
}
662689

663-
public abstract ImmutableList<TestColor> getTestColors();
690+
@InlineMe(replacement = "this.locationString()")
691+
public String getLocationString() {
692+
return locationString();
693+
}
694+
695+
@InlineMe(replacement = "this.testColors()")
696+
public ImmutableList<TestColor> getTestColors() {
697+
return testColors();
698+
}
664699

665700
public List<Color> getColors() {
666701
return getTestColors().stream().map(TestColor::getColor).collect(Collectors.toList());
@@ -683,8 +718,7 @@ public TypePool.DebugInfo.Mismatch getExpectedMismatch() {
683718
* order
684719
*/
685720
static TestMismatch create(String locationString, TestColor... testColors) {
686-
return new AutoValue_ColorSerializerTest_TestMismatch(
687-
locationString, ImmutableList.copyOf(testColors));
721+
return new TestMismatch(locationString, ImmutableList.copyOf(testColors));
688722
}
689723
}
690724

@@ -787,16 +821,22 @@ GenerateTypePoolTestResult generateTypePool() {
787821
}
788822

789823
/** The result of Tester::generateTypePool() */
790-
@AutoValue
791-
abstract static class GenerateTypePoolTestResult {
792-
public abstract TypePool getTypePool();
824+
record GenerateTypePoolTestResult(TypePool typePool) {
825+
GenerateTypePoolTestResult {
826+
requireNonNull(typePool, "typePool");
827+
}
828+
829+
@InlineMe(replacement = "this.typePool()")
830+
public TypePool getTypePool() {
831+
return typePool();
832+
}
793833

794834
ProtoSubject assertThatTypePool() {
795835
return assertThat(getTypePool());
796836
}
797837

798838
static GenerateTypePoolTestResult create(TypePool typePool) {
799-
return new AutoValue_ColorSerializerTest_GenerateTypePoolTestResult(typePool);
839+
return new GenerateTypePoolTestResult(typePool);
800840
}
801841
}
802842
}

0 commit comments

Comments
 (0)