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 © 1997 Sun Microsystems, Inc. 6# Copyright © 1998-1999 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 11if {"::tcltest" ni [namespace children]} { 12 package require tcltest 2.5 13 namespace import -force ::tcltest::* 14} 15 16::tcltest::loadTestedCommands 17catch [list package require -exact tcl::test [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 24testConstraint testexprparser [llength [info commands testexprparser]] 25testConstraint testbytestring [llength [info commands testbytestring]] 26 27# Big test for correct ordering of data in [expr] 28 29proc 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} 83testConstraint ieeeFloatingPoint [testIEEE] 84 85###################################################################### 86 87test parseExpr-1.1 {Tcl_ParseExpr procedure, computing string length} {testexprparser testbytestring} { 88 testexprparser [testbytestring "1+2\x00 +3"] -1 89} {- {} 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}} 90test 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 {}} 93test parseExpr-1.3 {Tcl_ParseExpr procedure, error getting initial lexeme} testexprparser { 94 testexprparser 12345678901234567890 -1 95} {- {} 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}} 96test parseExpr-1.4 {Tcl_ParseExpr procedure, error in conditional expression} \ 97 -constraints testexprparser -body { 98 testexprparser {foo+} -1 99 } -match glob -returnCodes error -result * 100test 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 104test 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 {}} 107test parseExpr-2.2 {ParseCondExpr procedure, error in test subexpr} \ 108 -constraints testexprparser -body { 109 testexprparser {0 || foo} -1 110 } -match glob -returnCodes error -result * 111test 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 {}} 114test 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 {}} 117test 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 {}} 120test 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 {}} 123test 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 * 127test 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 * 130test 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 {}} 133test 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 138test 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 {}} 141test 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 * 145test 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 {}} 148test 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 {}} 151test 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 {}} 154test 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 {}} 157test 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 162test 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 {}} 165test 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 * 169test 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 {}} 172test 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 {}} 175test 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 {}} 178test 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 {}} 181test 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 186test 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 {}} 189test 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 * 193test 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 {}} 196test 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 {}} 199test 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 {}} 202test 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 {}} 205test 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 210test 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 {}} 213test 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 * 217test 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 {}} 220test 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 {}} 223test 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 {}} 226test 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 {}} 229test 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 234test 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 {}} 237test 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 * 241test 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 {}} 244test 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 {}} 247test 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 {}} 250test 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 {}} 253test 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 258test 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 {}} 261test 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 * 265test 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 {}} 268test 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 {}} 271test 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 {}} 274test 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 {}} 277test 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 {}} 280test 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 285test 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 {}} 288test 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 * 292test 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 {}} 295test 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 {}} 298test 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 {}} 301test 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 {}} 304test 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 {}} 307test 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 {}} 310test 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 {}} 313test 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 318test 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 {}} 321test 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 * 325test 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 {}} 328test 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 {}} 331test 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 {}} 334test 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 {}} 337test 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 {}} 340test 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 345test 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 {}} 348test 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 * 352test 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 {}} 355test 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 {}} 358test 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 {}} 361test 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 {}} 364test 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 {}} 367test 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 372test 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 {}} 375test 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 * 379test 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 {}} 382test 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 {}} 385test 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 {}} 388test 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 {}} 391test 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 {}} 394test 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 399test 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 {}} 402test 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 {}} 405test 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 {}} 408test 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 {}} 411test 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 {}} 414test 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 {}} 417test 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 {}} 420test 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 {}} 423test 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 428test 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 {}} 431test 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 {}} 434test 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 {}} 437test 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 {}} 440test 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 {}} 443test 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 {}} 446test 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 {}} 449test 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 * 452test 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 * 455test parseExpr-14.10 {ParseUnaryExpr procedure, first token is not unary op} testexprparser { 456 testexprparser {123} -1 457} {- {} 0 subexpr 123 1 text 123 0 {}} 458test 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 {}} 461test 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 465test 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 {}} 468test parseExpr-15.2 {ParsePrimaryExpr procedure, bad lexeme after "("} {testexprparser} { 469 testexprparser {(12345678901234567890)} -1 470} {- {} 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}} 471test 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 {}} 474test parseExpr-15.4 {ParsePrimaryExpr procedure, error in parenthesized subexpr} -constraints testexprparser -body { 475 testexprparser {(? 123 : 456)} -1 476} -returnCodes error -match glob -result * 477test parseExpr-15.5 {ParsePrimaryExpr procedure, missing ")" after in parenthesized subexpr} -constraints testexprparser -body { 478 testexprparser {({abc}/{def}} -1 479} -returnCodes error -match glob -result * 480test parseExpr-15.6 {ParsePrimaryExpr procedure, primary is literal} testexprparser { 481 testexprparser {12345} -1 482} {- {} 0 subexpr 12345 1 text 12345 0 {}} 483test parseExpr-15.7 {ParsePrimaryExpr procedure, primary is literal} testexprparser { 484 testexprparser {12345.6789} -1 485} {- {} 0 subexpr 12345.6789 1 text 12345.6789 0 {}} 486test 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 {}} 489test 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 {}} 492test 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 {}} 495test parseExpr-15.11 {ParsePrimaryExpr procedure, error in var reference} -constraints testexprparser -body { 496 testexprparser {$a(} -1 497} -returnCodes error -match glob -result * 498test 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 {}} 501test parseExpr-15.13 {ParsePrimaryExpr procedure, error in quoted string} -constraints testexprparser -body { 502 testexprparser {"$a(12"} -1 503} -returnCodes error -match glob -result * 504test 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 {}} 507test parseExpr-15.15 {ParsePrimaryExpr procedure, primary is command} testexprparser { 508 testexprparser {[def]} -1 509} {- {} 0 subexpr {[def]} 1 command {[def]} 0 {}} 510test 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 {}} 513test 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 {}} 516test parseExpr-15.18 {ParsePrimaryExpr procedure, missing close bracket} -constraints testexprparser -body { 517 testexprparser {[one} -1 518} -returnCodes error -match glob -result * 519test 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 {}} 522test 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 * 525test 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 {}} 529test 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 {}} 532test 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 * 535test 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 * 539test 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 {}} 542test 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 {}} 545test parseExpr-15.27 {ParsePrimaryExpr procedure, error in function arg} -constraints testexprparser -body { 546 testexprparser {foo(*1-2)} -1 547} -returnCodes error -match glob -result * 548test parseExpr-15.28 {ParsePrimaryExpr procedure, error in function arg} -constraints testexprparser -body { 549 testexprparser {foo(*1-2)} -1 550} -returnCodes error -match glob -result * 551test 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 {}} 554test 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 {}} 557test 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 * 560test parseExpr-15.32 {ParsePrimaryExpr procedure, bad lexeme after primary} -constraints testexprparser -body { 561 testexprparser {123 12345678901234567890} -1 562} -returnCodes error -match glob -result * 563test parseExpr-15.33 {ParsePrimaryExpr procedure, comma-specific message} -constraints testexprparser -body { 564 testexprparser {123+,456} -1 565} -returnCodes error -match glob -result * 566test parseExpr-15.34 {ParsePrimaryExpr procedure, single equal-specific message} -constraints testexprparser -body { 567 testexprparser {123+=456} -1 568} -returnCodes error -match glob -result * 569test parseExpr-15.35 {ParsePrimaryExpr procedure, error in parenthesized subexpr} -constraints testexprparser -body { 570 testexprparser {(: 123 : 456)} -1 571} -returnCodes error -match glob -result * 572test 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 577test parseExpr-16.1 {GetLexeme procedure, whitespace before lexeme} testexprparser { 578 testexprparser { 123} -1 579} {- {} 0 subexpr 123 1 text 123 0 {}} 580test parseExpr-16.2 {GetLexeme procedure, whitespace before lexeme} testexprparser { 581 testexprparser { \ 582456} -1 583} {- {} 0 subexpr 456 1 text 456 0 {}} 584test parseExpr-16.3 {GetLexeme procedure, no lexeme after whitespace} testexprparser { 585 testexprparser { 123 \ 586 } -1 587} {- {} 0 subexpr 123 1 text 123 0 {}} 588test parseExpr-16.4 {GetLexeme procedure, integer lexeme} testexprparser { 589 testexprparser {000} -1 590} {- {} 0 subexpr 000 1 text 000 0 {}} 591test parseExpr-16.5 {GetLexeme procedure, integer lexeme too big} testexprparser { 592 testexprparser {12345678901234567890} -1 593} {- {} 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}} 594test parseExpr-16.6 {GetLexeme procedure, bad integer lexeme} -constraints testexprparser -body { 595 testexprparser {0o999} -1 596} -returnCodes error -match glob -result {*invalid octal number*} 597test parseExpr-16.7 {GetLexeme procedure, double lexeme} testexprparser { 598 testexprparser {0.999} -1 599} {- {} 0 subexpr 0.999 1 text 0.999 0 {}} 600test parseExpr-16.8 {GetLexeme procedure, double lexeme} testexprparser { 601 testexprparser {.123} -1 602} {- {} 0 subexpr .123 1 text .123 0 {}} 603test parseExpr-16.9 {GetLexeme procedure, double lexeme} {testexprparser unix} { 604 testexprparser {nan} -1 605} {- {} 0 subexpr nan 1 text nan 0 {}} 606test parseExpr-16.10 {GetLexeme procedure, double lexeme} {testexprparser unix} { 607 testexprparser {NaN} -1 608} {- {} 0 subexpr NaN 1 text NaN 0 {}} 609test 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}} 612test 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 {}}} 615test parseExpr-16.12 {GetLexeme procedure, bad double lexeme} -constraints testexprparser -body { 616 testexprparser {123.4x56} -1 617} -returnCodes error -match glob -result * 618test parseExpr-16.13 {GetLexeme procedure, lexeme is "["} testexprparser { 619 testexprparser {[foo]} -1 620} {- {} 0 subexpr {[foo]} 1 command {[foo]} 0 {}} 621test parseExpr-16.14 {GetLexeme procedure, lexeme is open brace} testexprparser { 622 testexprparser {{bar}} -1 623} {- {} 0 subexpr {{bar}} 1 text bar 0 {}} 624test parseExpr-16.15 {GetLexeme procedure, lexeme is "("} testexprparser { 625 testexprparser {(123)} -1 626} {- {} 0 subexpr 123 1 text 123 0 {}} 627test 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 {}} 630test parseExpr-16.17 {GetLexeme procedure, lexeme is "$"} testexprparser { 631 testexprparser {$wombat} -1 632} {- {} 0 subexpr {$wombat} 2 variable {$wombat} 1 text wombat 0 {}} 633test parseExpr-16.18 "GetLexeme procedure, lexeme is '\"'" testexprparser { 634 testexprparser {"fred"} -1 635} {- {} 0 subexpr {"fred"} 1 text fred 0 {}} 636test 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 {}} 639test 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 {}} 642test 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 {}} 645test 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 {}} 648test 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 {}} 651test 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 {}} 654test 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 {}} 657test 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 {}} 660test 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 {}} 663test 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 {}} 666test 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 {}} 669test 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 {}} 672test 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 {}} 675test 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 {}} 678test parseExpr-16.33 {GetLexeme procedure, bad lexeme starting with "="} -constraints testexprparser -body { 679 testexprparser {2=+3} -1 680} -returnCodes error -match glob -result * 681test 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 {}} 684test 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 {}} 687test 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 {}} 690test 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 {}} 693test 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 {}} 696test 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 {}} 699test 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 {}} 702test 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 {}} 705test parseExpr-16.42 {GetLexeme procedure, lexeme is func name} testexprparser { 706 testexprparser {george()} -1 707} {- {} 0 subexpr george() 1 operator george 0 {}} 708test 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 {}} 711test parseExpr-16.44 {GetLexeme procedure, unknown lexeme} -constraints testexprparser -body { 712 testexprparser {@27} -1 713} -returnCodes error -match glob -result * 714 715test 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 719test 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 723test 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 730test parseExpr-20.1 {Bug 1451233} { 731 expr 1000000000000000000042 732} 1000000000000000000042 733test parseExpr-20.2 {Bug 1451233} { 734 expr 10000000000000000000420000000042 735} 10000000000000000000420000000042 736test parseExpr-20.3 {Bug 1451233} { 737 expr 10000000000000000000020000000002 738} 10000000000000000000020000000002 739 740test parseExpr-21.1 {error messages} -body { 741 expr @ 742} -returnCodes error -result {invalid character "@" 743in expression "@"} 744test parseExpr-21.2 {error messages} -body { 745 expr = 746} -returnCodes error -result {incomplete operator "=" 747in expression "="} 748test parseExpr-21.3 {error messages} -body { 749 expr x 750} -returnCodes error -result {invalid bareword "x" 751in expression "x"; 752should be "$x" or "{x}" or "x(...)" or ...} 753test parseExpr-21.4 {error messages} -body { 754 expr abcdefghijklmnopqrstuvwxyz 755} -returnCodes error -result {invalid bareword "abcdefghijklmnopqrstuv..." 756in expression "abcdefghijklmnopqrstuv..."; 757should be "$abcdefghijklmnopqrstuv..." or "{abcdefghijklmnopqrstuv...}" or "abcdefghijklmnopqrstuv...(...)" or ...} 758test parseExpr-21.5 {error messages} -body { 759 expr {[][]} 760} -returnCodes error -result {missing operator at _@_ 761in expression "[]_@_[]"} 762test parseExpr-21.6 {error messages} -body { 763 expr {0 0} 764} -returnCodes error -result {missing operator at _@_ 765in expression "0 _@_0"} 766test parseExpr-21.7 {error messages} -body { 767 expr {0o8} 768} -returnCodes error -match glob -result {*invalid octal number*} 769test parseExpr-21.8 {error messages} -body { 770 expr {0o8x} 771} -returnCodes error -match glob -result {*invalid octal number*} 772test parseExpr-21.9 {error messages} -body { 773 expr {"} 774} -returnCodes error -result {missing " 775in expression """} 776test parseExpr-21.10 {error messages} -body { 777 expr \{ 778} -returnCodes error -result "missing close-brace 779in expression \"\{\"" 780test parseExpr-21.11 {error messages} -body { 781 expr $ 782} -returnCodes error -result {invalid character "$" 783in expression "$"} 784test parseExpr-21.12 {error messages} -body { 785 expr {$(} 786} -returnCodes error -result {missing ) 787in expression "$("} 788test parseExpr-21.13 {error messages} -body { 789 expr {[""x]} 790} -returnCodes error -result {extra characters after close-quote 791in expression "[""x]"} 792test parseExpr-21.14 {error messages} -body { 793 expr {[} 794} -returnCodes error -result {missing close-bracket 795in expression "["} 796test parseExpr-21.15 {error messages} -body { 797 expr 0~0 798} -returnCodes error -result {missing operator at _@_ 799in expression "0_@_~0"} 800test parseExpr-21.16 {error messages} -body { 801 expr () 802} -returnCodes error -result {empty subexpression at _@_ 803in expression "(_@_)"} 804test parseExpr-21.17 {error messages} -body { 805 expr ( 806} -returnCodes error -result {unbalanced open paren 807in expression "("} 808test parseExpr-21.18 {error messages} -body { 809 expr a(0,) 810} -returnCodes error -result {missing function argument at _@_ 811in expression "a(0,_@_)"} 812test parseExpr-21.19 {error messages} -body { 813 expr {} 814} -returnCodes error -result {empty expression 815in expression ""} 816test parseExpr-21.20 {error messages} -body { 817 expr ) 818} -returnCodes error -result {unbalanced close paren 819in expression ")"} 820test parseExpr-21.21 {error messages} -body { 821 expr a(,0) 822} -returnCodes error -result {missing function argument at _@_ 823in expression "a(_@_,0)"} 824test parseExpr-21.22 {error messages} -body { 825 expr 0&|0 826} -returnCodes error -result {missing operand at _@_ 827in expression "0&_@_|0"} 828test parseExpr-21.23 {error messages} -body { 829 expr 0^^0 830} -returnCodes error -result {missing operand at _@_ 831in expression "0^_@_^0"} 832test parseExpr-21.24 {error messages} -body { 833 expr 0|&0 834} -returnCodes error -result {missing operand at _@_ 835in expression "0|_@_&0"} 836test parseExpr-21.25 {error messages} -body { 837 expr a(1+,0) 838} -returnCodes error -result {missing operand at _@_ 839in expression "a(1+_@_,0)"} 840test parseExpr-21.26 {error messages} -body { 841 expr (0 842} -returnCodes error -result {unbalanced open paren 843in expression "(0"} 844test parseExpr-21.27 {error messages} -body { 845 expr 0?0 846} -returnCodes error -result {missing operator ":" at _@_ 847in expression "0?0_@_"} 848test parseExpr-21.28 {error messages} -body { 849 expr 0:0 850} -returnCodes error -result {unexpected operator ":" without preceding "?" 851in expression "0:0"} 852test parseExpr-21.29 {error messages} -body { 853 expr 0) 854} -returnCodes error -result {unbalanced close paren 855in expression "0)"} 856test parseExpr-21.30 {error messages} -body { 857 expr 0, 858} -returnCodes error -result {unexpected "," outside function argument list 859in expression "0,"} 860test parseExpr-21.31 {error messages} -body { 861 expr 0,0 862} -returnCodes error -result {unexpected "," outside function argument list 863in expression "0,0"} 864test parseExpr-21.32 {error messages} -body { 865 expr (0,0) 866} -returnCodes error -result {unexpected "," outside function argument list 867in expression "(0,0)"} 868test parseExpr-21.33 {error messages} -body { 869 expr a(0:0,0) 870} -returnCodes error -result {unexpected operator ":" without preceding "?" 871in expression "a(0:0,0)"} 872test parseExpr-21.34 {error messages} -body { 873 expr {"abcdefghijklmnopqrstuvwxyz"@0} 874} -returnCodes error -result {invalid character "@" 875in expression "...fghijklmnopqrstuvwxyz"@0"} 876test parseExpr-21.35 {error messages} -body { 877 expr {0@"abcdefghijklmnopqrstuvwxyz"} 878} -returnCodes error -result {invalid character "@" 879in expression "0@"abcdefghijklmnopqrstu..."} 880test parseExpr-21.36 {error messages} -body { 881 expr {"abcdefghijklmnopqrstuvwxyz"@"abcdefghijklmnopqrstuvwxyz"} 882} -returnCodes error -result {invalid character "@" 883in expression "...fghijklmnopqrstuvwxyz"@"abcdefghijklmnopqrstu..."} 884test parseExpr-21.37 {error messages} -body { 885 expr [format {"%s" @ 0} [string repeat \xA7 25]] 886} -returnCodes error -result [format {invalid character "@" 887in expression "...%s" @ 0"} [string repeat \xA7 10]] 888test parseExpr-21.38 {error messages} -body { 889 expr [format {0 @ "%s"} [string repeat \xA7 25]] 890} -returnCodes error -result [format {invalid character "@" 891in expression "0 @ "%s..."} [string repeat \xA7 10]] 892test parseExpr-21.39 {error messages} -body { 893 expr [format {"%s" @ "%s"} [string repeat \xA7 25] [string repeat \xA7 25]] 894} -returnCodes error -result [format {invalid character "@" 895in expression "...%s" @ "%s..."} [string repeat \xA7 10] [string repeat \xA7 10]] 896test parseExpr-21.40 {error messages} -body { 897 catch {expr {"abcdefghijklmnopqrstuvwxyz"@0}} m o 898 dict get $o -errorinfo 899} -result {invalid character "@" 900in expression "...fghijklmnopqrstuvwxyz"@0" 901 (parsing expression ""abcdefghijklmnopqrstu...") 902 invoked from within 903"expr {"abcdefghijklmnopqrstuvwxyz"@0}"} 904test parseExpr-21.41 {error messages} -body { 905 catch {expr [format {"%s" @ 0} [string repeat \xA7 25]]} m o 906 dict get $o -errorinfo 907} -result [format {invalid character "@" 908in expression "...%s" @ 0" 909 (parsing expression ""%s...") 910 invoked from within 911"expr [format {"%%s" @ 0} [string repeat \xA7 25]]"} [string repeat \xA7 10] [string repeat \xA7 10]] 912test parseExpr-21.42 {error message} -body { 913 expr {123456789012345678901234567890*"abcdefghijklmnopqrstuvwxyz} 914} -returnCodes error -result {missing " 915in expression "...012345678901234567890*"abcdefghijklmnopqrstuv..."} 916test parseExpr-21.43 {error message} -body { 917 expr "123456789012345678901234567890*\"foobar\$\{abcdefghijklmnopqrstuvwxyz\"" 918} -returnCodes error -result "missing close-brace for variable name 919in expression \"...8901234567890*\"foobar\$\{abcdefghijklmnopqrstuv...\"" 920test parseExpr-21.44 {error message} -body { 921 expr {123456789012345678901234567890*"foo$bar(abcdefghijklmnopqrstuvwxyz"} 922} -returnCodes error -result {missing ) 923in expression "...8901234567890*"foo$bar(abcdefghijklmnopqrstuv..."} 924test parseExpr-21.45 {error message} -body { 925 expr {123456789012345678901234567890*"foo$bar([{}abcdefghijklmnopqrstuvwxyz])"} 926} -returnCodes error -result {extra characters after close-brace 927in expression "...234567890*"foo$bar([{}abcdefghijklmnopqrstuv..."} 928test parseExpr-21.46 {error message} -body { 929 expr {123456789012345678901234567890*"foo$bar([""abcdefghijklmnopqrstuvwxyz])"} 930} -returnCodes error -result {extra characters after close-quote 931in expression "...234567890*"foo$bar([""abcdefghijklmnopqrstuv..."} 932test parseExpr-21.47 {error message} -body { 933 expr {123456789012345678901234567890*"foo$bar([abcdefghijklmnopqrstuvwxyz)"} 934} -returnCodes error -result {missing close-bracket 935in expression "...901234567890*"foo$bar([abcdefghijklmnopqrstuv..."} 936test parseExpr-21.48 {error message} -body { 937 expr "123456789012345678901234567890*\"foo\$bar(\[\{abcdefghijklmnopqrstuvwxyz])\"" 938} -returnCodes error -result "missing close-brace 939in expression \"...01234567890*\"foo\$bar(\[\{abcdefghijklmnopqrstuv...\"" 940 941test parseExpr-21.49 {error message} -body { 942 expr "123456789012345678901234567890*\{abcdefghijklmnopqrstuvwxyz" 943} -returnCodes error -result "missing close-brace 944in expression \"...012345678901234567890*\{abcdefghijklmnopqrstuv...\"" 945 946test parseExpr-21.50 {error message} -body { 947 expr {123456789012345678901234567890*$foo(["abcdefghijklmnopqrstuvwxyz])} 948} -returnCodes error -result {missing " 949in expression "...678901234567890*$foo(["abcdefghijklmnopqrstuv..."} 950test parseExpr-21.51 {error message} -body { 951 expr "123456789012345678901234567890*\$\{abcdefghijklmnopqrstuvwxyz" 952} -returnCodes error -result "missing close-brace for variable name 953in expression \"...12345678901234567890*\$\{abcdefghijklmnopqrstuv...\"" 954test parseExpr-21.52 {error message} -body { 955 expr {123456789012345678901234567890*$bar(abcdefghijklmnopqrstuvwxyz} 956} -returnCodes error -result {missing ) 957in expression "...45678901234567890*$bar(abcdefghijklmnopqrstuv..."} 958test parseExpr-21.53 {error message} -body { 959 expr {123456789012345678901234567890*$bar([{}abcdefghijklmnopqrstuvwxyz])"} 960} -returnCodes error -result {extra characters after close-brace 961in expression "...8901234567890*$bar([{}abcdefghijklmnopqrstuv..."} 962test parseExpr-21.54 {error message} -body { 963 expr {123456789012345678901234567890*$bar([""abcdefghijklmnopqrstuvwxyz])"} 964} -returnCodes error -result {extra characters after close-quote 965in expression "...8901234567890*$bar([""abcdefghijklmnopqrstuv..."} 966test parseExpr-21.55 {error message} -body { 967 expr {123456789012345678901234567890*$bar([abcdefghijklmnopqrstuvwxyz)"} 968} -returnCodes error -result {missing close-bracket 969in expression "...5678901234567890*$bar([abcdefghijklmnopqrstuv..."} 970test parseExpr-21.56 {error message} -body { 971 expr "123456789012345678901234567890*\$bar(\[\{abcdefghijklmnopqrstuvwxyz])" 972} -returnCodes error -result "missing close-brace 973in expression \"...678901234567890*\$bar(\[\{abcdefghijklmnopqrstuv...\"" 974 975test parseExpr-21.57 {error message} -body { 976 expr {123456789012345678901234567890*["abcdefghijklmnopqrstuvwxyz]} 977} -returnCodes error -result {missing " 978in expression "...12345678901234567890*["abcdefghijklmnopqrstuv..."} 979test parseExpr-21.58 {error message} -body { 980 expr "123456789012345678901234567890*\[\$\{abcdefghijklmnopqrstuvwxyz]" 981} -returnCodes error -result "missing close-brace for variable name 982in expression \"...2345678901234567890*\[\$\{abcdefghijklmnopqrstuv...\"" 983test parseExpr-21.59 {error message} -body { 984 expr {123456789012345678901234567890*[$bar(abcdefghijklmnopqrstuvwxyz]} 985} -returnCodes error -result {missing ) 986in expression "...5678901234567890*[$bar(abcdefghijklmnopqrstuv..."} 987test parseExpr-21.60 {error message} -body { 988 expr {123456789012345678901234567890*[{}abcdefghijklmnopqrstuvwxyz]"} 989} -returnCodes error -result {extra characters after close-brace 990in expression "...345678901234567890*[{}abcdefghijklmnopqrstuv..."} 991test parseExpr-21.61 {error message} -body { 992 expr {123456789012345678901234567890*[""abcdefghijklmnopqrstuvwxyz]"} 993} -returnCodes error -result {extra characters after close-quote 994in expression "...345678901234567890*[""abcdefghijklmnopqrstuv..."} 995test parseExpr-21.62 {error message} -body { 996 expr {123456789012345678901234567890*[abcdefghijklmnopqrstuvwxyz"} 997} -returnCodes error -result {missing close-bracket 998in expression "...012345678901234567890*[abcdefghijklmnopqrstuv..."} 999test parseExpr-21.63 {error message} -body { 1000 expr "123456789012345678901234567890*\[\{abcdefghijklmnopqrstuvwxyz]" 1001} -returnCodes error -result "missing close-brace 1002in expression \"...12345678901234567890*\[\{abcdefghijklmnopqrstuv...\"" 1003 1004test parseExpr-22.1 {Bug 3401704} -constraints testexprparser -body { 1005 testexprparser 2a() 1 1006} -result {- {} 0 subexpr 2 1 text 2 0 {}} 1007test parseExpr-22.2 {Bug 3401704} -constraints testexprparser -body { 1008 testexprparser nana() 3 1009} -result {- {} 0 subexpr nan 1 text nan 0 {}} 1010test parseExpr-22.3 {Bug 3401704} -constraints testexprparser -body { 1011 testexprparser 2a() -1 1012} -result {- {} 0 subexpr 2a() 1 operator 2a 0 {}} 1013test parseExpr-22.4 {Bug 3401704} -constraints testexprparser -body { 1014 testexprparser nana() -1 1015} -result {- {} 0 subexpr nana() 1 operator nana 0 {}} 1016test parseExpr-22.5 {Bug 3401704} -constraints testexprparser -body { 1017 testexprparser nan9() -1 1018} -result {- {} 0 subexpr nan9() 1 operator nan9 0 {}} 1019test parseExpr-22.6 {Bug 3401704} -constraints testexprparser -body { 1020 testexprparser 2_() -1 1021} -result {- {} 0 subexpr 2_() 1 operator 2_ 0 {}} 1022test parseExpr-22.7 {Bug 3401704} -constraints testexprparser -body { 1023 testexprparser nan_() -1 1024} -result {- {} 0 subexpr nan_() 1 operator nan_ 0 {}} 1025test 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} 1029test parseExpr-22.9 {Bug 3401704} -constraints testexprparser -body { 1030 testexprparser 1e3_() -1 1031} -result {- {} 0 subexpr 1e3_() 1 operator 1e3_ 0 {}} 1032test 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} 1036test 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} 1040test 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} 1044test parseExpr-22.13 {Bug 3401704} -constraints testexprparser -body { 1045 testexprparser naner() -1 1046} -result {- {} 0 subexpr naner() 1 operator naner 0 {}} 1047 1048test parseExpr-22.14 {Bug 3401704} -constraints testexprparser -body { 1049 testexprparser 07 -1 1050} -result {- {} 0 subexpr 07 1 text 07 0 {}} 1051test parseExpr-22.15 {Bug 3401704} -constraints testexprparser -body { 1052 catch {testexprparser 0o8 -1} m o 1053 dict get $o -errorcode 1054} -result {TCL PARSE EXPR BADNUMBER OCTAL} 1055test parseExpr-22.16 {Bug 3401704} -constraints testexprparser -body { 1056 catch {testexprparser 0o08 -1} m o 1057 dict get $o -errorcode 1058} -result {TCL PARSE EXPR BADNUMBER OCTAL} 1059test parseExpr-22.17 {Bug 3401704} -constraints testexprparser -body { 1060 catch {testexprparser 0b2 -1} m o 1061 dict get $o -errorcode 1062} -result {TCL PARSE EXPR BADNUMBER BINARY} 1063test parseExpr-22.18 {Bug 3401704} -constraints testexprparser -body { 1064 catch {testexprparser 0b02 -1} m o 1065 dict get $o -errorcode 1066} -result {TCL PARSE EXPR BADNUMBER BINARY} 1067 1068test parseExpr-22.19 {Bug d2ffcca163} -constraints testexprparser -body { 1069 testexprparser г -1 1070} -returnCodes error -match glob -result {*invalid character*} 1071test parseExpr-22.20 {Bug d2ffcca163} -constraints testexprparser -body { 1072 testexprparser п -1 1073} -returnCodes error -match glob -result {*invalid character*} 1074test parseExpr-22.21 {Bug d2ffcca163} -constraints testexprparser -body { 1075 testexprparser inг(0) -1 1076} -returnCodes error -match glob -result {missing operand*} 1077 1078test parseExpr-23.1 {TIP 582: comments} -constraints testexprparser -body { 1079 testexprparser "7 # * 8 " -1 1080} -result {- {} 0 subexpr 7 1 text 7 0 {}} 1081test parseExpr-23.2 {TIP 582: comments} -constraints testexprparser -body { 1082 testexprparser "7 #\n* 8 " -1 1083} -result {- {} 0 subexpr {7 # 1084*} 5 operator # 0 subexpr 7 1 text 7 0 subexpr * 1 text * 0 {}} 1085 1086# cleanup 1087cleanupTests 1088return 1089