From 71c59c7fb8559c62342c79482ca6a703a8714a42 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Wed, 17 Jan 2024 22:13:45 -0800 Subject: [PATCH] We can ship 1.0 without multiline for Groovy and Scala, delegate them out to #105 and #106. --- .../kotlin/com/diffplug/selfie/guts/Literals.kt | 14 ++++++++++---- .../kotlin/undertest/junit5/UT_InlineIntTest.kt | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/guts/Literals.kt b/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/guts/Literals.kt index ea863050..9d1a3ac0 100644 --- a/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/guts/Literals.kt +++ b/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/guts/Literals.kt @@ -108,16 +108,20 @@ internal object LiteralString : LiteralFormat() { when (language) { Language.SCALA, // scala only does $ substitution for s" and f" strings Language.JAVA_PRE15, - Language.JAVA -> encodeSingleJava(value) Language.GROOVY, + Language.JAVA -> encodeSingleJava(value) Language.KOTLIN -> encodeSingleJavaWithDollars(value) } else when (language) { + // TODO: support triple-quoted strings in scala + // https://github.com/diffplug/selfie/issues/106 Language.SCALA, + // TODO: support triple-quoted strings in groovy + // https://github.com/diffplug/selfie/issues/105 + Language.GROOVY, Language.JAVA_PRE15 -> encodeSingleJava(value) Language.JAVA -> encodeMultiJava(value) - Language.GROOVY, Language.KOTLIN -> encodeMultiKotlin(value) } override fun parse(str: String, language: Language): String = @@ -133,10 +137,12 @@ internal object LiteralString : LiteralFormat() { when (language) { Language.SCALA -> throw UnsupportedOperationException( - "Selfie doesn't support triple-quoted strings in Scala") + "Selfie doesn't support triple-quoted strings in Scala, yet - help wanted: https://github.com/diffplug/selfie/issues/106") + Language.GROOVY -> + throw UnsupportedOperationException( + "Selfie doesn't support triple-quoted strings in Groovy, yet - help wanted: https://github.com/diffplug/selfie/issues/105") Language.JAVA_PRE15, Language.JAVA -> parseMultiJava(str) - Language.GROOVY, Language.KOTLIN -> parseMultiKotlin(str) } fun encodeSingleJava(value: String): String = encodeSingleJavaish(value, false) diff --git a/undertest-junit5/src/test/kotlin/undertest/junit5/UT_InlineIntTest.kt b/undertest-junit5/src/test/kotlin/undertest/junit5/UT_InlineIntTest.kt index b8f81bfc..3c3e7959 100644 --- a/undertest-junit5/src/test/kotlin/undertest/junit5/UT_InlineIntTest.kt +++ b/undertest-junit5/src/test/kotlin/undertest/junit5/UT_InlineIntTest.kt @@ -6,6 +6,6 @@ import kotlin.test.Test class UT_InlineIntTest { @Test fun singleInt() { - expectSelfie(7777).toBe(7_777) + expectSelfie(555).toBe_TODO(789) } }