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