Debian Codegraph @

tests/parseExpr.test

raw
1 # This file contains a collection of tests for the procedures in the
2 # file tclCompExpr.c. Sourcing this file into Tcl runs the tests and
3 # generates output for errors. No output means no errors were found.
4 #
5 # Copyright (c) 1997 Sun Microsystems, Inc.
6 # Copyright (c) 1998-1999 by Scriptics Corporation.
7 #
8 # See the file "license.terms" for information on usage and redistribution
9 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
11 if {"::tcltest" ni [namespace children]} {
12 package require tcltest 2.5
13 namespace import -force ::tcltest::*
14 }
15
16 ::tcltest::loadTestedCommands
17 catch [list package require -exact Tcltest [info patchlevel]]
18
19 # Note that the Tcl expression parser (tclCompExpr.c) does not check
20 # the semantic validity of the expressions it parses. It does not check,
21 # for example, that a math function actually exists, or that the operands
22 # of "<<" are integers.
23
24 testConstraint testexprparser [llength [info commands testexprparser]]
25 testConstraint testbytestring [llength [info commands testbytestring]]
26
27 # Big test for correct ordering of data in [expr]
28
29 proc testIEEE {} {
30 variable ieeeValues
31 binary scan [binary format dd -1.0 1.0] c* c
32 switch -exact -- $c {
33 {0 0 0 0 0 0 -16 -65 0 0 0 0 0 0 -16 63} {
34 # little endian
35 binary scan \x00\x00\x00\x00\x00\x00\xf0\xff d \
36 ieeeValues(-Infinity)
37 binary scan \x00\x00\x00\x00\x00\x00\xf0\xbf d \
38 ieeeValues(-Normal)
39 binary scan \x00\x00\x00\x00\x00\x00\x08\x80 d \
40 ieeeValues(-Subnormal)
41 binary scan \x00\x00\x00\x00\x00\x00\x00\x80 d \
42 ieeeValues(-0)
43 binary scan \x00\x00\x00\x00\x00\x00\x00\x00 d \
44 ieeeValues(+0)
45 binary scan \x00\x00\x00\x00\x00\x00\x08\x00 d \
46 ieeeValues(+Subnormal)
47 binary scan \x00\x00\x00\x00\x00\x00\xf0\x3f d \
48 ieeeValues(+Normal)
49 binary scan \x00\x00\x00\x00\x00\x00\xf0\x7f d \
50 ieeeValues(+Infinity)
51 binary scan \x00\x00\x00\x00\x00\x00\xf8\x7f d \
52 ieeeValues(NaN)
53 set ieeeValues(littleEndian) 1
54 return 1
55 }
56 {-65 -16 0 0 0 0 0 0 63 -16 0 0 0 0 0 0} {
57 binary scan \xff\xf0\x00\x00\x00\x00\x00\x00 d \
58 ieeeValues(-Infinity)
59 binary scan \xbf\xf0\x00\x00\x00\x00\x00\x00 d \
60 ieeeValues(-Normal)
61 binary scan \x80\x08\x00\x00\x00\x00\x00\x00 d \
62 ieeeValues(-Subnormal)
63 binary scan \x80\x00\x00\x00\x00\x00\x00\x00 d \
64 ieeeValues(-0)
65 binary scan \x00\x00\x00\x00\x00\x00\x00\x00 d \
66 ieeeValues(+0)
67 binary scan \x00\x08\x00\x00\x00\x00\x00\x00 d \
68 ieeeValues(+Subnormal)
69 binary scan \x3f\xf0\x00\x00\x00\x00\x00\x00 d \
70 ieeeValues(+Normal)
71 binary scan \x7f\xf0\x00\x00\x00\x00\x00\x00 d \
72 ieeeValues(+Infinity)
73 binary scan \x7f\xf8\x00\x00\x00\x00\x00\x00 d \
74 ieeeValues(NaN)
75 set ieeeValues(littleEndian) 0
76 return 1
77 }
78 default {
79 return 0
80 }
81 }
82 }
83 testConstraint ieeeFloatingPoint [testIEEE]
84
85 ######################################################################
86
87 test parseExpr-1.1 {Tcl_ParseExpr procedure, computing string length} {testexprparser testbytestring} {
88 testexprparser [testbytestring "1+2\0 +3"] -1
89 } {- {} 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
90 test parseExpr-1.2 {Tcl_ParseExpr procedure, computing string length} testexprparser {
91 testexprparser "1 + 2" -1
92 } {- {} 0 subexpr {1 + 2} 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
93 test parseExpr-1.3 {Tcl_ParseExpr procedure, error getting initial lexeme} testexprparser {
94 testexprparser 12345678901234567890 -1
95 } {- {} 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
96 test parseExpr-1.4 {Tcl_ParseExpr procedure, error in conditional expression} \
97 -constraints testexprparser -body {
98 testexprparser {foo+} -1
99 } -match glob -returnCodes error -result *
100 test parseExpr-1.5 {Tcl_ParseExpr procedure, lexemes after the expression} -constraints testexprparser -body {
101 testexprparser {1+2 345} -1
102 } -returnCodes error -match glob -result *
103
104 test parseExpr-2.1 {ParseCondExpr procedure, valid test subexpr} testexprparser {
105 testexprparser {2>3? 1 : 0} -1
106 } {- {} 0 subexpr {2>3? 1 : 0} 11 operator ? 0 subexpr 2>3 5 operator > 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
107 test parseExpr-2.2 {ParseCondExpr procedure, error in test subexpr} \
108 -constraints testexprparser -body {
109 testexprparser {0 || foo} -1
110 } -match glob -returnCodes error -result *
111 test parseExpr-2.3 {ParseCondExpr procedure, next lexeme isn't "?"} testexprparser {
112 testexprparser {1+2} -1
113 } {- {} 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
114 test parseExpr-2.4 {ParseCondExpr procedure, next lexeme is "?"} testexprparser {
115 testexprparser {1+2 ? 3 : 4} -1
116 } {- {} 0 subexpr {1+2 ? 3 : 4} 11 operator ? 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
117 test parseExpr-2.5 {ParseCondExpr procedure, bad lexeme after "?"} testexprparser {
118 testexprparser {1+2 ? 12345678901234567890 : 0} -1
119 } {- {} 0 subexpr {1+2 ? 12345678901234567890 : 0} 11 operator ? 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 subexpr 0 1 text 0 0 {}}
120 test parseExpr-2.6 {ParseCondExpr procedure, valid "then" subexpression} testexprparser {
121 testexprparser {1? 3 : 4} -1
122 } {- {} 0 subexpr {1? 3 : 4} 7 operator ? 0 subexpr 1 1 text 1 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
123 test parseExpr-2.7 {ParseCondExpr procedure, error in "then" subexpression} \
124 -constraints testexprparser -body {
125 testexprparser {1? fred : martha} -1
126 } -match glob -returnCodes error -result *
127 test parseExpr-2.8 {ParseCondExpr procedure, lexeme after "then" subexpr isn't ":"} -constraints testexprparser -body {
128 testexprparser {1? 2 martha 3} -1
129 } -returnCodes error -match glob -result *
130 test parseExpr-2.9 {ParseCondExpr procedure, valid "else" subexpression} testexprparser {
131 testexprparser {27||3? 3 : 4&&9} -1
132 } {- {} 0 subexpr {27||3? 3 : 4&&9} 15 operator ? 0 subexpr 27||3 5 operator || 0 subexpr 27 1 text 27 0 subexpr 3 1 text 3 0 subexpr 3 1 text 3 0 subexpr 4&&9 5 operator && 0 subexpr 4 1 text 4 0 subexpr 9 1 text 9 0 {}}
133 test parseExpr-2.10 {ParseCondExpr procedure, error in "else" subexpression} \
134 -constraints testexprparser -body {
135 testexprparser {1? 2 : martha} -1
136 } -match glob -returnCodes error -result *
137
138 test parseExpr-3.1 {ParseLorExpr procedure, valid logical and subexpr} testexprparser {
139 testexprparser {1&&2 || 3} -1
140 } {- {} 0 subexpr {1&&2 || 3} 9 operator || 0 subexpr 1&&2 5 operator && 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
141 test parseExpr-3.2 {ParseLorExpr procedure, error in logical and subexpr} \
142 -constraints testexprparser -body {
143 testexprparser {1&&foo || 3} -1
144 } -match glob -returnCodes error -result *
145 test parseExpr-3.3 {ParseLorExpr procedure, next lexeme isn't "||"} testexprparser {
146 testexprparser {1&&2? 1 : 0} -1
147 } {- {} 0 subexpr {1&&2? 1 : 0} 11 operator ? 0 subexpr 1&&2 5 operator && 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
148 test parseExpr-3.4 {ParseLorExpr procedure, next lexeme is "||"} testexprparser {
149 testexprparser {1&&2 || 3} -1
150 } {- {} 0 subexpr {1&&2 || 3} 9 operator || 0 subexpr 1&&2 5 operator && 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
151 test parseExpr-3.5 {ParseLorExpr procedure, bad lexeme after "||"} testexprparser {
152 testexprparser {1&&2 || 12345678901234567890} -1
153 } {- {} 0 subexpr {1&&2 || 12345678901234567890} 9 operator || 0 subexpr 1&&2 5 operator && 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
154 test parseExpr-3.6 {ParseLorExpr procedure, valid RHS subexpression} testexprparser {
155 testexprparser {1&&2 || 3 || 4} -1
156 } {- {} 0 subexpr {1&&2 || 3 || 4} 13 operator || 0 subexpr {1&&2 || 3} 9 operator || 0 subexpr 1&&2 5 operator && 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
157 test parseExpr-3.7 {ParseLorExpr procedure, error in RHS subexpression} \
158 -constraints testexprparser -body {
159 testexprparser {1&&2 || 3 || martha} -1
160 } -match glob -returnCodes error -result *
161
162 test parseExpr-4.1 {ParseLandExpr procedure, valid LHS "|" subexpr} testexprparser {
163 testexprparser {1|2 && 3} -1
164 } {- {} 0 subexpr {1|2 && 3} 9 operator && 0 subexpr 1|2 5 operator | 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
165 test parseExpr-4.2 {ParseLandExpr procedure, error in LHS "|" subexpr} \
166 -constraints testexprparser -body {
167 testexprparser {1&&foo && 3} -1
168 } -match glob -returnCodes error -result *
169 test parseExpr-4.3 {ParseLandExpr procedure, next lexeme isn't "&&"} testexprparser {
170 testexprparser {1|2? 1 : 0} -1
171 } {- {} 0 subexpr {1|2? 1 : 0} 11 operator ? 0 subexpr 1|2 5 operator | 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
172 test parseExpr-4.4 {ParseLandExpr procedure, next lexeme is "&&"} testexprparser {
173 testexprparser {1|2 && 3} -1
174 } {- {} 0 subexpr {1|2 && 3} 9 operator && 0 subexpr 1|2 5 operator | 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
175 test parseExpr-4.5 {ParseLandExpr procedure, bad lexeme after "&&"} testexprparser {
176 testexprparser {1|2 && 12345678901234567890} -1
177 } {- {} 0 subexpr {1|2 && 12345678901234567890} 9 operator && 0 subexpr 1|2 5 operator | 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
178 test parseExpr-4.6 {ParseLandExpr procedure, valid RHS subexpression} testexprparser {
179 testexprparser {1|2 && 3 && 4} -1
180 } {- {} 0 subexpr {1|2 && 3 && 4} 13 operator && 0 subexpr {1|2 && 3} 9 operator && 0 subexpr 1|2 5 operator | 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
181 test parseExpr-4.7 {ParseLandExpr procedure, error in RHS subexpression} \
182 -constraints testexprparser -body {
183 testexprparser {1|2 && 3 && martha} -1
184 } -match glob -returnCodes error -result *
185
186 test parseExpr-5.1 {ParseBitOrExpr procedure, valid LHS "^" subexpr} testexprparser {
187 testexprparser {1^2 | 3} -1
188 } {- {} 0 subexpr {1^2 | 3} 9 operator | 0 subexpr 1^2 5 operator ^ 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
189 test parseExpr-5.2 {ParseBitOrExpr procedure, error in LHS "^" subexpr} \
190 -constraints testexprparser -body {
191 testexprparser {1|foo | 3} -1
192 } -match glob -returnCodes error -result *
193 test parseExpr-5.3 {ParseBitOrExpr procedure, next lexeme isn't "|"} testexprparser {
194 testexprparser {1^2? 1 : 0} -1
195 } {- {} 0 subexpr {1^2? 1 : 0} 11 operator ? 0 subexpr 1^2 5 operator ^ 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
196 test parseExpr-5.4 {ParseBitOrExpr procedure, next lexeme is "|"} testexprparser {
197 testexprparser {1^2 | 3} -1
198 } {- {} 0 subexpr {1^2 | 3} 9 operator | 0 subexpr 1^2 5 operator ^ 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
199 test parseExpr-5.5 {ParseBitOrExpr procedure, bad lexeme after "|"} testexprparser {
200 testexprparser {1^2 | 12345678901234567890} -1
201 } {- {} 0 subexpr {1^2 | 12345678901234567890} 9 operator | 0 subexpr 1^2 5 operator ^ 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
202 test parseExpr-5.6 {ParseBitOrExpr procedure, valid RHS subexpression} testexprparser {
203 testexprparser {1^2 | 3 | 4} -1
204 } {- {} 0 subexpr {1^2 | 3 | 4} 13 operator | 0 subexpr {1^2 | 3} 9 operator | 0 subexpr 1^2 5 operator ^ 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
205 test parseExpr-5.7 {ParseBitOrExpr procedure, error in RHS subexpression} \
206 -constraints testexprparser -body {
207 testexprparser {1^2 | 3 | martha} -1
208 } -match glob -returnCodes error -result *
209
210 test parseExpr-6.1 {ParseBitXorExpr procedure, valid LHS "&" subexpr} testexprparser {
211 testexprparser {1&2 ^ 3} -1
212 } {- {} 0 subexpr {1&2 ^ 3} 9 operator ^ 0 subexpr 1&2 5 operator & 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
213 test parseExpr-6.2 {ParseBitXorExpr procedure, error in LHS "&" subexpr} \
214 -constraints testexprparser -body {
215 testexprparser {1^foo ^ 3} -1
216 } -match glob -returnCodes error -result *
217 test parseExpr-6.3 {ParseBitXorExpr procedure, next lexeme isn't "^"} testexprparser {
218 testexprparser {1&2? 1 : 0} -1
219 } {- {} 0 subexpr {1&2? 1 : 0} 11 operator ? 0 subexpr 1&2 5 operator & 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
220 test parseExpr-6.4 {ParseBitXorExpr procedure, next lexeme is "^"} testexprparser {
221 testexprparser {1&2 ^ 3} -1
222 } {- {} 0 subexpr {1&2 ^ 3} 9 operator ^ 0 subexpr 1&2 5 operator & 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
223 test parseExpr-6.5 {ParseBitXorExpr procedure, bad lexeme after "^"} testexprparser {
224 testexprparser {1&2 ^ 12345678901234567890} -1
225 } {- {} 0 subexpr {1&2 ^ 12345678901234567890} 9 operator ^ 0 subexpr 1&2 5 operator & 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
226 test parseExpr-6.6 {ParseBitXorExpr procedure, valid RHS subexpression} testexprparser {
227 testexprparser {1&2 ^ 3 ^ 4} -1
228 } {- {} 0 subexpr {1&2 ^ 3 ^ 4} 13 operator ^ 0 subexpr {1&2 ^ 3} 9 operator ^ 0 subexpr 1&2 5 operator & 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
229 test parseExpr-6.7 {ParseBitXorExpr procedure, error in RHS subexpression} \
230 -constraints testexprparser -body {
231 testexprparser {1&2 ^ 3 ^ martha} -1
232 } -match glob -returnCodes error -result *
233
234 test parseExpr-7.1 {ParseBitAndExpr procedure, valid LHS equality subexpr} testexprparser {
235 testexprparser {1==2 & 3} -1
236 } {- {} 0 subexpr {1==2 & 3} 9 operator & 0 subexpr 1==2 5 operator == 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
237 test parseExpr-7.2 {ParseBitAndExpr procedure, error in LHS equality subexpr} \
238 -constraints testexprparser -body {
239 testexprparser {1!=foo & 3} -1
240 } -match glob -returnCodes error -result *
241 test parseExpr-7.3 {ParseBitAndExpr procedure, next lexeme isn't "&"} testexprparser {
242 testexprparser {1==2? 1 : 0} -1
243 } {- {} 0 subexpr {1==2? 1 : 0} 11 operator ? 0 subexpr 1==2 5 operator == 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
244 test parseExpr-7.4 {ParseBitAndExpr procedure, next lexeme is "&"} testexprparser {
245 testexprparser {1>2 & 3} -1
246 } {- {} 0 subexpr {1>2 & 3} 9 operator & 0 subexpr 1>2 5 operator > 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
247 test parseExpr-7.5 {ParseBitAndExpr procedure, bad lexeme after "&"} {testexprparser} {
248 testexprparser {1==2 & 12345678901234567890} -1
249 } {- {} 0 subexpr {1==2 & 12345678901234567890} 9 operator & 0 subexpr 1==2 5 operator == 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
250 test parseExpr-7.6 {ParseBitAndExpr procedure, valid RHS subexpression} testexprparser {
251 testexprparser {1<2 & 3 & 4} -1
252 } {- {} 0 subexpr {1<2 & 3 & 4} 13 operator & 0 subexpr {1<2 & 3} 9 operator & 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
253 test parseExpr-7.7 {ParseBitAndExpr procedure, error in RHS subexpression} \
254 -constraints testexprparser -body {
255 testexprparser {1==2 & 3>2 & martha} -1
256 } -match glob -returnCodes error -result *
257
258 test parseExpr-8.1 {ParseEqualityExpr procedure, valid LHS relational subexpr} testexprparser {
259 testexprparser {1<2 == 3} -1
260 } {- {} 0 subexpr {1<2 == 3} 9 operator == 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
261 test parseExpr-8.2 {ParseEqualityExpr procedure, error in LHS relational subexpr} \
262 -constraints testexprparser -body {
263 testexprparser {1>=foo == 3} -1
264 } -match glob -returnCodes error -result *
265 test parseExpr-8.3 {ParseEqualityExpr procedure, next lexeme isn't "==" or "!="} testexprparser {
266 testexprparser {1<2? 1 : 0} -1
267 } {- {} 0 subexpr {1<2? 1 : 0} 11 operator ? 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
268 test parseExpr-8.4 {ParseEqualityExpr procedure, next lexeme is "==" or "!="} testexprparser {
269 testexprparser {1<2 == 3} -1
270 } {- {} 0 subexpr {1<2 == 3} 9 operator == 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
271 test parseExpr-8.5 {ParseEqualityExpr procedure, next lexeme is "==" or "!="} testexprparser {
272 testexprparser {1<2 != 3} -1
273 } {- {} 0 subexpr {1<2 != 3} 9 operator != 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
274 test parseExpr-8.6 {ParseEqualityExpr procedure, bad lexeme after "==" or "!="} testexprparser {
275 testexprparser {1<2 == 12345678901234567890} -1
276 } {- {} 0 subexpr {1<2 == 12345678901234567890} 9 operator == 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
277 test parseExpr-8.7 {ParseEqualityExpr procedure, valid RHS subexpression} testexprparser {
278 testexprparser {1<2 == 3 == 4} -1
279 } {- {} 0 subexpr {1<2 == 3 == 4} 13 operator == 0 subexpr {1<2 == 3} 9 operator == 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
280 test parseExpr-8.8 {ParseEqualityExpr procedure, error in RHS subexpression} \
281 -constraints testexprparser -body {
282 testexprparser {1<2 == 3 != martha} -1
283 } -match glob -returnCodes error -result *
284
285 test parseExpr-9.1 {ParseRelationalExpr procedure, valid LHS shift subexpr} testexprparser {
286 testexprparser {1<<2 < 3} -1
287 } {- {} 0 subexpr {1<<2 < 3} 9 operator < 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
288 test parseExpr-9.2 {ParseRelationalExpr procedure, error in LHS shift subexpr} \
289 -constraints testexprparser -body {
290 testexprparser {1>=foo < 3} -1
291 } -match glob -returnCodes error -result *
292 test parseExpr-9.3 {ParseRelationalExpr procedure, next lexeme isn't relational op} testexprparser {
293 testexprparser {1<<2? 1 : 0} -1
294 } {- {} 0 subexpr {1<<2? 1 : 0} 11 operator ? 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
295 test parseExpr-9.4 {ParseRelationalExpr procedure, next lexeme is relational op} testexprparser {
296 testexprparser {1<<2 < 3} -1
297 } {- {} 0 subexpr {1<<2 < 3} 9 operator < 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
298 test parseExpr-9.5 {ParseRelationalExpr procedure, next lexeme is relational op} testexprparser {
299 testexprparser {1>>2 > 3} -1
300 } {- {} 0 subexpr {1>>2 > 3} 9 operator > 0 subexpr 1>>2 5 operator >> 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
301 test parseExpr-9.6 {ParseRelationalExpr procedure, next lexeme is relational op} testexprparser {
302 testexprparser {1<<2 <= 3} -1
303 } {- {} 0 subexpr {1<<2 <= 3} 9 operator <= 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
304 test parseExpr-9.7 {ParseRelationalExpr procedure, next lexeme is relational op} testexprparser {
305 testexprparser {1<<2 >= 3} -1
306 } {- {} 0 subexpr {1<<2 >= 3} 9 operator >= 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
307 test parseExpr-9.8 {ParseRelationalExpr procedure, bad lexeme after relational op} testexprparser {
308 testexprparser {1<<2 < 12345678901234567890} -1
309 } {- {} 0 subexpr {1<<2 < 12345678901234567890} 9 operator < 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
310 test parseExpr-9.9 {ParseRelationalExpr procedure, valid RHS subexpression} testexprparser {
311 testexprparser {1<<2 < 3 < 4} -1
312 } {- {} 0 subexpr {1<<2 < 3 < 4} 13 operator < 0 subexpr {1<<2 < 3} 9 operator < 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
313 test parseExpr-9.10 {ParseRelationalExpr procedure, error in RHS subexpression} \
314 -constraints testexprparser -body {
315 testexprparser {1<<2 < 3 > martha} -1
316 } -match glob -returnCodes error -result *
317
318 test parseExpr-10.1 {ParseShiftExpr procedure, valid LHS add subexpr} testexprparser {
319 testexprparser {1+2 << 3} -1
320 } {- {} 0 subexpr {1+2 << 3} 9 operator << 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
321 test parseExpr-10.2 {ParseShiftExpr procedure, error in LHS add subexpr} \
322 -constraints testexprparser -body {
323 testexprparser {1-foo << 3} -1
324 } -match glob -returnCodes error -result *
325 test parseExpr-10.3 {ParseShiftExpr procedure, next lexeme isn't "<<" or ">>"} testexprparser {
326 testexprparser {1+2? 1 : 0} -1
327 } {- {} 0 subexpr {1+2? 1 : 0} 11 operator ? 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
328 test parseExpr-10.4 {ParseShiftExpr procedure, next lexeme is "<<" or ">>"} testexprparser {
329 testexprparser {1+2 << 3} -1
330 } {- {} 0 subexpr {1+2 << 3} 9 operator << 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
331 test parseExpr-10.5 {ParseShiftExpr procedure, next lexeme is "<<" or ">>"} testexprparser {
332 testexprparser {1+2 >> 3} -1
333 } {- {} 0 subexpr {1+2 >> 3} 9 operator >> 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
334 test parseExpr-10.6 {ParseShiftExpr procedure, bad lexeme after "<<" or ">>"} testexprparser {
335 testexprparser {1+2 << 12345678901234567890} -1
336 } {- {} 0 subexpr {1+2 << 12345678901234567890} 9 operator << 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
337 test parseExpr-10.7 {ParseShiftExpr procedure, valid RHS subexpression} testexprparser {
338 testexprparser {1+2 << 3 << 4} -1
339 } {- {} 0 subexpr {1+2 << 3 << 4} 13 operator << 0 subexpr {1+2 << 3} 9 operator << 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
340 test parseExpr-10.8 {ParseShiftExpr procedure, error in RHS subexpression} \
341 -constraints testexprparser -body {
342 testexprparser {1+2 << 3 >> martha} -1
343 } -match glob -returnCodes error -result *
344
345 test parseExpr-11.1 {ParseAddExpr procedure, valid LHS multiply subexpr} testexprparser {
346 testexprparser {1*2 + 3} -1
347 } {- {} 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
348 test parseExpr-11.2 {ParseAddExpr procedure, error in LHS multiply subexpr} \
349 -constraints testexprparser -body {
350 testexprparser {1/foo + 3} -1
351 } -match glob -returnCodes error -result *
352 test parseExpr-11.3 {ParseAddExpr procedure, next lexeme isn't "+" or "-"} testexprparser {
353 testexprparser {1*2? 1 : 0} -1
354 } {- {} 0 subexpr {1*2? 1 : 0} 11 operator ? 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
355 test parseExpr-11.4 {ParseAddExpr procedure, next lexeme is "+" or "-"} testexprparser {
356 testexprparser {1*2 + 3} -1
357 } {- {} 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
358 test parseExpr-11.5 {ParseAddExpr procedure, next lexeme is "+" or "-"} testexprparser {
359 testexprparser {1*2 - 3} -1
360 } {- {} 0 subexpr {1*2 - 3} 9 operator - 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
361 test parseExpr-11.6 {ParseAddExpr procedure, bad lexeme after "+" or "-"} testexprparser {
362 testexprparser {1*2 + 12345678901234567890} -1
363 } {- {} 0 subexpr {1*2 + 12345678901234567890} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
364 test parseExpr-11.7 {ParseAddExpr procedure, valid RHS subexpression} testexprparser {
365 testexprparser {1*2 + 3 + 4} -1
366 } {- {} 0 subexpr {1*2 + 3 + 4} 13 operator + 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
367 test parseExpr-11.8 {ParseAddExpr procedure, error in RHS subexpression} \
368 -constraints testexprparser -body {
369 testexprparser {1*2 + 3 - martha} -1
370 } -match glob -returnCodes error -result *
371
372 test parseExpr-12.1 {ParseAddExpr procedure, valid LHS multiply subexpr} testexprparser {
373 testexprparser {1*2 + 3} -1
374 } {- {} 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
375 test parseExpr-12.2 {ParseAddExpr procedure, error in LHS multiply subexpr} \
376 -constraints testexprparser -body {
377 testexprparser {1/foo + 3} -1
378 } -match glob -returnCodes error -result *
379 test parseExpr-12.3 {ParseAddExpr procedure, next lexeme isn't "+" or "-"} testexprparser {
380 testexprparser {1*2? 1 : 0} -1
381 } {- {} 0 subexpr {1*2? 1 : 0} 11 operator ? 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
382 test parseExpr-12.4 {ParseAddExpr procedure, next lexeme is "+" or "-"} testexprparser {
383 testexprparser {1*2 + 3} -1
384 } {- {} 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
385 test parseExpr-12.5 {ParseAddExpr procedure, next lexeme is "+" or "-"} testexprparser {
386 testexprparser {1*2 - 3} -1
387 } {- {} 0 subexpr {1*2 - 3} 9 operator - 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
388 test parseExpr-12.6 {ParseAddExpr procedure, bad lexeme after "+" or "-"} testexprparser {
389 testexprparser {1*2 + 12345678901234567890} -1
390 } {- {} 0 subexpr {1*2 + 12345678901234567890} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
391 test parseExpr-12.7 {ParseAddExpr procedure, valid RHS subexpression} testexprparser {
392 testexprparser {1*2 + 3 + 4} -1
393 } {- {} 0 subexpr {1*2 + 3 + 4} 13 operator + 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
394 test parseExpr-12.8 {ParseAddExpr procedure, error in RHS subexpression} \
395 -constraints testexprparser -body {
396 testexprparser {1*2 + 3 - martha} -1
397 } -match glob -returnCodes error -result *
398
399 test parseExpr-13.1 {ParseMultiplyExpr procedure, valid LHS unary subexpr} testexprparser {
400 testexprparser {+2 * 3} -1
401 } {- {} 0 subexpr {+2 * 3} 7 operator * 0 subexpr +2 3 operator + 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
402 test parseExpr-13.2 {ParseMultiplyExpr procedure, error in LHS unary subexpr} testexprparser {
403 testexprparser {-12345678901234567890 * 3} -1
404 } {- {} 0 subexpr {-12345678901234567890 * 3} 7 operator * 0 subexpr -12345678901234567890 3 operator - 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 subexpr 3 1 text 3 0 {}}
405 test parseExpr-13.3 {ParseMultiplyExpr procedure, next lexeme isn't "*", "/", or "%"} testexprparser {
406 testexprparser {+2? 1 : 0} -1
407 } {- {} 0 subexpr {+2? 1 : 0} 9 operator ? 0 subexpr +2 3 operator + 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
408 test parseExpr-13.4 {ParseMultiplyExpr procedure, next lexeme is "*", "/", or "%"} testexprparser {
409 testexprparser {-123 * 3} -1
410 } {- {} 0 subexpr {-123 * 3} 7 operator * 0 subexpr -123 3 operator - 0 subexpr 123 1 text 123 0 subexpr 3 1 text 3 0 {}}
411 test parseExpr-13.5 {ParseMultiplyExpr procedure, next lexeme is "*", "/", or "%"} testexprparser {
412 testexprparser {+-456 / 3} -1
413 } {- {} 0 subexpr {+-456 / 3} 9 operator / 0 subexpr +-456 5 operator + 0 subexpr -456 3 operator - 0 subexpr 456 1 text 456 0 subexpr 3 1 text 3 0 {}}
414 test parseExpr-13.6 {ParseMultiplyExpr procedure, next lexeme is "*", "/", or "%"} testexprparser {
415 testexprparser {+-456 % 3} -1
416 } {- {} 0 subexpr {+-456 % 3} 9 operator % 0 subexpr +-456 5 operator + 0 subexpr -456 3 operator - 0 subexpr 456 1 text 456 0 subexpr 3 1 text 3 0 {}}
417 test parseExpr-13.7 {ParseMultiplyExpr procedure, bad lexeme after "*", "/", or "%"} testexprparser {
418 testexprparser {--++5 / 12345678901234567890} -1
419 } {- {} 0 subexpr {--++5 / 12345678901234567890} 13 operator / 0 subexpr --++5 9 operator - 0 subexpr -++5 7 operator - 0 subexpr ++5 5 operator + 0 subexpr +5 3 operator + 0 subexpr 5 1 text 5 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
420 test parseExpr-13.8 {ParseMultiplyExpr procedure, valid RHS subexpression} testexprparser {
421 testexprparser {-2 / 3 % 4} -1
422 } {- {} 0 subexpr {-2 / 3 % 4} 11 operator % 0 subexpr {-2 / 3} 7 operator / 0 subexpr -2 3 operator - 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
423 test parseExpr-13.9 {ParseMultiplyExpr procedure, error in RHS subexpression} \
424 -constraints testexprparser -body {
425 testexprparser {++2 / 3 * martha} -1
426 } -match glob -returnCodes error -result *
427
428 test parseExpr-14.1 {ParseUnaryExpr procedure, first token is unary operator} testexprparser {
429 testexprparser {+2} -1
430 } {- {} 0 subexpr +2 3 operator + 0 subexpr 2 1 text 2 0 {}}
431 test parseExpr-14.2 {ParseUnaryExpr procedure, first token is unary operator} testexprparser {
432 testexprparser {-2} -1
433 } {- {} 0 subexpr -2 3 operator - 0 subexpr 2 1 text 2 0 {}}
434 test parseExpr-14.3 {ParseUnaryExpr procedure, first token is unary operator} testexprparser {
435 testexprparser {~2} -1
436 } {- {} 0 subexpr ~2 3 operator ~ 0 subexpr 2 1 text 2 0 {}}
437 test parseExpr-14.4 {ParseUnaryExpr procedure, first token is unary operator} testexprparser {
438 testexprparser {!2} -1
439 } {- {} 0 subexpr !2 3 operator ! 0 subexpr 2 1 text 2 0 {}}
440 test parseExpr-14.5 {ParseUnaryExpr procedure, error in lexeme after unary op} testexprparser {
441 testexprparser {-12345678901234567890} -1
442 } {- {} 0 subexpr -12345678901234567890 3 operator - 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
443 test parseExpr-14.6 {ParseUnaryExpr procedure, simple unary expr after unary op} testexprparser {
444 testexprparser {+"1234"} -1
445 } {- {} 0 subexpr +\"1234\" 3 operator + 0 subexpr {"1234"} 1 text 1234 0 {}}
446 test parseExpr-14.7 {ParseUnaryExpr procedure, another unary expr after unary op} testexprparser {
447 testexprparser {~!{fred}} -1
448 } {- {} 0 subexpr ~!{fred} 5 operator ~ 0 subexpr !{fred} 3 operator ! 0 subexpr {{fred}} 1 text fred 0 {}}
449 test parseExpr-14.8 {ParseUnaryExpr procedure, error in unary expr after unary op} -constraints testexprparser -body {
450 testexprparser {+-||27} -1
451 } -returnCodes error -match glob -result *
452 test parseExpr-14.9 {ParseUnaryExpr procedure, error in unary expr after unary op} -constraints testexprparser -body {
453 testexprparser {+-||27} -1
454 } -returnCodes error -match glob -result *
455 test parseExpr-14.10 {ParseUnaryExpr procedure, first token is not unary op} testexprparser {
456 testexprparser {123} -1
457 } {- {} 0 subexpr 123 1 text 123 0 {}}
458 test parseExpr-14.11 {ParseUnaryExpr procedure, not unary expr, complex primary expr} testexprparser {
459 testexprparser {(1+2)} -1
460 } {- {} 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
461 test parseExpr-14.12 {ParseUnaryExpr procedure, not unary expr, error in primary expr} testexprparser {
462 testexprparser {(12345678901234567890)} -1
463 } {- {} 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
464
465 test parseExpr-15.1 {ParsePrimaryExpr procedure, just parenthesized subexpr} testexprparser {
466 testexprparser {({abc}/{def})} -1
467 } {- {} 0 subexpr {{abc}/{def}} 5 operator / 0 subexpr {{abc}} 1 text abc 0 subexpr {{def}} 1 text def 0 {}}
468 test parseExpr-15.2 {ParsePrimaryExpr procedure, bad lexeme after "("} {testexprparser} {
469 testexprparser {(12345678901234567890)} -1
470 } {- {} 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
471 test parseExpr-15.3 {ParsePrimaryExpr procedure, valid parenthesized subexpr} testexprparser {
472 testexprparser {({abc}? 2*4 : -6)} -1
473 } {- {} 0 subexpr {{abc}? 2*4 : -6} 13 operator ? 0 subexpr {{abc}} 1 text abc 0 subexpr 2*4 5 operator * 0 subexpr 2 1 text 2 0 subexpr 4 1 text 4 0 subexpr -6 3 operator - 0 subexpr 6 1 text 6 0 {}}
474 test parseExpr-15.4 {ParsePrimaryExpr procedure, error in parenthesized subexpr} -constraints testexprparser -body {
475 testexprparser {(? 123 : 456)} -1
476 } -returnCodes error -match glob -result *
477 test parseExpr-15.5 {ParsePrimaryExpr procedure, missing ")" after in parenthesized subexpr} -constraints testexprparser -body {
478 testexprparser {({abc}/{def}} -1
479 } -returnCodes error -match glob -result *
480 test parseExpr-15.6 {ParsePrimaryExpr procedure, primary is literal} testexprparser {
481 testexprparser {12345} -1
482 } {- {} 0 subexpr 12345 1 text 12345 0 {}}
483 test parseExpr-15.7 {ParsePrimaryExpr procedure, primary is literal} testexprparser {
484 testexprparser {12345.6789} -1
485 } {- {} 0 subexpr 12345.6789 1 text 12345.6789 0 {}}
486 test parseExpr-15.8 {ParsePrimaryExpr procedure, primary is var reference} testexprparser {
487 testexprparser {$a} -1
488 } {- {} 0 subexpr {$a} 2 variable {$a} 1 text a 0 {}}
489 test parseExpr-15.9 {ParsePrimaryExpr procedure, primary is var reference} testexprparser {
490 testexprparser {$a(hello$there)} -1
491 } {- {} 0 subexpr {$a(hello$there)} 5 variable {$a(hello$there)} 4 text a 0 text hello 0 variable {$there} 1 text there 0 {}}
492 test parseExpr-15.10 {ParsePrimaryExpr procedure, primary is var reference} testexprparser {
493 testexprparser {$a()} -1
494 } {- {} 0 subexpr {$a()} 3 variable {$a()} 2 text a 0 text {} 0 {}}
495 test parseExpr-15.11 {ParsePrimaryExpr procedure, error in var reference} -constraints testexprparser -body {
496 testexprparser {$a(} -1
497 } -returnCodes error -match glob -result *
498 test parseExpr-15.12 {ParsePrimaryExpr procedure, primary is quoted string} testexprparser {
499 testexprparser {"abc $xyz def"} -1
500 } {- {} 0 subexpr {"abc $xyz def"} 5 word {"abc $xyz def"} 4 text {abc } 0 variable {$xyz} 1 text xyz 0 text { def} 0 {}}
501 test parseExpr-15.13 {ParsePrimaryExpr procedure, error in quoted string} -constraints testexprparser -body {
502 testexprparser {"$a(12"} -1
503 } -returnCodes error -match glob -result *
504 test parseExpr-15.14 {ParsePrimaryExpr procedure, quoted string has multiple tokens} testexprparser {
505 testexprparser {"abc [xyz] $def"} -1
506 } {- {} 0 subexpr {"abc [xyz] $def"} 6 word {"abc [xyz] $def"} 5 text {abc } 0 command {[xyz]} 0 text { } 0 variable {$def} 1 text def 0 {}}
507 test parseExpr-15.15 {ParsePrimaryExpr procedure, primary is command} testexprparser {
508 testexprparser {[def]} -1
509 } {- {} 0 subexpr {[def]} 1 command {[def]} 0 {}}
510 test parseExpr-15.16 {ParsePrimaryExpr procedure, primary is multiple commands} testexprparser {
511 testexprparser {[one; two; three; four;]} -1
512 } {- {} 0 subexpr {[one; two; three; four;]} 1 command {[one; two; three; four;]} 0 {}}
513 test parseExpr-15.17 {ParsePrimaryExpr procedure, primary is multiple commands} testexprparser {
514 testexprparser {[one; two; three; four;]} -1
515 } {- {} 0 subexpr {[one; two; three; four;]} 1 command {[one; two; three; four;]} 0 {}}
516 test parseExpr-15.18 {ParsePrimaryExpr procedure, missing close bracket} -constraints testexprparser -body {
517 testexprparser {[one} -1
518 } -returnCodes error -match glob -result *
519 test parseExpr-15.19 {ParsePrimaryExpr procedure, primary is braced string} testexprparser {
520 testexprparser {{hello world}} -1
521 } {- {} 0 subexpr {{hello world}} 1 text {hello world} 0 {}}
522 test parseExpr-15.20 {ParsePrimaryExpr procedure, error in primary, which is braced string} -constraints testexprparser -body {
523 testexprparser "\{abc\\\n" -1
524 } -returnCodes error -match glob -result *
525 test parseExpr-15.21 {ParsePrimaryExpr procedure, primary is braced string with multiple tokens} testexprparser {
526 testexprparser "\{ \\
527 +123 \}" -1
528 } {- {} 0 subexpr \{\ \ \\\n\ +123\ \} 4 word \{\ \ \\\n\ +123\ \} 3 text { } 0 backslash \\\n\ 0 text {+123 } 0 {}}
529 test parseExpr-15.22 {ParsePrimaryExpr procedure, primary is function call} testexprparser {
530 testexprparser {foo(123)} -1
531 } {- {} 0 subexpr foo(123) 3 operator foo 0 subexpr 123 1 text 123 0 {}}
532 test parseExpr-15.23 {ParsePrimaryExpr procedure, bad lexeme after function name} -constraints testexprparser -body {
533 testexprparser {foo 12345678901234567890 123)} -1
534 } -returnCodes error -match glob -result *
535 test parseExpr-15.24 {ParsePrimaryExpr procedure, lexeme after function name isn't "("} \
536 -constraints testexprparser -body {
537 testexprparser {foo 27.4 123)} -1
538 } -match glob -returnCodes error -result *
539 test parseExpr-15.25 {ParsePrimaryExpr procedure, bad lexeme after "("} testexprparser {
540 testexprparser {foo(12345678901234567890)} -1
541 } {- {} 0 subexpr foo(12345678901234567890) 3 operator foo 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
542 test parseExpr-15.26 {ParsePrimaryExpr procedure, function call, one arg} testexprparser {
543 testexprparser {foo(27*4)} -1
544 } {- {} 0 subexpr foo(27*4) 7 operator foo 0 subexpr 27*4 5 operator * 0 subexpr 27 1 text 27 0 subexpr 4 1 text 4 0 {}}
545 test parseExpr-15.27 {ParsePrimaryExpr procedure, error in function arg} -constraints testexprparser -body {
546 testexprparser {foo(*1-2)} -1
547 } -returnCodes error -match glob -result *
548 test parseExpr-15.28 {ParsePrimaryExpr procedure, error in function arg} -constraints testexprparser -body {
549 testexprparser {foo(*1-2)} -1
550 } -returnCodes error -match glob -result *
551 test parseExpr-15.29 {ParsePrimaryExpr procedure, function call, comma after arg} testexprparser {
552 testexprparser {foo(27-2, (-2*[foo]))} -1
553 } {- {} 0 subexpr {foo(27-2, (-2*[foo]))} 15 operator foo 0 subexpr 27-2 5 operator - 0 subexpr 27 1 text 27 0 subexpr 2 1 text 2 0 subexpr {-2*[foo]} 7 operator * 0 subexpr -2 3 operator - 0 subexpr 2 1 text 2 0 subexpr {[foo]} 1 command {[foo]} 0 {}}
554 test parseExpr-15.30 {ParsePrimaryExpr procedure, bad lexeme after comma} testexprparser {
555 testexprparser {foo(123, 12345678901234567890)} -1
556 } {- {} 0 subexpr {foo(123, 12345678901234567890)} 5 operator foo 0 subexpr 123 1 text 123 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
557 test parseExpr-15.31 {ParsePrimaryExpr procedure, lexeme not "," or ")" after arg} -constraints testexprparser -body {
558 testexprparser {foo(123 [foo])} -1
559 } -returnCodes error -match glob -result *
560 test parseExpr-15.32 {ParsePrimaryExpr procedure, bad lexeme after primary} -constraints testexprparser -body {
561 testexprparser {123 12345678901234567890} -1
562 } -returnCodes error -match glob -result *
563 test parseExpr-15.33 {ParsePrimaryExpr procedure, comma-specific message} -constraints testexprparser -body {
564 testexprparser {123+,456} -1
565 } -returnCodes error -match glob -result *
566 test parseExpr-15.34 {ParsePrimaryExpr procedure, single equal-specific message} -constraints testexprparser -body {
567 testexprparser {123+=456} -1
568 } -returnCodes error -match glob -result *
569 test parseExpr-15.35 {ParsePrimaryExpr procedure, error in parenthesized subexpr} -constraints testexprparser -body {
570 testexprparser {(: 123 : 456)} -1
571 } -returnCodes error -match glob -result *
572 test parseExpr-15.36 {ParsePrimaryExpr procedure, missing close-bracket} -constraints testexprparser -body {
573 # Test for Bug 681841
574 testexprparser {[set a [format bc]} -1
575 } -returnCodes error -match glob -result *
576
577 test parseExpr-16.1 {GetLexeme procedure, whitespace before lexeme} testexprparser {
578 testexprparser { 123} -1
579 } {- {} 0 subexpr 123 1 text 123 0 {}}
580 test parseExpr-16.2 {GetLexeme procedure, whitespace before lexeme} testexprparser {
581 testexprparser { \
582 456} -1
583 } {- {} 0 subexpr 456 1 text 456 0 {}}
584 test parseExpr-16.3 {GetLexeme procedure, no lexeme after whitespace} testexprparser {
585 testexprparser { 123 \
586 } -1
587 } {- {} 0 subexpr 123 1 text 123 0 {}}
588 test parseExpr-16.4 {GetLexeme procedure, integer lexeme} testexprparser {
589 testexprparser {000} -1
590 } {- {} 0 subexpr 000 1 text 000 0 {}}
591 test parseExpr-16.5 {GetLexeme procedure, integer lexeme too big} testexprparser {
592 testexprparser {12345678901234567890} -1
593 } {- {} 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
594 test parseExpr-16.6 {GetLexeme procedure, bad integer lexeme} -constraints testexprparser -body {
595 testexprparser {0o999} -1
596 } -returnCodes error -match glob -result {*invalid octal number*}
597 test parseExpr-16.7 {GetLexeme procedure, double lexeme} testexprparser {
598 testexprparser {0.999} -1
599 } {- {} 0 subexpr 0.999 1 text 0.999 0 {}}
600 test parseExpr-16.8 {GetLexeme procedure, double lexeme} testexprparser {
601 testexprparser {.123} -1
602 } {- {} 0 subexpr .123 1 text .123 0 {}}
603 test parseExpr-16.9 {GetLexeme procedure, double lexeme} {testexprparser unix} {
604 testexprparser {nan} -1
605 } {- {} 0 subexpr nan 1 text nan 0 {}}
606 test parseExpr-16.10 {GetLexeme procedure, double lexeme} {testexprparser unix} {
607 testexprparser {NaN} -1
608 } {- {} 0 subexpr NaN 1 text NaN 0 {}}
609 test parseExpr-16.11a {GetLexeme procedure, bad double lexeme too big} {testexprparser && !ieeeFloatingPoint} {
610 list [catch {testexprparser {123.e+99999999999999} -1} msg] $msg
611 } {1 {floating-point value too large to represent}}
612 test parseExpr-16.11b {GetLexeme procedure, bad double lexeme too big} {testexprparser && ieeeFloatingPoint} {
613 list [catch {testexprparser {123.e+99999999999999} -1} msg] $msg
614 } {0 {- {} 0 subexpr 123.e+99999999999999 1 text 123.e+99999999999999 0 {}}}
615 test parseExpr-16.12 {GetLexeme procedure, bad double lexeme} -constraints testexprparser -body {
616 testexprparser {123.4x56} -1
617 } -returnCodes error -match glob -result *
618 test parseExpr-16.13 {GetLexeme procedure, lexeme is "["} testexprparser {
619 testexprparser {[foo]} -1
620 } {- {} 0 subexpr {[foo]} 1 command {[foo]} 0 {}}
621 test parseExpr-16.14 {GetLexeme procedure, lexeme is open brace} testexprparser {
622 testexprparser {{bar}} -1
623 } {- {} 0 subexpr {{bar}} 1 text bar 0 {}}
624 test parseExpr-16.15 {GetLexeme procedure, lexeme is "("} testexprparser {
625 testexprparser {(123)} -1
626 } {- {} 0 subexpr 123 1 text 123 0 {}}
627 test parseExpr-16.16 {GetLexeme procedure, lexeme is ")"} testexprparser {
628 testexprparser {(2*3)} -1
629 } {- {} 0 subexpr 2*3 5 operator * 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
630 test parseExpr-16.17 {GetLexeme procedure, lexeme is "$"} testexprparser {
631 testexprparser {$wombat} -1
632 } {- {} 0 subexpr {$wombat} 2 variable {$wombat} 1 text wombat 0 {}}
633 test parseExpr-16.18 "GetLexeme procedure, lexeme is '\"'" testexprparser {
634 testexprparser {"fred"} -1
635 } {- {} 0 subexpr {"fred"} 1 text fred 0 {}}
636 test parseExpr-16.19 {GetLexeme procedure, lexeme is ","} testexprparser {
637 testexprparser {foo(1,2)} -1
638 } {- {} 0 subexpr foo(1,2) 5 operator foo 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
639 test parseExpr-16.20 {GetLexeme procedure, lexeme is "*"} testexprparser {
640 testexprparser {$a*$b} -1
641 } {- {} 0 subexpr {$a*$b} 7 operator * 0 subexpr {$a} 2 variable {$a} 1 text a 0 subexpr {$b} 2 variable {$b} 1 text b 0 {}}
642 test parseExpr-16.21 {GetLexeme procedure, lexeme is "/"} testexprparser {
643 testexprparser {5/6} -1
644 } {- {} 0 subexpr 5/6 5 operator / 0 subexpr 5 1 text 5 0 subexpr 6 1 text 6 0 {}}
645 test parseExpr-16.22 {GetLexeme procedure, lexeme is "%"} testexprparser {
646 testexprparser {5%[xxx]} -1
647 } {- {} 0 subexpr {5%[xxx]} 5 operator % 0 subexpr 5 1 text 5 0 subexpr {[xxx]} 1 command {[xxx]} 0 {}}
648 test parseExpr-16.23 {GetLexeme procedure, lexeme is "+"} testexprparser {
649 testexprparser {1+2} -1
650 } {- {} 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
651 test parseExpr-16.24 {GetLexeme procedure, lexeme is "-"} testexprparser {
652 testexprparser {.12-0e27} -1
653 } {- {} 0 subexpr .12-0e27 5 operator - 0 subexpr .12 1 text .12 0 subexpr 0e27 1 text 0e27 0 {}}
654 test parseExpr-16.25 {GetLexeme procedure, lexeme is "?" or ":"} testexprparser {
655 testexprparser {$b? 1 : 0} -1
656 } {- {} 0 subexpr {$b? 1 : 0} 8 operator ? 0 subexpr {$b} 2 variable {$b} 1 text b 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
657 test parseExpr-16.26 {GetLexeme procedure, lexeme is "<"} testexprparser {
658 testexprparser {2<3} -1
659 } {- {} 0 subexpr 2<3 5 operator < 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
660 test parseExpr-16.27 {GetLexeme procedure, lexeme is "<<"} testexprparser {
661 testexprparser {2<<3} -1
662 } {- {} 0 subexpr 2<<3 5 operator << 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
663 test parseExpr-16.28 {GetLexeme procedure, lexeme is "<="} testexprparser {
664 testexprparser {2<=3} -1
665 } {- {} 0 subexpr 2<=3 5 operator <= 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
666 test parseExpr-16.29 {GetLexeme procedure, lexeme is ">"} testexprparser {
667 testexprparser {2>3} -1
668 } {- {} 0 subexpr 2>3 5 operator > 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
669 test parseExpr-16.30 {GetLexeme procedure, lexeme is ">>"} testexprparser {
670 testexprparser {2>>3} -1
671 } {- {} 0 subexpr 2>>3 5 operator >> 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
672 test parseExpr-16.31 {GetLexeme procedure, lexeme is ">="} testexprparser {
673 testexprparser {2>=3} -1
674 } {- {} 0 subexpr 2>=3 5 operator >= 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
675 test parseExpr-16.32 {GetLexeme procedure, lexeme is "=="} testexprparser {
676 testexprparser {2==3} -1
677 } {- {} 0 subexpr 2==3 5 operator == 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
678 test parseExpr-16.33 {GetLexeme procedure, bad lexeme starting with "="} -constraints testexprparser -body {
679 testexprparser {2=+3} -1
680 } -returnCodes error -match glob -result *
681 test parseExpr-16.34 {GetLexeme procedure, lexeme is "!="} testexprparser {
682 testexprparser {2!=3} -1
683 } {- {} 0 subexpr 2!=3 5 operator != 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
684 test parseExpr-16.35 {GetLexeme procedure, lexeme is "!"} testexprparser {
685 testexprparser {!2} -1
686 } {- {} 0 subexpr !2 3 operator ! 0 subexpr 2 1 text 2 0 {}}
687 test parseExpr-16.36 {GetLexeme procedure, lexeme is "&&"} testexprparser {
688 testexprparser {2&&3} -1
689 } {- {} 0 subexpr 2&&3 5 operator && 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
690 test parseExpr-16.37 {GetLexeme procedure, lexeme is "&"} testexprparser {
691 testexprparser {1&2} -1
692 } {- {} 0 subexpr 1&2 5 operator & 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
693 test parseExpr-16.38 {GetLexeme procedure, lexeme is "^"} testexprparser {
694 testexprparser {1^2} -1
695 } {- {} 0 subexpr 1^2 5 operator ^ 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
696 test parseExpr-16.39 {GetLexeme procedure, lexeme is "||"} testexprparser {
697 testexprparser {2||3} -1
698 } {- {} 0 subexpr 2||3 5 operator || 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
699 test parseExpr-16.40 {GetLexeme procedure, lexeme is "|"} testexprparser {
700 testexprparser {1|2} -1
701 } {- {} 0 subexpr 1|2 5 operator | 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
702 test parseExpr-16.41 {GetLexeme procedure, lexeme is "~"} testexprparser {
703 testexprparser {~2} -1
704 } {- {} 0 subexpr ~2 3 operator ~ 0 subexpr 2 1 text 2 0 {}}
705 test parseExpr-16.42 {GetLexeme procedure, lexeme is func name} testexprparser {
706 testexprparser {george()} -1
707 } {- {} 0 subexpr george() 1 operator george 0 {}}
708 test parseExpr-16.43 {GetLexeme procedure, lexeme is func name} testexprparser {
709 testexprparser {harmonic_ratio(2,3)} -1
710 } {- {} 0 subexpr harmonic_ratio(2,3) 5 operator harmonic_ratio 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
711 test parseExpr-16.44 {GetLexeme procedure, unknown lexeme} -constraints testexprparser -body {
712 testexprparser {@27} -1
713 } -returnCodes error -match glob -result *
714
715 test parseExpr-17.1 {PrependSubExprTokens procedure, expand token array} testexprparser {
716 testexprparser {[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]} -1
717 } {- {} 0 subexpr {[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]} 13 operator && 0 subexpr {[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]} 9 operator && 0 subexpr {[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]} 5 operator && 0 subexpr {[string compare [format %c $i] [string index $a $i]]} 1 command {[string compare [format %c $i] [string index $a $i]]} 0 subexpr {[string compare [format %c $i] [string index $a $i]]} 1 command {[string compare [format %c $i] [string index $a $i]]} 0 subexpr {[string compare [format %c $i] [string index $a $i]]} 1 command {[string compare [format %c $i] [string index $a $i]]} 0 subexpr {[string compare [format %c $i] [string index $a $i]]} 1 command {[string compare [format %c $i] [string index $a $i]]} 0 {}}
718
719 test parseExpr-18.1 {LogSyntaxError procedure, error in expr longer than 60 chars} -constraints testexprparser -body {
720 testexprparser {(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)/} -1
721 } -returnCodes error -match glob -result *
722
723 test parseExpr-19.1 {TclParseInteger: [Bug 648441]} -body {
724 # Should see this as integer "0" followed by incomplete function "x"
725 # Thus, syntax error.
726 # If Bug 648441 is not fixed, "0x" will be seen as floating point 0.0
727 expr 0x
728 } -returnCodes error -match glob -result *
729
730 test parseExpr-20.1 {Bug 1451233} {
731 expr 1000000000000000000042
732 } 1000000000000000000042
733 test parseExpr-20.2 {Bug 1451233} {
734 expr 10000000000000000000420000000042
735 } 10000000000000000000420000000042
736 test parseExpr-20.3 {Bug 1451233} {
737 expr 10000000000000000000020000000002
738 } 10000000000000000000020000000002
739
740 test parseExpr-21.1 {error messages} -body {
741 expr @
742 } -returnCodes error -result {invalid character "@"
743 in expression "@"}
744 test parseExpr-21.2 {error messages} -body {
745 expr =
746 } -returnCodes error -result {incomplete operator "="
747 in expression "="}
748 test parseExpr-21.3 {error messages} -body {
749 expr x
750 } -returnCodes error -result {invalid bareword "x"
751 in expression "x";
752 should be "$x" or "{x}" or "x(...)" or ...}
753 test parseExpr-21.4 {error messages} -body {
754 expr abcdefghijklmnopqrstuvwxyz
755 } -returnCodes error -result {invalid bareword "abcdefghijklmnopqrstuv..."
756 in expression "abcdefghijklmnopqrstuv...";
757 should be "$abcdefghijklmnopqrstuv..." or "{abcdefghijklmnopqrstuv...}" or "abcdefghijklmnopqrstuv...(...)" or ...}
758 test parseExpr-21.5 {error messages} -body {
759 expr {[][]}
760 } -returnCodes error -result {missing operator at _@_
761 in expression "[]_@_[]"}
762 test parseExpr-21.6 {error messages} -body {
763 expr {0 0}
764 } -returnCodes error -result {missing operator at _@_
765 in expression "0 _@_0"}
766 test parseExpr-21.7 {error messages} -body {
767 expr {0o8}
768 } -returnCodes error -match glob -result {*invalid octal number*}
769 test parseExpr-21.8 {error messages} -body {
770 expr {0o8x}
771 } -returnCodes error -match glob -result {*invalid octal number*}
772 test parseExpr-21.9 {error messages} -body {
773 expr {"}
774 } -returnCodes error -result {missing "
775 in expression """}
776 test parseExpr-21.10 {error messages} -body {
777 expr \{
778 } -returnCodes error -result "missing close-brace
779 in expression \"\{\""
780 test parseExpr-21.11 {error messages} -body {
781 expr $
782 } -returnCodes error -result {invalid character "$"
783 in expression "$"}
784 test parseExpr-21.12 {error messages} -body {
785 expr {$(}
786 } -returnCodes error -result {missing )
787 in expression "$("}
788 test parseExpr-21.13 {error messages} -body {
789 expr {[""x]}
790 } -returnCodes error -result {extra characters after close-quote
791 in expression "[""x]"}
792 test parseExpr-21.14 {error messages} -body {
793 expr {[}
794 } -returnCodes error -result {missing close-bracket
795 in expression "["}
796 test parseExpr-21.15 {error messages} -body {
797 expr 0~0
798 } -returnCodes error -result {missing operator at _@_
799 in expression "0_@_~0"}
800 test parseExpr-21.16 {error messages} -body {
801 expr ()
802 } -returnCodes error -result {empty subexpression at _@_
803 in expression "(_@_)"}
804 test parseExpr-21.17 {error messages} -body {
805 expr (
806 } -returnCodes error -result {unbalanced open paren
807 in expression "("}
808 test parseExpr-21.18 {error messages} -body {
809 expr a(0,)
810 } -returnCodes error -result {missing function argument at _@_
811 in expression "a(0,_@_)"}
812 test parseExpr-21.19 {error messages} -body {
813 expr {}
814 } -returnCodes error -result {empty expression
815 in expression ""}
816 test parseExpr-21.20 {error messages} -body {
817 expr )
818 } -returnCodes error -result {unbalanced close paren
819 in expression ")"}
820 test parseExpr-21.21 {error messages} -body {
821 expr a(,0)
822 } -returnCodes error -result {missing function argument at _@_
823 in expression "a(_@_,0)"}
824 test parseExpr-21.22 {error messages} -body {
825 expr 0&|0
826 } -returnCodes error -result {missing operand at _@_
827 in expression "0&_@_|0"}
828 test parseExpr-21.23 {error messages} -body {
829 expr 0^^0
830 } -returnCodes error -result {missing operand at _@_
831 in expression "0^_@_^0"}
832 test parseExpr-21.24 {error messages} -body {
833 expr 0|&0
834 } -returnCodes error -result {missing operand at _@_
835 in expression "0|_@_&0"}
836 test parseExpr-21.25 {error messages} -body {
837 expr a(1+,0)
838 } -returnCodes error -result {missing operand at _@_
839 in expression "a(1+_@_,0)"}
840 test parseExpr-21.26 {error messages} -body {
841 expr (0
842 } -returnCodes error -result {unbalanced open paren
843 in expression "(0"}
844 test parseExpr-21.27 {error messages} -body {
845 expr 0?0
846 } -returnCodes error -result {missing operator ":" at _@_
847 in expression "0?0_@_"}
848 test parseExpr-21.28 {error messages} -body {
849 expr 0:0
850 } -returnCodes error -result {unexpected operator ":" without preceding "?"
851 in expression "0:0"}
852 test parseExpr-21.29 {error messages} -body {
853 expr 0)
854 } -returnCodes error -result {unbalanced close paren
855 in expression "0)"}
856 test parseExpr-21.30 {error messages} -body {
857 expr 0,
858 } -returnCodes error -result {unexpected "," outside function argument list
859 in expression "0,"}
860 test parseExpr-21.31 {error messages} -body {
861 expr 0,0
862 } -returnCodes error -result {unexpected "," outside function argument list
863 in expression "0,0"}
864 test parseExpr-21.32 {error messages} -body {
865 expr (0,0)
866 } -returnCodes error -result {unexpected "," outside function argument list
867 in expression "(0,0)"}
868 test parseExpr-21.33 {error messages} -body {
869 expr a(0:0,0)
870 } -returnCodes error -result {unexpected operator ":" without preceding "?"
871 in expression "a(0:0,0)"}
872 test parseExpr-21.34 {error messages} -body {
873 expr {"abcdefghijklmnopqrstuvwxyz"@0}
874 } -returnCodes error -result {invalid character "@"
875 in expression "...fghijklmnopqrstuvwxyz"@0"}
876 test parseExpr-21.35 {error messages} -body {
877 expr {0@"abcdefghijklmnopqrstuvwxyz"}
878 } -returnCodes error -result {invalid character "@"
879 in expression "0@"abcdefghijklmnopqrstu..."}
880 test parseExpr-21.36 {error messages} -body {
881 expr {"abcdefghijklmnopqrstuvwxyz"@"abcdefghijklmnopqrstuvwxyz"}
882 } -returnCodes error -result {invalid character "@"
883 in expression "...fghijklmnopqrstuvwxyz"@"abcdefghijklmnopqrstu..."}
884 test parseExpr-21.37 {error messages} -body {
885 expr [format {"%s" @ 0} [string repeat \u00a7 25]]
886 } -returnCodes error -result [format {invalid character "@"
887 in expression "...%s" @ 0"} [string repeat \u00a7 10]]
888 test parseExpr-21.38 {error messages} -body {
889 expr [format {0 @ "%s"} [string repeat \u00a7 25]]
890 } -returnCodes error -result [format {invalid character "@"
891 in expression "0 @ "%s..."} [string repeat \u00a7 10]]
892 test parseExpr-21.39 {error messages} -body {
893 expr [format {"%s" @ "%s"} [string repeat \u00a7 25] [string repeat \u00a7 25]]
894 } -returnCodes error -result [format {invalid character "@"
895 in expression "...%s" @ "%s..."} [string repeat \u00a7 10] [string repeat \u00a7 10]]
896 test parseExpr-21.40 {error messages} -body {
897 catch {expr {"abcdefghijklmnopqrstuvwxyz"@0}} m o
898 dict get $o -errorinfo
899 } -result {invalid character "@"
900 in expression "...fghijklmnopqrstuvwxyz"@0"
901 (parsing expression ""abcdefghijklmnopqrstu...")
902 invoked from within
903 "expr {"abcdefghijklmnopqrstuvwxyz"@0}"}
904 test parseExpr-21.41 {error messages} -body {
905 catch {expr [format {"%s" @ 0} [string repeat \u00a7 25]]} m o
906 dict get $o -errorinfo
907 } -result [format {invalid character "@"
908 in expression "...%s" @ 0"
909 (parsing expression ""%s...")
910 invoked from within
911 "expr [format {"%%s" @ 0} [string repeat \u00a7 25]]"} [string repeat \u00a7 10] [string repeat \u00a7 10]]
912 test parseExpr-21.42 {error message} -body {
913 expr {123456789012345678901234567890*"abcdefghijklmnopqrstuvwxyz}
914 } -returnCodes error -result {missing "
915 in expression "...012345678901234567890*"abcdefghijklmnopqrstuv..."}
916 test parseExpr-21.43 {error message} -body {
917 expr "123456789012345678901234567890*\"foobar\$\{abcdefghijklmnopqrstuvwxyz\""
918 } -returnCodes error -result "missing close-brace for variable name
919 in expression \"...8901234567890*\"foobar\$\{abcdefghijklmnopqrstuv...\""
920 test parseExpr-21.44 {error message} -body {
921 expr {123456789012345678901234567890*"foo$bar(abcdefghijklmnopqrstuvwxyz"}
922 } -returnCodes error -result {missing )
923 in expression "...8901234567890*"foo$bar(abcdefghijklmnopqrstuv..."}
924 test parseExpr-21.45 {error message} -body {
925 expr {123456789012345678901234567890*"foo$bar([{}abcdefghijklmnopqrstuvwxyz])"}
926 } -returnCodes error -result {extra characters after close-brace
927 in expression "...234567890*"foo$bar([{}abcdefghijklmnopqrstuv..."}
928 test parseExpr-21.46 {error message} -body {
929 expr {123456789012345678901234567890*"foo$bar([""abcdefghijklmnopqrstuvwxyz])"}
930 } -returnCodes error -result {extra characters after close-quote
931 in expression "...234567890*"foo$bar([""abcdefghijklmnopqrstuv..."}
932 test parseExpr-21.47 {error message} -body {
933 expr {123456789012345678901234567890*"foo$bar([abcdefghijklmnopqrstuvwxyz)"}
934 } -returnCodes error -result {missing close-bracket
935 in expression "...901234567890*"foo$bar([abcdefghijklmnopqrstuv..."}
936 test parseExpr-21.48 {error message} -body {
937 expr "123456789012345678901234567890*\"foo\$bar(\[\{abcdefghijklmnopqrstuvwxyz])\""
938 } -returnCodes error -result "missing close-brace
939 in expression \"...01234567890*\"foo\$bar(\[\{abcdefghijklmnopqrstuv...\""
940
941 test parseExpr-21.49 {error message} -body {
942 expr "123456789012345678901234567890*\{abcdefghijklmnopqrstuvwxyz"
943 } -returnCodes error -result "missing close-brace
944 in expression \"...012345678901234567890*\{abcdefghijklmnopqrstuv...\""
945
946 test parseExpr-21.50 {error message} -body {
947 expr {123456789012345678901234567890*$foo(["abcdefghijklmnopqrstuvwxyz])}
948 } -returnCodes error -result {missing "
949 in expression "...678901234567890*$foo(["abcdefghijklmnopqrstuv..."}
950 test parseExpr-21.51 {error message} -body {
951 expr "123456789012345678901234567890*\$\{abcdefghijklmnopqrstuvwxyz"
952 } -returnCodes error -result "missing close-brace for variable name
953 in expression \"...12345678901234567890*\$\{abcdefghijklmnopqrstuv...\""
954 test parseExpr-21.52 {error message} -body {
955 expr {123456789012345678901234567890*$bar(abcdefghijklmnopqrstuvwxyz}
956 } -returnCodes error -result {missing )
957 in expression "...45678901234567890*$bar(abcdefghijklmnopqrstuv..."}
958 test parseExpr-21.53 {error message} -body {
959 expr {123456789012345678901234567890*$bar([{}abcdefghijklmnopqrstuvwxyz])"}
960 } -returnCodes error -result {extra characters after close-brace
961 in expression "...8901234567890*$bar([{}abcdefghijklmnopqrstuv..."}
962 test parseExpr-21.54 {error message} -body {
963 expr {123456789012345678901234567890*$bar([""abcdefghijklmnopqrstuvwxyz])"}
964 } -returnCodes error -result {extra characters after close-quote
965 in expression "...8901234567890*$bar([""abcdefghijklmnopqrstuv..."}
966 test parseExpr-21.55 {error message} -body {
967 expr {123456789012345678901234567890*$bar([abcdefghijklmnopqrstuvwxyz)"}
968 } -returnCodes error -result {missing close-bracket
969 in expression "...5678901234567890*$bar([abcdefghijklmnopqrstuv..."}
970 test parseExpr-21.56 {error message} -body {
971 expr "123456789012345678901234567890*\$bar(\[\{abcdefghijklmnopqrstuvwxyz])"
972 } -returnCodes error -result "missing close-brace
973 in expression \"...678901234567890*\$bar(\[\{abcdefghijklmnopqrstuv...\""
974
975 test parseExpr-21.57 {error message} -body {
976 expr {123456789012345678901234567890*["abcdefghijklmnopqrstuvwxyz]}
977 } -returnCodes error -result {missing "
978 in expression "...12345678901234567890*["abcdefghijklmnopqrstuv..."}
979 test parseExpr-21.58 {error message} -body {
980 expr "123456789012345678901234567890*\[\$\{abcdefghijklmnopqrstuvwxyz]"
981 } -returnCodes error -result "missing close-brace for variable name
982 in expression \"...2345678901234567890*\[\$\{abcdefghijklmnopqrstuv...\""
983 test parseExpr-21.59 {error message} -body {
984 expr {123456789012345678901234567890*[$bar(abcdefghijklmnopqrstuvwxyz]}
985 } -returnCodes error -result {missing )
986 in expression "...5678901234567890*[$bar(abcdefghijklmnopqrstuv..."}
987 test parseExpr-21.60 {error message} -body {
988 expr {123456789012345678901234567890*[{}abcdefghijklmnopqrstuvwxyz]"}
989 } -returnCodes error -result {extra characters after close-brace
990 in expression "...345678901234567890*[{}abcdefghijklmnopqrstuv..."}
991 test parseExpr-21.61 {error message} -body {
992 expr {123456789012345678901234567890*[""abcdefghijklmnopqrstuvwxyz]"}
993 } -returnCodes error -result {extra characters after close-quote
994 in expression "...345678901234567890*[""abcdefghijklmnopqrstuv..."}
995 test parseExpr-21.62 {error message} -body {
996 expr {123456789012345678901234567890*[abcdefghijklmnopqrstuvwxyz"}
997 } -returnCodes error -result {missing close-bracket
998 in expression "...012345678901234567890*[abcdefghijklmnopqrstuv..."}
999 test parseExpr-21.63 {error message} -body {
1000 expr "123456789012345678901234567890*\[\{abcdefghijklmnopqrstuvwxyz]"
1001 } -returnCodes error -result "missing close-brace
1002 in expression \"...12345678901234567890*\[\{abcdefghijklmnopqrstuv...\""
1003
1004 test parseExpr-22.1 {Bug 3401704} -constraints testexprparser -body {
1005 testexprparser 2a() 1
1006 } -result {- {} 0 subexpr 2 1 text 2 0 {}}
1007 test parseExpr-22.2 {Bug 3401704} -constraints testexprparser -body {
1008 testexprparser nana() 3
1009 } -result {- {} 0 subexpr nan 1 text nan 0 {}}
1010 test parseExpr-22.3 {Bug 3401704} -constraints testexprparser -body {
1011 testexprparser 2a() -1
1012 } -result {- {} 0 subexpr 2a() 1 operator 2a 0 {}}
1013 test parseExpr-22.4 {Bug 3401704} -constraints testexprparser -body {
1014 testexprparser nana() -1
1015 } -result {- {} 0 subexpr nana() 1 operator nana 0 {}}
1016 test parseExpr-22.5 {Bug 3401704} -constraints testexprparser -body {
1017 testexprparser nan9() -1
1018 } -result {- {} 0 subexpr nan9() 1 operator nan9 0 {}}
1019 test parseExpr-22.6 {Bug 3401704} -constraints testexprparser -body {
1020 testexprparser 2_() -1
1021 } -result {- {} 0 subexpr 2_() 1 operator 2_ 0 {}}
1022 test parseExpr-22.7 {Bug 3401704} -constraints testexprparser -body {
1023 testexprparser nan_() -1
1024 } -result {- {} 0 subexpr nan_() 1 operator nan_ 0 {}}
1025 test parseExpr-22.8 {Bug 3401704} -constraints testexprparser -body {
1026 catch {testexprparser nan!() -1} m o
1027 dict get $o -errorcode
1028 } -result {TCL PARSE EXPR MISSING}
1029 test parseExpr-22.9 {Bug 3401704} -constraints testexprparser -body {
1030 testexprparser 1e3_() -1
1031 } -result {- {} 0 subexpr 1e3_() 1 operator 1e3_ 0 {}}
1032 test parseExpr-22.10 {Bug 3401704} -constraints testexprparser -body {
1033 catch {testexprparser 1.3_() -1} m o
1034 dict get $o -errorcode
1035 } -result {TCL PARSE EXPR BADCHAR}
1036 test parseExpr-22.11 {Bug 3401704} -constraints testexprparser -body {
1037 catch {testexprparser 1e-3_() -1} m o
1038 dict get $o -errorcode
1039 } -result {TCL PARSE EXPR BADCHAR}
1040 test parseExpr-22.12 {Bug 3401704} -constraints testexprparser -body {
1041 catch {testexprparser naneq() -1} m o
1042 dict get $o -errorcode
1043 } -result {TCL PARSE EXPR EMPTY}
1044 test parseExpr-22.13 {Bug 3401704} -constraints testexprparser -body {
1045 testexprparser naner() -1
1046 } -result {- {} 0 subexpr naner() 1 operator naner 0 {}}
1047
1048 test parseExpr-22.14 {Bug 3401704} -constraints testexprparser -body {
1049 catch {testexprparser 08 -1} m o
1050 dict get $o -errorcode
1051 } -result {TCL PARSE EXPR BADNUMBER OCTAL}
1052 test parseExpr-22.15 {Bug 3401704} -constraints testexprparser -body {
1053 catch {testexprparser 0o8 -1} m o
1054 dict get $o -errorcode
1055 } -result {TCL PARSE EXPR BADNUMBER OCTAL}
1056 test parseExpr-22.16 {Bug 3401704} -constraints testexprparser -body {
1057 catch {testexprparser 0o08 -1} m o
1058 dict get $o -errorcode
1059 } -result {TCL PARSE EXPR BADNUMBER OCTAL}
1060 test parseExpr-22.17 {Bug 3401704} -constraints testexprparser -body {
1061 catch {testexprparser 0b2 -1} m o
1062 dict get $o -errorcode
1063 } -result {TCL PARSE EXPR BADNUMBER BINARY}
1064 test parseExpr-22.18 {Bug 3401704} -constraints testexprparser -body {
1065 catch {testexprparser 0b02 -1} m o
1066 dict get $o -errorcode
1067 } -result {TCL PARSE EXPR BADNUMBER BINARY}
1068
1069 test parseExpr-22.19 {Bug d2ffcca163} -constraints testexprparser -body {
1070 testexprparser \u0433 -1
1071 } -returnCodes error -match glob -result {*invalid character*}
1072 test parseExpr-22.20 {Bug d2ffcca163} -constraints testexprparser -body {
1073 testexprparser \u043f -1
1074 } -returnCodes error -match glob -result {*invalid character*}
1075 test parseExpr-22.21 {Bug d2ffcca163} -constraints testexprparser -body {
1076 testexprparser in\u0433(0) -1
1077 } -returnCodes error -match glob -result {missing operand*}
1078
1079 # cleanup
1080 cleanupTests
1081 return