os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/cmdMZ.test
Update contrib.
1 # The tests in this file cover the procedures in tclCmdMZ.c.
3 # This file contains a collection of tests for one or more of the Tcl
4 # built-in commands. Sourcing this file into Tcl runs the tests and
5 # generates output for errors. No output means no errors were found.
7 # Copyright (c) 1991-1993 The Regents of the University of California.
8 # Copyright (c) 1994 Sun Microsystems, Inc.
9 # Copyright (c) 1998-1999 by Scriptics Corporation.
11 # See the file "license.terms" for information on usage and redistribution
12 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 # RCS: @(#) $Id: cmdMZ.test,v 1.13.2.3 2004/02/25 23:38:16 dgp Exp $
16 if {[lsearch [namespace children] ::tcltest] == -1} {
17 package require tcltest 2.1
18 namespace import -force ::tcltest::*
23 test cmdMZ-1.1 {Tcl_PwdObjCmd} {
24 list [catch {pwd a} msg] $msg
25 } {1 {wrong # args: should be "pwd"}}
26 test cmdMZ-1.2 {Tcl_PwdObjCmd: simple pwd} {
29 test cmdMZ-1.3 {Tcl_PwdObjCmd: simple pwd} {
30 expr [string length pwd]>0
32 test cmdMZ-1.4 {Tcl_PwdObjCmd: failure} {unixOnly nonPortable} {
33 # This test fails on various unix platforms (eg Linux) where
34 # permissions caching causes this to fail. The caching is strictly
35 # incorrect, but we have no control over that.
36 set foodir [file join [temporaryDirectory] foo]
37 file delete -force $foodir
41 file attr . -permissions 000
42 set result [list [catch {pwd} msg] $msg]
44 file delete -force $foodir
46 } {1 {error getting working directory name: permission denied}}
48 # The tests for Tcl_RegexpObjCmd, Tcl_RegsubObjCmd are in regexp.test
52 test cmdMZ-2.1 {Tcl_RenameObjCmd: error conditions} {
53 list [catch {rename r1} msg] $msg $errorCode
54 } {1 {wrong # args: should be "rename oldName newName"} NONE}
55 test cmdMZ-2.2 {Tcl_RenameObjCmd: error conditions} {
56 list [catch {rename r1 r2 r3} msg] $msg $errorCode
57 } {1 {wrong # args: should be "rename oldName newName"} NONE}
58 test cmdMZ-2.3 {Tcl_RenameObjCmd: success} {
60 proc r1 {} {return "r1"}
64 test cmdMZ-2.4 {Tcl_RenameObjCmd: success} {
65 proc r1 {} {return "r1"}
67 list [catch {r1} msg] $msg
68 } {1 {invalid command name "r1"}}
70 # The tests for Tcl_ReturnObjCmd are in proc-old.test
71 # The tests for Tcl_ScanObjCmd are in scan.test
75 test cmdMZ-3.1 {Tcl_SourceObjCmd: error conditions} {macOnly} {
76 list [catch {source} msg] $msg
77 } {1 {wrong # args: should be "source fileName" or "source -rsrc name ?fileName?" or "source -rsrcid id ?fileName?"}}
78 test cmdMZ-3.2 {Tcl_SourceObjCmd: error conditions} {macOnly} {
79 list [catch {source a b} msg] $msg
80 } {1 {bad argument: should be "source fileName" or "source -rsrc name ?fileName?" or "source -rsrcid id ?fileName?"}}
81 test cmdMZ-3.3 {Tcl_SourceObjCmd: error conditions} {unixOrPc} {
82 list [catch {source} msg] $msg
83 } {1 {wrong # args: should be "source fileName"}}
84 test cmdMZ-3.4 {Tcl_SourceObjCmd: error conditions} {unixOrPc} {
85 list [catch {source a b} msg] $msg
86 } {1 {wrong # args: should be "source fileName"}}
88 proc ListGlobMatch {expected actual} {
89 if {[llength $expected] != [llength $actual]} {
92 foreach e $expected a $actual {
93 if {![string match $e $a]} {
99 customMatch listGlob ListGlobMatch
101 test cmdMZ-3.5 {Tcl_SourceObjCmd: error in script} -setup {
104 error "error in sourced file"
108 list [catch {source $file} msg] $msg $errorInfo
110 removeFile source.file
111 } -match listGlob -result {1 {error in sourced file} {error in sourced file
113 "error "error in sourced file""
117 test cmdMZ-3.6 {Tcl_SourceObjCmd: simple script} {
118 set file [makeFile {list result} source.file]
119 set result [source $file]
120 removeFile source.file
126 test cmdMZ-4.1 {Tcl_SplitObjCmd: split errors} {
127 list [catch split msg] $msg $errorCode
128 } {1 {wrong # args: should be "split string ?splitChars?"} NONE}
129 test cmdMZ-4.2 {Tcl_SplitObjCmd: split errors} {
130 list [catch {split a b c} msg] $msg $errorCode
131 } {1 {wrong # args: should be "split string ?splitChars?"} NONE}
132 test cmdMZ-4.3 {Tcl_SplitObjCmd: basic split commands} {
133 split "a\n b\t\r c\n "
134 } {a {} b {} {} c {} {}}
135 test cmdMZ-4.4 {Tcl_SplitObjCmd: basic split commands} {
136 split "word 1xyzword 2zword 3" xyz
137 } {{word 1} {} {} {word 2} {word 3}}
138 test cmdMZ-4.5 {Tcl_SplitObjCmd: basic split commands} {
141 test cmdMZ-4.6 {Tcl_SplitObjCmd: basic split commands} {
142 split "a\}b\[c\{\]\$"
143 } "a\\}b\\\[c\\{\\\]\\\$"
144 test cmdMZ-4.7 {Tcl_SplitObjCmd: basic split commands} {
147 test cmdMZ-4.8 {Tcl_SplitObjCmd: basic split commands} {
150 test cmdMZ-4.9 {Tcl_SplitObjCmd: basic split commands} {
153 test cmdMZ-4.10 {Tcl_SplitObjCmd: basic split commands} {
156 foreach f [split {]\n} {}] {
163 test cmdMZ-4.11 {Tcl_SplitObjCmd: basic split commands} {
171 test cmdMZ-4.12 {Tcl_SplitObjCmd: basic split commands} {
172 split "a0ab1b2bbb3\000c4" ab\000c
173 } {{} 0 {} 1 2 {} {} 3 {} 4}
174 test cmdMZ-4.13 {Tcl_SplitObjCmd: basic split commands} {
175 # if not UTF-8 aware, result is "a {} {} b qw\xe5 {} N wq"
176 split "a\u4e4eb qw\u5e4e\x4e wq" " \u4e4e"
179 # The tests for Tcl_StringObjCmd are in string.test
180 # The tests for Tcl_SubstObjCmd are in subst.test
181 # The tests for Tcl_SwitchObjCmd are in switch.test
183 test cmdMZ-5.1 {Tcl_TimeObjCmd: basic format of command} {
184 list [catch {time} msg] $msg
185 } {1 {wrong # args: should be "time command ?count?"}}
186 test cmdMZ-5.2 {Tcl_TimeObjCmd: basic format of command} {
187 list [catch {time a b c} msg] $msg
188 } {1 {wrong # args: should be "time command ?count?"}}
189 test cmdMZ-5.3 {Tcl_TimeObjCmd: basic format of command} {
190 list [catch {time a b} msg] $msg
191 } {1 {expected integer but got "b"}}
192 test cmdMZ-5.4 {Tcl_TimeObjCmd: nothing happens with negative iteration counts} {
194 } {0 microseconds per iteration}
195 test cmdMZ-5.5 {Tcl_TimeObjCmd: result format} {
196 regexp {^\d+ microseconds per iteration} [time {format 1}]
198 test cmdMZ-5.6 {Tcl_TimeObjCmd: slower commands take longer} {
199 expr {[lindex [time {after 2}] 0] < [lindex [time {after 1000}] 0]}
201 test cmdMZ-5.7 {Tcl_TimeObjCmd: errors generate right trace} {
202 list [catch {time {error foo}} msg] $msg $::errorInfo
209 # The tests for Tcl_TraceObjCmd and TraceVarProc are in trace.test
210 # The tests for Tcl_WhileObjCmd are in while.test
213 ::tcltest::cleanupTests