diff --git a/kotlin-native/backend.native/tests/stdlib_external/utils.kt b/kotlin-native/backend.native/tests/stdlib_external/utils.kt index d613b8767b1..111d54ef1cd 100644 --- a/kotlin-native/backend.native/tests/stdlib_external/utils.kt +++ b/kotlin-native/backend.native/tests/stdlib_external/utils.kt @@ -24,7 +24,7 @@ public actual val supportsOctalLiteralInRegex: Boolean get() = true public actual val supportsEscapeAnyCharInRegex: Boolean get() = true -public actual val regexSplitUnicodeCodePointHandling: Boolean get() = true +public actual val regexSplitUnicodeCodePointHandling: Boolean get() = false public actual object BackReferenceHandling { actual val captureLargestValidIndex: Boolean get() = true diff --git a/libraries/stdlib/native-wasm/src/kotlin/text/regex/sets/EmptySet.kt b/libraries/stdlib/native-wasm/src/kotlin/text/regex/sets/EmptySet.kt index 2e507eee5a3..35e98414dee 100644 --- a/libraries/stdlib/native-wasm/src/kotlin/text/regex/sets/EmptySet.kt +++ b/libraries/stdlib/native-wasm/src/kotlin/text/regex/sets/EmptySet.kt @@ -33,12 +33,6 @@ internal class EmptySet(override var next: AbstractSet) : LeafSet() { override fun find(startIndex: Int, testString: CharSequence, matchResult: MatchResultImpl): Int { for (index in startIndex..testString.length) { - if (index < testString.length) { - if (testString[index].isLowSurrogate() && - index > 0 && testString[index - 1].isHighSurrogate()) { - continue - } - } if (next.matches(index, testString, matchResult) >= 0) { return index } @@ -48,12 +42,6 @@ internal class EmptySet(override var next: AbstractSet) : LeafSet() { override fun findBack(leftLimit: Int, rightLimit: Int, testString: CharSequence, matchResult: MatchResultImpl): Int { for (index in rightLimit downTo leftLimit) { - if (index < testString.length) { - if (testString[index].isLowSurrogate() && - index > 0 && testString[index - 1].isHighSurrogate()) { - continue - } - } if (next.matches(index, testString, matchResult) >= 0) { return index } diff --git a/libraries/stdlib/native-wasm/test/harmony_regex/SplitTest.kt b/libraries/stdlib/native-wasm/test/harmony_regex/SplitTest.kt index 932fdb956d3..1ba3dc29744 100644 --- a/libraries/stdlib/native-wasm/test/harmony_regex/SplitTest.kt +++ b/libraries/stdlib/native-wasm/test/harmony_regex/SplitTest.kt @@ -135,22 +135,4 @@ class SplitTest { assertEquals("d", s[4]) assertEquals("", s[5]) } - - @Test fun testSplitSupplementaryWithEmptyString() { - - /* - * See http://www.unicode.org/reports/tr18/#Supplementary_Characters We - * have to treat text as code points not code units. - */ - val p = Regex("") - val s: List - s = p.split("a\ud869\uded6b", 0) - assertEquals(5, s.size) - assertEquals("", s[0]) - assertEquals("a", s[1]) - assertEquals("\ud869\uded6", s[2]) - assertEquals("b", s[3]) - assertEquals("", s[4]) - } - } diff --git a/libraries/stdlib/test/text/RegexTest.kt b/libraries/stdlib/test/text/RegexTest.kt index 08584a96050..5c61d9c8569 100644 --- a/libraries/stdlib/test/text/RegexTest.kt +++ b/libraries/stdlib/test/text/RegexTest.kt @@ -529,17 +529,19 @@ class RegexTest { @Test fun splitByEmptyMatch() { val input = "test" - val emptyMatch = "".toRegex() + for (pattern in listOf("", "(?<=)")) { + val emptyMatch = pattern.toRegex() - testSplitEquals(listOf("", "t", "e", "s", "t", ""), input, emptyMatch) - testSplitEquals(listOf("", "t", "est"), input, emptyMatch, limit = 3) + testSplitEquals(listOf("", "t", "e", "s", "t", ""), input, emptyMatch) + testSplitEquals(listOf("", "t", "est"), input, emptyMatch, limit = 3) - testSplitEquals("".split(""), "", emptyMatch) + testSplitEquals("".split(""), "", emptyMatch) - testSplitEquals( - if (regexSplitUnicodeCodePointHandling) listOf("", "\uD83D\uDE04", "\uD801", "") else listOf("", "\uD83D", "\uDE04", "\uD801", ""), - "\uD83D\uDE04\uD801", emptyMatch - ) + testSplitEquals( + if (regexSplitUnicodeCodePointHandling) listOf("", "\uD83D\uDE04", "\uD801", "") else listOf("", "\uD83D", "\uDE04", "\uD801", ""), + "\uD83D\uDE04\uD801", emptyMatch + ) + } val emptyMatchBeforeT = "(?=t)".toRegex() diff --git a/libraries/stdlib/wasm/test/testUtils.kt b/libraries/stdlib/wasm/test/testUtils.kt index 7f60d75bbac..493d1e7ad81 100644 --- a/libraries/stdlib/wasm/test/testUtils.kt +++ b/libraries/stdlib/wasm/test/testUtils.kt @@ -21,7 +21,7 @@ public actual val supportsOctalLiteralInRegex: Boolean get() = true public actual val supportsEscapeAnyCharInRegex: Boolean get() = true -public actual val regexSplitUnicodeCodePointHandling: Boolean get() = true +public actual val regexSplitUnicodeCodePointHandling: Boolean get() = false public actual object BackReferenceHandling { actual val captureLargestValidIndex: Boolean get() = true