diff options
Diffstat (limited to 'tests/info.test')
-rw-r--r-- | tests/info.test | 233 |
1 files changed, 77 insertions, 156 deletions
diff --git a/tests/info.test b/tests/info.test index b059fc8..4522520 100644 --- a/tests/info.test +++ b/tests/info.test @@ -5,14 +5,29 @@ # generates output for errors. No output means no errors were found. # # Copyright (c) 1991-1994 The Regents of the University of California. -# Copyright (c) 1994-1995 Sun Microsystems, Inc. +# Copyright (c) 1994-1997 Sun Microsystems, Inc. +# Copyright (c) 1998-1999 by Scriptics Corporation. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: info.test,v 1.5 1998/11/11 02:39:56 welch Exp $ +# RCS: @(#) $Id: info.test,v 1.6 1999/04/16 00:47:29 stanton Exp $ + +if {[lsearch [namespace children] ::tcltest] == -1} { + source [file join [pwd] [file dirname [info script]] defs.tcl] +} + +# Set up namespaces needed to test operation of "info args", "info body", +# "info default", and "info procs" with imported procedures. + +catch {namespace delete test_ns_info1 test_ns_info2} + +namespace eval test_ns_info1 { + namespace export * + proc p {x} {return "x=$x"} + proc q {{y 27} z} {return "y=$y"} +} -if {[string compare test [info procs test]] == 1} then {source defs} test info-1.1 {info args option} { proc t1 {a bbb c} {return foo} @@ -38,6 +53,13 @@ test info-1.6 {info args option} { t1 1 2 info args t1 } {a b} +test info-1.7 {info args option} { + catch {namespace delete test_ns_info2} + namespace eval test_ns_info2 { + namespace import ::test_ns_info1::* + list [info args p] [info args q] + } +} {x {y z}} test info-2.1 {info body option} { proc t1 {} {body of t1} @@ -49,6 +71,13 @@ test info-2.2 {info body option} { test info-2.3 {info body option} { list [catch {info args set 1} msg] $msg } {1 {wrong # args: should be "info args procname"}} +test info-2.4 {info body option} { + catch {namespace delete test_ns_info2} + namespace eval test_ns_info2 { + namespace import ::test_ns_info1::* + list [info body p] [info body q] + } +} {{return "x=$x"} {return "y=$y"}} # "info cmdcount" is no longer accurate for compiled commands! The expected # result for info-3.1 used to be "3" and is now "1" since the "set"s have @@ -59,7 +88,7 @@ test info-3.1 {info cmdcount option} { set z [info cm] expr $z-$x } 1 -test info-3.2 {info body option} { +test info-3.2 {info cmdcount option} { list [catch {info cmdcount 1} msg] $msg } {1 {wrong # args: should be "info cmdcount"}} @@ -93,152 +122,17 @@ test info-4.5 {info commands option} { } {1 {wrong # args: should be "info commands ?pattern?"}} test info-5.1 {info complete option} { - info complete "" -} 1 + list [catch {info complete} msg] $msg +} {1 {wrong # args: should be "info complete command"}} test info-5.2 {info complete option} { - info complete " \n" -} 1 -test info-5.3 {info complete option} { - info complete "abc def" -} 1 -test info-5.4 {info complete option} { - info complete "a b c d e f \t\n" -} 1 -test info-5.5 {info complete option} { - info complete {a b c"d} -} 1 -test info-5.6 {info complete option} { - info complete {a b "c d" e} -} 1 -test info-5.7 {info complete option} { - info complete {a b "c d"} -} 1 -test info-5.8 {info complete option} { - info complete {a b "c d"} -} 1 -test info-5.9 {info complete option} { - info complete {a b "c d} -} 0 -test info-5.10 {info complete option} { - info complete {a b "} -} 0 -test info-5.11 {info complete option} { - info complete {a b "cd"xyz} -} 1 -test info-5.12 {info complete option} { - info complete {a b "c $d() d"} -} 1 -test info-5.13 {info complete option} { - info complete {a b "c $dd("} -} 0 -test info-5.14 {info complete option} { - info complete {a b "c \"} -} 0 -test info-5.15 {info complete option} { - info complete {a b "c [d e f]"} -} 1 -test info-5.16 {info complete option} { - info complete {a b "c [d e f] g"} -} 1 -test info-5.17 {info complete option} { - info complete {a b "c [d e f"} -} 0 -test info-5.18 {info complete option} { - info complete {a {b c d} e} -} 1 -test info-5.19 {info complete option} { - info complete {a {b c d}} -} 1 -test info-5.20 {info complete option} { - info complete "a b\{c d" -} 1 -test info-5.21 {info complete option} { - info complete "a b \{c" -} 0 -test info-5.22 {info complete option} { - info complete "a b \{c{ }" -} 0 -test info-5.23 {info complete option} { - info complete "a b {c d e}xxx" -} 1 -test info-5.24 {info complete option} { - info complete "a b {c \\\{d e}xxx" -} 1 -test info-5.25 {info complete option} { - info complete {a b [ab cd ef]} -} 1 -test info-5.26 {info complete option} { - info complete {a b x[ab][cd][ef] gh} -} 1 -test info-5.27 {info complete option} { - info complete {a b x[ab][cd[ef] gh} -} 0 -test info-5.28 {info complete option} { - info complete {a b x[ gh} -} 0 -test info-5.29 {info complete option} { - info complete {[]]]} + info complete abc } 1 -test info-5.30 {info complete option} { - info complete {abc x$yyy} -} 1 -test info-5.31 {info complete option} { - info complete "abc x\${abc\[\\d} xyz" -} 1 -test info-5.32 {info complete option} { - info complete "abc x\$\{ xyz" -} 0 -test info-5.33 {info complete option} { - info complete {word $a(xyz)} -} 1 -test info-5.34 {info complete option} { - info complete {word $a(} -} 0 -test info-5.35 {info complete option} { - info complete "set a \\\n" -} 0 -test info-5.36 {info complete option} { - info complete "set a \\n " -} 1 -test info-5.37 {info complete option} { - info complete "set a \\" -} 1 -test info-5.38 {info complete option} { - info complete "foo \\\n\{" -} 0 -test info-5.39 {info complete option} { - info complete " # \{" -} 1 -test info-5.40 {info complete option} { - info complete "foo bar;# \{" -} 1 -test info-5.41 {info complete option} { - info complete "a\nb\n# \{\n# \{\nc\n" -} 1 -test info-5.42 {info complete option} { - info complete "#Incomplete comment\\\n" -} 0 -test info-5.43 {info complete option} { - info complete "#Incomplete comment\\\nBut now it's complete.\n" -} 1 -test info-5.44 {info complete option} { - info complete "# Complete comment\\\\\n" -} 1 -test info-5.45 {info complete option} { - info complete "abc\\\n def" -} 1 -test info-5.46 {info complete option} { - info complete "abc\\\n " -} 1 -test info-5.47 {info complete option} { - info complete "abc\\\n" +test info-5.2 {info complete option} { + info complete "\{abcd " } 0 -test info-5.48 {info complete option} { - info complete "set x [binary format H 00]; puts hi" +test info-5.3 {info complete option} { + info complete {# Comment should be complete command} } 1 -test info-5.49 {info complete option} { - info complete "set x [binary format H 00]; \{" -} 0 test info-6.1 {info default option} { proc t1 {a b {c d} {e "long default value"}} {} @@ -288,6 +182,13 @@ test info-6.10 {info default option} { proc t1 {{a 18} b} {} list [catch {info default t1 a a} msg] $msg } {1 {couldn't store default value in variable "a"}} +test info-6.11 {info default option} { + catch {namespace delete test_ns_info2} + namespace eval test_ns_info2 { + namespace import ::test_ns_info1::* + list [info default p x foo] $foo [info default q y bar] $bar + } +} {0 {} 1 27} catch {unset a} test info-7.1 {info exists option} { @@ -416,7 +317,7 @@ test info-11.1 {info loaded option} { } {1 {wrong # args: should be "info loaded ?interp?"}} test info-11.2 {info loaded option} { list [catch {info loaded {}}] [catch {info loaded gorp} msg] $msg -} {0 1 {couldn't find slave interpreter named "gorp"}} +} {0 1 {could not find interpreter "gorp"}} test info-12.1 {info locals option} { set a 22 @@ -499,31 +400,34 @@ catch {rename _tt2 {}} test info-15.3 {info procs option} { list [catch {info procs 2 3} msg] $msg } {1 {wrong # args: should be "info procs ?pattern?"}} - -set self info.test -if {$tcl_platform(os) == "Win32s"} { - set self info~1.tes -} +test info-15.4 {info procs option} { + catch {namespace delete test_ns_info2} + namespace eval test_ns_info2 { + namespace import ::test_ns_info1::* + proc r {} {} + list [info procs] [info procs p*] + } +} {{p q r} p} test info-16.1 {info script option} { list [catch {info script x} msg] $msg } {1 {wrong # args: should be "info script"}} test info-16.2 {info script option} { file tail [info sc] -} $self +} "info.test" removeFile gorp.info makeFile "info script\n" gorp.info test info-16.3 {info script option} { list [source gorp.info] [file tail [info script]] -} [list gorp.info $self] +} [list gorp.info info.test] test info-16.4 {resetting "info script" after errors} { catch {source ~_nobody_/foo} file tail [info script] -} $self +} "info.test" test info-16.5 {resetting "info script" after errors} { catch {source _nonexistent_} file tail [info script] -} $self +} "info.test" removeFile gorp.info test info-17.1 {info sharedlibextension option} { @@ -594,3 +498,20 @@ test info-20.4 {miscellaneous error conditions} { test info-20.5 {miscellaneous error conditions} { list [catch {info s} msg] $msg } {1 {ambiguous option "s": must be args, body, cmdcount, commands, complete, default, exists, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}} + +# cleanup +catch {namespace delete test_ns_info1 test_ns_info2} +::tcltest::cleanupTests +return + + + + + + + + + + + + |