diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2008-09-08 10:48:56 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2008-09-08 10:48:56 (GMT) |
commit | 15f99b3fa80902c78a829d71b3d6159e9769cac1 (patch) | |
tree | afdacac93425656228bf508da3a231932a35f5f0 /tests/appendComp.test | |
parent | 76a689aef30bb27f1e24881a16991f7209a15132 (diff) | |
download | tcl-15f99b3fa80902c78a829d71b3d6159e9769cac1.zip tcl-15f99b3fa80902c78a829d71b3d6159e9769cac1.tar.gz tcl-15f99b3fa80902c78a829d71b3d6159e9769cac1.tar.bz2 |
Simplify test bodies using tcltest2
Diffstat (limited to 'tests/appendComp.test')
-rw-r--r-- | tests/appendComp.test | 163 |
1 files changed, 83 insertions, 80 deletions
diff --git a/tests/appendComp.test b/tests/appendComp.test index dd0b4d0..e912186 100644 --- a/tests/appendComp.test +++ b/tests/appendComp.test @@ -1,17 +1,17 @@ # Commands covered: append lappend # -# This file contains a collection of tests for one or more of the Tcl -# built-in commands. Sourcing this file into Tcl runs the tests and -# generates output for errors. No output means no errors were found. +# This file contains a collection of tests for one or more of the Tcl built-in +# commands. Sourcing this file into Tcl runs the tests and generates output +# for errors. No output means no errors were found. # # Copyright (c) 1991-1993 The Regents of the University of California. # Copyright (c) 1994-1996 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. +# See the file "license.terms" for information on usage and redistribution of +# this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: appendComp.test,v 1.10 2008/07/19 22:50:38 nijtmans Exp $ +# RCS: @(#) $Id: appendComp.test,v 1.11 2008/09/08 10:49:04 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -54,24 +54,24 @@ test appendComp-2.1 {long appends} { foo } 1 -test appendComp-3.1 {append errors} { +test appendComp-3.1 {append errors} -returnCodes error -body { proc foo {} {append} - list [catch {foo} msg] $msg -} {1 {wrong # args: should be "append varName ?value ...?"}} -test appendComp-3.2 {append errors} { + foo +} -result {wrong # args: should be "append varName ?value ...?"} +test appendComp-3.2 {append errors} -returnCodes error -body { proc foo {} { set x "" append x(0) 44 } - list [catch {foo} msg] $msg -} {1 {can't set "x(0)": variable isn't array}} -test appendComp-3.3 {append errors} { + foo +} -result {can't set "x(0)": variable isn't array} +test appendComp-3.3 {append errors} -returnCodes error -body { proc foo {} { catch {unset x} append x } - list [catch {foo} msg] $msg -} {1 {can't read "x": no such variable}} + foo +} -result {can't read "x": no such variable} test appendComp-4.1 {lappend command} { proc foo {} { @@ -134,34 +134,34 @@ test appendComp-4.8 {lappend command} { } foo } "\\{ abc" -test appendComp-4.9 {lappend command} { +test appendComp-4.9 {lappend command} -returnCodes error -body { proc foo {} { set x " \{" - list [catch {lappend x abc} msg] $msg + lappend x abc } foo -} {1 {unmatched open brace in list}} -test appendComp-4.10 {lappend command} { +} -result {unmatched open brace in list} +test appendComp-4.10 {lappend command} -returnCodes error -body { proc foo {} { set x " \{" - list [catch {lappend x abc} msg] $msg + lappend x abc } foo -} {1 {unmatched open brace in list}} -test appendComp-4.11 {lappend command} { +} -result {unmatched open brace in list} +test appendComp-4.11 {lappend command} -returnCodes error -body { proc foo {} { set x "\{\{\{" - list [catch {lappend x abc} msg] $msg + lappend x abc } foo -} {1 {unmatched open brace in list}} -test appendComp-4.12 {lappend command} { +} -result {unmatched open brace in list} +test appendComp-4.12 {lappend command} -returnCodes error -body { proc foo {} { set x "x \{\{\{" - list [catch {lappend x abc} msg] $msg + lappend x abc } foo -} {1 {unmatched open brace in list}} +} -result {unmatched open brace in list} test appendComp-4.13 {lappend command} { proc foo {} { set x "x\{\{\{" @@ -229,23 +229,24 @@ test appendComp-5.1 {long lappends} { check $x 300 } ok -test appendComp-6.1 {lappend errors} { +test appendComp-6.1 {lappend errors} -returnCodes error -body { proc foo {} {lappend} - list [catch {foo} msg] $msg -} {1 {wrong # args: should be "lappend varName ?value ...?"}} -test appendComp-6.2 {lappend errors} { + foo +} -result {wrong # args: should be "lappend varName ?value ...?"} +test appendComp-6.2 {lappend errors} -returnCodes error -body { proc foo {} { set x "" lappend x(0) 44 } - list [catch {foo} msg] $msg -} {1 {can't set "x(0)": variable isn't array}} + foo +} -result {can't set "x(0)": variable isn't array} -test appendComp-7.1 {lappendComp-created var and error in trace on that var} { +test appendComp-7.1 {lappendComp-created var and error in trace on that var} -setup { + catch {rename foo ""} + catch {unset x} +} -body { proc bar {} { global x - catch {rename foo ""} - catch {unset x} trace variable x w foo proc foo {} {global x; unset x} catch {lappend x 1} @@ -256,100 +257,102 @@ test appendComp-7.1 {lappendComp-created var and error in trace on that var} { list [info exists x] [catch {set x} msg] $msg } bar -} {0 1 {can't read "x": no such variable}} -test appendComp-7.2 {lappend var triggers read trace, index var} { +} -result {0 1 {can't read "x": no such variable}} +test appendComp-7.2 {lappend var triggers read trace, index var} -setup { + catch {unset ::result} +} -body { proc bar {} { - catch {unset myvar} - catch {unset ::result} trace variable myvar r foo proc foo {args} {append ::result $args} lappend myvar a - list [catch {set ::result} msg] $msg + return $::result } bar -} {0 {myvar {} r}} -test appendComp-7.3 {lappend var triggers read trace, stack var} { +} -result {myvar {} r} +test appendComp-7.3 {lappend var triggers read trace, stack var} -setup { + catch {unset ::result} +} -body { proc bar {} { - catch {unset ::myvar} - catch {unset ::result} trace variable ::myvar r foo proc foo {args} {append ::result $args} lappend ::myvar a - list [catch {set ::result} msg] $msg + return $::result } bar -} {0 {::myvar {} r}} -test appendComp-7.4 {lappend var triggers read trace, array var} { - # The behavior of read triggers on lappend changed in 8.0 to - # not trigger them. Maybe not correct, but been there a while. +} -result {::myvar {} r} +test appendComp-7.4 {lappend var triggers read trace, array var} -setup { + catch {unset ::result} +} -body { + # The behavior of read triggers on lappend changed in 8.0 to not trigger + # them. Maybe not correct, but been there a while. proc bar {} { - catch {unset myvar} - catch {unset ::result} trace variable myvar r foo proc foo {args} {append ::result $args} lappend myvar(b) a - list [catch {set ::result} msg] $msg + return $::result } bar -} {0 {myvar b r}} -test appendComp-7.5 {lappend var triggers read trace, array var} { - # The behavior of read triggers on lappend changed in 8.0 to - # not trigger them. Maybe not correct, but been there a while. +} -result {myvar b r} +test appendComp-7.5 {lappend var triggers read trace, array var} -setup { + catch {unset ::result} +} -body { + # The behavior of read triggers on lappend changed in 8.0 to not trigger + # them. Maybe not correct, but been there a while. proc bar {} { - catch {unset myvar} - catch {unset ::result} trace variable myvar r foo proc foo {args} {append ::result $args} lappend myvar(b) a b - list [catch {set ::result} msg] $msg + return $::result } bar -} {0 {myvar b r}} -test appendComp-7.6 {lappend var triggers read trace, array var exists} { +} -result {myvar b r} +test appendComp-7.6 {lappend var triggers read trace, array var exists} -setup { + catch {unset ::result} +} -body { proc bar {} { - catch {unset myvar} - catch {unset ::result} set myvar(0) 1 trace variable myvar r foo proc foo {args} {append ::result $args} lappend myvar(b) a - list [catch {set ::result} msg] $msg + return $::result } bar -} {0 {myvar b r}} -test appendComp-7.7 {lappend var triggers read trace, array stack var} { +} -result {myvar b r} +test appendComp-7.7 {lappend var triggers read trace, array stack var} -setup { + catch {unset ::myvar} + catch {unset ::result} +} -body { proc bar {} { - catch {unset ::myvar} - catch {unset ::result} trace variable ::myvar r foo proc foo {args} {append ::result $args} lappend ::myvar(b) a - list [catch {set ::result} msg] $msg + return $::result } bar -} {0 {::myvar b r}} -test appendComp-7.8 {lappend var triggers read trace, array stack var} { +} -result {::myvar b r} +test appendComp-7.8 {lappend var triggers read trace, array stack var} -setup { + catch {unset ::myvar} + catch {unset ::result} +} -body { proc bar {} { - catch {unset ::myvar} - catch {unset ::result} trace variable ::myvar r foo proc foo {args} {append ::result $args} lappend ::myvar(b) a b - list [catch {set ::result} msg] $msg + return $::result } bar -} {0 {::myvar b r}} -test appendComp-7.9 {append var does not trigger read trace} { +} -result {::myvar b r} +test appendComp-7.9 {append var does not trigger read trace} -setup { + catch {unset ::result} +} -body { proc bar {} { - catch {unset myvar} - catch {unset ::result} trace variable myvar r foo proc foo {args} {append ::result $args} append myvar a info exists ::result } bar -} {0} +} -result {0} test appendComp-8.1 {defer error to runtime} -setup { interp create slave |