| 1 |
# This file contains a collection of tests for the procedures in the |
| 2 |
# file tclParse.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 {[catch {package require tcltest 2.0.2}]} { |
| 12 |
puts stderr "Skipping tests in [info script]. tcltest 2.0.2 required." |
| 13 |
return |
| 14 |
} |
| 15 |
|
| 16 |
namespace eval ::tcl::test::parse { |
| 17 |
namespace import ::tcltest::* |
| 18 |
|
| 19 |
::tcltest::loadTestedCommands |
| 20 |
catch [list package require -exact Tcltest [info patchlevel]] |
| 21 |
|
| 22 |
testConstraint testparser [llength [info commands testparser]] |
| 23 |
testConstraint testbytestring [llength [info commands testbytestring]] |
| 24 |
testConstraint testevalobjv [llength [info commands testevalobjv]] |
| 25 |
testConstraint testevalex [llength [info commands testevalex]] |
| 26 |
testConstraint testparsevarname [llength [info commands testparsevarname]] |
| 27 |
testConstraint testparsevar [llength [info commands testparsevar]] |
| 28 |
testConstraint testasync [llength [info commands testasync]] |
| 29 |
testConstraint testcmdtrace [llength [info commands testcmdtrace]] |
| 30 |
testConstraint testevent [llength [info commands testevent]] |
| 31 |
testConstraint memory [llength [info commands memory]] |
| 32 |
|
| 33 |
test parse-1.1 {Tcl_ParseCommand procedure, computing string length} {testparser testbytestring} { |
| 34 |
testparser [testbytestring "foo\0 bar"] -1 |
| 35 |
} {- foo 1 simple foo 1 text foo 0 {}} |
| 36 |
test parse-1.2 {Tcl_ParseCommand procedure, computing string length} testparser { |
| 37 |
testparser "foo bar" -1 |
| 38 |
} {- {foo bar} 2 simple foo 1 text foo 0 simple bar 1 text bar 0 {}} |
| 39 |
test parse-1.3 {Tcl_ParseCommand procedure, leading space} testparser { |
| 40 |
testparser " \n\t foo" 0 |
| 41 |
} {- foo 1 simple foo 1 text foo 0 {}} |
| 42 |
test parse-1.4 {Tcl_ParseCommand procedure, leading space} testparser { |
| 43 |
testparser "\f\r\vfoo" 0 |
| 44 |
} {- foo 1 simple foo 1 text foo 0 {}} |
| 45 |
test parse-1.5 {Tcl_ParseCommand procedure, backslash-newline in leading space} testparser { |
| 46 |
testparser " \\\n foo" 0 |
| 47 |
} {- foo 1 simple foo 1 text foo 0 {}} |
| 48 |
test parse-1.6 {Tcl_ParseCommand procedure, backslash-newline in leading space} testparser { |
| 49 |
testparser { \a foo} 0 |
| 50 |
} {- {\a foo} 2 word {\a} 1 backslash {\a} 0 simple foo 1 text foo 0 {}} |
| 51 |
test parse-1.7 {Tcl_ParseCommand procedure, missing continuation line in leading space} testparser { |
| 52 |
testparser " \\\n" 0 |
| 53 |
} {- {} 0 {}} |
| 54 |
test parse-1.8 {Tcl_ParseCommand procedure, eof in leading space} testparser { |
| 55 |
testparser " foo" 3 |
| 56 |
} {- {} 0 { foo}} |
| 57 |
test parse-1.9 {Tcl_ParseCommand procedure, backslash newline + newline} testparser { |
| 58 |
testparser "cmd1\\\n\ncmd2" 0 |
| 59 |
} {- cmd1\\\n\n 1 simple cmd1 1 text cmd1 0 cmd2} |
| 60 |
test parse-1.10 {Tcl_ParseCommand procedure, backslash newline + newline} testparser { |
| 61 |
testparser "list \\\nA B\\\n\nlist C D" 0 |
| 62 |
} {- list\ \\\nA\ B\\\n\n 3 simple list 1 text list 0 simple A 1 text A 0 simple B 1 text B 0 {list C D}} |
| 63 |
|
| 64 |
test parse-2.1 {Tcl_ParseCommand procedure, comments} testparser { |
| 65 |
testparser "# foo bar\n foo" 0 |
| 66 |
} {{# foo bar |
| 67 |
} foo 1 simple foo 1 text foo 0 {}} |
| 68 |
test parse-2.2 {Tcl_ParseCommand procedure, several comments} testparser { |
| 69 |
testparser " # foo bar\n # another comment\n\n foo" 0 |
| 70 |
} {{# foo bar |
| 71 |
# another comment |
| 72 |
} foo 1 simple foo 1 text foo 0 {}} |
| 73 |
test parse-2.3 {Tcl_ParseCommand procedure, backslash-newline in comments} testparser { |
| 74 |
testparser " # foo bar\\\ncomment on continuation line\nfoo" 0 |
| 75 |
} {\#\ foo\ bar\\\ncomment\ on\ continuation\ line\n foo 1 simple foo 1 text foo 0 {}} |
| 76 |
test parse-2.4 {Tcl_ParseCommand procedure, missing continuation line in comment} testparser { |
| 77 |
testparser "# \\\n" 0 |
| 78 |
} {\#\ \ \ \\\n {} 0 {}} |
| 79 |
test parse-2.5 {Tcl_ParseCommand procedure, eof in comment} testparser { |
| 80 |
testparser " # foo bar\nfoo" 8 |
| 81 |
} {{# foo b} {} 0 {ar |
| 82 |
foo}} |
| 83 |
|
| 84 |
test parse-3.1 {Tcl_ParseCommand procedure, parsing words, skipping space} testparser { |
| 85 |
testparser "foo bar\t\tx" 0 |
| 86 |
} {- {foo bar x} 3 simple foo 1 text foo 0 simple bar 1 text bar 0 simple x 1 text x 0 {}} |
| 87 |
test parse-3.2 {Tcl_ParseCommand procedure, missing continuation line in leading space} testparser { |
| 88 |
testparser "abc \\\n" 0 |
| 89 |
} {- abc\ \ \\\n 1 simple abc 1 text abc 0 {}} |
| 90 |
test parse-3.3 {Tcl_ParseCommand procedure, parsing words, command ends in space} testparser { |
| 91 |
testparser "foo ; bar x" 0 |
| 92 |
} {- {foo ;} 1 simple foo 1 text foo 0 { bar x}} |
| 93 |
test parse-3.4 {Tcl_ParseCommand procedure, parsing words, command ends in space} testparser { |
| 94 |
testparser "foo " 5 |
| 95 |
} {- {foo } 1 simple foo 1 text foo 0 { }} |
| 96 |
test parse-3.5 {Tcl_ParseCommand procedure, quoted words} testparser { |
| 97 |
testparser {foo "a b c" d "efg";} 0 |
| 98 |
} {- {foo "a b c" d "efg";} 4 simple foo 1 text foo 0 simple {"a b c"} 1 text {a b c} 0 simple d 1 text d 0 simple {"efg"} 1 text efg 0 {}} |
| 99 |
test parse-3.6 {Tcl_ParseCommand procedure, words in braces} testparser { |
| 100 |
testparser {foo {a $b [concat foo]} {c d}} 0 |
| 101 |
} {- {foo {a $b [concat foo]} {c d}} 3 simple foo 1 text foo 0 simple {{a $b [concat foo]}} 1 text {a $b [concat foo]} 0 simple {{c d}} 1 text {c d} 0 {}} |
| 102 |
test parse-3.7 {Tcl_ParseCommand procedure, error in unquoted word} testparser { |
| 103 |
list [catch {testparser "foo \$\{abc" 0} msg] $msg $::errorInfo |
| 104 |
} {1 {missing close-brace for variable name} missing\ close-brace\ for\ variable\ name\n\ \ \ \ (remainder\ of\ script:\ \"\{abc\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"foo\ \\\$\\\{abc\"\ 0\"} |
| 105 |
|
| 106 |
test parse-4.1 {Tcl_ParseCommand procedure, simple words} testparser { |
| 107 |
testparser {foo} 0 |
| 108 |
} {- foo 1 simple foo 1 text foo 0 {}} |
| 109 |
test parse-4.2 {Tcl_ParseCommand procedure, simple words} testparser { |
| 110 |
testparser {{abc}} 0 |
| 111 |
} {- {{abc}} 1 simple {{abc}} 1 text abc 0 {}} |
| 112 |
test parse-4.3 {Tcl_ParseCommand procedure, simple words} testparser { |
| 113 |
testparser {"c d"} 0 |
| 114 |
} {- {"c d"} 1 simple {"c d"} 1 text {c d} 0 {}} |
| 115 |
test parse-4.4 {Tcl_ParseCommand procedure, simple words} testparser { |
| 116 |
testparser {x$d} 0 |
| 117 |
} {- {x$d} 1 word {x$d} 3 text x 0 variable {$d} 1 text d 0 {}} |
| 118 |
test parse-4.5 {Tcl_ParseCommand procedure, simple words} testparser { |
| 119 |
testparser {"a [foo] b"} 0 |
| 120 |
} {- {"a [foo] b"} 1 word {"a [foo] b"} 3 text {a } 0 command {[foo]} 0 text { b} 0 {}} |
| 121 |
test parse-4.6 {Tcl_ParseCommand procedure, simple words} testparser { |
| 122 |
testparser {$x} 0 |
| 123 |
} {- {$x} 1 word {$x} 2 variable {$x} 1 text x 0 {}} |
| 124 |
|
| 125 |
test parse-5.1 {Tcl_ParseCommand procedure, backslash-newline terminates word} testparser { |
| 126 |
testparser "{abc}\\\n" 0 |
| 127 |
} {- \{abc\}\\\n 1 simple {{abc}} 1 text abc 0 {}} |
| 128 |
test parse-5.2 {Tcl_ParseCommand procedure, backslash-newline terminates word} testparser { |
| 129 |
testparser "foo\\\nbar" 0 |
| 130 |
} {- foo\\\nbar 2 simple foo 1 text foo 0 simple bar 1 text bar 0 {}} |
| 131 |
test parse-5.3 {Tcl_ParseCommand procedure, word terminator is command terminator} testparser { |
| 132 |
testparser "foo\n bar" 0 |
| 133 |
} {- {foo |
| 134 |
} 1 simple foo 1 text foo 0 { bar}} |
| 135 |
test parse-5.4 {Tcl_ParseCommand procedure, word terminator is command terminator} testparser { |
| 136 |
testparser "foo; bar" 0 |
| 137 |
} {- {foo;} 1 simple foo 1 text foo 0 { bar}} |
| 138 |
test parse-5.5 {Tcl_ParseCommand procedure, word terminator is end of string} testparser { |
| 139 |
testparser "\"foo\" bar" 5 |
| 140 |
} {- {"foo"} 1 simple {"foo"} 1 text foo 0 { bar}} |
| 141 |
test parse-5.6 {Tcl_ParseCommand procedure, junk after close quote} testparser { |
| 142 |
list [catch {testparser {foo "bar"x} 0} msg] $msg $::errorInfo |
| 143 |
} {1 {extra characters after close-quote} {extra characters after close-quote |
| 144 |
(remainder of script: "x") |
| 145 |
invoked from within |
| 146 |
"testparser {foo "bar"x} 0"}} |
| 147 |
test parse-5.7 {Tcl_ParseCommand procedure, backslash-newline after close quote} testparser { |
| 148 |
testparser "foo \"bar\"\\\nx" 0 |
| 149 |
} {- foo\ \"bar\"\\\nx 3 simple foo 1 text foo 0 simple {"bar"} 1 text bar 0 simple x 1 text x 0 {}} |
| 150 |
test parse-5.8 {Tcl_ParseCommand procedure, junk after close brace} testparser { |
| 151 |
list [catch {testparser {foo {bar}x} 0} msg] $msg $::errorInfo |
| 152 |
} {1 {extra characters after close-brace} {extra characters after close-brace |
| 153 |
(remainder of script: "x") |
| 154 |
invoked from within |
| 155 |
"testparser {foo {bar}x} 0"}} |
| 156 |
test parse-5.9 {Tcl_ParseCommand procedure, backslash-newline after close brace} testparser { |
| 157 |
testparser "foo {bar}\\\nx" 0 |
| 158 |
} {- foo\ \{bar\}\\\nx 3 simple foo 1 text foo 0 simple {{bar}} 1 text bar 0 simple x 1 text x 0 {}} |
| 159 |
test parse-5.10 {Tcl_ParseCommand procedure, multiple deletion of non-static buffer} testparser { |
| 160 |
# This test is designed to catch bug 1681. |
| 161 |
list [catch {testparser "a \"\\1\\2\\3\\4\\5\\6\\7\\8\\9\\1\\2\\3\\4\\5\\6\\7\\8" 0} msg] $msg $::errorInfo |
| 162 |
} "1 {missing \"} {missing \" |
| 163 |
(remainder of script: \"\"\\1\\2\\3\\4\\5\\6\\7\\8\\9\\1\\2\\3\\4\\5\\6\\7\\8\") |
| 164 |
invoked from within |
| 165 |
\"testparser \"a \\\"\\\\1\\\\2\\\\3\\\\4\\\\5\\\\6\\\\7\\\\8\\\\9\\\\1\\\\2\\\\3\\\\4\\\\5\\\\6\\\\7\\\\8\" 0\"}" |
| 166 |
|
| 167 |
test parse-5.11 {Tcl_ParseCommand: {*} parsing} testparser { |
| 168 |
testparser {{expan}} 0 |
| 169 |
} {- {{expan}} 1 simple {{expan}} 1 text expan 0 {}} |
| 170 |
test parse-5.12 {Tcl_ParseCommand: {*} parsing} -constraints { |
| 171 |
testparser |
| 172 |
} -body { |
| 173 |
testparser {{expan}x} 0 |
| 174 |
} -returnCodes error -result {extra characters after close-brace} |
| 175 |
test parse-5.13 {Tcl_ParseCommand: {*} parsing} testparser { |
| 176 |
testparser {{**}} 0 |
| 177 |
} {- {{**}} 1 simple {{**}} 1 text ** 0 {}} |
| 178 |
test parse-5.14 {Tcl_ParseCommand: {*} parsing} -constraints { |
| 179 |
testparser |
| 180 |
} -body { |
| 181 |
testparser {{**}x} 0 |
| 182 |
} -returnCodes error -result {extra characters after close-brace} |
| 183 |
test parse-5.15 {Tcl_ParseCommand: {*} parsing} -constraints { |
| 184 |
testparser |
| 185 |
} -body { |
| 186 |
testparser {{*}{123456}x} 0 |
| 187 |
} -returnCodes error -result {extra characters after close-brace} |
| 188 |
test parse-5.16 {Tcl_ParseCommand: {*} parsing} testparser { |
| 189 |
testparser {{123456\ |
| 190 |
}} 0 |
| 191 |
} {- {{123456 }} 1 simple {{123456 }} 1 text {123456 } 0 {}} |
| 192 |
test parse-5.17 {Tcl_ParseCommand: {*} parsing} -constraints { |
| 193 |
testparser |
| 194 |
} -body { |
| 195 |
testparser {{123456\ |
| 196 |
}x} 0 |
| 197 |
} -returnCodes error -result {extra characters after close-brace} |
| 198 |
test parse-5.18 {Tcl_ParseCommand: {*} parsing} testparser { |
| 199 |
testparser {{*\ |
| 200 |
}} 0 |
| 201 |
} {- {{* }} 1 simple {{* }} 1 text {* } 0 {}} |
| 202 |
test parse-5.19 {Tcl_ParseCommand: {*} parsing} -constraints { |
| 203 |
testparser |
| 204 |
} -body { |
| 205 |
testparser {{*\ |
| 206 |
}x} 0 |
| 207 |
} -returnCodes error -result {extra characters after close-brace} |
| 208 |
test parse-5.20 {Tcl_ParseCommand: {*} parsing} testparser { |
| 209 |
testparser {{123456}} 0 |
| 210 |
} {- {{123456}} 1 simple {{123456}} 1 text 123456 0 {}} |
| 211 |
test parse-5.21 {Tcl_ParseCommand: {*} parsing} -constraints { |
| 212 |
testparser |
| 213 |
} -body { |
| 214 |
testparser {{123456}x} 0 |
| 215 |
} -returnCodes error -result {extra characters after close-brace} |
| 216 |
test parse-5.22 {Tcl_ParseCommand: {*} parsing} testparser { |
| 217 |
testparser {{*}} 0 |
| 218 |
} {- {{*}} 1 simple {{*}} 1 text * 0 {}} |
| 219 |
test parse-5.23 {Tcl_ParseCommand: {*} parsing} testparser { |
| 220 |
testparser {{*} } 0 |
| 221 |
} {- {{*} } 1 simple {{*}} 1 text * 0 {}} |
| 222 |
test parse-5.24 {Tcl_ParseCommand: {*} parsing} testparser { |
| 223 |
testparser {{*}x} 0 |
| 224 |
} {- {{*}x} 1 simple x 1 text x 0 {}} |
| 225 |
test parse-5.25 {Tcl_ParseCommand: {*} parsing} testparser { |
| 226 |
testparser {{*} |
| 227 |
} 0 |
| 228 |
} {- {{*} |
| 229 |
} 1 simple {{*}} 1 text * 0 {}} |
| 230 |
test parse-5.26 {Tcl_ParseCommand: {*} parsing} testparser { |
| 231 |
testparser {{*};} 0 |
| 232 |
} {- {{*};} 1 simple {{*}} 1 text * 0 {}} |
| 233 |
test parse-5.27 {Tcl_ParseCommand: {*} parsing} testparser { |
| 234 |
testparser "{*}\\\n foo bar" 0 |
| 235 |
} {- \{*\}\\\n\ foo\ bar 3 simple {{*}} 1 text * 0 simple foo 1 text foo 0 simple bar 1 text bar 0 {}} |
| 236 |
test parse-5.28 {Tcl_ParseCommand: {*} parsing, expanded literals} testparser { |
| 237 |
testparser {{*}{a b}} 0 |
| 238 |
} {- {{*}{a b}} 2 simple a 1 text a 0 simple b 1 text b 0 {}} |
| 239 |
test parse-5.29 {Tcl_ParseCommand: {*} parsing, expanded literals, naked backslashes} testparser { |
| 240 |
testparser {{*}{a \n b}} 0 |
| 241 |
} {- {{*}{a \n b}} 1 expand {{*}{a \n b}} 1 text {a \n b} 0 {}} |
| 242 |
test parse-5.30 {Tcl_ParseCommand: {*} parsing, expanded literals} testparser { |
| 243 |
testparser {{*}"a b"} 0 |
| 244 |
} {- {{*}"a b"} 2 simple a 1 text a 0 simple b 1 text b 0 {}} |
| 245 |
test parse-5.31 {Tcl_ParseCommand: {*} parsing, expanded literals, naked backslashes} testparser { |
| 246 |
testparser {{*}"a \n b"} 0 |
| 247 |
} {- {{*}"a \n b"} 1 expand {{*}"a \n b"} 3 text {a } 0 backslash {\n} 0 text { b} 0 {}} |
| 248 |
|
| 249 |
test parse-6.1 {ParseTokens procedure, empty word} testparser { |
| 250 |
testparser {""} 0 |
| 251 |
} {- {""} 1 simple {""} 1 text {} 0 {}} |
| 252 |
test parse-6.2 {ParseTokens procedure, simple range} testparser { |
| 253 |
testparser {"abc$x.e"} 0 |
| 254 |
} {- {"abc$x.e"} 1 word {"abc$x.e"} 4 text abc 0 variable {$x} 1 text x 0 text .e 0 {}} |
| 255 |
test parse-6.3 {ParseTokens procedure, variable reference} testparser { |
| 256 |
testparser {abc$x.e $y(z)} 0 |
| 257 |
} {- {abc$x.e $y(z)} 2 word {abc$x.e} 4 text abc 0 variable {$x} 1 text x 0 text .e 0 word {$y(z)} 3 variable {$y(z)} 2 text y 0 text z 0 {}} |
| 258 |
test parse-6.4 {ParseTokens procedure, variable reference} testparser { |
| 259 |
list [catch {testparser {$x([a )} 0} msg] $msg |
| 260 |
} {1 {missing close-bracket}} |
| 261 |
test parse-6.5 {ParseTokens procedure, command substitution} testparser { |
| 262 |
testparser {[foo $x bar]z} 0 |
| 263 |
} {- {[foo $x bar]z} 1 word {[foo $x bar]z} 2 command {[foo $x bar]} 0 text z 0 {}} |
| 264 |
test parse-6.6 {ParseTokens procedure, command substitution} testparser { |
| 265 |
testparser {[foo \] [a b]]} 0 |
| 266 |
} {- {[foo \] [a b]]} 1 word {[foo \] [a b]]} 1 command {[foo \] [a b]]} 0 {}} |
| 267 |
test parse-6.7 {ParseTokens procedure, error in command substitution} testparser { |
| 268 |
list [catch {testparser {a [b {}c d] e} 0} msg] $msg $::errorInfo |
| 269 |
} {1 {extra characters after close-brace} {extra characters after close-brace |
| 270 |
(remainder of script: "c d] e") |
| 271 |
invoked from within |
| 272 |
"testparser {a [b {}c d] e} 0"}} |
| 273 |
test parse-6.8 {ParseTokens procedure, error in command substitution} { |
| 274 |
info complete {a [b {}c d]} |
| 275 |
} {1} |
| 276 |
test parse-6.9 {ParseTokens procedure, error in command substitution} { |
| 277 |
info complete {a [b "c d} |
| 278 |
} {0} |
| 279 |
test parse-6.10 {ParseTokens procedure, incomplete sub-command} { |
| 280 |
info complete {puts [ |
| 281 |
expr {1+1} |
| 282 |
#this is a comment ]} |
| 283 |
} {0} |
| 284 |
test parse-6.11 {ParseTokens procedure, memory allocation for big nested command} testparser { |
| 285 |
testparser {[$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b)]} 0 |
| 286 |
} {- {[$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b)]} 1 word {[$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b)]} 1 command {[$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b)]} 0 {}} |
| 287 |
test parse-6.12 {ParseTokens procedure, missing close bracket} testparser { |
| 288 |
list [catch {testparser {[foo $x bar} 0} msg] $msg $::errorInfo |
| 289 |
} {1 {missing close-bracket} {missing close-bracket |
| 290 |
(remainder of script: "[foo $x bar") |
| 291 |
invoked from within |
| 292 |
"testparser {[foo $x bar} 0"}} |
| 293 |
test parse-6.13 {ParseTokens procedure, backslash-newline without continuation line} testparser { |
| 294 |
list [catch {testparser "\"a b\\\n" 0} msg] $msg $::errorInfo |
| 295 |
} {1 {missing "} missing\ \"\n\ \ \ \ (remainder\ of\ script:\ \"\"a\ b\\\n\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"\\\"a\ b\\\\\\n\"\ 0\"} |
| 296 |
test parse-6.14 {ParseTokens procedure, backslash-newline} testparser { |
| 297 |
testparser "b\\\nc" 0 |
| 298 |
} {- b\\\nc 2 simple b 1 text b 0 simple c 1 text c 0 {}} |
| 299 |
test parse-6.15 {ParseTokens procedure, backslash-newline} testparser { |
| 300 |
testparser "\"b\\\nc\"" 0 |
| 301 |
} {- \"b\\\nc\" 1 word \"b\\\nc\" 3 text b 0 backslash \\\n 0 text c 0 {}} |
| 302 |
test parse-6.16 {ParseTokens procedure, backslash substitution} testparser { |
| 303 |
testparser {\n\a\x7f} 0 |
| 304 |
} {- {\n\a\x7f} 1 word {\n\a\x7f} 3 backslash {\n} 0 backslash {\a} 0 backslash {\x7f} 0 {}} |
| 305 |
test parse-6.17 {ParseTokens procedure, null characters} {testparser testbytestring} { |
| 306 |
expr {[testparser [testbytestring "foo\0zz"] 0] eq |
| 307 |
"- [testbytestring foo\0zz] 1 word [testbytestring foo\0zz] 3 text foo 0 text [testbytestring \0] 0 text zz 0 {}" |
| 308 |
} |
| 309 |
} 1 |
| 310 |
test parse-6.18 {ParseTokens procedure, seek past numBytes for close-bracket} testparser { |
| 311 |
# Test for Bug 681841 |
| 312 |
list [catch {testparser {[a]} 2} msg] $msg |
| 313 |
} {1 {missing close-bracket}} |
| 314 |
|
| 315 |
test parse-7.1 {Tcl_FreeParse and ExpandTokenArray procedures} testparser { |
| 316 |
testparser {$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) } 0 |
| 317 |
} {- {$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) } 16 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 {}} |
| 318 |
|
| 319 |
test parse-8.1 {Tcl_EvalObjv procedure} testevalobjv { |
| 320 |
testevalobjv 0 concat this is a test |
| 321 |
} {this is a test} |
| 322 |
test parse-8.2 {Tcl_EvalObjv procedure, unknown commands} testevalobjv { |
| 323 |
rename ::unknown unknown.old |
| 324 |
set x [catch {testevalobjv 10 asdf poiu} msg] |
| 325 |
rename unknown.old ::unknown |
| 326 |
list $x $msg |
| 327 |
} {1 {invalid command name "asdf"}} |
| 328 |
test parse-8.3 {Tcl_EvalObjv procedure, unknown commands} testevalobjv { |
| 329 |
rename ::unknown unknown.old |
| 330 |
proc ::unknown args { |
| 331 |
return "unknown $args" |
| 332 |
} |
| 333 |
set x [catch {testevalobjv 0 asdf poiu} msg] |
| 334 |
rename ::unknown {} |
| 335 |
rename unknown.old ::unknown |
| 336 |
list $x $msg |
| 337 |
} {0 {unknown asdf poiu}} |
| 338 |
test parse-8.4 {Tcl_EvalObjv procedure, unknown commands} testevalobjv { |
| 339 |
rename ::unknown unknown.old |
| 340 |
proc ::unknown args { |
| 341 |
error "I don't like that command" |
| 342 |
} |
| 343 |
set x [catch {testevalobjv 0 asdf poiu} msg] |
| 344 |
rename ::unknown {} |
| 345 |
rename unknown.old ::unknown |
| 346 |
list $x $msg |
| 347 |
} {1 {I don't like that command}} |
| 348 |
test parse-8.5 {Tcl_EvalObjv procedure, command traces} {testevalobjv testcmdtrace} { |
| 349 |
testevalobjv 0 set x 123 |
| 350 |
testcmdtrace tracetest {testevalobjv 0 set x $x} |
| 351 |
} {{testevalobjv 0 set x $x} {testevalobjv 0 set x 123} {set x 123} {set x 123}} |
| 352 |
test parse-8.7 {Tcl_EvalObjv procedure, TCL_EVAL_GLOBAL flag} -constraints { |
| 353 |
testevalobjv |
| 354 |
} -setup { |
| 355 |
proc x {} { |
| 356 |
set y 23 |
| 357 |
set z [testevalobjv 1 set y] |
| 358 |
return [list $z $y] |
| 359 |
} |
| 360 |
set ::y 16 |
| 361 |
} -cleanup { |
| 362 |
unset ::y |
| 363 |
} -body { |
| 364 |
x |
| 365 |
} -result {16 23} |
| 366 |
test parse-8.8 {Tcl_EvalObjv procedure, async handlers} -constraints { |
| 367 |
testevalobjv testasync |
| 368 |
} -setup { |
| 369 |
variable ::aresult |
| 370 |
variable ::acode |
| 371 |
proc async1 {result code} { |
| 372 |
variable ::aresult |
| 373 |
variable ::acode |
| 374 |
set aresult $result |
| 375 |
set acode $code |
| 376 |
return "new result" |
| 377 |
} |
| 378 |
set handler1 [testasync create async1] |
| 379 |
set aresult xxx |
| 380 |
set acode yyy |
| 381 |
} -cleanup { |
| 382 |
testasync delete |
| 383 |
} -body { |
| 384 |
list [testevalobjv 0 testasync mark $handler1 original 0] $acode $aresult |
| 385 |
} -result {{new result} 0 original} |
| 386 |
test parse-8.9 {Tcl_EvalObjv procedure, exceptional return} testevalobjv { |
| 387 |
list [catch {testevalobjv 0 error message} msg] $msg |
| 388 |
} {1 message} |
| 389 |
test parse-8.10 {Tcl_EvalObjv procedure, TCL_EVAL_GLOBAL} testevalobjv { |
| 390 |
rename ::unknown unknown.save |
| 391 |
proc ::unknown args {lappend ::info [info level]} |
| 392 |
catch {rename ::noSuchCommand {}} |
| 393 |
set ::info {} |
| 394 |
namespace eval test_ns_1 { |
| 395 |
testevalobjv 1 noSuchCommand |
| 396 |
uplevel #0 noSuchCommand |
| 397 |
} |
| 398 |
namespace delete test_ns_1 |
| 399 |
rename ::unknown {} |
| 400 |
rename unknown.save ::unknown |
| 401 |
set ::info |
| 402 |
} {1 1} |
| 403 |
test parse-8.11 {Tcl_EvalObjv procedure, TCL_EVAL_INVOKE} testevalobjv { |
| 404 |
rename ::unknown unknown.save |
| 405 |
proc ::unknown args {lappend ::info [info level]; uplevel 1 foo} |
| 406 |
proc ::foo args {lappend ::info global} |
| 407 |
catch {rename ::noSuchCommand {}} |
| 408 |
set ::child [interp create] |
| 409 |
$::child alias bar noSuchCommand |
| 410 |
set ::info {} |
| 411 |
namespace eval test_ns_1 { |
| 412 |
proc foo args {lappend ::info namespace} |
| 413 |
$::child eval bar |
| 414 |
testevalobjv 1 [list $::child eval bar] |
| 415 |
uplevel #0 [list $::child eval bar] |
| 416 |
} |
| 417 |
namespace delete test_ns_1 |
| 418 |
rename ::foo {} |
| 419 |
rename ::unknown {} |
| 420 |
rename unknown.save ::unknown |
| 421 |
set ::info |
| 422 |
} [subst {[set level 2; incr level [info level]] global 1 global 1 global}] |
| 423 |
test parse-8.12 {Tcl_EvalObjv procedure, TCL_EVAL_INVOKE} { |
| 424 |
set ::auto_index(noSuchCommand) { |
| 425 |
proc noSuchCommand {} {lappend ::info global} |
| 426 |
} |
| 427 |
set ::auto_index(::[string trimleft [namespace current]::test_ns_1::noSuchCommand :]) [list \ |
| 428 |
proc [namespace current]::test_ns_1::noSuchCommand {} { |
| 429 |
lappend ::info ns |
| 430 |
}] |
| 431 |
catch {rename ::noSuchCommand {}} |
| 432 |
set ::child [interp create] |
| 433 |
$::child alias bar noSuchCommand |
| 434 |
set ::info {} |
| 435 |
namespace eval test_ns_1 { |
| 436 |
$::child eval bar |
| 437 |
} |
| 438 |
namespace delete test_ns_1 |
| 439 |
interp delete $::child |
| 440 |
catch {rename ::noSuchCommand {}} |
| 441 |
set ::info |
| 442 |
} global |
| 443 |
|
| 444 |
|
| 445 |
test parse-9.1 {Tcl_LogCommandInfo, line numbers} testevalex { |
| 446 |
unset -nocomplain x |
| 447 |
list [catch {testevalex {for {} 1 {} { |
| 448 |
|
| 449 |
|
| 450 |
# asdf |
| 451 |
set x |
| 452 |
}}}] $::errorInfo |
| 453 |
} {1 {can't read "x": no such variable |
| 454 |
while executing |
| 455 |
"set x" |
| 456 |
("for" body line 5) |
| 457 |
invoked from within |
| 458 |
"for {} 1 {} { |
| 459 |
|
| 460 |
|
| 461 |
# asdf |
| 462 |
set x |
| 463 |
}" |
| 464 |
invoked from within |
| 465 |
"testevalex {for {} 1 {} { |
| 466 |
|
| 467 |
|
| 468 |
# asdf |
| 469 |
set x |
| 470 |
}}"}} |
| 471 |
test parse-9.2 {Tcl_LogCommandInfo, truncating long commands} { |
| 472 |
list [catch {set a b 111111111 222222222 333333333 444444444 555555555 666666666 777777777 888888888 999999999 000000000 aaaaaaaaa bbbbbbbbb ccccccccc ddddddddd eeeeeeeee fffffffff ggggggggg}] $::errorInfo |
| 473 |
} {1 {wrong # args: should be "set varName ?newValue?" |
| 474 |
while executing |
| 475 |
"set a b 111111111 222222222 333333333 444444444 555555555 666666666 777777777 888888888 999999999 000000000 aaaaaaaaa bbbbbbbbb ccccccccc ddddddddd ee..."}} |
| 476 |
|
| 477 |
test parse-10.1 {Tcl_EvalTokens, simple text} testevalex { |
| 478 |
testevalex {concat test} |
| 479 |
} {test} |
| 480 |
test parse-10.2 {Tcl_EvalTokens, backslash sequences} testevalex { |
| 481 |
testevalex {concat test\063\062test} |
| 482 |
} {test32test} |
| 483 |
test parse-10.3 {Tcl_EvalTokens, nested commands} testevalex { |
| 484 |
testevalex {concat [expr {2 + 6}]} |
| 485 |
} {8} |
| 486 |
test parse-10.4 {Tcl_EvalTokens, nested commands} testevalex { |
| 487 |
unset -nocomplain a |
| 488 |
list [catch {testevalex {concat xxx[expr {$a}]}} msg] $msg |
| 489 |
} {1 {can't read "a": no such variable}} |
| 490 |
test parse-10.5 {Tcl_EvalTokens, simple variables} testevalex { |
| 491 |
set a hello |
| 492 |
testevalex {concat $a} |
| 493 |
} {hello} |
| 494 |
test parse-10.6 {Tcl_EvalTokens, array variables} testevalex { |
| 495 |
unset -nocomplain a |
| 496 |
set a(12) 46 |
| 497 |
testevalex {concat $a(12)} |
| 498 |
} {46} |
| 499 |
test parse-10.7 {Tcl_EvalTokens, array variables} testevalex { |
| 500 |
unset -nocomplain a |
| 501 |
set a(12) 46 |
| 502 |
testevalex {concat $a(1[expr {3 - 1}])} |
| 503 |
} {46} |
| 504 |
test parse-10.8 {Tcl_EvalTokens, array variables} testevalex { |
| 505 |
unset -nocomplain a |
| 506 |
list [catch {testevalex {concat $x($a)}} msg] $msg |
| 507 |
} {1 {can't read "a": no such variable}} |
| 508 |
test parse-10.9 {Tcl_EvalTokens, array variables} testevalex { |
| 509 |
unset -nocomplain a |
| 510 |
list [catch {testevalex {concat xyz$a(1)}} msg] $msg |
| 511 |
} {1 {can't read "a(1)": no such variable}} |
| 512 |
test parse-10.10 {Tcl_EvalTokens, object values} testevalex { |
| 513 |
set a 123 |
| 514 |
testevalex {concat $a} |
| 515 |
} {123} |
| 516 |
test parse-10.11 {Tcl_EvalTokens, object values} testevalex { |
| 517 |
set a 123 |
| 518 |
testevalex {concat $a$a$a} |
| 519 |
} {123123123} |
| 520 |
test parse-10.12 {Tcl_EvalTokens, object values} testevalex { |
| 521 |
testevalex {concat [expr {2}][expr {4}][expr {6}]} |
| 522 |
} {246} |
| 523 |
test parse-10.13 {Tcl_EvalTokens, string values} testevalex { |
| 524 |
testevalex {concat {a" b"}} |
| 525 |
} {a" b"} |
| 526 |
test parse-10.14 {Tcl_EvalTokens, string values} testevalex { |
| 527 |
set a 111 |
| 528 |
testevalex {concat x$a.$a.$a} |
| 529 |
} {x111.111.111} |
| 530 |
|
| 531 |
test parse-11.1 {Tcl_EvalEx, TCL_EVAL_GLOBAL flag} -constraints { |
| 532 |
testevalex |
| 533 |
} -setup { |
| 534 |
proc x {} { |
| 535 |
set y 777 |
| 536 |
set z [testevalex "set y" global] |
| 537 |
return [list $z $y] |
| 538 |
} |
| 539 |
set ::y 321 |
| 540 |
} -cleanup { |
| 541 |
unset ::y |
| 542 |
} -body { |
| 543 |
x |
| 544 |
} -result {321 777} |
| 545 |
test parse-11.2 {Tcl_EvalEx, error while parsing} testevalex { |
| 546 |
list [catch {testevalex {concat "abc}} msg] $msg |
| 547 |
} {1 {missing "}} |
| 548 |
test parse-11.3 {Tcl_EvalEx, error while collecting words} testevalex { |
| 549 |
unset -nocomplain a |
| 550 |
list [catch {testevalex {concat xyz $a}} msg] $msg |
| 551 |
} {1 {can't read "a": no such variable}} |
| 552 |
test parse-11.4 {Tcl_EvalEx, error in Tcl_EvalObjv call} testevalex { |
| 553 |
unset -nocomplain a |
| 554 |
list [catch {testevalex {_bogus_ a b c d}} msg] $msg |
| 555 |
} {1 {invalid command name "_bogus_"}} |
| 556 |
test parse-11.5 {Tcl_EvalEx, exceptional return} testevalex { |
| 557 |
list [catch {testevalex {break}} msg] $msg |
| 558 |
} {3 {}} |
| 559 |
test parse-11.6 {Tcl_EvalEx, freeing memory} testevalex { |
| 560 |
testevalex {concat a b c d e f g h i j k l m n o p q r s t u v w x y z} |
| 561 |
} {a b c d e f g h i j k l m n o p q r s t u v w x y z} |
| 562 |
test parse-11.7 {Tcl_EvalEx, multiple commands in script} testevalex { |
| 563 |
list [testevalex {set a b; set c d}] $a $c |
| 564 |
} {d b d} |
| 565 |
test parse-11.8 {Tcl_EvalEx, multiple commands in script} testevalex { |
| 566 |
list [testevalex { |
| 567 |
set a b |
| 568 |
set c d |
| 569 |
}] $a $c |
| 570 |
} {d b d} |
| 571 |
test parse-11.9 {Tcl_EvalEx, freeing memory after error} testevalex { |
| 572 |
unset -nocomplain a |
| 573 |
list [catch {testevalex {concat a b c d e f g h i j k l m n o p q r s t u v w x y z $a}} msg] $msg |
| 574 |
} {1 {can't read "a": no such variable}} |
| 575 |
test parse-11.10 {Tcl_EvalTokens, empty commands} testevalex { |
| 576 |
testevalex {concat xyz; } |
| 577 |
} {xyz} |
| 578 |
test parse-11.11 {Tcl_EvalTokens, empty commands} testevalex { |
| 579 |
testevalex "concat abc; ; # this is a comment\n" |
| 580 |
} {abc} |
| 581 |
test parse-11.12 {Tcl_EvalTokens, empty commands} testevalex { |
| 582 |
testevalex {} |
| 583 |
} {} |
| 584 |
|
| 585 |
test parse-12.1 {Tcl_ParseVarName procedure, initialization} testparsevarname { |
| 586 |
list [catch {testparsevarname {$a([first second])} 8 0} msg] $msg |
| 587 |
} {1 {missing close-bracket}} |
| 588 |
test parse-12.2 {Tcl_ParseVarName procedure, initialization} testparsevarname { |
| 589 |
testparsevarname {$a([first second])} 0 0 |
| 590 |
} {- {} 0 variable {$a([first second])} 2 text a 0 command {[first second]} 0 {}} |
| 591 |
test parse-12.3 {Tcl_ParseVarName procedure, initialization} testparsevarname { |
| 592 |
list [catch {testparsevarname {$abcd} 3 0} msg] $msg |
| 593 |
} {0 {- {} 0 variable {$ab} 1 text ab 0 cd}} |
| 594 |
test parse-12.4 {Tcl_ParseVarName procedure, initialization} testparsevarname { |
| 595 |
testparsevarname {$abcd} 0 0 |
| 596 |
} {- {} 0 variable {$abcd} 1 text abcd 0 {}} |
| 597 |
test parse-12.5 {Tcl_ParseVarName procedure, just a dollar sign} testparsevarname { |
| 598 |
testparsevarname {$abcd} 1 0 |
| 599 |
} {- {} 0 text {$} 0 abcd} |
| 600 |
test parse-12.6 {Tcl_ParseVarName procedure, braced variable name} testparser { |
| 601 |
testparser {${..[]b}cd} 0 |
| 602 |
} {- {${..[]b}cd} 1 word {${..[]b}cd} 3 variable {${..[]b}} 1 text {..[]b} 0 text cd 0 {}} |
| 603 |
test parse-12.7 {Tcl_ParseVarName procedure, braced variable name} testparser { |
| 604 |
testparser "\$\{\{\} " 0 |
| 605 |
} {- \$\{\{\}\ 1 word \$\{\{\} 2 variable \$\{\{\} 1 text \{ 0 {}} |
| 606 |
test parse-12.8 {Tcl_ParseVarName procedure, missing close brace} testparser { |
| 607 |
list [catch {testparser "$\{abc" 0} msg] $msg $::errorInfo |
| 608 |
} {1 {missing close-brace for variable name} missing\ close-brace\ for\ variable\ name\n\ \ \ \ (remainder\ of\ script:\ \"\{abc\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"\$\\\{abc\"\ 0\"} |
| 609 |
test parse-12.9 {Tcl_ParseVarName procedure, missing close brace} testparsevarname { |
| 610 |
list [catch {testparsevarname {${bcd}} 4 0} msg] $msg |
| 611 |
} {1 {missing close-brace for variable name}} |
| 612 |
test parse-12.10 {Tcl_ParseVarName procedure, missing close brace} testparsevarname { |
| 613 |
list [catch {testparsevarname {${bc}} 4 0} msg] $msg |
| 614 |
} {1 {missing close-brace for variable name}} |
| 615 |
test parse-12.11 {Tcl_ParseVarName procedure, simple variable name} testparser { |
| 616 |
testparser {$az_AZ.} 0 |
| 617 |
} {- {$az_AZ.} 1 word {$az_AZ.} 3 variable {$az_AZ} 1 text az_AZ 0 text . 0 {}} |
| 618 |
test parse-12.12 {Tcl_ParseVarName procedure, simple variable name} testparser { |
| 619 |
testparser {$abcdefg} 4 |
| 620 |
} {- {$abc} 1 word {$abc} 2 variable {$abc} 1 text abc 0 defg} |
| 621 |
test parse-12.13 {Tcl_ParseVarName procedure, simple variable name with ::} testparser { |
| 622 |
testparser {$xyz::ab:c} 0 |
| 623 |
} {- {$xyz::ab:c} 1 word {$xyz::ab:c} 3 variable {$xyz::ab} 1 text xyz::ab 0 text :c 0 {}} |
| 624 |
test parse-12.14 {Tcl_ParseVarName procedure, variable names with many colons} testparser { |
| 625 |
testparser {$xyz:::::c} 0 |
| 626 |
} {- {$xyz:::::c} 1 word {$xyz:::::c} 2 variable {$xyz:::::c} 1 text xyz:::::c 0 {}} |
| 627 |
test parse-12.15 {Tcl_ParseVarName procedure, : vs. ::} testparsevarname { |
| 628 |
testparsevarname {$ab:cd} 0 0 |
| 629 |
} {- {} 0 variable {$ab} 1 text ab 0 :cd} |
| 630 |
test parse-12.16 {Tcl_ParseVarName procedure, eof in ::} testparsevarname { |
| 631 |
testparsevarname {$ab::cd} 4 0 |
| 632 |
} {- {} 0 variable {$ab} 1 text ab 0 ::cd} |
| 633 |
test parse-12.17 {Tcl_ParseVarName procedure, eof in ::} testparsevarname { |
| 634 |
testparsevarname {$ab:::cd} 5 0 |
| 635 |
} {- {} 0 variable {$ab::} 1 text ab:: 0 :cd} |
| 636 |
test parse-12.18 {Tcl_ParseVarName procedure, no variable name} testparser { |
| 637 |
testparser {$$ $.} 0 |
| 638 |
} {- {$$ $.} 2 word {$$} 2 text {$} 0 text {$} 0 word {$.} 2 text {$} 0 text . 0 {}} |
| 639 |
test parse-12.19 {Tcl_ParseVarName procedure, EOF before (} testparsevarname { |
| 640 |
testparsevarname {$ab(cd)} 3 0 |
| 641 |
} {- {} 0 variable {$ab} 1 text ab 0 (cd)} |
| 642 |
test parse-12.20 {Tcl_ParseVarName procedure, array reference} testparser { |
| 643 |
testparser {$x(abc)} 0 |
| 644 |
} {- {$x(abc)} 1 word {$x(abc)} 3 variable {$x(abc)} 2 text x 0 text abc 0 {}} |
| 645 |
test parse-12.21 {Tcl_ParseVarName procedure, array reference} testparser { |
| 646 |
testparser {$x(ab$cde[foo bar])} 0 |
| 647 |
} {- {$x(ab$cde[foo bar])} 1 word {$x(ab$cde[foo bar])} 6 variable {$x(ab$cde[foo bar])} 5 text x 0 text ab 0 variable {$cde} 1 text cde 0 command {[foo bar]} 0 {}} |
| 648 |
test parse-12.22 {Tcl_ParseVarName procedure, array reference} testparser { |
| 649 |
testparser {$x([cmd arg]zz)} 0 |
| 650 |
} {- {$x([cmd arg]zz)} 1 word {$x([cmd arg]zz)} 4 variable {$x([cmd arg]zz)} 3 text x 0 command {[cmd arg]} 0 text zz 0 {}} |
| 651 |
test parse-12.23 {Tcl_ParseVarName procedure, missing close paren in array reference} testparser { |
| 652 |
list [catch {testparser {$x(poiu} 0} msg] $msg $::errorInfo |
| 653 |
} {1 {missing )} {missing ) |
| 654 |
(remainder of script: "(poiu") |
| 655 |
invoked from within |
| 656 |
"testparser {$x(poiu} 0"}} |
| 657 |
test parse-12.24 {Tcl_ParseVarName procedure, missing close paren in array reference} testparsevarname { |
| 658 |
list [catch {testparsevarname {$ab(cd)} 6 0} msg] $msg $::errorInfo |
| 659 |
} {1 {missing )} {missing ) |
| 660 |
(remainder of script: "(cd)") |
| 661 |
invoked from within |
| 662 |
"testparsevarname {$ab(cd)} 6 0"}} |
| 663 |
test parse-12.25 {Tcl_ParseVarName procedure, nested array reference} testparser { |
| 664 |
testparser {$x(a$y(b$z))} 0 |
| 665 |
} {- {$x(a$y(b$z))} 1 word {$x(a$y(b$z))} 8 variable {$x(a$y(b$z))} 7 text x 0 text a 0 variable {$y(b$z)} 4 text y 0 text b 0 variable {$z} 1 text z 0 {}} |
| 666 |
test parse-12.26 {Tcl_ParseVarName [d2ffcca163] non-ascii} testparser { |
| 667 |
testparser "$\u0433" -1 |
| 668 |
} "- {$\u0433} 1 word {$\u0433} 2 text {$} 0 text \u0433 0 {}" |
| 669 |
|
| 670 |
test parse-13.1 {Tcl_ParseVar procedure} testparsevar { |
| 671 |
set abc 24 |
| 672 |
testparsevar {$abc.fg} |
| 673 |
} {24 .fg} |
| 674 |
test parse-13.2 {Tcl_ParseVar procedure, no variable name} testparsevar { |
| 675 |
testparsevar {$} |
| 676 |
} {{$} {}} |
| 677 |
test parse-13.3 {Tcl_ParseVar procedure, no variable name} testparsevar { |
| 678 |
testparsevar {$.123} |
| 679 |
} {{$} .123} |
| 680 |
test parse-13.4 {Tcl_ParseVar procedure, error looking up variable} testparsevar { |
| 681 |
unset -nocomplain abc |
| 682 |
list [catch {testparsevar {$abc}} msg] $msg |
| 683 |
} {1 {can't read "abc": no such variable}} |
| 684 |
test parse-13.5 {Tcl_ParseVar procedure, error looking up variable} testparsevar { |
| 685 |
unset -nocomplain abc |
| 686 |
list [catch {testparsevar {$abc([bogus x y z])}} msg] $msg |
| 687 |
} {1 {invalid command name "bogus"}} |
| 688 |
test parse-13.6 {Tcl_ParseVar memory leak} -constraints memory -setup { |
| 689 |
proc getbytes {} { |
| 690 |
return [lindex [split [memory info] \n] 3 3] |
| 691 |
} |
| 692 |
} -body { |
| 693 |
set a() foo |
| 694 |
set end [getbytes] |
| 695 |
for {set i 0} {$i < 5} {incr i} { |
| 696 |
set vn {} |
| 697 |
set res [testparsevar [append vn $ a([string repeat {[]} 19]) bar]] |
| 698 |
if {$res ne {foo bar}} {error "Unexpected result: $res"} |
| 699 |
|
| 700 |
set tmp $end |
| 701 |
set end [getbytes] |
| 702 |
} |
| 703 |
expr {$end - $tmp} |
| 704 |
} -cleanup { |
| 705 |
unset -nocomplain a end i vn res tmp |
| 706 |
rename getbytes {} |
| 707 |
} -result 0 |
| 708 |
|
| 709 |
test parse-14.1 {Tcl_ParseBraces procedure, computing string length} {testparser testbytestring} { |
| 710 |
testparser [testbytestring "foo\0 bar"] -1 |
| 711 |
} {- foo 1 simple foo 1 text foo 0 {}} |
| 712 |
test parse-14.2 {Tcl_ParseBraces procedure, computing string length} testparser { |
| 713 |
testparser "foo bar" -1 |
| 714 |
} {- {foo bar} 2 simple foo 1 text foo 0 simple bar 1 text bar 0 {}} |
| 715 |
test parse-14.3 {Tcl_ParseBraces procedure, words in braces} testparser { |
| 716 |
testparser {foo {a $b [concat foo]} {c d}} 0 |
| 717 |
} {- {foo {a $b [concat foo]} {c d}} 3 simple foo 1 text foo 0 simple {{a $b [concat foo]}} 1 text {a $b [concat foo]} 0 simple {{c d}} 1 text {c d} 0 {}} |
| 718 |
test parse-14.4 {Tcl_ParseBraces procedure, empty nested braces} testparser { |
| 719 |
testparser {foo {{}}} 0 |
| 720 |
} {- {foo {{}}} 2 simple foo 1 text foo 0 simple {{{}}} 1 text {{}} 0 {}} |
| 721 |
test parse-14.5 {Tcl_ParseBraces procedure, nested braces} testparser { |
| 722 |
testparser {foo {{a {b} c} {} {d e}}} 0 |
| 723 |
} {- {foo {{a {b} c} {} {d e}}} 2 simple foo 1 text foo 0 simple {{{a {b} c} {} {d e}}} 1 text {{a {b} c} {} {d e}} 0 {}} |
| 724 |
test parse-14.6 {Tcl_ParseBraces procedure, backslashes in words in braces} testparser { |
| 725 |
testparser "foo {a \\n\\\{}" 0 |
| 726 |
} {- {foo {a \n\{}} 2 simple foo 1 text foo 0 simple {{a \n\{}} 1 text {a \n\{} 0 {}} |
| 727 |
test parse-14.7 {Tcl_ParseBraces procedure, missing continuation line in braces} testparser { |
| 728 |
list [catch {testparser "\{abc\\\n" 0} msg] $msg $::errorInfo |
| 729 |
} {1 {missing close-brace} missing\ close-brace\n\ \ \ \ (remainder\ of\ script:\ \"\{abc\\\n\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"\\\{abc\\\\\\n\"\ 0\"} |
| 730 |
test parse-14.8 {Tcl_ParseBraces procedure, backslash-newline in braces} testparser { |
| 731 |
testparser "foo {\\\nx}" 0 |
| 732 |
} {- foo\ \{\\\nx\} 2 simple foo 1 text foo 0 word \{\\\nx\} 2 backslash \\\n 0 text x 0 {}} |
| 733 |
test parse-14.9 {Tcl_ParseBraces procedure, backslash-newline in braces} testparser { |
| 734 |
testparser "foo {a \\\n b}" 0 |
| 735 |
} {- foo\ \{a\ \\\n\ \ \ b\} 2 simple foo 1 text foo 0 word \{a\ \\\n\ \ \ b\} 3 text {a } 0 backslash \\\n\ \ \ 0 text b 0 {}} |
| 736 |
test parse-14.10 {Tcl_ParseBraces procedure, backslash-newline in braces} testparser { |
| 737 |
testparser "foo {xyz\\\n }" 0 |
| 738 |
} {- foo\ \{xyz\\\n\ \} 2 simple foo 1 text foo 0 word \{xyz\\\n\ \} 2 text xyz 0 backslash \\\n\ 0 {}} |
| 739 |
test parse-14.11 {Tcl_ParseBraces procedure, empty braced string} testparser { |
| 740 |
testparser {foo {}} 0 |
| 741 |
} {- {foo {}} 2 simple foo 1 text foo 0 simple {{}} 1 text {} 0 {}} |
| 742 |
test parse-14.12 {Tcl_ParseBraces procedure, missing close brace} testparser { |
| 743 |
list [catch {testparser "foo \{xy\\\nz" 0} msg] $msg $::errorInfo |
| 744 |
} {1 {missing close-brace} missing\ close-brace\n\ \ \ \ (remainder\ of\ script:\ \"\{xy\\\nz\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"foo\ \\\{xy\\\\\\nz\"\ 0\"} |
| 745 |
|
| 746 |
test parse-15.1 {Tcl_ParseQuotedString procedure, computing string length} {testparser testbytestring} { |
| 747 |
testparser [testbytestring "foo\0 bar"] -1 |
| 748 |
} {- foo 1 simple foo 1 text foo 0 {}} |
| 749 |
test parse-15.2 {Tcl_ParseQuotedString procedure, computing string length} testparser { |
| 750 |
testparser "foo bar" -1 |
| 751 |
} {- {foo bar} 2 simple foo 1 text foo 0 simple bar 1 text bar 0 {}} |
| 752 |
test parse-15.3 {Tcl_ParseQuotedString procedure, word is quoted string} testparser { |
| 753 |
testparser {foo "a b c" d "efg";} 0 |
| 754 |
} {- {foo "a b c" d "efg";} 4 simple foo 1 text foo 0 simple {"a b c"} 1 text {a b c} 0 simple d 1 text d 0 simple {"efg"} 1 text efg 0 {}} |
| 755 |
test parse-15.4 {Tcl_ParseQuotedString procedure, garbage after quoted string} testparser { |
| 756 |
list [catch {testparser {foo "a b c"d} 0} msg] $msg $::errorInfo |
| 757 |
} {1 {extra characters after close-quote} {extra characters after close-quote |
| 758 |
(remainder of script: "d") |
| 759 |
invoked from within |
| 760 |
"testparser {foo "a b c"d} 0"}} |
| 761 |
|
| 762 |
test parse-15.5 {CommandComplete procedure} { |
| 763 |
info complete "" |
| 764 |
} 1 |
| 765 |
test parse-15.6 {CommandComplete procedure} { |
| 766 |
info complete " \n" |
| 767 |
} 1 |
| 768 |
test parse-15.7 {CommandComplete procedure} { |
| 769 |
info complete "abc def" |
| 770 |
} 1 |
| 771 |
test parse-15.8 {CommandComplete procedure} { |
| 772 |
info complete "a b c d e f \t\n" |
| 773 |
} 1 |
| 774 |
test parse-15.9 {CommandComplete procedure} { |
| 775 |
info complete {a b c"d} |
| 776 |
} 1 |
| 777 |
test parse-15.10 {CommandComplete procedure} { |
| 778 |
info complete {a b "c d" e} |
| 779 |
} 1 |
| 780 |
test parse-15.11 {CommandComplete procedure} { |
| 781 |
info complete {a b "c d"} |
| 782 |
} 1 |
| 783 |
test parse-15.12 {CommandComplete procedure} { |
| 784 |
info complete {a b "c d"} |
| 785 |
} 1 |
| 786 |
test parse-15.13 {CommandComplete procedure} { |
| 787 |
info complete {a b "c d} |
| 788 |
} 0 |
| 789 |
test parse-15.14 {CommandComplete procedure} { |
| 790 |
info complete {a b "} |
| 791 |
} 0 |
| 792 |
test parse-15.15 {CommandComplete procedure} { |
| 793 |
info complete {a b "cd"xyz} |
| 794 |
} 1 |
| 795 |
test parse-15.16 {CommandComplete procedure} { |
| 796 |
info complete {a b "c $d() d"} |
| 797 |
} 1 |
| 798 |
test parse-15.17 {CommandComplete procedure} { |
| 799 |
info complete {a b "c $dd("} |
| 800 |
} 0 |
| 801 |
test parse-15.18 {CommandComplete procedure} { |
| 802 |
info complete {a b "c \"} |
| 803 |
} 0 |
| 804 |
test parse-15.19 {CommandComplete procedure} { |
| 805 |
info complete {a b "c [d e f]"} |
| 806 |
} 1 |
| 807 |
test parse-15.20 {CommandComplete procedure} { |
| 808 |
info complete {a b "c [d e f] g"} |
| 809 |
} 1 |
| 810 |
test parse-15.21 {CommandComplete procedure} { |
| 811 |
info complete {a b "c [d e f"} |
| 812 |
} 0 |
| 813 |
test parse-15.22 {CommandComplete procedure} { |
| 814 |
info complete {a {b c d} e} |
| 815 |
} 1 |
| 816 |
test parse-15.23 {CommandComplete procedure} { |
| 817 |
info complete {a {b c d}} |
| 818 |
} 1 |
| 819 |
test parse-15.24 {CommandComplete procedure} { |
| 820 |
info complete "a b\{c d" |
| 821 |
} 1 |
| 822 |
test parse-15.25 {CommandComplete procedure} { |
| 823 |
info complete "a b \{c" |
| 824 |
} 0 |
| 825 |
test parse-15.26 {CommandComplete procedure} { |
| 826 |
info complete "a b \{c{ }" |
| 827 |
} 0 |
| 828 |
test parse-15.27 {CommandComplete procedure} { |
| 829 |
info complete "a b {c d e}xxx" |
| 830 |
} 1 |
| 831 |
test parse-15.28 {CommandComplete procedure} { |
| 832 |
info complete "a b {c \\\{d e}xxx" |
| 833 |
} 1 |
| 834 |
test parse-15.29 {CommandComplete procedure} { |
| 835 |
info complete {a b [ab cd ef]} |
| 836 |
} 1 |
| 837 |
test parse-15.30 {CommandComplete procedure} { |
| 838 |
info complete {a b x[ab][cd][ef] gh} |
| 839 |
} 1 |
| 840 |
test parse-15.31 {CommandComplete procedure} { |
| 841 |
info complete {a b x[ab][cd[ef] gh} |
| 842 |
} 0 |
| 843 |
test parse-15.32 {CommandComplete procedure} { |
| 844 |
info complete {a b x[ gh} |
| 845 |
} 0 |
| 846 |
test parse-15.33 {CommandComplete procedure} { |
| 847 |
info complete {[]]]} |
| 848 |
} 1 |
| 849 |
test parse-15.34 {CommandComplete procedure} { |
| 850 |
info complete {abc x$yyy} |
| 851 |
} 1 |
| 852 |
test parse-15.35 {CommandComplete procedure} { |
| 853 |
info complete "abc x\${abc\[\\d} xyz" |
| 854 |
} 1 |
| 855 |
test parse-15.36 {CommandComplete procedure} { |
| 856 |
info complete "abc x\$\{ xyz" |
| 857 |
} 0 |
| 858 |
test parse-15.37 {CommandComplete procedure} { |
| 859 |
info complete {word $a(xyz)} |
| 860 |
} 1 |
| 861 |
test parse-15.38 {CommandComplete procedure} { |
| 862 |
info complete {word $a(} |
| 863 |
} 0 |
| 864 |
test parse-15.39 {CommandComplete procedure} { |
| 865 |
info complete "set a \\\n" |
| 866 |
} 0 |
| 867 |
test parse-15.40 {CommandComplete procedure} { |
| 868 |
info complete "set a \\\\\n" |
| 869 |
} 1 |
| 870 |
test parse-15.41 {CommandComplete procedure} { |
| 871 |
info complete "set a \\n " |
| 872 |
} 1 |
| 873 |
test parse-15.42 {CommandComplete procedure} { |
| 874 |
info complete "set a \\" |
| 875 |
} 1 |
| 876 |
test parse-15.43 {CommandComplete procedure} { |
| 877 |
info complete "foo \\\n\{" |
| 878 |
} 0 |
| 879 |
test parse-15.44 {CommandComplete procedure} { |
| 880 |
info complete "a\nb\n# \{\n# \{\nc\n" |
| 881 |
} 1 |
| 882 |
test parse-15.45 {CommandComplete procedure} { |
| 883 |
info complete "#Incomplete comment\\\n" |
| 884 |
} 0 |
| 885 |
test parse-15.46 {CommandComplete procedure} { |
| 886 |
info complete "#Incomplete comment\\\nBut now it's complete.\n" |
| 887 |
} 1 |
| 888 |
test parse-15.47 {CommandComplete procedure} { |
| 889 |
info complete "# Complete comment\\\\\n" |
| 890 |
} 1 |
| 891 |
test parse-15.48 {CommandComplete procedure} { |
| 892 |
info complete "abc\\\n def" |
| 893 |
} 1 |
| 894 |
test parse-15.49 {CommandComplete procedure} { |
| 895 |
info complete "abc\\\n " |
| 896 |
} 1 |
| 897 |
test parse-15.50 {CommandComplete procedure} { |
| 898 |
info complete "abc\\\n" |
| 899 |
} 0 |
| 900 |
test parse-15.51 {CommandComplete procedure} " |
| 901 |
info complete \"\\\{abc\\\}\\\{\" |
| 902 |
" 1 |
| 903 |
test parse-15.52 {CommandComplete procedure} { |
| 904 |
info complete "\"abc\"(" |
| 905 |
} 1 |
| 906 |
test parse-15.53 {CommandComplete procedure} " |
| 907 |
info complete \" # \{\" |
| 908 |
" 1 |
| 909 |
test parse-15.54 {CommandComplete procedure} " |
| 910 |
info complete \"foo bar;# \{\" |
| 911 |
" 1 |
| 912 |
test parse-15.55 {CommandComplete procedure} testbytestring { |
| 913 |
info complete "set x [testbytestring \0]; puts hi" |
| 914 |
} 1 |
| 915 |
test parse-15.56 {CommandComplete procedure} testbytestring { |
| 916 |
info complete "set x [testbytestring \0]; \{" |
| 917 |
} 0 |
| 918 |
test parse-15.57 {CommandComplete procedure} { |
| 919 |
info complete "# Comment should be complete command" |
| 920 |
} 1 |
| 921 |
test parse-15.58 {CommandComplete procedure, memory leaks} { |
| 922 |
info complete "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22" |
| 923 |
} 1 |
| 924 |
test parse-15.59 {CommandComplete procedure} testbytestring { |
| 925 |
# Test for Tcl Bug 684744 |
| 926 |
info complete [testbytestring "\x00;if 1 \{"] |
| 927 |
} 0 |
| 928 |
test parse-15.60 {CommandComplete procedure} { |
| 929 |
# Test for Tcl Bug 1968882 |
| 930 |
info complete \\\n |
| 931 |
} 0 |
| 932 |
|
| 933 |
test parse-16.1 {Bug 218885 (Scriptics bug 2535)} { |
| 934 |
subst {[eval {return foo}]bar} |
| 935 |
} foobar |
| 936 |
|
| 937 |
test parse-17.1 {Correct return codes from errors during substitution} { |
| 938 |
catch {eval {w[continue]}} |
| 939 |
} 4 |
| 940 |
|
| 941 |
test parse-18.1 {Tcl_SubstObj, ParseTokens flags} { |
| 942 |
subst {foo\t$::tcl_library\t[set ::tcl_library]} |
| 943 |
} "foo $::tcl_library $::tcl_library" |
| 944 |
test parse-18.2 {Tcl_SubstObj, ParseTokens flags} { |
| 945 |
subst -nocommands {foo\t$::tcl_library\t[set ::tcl_library]} |
| 946 |
} "foo $::tcl_library \[set ::tcl_library]" |
| 947 |
test parse-18.3 {Tcl_SubstObj, ParseTokens flags} { |
| 948 |
subst -novariables {foo\t$::tcl_library\t[set ::tcl_library]} |
| 949 |
} "foo \$::tcl_library $::tcl_library" |
| 950 |
test parse-18.4 {Tcl_SubstObj, ParseTokens flags} { |
| 951 |
subst -nobackslashes {foo\t$::tcl_library\t[set ::tcl_library]} |
| 952 |
} "foo\\t$::tcl_library\\t$::tcl_library" |
| 953 |
test parse-18.5 {Tcl_SubstObj, ParseTokens flags} { |
| 954 |
subst -novariables -nobackslashes {foo\t$::tcl_library\t[set ::tcl_library]} |
| 955 |
} "foo\\t\$::tcl_library\\t$::tcl_library" |
| 956 |
test parse-18.6 {Tcl_SubstObj, ParseTokens flags} { |
| 957 |
subst -nocommands -nobackslashes {foo\t$::tcl_library\t[set ::tcl_library]} |
| 958 |
} "foo\\t$::tcl_library\\t\[set ::tcl_library]" |
| 959 |
test parse-18.7 {Tcl_SubstObj, ParseTokens flags} { |
| 960 |
subst -nocommands -novariables {foo\t$::tcl_library\t[set ::tcl_library]} |
| 961 |
} "foo \$::tcl_library \[set ::tcl_library]" |
| 962 |
test parse-18.8 {Tcl_SubstObj, ParseTokens flags} { |
| 963 |
subst -nocommands -novariables -nobackslashes \ |
| 964 |
{foo\t$::tcl_library\t[set ::tcl_library]} |
| 965 |
} "foo\\t\$::tcl_library\\t\[set ::tcl_library]" |
| 966 |
|
| 967 |
test parse-18.9 {Tcl_SubstObj, parse errors} { |
| 968 |
list [catch "subst foo\$\{foo" msg] $msg |
| 969 |
} [list 1 "missing close-brace for variable name"] |
| 970 |
test parse-18.10 {Tcl_SubstObj, parse errors} { |
| 971 |
list [catch "subst foo\[set \$\{foo]" msg] $msg |
| 972 |
} [list 1 "missing close-brace for variable name"] |
| 973 |
test parse-18.11 {Tcl_SubstObj, parse errors} { |
| 974 |
list [catch "subst foo\$array(\$\{foo)" msg] $msg |
| 975 |
} [list 1 "missing close-brace for variable name"] |
| 976 |
test parse-18.12 {Tcl_SubstObj, parse errors} { |
| 977 |
list [catch "subst foo\$(\$\{foo)" msg] $msg |
| 978 |
} [list 1 "missing close-brace for variable name"] |
| 979 |
test parse-18.13 {Tcl_SubstObj, parse errors} { |
| 980 |
list [catch "subst \[" msg] $msg |
| 981 |
} [list 1 "missing close-bracket"] |
| 982 |
|
| 983 |
test parse-18.14 {Tcl_SubstObj, exception handling} { |
| 984 |
subst {abc,[break],def} |
| 985 |
} {abc,} |
| 986 |
test parse-18.15 {Tcl_SubstObj, exception handling} { |
| 987 |
subst {abc,[continue; expr {1+2}],def} |
| 988 |
} {abc,,def} |
| 989 |
test parse-18.16 {Tcl_SubstObj, exception handling} { |
| 990 |
subst {abc,[return foo; expr {1+2}],def} |
| 991 |
} {abc,foo,def} |
| 992 |
test parse-18.17 {Tcl_SubstObj, exception handling} { |
| 993 |
subst {abc,[return -code 10 foo; expr {1+2}],def} |
| 994 |
} {abc,foo,def} |
| 995 |
test parse-18.18 {Tcl_SubstObj, exception handling} { |
| 996 |
subst {abc,[break; set {} {}{}],def} |
| 997 |
} {abc,} |
| 998 |
test parse-18.19 {Tcl_SubstObj, exception handling} { |
| 999 |
list [catch {subst {abc,[continue; expr {1+2}; set {} {}{}],def}} msg] $msg |
| 1000 |
} [list 1 "extra characters after close-brace"] |
| 1001 |
test parse-18.20 {Tcl_SubstObj, exception handling} { |
| 1002 |
list [catch {subst {abc,[return foo; expr {1+2}; set {} {}{}],def}} msg] $msg |
| 1003 |
} [list 1 "extra characters after close-brace"] |
| 1004 |
test parse-18.21 {Tcl_SubstObj, exception handling} { |
| 1005 |
list [catch { |
| 1006 |
subst {abc,[return -code 10 foo; expr {1+2}; set {} {}{}],def} |
| 1007 |
} msg] $msg |
| 1008 |
} [list 1 "extra characters after close-brace"] |
| 1009 |
|
| 1010 |
test parse-18.22 {Tcl_SubstObj, side effects} { |
| 1011 |
set a 0 |
| 1012 |
list [subst {foo[incr a]bar}] $a |
| 1013 |
} [list foo1bar 1] |
| 1014 |
test parse-18.23 {Tcl_SubstObj, side effects} { |
| 1015 |
set a 0 |
| 1016 |
list [subst {foo[incr a; incr a]bar}] $a |
| 1017 |
} [list foo2bar 2] |
| 1018 |
test parse-18.24 {Tcl_SubstObj, side effects} { |
| 1019 |
set a 0 |
| 1020 |
list [subst {foo[incr a; break; incr a]bar}] $a |
| 1021 |
} [list foo 1] |
| 1022 |
test parse-18.25 {Tcl_SubstObj, side effects} { |
| 1023 |
set a 0 |
| 1024 |
list [subst {foo[incr a; continue; incr a]bar}] $a |
| 1025 |
} [list foobar 1] |
| 1026 |
test parse-18.26 {Tcl_SubstObj, side effects} { |
| 1027 |
set a 0 |
| 1028 |
list [subst {foo[incr a; return; incr a]bar}] $a |
| 1029 |
} [list foobar 1] |
| 1030 |
test parse-18.27 {Tcl_SubstObj, side effects} { |
| 1031 |
set a 0 |
| 1032 |
list [subst {foo[incr a; return -code 10; incr a]bar}] $a |
| 1033 |
} [list foobar 1] |
| 1034 |
test parse-18.28 {Tcl_SubstObj, side effects} { |
| 1035 |
set a 0 |
| 1036 |
catch {subst {foo[incr a; parse error {}{}; incr a]bar}} |
| 1037 |
set a |
| 1038 |
} 1 |
| 1039 |
test parse-18.29 {Tcl_SubstObj, side effects} { |
| 1040 |
set a 0 |
| 1041 |
catch {subst {foo[incr a; incr a; parse error {}{}]bar}} |
| 1042 |
set a |
| 1043 |
} 2 |
| 1044 |
test parse-18.30 {Tcl_SubstObj, side effects} { |
| 1045 |
set a 0 |
| 1046 |
catch {subst {foo[incr a; incr a parse error {}{}]bar}} |
| 1047 |
set a |
| 1048 |
} 1 |
| 1049 |
|
| 1050 |
test parse-19.1 {Bug 1115904: recursion limit in Tcl_EvalEx} -constraints { |
| 1051 |
testevalex |
| 1052 |
} -setup { |
| 1053 |
interp create i |
| 1054 |
load {} Tcltest i |
| 1055 |
i eval {proc {} args {}} |
| 1056 |
interp recursionlimit i 3 |
| 1057 |
} -body { |
| 1058 |
i eval {testevalex {[]}} |
| 1059 |
} -cleanup { |
| 1060 |
interp delete i |
| 1061 |
} |
| 1062 |
|
| 1063 |
test parse-19.2 {Bug 1115904: recursion limit in Tcl_EvalEx} -constraints { |
| 1064 |
testevalex |
| 1065 |
} -setup { |
| 1066 |
interp create i |
| 1067 |
load {} Tcltest i |
| 1068 |
i eval {proc {} args {}} |
| 1069 |
interp recursionlimit i 2 |
| 1070 |
} -body { |
| 1071 |
i eval {testevalex {[[]]}} |
| 1072 |
} -cleanup { |
| 1073 |
interp delete i |
| 1074 |
} -returnCodes error -match glob -result {too many nested*} |
| 1075 |
|
| 1076 |
test parse-19.3 {Bug 1115904: recursion limit in Tcl_EvalEx} emptyTest { |
| 1077 |
# Test no longer valid in Tcl 8.6 |
| 1078 |
} {} |
| 1079 |
test parse-19.4 {Bug 1115904: recursion limit in Tcl_EvalEx} emptyTest { |
| 1080 |
# Test no longer valid in Tcl 8.6 |
| 1081 |
} {} |
| 1082 |
|
| 1083 |
test parse-20.1 {TclParseBackslash: truncated escape} testparser { |
| 1084 |
testparser {\u12345} 1 |
| 1085 |
} {- \\ 1 simple \\ 1 text \\ 0 u12345} |
| 1086 |
test parse-20.2 {TclParseBackslash: truncated escape} testparser { |
| 1087 |
testparser {\u12345} 2 |
| 1088 |
} {- {\u} 1 word {\u} 1 backslash {\u} 0 12345} |
| 1089 |
test parse-20.3 {TclParseBackslash: truncated escape} testparser { |
| 1090 |
testparser {\u12345} 3 |
| 1091 |
} {- {\u1} 1 word {\u1} 1 backslash {\u1} 0 2345} |
| 1092 |
test parse-20.4 {TclParseBackslash: truncated escape} testparser { |
| 1093 |
testparser {\u12345} 4 |
| 1094 |
} {- {\u12} 1 word {\u12} 1 backslash {\u12} 0 345} |
| 1095 |
test parse-20.5 {TclParseBackslash: truncated escape} testparser { |
| 1096 |
testparser {\u12345} 5 |
| 1097 |
} {- {\u123} 1 word {\u123} 1 backslash {\u123} 0 45} |
| 1098 |
test parse-20.6 {TclParseBackslash: truncated escape} testparser { |
| 1099 |
testparser {\u12345} 6 |
| 1100 |
} {- {\u1234} 1 word {\u1234} 1 backslash {\u1234} 0 5} |
| 1101 |
test parse-20.7 {TclParseBackslash: truncated escape} testparser { |
| 1102 |
testparser {\u12345} 7 |
| 1103 |
} {- {\u12345} 1 word {\u12345} 2 backslash {\u1234} 0 text 5 0 {}} |
| 1104 |
|
| 1105 |
test parse-20.8 {TclParseBackslash: truncated escape} testparser { |
| 1106 |
testparser {\x12X} 1 |
| 1107 |
} {- \\ 1 simple \\ 1 text \\ 0 x12X} |
| 1108 |
test parse-20.9 {TclParseBackslash: truncated escape} testparser { |
| 1109 |
testparser {\x12X} 2 |
| 1110 |
} {- {\x} 1 word {\x} 1 backslash {\x} 0 12X} |
| 1111 |
test parse-20.10 {TclParseBackslash: truncated escape} testparser { |
| 1112 |
testparser {\x12X} 3 |
| 1113 |
} {- {\x1} 1 word {\x1} 1 backslash {\x1} 0 2X} |
| 1114 |
test parse-20.11 {TclParseBackslash: truncated escape} testparser { |
| 1115 |
testparser {\x12X} 4 |
| 1116 |
} {- {\x12} 1 word {\x12} 1 backslash {\x12} 0 X} |
| 1117 |
test parse-20.12 {TclParseBackslash: truncated escape} testparser { |
| 1118 |
testparser {\x12X} 5 |
| 1119 |
} {- {\x12X} 1 word {\x12X} 2 backslash {\x12} 0 text X 0 {}} |
| 1120 |
|
| 1121 |
test parse-21.0 {Bug 1884496} testevent { |
| 1122 |
set ::script {testevent delete a; set a [p]; set ::done $a} |
| 1123 |
proc ::p {} {string first s $::script} |
| 1124 |
testevent queue a head $::script |
| 1125 |
vwait done |
| 1126 |
} {} |
| 1127 |
test parse-21.1 {TCL_EVAL_DIRECT coverage} testevent { |
| 1128 |
testevent queue a head {testevent delete a; \ |
| 1129 |
set ::done [dict get [info frame 0] line]} |
| 1130 |
vwait done |
| 1131 |
set ::done |
| 1132 |
} 2 |
| 1133 |
|
| 1134 |
cleanupTests |
| 1135 |
} |
| 1136 |
|
| 1137 |
namespace delete ::tcl::test::parse |
| 1138 |
return |