blob: 8b03192879f838e98ca4c1a1d65c13bfe263a953 (
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
source [file dirname [info script]]/testing.tcl
test parse-1.1 "Quoted closing bracket" {
set x [string length "]"]
} {1}
test parse-1.2 "Quoted opening bracket" {
set x [string length "\["]
} {1}
test parse-1.3 "Quoted open brace" {
set x [string length "\{"]
} {1}
test parse-1.4 "Quoted open brace via var" {
set lb \{
set x [string length "$lb"]
} {1}
test parse-1.5 "Braced bracket" {
set x [string length {]}]
} {1}
test parse-1.6 "Dict sugar" -body {
unset -nocomplain a
array set a {a 1 b 2 c 3}
set x $a(
} -returnCodes error -match glob -result "*"
test parse-1.8 "Dict sugar" {
unset -nocomplain a
array set a {a 1 b 2 c 3}
set x $a([set y b])
} 2
test parse-1.9 "Backslash newline" {
set x 123;\
set y 456
list $x $y
} {123 456}
test parse-1.10 "Backslash newline in quotes" {
set x "abc\
def"
} "abc def"
test parse-1.11 "Backslash newline in quotes after var" {
set y 1
set x "abc$y\
def"
} "abc1 def"
test parse-1.12 "Backslash newline in quotes after var" {
set y 1
set x "abc$y\
def"
} "abc1 def"
test parse-1.13 "Newline in quotes" {
set y 1
set x "abc
def"
} "abc\ndef"
test parse-1.14 "Newline in quotes after var" {
set y 1
set x "abc$y
def"
} "abc1\ndef"
test parse-1.15 "Space in quotes" {
set y 1
set x "abc def"
} "abc def"
test parse-1.16 "Space in quotes after var" {
set y 1
set x "abc${y} def"
} "abc1 def"
test parse-1.17 "Command and var in quotes" {
set y 1
set x "[set z 2][set y]"
} 21
test parse-1.18 "Command and var in bare context" {
set y 1
set x [set z 2][set y]
} 21
test parse-1.19 "Lone dollar sign in quotes" {
set y 1
set x "6$[set y]"
} 6\$1
test parse-1.20 "Command and var in bare context" {
set y 1
set x 6$[set y]
} 6\$1
test parse-1.21 "Comment" {
set y 1
# A comment one a line
set x [set y] ;# comment after semicolon
} 1
test parse-1.22 "# char" {
set y 1
append y #
set x "[set y]#"
} {1##}
test parse-1.23 "newline in command" {
set y 1
set z 2
set x [incr y
incr z]
list $x $y $z
} {3 2 3}
test parse-1.24 "semicolon in command" {
set x [list a; list b c; list d e f]
} {d e f}
# Note that Tcl complains about the missing brace here
# while Jim ignores it
test parse-1.25 "missing brace in var" jim {
unset -nocomplain a
set a 3
set brace \{
set x [subst \$${brace}a]
} 3
test parse-1.26 "newline in braced var" {
set "a\nb" var1
set x ${a
b}
} var1
test parse-1.27 "backslash escape in dict sugar" {
unset -nocomplain a
set a(b\x55d) 5
set x $a(b\x55d)
} 5
test parse-1.28 "nested dict sugar" {
unset -nocomplain a b
set a(V) 5
set b(5) five
set x $b($a(V))
} five
set dq {"}
set script "set x ${dq}hello"
test parse-1.29 "missing quote" -constraints jim -body {
eval $script
} -returnCodes error -match glob -result {missing quote}
test parse-1.30 "missing quote" {
info complete $script
} 0
test parse-1.31 "backslash newline in bare context" {
list abc\
123
} {abc 123}
test parse-1.32 "comment as last line of script" {
set script {set x 3; # this is a comment}
eval $script
} 3
test parse-1.33 "upper case hex escapes" {
list \x4A \x4F \x3C
} {J O <}
test parse-1.34 "octal escapes" {
list \112 \117 \074
} {J O <}
test parse-1.35 "invalid hex escape" {
list \xZZ
} xZZ
test parse-1.36 "unicode escape" jim {
list \u00b5
} \xc2\xb5
test parse-1.37 "invalid unicode escape after unicode" jim {
list \ub5x
} \xc2\xb5x
test parse-1.38 "invalid unicode escape" {
list \ux
} ux
test parse-1.39 "octal escape followed by invalid" {
list \76x
} >x
test parse-1.40 "list containing quoted trailing backslash" jim {
set x "abc \"def\\"
lindex $x 1
} def\\
test parse-1.41 "list containing quoted newline" {
set x {abc "def
ghi"}
lindex $x 1
} def\nghi
test parse-1.42 "list containing missing quote" jim {
set x {abc "def}
lindex $x 1
} def
test parse-1.43 "list containing trailing backslash" {
set x "abc def\\"
lindex $x 1
} def\\
test parse-1.44 "list creation" {
list "a{ }d"
} {{a{ }d}}
test parse-1.45 "spaces before expr function args" {
expr {round (3.2)}
} 3
test parse-1.46 "expr function missing paren" {
catch {expr {round 3.2}}
} 1
test parse-1.47 "backslash newline in quotes" {
# spaces
set x "abc\
def"
} "abc def"
test parse-1.48 "backslash newline in quotes" {
# tabs
set x "abc\
def"
} "abc def"
test parse-1.49 "backslash newline in quotes" {
# tabs plus newline
set x "abc\
def"
} "abc \ndef"
test parse-1.50 "backslash newline in quotes" {
# tabs plus newline
set x "abc\
def"
} "abc def"
test parse-1.51 "special chars in dict sugar" {
unset -nocomplain a
set a(x$) 5
array names a
} {{x$}}
test parse-1.52 "special chars in dict sugar" {
set x $a(x$)
} 5
test parse-1.53 "special chars in dict sugar" {
unset -nocomplain a
set a(x\[) 5
array names a
} {{x[}}
test parse-1.54 "special chars in dict sugar" {
set x $a(x\[)
} 5
test parse-1.55 "special chars in dict sugar" {
unset -nocomplain a
set a(x\() 5
array names a
} {x(}
test parse-1.56 "special chars in dict sugar" {
set x $a(x\()
} 5
test parse-1.57 "special chars in dict sugar" {
unset -nocomplain a
set a(x() 5
array names a
} {x(}
test parse-1.58 "special chars in dict sugar" {
set x $a(x()
} 5
test parse-1.59 "special chars in dict sugar" {
unset -nocomplain a
set a(x") 5
lindex [array names a] 0
} {x"}
test parse-1.60 "special chars in dict sugar" {
set x $a(x")
} 5
test parse-1.61 "quote in command" {
set x [list \\" x]
lindex $x end
} x
test parse-1.62 "quoted orphan dollar sign" {
set x "x$"
} {x$}
test parse-1.63 "unquoted dollar sign" {
set x x$
} {x$}
test parse-1.64 "backslash in comment" {
set x 0
# comment \
incr x
incr x
} 1
test parse-1.65 "double backslash in comment" {
set x 0
# comment \\
incr x
incr x
} 2
testreport
|