mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 06:05:39 +08:00
Remove '--import' from regex string match tests
The '--import' flag was used for importing named capture groups, but it was decided to always import them unconditionally. This flag was causing the tests to fail.
This commit is contained in:
parent
962ff26b92
commit
a434ec0e19
|
@ -2,32 +2,32 @@
|
||||||
# Tests for importing named regex groups as fish variables
|
# Tests for importing named regex groups as fish variables
|
||||||
|
|
||||||
# Capture first match
|
# Capture first match
|
||||||
echo "hello world" | string match --regex -q --import -- '(?<words>[^ ]+) ?'
|
echo "hello world" | string match --regex -q -- '(?<words>[^ ]+) ?'
|
||||||
printf "%s\n" $words
|
printf "%s\n" $words
|
||||||
# CHECK: hello
|
# CHECK: hello
|
||||||
|
|
||||||
# Capture multiple matches
|
# Capture multiple matches
|
||||||
echo "hello world" | string match --regex -q --import --all -- '(?<words>[^ ]+) ?'
|
echo "hello world" | string match --regex -q --all -- '(?<words>[^ ]+) ?'
|
||||||
printf "%s\n" $words
|
printf "%s\n" $words
|
||||||
# CHECK: hello
|
# CHECK: hello
|
||||||
# CHECK: world
|
# CHECK: world
|
||||||
|
|
||||||
# Capture multiple variables
|
# Capture multiple variables
|
||||||
echo "hello world" | string match -rqI -- '^(?<word1>[^ ]+) (?<word2>.*)$'
|
echo "hello world" | string match -rq -- '^(?<word1>[^ ]+) (?<word2>.*)$'
|
||||||
printf "%s\n" $word1 $word2
|
printf "%s\n" $word1 $word2
|
||||||
# CHECK: hello
|
# CHECK: hello
|
||||||
# CHECK: world
|
# CHECK: world
|
||||||
|
|
||||||
# Clear variables on no match
|
# Clear variables on no match
|
||||||
set foo foo
|
set foo foo
|
||||||
echo "foo" | string match -rqI -- '^(?<foo>bar)$'
|
echo "foo" | string match -rq -- '^(?<foo>bar)$'
|
||||||
echo $foo
|
echo $foo
|
||||||
# CHECK:
|
# CHECK:
|
||||||
|
|
||||||
# Named group may be empty in some of the matches
|
# Named group may be empty in some of the matches
|
||||||
set word
|
set word
|
||||||
set punctuation
|
set punctuation
|
||||||
echo "hello world, boy!" | string match -a -qrI -- '(?<word>[^ .,!;]+)(?<punctuation>[.,!;])?'
|
echo "hello world, boy!" | string match -a -qr -- '(?<word>[^ .,!;]+)(?<punctuation>[.,!;])?'
|
||||||
echo $word
|
echo $word
|
||||||
# CHECK: hello world boy
|
# CHECK: hello world boy
|
||||||
printf "%s\n" $punctuation
|
printf "%s\n" $punctuation
|
||||||
|
|
Loading…
Reference in New Issue
Block a user