Test octal literal in regex

This commit is contained in:
Abduqodiri Qurbonzoda
2022-03-31 01:55:08 +03:00
committed by Space
parent 46408ffd9d
commit 74121b26c0
6 changed files with 19 additions and 0 deletions
@@ -32,6 +32,8 @@ public actual val supportsSuppressedExceptions: Boolean get() = true
public actual val supportsNamedCapturingGroup: Boolean get() = true
public actual val supportsOctalLiteralInRegex: Boolean get() = true
public actual val regexSplitUnicodeCodePointHandling: Boolean get() = true
public actual object BackReferenceHandling {
@@ -20,6 +20,8 @@ public expect val supportsSuppressedExceptions: Boolean
public expect val supportsNamedCapturingGroup: Boolean
public expect val supportsOctalLiteralInRegex: Boolean
public expect val regexSplitUnicodeCodePointHandling: Boolean
public enum class HandlingOption {
@@ -29,6 +29,8 @@ actual val supportsSuppressedExceptions: Boolean get() = true
public actual val supportsNamedCapturingGroup: Boolean get() = true
public actual val supportsOctalLiteralInRegex: Boolean get() = false
public actual val regexSplitUnicodeCodePointHandling: Boolean get() = true
public actual object BackReferenceHandling {
@@ -43,6 +43,8 @@ public actual val supportsSuppressedExceptions: Boolean get() = !isJava6
public actual val supportsNamedCapturingGroup: Boolean get() = !isJava6
public actual val supportsOctalLiteralInRegex: Boolean get() = true
public actual val regexSplitUnicodeCodePointHandling: Boolean get() = false
public actual object BackReferenceHandling {
+9
View File
@@ -9,6 +9,7 @@ package test.text
import test.regexSplitUnicodeCodePointHandling
import test.supportsNamedCapturingGroup
import test.supportsOctalLiteralInRegex
import test.BackReferenceHandling
import test.HandlingOption
import kotlin.test.*
@@ -242,6 +243,14 @@ class RegexTest {
testInvalidBackReference(BackReferenceHandling.notYetDefinedGroup, pattern = "a\\1(a)")
}
@Test fun matchCharWithOctalValue() {
if (supportsOctalLiteralInRegex) {
assertEquals("aa", "a\\0141".toRegex().find("aaaa")?.value)
} else {
assertFails { "a\\0141".toRegex() }
}
}
@Test fun matchNamedGroupsWithBackReference() {
if (!supportsNamedCapturingGroup) return
+2
View File
@@ -30,6 +30,8 @@ actual val supportsSuppressedExceptions: Boolean get() = true
public actual val supportsNamedCapturingGroup: Boolean get() = true
public actual val supportsOctalLiteralInRegex: Boolean get() = true
public actual val regexSplitUnicodeCodePointHandling: Boolean get() = true
public actual object BackReferenceHandling {