os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/if-old.test
Update contrib.
3 # This file contains the original set of tests for Tcl's if command.
4 # Since the if command is now compiled, a new set of tests covering
5 # the new implementation is in the file "if.test". Sourcing this file
6 # into Tcl runs the tests and generates output for errors.
7 # No output means no errors were found.
9 # Copyright (c) 1991-1993 The Regents of the University of California.
10 # Copyright (c) 1994-1996 Sun Microsystems, Inc.
11 # Copyright (c) 1998-1999 by Scriptics Corporation.
13 # See the file "license.terms" for information on usage and redistribution
14 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
16 # RCS: @(#) $Id: if-old.test,v 1.5.24.1 2003/03/27 13:11:12 dkf Exp $
18 if {[lsearch [namespace children] ::tcltest] == -1} {
19 package require tcltest
20 namespace import -force ::tcltest::*
23 test if-old-1.1 {taking proper branch} {
25 if 0 {set a 1} else {set a 2}
28 test if-old-1.2 {taking proper branch} {
30 if 1 {set a 1} else {set a 2}
33 test if-old-1.3 {taking proper branch} {
38 test if-old-1.4 {taking proper branch} {
43 test if-old-1.5 {taking proper branch} {
45 if 0 {set a 1} else {}
48 test if-old-1.6 {taking proper branch} {
50 if 0 {set a 1} elseif 1 {set a 2} elseif 1 {set a 3} else {set a 4}
53 test if-old-1.7 {taking proper branch} {
55 if 0 {set a 1} elseif 0 {set a 2} elseif 1 {set a 3} else {set a 4}
58 test if-old-1.8 {taking proper branch} {
60 if 0 {set a 1} elseif 0 {set a 2} elseif 0 {set a 3} else {set a 4}
63 test if-old-1.9 {taking proper branch, multiline test expr} {
65 if {($tcl_platform(platform) != "foobar1") && \
66 ($tcl_platform(platform) != "foobar2")} {set a 3} else {set a 4}
71 test if-old-2.1 {optional then-else args} {
73 if 0 then {set a 1} elseif 0 then {set a 3} else {set a 2}
76 test if-old-2.2 {optional then-else args} {
78 if 1 then {set a 1} else {set a 2}
81 test if-old-2.3 {optional then-else args} {
83 if 0 {set a 1} else {set a 2}
86 test if-old-2.4 {optional then-else args} {
88 if 1 {set a 1} else {set a 2}
91 test if-old-2.5 {optional then-else args} {
93 if 0 then {set a 1} {set a 2}
96 test if-old-2.6 {optional then-else args} {
98 if 1 then {set a 1} {set a 2}
101 test if-old-2.7 {optional then-else args} {
103 if 0 then {set a 1} else {set a 2}
106 test if-old-2.8 {optional then-else args} {
108 if 0 then {set a 1} elseif 0 {set a 2} elseif 0 {set a 3} {set a 4}
112 test if-old-3.1 {return value} {
113 if 1 then {set a 22; concat abc}
115 test if-old-3.2 {return value} {
116 if 0 then {set a 22; concat abc} elseif 1 {concat def} {concat ghi}
118 test if-old-3.3 {return value} {
119 if 0 then {set a 22; concat abc} else {concat def}
121 test if-old-3.4 {return value} {
122 if 0 then {set a 22; concat abc}
124 test if-old-3.5 {return value} {
125 if 0 then {set a 22; concat abc} elseif 0 {concat def}
128 test if-old-4.1 {error conditions} {
129 list [catch {if} msg] $msg
130 } {1 {wrong # args: no expression after "if" argument}}
131 test if-old-4.2 {error conditions} {
132 list [catch {if {[error "error in condition"]} foo} msg] $msg
133 } {1 {error in condition}}
134 test if-old-4.3 {error conditions} {
135 list [catch {if 2} msg] $msg
136 } {1 {wrong # args: no script following "2" argument}}
137 test if-old-4.4 {error conditions} {
138 list [catch {if 2 then} msg] $msg
139 } {1 {wrong # args: no script following "then" argument}}
140 test if-old-4.5 {error conditions} {
141 list [catch {if 2 the} msg] $msg
142 } {1 {invalid command name "the"}}
143 test if-old-4.6 {error conditions} {
144 list [catch {if 2 then {[error "error in then clause"]}} msg] $msg
145 } {1 {error in then clause}}
146 test if-old-4.7 {error conditions} {
147 list [catch {if 0 then foo elseif} msg] $msg
148 } {1 {wrong # args: no expression after "elseif" argument}}
149 test if-old-4.8 {error conditions} {
150 list [catch {if 0 then foo elsei} msg] $msg
151 } {1 {invalid command name "elsei"}}
152 test if-old-4.9 {error conditions} {
153 list [catch {if 0 then foo elseif 0 bar else} msg] $msg
154 } {1 {wrong # args: no script following "else" argument}}
155 test if-old-4.10 {error conditions} {
156 list [catch {if 0 then foo elseif 0 bar els} msg] $msg
157 } {1 {invalid command name "els"}}
158 test if-old-4.11 {error conditions} {
159 list [catch {if 0 then foo elseif 0 bar else {[error "error in else clause"]}} msg] $msg
160 } {1 {error in else clause}}
163 ::tcltest::cleanupTests