Class EquivalentAtmComboScannerVisitedTest
EquivalentAtmComboScanner.Visited, the recursion guard of
EqualityAtmComparer (and so of AnnotatedTypeMirror.equals(java.lang.Object)) and of the poly collector.
Visited is an open-addressing table keyed on the identity of both types of a pair. The
checker test suites exercise it only through type comparisons, which rarely record more than a
few pairs, so these tests target its boundaries directly: identity (not equality) of the keys,
colliding pairs and probes that wrap around the end of the table, growth across every threshold
with every pair and result preserved, replacing a pair's result (including a null result, which
contains distinguishes from an absent pair), and clearing a table of the initial size (in
place) and a grown one (dropped). The last test compares the table against the nested IdentityHashMaps it replaced over a seeded sequence of operations.
Collisions are made deterministic without assuming anything about identity hash codes: a test
creates fresh first types until EquivalentAtmComboScanner.Visited.slotFor(java.lang.Object[], java.lang.Object, java.lang.Object) maps a pair to
the wanted home entry of an empty table of the relevant capacity, and then inspects the table to
confirm where the entry landed. The home entry depends on the first type only, so pairs that
share a first type collide by construction, which one test covers directly.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdding a pair again replaces its result, and a null result is distinguished from an absent pair bycontains.voidOver a seeded sequence of adds, lookups and clears on a small pool of types, the table answers every query exactly as the nested identity maps did, after every operation.voidClearing a grown table drops it, and the next add allocates a table of the initial size.voidClearing a table of the initial size nulls it in place, and the table is reused.voidColliding pairs probe forward to the next empty entries and are found there.static voidRuns a checker on a trivial class so that its type factory can create annotated types.voidThe table doubles exactly when the next pair would make it more than two thirds full, and every pair and result survives each growth.voidPairs are keyed on the identity of both types, in order, not on their equality.voidPairs that share a first type have the same home entry and form one probe run.voidA probe that reaches the end of the table continues at its first entry.voidEquivalentAtmComboScanner.visit(org.checkerframework.framework.type.AnnotatedTypeMirror, org.checkerframework.framework.type.AnnotatedTypeMirror, PARAM)starts every scan with an empty history.
-
Constructor Details
-
EquivalentAtmComboScannerVisitedTest
public EquivalentAtmComboScannerVisitedTest()
-
-
Method Details
-
createFactory
Runs a checker on a trivial class so that its type factory can create annotated types.AnnotatedTypeMirror.createType(javax.lang.model.type.TypeMirror, org.checkerframework.framework.type.AnnotatedTypeFactory, boolean)needs a factory; which checker provides it is irrelevant to these tests, which use the types only as identity keys.- Throws:
Exception- if the compiler task cannot be created
-
keysAreIdentityPairs
public void keysAreIdentityPairs()Pairs are keyed on the identity of both types, in order, not on their equality. -
collidingPairsProbeForward
public void collidingPairsProbeForward()Colliding pairs probe forward to the next empty entries and are found there. -
probeWrapsAroundTheEndOfTheTable
public void probeWrapsAroundTheEndOfTheTable()A probe that reaches the end of the table continues at its first entry. -
growthPreservesEveryPairAndResult
public void growthPreservesEveryPairAndResult()The table doubles exactly when the next pair would make it more than two thirds full, and every pair and result survives each growth. -
addReplacesTheResult
public void addReplacesTheResult()Adding a pair again replaces its result, and a null result is distinguished from an absent pair bycontains. -
clearReusesTheInitialTable
public void clearReusesTheInitialTable()Clearing a table of the initial size nulls it in place, and the table is reused. -
clearDropsAGrownTable
public void clearDropsAGrownTable()Clearing a grown table drops it, and the next add allocates a table of the initial size. -
visitClearsTheHistory
public void visitClearsTheHistory()EquivalentAtmComboScanner.visit(org.checkerframework.framework.type.AnnotatedTypeMirror, org.checkerframework.framework.type.AnnotatedTypeMirror, PARAM)starts every scan with an empty history. -
agreesWithNestedIdentityMaps
public void agreesWithNestedIdentityMaps()Over a seeded sequence of adds, lookups and clears on a small pool of types, the table answers every query exactly as the nested identity maps did, after every operation.
-