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 | # RCS: @(#) $Id: unknown.test,v 1.7 2004/05/19 13:05:37 dkf Exp $ |
---|
15 | |
---|
16 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
17 | package require tcltest |
---|
18 | namespace import -force ::tcltest::* |
---|
19 | } |
---|
20 | |
---|
21 | catch {unset x} |
---|
22 | catch {rename unknown unknown.old} |
---|
23 | |
---|
24 | test unknown-1.1 {non-existent "unknown" command} { |
---|
25 | list [catch {_non-existent_ foo bar} msg] $msg |
---|
26 | } {1 {invalid command name "_non-existent_"}} |
---|
27 | |
---|
28 | proc unknown {args} { |
---|
29 | global x |
---|
30 | set x $args |
---|
31 | } |
---|
32 | |
---|
33 | test unknown-2.1 {calling "unknown" command} { |
---|
34 | foobar x y z |
---|
35 | set x |
---|
36 | } {foobar x y z} |
---|
37 | test unknown-2.2 {calling "unknown" command with lots of args} { |
---|
38 | foobar 1 2 3 4 5 6 7 |
---|
39 | set x |
---|
40 | } {foobar 1 2 3 4 5 6 7} |
---|
41 | test unknown-2.3 {calling "unknown" command with lots of args} { |
---|
42 | foobar 1 2 3 4 5 6 7 8 |
---|
43 | set x |
---|
44 | } {foobar 1 2 3 4 5 6 7 8} |
---|
45 | test unknown-2.4 {calling "unknown" command with lots of args} { |
---|
46 | foobar 1 2 3 4 5 6 7 8 9 |
---|
47 | set x |
---|
48 | } {foobar 1 2 3 4 5 6 7 8 9} |
---|
49 | |
---|
50 | test unknown-3.1 {argument quoting in calls to "unknown"} { |
---|
51 | foobar \{ \} a\{b \; "\\" \$a a\[b \] |
---|
52 | set x |
---|
53 | } "foobar \\{ \\} a\\{b {;} \\\\ {\$a} {a\[b} \\]" |
---|
54 | |
---|
55 | proc unknown args { |
---|
56 | error "unknown failed" |
---|
57 | } |
---|
58 | |
---|
59 | test unknown-4.1 {errors in "unknown" procedure} { |
---|
60 | list [catch {non-existent a b} msg] $msg $errorCode |
---|
61 | } {1 {unknown failed} NONE} |
---|
62 | |
---|
63 | # cleanup |
---|
64 | catch {rename unknown {}} |
---|
65 | catch {rename unknown.old unknown} |
---|
66 | ::tcltest::cleanupTests |
---|
67 | return |
---|