diff options
author | Steve Bennett <steveb@workware.net.au> | 2021-01-02 14:11:46 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2021-03-09 22:08:04 +1000 |
commit | 1843b79a03dde71e361ade45e577e6ef4e52cfe5 (patch) | |
tree | 9b551fe6c81d6f261b3a107a7e794f2ea5e3284f /tests/format.test | |
parent | 5fed880195c92cc4d70cd960a116d4130f1a37f4 (diff) | |
download | jimtcl-1843b79a03dde71e361ade45e577e6ef4e52cfe5.zip jimtcl-1843b79a03dde71e361ade45e577e6ef4e52cfe5.tar.gz jimtcl-1843b79a03dde71e361ade45e577e6ef4e52cfe5.tar.bz2 |
expr: TIP 526, only support a single arg
Avoid unexpected issues by concatenating multiple arguments.
This does create an incompatibility with early versions, but
it is generally trivial to convert existing code to one of two forms:
1. expr {$a + $b} -- usually correct
2. expr "$a + $b" -- usually incorrect
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests/format.test')
-rw-r--r-- | tests/format.test | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/format.test b/tests/format.test index bc3e461..8934cef 100644 --- a/tests/format.test +++ b/tests/format.test @@ -419,7 +419,7 @@ test format-13.1 {tcl_precision fuzzy comparison} { set a 0.0000000000001 set b 0.00000000000001 set c 0.00000000000000001 - set d [expr $a + $b + $c] + set d [expr {$a + $b + $c}] format {%0.10f %0.12f %0.15f %0.17f} $d $d $d $d } {0.0000000000 0.000000000000 0.000000000000110 0.00000000000011001} test format-13.2 {tcl_precision fuzzy comparison} { @@ -430,7 +430,7 @@ test format-13.2 {tcl_precision fuzzy comparison} { set a 0.000000000001 set b 0.000000000000005 set c 0.0000000000000008 - set d [expr $a + $b + $c] + set d [expr {$a + $b + $c}] format {%0.10f %0.12f %0.15f %0.17f} $d $d $d $d } {0.0000000000 0.000000000001 0.000000000001006 0.00000000000100580} test format-13.3 {tcl_precision fuzzy comparison} { @@ -439,7 +439,7 @@ test format-13.3 {tcl_precision fuzzy comparison} { catch {unset c} set a 0.00000000000099 set b 0.000000000000011 - set c [expr $a + $b] + set c [expr {$a + $b}] format {%0.10f %0.12f %0.15f %0.17f} $c $c $c $c } {0.0000000000 0.000000000001 0.000000000001001 0.00000000000100100} test format-13.4 {tcl_precision fuzzy comparison} { @@ -448,7 +448,7 @@ test format-13.4 {tcl_precision fuzzy comparison} { catch {unset c} set a 0.444444444444 set b 0.33333333333333 - set c [expr $a + $b] + set c [expr {$a + $b}] format {%0.10f %0.12f %0.15f %0.16f} $c $c $c $c } {0.7777777778 0.777777777777 0.777777777777330 0.7777777777773300} test format-13.5 {tcl_precision fuzzy comparison} { @@ -457,7 +457,7 @@ test format-13.5 {tcl_precision fuzzy comparison} { catch {unset c} set a 0.444444444444 set b 0.99999999999999 - set c [expr $a + $b] + set c [expr {$a + $b}] format {%0.10f %0.12f %0.15f} $c $c $c } {1.4444444444 1.444444444444 1.444444444443990} test format-14.1 {testing MAX_FLOAT_SIZE for 0 and 1} { @@ -486,7 +486,7 @@ for {set i 0} {$i < 290} {incr i} { append b $a } for {set i 290} {$i < 400} {incr i} { - test format-15.[expr $i -290] {testing MAX_FLOAT_SIZE} { + test format-15.[expr {$i -290}] {testing MAX_FLOAT_SIZE} { format {%s} $b } $b append b "x" |