From 97916bd8d5631ddb6730c0d01c0cf69a87b904ca Mon Sep 17 00:00:00 2001 From: Benjamin Galliot Date: Sat, 3 Apr 2021 20:18:03 +0200 Subject: [PATCH] Add test for Unicode named subpatterns and property mixes of scripts and classes. (#40328) (cherry picked from commit 8b6a778bb46276e46caf95eb8376dcbd5d7b8ef7) --- test/regex.jl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/regex.jl b/test/regex.jl index ef09dc35071b26..cce0b26ed34486 100644 --- a/test/regex.jl +++ b/test/regex.jl @@ -101,6 +101,17 @@ @test keys(m) == ["numéro", "文本"] end + # Unicode named subpatterns and property mixes of scripts and classes (issues #35322/#35459 and #40231) + let m = match(r"(?\d)[\pZs]*(?<文本>[\p{Han}\p{P}]+)", "1 孔生雪笠,聖裔也。為人蘊藉,工詩。") + @test haskey(m, :numéro) + @test haskey(m, "文本") + @test !haskey(m, "ゑ") + @test (m[:numéro], m[:文本]) == ("1", "孔生雪笠,聖裔也。為人蘊藉,工詩。") + @test (m[1], m[2]) == (m[:numéro], m[:文本]) + @test sprint(show, m) == "RegexMatch(\"1 孔生雪笠,聖裔也。為人蘊藉,工詩。\", numéro=\"1\", 文本=\"孔生雪笠,聖裔也。為人蘊藉,工詩。\")" + @test keys(m) == ["numéro", "文本"] + end + # Backcapture reference in substitution string @test replace("abcde", r"(..)(?Pd)" => s"\gxy\\\1") == "adxy\\bce" @test_throws ErrorException replace("a", r"(?P)" => s"\g")