os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/basic.test
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 # This file contains tests for the tclBasic.c source file. Tests appear in
     2 # the same order as the C code that they test. The set of tests is
     3 # currently incomplete since it currently includes only new tests for
     4 # code changed for the addition of Tcl namespaces. Other variable-
     5 # related tests appear in several other test files including
     6 # assocd.test, cmdInfo.test, eval.test, expr.test, interp.test,
     7 # and trace.test.
     8 #
     9 # Sourcing this file into Tcl runs the tests and generates output for
    10 # errors. No output means no errors were found.
    11 #
    12 # Copyright (c) 1997 Sun Microsystems, Inc.
    13 # Copyright (c) 1998-1999 by Scriptics Corporation.
    14 #
    15 # See the file "license.terms" for information on usage and redistribution
    16 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    17 #
    18 # RCS: @(#) $Id: basic.test,v 1.25.2.7 2005/03/18 16:33:43 dgp Exp $
    19 #
    20 
    21 package require tcltest 2
    22 namespace import -force ::tcltest::*
    23 
    24 testConstraint testcmdtoken [llength [info commands testcmdtoken]]
    25 testConstraint testcmdtrace [llength [info commands testcmdtrace]]
    26 testConstraint testcreatecommand [llength [info commands testcreatecommand]]
    27 testConstraint testevalex [llength [info commands testevalex]]
    28 testConstraint exec [llength [info commands exec]]
    29 
    30 # This variable needs to be changed when the major or minor version number for
    31 # Tcl changes.
    32 set tclvers 8.4
    33 
    34 catch {namespace delete test_ns_basic}
    35 catch {interp delete test_interp}
    36 catch {rename p ""}
    37 catch {rename q ""}
    38 catch {rename cmd ""}
    39 catch {unset x}
    40 
    41 test basic-1.1 {Tcl_CreateInterp, creates interp's global namespace} {
    42     catch {interp delete test_interp}
    43     interp create test_interp
    44     interp eval test_interp {
    45         namespace eval test_ns_basic {
    46             proc p {} {
    47                 return [namespace current]
    48             }
    49         }
    50     }
    51     list [interp eval test_interp {test_ns_basic::p}] \
    52          [interp delete test_interp]
    53 } {::test_ns_basic {}}
    54 
    55 test basic-2.1 {TclHideUnsafeCommands} {emptyTest} {
    56 } {}
    57 
    58 test basic-3.1 {Tcl_CallWhenDeleted: see dcall.test} {emptyTest} {
    59 } {}
    60 
    61 test basic-4.1 {Tcl_DontCallWhenDeleted: see dcall.test} {emptyTest} {
    62 } {}
    63 
    64 test basic-5.1 {Tcl_SetAssocData: see assoc.test} {emptyTest} {
    65 } {}
    66 
    67 test basic-6.1 {Tcl_DeleteAssocData: see assoc.test} {emptyTest} {
    68 } {}
    69 
    70 test basic-7.1 {Tcl_GetAssocData: see assoc.test} {emptyTest} {
    71 } {}
    72 
    73 test basic-8.1 {Tcl_InterpDeleted} {emptyTest} {
    74 } {}
    75 
    76 test basic-9.1 {Tcl_DeleteInterp: see interp.test} {emptyTest} {
    77 } {}
    78 
    79 test basic-10.1 {DeleteInterpProc, destroys interp's global namespace} {
    80     catch {interp delete test_interp}
    81     interp create test_interp
    82     interp eval test_interp {
    83         namespace eval test_ns_basic {
    84             namespace export p
    85             proc p {} {
    86                 return [namespace current]
    87             }
    88         }
    89         namespace eval test_ns_2 {
    90             namespace import ::test_ns_basic::p
    91             variable v 27
    92             proc q {} {
    93                 variable v
    94                 return "[p] $v"
    95             }
    96         }
    97     }
    98     list [interp eval test_interp {test_ns_2::q}] \
    99          [interp eval test_interp {namespace delete ::}] \
   100          [catch {interp eval test_interp {set a 123}} msg] $msg \
   101          [interp delete test_interp]
   102 } {{::test_ns_basic 27} {} 1 {invalid command name "set"} {}}
   103 
   104 test basic-11.1 {HiddenCmdsDeleteProc, invalidate cached refs to deleted hidden cmd} {
   105     catch {interp delete test_interp}
   106     interp create test_interp
   107     interp eval test_interp {
   108         proc p {} {
   109             return 27
   110         }
   111     }
   112     interp alias {} localP test_interp p
   113     list [interp eval test_interp {p}] \
   114          [localP] \
   115          [test_interp hide p] \
   116          [catch {localP} msg] $msg \
   117          [interp delete test_interp] \
   118          [catch {localP} msg] $msg
   119 } {27 27 {} 1 {invalid command name "p"} {} 1 {invalid command name "localP"}}
   120 
   121 # NB: More tests about hide/expose are found in interp.test
   122 
   123 test basic-12.1 {Tcl_HideCommand, names of hidden cmds can't have namespace qualifiers} {
   124     catch {interp delete test_interp}
   125     interp create test_interp
   126     interp eval test_interp {
   127         namespace eval test_ns_basic {
   128             proc p {} {
   129                 return [namespace current]
   130             }
   131         }
   132     }
   133     list [catch {test_interp hide test_ns_basic::p x} msg] $msg \
   134 	 [catch {test_interp hide x test_ns_basic::p} msg1] $msg1 \
   135          [interp delete test_interp]
   136 } {1 {can only hide global namespace commands (use rename then hide)} 1 {cannot use namespace qualifiers in hidden command token (rename)} {}}
   137 
   138 test basic-12.2 {Tcl_HideCommand, a hidden cmd remembers its containing namespace} {
   139     catch {namespace delete test_ns_basic}
   140     catch {rename cmd ""}
   141     proc cmd {} {   ;# note that this is global
   142         return [namespace current]
   143     }
   144     namespace eval test_ns_basic {
   145         proc hideCmd {} {
   146             interp hide {} cmd
   147         }
   148         proc exposeCmd {} {
   149             interp expose {} cmd
   150         }
   151         proc callCmd {} {
   152             cmd
   153         }
   154     }
   155     list [test_ns_basic::callCmd] \
   156          [test_ns_basic::hideCmd] \
   157          [catch {cmd} msg] $msg \
   158          [test_ns_basic::exposeCmd] \
   159          [test_ns_basic::callCmd] \
   160          [namespace delete test_ns_basic]
   161 } {:: {} 1 {invalid command name "cmd"} {} :: {}}
   162 
   163 test basic-13.1 {Tcl_ExposeCommand, a command stays in the global namespace and can not go to another namespace} {
   164     catch {namespace delete test_ns_basic}
   165     catch {rename cmd ""}
   166     proc cmd {} {   ;# note that this is global
   167         return [namespace current]
   168     }
   169     namespace eval test_ns_basic {
   170         proc hideCmd {} {
   171             interp hide {} cmd
   172         }
   173         proc exposeCmdFailing {} {
   174             interp expose {} cmd ::test_ns_basic::newCmd
   175         }
   176         proc exposeCmdWorkAround {} {
   177             interp expose {} cmd;
   178 	    rename cmd ::test_ns_basic::newCmd;
   179         }
   180         proc callCmd {} {
   181             cmd
   182         }
   183     }
   184     list [test_ns_basic::callCmd] \
   185          [test_ns_basic::hideCmd] \
   186          [catch {test_ns_basic::exposeCmdFailing} msg] $msg \
   187          [test_ns_basic::exposeCmdWorkAround] \
   188          [test_ns_basic::newCmd] \
   189          [namespace delete test_ns_basic]
   190 } {:: {} 1 {can not expose to a namespace (use expose to toplevel, then rename)} {} ::test_ns_basic {}}
   191 test basic-13.2 {Tcl_ExposeCommand, invalidate cached refs to cmd now being exposed} {
   192     catch {rename p ""}
   193     catch {rename cmd ""}
   194     proc p {} {
   195         cmd
   196     }
   197     proc cmd {} {
   198         return 42
   199     }
   200     list [p] \
   201          [interp hide {} cmd] \
   202          [proc cmd {} {return Hello}] \
   203          [cmd] \
   204          [rename cmd ""] \
   205          [interp expose {} cmd] \
   206          [p]
   207 } {42 {} {} Hello {} {} 42}
   208 
   209 test basic-14.1 {Tcl_CreateCommand, new cmd goes into a namespace specified in its name, if any} {testcreatecommand} {
   210     catch {eval namespace delete [namespace children :: test_ns_*]}
   211     list [testcreatecommand create] \
   212 	 [test_ns_basic::createdcommand] \
   213 	 [testcreatecommand delete]
   214 } {{} {CreatedCommandProc in ::test_ns_basic} {}}
   215 test basic-14.2 {Tcl_CreateCommand, namespace code ignore single ":"s in middle or end of names} {testcreatecommand} {
   216     catch {eval namespace delete [namespace children :: test_ns_*]}
   217     catch {rename value:at: ""}
   218     list [testcreatecommand create2] \
   219 	 [value:at:] \
   220 	 [testcreatecommand delete2]
   221 } {{} {CreatedCommandProc2 in ::} {}}
   222 
   223 test basic-15.1 {Tcl_CreateObjCommand, new cmd goes into a namespace specified in its name, if any} {
   224     catch {eval namespace delete [namespace children :: test_ns_*]}
   225     namespace eval test_ns_basic {}
   226     proc test_ns_basic::cmd {} {  ;# proc requires that ns already exist
   227         return [namespace current]
   228     }
   229     list [test_ns_basic::cmd] \
   230          [namespace delete test_ns_basic]
   231 } {::test_ns_basic {}}
   232 
   233 test basic-16.1 {TclInvokeStringCommand} {emptyTest} {
   234 } {}
   235 
   236 test basic-17.1 {TclInvokeObjCommand} {emptyTest} {
   237 } {}
   238 
   239 test basic-18.1 {TclRenameCommand, name of existing cmd can have namespace qualifiers} {
   240     catch {eval namespace delete [namespace children :: test_ns_*]}
   241     catch {rename cmd ""}
   242     namespace eval test_ns_basic {
   243         proc p {} {
   244             return "p in [namespace current]"
   245         }
   246     }
   247     list [test_ns_basic::p] \
   248          [rename test_ns_basic::p test_ns_basic::q] \
   249          [test_ns_basic::q] 
   250 } {{p in ::test_ns_basic} {} {p in ::test_ns_basic}}
   251 test basic-18.2 {TclRenameCommand, existing cmd must be found} {
   252     catch {eval namespace delete [namespace children :: test_ns_*]}
   253     list [catch {rename test_ns_basic::p test_ns_basic::q} msg] $msg
   254 } {1 {can't rename "test_ns_basic::p": command doesn't exist}}
   255 test basic-18.3 {TclRenameCommand, delete cmd if new name is empty} {
   256     catch {eval namespace delete [namespace children :: test_ns_*]}
   257     namespace eval test_ns_basic {
   258         proc p {} {
   259             return "p in [namespace current]"
   260         }
   261     }
   262     list [info commands test_ns_basic::*] \
   263          [rename test_ns_basic::p ""] \
   264          [info commands test_ns_basic::*]
   265 } {::test_ns_basic::p {} {}}
   266 test basic-18.4 {TclRenameCommand, bad new name} {
   267     catch {eval namespace delete [namespace children :: test_ns_*]}
   268     namespace eval test_ns_basic {
   269         proc p {} {
   270             return "p in [namespace current]"
   271         }
   272     }
   273     rename test_ns_basic::p :::george::martha
   274 } {}
   275 test basic-18.5 {TclRenameCommand, new name must not already exist} {
   276     namespace eval test_ns_basic {
   277         proc q {} {
   278             return 42
   279         }
   280     }
   281     list [catch {rename test_ns_basic::q :::george::martha} msg] $msg
   282 } {1 {can't rename to ":::george::martha": command already exists}}
   283 test basic-18.6 {TclRenameCommand, check for command shadowing by newly renamed cmd} {
   284     catch {eval namespace delete [namespace children :: test_ns_*]}
   285     catch {rename p ""}
   286     catch {rename q ""}
   287     proc p {} {
   288         return "p in [namespace current]"
   289     }
   290     proc q {} {
   291         return "q in [namespace current]"
   292     }
   293     namespace eval test_ns_basic {
   294         proc callP {} {
   295             p
   296         }
   297     }
   298     list [test_ns_basic::callP] \
   299          [rename q test_ns_basic::p] \
   300          [test_ns_basic::callP]
   301 } {{p in ::} {} {q in ::test_ns_basic}}
   302 
   303 test basic-19.1 {Tcl_SetCommandInfo} {emptyTest} {
   304 } {}
   305 
   306 test basic-20.1 {Tcl_GetCommandInfo, names for commands created inside namespaces} {testcmdtoken} {
   307     catch {eval namespace delete [namespace children :: test_ns_*]}
   308     catch {rename p ""}
   309     catch {rename q ""}
   310     catch {unset x}
   311     set x [namespace eval test_ns_basic::test_ns_basic2 {
   312         # the following creates a cmd in the global namespace
   313         testcmdtoken create p
   314     }]
   315     list [testcmdtoken name $x] \
   316          [rename ::p q] \
   317          [testcmdtoken name $x]
   318 } {{p ::p} {} {q ::q}}
   319 test basic-20.2 {Tcl_GetCommandInfo, names for commands created outside namespaces} {testcmdtoken} {
   320     catch {rename q ""}
   321     set x [testcmdtoken create test_ns_basic::test_ns_basic2::p]
   322     list [testcmdtoken name $x] \
   323          [rename test_ns_basic::test_ns_basic2::p q] \
   324          [testcmdtoken name $x]
   325 } {{p ::test_ns_basic::test_ns_basic2::p} {} {q ::q}}
   326 
   327 test basic-21.1 {Tcl_GetCommandName} {emptyTest} {
   328 } {}
   329 
   330 test basic-22.1 {Tcl_GetCommandFullName} {
   331     catch {eval namespace delete [namespace children :: test_ns_*]}
   332     namespace eval test_ns_basic1 {
   333         namespace export cmd*
   334         proc cmd1 {} {}
   335         proc cmd2 {} {}
   336     }
   337     namespace eval test_ns_basic2 {
   338         namespace export *
   339         namespace import ::test_ns_basic1::*
   340         proc p {} {}
   341     }
   342     namespace eval test_ns_basic3 {
   343         namespace import ::test_ns_basic2::*
   344         proc q {} {}
   345         list [namespace which -command foreach] \
   346              [namespace which -command q] \
   347              [namespace which -command p] \
   348              [namespace which -command cmd1] \
   349              [namespace which -command ::test_ns_basic2::cmd2]
   350     }
   351 } {::foreach ::test_ns_basic3::q ::test_ns_basic3::p ::test_ns_basic3::cmd1 ::test_ns_basic2::cmd2}
   352 
   353 test basic-23.1 {Tcl_DeleteCommand} {emptyTest} {
   354 } {}
   355 
   356 test basic-24.1 {Tcl_DeleteCommandFromToken, invalidate all compiled code if cmd has compile proc} {
   357     catch {interp delete test_interp}
   358     catch {unset x}
   359     interp create test_interp
   360     interp eval test_interp {
   361         proc useSet {} {
   362             return [set a 123]
   363         }
   364     }
   365     set x [interp eval test_interp {useSet}]
   366     interp eval test_interp {
   367         rename set ""
   368         proc set {args} {
   369             return "set called with $args"
   370         }
   371     }
   372     list $x \
   373          [interp eval test_interp {useSet}] \
   374          [interp delete test_interp]
   375 } {123 {set called with a 123} {}}
   376 test basic-24.2 {Tcl_DeleteCommandFromToken, deleting commands changes command epoch} {
   377     catch {eval namespace delete [namespace children :: test_ns_*]}
   378     catch {rename p ""}
   379     proc p {} {
   380         return "global p"
   381     }
   382     namespace eval test_ns_basic {
   383         proc p {} {
   384             return "namespace p"
   385         }
   386         proc callP {} {
   387             p
   388         }
   389     }
   390     list [test_ns_basic::callP] \
   391          [rename test_ns_basic::p ""] \
   392          [test_ns_basic::callP]
   393 } {{namespace p} {} {global p}}
   394 test basic-24.3 {Tcl_DeleteCommandFromToken, delete imported cmds that refer to a deleted cmd} {
   395     catch {eval namespace delete [namespace children :: test_ns_*]}
   396     catch {rename p ""}
   397     namespace eval test_ns_basic {
   398         namespace export p
   399         proc p {} {return 42}
   400     }
   401     namespace eval test_ns_basic2 {
   402         namespace import ::test_ns_basic::*
   403         proc callP {} {
   404             p
   405         }
   406     }
   407     list [test_ns_basic2::callP] \
   408          [info commands test_ns_basic2::*] \
   409          [rename test_ns_basic::p ""] \
   410          [catch {test_ns_basic2::callP} msg] $msg \
   411          [info commands test_ns_basic2::*]
   412 } {42 {::test_ns_basic2::callP ::test_ns_basic2::p} {} 1 {invalid command name "p"} ::test_ns_basic2::callP}
   413 
   414 test basic-25.1 {TclCleanupCommand} {emptyTest} {
   415 } {}
   416 
   417 test basic-26.1 {Tcl_EvalObj: preserve object while evaling it} {
   418     # If object isn't preserved, errorInfo would be set to
   419     # "foo\n    while executing\n\"garbage bytes\"" because the object's
   420     # string would have been freed, leaving garbage bytes for the error
   421     # message.
   422 
   423     proc bgerror {args} {set ::x $::errorInfo}
   424     set fName [makeFile {} test1]
   425     set f [open $fName w]
   426     fileevent $f writable "fileevent $f writable {}; error foo"
   427     set x {}
   428     vwait x
   429     close $f
   430     removeFile test1
   431     rename bgerror {}
   432     set x
   433 } "foo\n    while executing\n\"error foo\""
   434 
   435 test basic-26.2 {Tcl_EvalObjEx, pure-list branch: preserve "objv"} {
   436     #
   437     # Follow the pure-list branch in a manner that
   438     #   a - the pure-list internal rep is destroyed by shimmering
   439     #   b - the command returns an error
   440     # As the error code in Tcl_EvalObjv accesses the list elements, this will
   441     # cause a segfault if [Bug 1119369] has not been fixed.
   442     #
   443 
   444     set SRC [list foo 1] ;# pure-list command 
   445     proc foo str {
   446 	# Shimmer pure-list to cmdName, cleanup and error
   447 	proc $::SRC {} {}; $::SRC
   448 	error "BAD CALL"
   449     }
   450     catch {eval $SRC}
   451 } 1
   452 
   453 test basic-27.1 {Tcl_ExprLong} {emptyTest} {
   454 } {}
   455 
   456 test basic-28.1 {Tcl_ExprDouble} {emptyTest} {
   457 } {}
   458 
   459 test basic-29.1 {Tcl_ExprBoolean} {emptyTest} {
   460 } {}
   461 
   462 test basic-30.1 {Tcl_ExprLongObj} {emptyTest} {
   463 } {}
   464 
   465 test basic-31.1 {Tcl_ExprDoubleObj} {emptyTest} {
   466 } {}
   467 
   468 test basic-32.1 {Tcl_ExprBooleanObj} {emptyTest} {
   469 } {}
   470 
   471 test basic-33.1 {TclInvoke} {emptyTest} {
   472 } {}
   473 
   474 test basic-34.1 {TclGlobalInvoke} {emptyTest} {
   475 } {}
   476 
   477 test basic-35.1 {TclObjInvokeGlobal} {emptyTest} {
   478 } {}
   479 
   480 test basic-36.1 {TclObjInvoke, lookup of "unknown" command} {
   481     catch {eval namespace delete [namespace children :: test_ns_*]}
   482     catch {interp delete test_interp}
   483     interp create test_interp
   484     interp eval test_interp {
   485         proc unknown {args} {
   486             return "global unknown"
   487         }
   488         namespace eval test_ns_basic {
   489             proc unknown {args} {
   490                 return "namespace unknown"
   491             }
   492         }
   493     }
   494     list [interp alias test_interp newAlias test_interp doesntExist] \
   495          [catch {interp eval test_interp {newAlias}} msg] $msg \
   496          [interp delete test_interp]
   497 } {newAlias 0 {global unknown} {}}
   498 
   499 test basic-37.1 {Tcl_ExprString: see expr.test} {emptyTest} {
   500 } {}
   501 
   502 test basic-38.1 {Tcl_ExprObj} {emptyTest} {
   503 } {}
   504 
   505 test basic-39.1 {Tcl_CreateTrace, correct command and argc/argv arguments of trace proc} {testcmdtrace} {
   506     testcmdtrace tracetest {set stuff [expr 14 + 16]}
   507 } {{expr 14 + 16} {expr 14 + 16} {set stuff [expr 14 + 16]} {set stuff 30}}
   508 test basic-39.2 {Tcl_CreateTrace, correct command and argc/argv arguments of trace proc} {testcmdtrace} {
   509     testcmdtrace tracetest {set stuff [info tclversion]}
   510 } [list {info tclversion} {info tclversion} {set stuff [info tclversion]} "set stuff $tclvers"]
   511 test basic-39.3 {Tcl_CreateTrace, correct command and argc/argv arguments of trace proc} {testcmdtrace} {
   512     testcmdtrace deletetest {set stuff [info tclversion]}
   513 } $tclvers
   514 test basic-39.4 {Tcl_CreateTrace, check that tracing doesn't cause memory faults} {testcmdtrace} {
   515     # Note that the proc call is the same as the variable name, and that
   516     # the call can be direct or indirect by way of another procedure
   517     proc tracer {args} {}
   518     proc tracedLoop {level} {
   519 	incr level
   520 	tracer
   521 	foreach tracer [expr {$level==1 ? {1 2} : {}}] {tracedLoop $level}
   522     }
   523     testcmdtrace tracetest {tracedLoop 0}
   524 } {{tracedLoop 0} {tracedLoop 0} {incr level} {incr level} tracer {tracer} {expr {$level==1 ? {1 2} : {}}} {expr {$level==1 ? {1 2} : {}}} {foreach tracer [expr {$level==1 ? {1 2} : {}}] {tracedLoop $level}} {foreach tracer {1 2} {tracedLoop $level}} {tracedLoop $level} {tracedLoop 1} {incr level} {incr level} tracer {tracer} {expr {$level==1 ? {1 2} : {}}} {expr {$level==1 ? {1 2} : {}}} {foreach tracer [expr {$level==1 ? {1 2} : {}}] {tracedLoop $level}} {foreach tracer {} {tracedLoop $level}} {tracedLoop $level} {tracedLoop 1} {incr level} {incr level} tracer {tracer} {expr {$level==1 ? {1 2} : {}}} {expr {$level==1 ? {1 2} : {}}} {foreach tracer [expr {$level==1 ? {1 2} : {}}] {tracedLoop $level}} {foreach tracer {} {tracedLoop $level}}}
   525 catch {rename tracer {}}
   526 catch {rename tracedLoop {}}
   527 
   528 test basic-39.5 {Tcl_CreateObjTrace, status return TCL_ERROR} {testcmdtrace} {
   529     proc Error { args } { error "Shouldn't get here" }
   530     set x 1;
   531     list [catch {testcmdtrace resulttest {Error $x}} result] [set result]
   532 } {1 {Error $x}}
   533 
   534 test basic-39.6 {Tcl_CreateObjTrace, status return TCL_RETURN} {testcmdtrace} {
   535     proc Return { args } { error "Shouldn't get here" }
   536     set x 1;
   537     list [catch {testcmdtrace resulttest {Return $x}} result] [set result]
   538 } {2 {}}
   539 
   540 test basic-39.7 {Tcl_CreateObjTrace, status return TCL_BREAK} {testcmdtrace} {
   541     proc Break { args } { error "Shouldn't get here" }
   542     set x 1;
   543     list [catch {testcmdtrace resulttest {Break $x}} result] [set result]
   544 } {3 {}}
   545 
   546 test basic-39.8 {Tcl_CreateObjTrace, status return TCL_CONTINUE} {testcmdtrace} {
   547     proc Continue { args } { error "Shouldn't get here" }
   548     set x 1;
   549     list [catch {testcmdtrace resulttest {Continue $x}} result] [set result]
   550 } {4 {}}
   551 
   552 test basic-39.9 {Tcl_CreateObjTrace, status return unknown} {testcmdtrace} {
   553     proc OtherStatus { args } { error "Shouldn't get here" }
   554     set x 1;
   555     list [catch {testcmdtrace resulttest {OtherStatus $x}} result] [set result]
   556 } {6 {}}
   557 
   558 test basic-39.10 {Tcl_CreateTrace, correct level interpretation} {testcmdtrace} {
   559     proc foo {} {uplevel 1 bar}
   560     proc bar {} {uplevel 1 grok}
   561     proc grok {} {uplevel 1 spock}
   562     proc spock {} {uplevel 1 fascinating}
   563     proc fascinating {} {}
   564     testcmdtrace leveltest {foo}
   565 } {foo {foo} {uplevel 1 bar} {uplevel 1 bar} bar {bar} {uplevel 1 grok} {uplevel 1 grok}}
   566 
   567 test basic-40.1 {Tcl_DeleteTrace} {emptyTest} {
   568     # the above tests have tested Tcl_DeleteTrace
   569 } {}
   570 
   571 test basic-41.1 {Tcl_AddErrorInfo} {emptyTest} {
   572 } {}
   573 
   574 test basic-42.1 {Tcl_AddObjErrorInfo} {emptyTest} {
   575 } {}
   576 
   577 test basic-43.1 {Tcl_VarEval} {emptyTest} {
   578 } {}
   579 
   580 test basic-44.1 {Tcl_GlobalEval} {emptyTest} {
   581 } {}
   582 
   583 test basic-45.1 {Tcl_SetRecursionLimit: see interp.test} {emptyTest} {
   584 } {}
   585 
   586 test basic-46.1 {Tcl_AllowExceptions: exception return not allowed} {stdio} {
   587     catch {close $f}
   588     set res [catch {
   589 	set f [open |[list [interpreter]] w+]
   590 	fconfigure $f -buffering line
   591 	puts $f {fconfigure stdout -buffering line}
   592 	puts $f continue
   593 	puts $f {puts $errorInfo}
   594 	puts $f {puts DONE}
   595 	set newMsg {}
   596 	set msg {}
   597 	while {$newMsg != "DONE"} {
   598 	    set newMsg [gets $f]
   599 	    append msg "${newMsg}\n"
   600 	}
   601 	close $f
   602     } error]
   603     list $res $msg
   604 } {1 {invoked "continue" outside of a loop
   605     while executing
   606 "continue"
   607 DONE
   608 }}
   609 
   610 test basic-46.2 {Tcl_AllowExceptions: exception return not allowed} -setup {
   611     set fName [makeFile {
   612 	puts hello
   613 	break
   614     } BREAKtest]
   615 } -constraints {
   616     exec
   617 } -body {
   618     exec [interpreter] $fName
   619 } -cleanup {
   620     removeFile BREAKtest
   621 } -returnCodes error -match glob -result {hello
   622 invoked "break" outside of a loop
   623     while executing
   624 "break"
   625     (file "*BREAKtest" line 3)}    
   626 
   627 test basic-46.3 {Tcl_AllowExceptions: exception return not allowed} -setup {
   628     set fName [makeFile {
   629 	interp alias {} patch {} info patchlevel
   630 	patch
   631 	break
   632     } BREAKtest]
   633 } -constraints {
   634     exec
   635 } -body {
   636     exec [interpreter] $fName
   637 } -cleanup {
   638     removeFile BREAKtest
   639 } -returnCodes error -match glob -result {invoked "break" outside of a loop
   640     while executing
   641 "break"
   642     (file "*BREAKtest" line 4)}    
   643 
   644 test basic-46.4 {Tcl_AllowExceptions: exception return not allowed} -setup {
   645     set fName [makeFile {
   646 	foo [set a 1] [break]
   647     } BREAKtest]
   648 } -constraints {
   649     exec
   650 } -body {
   651     exec [interpreter] $fName
   652 } -cleanup {
   653     removeFile BREAKtest
   654 } -returnCodes error -match glob -result {invoked "break" outside of a loop
   655     while executing*
   656 "foo \[set a 1] \[break]"
   657     (file "*BREAKtest" line 2)}
   658 
   659 test basic-46.5 {Tcl_AllowExceptions: exception return not allowed} -setup {
   660     set fName [makeFile {
   661 	return -code return
   662     } BREAKtest]
   663 } -constraints {
   664     exec
   665 } -body {
   666     exec [interpreter] $fName
   667 } -cleanup {
   668     removeFile BREAKtest
   669 } -returnCodes error -match glob -result {command returned bad code: 2
   670     while executing
   671 "return -code return"
   672     (file "*BREAKtest" line 2)}
   673 
   674 test basic-47.1 {Tcl_EvalEx: check for missing close-bracket} -body {
   675     subst {a[set b [format cd]}
   676 } -returnCodes error -result {missing close-bracket}
   677 
   678 test basic-49.1 {Tcl_EvalEx: verify TCL_EVAL_GLOBAL operation} testevalex {
   679     set ::x global
   680     namespace eval ns {
   681         variable x namespace
   682         testevalex {set x changed} global
   683         set ::result [list $::x $x]
   684     } 
   685     namespace delete ns
   686     set ::result
   687 } {changed namespace}
   688 test basic-49.2 {Tcl_EvalEx: verify TCL_EVAL_GLOBAL operation} testevalex {
   689     set ::x global
   690     namespace eval ns {
   691         variable x namespace
   692         testevalex {set ::context $x} global
   693     }
   694     namespace delete ns
   695     set ::context
   696 } {global}
   697 
   698 # cleanup
   699 catch {eval namespace delete [namespace children :: test_ns_*]}
   700 catch {namespace delete george}
   701 catch {interp delete test_interp}
   702 catch {rename p ""}
   703 catch {rename q ""}
   704 catch {rename cmd ""}
   705 catch {rename value:at: ""}
   706 catch {unset x}
   707 ::tcltest::cleanupTests
   708 return