From 5536f4da07ba3dad6d5c43e1f82882241553e6cc Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 24 Apr 2014 16:21:06 +0400 Subject: [PATCH] Test data generated from both files separated in 717f03f474 --- .../tests/GenerateRangesCodegenTestData.java | 59 ++++++++++--------- .../test/language/RangeIterationTestJVM.kt | 1 + 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateRangesCodegenTestData.java b/generators/src/org/jetbrains/jet/generators/tests/GenerateRangesCodegenTestData.java index 23da8a76b4d..6bd37c5ce1a 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/GenerateRangesCodegenTestData.java +++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateRangesCodegenTestData.java @@ -35,7 +35,10 @@ public class GenerateRangesCodegenTestData { private static final File TEST_DATA_DIR = new File("compiler/testData/codegen/boxWithStdlib/ranges"); private static final File AS_LITERAL_DIR = new File(TEST_DATA_DIR, "literal"); private static final File AS_EXPRESSION_DIR = new File(TEST_DATA_DIR, "expression"); - private static final File SOURCE_TEST_FILE = new File("libraries/stdlib/test/language/RangeIterationTest.kt"); + private static final File[] SOURCE_TEST_FILES = { + new File("libraries/stdlib/test/language/RangeIterationTest.kt"), + new File("libraries/stdlib/test/language/RangeIterationTestJVM.kt") + }; private static final Pattern TEST_FUN_PATTERN = Pattern.compile("test fun (\\w+)\\(\\) \\{.+?}", Pattern.DOTALL); private static final Pattern SUBTEST_INVOCATION_PATTERN = Pattern.compile("doTest\\(([^,]+), [^,]+, [^,]+, [^,]+,\\s+listOf[\\w<>]*\\(([^\\n]*)\\)\\)", Pattern.DOTALL); @@ -144,33 +147,35 @@ public class GenerateRangesCodegenTestData { //noinspection ResultOfMethodCallIgnored AS_EXPRESSION_DIR.mkdirs(); - String sourceContent = FileUtil.loadFile(SOURCE_TEST_FILE); - Matcher testFunMatcher = TEST_FUN_PATTERN.matcher(sourceContent); - while (testFunMatcher.find()) { - String testFunName = testFunMatcher.group(1); - if (testFunName.equals("emptyConstant")) { - continue; + for (File file : SOURCE_TEST_FILES) { + String sourceContent = FileUtil.loadFile(file); + Matcher testFunMatcher = TEST_FUN_PATTERN.matcher(sourceContent); + while (testFunMatcher.find()) { + String testFunName = testFunMatcher.group(1); + if (testFunName.equals("emptyConstant")) { + continue; + } + + String testFunText = testFunMatcher.group(); + + StringBuilder asLiteralBody = new StringBuilder(); + StringBuilder asExpressionBody = new StringBuilder(); + int index = 0; + + Matcher matcher = SUBTEST_INVOCATION_PATTERN.matcher(testFunText); + while (matcher.find()) { + index++; + String rangeExpression = matcher.group(1); + String expectedListElements = matcher.group(2); + String elementType = detectElementType(rangeExpression); + asLiteralBody.append(renderTemplate(LITERAL_TEMPLATE, index, elementType, rangeExpression, expectedListElements)); + asExpressionBody.append(renderTemplate(EXPRESSION_TEMPLATE, index, elementType, rangeExpression, expectedListElements)); + } + + String fileName = testFunName + ".kt"; + writeToFile(new File(AS_LITERAL_DIR, fileName), asLiteralBody.toString()); + writeToFile(new File(AS_EXPRESSION_DIR, fileName), asExpressionBody.toString()); } - - String testFunText = testFunMatcher.group(); - - StringBuilder asLiteralBody = new StringBuilder(); - StringBuilder asExpressionBody = new StringBuilder(); - int index = 0; - - Matcher matcher = SUBTEST_INVOCATION_PATTERN.matcher(testFunText); - while (matcher.find()) { - index++; - String rangeExpression = matcher.group(1); - String expectedListElements = matcher.group(2); - String elementType = detectElementType(rangeExpression); - asLiteralBody.append(renderTemplate(LITERAL_TEMPLATE, index, elementType, rangeExpression, expectedListElements)); - asExpressionBody.append(renderTemplate(EXPRESSION_TEMPLATE, index, elementType, rangeExpression, expectedListElements)); - } - - String fileName = testFunName + ".kt"; - writeToFile(new File(AS_LITERAL_DIR, fileName), asLiteralBody.toString()); - writeToFile(new File(AS_EXPRESSION_DIR, fileName), asExpressionBody.toString()); } } diff --git a/libraries/stdlib/test/language/RangeIterationTestJVM.kt b/libraries/stdlib/test/language/RangeIterationTestJVM.kt index 86820da06ff..2b8bd50b221 100644 --- a/libraries/stdlib/test/language/RangeIterationTestJVM.kt +++ b/libraries/stdlib/test/language/RangeIterationTestJVM.kt @@ -15,6 +15,7 @@ import java.lang.Character.MIN_VALUE as MinC import kotlin.test.assertEquals import org.junit.Test as test +// Test data for codegen is generated from this class. If you change it, rerun GenerateTests public class RangeIterationTestJVM { private fun doTest( sequence: Progression,