blob: 59974cdc0ee924c83cba01672078c8a5701985a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# Commands covered: if
#
# This file contains the original set of tests for Tcl's if command.
# Since the if command is now compiled, a new set of tests covering
# the new implementation is in the file "if.test". 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.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: if-old.test,v 1.1.2.2 1998/09/24 23:59:26 stanton Exp $
if {[string compare test [info procs test]] == 1} then {source defs}
test if-old-1.1 {taking proper branch} {
set a {}
if 0 {set a 1} else {set a 2}
set a
} 2
test if-old-1.2 {taking proper branch} {
set a {}
if 1 {set a 1} else {set a 2}
set a
} 1
test if-old-1.3 {taking proper branch} {
set a {}
if 1<2 {set a 1}
set a
} 1
test if-old-1.4 {taking proper branch} {
set a {}
if 1>2 {set a 1}
set a
} {}
test if-old-1.5 {taking proper branch} {
set a {}
if 0 {set a 1} else {}
set a
} {}
test if-old-1.5 {taking proper branch} {
set a {}
if 0 {set a 1} elseif 1 {set a 2} elseif 1 {set a 3} else {set a 4}
set a
} {2}
test if-old-1.6 {taking proper branch} {
set a {}
if 0 {set a 1} elseif 0 {set a 2} elseif 1 {set a 3} else {set a 4}
set a
} {3}
test if-old-1.7 {taking proper branch} {
set a {}
if 0 {set a 1} elseif 0 {set a 2} elseif 0 {set a 3} else {set a 4}
set a
} {4}
test if-old-1.8 {taking proper branch, multiline test expr} {
set a {}
if {($tcl_platform(platform) != "foobar1") && \
($tcl_platform(platform) != "foobar2")} {set a 3} else {set a 4}
set a
} {3}
test if-old-2.1 {optional then-else args} {
set a 44
if 0 then {set a 1} elseif 0 then {set a 3} else {set a 2}
set a
} 2
test if-old-2.2 {optional then-else args} {
set a 44
if 1 then {set a 1} else {set a 2}
set a
} 1
test if-old-2.3 {optional then-else args} {
set a 44
if 0 {set a 1} else {set a 2}
set a
} 2
test if-old-2.4 {optional then-else args} {
set a 44
if 1 {set a 1} else {set a 2}
set a
} 1
test if-old-2.5 {optional then-else args} {
set a 44
if 0 then {set a 1} {set a 2}
set a
} 2
test if-old-2.6 {optional then-else args} {
set a 44
if 1 then {set a 1} {set a 2}
set a
} 1
test if-old-2.7 {optional then-else args} {
set a 44
if 0 then {set a 1} else {set a 2}
set a
} 2
test if-old-2.8 {optional then-else args} {
set a 44
if 0 then {set a 1} elseif 0 {set a 2} elseif 0 {set a 3} {set a 4}
set a
} 4
test if-old-3.1 {return value} {
if 1 then {set a 22; concat abc}
} abc
test if-old-3.2 {return value} {
if 0 then {set a 22; concat abc} elseif 1 {concat def} {concat ghi}
} def
test if-old-3.3 {return value} {
if 0 then {set a 22; concat abc} else {concat def}
} def
test if-old-3.4 {return value} {
if 0 then {set a 22; concat abc}
} {}
test if-old-3.5 {return value} {
if 0 then {set a 22; concat abc} elseif 0 {concat def}
} {}
test if-old-4.1 {error conditions} {
list [catch {if} msg] $msg
} {1 {wrong # args: no expression after "if" argument}}
test if-old-4.2 {error conditions} {
list [catch {if {[error "error in condition"]} foo} msg] $msg
} {1 {error in condition}}
test if-old-4.3 {error conditions} {
list [catch {if 2} msg] $msg
} {1 {wrong # args: no script following "2" argument}}
test if-old-4.4 {error conditions} {
list [catch {if 2 then} msg] $msg
} {1 {wrong # args: no script following "then" argument}}
test if-old-4.5 {error conditions} {
list [catch {if 2 the} msg] $msg
} {1 {invalid command name "the"}}
test if-old-4.6 {error conditions} {
list [catch {if 2 then {[error "error in then clause"]}} msg] $msg
} {1 {error in then clause}}
test if-old-4.7 {error conditions} {
list [catch {if 0 then foo elseif} msg] $msg
} {1 {wrong # args: no expression after "elseif" argument}}
test if-old-4.8 {error conditions} {
list [catch {if 0 then foo elsei} msg] $msg
} {1 {invalid command name "elsei"}}
test if-old-4.9 {error conditions} {
list [catch {if 0 then foo elseif 0 bar else} msg] $msg
} {1 {wrong # args: no script following "else" argument}}
test if-old-4.10 {error conditions} {
list [catch {if 0 then foo elseif 0 bar els} msg] $msg
} {1 {invalid command name "els"}}
test if-old-4.11 {error conditions} {
list [catch {if 0 then foo elseif 0 bar else {[error "error in else clause"]}} msg] $msg
} {1 {error in else clause}}
return
|