home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tcl8.0 / tests / expr-old.test < prev    next >
Encoding:
Text File  |  1997-08-15  |  36.1 KB  |  905 lines  |  [TEXT/ALFA]

  1. # Commands covered: expr
  2. #
  3. # This file contains the original set of tests for Tcl's expr command.
  4. # Since the expr command is now compiled, a new set of tests covering
  5. # the new implementation is in the file "expr.test". Sourcing this file
  6. # into Tcl runs the tests and generates output for errors.
  7. # No output means no errors were found.
  8. #
  9. # Copyright (c) 1991-1994 The Regents of the University of California.
  10. # Copyright (c) 1994-1997 Sun Microsystems, Inc.
  11. #
  12. # See the file "license.terms" for information on usage and redistribution
  13. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  14. #
  15. # SCCS: @(#) expr-old.test 1.61 97/08/13 10:26:38
  16.  
  17. if {[string compare test [info procs test]] == 1} then {source defs}
  18.  
  19. if {([catch {expr T1()} msg] == 1) && ($msg == {unknown math function "T1"})} {
  20.     set gotT1 0
  21.     puts "This application hasn't been compiled with the \"T1\" and"
  22.     puts "\"T2\" math functions, so I'll skip some of the expr tests."
  23. } else {
  24.     set gotT1 1
  25. }
  26.  
  27. # First, test all of the integer operators individually.
  28.  
  29. test expr-old-1.1 {integer operators} {expr -4} -4
  30. test expr-old-1.2 {integer operators} {expr -(1+4)} -5
  31. test expr-old-1.3 {integer operators} {expr ~3} -4
  32. test expr-old-1.4 {integer operators} {expr !2} 0
  33. test expr-old-1.5 {integer operators} {expr !0} 1
  34. test expr-old-1.6 {integer operators} {expr 4*6} 24
  35. test expr-old-1.7 {integer operators} {expr 36/12} 3
  36. test expr-old-1.8 {integer operators} {expr 27/4} 6
  37. test expr-old-1.9 {integer operators} {expr 27%4} 3
  38. test expr-old-1.10 {integer operators} {expr 2+2} 4
  39. test expr-old-1.11 {integer operators} {expr 2-6} -4
  40. test expr-old-1.12 {integer operators} {expr 1<<3} 8
  41. test expr-old-1.13 {integer operators} {expr 0xff>>2} 63
  42. test expr-old-1.14 {integer operators} {expr -1>>2} -1
  43. test expr-old-1.15 {integer operators} {expr 3>2} 1
  44. test expr-old-1.16 {integer operators} {expr 2>2} 0
  45. test expr-old-1.17 {integer operators} {expr 1>2} 0
  46. test expr-old-1.18 {integer operators} {expr 3<2} 0
  47. test expr-old-1.19 {integer operators} {expr 2<2} 0
  48. test expr-old-1.20 {integer operators} {expr 1<2} 1
  49. test expr-old-1.21 {integer operators} {expr 3>=2} 1
  50. test expr-old-1.22 {integer operators} {expr 2>=2} 1
  51. test expr-old-1.23 {integer operators} {expr 1>=2} 0
  52. test expr-old-1.24 {integer operators} {expr 3<=2} 0
  53. test expr-old-1.25 {integer operators} {expr 2<=2} 1
  54. test expr-old-1.26 {integer operators} {expr 1<=2} 1
  55. test expr-old-1.27 {integer operators} {expr 3==2} 0
  56. test expr-old-1.28 {integer operators} {expr 2==2} 1
  57. test expr-old-1.29 {integer operators} {expr 3!=2} 1
  58. test expr-old-1.30 {integer operators} {expr 2!=2} 0
  59. test expr-old-1.31 {integer operators} {expr 7&0x13} 3
  60. test expr-old-1.32 {integer operators} {expr 7^0x13} 20
  61. test expr-old-1.33 {integer operators} {expr 7|0x13} 23
  62. test expr-old-1.34 {integer operators} {expr 0&&1} 0
  63. test expr-old-1.35 {integer operators} {expr 0&&0} 0
  64. test expr-old-1.36 {integer operators} {expr 1&&3} 1
  65. test expr-old-1.37 {integer operators} {expr 0||1} 1
  66. test expr-old-1.38 {integer operators} {expr 3||0} 1
  67. test expr-old-1.39 {integer operators} {expr 0||0} 0
  68. test expr-old-1.40 {integer operators} {expr 3>2?44:66} 44
  69. test expr-old-1.41 {integer operators} {expr 2>3?44:66} 66
  70. test expr-old-1.42 {integer operators} {expr 36/5} 7
  71. test expr-old-1.43 {integer operators} {expr 36%5} 1
  72. test expr-old-1.44 {integer operators} {expr -36/5} -8
  73. test expr-old-1.45 {integer operators} {expr -36%5} 4
  74. test expr-old-1.46 {integer operators} {expr 36/-5} -8
  75. test expr-old-1.47 {integer operators} {expr 36%-5} -4
  76. test expr-old-1.48 {integer operators} {expr -36/-5} 7
  77. test expr-old-1.49 {integer operators} {expr -36%-5} -1
  78. test expr-old-1.50 {integer operators} {expr +36} 36
  79. test expr-old-1.51 {integer operators} {expr +--++36} 36
  80. test expr-old-1.52 {integer operators} {expr +36%+5} 1
  81.  
  82. # Check the floating-point operators individually, along with
  83. # automatic conversion to integers where needed.
  84.  
  85. test expr-old-2.1 {floating-point operators} {expr -4.2} -4.2
  86. test expr-old-2.2 {floating-point operators} {expr -(1.1+4.2)} -5.3
  87. test expr-old-2.3 {floating-point operators} {expr +5.7} 5.7
  88. test expr-old-2.4 {floating-point operators} {expr +--+-62.0} -62.0
  89. test expr-old-2.5 {floating-point operators} {expr !2.1} 0
  90. test expr-old-2.6 {floating-point operators} {expr !0.0} 1
  91. test expr-old-2.7 {floating-point operators} {expr 4.2*6.3} 26.46
  92. test expr-old-2.8 {floating-point operators} {expr 36.0/12.0} 3.0
  93. test expr-old-2.9 {floating-point operators} {expr 27/4.0} 6.75
  94. test expr-old-2.10 {floating-point operators} {expr 2.3+2.1} 4.4
  95. test expr-old-2.11 {floating-point operators} {expr 2.3-6.5} -4.2
  96. test expr-old-2.12 {floating-point operators} {expr 3.1>2.1} 1
  97. test expr-old-2.13 {floating-point operators} {expr {2.1 > 2.1}} 0
  98. test expr-old-2.14 {floating-point operators} {expr 1.23>2.34e+1} 0
  99. test expr-old-2.15 {floating-point operators} {expr 3.45<2.34} 0
  100. test expr-old-2.16 {floating-point operators} {expr 0.002e3<--200e-2} 0
  101. test expr-old-2.17 {floating-point operators} {expr 1.1<2.1} 1
  102. test expr-old-2.18 {floating-point operators} {expr 3.1>=2.2} 1
  103. test expr-old-2.19 {floating-point operators} {expr 2.345>=2.345} 1
  104. test expr-old-2.20 {floating-point operators} {expr 1.1>=2.2} 0
  105. test expr-old-2.21 {floating-point operators} {expr 3.0<=2.0} 0
  106. test expr-old-2.22 {floating-point operators} {expr 2.2<=2.2} 1
  107. test expr-old-2.23 {floating-point operators} {expr 2.2<=2.2001} 1
  108. test expr-old-2.24 {floating-point operators} {expr 3.2==2.2} 0
  109. test expr-old-2.25 {floating-point operators} {expr 2.2==2.2} 1
  110. test expr-old-2.26 {floating-point operators} {expr 3.2!=2.2} 1
  111. test expr-old-2.27 {floating-point operators} {expr 2.2!=2.2} 0
  112. test expr-old-2.28 {floating-point operators} {expr 0.0&&0.0} 0
  113. test expr-old-2.29 {floating-point operators} {expr 0.0&&1.3} 0
  114. test expr-old-2.30 {floating-point operators} {expr 1.3&&0.0} 0
  115. test expr-old-2.31 {floating-point operators} {expr 1.3&&3.3} 1
  116. test expr-old-2.32 {floating-point operators} {expr 0.0||0.0} 0
  117. test expr-old-2.33 {floating-point operators} {expr 0.0||1.3} 1
  118. test expr-old-2.34 {floating-point operators} {expr 1.3||0.0} 1
  119. test expr-old-2.35 {floating-point operators} {expr 3.3||0.0} 1
  120. test expr-old-2.36 {floating-point operators} {expr 3.3>2.3?44.3:66.3} 44.3
  121. test expr-old-2.37 {floating-point operators} {expr 2.3>3.3?44.3:66.3} 66.3
  122. test expr-old-2.38 {floating-point operators} {
  123.     list [catch {expr 028.1 + 09.2} msg] $msg
  124. } {0 37.3}
  125.  
  126. # Operators that aren't legal on floating-point numbers
  127.  
  128. test expr-old-3.1 {illegal floating-point operations} {
  129.     list [catch {expr ~4.0} msg] $msg
  130. } {1 {can't use floating-point value as operand of "~"}}
  131. test expr-old-3.2 {illegal floating-point operations} {
  132.     list [catch {expr 27%4.0} msg] $msg
  133. } {1 {can't use floating-point value as operand of "%"}}
  134. test expr-old-3.3 {illegal floating-point operations} {
  135.     list [catch {expr 27.0%4} msg] $msg
  136. } {1 {can't use floating-point value as operand of "%"}}
  137. test expr-old-3.4 {illegal floating-point operations} {
  138.     list [catch {expr 1.0<<3} msg] $msg
  139. } {1 {can't use floating-point value as operand of "<<"}}
  140. test expr-old-3.5 {illegal floating-point operations} {
  141.     list [catch {expr 3<<1.0} msg] $msg
  142. } {1 {can't use floating-point value as operand of "<<"}}
  143. test expr-old-3.6 {illegal floating-point operations} {
  144.     list [catch {expr 24.0>>3} msg] $msg
  145. } {1 {can't use floating-point value as operand of ">>"}}
  146. test expr-old-3.7 {illegal floating-point operations} {
  147.     list [catch {expr 24>>3.0} msg] $msg
  148. } {1 {can't use floating-point value as operand of ">>"}}
  149. test expr-old-3.8 {illegal floating-point operations} {
  150.     list [catch {expr 24&3.0} msg] $msg
  151. } {1 {can't use floating-point value as operand of "&"}}
  152. test expr-old-3.9 {illegal floating-point operations} {
  153.     list [catch {expr 24.0|3} msg] $msg
  154. } {1 {can't use floating-point value as operand of "|"}}
  155. test expr-old-3.10 {illegal floating-point operations} {
  156.     list [catch {expr 24.0^3} msg] $msg
  157. } {1 {can't use floating-point value as operand of "^"}}
  158.  
  159. # Check the string operators individually.
  160.  
  161. test expr-old-4.1 {string operators} {expr {"abc" > "def"}} 0
  162. test expr-old-4.2 {string operators} {expr {"def" > "def"}} 0
  163. test expr-old-4.3 {string operators} {expr {"g" > "def"}} 1
  164. test expr-old-4.4 {string operators} {expr {"abc" < "abd"}} 1
  165. test expr-old-4.5 {string operators} {expr {"abd" < "abd"}} 0
  166. test expr-old-4.6 {string operators} {expr {"abe" < "abd"}} 0
  167. test expr-old-4.7 {string operators} {expr {"abc" >= "def"}} 0
  168. test expr-old-4.8 {string operators} {expr {"def" >= "def"}} 1
  169. test expr-old-4.9 {string operators} {expr {"g" >= "def"}} 1
  170. test expr-old-4.10 {string operators} {expr {"abc" <= "abd"}} 1
  171. test expr-old-4.11 {string operators} {expr {"abd" <= "abd"}} 1
  172. test expr-old-4.12 {string operators} {expr {"abe" <= "abd"}} 0
  173. test expr-old-4.13 {string operators} {expr {"abc" == "abd"}} 0
  174. test expr-old-4.14 {string operators} {expr {"abd" == "abd"}} 1
  175. test expr-old-4.15 {string operators} {expr {"abc" != "abd"}} 1
  176. test expr-old-4.16 {string operators} {expr {"abd" != "abd"}} 0
  177. test expr-old-4.17 {string operators} {expr {"0y" < "0x12"}} 0
  178. test expr-old-4.18 {string operators} {expr {"." < " "}} 0
  179.  
  180. # The following tests are non-portable because on some systems "+"
  181. # and "-" can be parsed as numbers.
  182.  
  183. test expr-old-4.19 {string operators} {nonPortable} {expr {"0" == "+"}} 0
  184. test expr-old-4.20 {string operators} {nonPortable} {expr {"0" == "-"}} 0
  185. test expr-old-4.21 {string operators} {expr {1?"foo":"bar"}} foo
  186. test expr-old-4.22 {string operators} {expr {0?"foo":"bar"}} bar
  187.  
  188. # Operators that aren't legal on string operands.
  189.  
  190. test expr-old-5.1 {illegal string operations} {
  191.     list [catch {expr {-"a"}} msg] $msg
  192. } {1 {can't use non-numeric string as operand of "-"}}
  193. test expr-old-5.2 {illegal string operations} {
  194.     list [catch {expr {+"a"}} msg] $msg
  195. } {1 {can't use non-numeric string as operand of "+"}}
  196. test expr-old-5.3 {illegal string operations} {
  197.     list [catch {expr {~"a"}} msg] $msg
  198. } {1 {can't use non-numeric string as operand of "~"}}
  199. test expr-old-5.4 {illegal string operations} {
  200.     list [catch {expr {!"a"}} msg] $msg
  201. } {1 {can't use non-numeric string as operand of "!"}}
  202. test expr-old-5.5 {illegal string operations} {
  203.     list [catch {expr {"a"*"b"}} msg] $msg
  204. } {1 {can't use non-numeric string as operand of "*"}}
  205. test expr-old-5.6 {illegal string operations} {
  206.     list [catch {expr {"a"/"b"}} msg] $msg
  207. } {1 {can't use non-numeric string as operand of "/"}}
  208. test expr-old-5.7 {illegal string operations} {
  209.     list [catch {expr {"a"%"b"}} msg] $msg
  210. } {1 {can't use non-numeric string as operand of "%"}}
  211. test expr-old-5.8 {illegal string operations} {
  212.     list [catch {expr {"a"+"b"}} msg] $msg
  213. } {1 {can't use non-numeric string as operand of "+"}}
  214. test expr-old-5.9 {illegal string operations} {
  215.     list [catch {expr {"a"-"b"}} msg] $msg
  216. } {1 {can't use non-numeric string as operand of "-"}}
  217. test expr-old-5.10 {illegal string operations} {
  218.     list [catch {expr {"a"<<"b"}} msg] $msg
  219. } {1 {can't use non-numeric string as operand of "<<"}}
  220. test expr-old-5.11 {illegal string operations} {
  221.     list [catch {expr {"a">>"b"}} msg] $msg
  222. } {1 {can't use non-numeric string as operand of ">>"}}
  223. test expr-old-5.12 {illegal string operations} {
  224.     list [catch {expr {"a"&"b"}} msg] $msg
  225. } {1 {can't use non-numeric string as operand of "&"}}
  226. test expr-old-5.13 {illegal string operations} {
  227.     list [catch {expr {"a"^"b"}} msg] $msg
  228. } {1 {can't use non-numeric string as operand of "^"}}
  229. test expr-old-5.14 {illegal string operations} {
  230.     list [catch {expr {"a"|"b"}} msg] $msg
  231. } {1 {can't use non-numeric string as operand of "|"}}
  232. test expr-old-5.15 {illegal string operations} {
  233.     list [catch {expr {"a"&&"b"}} msg] $msg
  234. } {1 {expected boolean value but got "a"}}
  235. test expr-old-5.16 {illegal string operations} {
  236.     list [catch {expr {"a"||"b"}} msg] $msg
  237. } {1 {expected boolean value but got "a"}}
  238. test expr-old-5.17 {illegal string operations} {
  239.     list [catch {expr {"a"?4:2}} msg] $msg
  240. } {1 {expected boolean value but got "a"}}
  241.  
  242. # Check precedence pairwise.
  243.  
  244. test expr-old-6.1 {precedence checks} {expr -~3} 4
  245. test expr-old-6.2 {precedence checks} {expr -!3} 0
  246. test expr-old-6.3 {precedence checks} {expr -~0} 1
  247.  
  248. test expr-old-7.1 {precedence checks} {expr 2*4/6} 1
  249. test expr-old-7.2 {precedence checks} {expr 24/6*3} 12
  250. test expr-old-7.3 {precedence checks} {expr 24/6/2} 2
  251.  
  252. test expr-old-8.1 {precedence checks} {expr -2+4} 2
  253. test expr-old-8.2 {precedence checks} {expr -2-4} -6
  254. test expr-old-8.3 {precedence checks} {expr +2-4} -2
  255.  
  256. test expr-old-9.1 {precedence checks} {expr 2*3+4} 10
  257. test expr-old-9.2 {precedence checks} {expr 8/2+4} 8
  258. test expr-old-9.3 {precedence checks} {expr 8%3+4} 6
  259. test expr-old-9.4 {precedence checks} {expr 2*3-1} 5
  260. test expr-old-9.5 {precedence checks} {expr 8/2-1} 3
  261. test expr-old-9.6 {precedence checks} {expr 8%3-1} 1
  262.  
  263. test expr-old-10.1 {precedence checks} {expr 6-3-2} 1
  264.  
  265. test expr-old-11.1 {precedence checks} {expr 7+1>>2} 2
  266. test expr-old-11.2 {precedence checks} {expr 7+1<<2} 32
  267. test expr-old-11.3 {precedence checks} {expr 7>>3-2} 3
  268. test expr-old-11.4 {precedence checks} {expr 7<<3-2} 14
  269.  
  270. test expr-old-12.1 {precedence checks} {expr 6>>1>4} 0
  271. test expr-old-12.2 {precedence checks} {expr 6>>1<2} 0
  272. test expr-old-12.3 {precedence checks} {expr 6>>1>=3} 1
  273. test expr-old-12.4 {precedence checks} {expr 6>>1<=2} 0
  274. test expr-old-12.5 {precedence checks} {expr 6<<1>5} 1
  275. test expr-old-12.6 {precedence checks} {expr 6<<1<5} 0
  276. test expr-old-12.7 {precedence checks} {expr 5<=6<<1} 1
  277. test expr-old-12.8 {precedence checks} {expr 5>=6<<1} 0
  278.  
  279. test expr-old-13.1 {precedence checks} {expr 2<3<4} 1
  280. test expr-old-13.2 {precedence checks} {expr 0<4>2} 0
  281. test expr-old-13.3 {precedence checks} {expr 4>2<1} 0
  282. test expr-old-13.4 {precedence checks} {expr 4>3>2} 0
  283. test expr-old-13.5 {precedence checks} {expr 4>3>=2} 0
  284. test expr-old-13.6 {precedence checks} {expr 4>=3>2} 0
  285. test expr-old-13.7 {precedence checks} {expr 4>=3>=2} 0
  286. test expr-old-13.8 {precedence checks} {expr 0<=4>=2} 0
  287. test expr-old-13.9 {precedence checks} {expr 4>=2<=0} 0
  288. test expr-old-13.10 {precedence checks} {expr 2<=3<=4} 1
  289.  
  290. test expr-old-14.1 {precedence checks} {expr 1==4>3} 1
  291. test expr-old-14.2 {precedence checks} {expr 0!=4>3} 1
  292. test expr-old-14.3 {precedence checks} {expr 1==3<4} 1
  293. test expr-old-14.4 {precedence checks} {expr 0!=3<4} 1
  294. test expr-old-14.5 {precedence checks} {expr 1==4>=3} 1
  295. test expr-old-14.6 {precedence checks} {expr 0!=4>=3} 1
  296. test expr-old-14.7 {precedence checks} {expr 1==3<=4} 1
  297. test expr-old-14.8 {precedence checks} {expr 0!=3<=4} 1
  298.  
  299. test expr-old-15.1 {precedence checks} {expr 1==3==3} 0
  300. test expr-old-15.2 {precedence checks} {expr 3==3!=2} 1
  301. test expr-old-15.3 {precedence checks} {expr 2!=3==3} 0
  302. test expr-old-15.4 {precedence checks} {expr 2!=1!=1} 0
  303.  
  304. test expr-old-16.1 {precedence checks} {expr 2&3==2} 0
  305. test expr-old-16.2 {precedence checks} {expr 1&3!=3} 0
  306.  
  307. test expr-old-17.1 {precedence checks} {expr 7&3^0x10} 19
  308. test expr-old-17.2 {precedence checks} {expr 7^0x10&3} 7
  309.  
  310. test expr-old-18.1 {precedence checks} {expr 7^0x10|3} 23
  311. test expr-old-18.2 {precedence checks} {expr 7|0x10^3} 23
  312.  
  313. test expr-old-19.1 {precedence checks} {expr 7|3&&1} 1
  314. test expr-old-19.2 {precedence checks} {expr 1&&3|7} 1
  315. test expr-old-19.3 {precedence checks} {expr 0&&1||1} 1
  316. test expr-old-19.4 {precedence checks} {expr 1||1&&0} 1
  317.  
  318. test expr-old-20.1 {precedence checks} {expr 1||0?3:4} 3
  319. test expr-old-20.2 {precedence checks} {expr 1?0:4||1} 0
  320. test expr-old-20.3 {precedence checks} {expr 1?2:0?3:4} 2
  321. test expr-old-20.4 {precedence checks} {expr 0?2:0?3:4} 4
  322. test expr-old-20.5 {precedence checks} {expr 1?2?3:4:0} 3
  323. test expr-old-20.6 {precedence checks} {expr 0?2?3:4:0} 0
  324.  
  325. # Parentheses.
  326.  
  327. test expr-old-21.1 {parenthesization} {expr (2+4)*6} 36
  328. test expr-old-21.2 {parenthesization} {expr (1?0:4)||1} 1
  329. test expr-old-21.3 {parenthesization} {expr +(3-4)} -1
  330.  
  331. # Embedded commands and variable names.
  332.  
  333. set a 16 
  334. test expr-old-22.1 {embedded variables} {expr {2*$a}} 32 
  335. test expr-old-22.2 {embedded variables} {
  336.     set x -5
  337.     set y 10
  338.     expr {$x + $y}
  339. } {5} 
  340. test expr-old-22.3 {embedded variables} {
  341.     set x "  -5"
  342.     set y "  +10"
  343.     expr {$x + $y}
  344. } {5}
  345. test expr-old-22.4 {embedded commands and variables} {expr {[set a] - 14}} 2
  346. test expr-old-22.5 {embedded commands and variables} {
  347.     list [catch {expr {12 - [bad_command_name]}} msg] $msg
  348. } {1 {invalid command name "bad_command_name"}}
  349.  
  350. # Double-quotes and things inside them.
  351.  
  352. test expr-old-23.1 {double quotes} {expr {"abc"}} abc
  353. test expr-old-23.2 {double quotes} {
  354.     set a 189
  355.     expr {"$a.bc"}
  356. } 189.bc
  357. test expr-old-23.3 {double quotes} {
  358.     set b2 xyx
  359.     expr {"$b2$b2$b2.[set b2].[set b2]"}
  360. } xyxxyxxyx.xyx.xyx
  361. test expr-old-23.4 {double quotes} {expr {"11\}\}22"}} 11}}22
  362. test expr-old-23.5 {double quotes} {expr {"\*bc"}} {*bc}
  363. test expr-old-23.6 {double quotes} {
  364.     catch {unset bogus__}
  365.     list [catch {expr {"$bogus__"}} msg] $msg
  366. } {1 {can't read "bogus__": no such variable}}
  367. test expr-old-23.7 {double quotes} {
  368.     list [catch {expr {"a[error Testing]bc"}} msg] $msg
  369. } {1 Testing}
  370. test expr-old-23.8 {double quotes} {
  371.     list [catch {expr {"12398712938788234-1298379" != ""}} msg] $msg
  372. } {0 1}
  373.  
  374. # Numbers in various bases.
  375.  
  376. test expr-old-24.1 {numbers in different bases} {expr 0x20} 32
  377. test expr-old-24.2 {numbers in different bases} {expr 015} 13
  378.  
  379. # Conversions between various data types.
  380.  
  381. test expr-old-25.1 {type conversions} {expr 2+2.5} 4.5
  382. test expr-old-25.2 {type conversions} {expr 2.5+2} 4.5
  383. test expr-old-25.3 {type conversions} {expr 2-2.5} -0.5
  384. test expr-old-25.4 {type conversions} {expr 2/2.5} 0.8
  385. test expr-old-25.5 {type conversions} {expr 2>2.5} 0
  386. test expr-old-25.6 {type conversions} {expr 2.5>2} 1
  387. test expr-old-25.7 {type conversions} {expr 2<2.5} 1
  388. test expr-old-25.8 {type conversions} {expr 2>=2.5} 0
  389. test expr-old-25.9 {type conversions} {expr 2<=2.5} 1
  390. test expr-old-25.10 {type conversions} {expr 2==2.5} 0
  391. test expr-old-25.11 {type conversions} {expr 2!=2.5} 1
  392. test expr-old-25.12 {type conversions} {expr 2>"ab"} 0
  393. test expr-old-25.13 {type conversions} {expr {2>" "}} 1
  394. test expr-old-25.14 {type conversions} {expr {"24.1a" > 24.1}} 1
  395. test expr-old-25.15 {type conversions} {expr {24.1 > "24.1a"}} 0
  396. test expr-old-25.16 {type conversions} {expr 2+2.5} 4.5
  397. test expr-old-25.17 {type conversions} {expr 2+2.5} 4.5
  398. test expr-old-25.18 {type conversions} {expr 2.0e2} 200.0
  399. test expr-old-25.19 {type conversions} {expr 2.0e15} 2e+15
  400. test expr-old-25.20 {type conversions} {expr 10.0} 10.0
  401.  
  402. # Various error conditions.
  403.  
  404. test expr-old-26.1 {error conditions} {
  405.     list [catch {expr 2+"a"} msg] $msg
  406. } {1 {can't use non-numeric string as operand of "+"}}
  407. test expr-old-26.2 {error conditions} {
  408.     list [catch {expr 2+4*} msg] $msg
  409. } {1 {syntax error in expression "2+4*"}}
  410. test expr-old-26.3 {error conditions} {
  411.     list [catch {expr 2+4*(} msg] $msg
  412. } {1 {syntax error in expression "2+4*("}}
  413. catch {unset _non_existent_}
  414. test expr-old-26.4 {error conditions} {
  415.     list [catch {expr 2+$_non_existent_} msg] $msg
  416. } {1 {can't read "_non_existent_": no such variable}}
  417. set a xx
  418. test expr-old-26.5 {error conditions} {
  419.     list [catch {expr {2+$a}} msg] $msg
  420. } {1 {can't use non-numeric string as operand of "+"}}
  421. test expr-old-26.6 {error conditions} {
  422.     list [catch {expr {2+[set a]}} msg] $msg
  423. } {1 {can't use non-numeric string as operand of "+"}}
  424. test expr-old-26.7 {error conditions} {
  425.     list [catch {expr {2+(4}} msg] $msg
  426. } {1 {syntax error in expression "2+(4"}}
  427. test expr-old-26.8 {error conditions} {
  428.     list [catch {expr 2/0} msg] $msg $errorCode
  429. } {1 {divide by zero} {ARITH DIVZERO {divide by zero}}}
  430. test expr-old-26.9 {error conditions} {
  431.     list [catch {expr 2%0} msg] $msg $errorCode
  432. } {1 {divide by zero} {ARITH DIVZERO {divide by zero}}}
  433. test expr-old-26.10 {error conditions} {
  434.     list [catch {expr 2.0/0.0} msg] $msg $errorCode
  435. } {1 {divide by zero} {ARITH DIVZERO {divide by zero}}}
  436. test expr-old-26.11 {error conditions} {
  437.     list [catch {expr 2#} msg] $msg
  438. } {1 {syntax error in expression "2#"}}
  439. test expr-old-26.12 {error conditions} {
  440.     list [catch {expr a.b} msg] $msg
  441. } {1 {syntax error in expression "a.b"}}
  442. test expr-old-26.13 {error conditions} {
  443.     list [catch {expr {"a"/"b"}} msg] $msg
  444. } {1 {can't use non-numeric string as operand of "/"}}
  445. test expr-old-26.14 {error conditions} {
  446.     list [catch {expr 2:3} msg] $msg
  447. } {1 {syntax error in expression "2:3"}}
  448. test expr-old-26.15 {error conditions} {
  449.     list [catch {expr a@b} msg] $msg
  450. } {1 {syntax error in expression "a@b"}}
  451. test expr-old-26.16 {error conditions} {
  452.     list [catch {expr a[b} msg] $msg
  453. } {1 {missing close-bracket or close-brace}}
  454. test expr-old-26.17 {error conditions} {
  455.     list [catch {expr a`b} msg] $msg
  456. } {1 {syntax error in expression "a`b"}}
  457. test expr-old-26.18 {error conditions} {
  458.     list [catch {expr \"a\"\{b} msg] $msg
  459. } {1 {missing close-brace}}
  460. test expr-old-26.19 {error conditions} {
  461.     list [catch {expr a} msg] $msg
  462. } {1 {syntax error in expression "a"}}
  463. test expr-old-26.20 {error conditions} {
  464.     list [catch expr msg] $msg
  465. } {1 {wrong # args: should be "expr arg ?arg ...?"}}
  466.  
  467. # Cancelled evaluation.
  468.  
  469. test expr-old-27.1 {cancelled evaluation} {
  470.     set a 1
  471.     expr {0&&[set a 2]}
  472.     set a
  473. } 1
  474. test expr-old-27.2 {cancelled evaluation} {
  475.     set a 1
  476.     expr {1||[set a 2]}
  477.     set a
  478. } 1
  479. test expr-old-27.3 {cancelled evaluation} {
  480.     set a 1
  481.     expr {0?[set a 2]:1}
  482.     set a
  483. } 1
  484. test expr-old-27.4 {cancelled evaluation} {
  485.     set a 1
  486.     expr {1?2:[set a 2]}
  487.     set a
  488. } 1
  489. catch {unset x}
  490. test expr-old-27.5 {cancelled evaluation} {
  491.     list [catch {expr {[info exists x] && $x}} msg] $msg
  492. } {0 0}
  493. test expr-old-27.6 {cancelled evaluation} {
  494.     list [catch {expr {0 && [concat $x]}} msg] $msg
  495. } {0 0}
  496. test expr-old-27.7 {cancelled evaluation} {
  497.     set one 1
  498.     list [catch {expr {1 || 1/$one}} msg] $msg
  499. } {0 1}
  500. test expr-old-27.8 {cancelled evaluation} {
  501.     list [catch {expr {1 || -"string"}} msg] $msg
  502. } {0 1}
  503. test expr-old-27.9 {cancelled evaluation} {
  504.     list [catch {expr {1 || ("string" * ("x" && "y"))}} msg] $msg
  505. } {0 1}
  506. test expr-old-27.10 {cancelled evaluation} {
  507.     set x -1.0
  508.     list [catch {expr {($x > 0) ? round(log($x)) : 0}} msg] $msg
  509. } {0 0}
  510. test expr-old-27.11 {cancelled evaluation} {
  511.     list [catch {expr {0 && foo}} msg] $msg
  512. } {1 {syntax error in expression "0 && foo"}}
  513. test expr-old-27.12 {cancelled evaluation} {
  514.     list [catch {expr {0 ? 1 : foo}} msg] $msg
  515. } {1 {syntax error in expression "0 ? 1 : foo"}}
  516.  
  517. # Tcl_ExprBool as used in "if" statements
  518.  
  519. test expr-old-28.1 {Tcl_ExprBoolean usage} {
  520.     set a 1
  521.     if {2} {set a 2}
  522.     set a
  523. } 2
  524. test expr-old-28.2 {Tcl_ExprBoolean usage} {
  525.     set a 1
  526.     if {0} {set a 2}
  527.     set a
  528. } 1
  529. test expr-old-28.3 {Tcl_ExprBoolean usage} {
  530.     set a 1
  531.     if {1.2} {set a 2}
  532.     set a
  533. } 2
  534. test expr-old-28.4 {Tcl_ExprBoolean usage} {
  535.     set a 1
  536.     if {-1.1} {set a 2}
  537.     set a
  538. } 2
  539. test expr-old-28.5 {Tcl_ExprBoolean usage} {
  540.     set a 1
  541.     if {0.0} {set a 2}
  542.     set a
  543. } 1
  544. test expr-old-28.6 {Tcl_ExprBoolean usage} {
  545.     set a 1
  546.     if {"YES"} {set a 2}
  547.     set a
  548. } 2
  549. test expr-old-28.7 {Tcl_ExprBoolean usage} {
  550.     set a 1
  551.     if {"no"} {set a 2}
  552.     set a
  553. } 1
  554. test expr-old-28.8 {Tcl_ExprBoolean usage} {
  555.     set a 1
  556.     if {"true"} {set a 2}
  557.     set a
  558. } 2
  559. test expr-old-28.9 {Tcl_ExprBoolean usage} {
  560.     set a 1
  561.     if {"fAlse"} {set a 2}
  562.     set a
  563. } 1
  564. test expr-old-28.10 {Tcl_ExprBoolean usage} {
  565.     set a 1
  566.     if {"on"} {set a 2}
  567.     set a
  568. } 2
  569. test expr-old-28.11 {Tcl_ExprBoolean usage} {
  570.     set a 1
  571.     if {"Off"} {set a 2}
  572.     set a
  573. } 1
  574. test expr-old-28.12 {Tcl_ExprBool usage} {
  575.     list [catch {if {"abc"} {}} msg] $msg
  576. } {1 {expected boolean value but got "abc"}}
  577. test expr-old-28.13 {Tcl_ExprBool usage} {
  578.     list [catch {if {"ogle"} {}} msg] $msg
  579. } {1 {expected boolean value but got "ogle"}}
  580. test expr-old-28.14 {Tcl_ExprBool usage} {
  581.     list [catch {if {"o"} {}} msg] $msg
  582. } {1 {expected boolean value but got "o"}}
  583.  
  584. # Operands enclosed in braces
  585.  
  586. test expr-old-29.1 {braces} {expr {{abc}}} abc
  587. test expr-old-29.2 {braces} {expr {{00010}}} 8
  588. test expr-old-29.3 {braces} {expr {{3.1200000}}} 3.12
  589. test expr-old-29.4 {braces} {expr {{a{b}{1 {2 3}}c}}} "a{b}{1 {2 3}}c"
  590. test expr-old-29.5 {braces} {
  591.     list [catch {expr "\{abc"} msg] $msg
  592. } {1 {missing close-brace}}
  593.  
  594. # Very long values
  595.  
  596. test expr-old-30.1 {long values} {
  597.     set a "0000 1111 2222 3333 4444"
  598.     set a "$a | $a | $a | $a | $a"
  599.     set a "$a || $a || $a || $a || $a"
  600.     expr {$a}
  601. } {0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 || 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 || 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 || 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 || 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444}
  602. test expr-old-30.2 {long values} {
  603.     set a "000000000000000000000000000000"
  604.     set a "$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a${a}5"
  605.     expr $a
  606. } 5
  607.  
  608. # Expressions spanning multiple arguments
  609.  
  610. test expr-old-31.1 {multiple arguments to expr command} {
  611.     expr 4 + ( 6 *12) -3
  612. } 73
  613. test expr-old-31.2 {multiple arguments to expr command} {
  614.     list [catch {expr 2 + (3 + 4} msg] $msg
  615. } {1 {syntax error in expression "2 + (3 + 4"}}
  616. test expr-old-31.3 {multiple arguments to expr command} {
  617.     list [catch {expr 2 + 3 +} msg] $msg
  618. } {1 {syntax error in expression "2 + 3 +"}}
  619. test expr-old-31.4 {multiple arguments to expr command} {
  620.     list [catch {expr 2 + 3 )} msg] $msg
  621. } {1 {syntax error in expression "2 + 3 )"}}
  622.  
  623. # Math functions
  624.  
  625. test expr-old-32.1 {math functions in expressions} {
  626.     format %.6g [expr acos(0.5)]
  627. } {1.0472}
  628. test expr-old-32.2 {math functions in expressions} {
  629.     format %.6g [expr asin(0.5)]
  630. } {0.523599}
  631. test expr-old-32.3 {math functions in expressions} {
  632.     format %.6g [expr atan(1.0)]
  633. } {0.785398}
  634. test expr-old-32.4 {math functions in expressions} {
  635.     format %.6g [expr atan2(2.0, 2.0)]
  636. } {0.785398}
  637. test expr-old-32.5 {math functions in expressions} {
  638.     format %.6g [expr ceil(1.999)]
  639. } {2}
  640. test expr-old-32.6 {math functions in expressions} {
  641.     format %.6g [expr cos(.1)]
  642. } {0.995004}
  643. test expr-old-32.7 {math functions in expressions} {
  644.     format %.6g [expr cosh(.1)]
  645. } {1.005}
  646. test expr-old-32.8 {math functions in expressions} {
  647.     format %.6g [expr exp(1.0)]
  648. } {2.71828}
  649. test expr-old-32.9 {math functions in expressions} {
  650.     format %.6g [expr floor(2.000)]
  651. } {2}
  652. test expr-old-32.10 {math functions in expressions} {
  653.     format %.6g [expr floor(2.001)]
  654. } {2}
  655. test expr-old-32.11 {math functions in expressions} {
  656.     format %.6g [expr fmod(7.3, 3.2)]
  657. } {0.9}
  658. test expr-old-32.12 {math functions in expressions} {
  659.     format %.6g [expr hypot(3.0, 4.0)]
  660. } {5}
  661. test expr-old-32.13 {math functions in expressions} {
  662.     format %.6g [expr log(2.8)]
  663. } {1.02962}
  664. test expr-old-32.14 {math functions in expressions} {
  665.     format %.6g [expr log10(2.8)]
  666. } {0.447158}
  667. test expr-old-32.15 {math functions in expressions} {
  668.     format %.6g [expr pow(2.1, 3.1)]
  669. } {9.97424}
  670. test expr-old-32.16 {math functions in expressions} {
  671.     format %.6g [expr sin(.1)]
  672. } {0.0998334}
  673. test expr-old-32.17 {math functions in expressions} {
  674.     format %.6g [expr sinh(.1)]
  675. } {0.100167}
  676. test expr-old-32.18 {math functions in expressions} {
  677.     format %.6g [expr sqrt(2.0)]
  678. } {1.41421}
  679. test expr-old-32.19 {math functions in expressions} {
  680.     format %.6g [expr tan(0.8)]
  681. } {1.02964}
  682. test expr-old-32.20 {math functions in expressions} {
  683.     format %.6g [expr tanh(0.8)]
  684. } {0.664037}
  685. test expr-old-32.21 {math functions in expressions} {
  686.     format %.6g [expr abs(-1.8)]
  687. } {1.8}
  688. test expr-old-32.22 {math functions in expressions} {
  689.     expr abs(10.0)
  690. } {10.0}
  691. test expr-old-32.23 {math functions in expressions} {
  692.     format %.6g [expr abs(-4)]
  693. } {4}
  694. test expr-old-32.24 {math functions in expressions} {
  695.     format %.6g [expr abs(66)]
  696. } {66}
  697. test expr-old-32.25 {math functions in expressions} {nonPortable} {
  698.     list [catch {expr abs(0x80000000)} msg] $msg
  699. } {1 {integer value too large to represent}}
  700. test expr-old-32.26 {math functions in expressions} {
  701.     expr double(1)
  702. } {1.0}
  703. test expr-old-32.27 {math functions in expressions} {
  704.     expr double(1.1)
  705. } {1.1}
  706. test expr-old-32.28 {math functions in expressions} {
  707.     expr int(1)
  708. } {1}
  709. test expr-old-32.29 {math functions in expressions} {
  710.     expr int(1.4)
  711. } {1}
  712. test expr-old-32.30 {math functions in expressions} {
  713.     expr int(1.6)
  714. } {1}
  715. test expr-old-32.31 {math functions in expressions} {
  716.     expr int(-1.4)
  717. } {-1}
  718. test expr-old-32.32 {math functions in expressions} {
  719.     expr int(-1.6)
  720. } {-1}
  721. test expr-old-32.33 {math functions in expressions} {
  722.     list [catch {expr int(1e60)} msg] $msg
  723. } {1 {integer value too large to represent}}
  724. test expr-old-32.34 {math functions in expressions} {
  725.     list [catch {expr int(-1e60)} msg] $msg
  726. } {1 {integer value too large to represent}}
  727. test expr-old-32.35 {math functions in expressions} {
  728.     expr round(1.49)
  729. } {1}
  730. test expr-old-32.36 {math functions in expressions} {
  731.     expr round(1.51)
  732. } {2}
  733. test expr-old-32.37 {math functions in expressions} {
  734.     expr round(-1.49)
  735. } {-1}
  736. test expr-old-32.38 {math functions in expressions} {
  737.     expr round(-1.51)
  738. } {-2}
  739. test expr-old-32.39 {math functions in expressions} {
  740.     list [catch {expr round(1e60)} msg] $msg
  741. } {1 {integer value too large to represent}}
  742. test expr-old-32.40 {math functions in expressions} {
  743.     list [catch {expr round(-1e60)} msg] $msg
  744. } {1 {integer value too large to represent}}
  745. test expr-old-32.41 {math functions in expressions} {
  746.     list [catch {expr pow(1.0 + 3.0 - 2, .8 * 5)} msg] $msg
  747. } {0 16.0}
  748. test expr-old-32.42 {math functions in expressions} {
  749.     list [catch {expr hypot(5*.8,3)} msg] $msg
  750. } {0 5.0}
  751. if $gotT1 {
  752.     test expr-old-32.43 {math functions in expressions} {
  753.     expr 2*T1()
  754.     } 246
  755.     test expr-old-32.44 {math functions in expressions} {
  756.     expr T2()*3
  757.     } 1035
  758. }
  759. test expr-old-32.45 {math functions in expressions} {
  760.     expr (0 <= rand()) && (rand() < 1)
  761. } {1}
  762. test expr-old-32.46 {math functions in expressions} {
  763.     list [catch {expr rand(24)} msg] $msg
  764. } {1 {syntax error in expression "rand(24)"}}
  765. test expr-old-32.47 {math functions in expressions} {
  766.     list [catch {expr srand()} msg] $msg
  767. } {1 {syntax error in expression "srand()"}}
  768. test expr-old-32.48 {math functions in expressions} {
  769.     list [catch {expr srand(3.79)} msg] $msg
  770. } {1 {can't use floating-point value as argument to srand}}
  771. test expr-old-32.49 {math functions in expressions} {
  772.     list [catch {expr srand("")} msg] $msg
  773. } {1 {can't use non-numeric string as argument to srand}}
  774. test expr-old-32.50 {math functions in expressions} {
  775.     set result [expr round(srand(12345) * 1000)]
  776.     for {set i 0} {$i < 10} {incr i} {
  777.     lappend result [expr round(rand() * 1000)]
  778.     }
  779.     set result
  780. } {97 834 948 36 12 51 766 585 914 784 333}
  781. test expr-old-32.51 {math functions in expressions} {
  782.     list [catch {expr {srand([lindex "6ty" 0])}} msg] $msg
  783. } {1 {can't use non-numeric string as argument to srand}}
  784.  
  785. test expr-old-33.1 {conversions and fancy args to math functions} {
  786.     expr hypot ( 3 , 4 )
  787. } 5.0
  788. test expr-old-33.2 {conversions and fancy args to math functions} {
  789.     expr hypot ( (2.0+1.0) , 4 )
  790. } 5.0
  791. test expr-old-33.3 {conversions and fancy args to math functions} {
  792.     expr hypot ( 3 , (3.0 + 1.0) )
  793. } 5.0
  794. test expr-old-33.4 {conversions and fancy args to math functions} {
  795.     format %.6g [expr cos(acos(0.1))]
  796. } 0.1
  797.  
  798. test expr-old-34.1 {errors in math functions} {
  799.     list [catch {expr func_2(1.0)} msg] $msg
  800. } {1 {unknown math function "func_2"}}
  801. test expr-old-34.2 {errors in math functions} {
  802.     list [catch {expr func|(1.0)} msg] $msg
  803. } {1 {syntax error in expression "func|(1.0)"}}
  804. test expr-old-34.3 {errors in math functions} {
  805.     list [catch {expr {hypot("a b", 2.0)}} msg] $msg
  806. } {1 {argument to math function didn't have numeric value}}
  807. test expr-old-34.4 {errors in math functions} {
  808.     list [catch {expr hypot(1.0 2.0)} msg] $msg
  809. } {1 {syntax error in expression "hypot(1.0 2.0)"}}
  810. test expr-old-34.5 {errors in math functions} {
  811.     list [catch {expr hypot(1.0, 2.0} msg] $msg
  812. } {1 {syntax error in expression "hypot(1.0, 2.0"}}
  813. test expr-old-34.6 {errors in math functions} {
  814.     list [catch {expr hypot(1.0 ,} msg] $msg
  815. } {1 {syntax error in expression "hypot(1.0 ,"}}
  816. test expr-old-34.7 {errors in math functions} {
  817.     list [catch {expr hypot(1.0)} msg] $msg
  818. } {1 {too few arguments for math function}}
  819. test expr-old-34.8 {errors in math functions} {
  820.     list [catch {expr hypot(1.0, 2.0, 3.0)} msg] $msg
  821. } {1 {too many arguments for math function}}
  822. test expr-old-34.9 {errors in math functions} {
  823.     list [catch {expr acos(-2.0)} msg] $msg $errorCode
  824. } {1 {domain error: argument not in valid range} {ARITH DOMAIN {domain error: argument not in valid range}}}
  825. test expr-old-34.10 {errors in math functions} {nonPortable} {
  826.     list [catch {expr pow(-3, 1000001)} msg] $msg $errorCode
  827. } {1 {floating-point value too large to represent} {ARITH OVERFLOW {floating-point value too large to represent}}}
  828. test expr-old-34.11 {errors in math functions} {
  829.     list [catch {expr pow(3, 1000001)} msg] $msg $errorCode
  830. } {1 {floating-point value too large to represent} {ARITH OVERFLOW {floating-point value too large to represent}}}
  831. test expr-old-34.12 {errors in math functions} {
  832.     list [catch {expr -14.0*exp(100000)} msg] $msg $errorCode
  833. } {1 {floating-point value too large to represent} {ARITH OVERFLOW {floating-point value too large to represent}}}
  834. test expr-old-34.13 {errors in math functions} {
  835.     list [catch {expr int(1.0e30)} msg] $msg $errorCode
  836. } {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
  837. test expr-old-34.14 {errors in math functions} {
  838.     list [catch {expr int(-1.0e30)} msg] $msg $errorCode
  839. } {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
  840. test expr-old-34.15 {errors in math functions} {
  841.     list [catch {expr round(1.0e30)} msg] $msg $errorCode
  842. } {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
  843. test expr-old-34.16 {errors in math functions} {
  844.     list [catch {expr round(-1.0e30)} msg] $msg $errorCode
  845. } {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
  846. if $gotT1 {
  847.     test expr-old-34.17 {errors in math functions} {
  848.     list [catch {expr T1(4)} msg] $msg
  849.     } {1 {syntax error in expression "T1(4)"}}
  850. }
  851.  
  852. test expr-old-36.1 {ExprLooksLikeInt procedure} {
  853.     list [catch {expr 0289} msg] $msg
  854. } {1 {syntax error in expression "0289"}}
  855. test expr-old-36.2 {ExprLooksLikeInt procedure} {
  856.     set x 0289
  857.     list [catch {expr {$x+1}} msg] $msg
  858. } {1 {can't use non-numeric string as operand of "+"}}
  859. test expr-old-36.3 {ExprLooksLikeInt procedure} {
  860.     list [catch {expr 0289.1} msg] $msg
  861. } {0 289.1}
  862. test expr-old-36.4 {ExprLooksLikeInt procedure} {
  863.     set x 0289.1
  864.     list [catch {expr {$x+1}} msg] $msg
  865. } {0 290.1}
  866. test expr-old-36.5 {ExprLooksLikeInt procedure} {
  867.     set x {  +22}
  868.     list [catch {expr {$x+1}} msg] $msg
  869. } {0 23}
  870. test expr-old-36.6 {ExprLooksLikeInt procedure} {
  871.     set x {    -22}
  872.     list [catch {expr {$x+1}} msg] $msg
  873. } {0 -21}
  874. test expr-old-36.7 {ExprLooksLikeInt procedure} {nonPortable unixOnly} {
  875.     list [catch {expr nan} msg] $msg
  876. } {1 {domain error: argument not in valid range}}
  877. test expr-old-36.8 {ExprLooksLikeInt procedure} {
  878.     list [catch {expr 78e1} msg] $msg
  879. } {0 780.0}
  880. test expr-old-36.9 {ExprLooksLikeInt procedure} {
  881.     list [catch {expr 24E1} msg] $msg
  882. } {0 240.0}
  883. test expr-old-36.10 {ExprLooksLikeInt procedure} {nonPortable unixOnly} {
  884.     list [catch {expr 78e} msg] $msg
  885. } {1 {syntax error in expression "78e"}}
  886.  
  887. test expr-old-37.1 {Check that Tcl_ExprLong doesn't modify interpreter result if no error} {
  888.     testexprlong
  889. } {This is a result: 5}
  890.  
  891. test expr-old-38.1 {Verify Tcl_ExprString's basic operation} {
  892.     list [testexprstring "1+4"] [testexprstring "2*3+4.2"] \
  893.         [catch {testexprstring "1+"} msg] $msg
  894. } {5 10.2 1 {syntax error in expression "1+"}}
  895.  
  896.  
  897. # Special test for Pentium arithmetic bug of 1994:
  898.  
  899. if {(4195835.0 - (4195835.0/3145727.0)*3145727.0) == 256.0} {
  900.     puts "Warning: this machine contains a defective Pentium processor"
  901.     puts "that performs arithmetic incorrectly.  I recommend that you"
  902.     puts "call Intel customer service immediately at 1-800-628-8686"
  903.     puts "to request a replacement processor."
  904. }
  905.