From 78d015bd61724e942493aa2e1a40897482696d0d Mon Sep 17 00:00:00 2001 From: David Adam Date: Wed, 29 May 2019 23:14:19 +0800 Subject: [PATCH] string: add tests for empty capture groups As seen in #5201. --- tests/string.err | 3 +++ tests/string.in | 4 ++++ tests/string.out | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/tests/string.err b/tests/string.err index d291768ce..478007e2d 100644 --- a/tests/string.err +++ b/tests/string.err @@ -176,6 +176,9 @@ #################### # string replace --regex -f "\d" X 1bc axc 2 d3f jk4 xyz +#################### +# string match -r with empty capture groups + #################### # string match -r "[" "a[sd" string match: Regular expression compile error: missing terminating ] for character class diff --git a/tests/string.in b/tests/string.in index e15f33ee5..7bb386d0e 100644 --- a/tests/string.in +++ b/tests/string.in @@ -203,6 +203,10 @@ or echo Unexpected exit status at line (status --current-line-number) string replace --regex -f "Z" X 1bc axc 2 d3f jk4 xyz and echo Unexpected exit status at line (status --current-line-number) +# From https://github.com/fish-shell/fish-shell/issues/5201 +logmsg 'string match -r with empty capture groups' +string match -r '^([ugoa]*)([=+-]?)([rwx]*)$' '=r' + # test some failure cases logmsg 'string match -r "[" "a[sd"' string match -r "[" "a[sd"; and echo "unexpected exit 0" diff --git a/tests/string.out b/tests/string.out index 2fdec3025..bdd0cb568 100644 --- a/tests/string.out +++ b/tests/string.out @@ -274,6 +274,13 @@ X dXf jkX +#################### +# string match -r with empty capture groups +=r + += +r + #################### # string match -r "[" "a[sd"