diff options
| author | Jonas Maier <jonas@x77.dev> | 2026-06-01 22:40:04 +0200 |
|---|---|---|
| committer | Jonas Maier <jonas@x77.dev> | 2026-06-01 22:40:04 +0200 |
| commit | e662dfa3a074a7603cbb9de473bf8bb45b4bb960 (patch) | |
| tree | 1bbb800bebfe137e82d64da47bca487abdfb786f /test-cases/case1 | |
| parent | c73ed9310d8162b71183688de62bf8c1fc8420df (diff) | |
| download | pish-e662dfa3a074a7603cbb9de473bf8bb45b4bb960.tar.gz | |
some more regex tests
Diffstat (limited to 'test-cases/case1')
| -rw-r--r-- | test-cases/case1/script.sh | 80 | ||||
| -rw-r--r-- | test-cases/case1/stdout.txt | 0 |
2 files changed, 80 insertions, 0 deletions
diff --git a/test-cases/case1/script.sh b/test-cases/case1/script.sh new file mode 100644 index 0000000..ed9de13 --- /dev/null +++ b/test-cases/case1/script.sh @@ -0,0 +1,80 @@ +case foo { + [fF][oO][oO] {} + .* { + echo 'failed foo [fF][oO][oO]' + } +} + +case fOo { + [fF][oO][oO] {} + .* { + echo 'failed fOo [fF][oO][oO]' + } +} + +case foo { + foo+ {} + .* { + echo 'failed foo+' + } +} + +case foo { + fo+ {} + .* { + echo 'failed fo+' + } +} + +case foo { + fo* {} + .* { + echo 'failed fo*' + } +} + +case foo { + fo { + echo 'failed fo' + } + .* {} +} + +case '[]' { + .. {} + .* { + echo 'failed [] ..' + } +} + +case '[]' { + \[\] {} + .* { + echo 'failed [] \[\]' + } +} + +fun match_ip { + case $1 { + ([0-9][0-9]?[0-9]?)\.([0-9]?[0-9]?[0-9])\.([0-9]?[0-9]?[0-9])\.([0-9]?[0-9]?[0-9]) { + if [ $2 != yes ] { + echo "$1 should not match but it did" + } + } + .* { + if [ $2 = yes ] { + echo "$1 should match but it did not" + } + } + } +} + +match_ip 192.168.1.1 yes +match_ip 999.999.999.999 yes # the IP regex is not very good but we are testing the regex engine not IP parsing. +match_ip foo no +match_ip ::1 no +match_ip 192..168.1.1 no +match_ip 192.168.1.1.1 no +match_ip 0.0.0.0 yes +match_ip 01.1.1.1 yes +match_ip 1234.0.0.1 no diff --git a/test-cases/case1/stdout.txt b/test-cases/case1/stdout.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test-cases/case1/stdout.txt |
