mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 10:54:19 -04:00
Added countables test that autocomplete values actually return valid countables
This commit is contained in:
parent
30270f2014
commit
a644875139
@ -38,6 +38,7 @@ enum class Countables(
|
||||
override val documentationHeader = "Integer constant - any positive or negative integer number"
|
||||
override fun matches(parameterText: String) = parameterText.toIntOrNull() != null
|
||||
override fun eval(parameterText: String, stateForConditionals: StateForConditionals) = parameterText.toIntOrNull()
|
||||
override fun getKnownValuesForAutocomplete(ruleset: Ruleset): Set<String> = setOf()
|
||||
override val example: String = "123"
|
||||
},
|
||||
|
||||
@ -130,6 +131,7 @@ enum class Countables(
|
||||
UniqueParameterType.PolicyFilter.getTranslatedErrorSeverity(parameterText, ruleset)
|
||||
override fun getKnownValuesForAutocomplete(ruleset: Ruleset): Set<String> =
|
||||
UniqueParameterType.PolicyFilter.getKnownValuesForAutocomplete(ruleset)
|
||||
.map { text.fillPlaceholders(it) }.toSet()
|
||||
},
|
||||
|
||||
RemainingCivs("Remaining [civFilter] Civilizations") {
|
||||
|
@ -3,6 +3,7 @@ package com.unciv.uniques
|
||||
import com.unciv.logic.city.City
|
||||
import com.unciv.logic.civilization.Civilization
|
||||
import com.unciv.models.ruleset.Ruleset
|
||||
import com.unciv.models.ruleset.RulesetCache
|
||||
import com.unciv.models.ruleset.unique.Countables
|
||||
import com.unciv.models.ruleset.unique.StateForConditionals
|
||||
import com.unciv.models.ruleset.unique.Unique
|
||||
@ -75,6 +76,24 @@ class CountableTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testAllCountableAutocompleteValuesMatch() {
|
||||
RulesetCache.loadRulesets(noMods = true)
|
||||
val ruleset = RulesetCache.getVanillaRuleset()
|
||||
for (countable in Countables.entries) {
|
||||
val knownValues = countable.getKnownValuesForAutocomplete(ruleset)
|
||||
for (value in knownValues) {
|
||||
val matchedCountable = Countables.getMatching(value, ruleset)
|
||||
assertEquals(
|
||||
"Countable ${countable.name} should match its own autocomplete value: $value",
|
||||
countable, matchedCountable
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPlaceholderParams(){
|
||||
val text = "when number of [Iron] is equal to [3 * 2 + [Iron] + [bob]]"
|
||||
|
Loading…
x
Reference in New Issue
Block a user