mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-25 21:03:15 -04:00
Finishing off #6133 - autoreplace cycles through deprecation replacements until it reaches a non-deprecated text
This is guaranteed to not cycle endlessly thanks to the added test Checked by having 2 uniques' deprecation text reference each other and it failed as expected
This commit is contained in:
parent
c498426715
commit
3bbfb0100c
@ -372,7 +372,12 @@ class OptionsPopup(val previousScreen: BaseScreen) : Popup(previousScreen) {
|
||||
allDeprecatedUniques.add(deprecatedUnique.text)
|
||||
|
||||
// note that this replacement does not contain conditionals attached to the original!
|
||||
|
||||
|
||||
var uniqueReplacementText = deprecatedUnique.getReplacementText()
|
||||
while (Unique(uniqueReplacementText).getDeprecationAnnotation() != null)
|
||||
uniqueReplacementText = Unique(uniqueReplacementText).getReplacementText()
|
||||
|
||||
for (conditional in deprecatedUnique.conditionals)
|
||||
uniqueReplacementText += " <${conditional.text}>"
|
||||
val replacementUnique = Unique(uniqueReplacementText)
|
||||
|
@ -144,6 +144,19 @@ class BasicTests {
|
||||
allOK = false
|
||||
}
|
||||
}
|
||||
|
||||
var iteration = 1
|
||||
var replacementUnique = Unique(uniqueType.placeholderText)
|
||||
while (replacementUnique.getDeprecationAnnotation() != null) {
|
||||
if (iteration == 10) {
|
||||
allOK = false
|
||||
println("${uniqueType.name}'s deprecation text never references an undeprecated unique!")
|
||||
break
|
||||
}
|
||||
iteration++
|
||||
replacementUnique = Unique(replacementUnique.getReplacementText())
|
||||
}
|
||||
|
||||
}
|
||||
Assert.assertTrue("This test succeeds only if all deprecated uniques have a replaceWith text that matches an existing type", allOK)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user