Annotation of researchv10dc/cmd/worm/scsi/tcl/tests/glob.test, revision 1.1.1.1

1.1       root        1: # This file contains contains a collection of tests for the "glob"
                      2: # command in Tcl.  If everything is OK then it finishes silently.
                      3: # If a problem is detected then it generates a Tcl error with a
                      4: # cryptic message.  To trace the error you'll have to read through
                      5: # the commands in this file.
                      6: #
                      7: # $Header: /sprite/src/lib/tcl/tests/RCS/glob.test,v 1.4 90/04/19 15:18:20 ouster Exp $ (Berkeley)
                      8: 
                      9: proc check {a b num} {
                     10:     if {[string compare $a $b] != 0} {
                     11:        error [format {Glob error %s: wanted "%s", got "%s"} $num $b $a]}
                     12: }
                     13: 
                     14: # First, create some subdirectories to use for testing.
                     15: 
                     16: exec rm -rf globTest
                     17: exec mkdir globTest globTest/a1 globTest/a2 globTest/a3
                     18: exec mkdir globTest/a1/b1 globTest/a1/b2 globTest/a2/b3
                     19: print abc globTest/x1.c
                     20: print abc globTest/y1.c
                     21: print abc globTest/z1.c
                     22: print abc globTest/.1
                     23: print abc globTest/a1/b1/x2.c
                     24: print abc globTest/a1/b2/y2.c
                     25: 
                     26: check [glob a] a 1.1
                     27: check [glob aaa bbb ccc] "aaa bbb ccc" 1.2
                     28: 
                     29: check [glob "{a1,a2}"] "a1 a2" 2.1
                     30: check [glob a/{x,y}{123,456}/z] "a/x123/z a/x456/z a/y123/z a/y456/z" 2.2
                     31: 
                     32: check [glob g*/*.c] "globTest/x1.c globTest/y1.c globTest/z1.c" 3.1
                     33: check [glob globTest/?1.c] "globTest/x1.c globTest/y1.c globTest/z1.c" 3.2
                     34: check [glob */*/*/*.c] "globTest/a1/b1/x2.c globTest/a1/b2/y2.c" 3.3
                     35: check [glob globTest/*] "globTest/a1 globTest/a2 globTest/a3 globTest/x1.c globTest/y1.c globTest/z1.c" 3.4
                     36: check [glob globTest/.*] "globTest/. globTest/.. globTest/.1" 3.5
                     37: check [glob globTest/*/*] "globTest/a1/b1 globTest/a1/b2 globTest/a2/b3" 3.6
                     38: check [glob {globTest/[xy]1.*}] "globTest/x1.c globTest/y1.c" 3.7
                     39: 
                     40: set myHome [file ~ tail]
                     41: if [string compare $myHome ouster] {
                     42:     check [glob ~/.csh*] "/users/ouster/.cshrc" 4.1
                     43:     check [glob ~ouster] "/users/ouster" 4.2
                     44: }
                     45: 
                     46: check [catch {glob} msg] 1 5.1
                     47: check $msg "no files matched glob pattern(s)" 5.2
                     48: check [catch {glob a/{b,c,d}/\{} msg] 1 5.3
                     49: check $msg "unmatched open-brace in file name" 5.4
                     50: check [catch {glob goo/*} msg] 1 5.5
                     51: check $msg {no files matched glob pattern(s)} 5.6
                     52: check [catch {glob ~no-one} msg] 1 5.7
                     53: check $msg {user "no-one" doesn't exist} 5.8
                     54: 
                     55: exec rm -rf globTest

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.