build: Fix out-of-tree build with json ext
[jimtcl.git] / tests / expr-base.test
blob27d583e2b32b71ab88eb6f2e499d7d3877e82afd
1 source [file dirname [info script]]/testing.tcl
3 # Test number detection
4 set good_testcases {
5         0                       0
6         1                       1
7         8                       8
8         00                      0
9         07                      7
10         0x5                     5
11         0x0                     0
12         0x00            0
13         -0x5            -5
14         0b111           7
15         -0b111          -7
16         -0B101          -5
17         0o7                     7
20 set i 0
21 foreach {str exp} $good_testcases {
22         test expr-base-1.[incr i] "expr conversion" [list expr [list $str]] $exp
25 # JimTCL specifically does not adhere to the octal default for numbers starting with zero
26 test expr-base-2.1 {expr conversion jim specific} -constraints jim -body {
27     expr [list "08"]
28 } -result {8}
30 set bad_testcases {
31         {0x + 1}
32         x
33         0xx5
34         0x-5
35         {0x 5}
36         {0o8 + 1}
39 set i 0
40 foreach str $bad_testcases {
41         test expr-base-3.[incr i] "expr conversion failure" -returnCodes error -body [list expr $str] -match glob -result "*"
43 testreport