os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/uplevel.test
First public contribution.
1 # Commands covered: uplevel
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: uplevel.test,v 1.7 2002/08/08 18:19:37 msofer Exp $
16 if {[lsearch [namespace children] ::tcltest] == -1} {
17 package require tcltest
18 namespace import -force ::tcltest::*
25 proc newset {name value} {
26 uplevel set $name $value
27 uplevel 1 {uplevel 1 {set xyz 22}}
30 test uplevel-1.1 {simple operation} {
34 test uplevel-1.2 {command is another uplevel command} {
61 test uplevel-2.1 {relative and absolute uplevel} {set a} 333
62 test uplevel-2.2 {relative and absolute uplevel} {set a1} 444
63 test uplevel-2.3 {relative and absolute uplevel} {set b} 111
64 test uplevel-2.4 {relative and absolute uplevel} {set b1} 222
65 test uplevel-2.5 {relative and absolute uplevel} {set x} 555
66 test uplevel-2.6 {relative and absolute uplevel} {set y} 666
68 test uplevel-3.1 {uplevel to same level} {
73 test uplevel-3.2 {uplevel to same level} {
77 test uplevel-3.3 {uplevel to same level} {
79 proc a1 {} {set y 55; uplevel 0 set y 66; return $y}
82 test uplevel-3.4 {uplevel to same level} {
84 proc a1 {} {set y 55; uplevel #1 set y}
88 test uplevel-4.1 {error: non-existent level} {
89 list [catch c1 msg] $msg
90 } {1 {bad level "#2"}}
91 test uplevel-4.2 {error: non-existent level} {
92 proc c2 {} {uplevel 3 {set a b}}
93 list [catch c2 msg] $msg
95 test uplevel-4.3 {error: not enough args} {
96 list [catch uplevel msg] $msg
97 } {1 {wrong # args: should be "uplevel ?level? command ?arg ...?"}}
98 test uplevel-4.4 {error: not enough args} {
99 proc upBug {} {uplevel 1}
100 list [catch upBug msg] $msg
101 } {1 {wrong # args: should be "uplevel ?level? command ?arg ...?"}}
112 test uplevel-5.1 {info level} {set x} 1
113 test uplevel-5.2 {info level} {set y} a3
116 proc set args {return ::ns1}
121 test uplevel-6.1 {uplevel and shadowed cmds} {
122 set res [namespace eval ns1 a2]
123 lappend res [namespace eval ns2 a2]
124 lappend res [namespace eval ns1 a2]
125 namespace eval ns1 {rename set {}}
126 lappend res [namespace eval ns1 a2]
127 } {::ns1 :: ::ns1 ::}
131 ::tcltest::cleanupTests