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 © 1991-1993 The Regents of the University of California.
8# Copyright © 1994 Sun Microsystems, Inc.
9# Copyright © 1998-1999 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
14if {"::tcltest" ni [namespace children]} {
15    package require tcltest 2.5
16    namespace import -force ::tcltest::*
17}
18
19unset -nocomplain x
20catch {rename unknown unknown.old}
21
22test unknown-1.1 {non-existent "unknown" command} {
23    list [catch {_non-existent_ foo bar} msg] $msg
24} {1 {invalid command name "_non-existent_"}}
25
26proc unknown {args} {
27    global x
28    set x $args
29}
30test unknown-2.1 {calling "unknown" command} {
31    foobar x y z
32    set x
33} {foobar x y z}
34test unknown-2.2 {calling "unknown" command with lots of args} {
35    foobar 1 2 3 4 5 6 7
36    set x
37} {foobar 1 2 3 4 5 6 7}
38test unknown-2.3 {calling "unknown" command with lots of args} {
39    foobar 1 2 3 4 5 6 7 8
40    set x
41} {foobar 1 2 3 4 5 6 7 8}
42test unknown-2.4 {calling "unknown" command with lots of args} {
43    foobar 1 2 3 4 5 6 7 8 9
44    set x
45} {foobar 1 2 3 4 5 6 7 8 9}
46
47test unknown-3.1 {argument quoting in calls to "unknown"} {
48    foobar \{ \} a\{b \; "\\" \$a a\[b \]
49    set x
50} "foobar \\{ \\} a\\{b {;} \\\\ {\$a} {a\[b} \\]"
51
52proc unknown args {
53    error "unknown failed"
54}
55test unknown-4.1 {errors in "unknown" procedure} {
56    list [catch {non-existent a b} msg] $msg $errorCode
57} {1 {unknown failed} NONE}
58
59# cleanup
60catch {rename unknown {}}
61catch {rename unknown.old unknown}
62cleanupTests
63return
64
65# Local Variables:
66# mode: tcl
67# End:
68