mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2025-04-21 12:27:27 +03:00
b2/test/subesc: test regexp escaping in substitutions
This commit is contained in:
49
b2/test/subesc
Executable file
49
b2/test/subesc
Executable file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
. ./Common
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
tst "substitutions: escape *" -R '*\\*' <<EOF
|
||||||
|
EOF
|
||||||
|
|
||||||
|
expect <<EOF
|
||||||
|
^.*\*\$
|
||||||
|
EOF
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
tst "substitutions: escape . (implicit)" -R 'x.y' <<EOF
|
||||||
|
EOF
|
||||||
|
|
||||||
|
expect <<EOF
|
||||||
|
^x\.y\$
|
||||||
|
EOF
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
tst "substitutions: escape |" -R 'a\\\|b' <<EOF
|
||||||
|
EOF
|
||||||
|
|
||||||
|
expect <<EOF
|
||||||
|
^a\\|b\$
|
||||||
|
EOF
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
tst "substitutions: escape \\" -R 'x\\\\y' <<EOF
|
||||||
|
EOF
|
||||||
|
|
||||||
|
expect <<EOF
|
||||||
|
^x\\\\y\$
|
||||||
|
EOF
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
tst_fail "substitutions: escape EOL" -R 'x\\' <<EOF
|
||||||
|
EOF
|
||||||
|
|
||||||
|
expect <<EOF
|
||||||
|
dummy:2: regexp ends with backslash
|
||||||
|
EOF
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
Reference in New Issue
Block a user