From fc5eac26cdc530f0393ef21fd6a674f749f70314 Mon Sep 17 00:00:00 2001 From: Mark Punzalan Date: Tue, 26 Feb 2019 15:15:03 -0800 Subject: [PATCH] Extracted complex string concatenation bytecode test case into separate test data file. --- .../stringOperations/multipleNestedConcat.kt | 10 ++++++++++ .../bytecodeText/stringOperations/nestedConcat.kt | 11 +---------- .../kotlin/codegen/BytecodeTextTestGenerated.java | 5 +++++ .../codegen/ir/IrBytecodeTextTestGenerated.java | 5 +++++ 4 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 compiler/testData/codegen/bytecodeText/stringOperations/multipleNestedConcat.kt diff --git a/compiler/testData/codegen/bytecodeText/stringOperations/multipleNestedConcat.kt b/compiler/testData/codegen/bytecodeText/stringOperations/multipleNestedConcat.kt new file mode 100644 index 00000000000..275db0e2038 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/stringOperations/multipleNestedConcat.kt @@ -0,0 +1,10 @@ +// Uses 3 StringBuilders: +// - In return expression +// - In argument to 1st call to foo() +// - In argument to 2nd call to foo() inside string literal +fun test(s1: String, s2: String, s3: String): String { + fun foo(s: String) = s + return "foo: " + foo(s1 + s2 + " ${foo("\${s3.length} = ${s3.length}")}") +} + +// 3 NEW java/lang/StringBuilder \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/stringOperations/nestedConcat.kt b/compiler/testData/codegen/bytecodeText/stringOperations/nestedConcat.kt index 000cc6f57b4..463b6a887ae 100644 --- a/compiler/testData/codegen/bytecodeText/stringOperations/nestedConcat.kt +++ b/compiler/testData/codegen/bytecodeText/stringOperations/nestedConcat.kt @@ -29,13 +29,4 @@ fun test5(s1: String, s2: String, s3: String) = fun test6(s1: String, s2: String, s3: String) = "${"s1:" + "${" " + s1};"} ${"s2:" + "${" " + s2};"} ${"s3:" + "${" " + s3}"}" -// Uses 3 StringBuilders: -// - In return expression -// - In argument to 1st call to foo() -// - In argument to 2nd call to foo() inside string literal -fun test7(s1: String, s2: String, s3: String): String { - fun foo(s: String) = s - return "foo: " + foo(s1 + s2 + " ${foo("\${s3.length} = ${s3.length}")}") -} - -// 9 NEW java/lang/StringBuilder \ No newline at end of file +// 6 NEW java/lang/StringBuilder \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index 98c30725db2..f0280febeca 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -3214,6 +3214,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/stringOperations/kt19037.kt"); } + @TestMetadata("multipleNestedConcat.kt") + public void testMultipleNestedConcat() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/stringOperations/multipleNestedConcat.kt"); + } + @TestMetadata("nestedConcat.kt") public void testNestedConcat() throws Exception { runTest("compiler/testData/codegen/bytecodeText/stringOperations/nestedConcat.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java index e1a03441e3d..3f7c3a8ab3f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java @@ -3214,6 +3214,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/stringOperations/kt19037.kt"); } + @TestMetadata("multipleNestedConcat.kt") + public void testMultipleNestedConcat() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/stringOperations/multipleNestedConcat.kt"); + } + @TestMetadata("nestedConcat.kt") public void testNestedConcat() throws Exception { runTest("compiler/testData/codegen/bytecodeText/stringOperations/nestedConcat.kt");