Debian Codegraph @

tests/unknown.test

raw
1 # Commands covered: unknown
2 #
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.
6 #
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.
10 #
11 # See the file "license.terms" for information on usage and redistribution
12 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13
14 package require tcltest 2.5
15 namespace import ::tcltest::*
16
17 unset -nocomplain x
18 catch {rename unknown unknown.old}
19
20 test unknown-1.1 {non-existent "unknown" command} {
21 list [catch {_non-existent_ foo bar} msg] $msg
22 } {1 {invalid command name "_non-existent_"}}
23
24 proc unknown {args} {
25 global x
26 set x $args
27 }
28 test unknown-2.1 {calling "unknown" command} {
29 foobar x y z
30 set x
31 } {foobar x y z}
32 test unknown-2.2 {calling "unknown" command with lots of args} {
33 foobar 1 2 3 4 5 6 7
34 set x
35 } {foobar 1 2 3 4 5 6 7}
36 test unknown-2.3 {calling "unknown" command with lots of args} {
37 foobar 1 2 3 4 5 6 7 8
38 set x
39 } {foobar 1 2 3 4 5 6 7 8}
40 test unknown-2.4 {calling "unknown" command with lots of args} {
41 foobar 1 2 3 4 5 6 7 8 9
42 set x
43 } {foobar 1 2 3 4 5 6 7 8 9}
44
45 test unknown-3.1 {argument quoting in calls to "unknown"} {
46 foobar \{ \} a\{b \; "\\" \$a a\[b \]
47 set x
48 } "foobar \\{ \\} a\\{b {;} \\\\ {\$a} {a\[b} \\]"
49
50 proc unknown args {
51 error "unknown failed"
52 }
53 test unknown-4.1 {errors in "unknown" procedure} {
54 list [catch {non-existent a b} msg] $msg $errorCode
55 } {1 {unknown failed} NONE}
56
57 # cleanup
58 catch {rename unknown {}}
59 catch {rename unknown.old unknown}
60 cleanupTests
61 return
62
63 # Local Variables:
64 # mode: tcl
65 # End: