diff options
author | stanton <stanton> | 1999-04-16 00:46:29 (GMT) |
---|---|---|
committer | stanton <stanton> | 1999-04-16 00:46:29 (GMT) |
commit | 97464e6cba8eb0008cf2727c15718671992b913f (patch) | |
tree | ce9959f2747257d98d52ec8d18bf3b0de99b9535 /tests/result.test | |
parent | a8c96ddb94d1483a9de5e340b740cb74ef6cafa7 (diff) | |
download | tcl-97464e6cba8eb0008cf2727c15718671992b913f.zip tcl-97464e6cba8eb0008cf2727c15718671992b913f.tar.gz tcl-97464e6cba8eb0008cf2727c15718671992b913f.tar.bz2 |
merged tcl 8.1 branch back into the main trunk
Diffstat (limited to 'tests/result.test')
-rw-r--r-- | tests/result.test | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/tests/result.test b/tests/result.test new file mode 100644 index 0000000..3f77fdc --- /dev/null +++ b/tests/result.test @@ -0,0 +1,102 @@ +# This file tests the routines in tclResult.c. +# +# 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) 1997 by 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. +# +# SCCS: @(#) result.test 1.4 97/12/08 15:07:49 + +if {[lsearch [namespace children] ::tcltest] == -1} { + source [file join [pwd] [file dirname [info script]] defs.tcl] +} + +# Some tests require the testsaveresult command + +set ::tcltest::testConfig(testsaveresult) \ + [expr {[info commands testsaveresult] != {}}] + +test result-1.1 {Tcl_SaveInterpResult} {testsaveresult} { + testsaveresult small {set x 42} 0 +} {small result} +test result-1.2 {Tcl_SaveInterpResult} {testsaveresult} { + testsaveresult append {set x 42} 0 +} {append result} +test result-1.3 {Tcl_SaveInterpResult} {testsaveresult} { + testsaveresult dynamic {set x 42} 0 +} {dynamic result notCalled present} +test result-1.4 {Tcl_SaveInterpResult} {testsaveresult} { + testsaveresult object {set x 42} 0 +} {object result same} +test result-1.5 {Tcl_SaveInterpResult} {testsaveresult} { + testsaveresult small {set x 42} 1 +} {42} +test result-1.6 {Tcl_SaveInterpResult} {testsaveresult} { + testsaveresult append {set x 42} 1 +} {42} +test result-1.7 {Tcl_SaveInterpResult} {testsaveresult} { + testsaveresult dynamic {set x 42} 1 +} {42 called missing} +test result-1.8 {Tcl_SaveInterpResult} {testsaveresult} { + testsaveresult object {set x 42} 1 +} {42 different} + + +# Tcl_RestoreInterpResult is mostly tested by the previous tests except +# for the following case + +test result-2.1 {Tcl_RestoreInterpResult} {testsaveresult} { + testsaveresult append {cd _foobar} 0 +} {append result} + +# Tcl_DiscardInterpResult is mostly tested by the previous tests except +# for the following cases + +test result-3.1 {Tcl_DiscardInterpResult} {testsaveresult} { + list [catch {testsaveresult append {cd _foobar} 1} msg] $msg +} {1 {couldn't change working directory to "_foobar": no such file or directory}} +test result-3.2 {Tcl_DiscardInterpResult} {testsaveresult} { + testsaveresult free {set x 42} 1 +} {42} + +test result-4.1 {Tcl_SetObjErrorCode - one arg} {testsaveresult} { + catch {testsetobjerrorcode 1} + list [set errorCode] +} {1} +test result-4.2 {Tcl_SetObjErrorCode - two args} {testsaveresult} { + catch {testsetobjerrorcode 1 2} + list [set errorCode] +} {{1 2}} +test result-4.3 {Tcl_SetObjErrorCode - three args} {testsaveresult} { + catch {testsetobjerrorcode 1 2 3} + list [set errorCode] +} {{1 2 3}} +test result-4.4 {Tcl_SetObjErrorCode - four args} {testsaveresult} { + catch {testsetobjerrorcode 1 2 3 4} + list [set errorCode] +} {{1 2 3 4}} +test result-4.5 {Tcl_SetObjErrorCode - five args} {testsaveresult} { + catch {testsetobjerrorcode 1 2 3 4 5} + list [set errorCode] +} {{1 2 3 4 5}} + +# cleanup +::tcltest::cleanupTests +return + + + + + + + + + + + + |