os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/result.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 # This file tests the routines in tclResult.c.
     2 #
     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.
     6 #
     7 # Copyright (c) 1997 by Sun Microsystems, Inc.
     8 # Copyright (c) 1998-1999 by Scriptics Corporation.
     9 #
    10 # See the file "license.terms" for information on usage and redistribution
    11 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    12 #
    13 # SCCS: @(#) result.test 1.4 97/12/08 15:07:49
    14 
    15 if {[lsearch [namespace children] ::tcltest] == -1} {
    16     package require tcltest 2
    17     namespace import -force ::tcltest::*
    18 }
    19 
    20 # Some tests require the testsaveresult command
    21 
    22 ::tcltest::testConstraint testsaveresult \
    23 	[expr {[info commands testsaveresult] != {}}]
    24 
    25 test result-1.1 {Tcl_SaveInterpResult} {testsaveresult} {
    26     testsaveresult small {set x 42} 0
    27 } {small result}
    28 test result-1.2 {Tcl_SaveInterpResult} {testsaveresult} {
    29     testsaveresult append {set x 42} 0
    30 } {append result}
    31 test result-1.3 {Tcl_SaveInterpResult} {testsaveresult} {
    32     testsaveresult dynamic {set x 42} 0
    33 } {dynamic result notCalled present}
    34 test result-1.4 {Tcl_SaveInterpResult} {testsaveresult} {
    35     testsaveresult object {set x 42} 0
    36 } {object result same}
    37 test result-1.5 {Tcl_SaveInterpResult} {testsaveresult} {
    38     testsaveresult small {set x 42} 1
    39 } {42}
    40 test result-1.6 {Tcl_SaveInterpResult} {testsaveresult} {
    41     testsaveresult append {set x 42} 1
    42 } {42}
    43 test result-1.7 {Tcl_SaveInterpResult} {testsaveresult} {
    44     testsaveresult dynamic {set x 42} 1
    45 } {42 called missing}
    46 test result-1.8 {Tcl_SaveInterpResult} {testsaveresult} {
    47     testsaveresult object {set x 42} 1
    48 } {42 different}
    49 
    50 
    51 # Tcl_RestoreInterpResult is mostly tested by the previous tests except
    52 # for the following case
    53 
    54 test result-2.1 {Tcl_RestoreInterpResult} {testsaveresult} {
    55     testsaveresult append {cd _foobar} 0
    56 } {append result}
    57 
    58 # Tcl_DiscardInterpResult is mostly tested by the previous tests except
    59 # for the following cases
    60 
    61 test result-3.1 {Tcl_DiscardInterpResult} {testsaveresult} {
    62     list [catch {testsaveresult append {cd _foobar} 1} msg] $msg
    63 } {1 {couldn't change working directory to "_foobar": no such file or directory}}
    64 test result-3.2 {Tcl_DiscardInterpResult} {testsaveresult} {
    65     testsaveresult free {set x 42} 1
    66 } {42}
    67 
    68 ::tcltest::testConstraint testsetobjerrorcode \
    69 	[expr {[info commands testsetobjerrorcode] != {}}]
    70 
    71 test result-4.1 {Tcl_SetObjErrorCode - one arg} {testsetobjerrorcode} {
    72     catch {testsetobjerrorcode 1}
    73     list [set errorCode]
    74 } {1}
    75 test result-4.2 {Tcl_SetObjErrorCode - two args} {testsetobjerrorcode} {
    76     catch {testsetobjerrorcode 1 2}
    77     list [set errorCode]
    78 } {{1 2}}
    79 test result-4.3 {Tcl_SetObjErrorCode - three args} {testsetobjerrorcode} {
    80     catch {testsetobjerrorcode 1 2 3}
    81     list [set errorCode]
    82 } {{1 2 3}}
    83 test result-4.4 {Tcl_SetObjErrorCode - four args} {testsetobjerrorcode} {
    84     catch {testsetobjerrorcode 1 2 3 4}
    85     list [set errorCode]
    86 } {{1 2 3 4}}
    87 test result-4.5 {Tcl_SetObjErrorCode - five args} {testsetobjerrorcode} {
    88     catch {testsetobjerrorcode 1 2 3 4 5}
    89     list [set errorCode]
    90 } {{1 2 3 4 5}}
    91 
    92 ::tcltest::testConstraint testseterrorcode \
    93 	[expr {[info commands testseterrorcode] != {}}]
    94 
    95 test result-5.1 {Tcl_SetErrorCode - one arg} testseterrorcode {
    96     catch {testseterrorcode 1}
    97     set errorCode
    98 } 1
    99 test result-5.2 {Tcl_SetErrorCode - one arg, list quoting} testseterrorcode {
   100     catch {testseterrorcode {a b}}
   101     set errorCode
   102 } {{a b}}
   103 test result-5.3 {Tcl_SetErrorCode - one arg, list quoting} testseterrorcode {
   104     catch {testseterrorcode \{}
   105     llength $errorCode
   106 } 1
   107 test result-5.4 {Tcl_SetErrorCode - two args, list quoting} testseterrorcode {
   108     catch {testseterrorcode {a b} c}
   109     set errorCode
   110 } {{a b} c}
   111 
   112 # cleanup
   113 ::tcltest::cleanupTests
   114 return
   115 
   116 
   117 
   118 
   119 
   120 
   121 
   122 
   123 
   124 
   125 
   126