diff options
author | Steve Bennett <steveb@workware.net.au> | 2020-04-18 09:34:25 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2020-05-04 21:57:34 +1000 |
commit | da82368c816c8d06f425aa3f25a2a918fdba1df1 (patch) | |
tree | e1dc05358910d168edc982ed05523d0b30ad24d5 /tests/regexp.test | |
parent | 8a5861eb51c32e41d638181188c256c1dbb93c96 (diff) | |
download | jimtcl-da82368c816c8d06f425aa3f25a2a918fdba1df1.zip jimtcl-da82368c816c8d06f425aa3f25a2a918fdba1df1.tar.gz jimtcl-da82368c816c8d06f425aa3f25a2a918fdba1df1.tar.bz2 |
tests: Add many new additional tests for code coverage
readdir, tty, utf8, signal, alarm, kill, file, jimsh, posix, aio,
history, interp, pack, unpack, eventloop, exec, load, package,
regexp, regsub
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests/regexp.test')
-rw-r--r-- | tests/regexp.test | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/regexp.test b/tests/regexp.test index 03fdcbe..e372fbd 100644 --- a/tests/regexp.test +++ b/tests/regexp.test @@ -661,6 +661,88 @@ test regexp-21.15 {Replace literal backslash} { set value } "\\abc\\def" +test regexp-22.1 {char range} { + regexp -all -inline {[a-c]+} "defaaghbcadfbaacccd" +} {aa bca baaccc} + +# Tcl doesn't like this +test regexp-22.2 {reversed char range} jim { + regexp -all -inline {[c-a]+} "defaaghbcadfbaacccd" +} {aa bca baaccc} + +# Note that here the hex escapes are interpreted by regexp, not by Tcl +test regexp-22.3 {hex digits} { + regexp -all -inline {[\x6a-\x6c]+} "jlaksdjflkwueorilkj" +} {jl k j lk lkj} + +test regexp-22.4 {uppercase hex digits} { + regexp -all -inline {[\x6A-\x6C]+} "jlaksdjflkwueorilkj" +} {jl k j lk lkj} + +# Below \x9X will be treated as \x9 followed by X +test regexp-22.5 {invalid hex digits} { + regexp -all -inline {[\x9X\x6C]+} "jla\tX6djflyw\tueorilkj" +} [list l \tX l \t l] + +test regexp-22.6 {unicode hex digits} jim { + regexp -all -inline {[\u{41}-\u{00043}]+} "AVBASDFBABDFBAFBAFA" +} {A BA BAB BA BA A} + +# \u{X41} is treated as u { X 41 } +test regexp-22.7 {unicode hex digits with invalid exscape} jim { + regexp -all -inline {[\u{X41}]+} "uVBAX{SD4B1}DFBAFBAFA" +} {u X\{ 4 1\}} + +test regexp-22.8 {unicode hex digits} { + regexp -all -inline {[\u0041-\u0043]+} "AVBASDFBABDFBAFBAFA" +} {A BA BAB BA BA A} + +test regexp-22.9 {\U unicode hex digits} { + regexp -all -inline {[\U00000041-\U00000043]+} "AVBASDFBABDFBAFBAFA" +} {A BA BAB BA BA A} + +test regexp-22.10 {Various char escapes} { + set result {} + foreach match [regexp -all -inline {[\e\f\v\t\b]+} "A\f\vBB\b\tC\x1BG"] { + set chars {} + foreach c [split $match ""] { + scan $c %c char + lappend chars $char + } + lappend result [join $chars ,] + } + join $result | +} {12,11|8,9|27} + +test regexp-22.11 {backslash as last char} { + regexp -all -inline "\[a\\" "ba\\d\[ef" +} "a\ \\\\" + +# Probably should be an error +test regexp-22.12 {missing closing bracket} { + regexp -all -inline {[abc} "abcdefghi" +} {a b c} + +test regexp-22.13 {empty alternative} { + regexp -all -inline {a(a|b|)c} "aacbacbaa" +} {aac a ac {}} + +test regexp-22.14 {] in set} { + regexp -all -inline {[]ab]+} "aac\[ba\]cbaa" +} {aa ba\] baa} + +test regexp-22.15 {- in set} { + regexp -all -inline {[-ab]+} "aac\[ba\]cb-aa" +} {aa ba b-aa} + +test regexp-22.16 {\s in set} { + regexp -all -inline {[\sa]+} "aac\[b a\]c\tb-aa" +} [list aa " a" \t aa] + +test regexp-22.17 {\d in set} { + regexp -all -inline {[a\d]+} "a0ac\[b a\]44c\tb-1aa7" +} {a0a a 44 1aa7} + # Tests resulting from bugs reported by users test reg-31.1 {[[:xdigit:]] behaves correctly when followed by [[:space:]]} { set str {2:::DebugWin32} |