@@ -22,16 +22,22 @@ object StrValueProvider : ValueProvider<Type, PythonFuzzedValue, PythonMethodDes
2222 return type.pythonTypeName() == pythonStrClassId.canonicalName
2323 }
2424
25- private fun getStrConstants (concreteValues : Collection <PythonFuzzedConcreteValue >): List <String > {
25+ private fun getConstants (concreteValues : Collection <PythonFuzzedConcreteValue >): List <String > {
2626 return concreteValues
2727 .filter { accept(it.type) }
28- .map {
29- val value = it.value as String
30- value.transformRawString()
31- }
32- .map {
33- it.transformQuotationMarks()
34- }
28+ .map { it.value as String }
29+ }
30+
31+ private fun getStrConstants (concreteValues : Collection <PythonFuzzedConcreteValue >): List <String > {
32+ return getConstants(concreteValues)
33+ .filterNot { it.isPattern() }
34+ .map { it.transformQuotationMarks() }
35+ }
36+
37+ private fun getRegexConstants (concreteValues : Collection <PythonFuzzedConcreteValue >): List <String > {
38+ return getConstants(concreteValues)
39+ .filter { it.isPattern() }
40+ .map { it.transformRawString().transformQuotationMarks() }
3541 }
3642
3743 override fun generate (description : PythonMethodDescription , type : Type ) = sequence {
@@ -42,13 +48,10 @@ object StrValueProvider : ValueProvider<Type, PythonFuzzedValue, PythonMethodDes
4248 )
4349 strConstants.forEach { yieldStrings(StringValue (it)) { value } }
4450
45- strConstants
46- .filter {
47- it.isPattern()
48- }
49- .forEach {
50- yieldStrings(RegexValue (it, description.random), StringValue ::value)
51- }
51+ val regexConstants = getRegexConstants(description.concreteValues)
52+ regexConstants.forEach {
53+ yieldStrings(RegexValue (it, description.random), StringValue ::value)
54+ }
5255 }
5356
5457 private suspend fun <T : KnownValue <T >> SequenceScope <Seed <Type , PythonFuzzedValue >>.yieldStrings (value : T , block : T .() -> Any ) {
0 commit comments