From d8b542c68d8e2a8daa2c3f7122f3337d38b94469 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 26 May 2023 16:26:17 +0300 Subject: [PATCH] [Test] Allow testcases with number 0 in spec test There was a hidden bug which was uncovered by KT-58936 --- .../org/jetbrains/kotlin/spec/utils/parsers/Patterns.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/parsers/Patterns.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/parsers/Patterns.kt index dd9f0e9d31b..87151b59f49 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/parsers/Patterns.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/parsers/Patterns.kt @@ -93,7 +93,8 @@ object LinkedSpecTestPatterns : BasePatterns { object TestCasePatterns { private const val TEST_CASE_CODE_REGEX = """(?<%s>[\s\S]*?)""" - private val testCaseInfoElementsRegex = """(?<%s>%s${SpecTestCaseInfoElementType.TESTCASE_NUMBER.name.withSpaces()}:%s*?\n)""" + // Lazy is needed to prevent cycle initialization dependency between this object and SpecTestCaseInfoElementType + private val testCaseInfoElementsRegex by lazy { """(?<%s>%s${SpecTestCaseInfoElementType.TESTCASE_NUMBER.name.withSpaces()}:%s*?\n)""" } private val testCaseInfoRegex = """$TEST_CASE_CODE_REGEX(?<%s>(?:$directiveRegex)|$)""" private val testCaseInfoSingleLineRegex = SINGLE_LINE_COMMENT_REGEX.format( @@ -105,5 +106,5 @@ object TestCasePatterns { ) + testCaseInfoRegex.format("codeML", "nextDirectiveML") val testCaseInfoPattern: Pattern = Pattern.compile("(?:$testCaseInfoSingleLineRegex)|(?:$testCaseInfoMultilineRegex)") - val testCaseNumberPattern: Pattern = Pattern.compile("""([1-9]\d*)(,\s*[1-9]\d*)*""") -} \ No newline at end of file + val testCaseNumberPattern: Pattern = Pattern.compile("""([0-9]\d*)(,\s*[1-9]\d*)*""") +}