Skip to content

Commit

Permalink
Merge 8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Jan 28, 2021
2 parents aa67292 + 080aef4 commit 5a5b02c
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 94 deletions.
2 changes: 1 addition & 1 deletion library/opt/optparse.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ proc ::tcl::OptCheckType {arg type {typeArgs ""}} {
return [expr {$arg ? 1 : 0}]
}
choice {
if {[lsearch -exact $typeArgs $arg] < 0} {
if {$arg ni $typeArgs} {
error "invalid choice"
}
return $arg
Expand Down
2 changes: 1 addition & 1 deletion library/tcltest/tcltest.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ namespace eval tcltest {

proc IsVerbose {level} {
variable Option
return [expr {[lsearch -exact $Option(-verbose) $level] >= 0}]
return [expr {$level in $Option(-verbose)}]
}

# Default verbosity is to show bodies of failed tests
Expand Down
8 changes: 4 additions & 4 deletions tests/clock.test
Original file line number Diff line number Diff line change
Expand Up @@ -35470,7 +35470,7 @@ test clock-33.5 {clock clicks tests, millisecond timing test} {
expr {
($end > $start) && (($end - $start) <= 60) ?
"ok" :
"test should have taken 0-60 ms, actually took [expr $end - $start]"}
"test should have taken 0-60 ms, actually took [expr {$end - $start}]"}
} {ok}
test clock-33.5a {clock tests, millisecond timing test} {
# This test can fail on a system that is so heavily loaded that
Expand All @@ -35486,7 +35486,7 @@ test clock-33.5a {clock tests, millisecond timing test} {
expr {
($end > $start) && (($end - $start) <= 60) ?
"ok" :
"test should have taken 0-60 ms, actually took [expr $end - $start]"}
"test should have taken 0-60 ms, actually took [expr {$end - $start}]"}
} {ok}
test clock-33.6 {clock clicks, milli with too much abbreviation} {
list [catch { clock clicks ? } msg] $msg
Expand Down Expand Up @@ -36930,10 +36930,10 @@ test clock-61.2 {overflow of a wide integer on output} {*}{
}
test clock-61.3 {near-miss overflow of a wide integer on output} {
clock format 0x7fffffffffffffff -format %s -gmt true
} [expr 0x7fffffffffffffff]
} [expr {0x7fffffffffffffff}]
test clock-61.4 {near-miss overflow of a wide integer on output} {
clock format -0x8000000000000000 -format %s -gmt true
} [expr -0x8000000000000000]
} [expr {-0x8000000000000000}]

test clock-62.1 {Bug 1902423} {*}{
-setup {::tcl::clock::ClearCaches}
Expand Down
2 changes: 1 addition & 1 deletion tests/exec.test
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ set path(sh2) [makeFile {
exit
} sh2]
set path(sleep) [makeFile {
after [expr $argv*1000]
after [expr {$argv*1000}]
exit
} sleep]
set path(exit) [makeFile {
Expand Down
2 changes: 1 addition & 1 deletion tests/fileSystem.test
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ test filesystem-1.12 {file new native path} {} {
}
}
# If we reach here we've succeeded. We used to crash above.
expr 1
expr {1}
} {1}
test filesystem-1.13 {file normalisation} {win} {
# This used to be broken
Expand Down
2 changes: 1 addition & 1 deletion tests/foreach.test
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ test foreach-4.1 {noncompiled foreach and shared variable or value list objects
catch {unset x}
foreach {12.0} {a b c} {
set x 12.0
set x [expr $x + 1]
set x [expr {$x + 1}]
}
set x
} 13.0
Expand Down
20 changes: 10 additions & 10 deletions tests/format.test
Original file line number Diff line number Diff line change
Expand Up @@ -381,20 +381,20 @@ test format-8.23 {error conditions} {
# scripts, therefore they are not documented. It's intended use is through
# the function Tcl_AppendPrintfToObj (et al).
test format-8.24 {Undocumented formats} -body {
format "%zd %td %d" [expr 2**30] [expr 2**30] [expr 2**30]
format "%zd %td %d" [expr {2**30}] [expr {2**30}] [expr {2**30}]
} -result {1073741824 1073741824 1073741824}
test format-8.25 {Undocumented formats} -constraints pointerIs64bit -body {
format "%zd %td %lld" [expr 2**33] [expr 2**33] [expr 2**33]
format "%zd %td %lld" [expr {2**33}] [expr {2**33}] [expr {2**33}]
} -result {8589934592 8589934592 8589934592}
# Since "%p" is equivalent to "%#llx" in 64-bit platforms and equivalent
# to "%#x" in 32-bit platforms, it are really not useful in scripts,
# therefore they are not documented. It's intended use is through the
# function Tcl_AppendPrintfToObj (et al).
test format-8.26 {Undocumented formats} -body {
format "%p %#x" [expr 2**31] [expr 2**31]
format "%p %#x" [expr {2**31}] [expr {2**31}]
} -result {0x80000000 0x80000000}
test format-8.27 {Undocumented formats} -constraints pointerIs64bit -body {
format "%p %#llx" [expr 2**33] [expr 2**33]
format "%p %#llx" [expr {2**33}] [expr {2**33}]
} -result {0x200000000 0x200000000}

test format-9.1 {long result} {
Expand Down Expand Up @@ -469,7 +469,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} {
Expand All @@ -480,7 +480,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} {
Expand All @@ -489,7 +489,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} {
Expand All @@ -498,7 +498,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} {
Expand All @@ -507,7 +507,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}

Expand Down Expand Up @@ -543,7 +543,7 @@ for {set i 0} {$i < 290} {incr i} {
append b $a
}
for {set i 290} {$i < 400} {incr i} {
test format-16.[expr $i -289] {testing MAX_FLOAT_SIZE} {
test format-16.[expr {$i -289}] {testing MAX_FLOAT_SIZE} {
format {%s} $b
} $b
append b "x"
Expand Down
2 changes: 1 addition & 1 deletion tests/info.test
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ test info-19.6 {info vars: Bug 1072654} -setup {

set functions {abs acos asin atan atan2 bool ceil cos cosh double entier exp floor fmod hypot int isfinite isinf isnan isnormal isqrt issubnormal isunordered log log10 max min pow rand round sin sinh sqrt srand tan tanh wide}
# Check whether the extra testing functions are defined...
if {!([catch {expr T1()} msg] && ($msg eq {invalid command name "tcl::mathfunc::T1"}))} {
if {!([catch {expr {T1()}} msg] && ($msg eq {invalid command name "tcl::mathfunc::T1"}))} {
set functions "T1 T2 T3 $functions" ;# A lazy way of prepending!
}
test info-20.1 {info functions option} {info functions sin} sin
Expand Down
36 changes: 18 additions & 18 deletions tests/io.test
Original file line number Diff line number Diff line change
Expand Up @@ -1943,35 +1943,35 @@ test io-17.1 {GetChannelTable, DeleteChannelTable on std handles} {testchannel}
eof stdin
interp create x
set l ""
lappend l [expr [testchannel refcount stdin] - $l1]
lappend l [expr {[testchannel refcount stdin] - $l1}]
x eval {eof stdin}
lappend l [expr [testchannel refcount stdin] - $l1]
lappend l [expr {[testchannel refcount stdin] - $l1}]
interp delete x
lappend l [expr [testchannel refcount stdin] - $l1]
lappend l [expr {[testchannel refcount stdin] - $l1}]
set l
} {0 1 0}
test io-17.2 {GetChannelTable, DeleteChannelTable on std handles} {testchannel} {
set l1 [testchannel refcount stdout]
eof stdin
interp create x
set l ""
lappend l [expr [testchannel refcount stdout] - $l1]
lappend l [expr {[testchannel refcount stdout] - $l1}]
x eval {eof stdout}
lappend l [expr [testchannel refcount stdout] - $l1]
lappend l [expr {[testchannel refcount stdout] - $l1}]
interp delete x
lappend l [expr [testchannel refcount stdout] - $l1]
lappend l [expr {[testchannel refcount stdout] - $l1}]
set l
} {0 1 0}
test io-17.3 {GetChannelTable, DeleteChannelTable on std handles} {testchannel} {
set l1 [testchannel refcount stderr]
eof stdin
interp create x
set l ""
lappend l [expr [testchannel refcount stderr] - $l1]
lappend l [expr {[testchannel refcount stderr] - $l1}]
x eval {eof stderr}
lappend l [expr [testchannel refcount stderr] - $l1]
lappend l [expr {[testchannel refcount stderr] - $l1}]
interp delete x
lappend l [expr [testchannel refcount stderr] - $l1]
lappend l [expr {[testchannel refcount stderr] - $l1}]
set l
} {0 1 0}

Expand Down Expand Up @@ -2161,7 +2161,7 @@ test io-26.1 {Tcl_GetChannelInstanceData} stdio {
# Don't care what pid is (but must be a number), just want to exercise it.

set f [open "|[list [interpreter] << exit]"]
expr [pid $f]
expr {[pid $f]}
close $f
} {}

Expand Down Expand Up @@ -3162,7 +3162,7 @@ test io-30.13 {Tcl_Write crlf on block boundary, Tcl_Read auto} {
set c [read $f]
close $f
string length $c
} [expr 700*15+1]
} [expr {700*15+1}]
test io-30.14 {Tcl_Write crlf on block boundary, Tcl_Read crlf} {
file delete $path(test1)
set f [open $path(test1) w]
Expand All @@ -3178,7 +3178,7 @@ test io-30.14 {Tcl_Write crlf on block boundary, Tcl_Read crlf} {
set c [read $f]
close $f
string length $c
} [expr 700*15+1]
} [expr {700*15+1}]
test io-30.15 {Tcl_Write mixed, Tcl_Read auto} {
file delete $path(test1)
set f [open $path(test1) w]
Expand Down Expand Up @@ -3996,7 +3996,7 @@ test io-31.31 {Tcl_Write crlf on block boundary, Tcl_Gets crlf} {
}
close $f
string length $c
} [expr 700*15+1]
} [expr {700*15+1}]
test io-31.32 {Tcl_Write crlf on block boundary, Tcl_Gets auto} {
file delete $path(test1)
set f [open $path(test1) w]
Expand All @@ -4015,7 +4015,7 @@ test io-31.32 {Tcl_Write crlf on block boundary, Tcl_Gets auto} {
}
close $f
string length $c
} [expr 700*15+1]
} [expr {700*15+1}]

# Test Tcl_Read and buffering.

Expand Down Expand Up @@ -5641,7 +5641,7 @@ test io-40.2 {POSIX open access modes: CREAT} {unix} {
file delete $path(test3)
set f [open $path(test3) {WRONLY CREAT} 0o600]
file stat $path(test3) stats
set x [format "%#o" [expr $stats(mode)&0o777]]
set x [format "%#o" [expr {$stats(mode)&0o777}]]
puts $f "line 1"
close $f
set f [open $path(test3) r]
Expand All @@ -5655,7 +5655,7 @@ test io-40.3 {POSIX open access modes: CREAT} {unix umask} {
set f [open $path(test3) {WRONLY CREAT}]
close $f
file stat $path(test3) stats
format 0o%03o [expr $stats(mode)&0o777]
format 0o%03o [expr {$stats(mode)&0o777}]
} [format 0o%03o [expr {0o666 & ~ $umaskValue}]]
test io-40.4 {POSIX open access modes: CREAT} {
file delete $path(test3)
Expand Down Expand Up @@ -7157,7 +7157,7 @@ test io-52.6 {TclCopyChannel} {fcopy} {
set f2 [open $path(test1) w]
fconfigure $f1 -translation lf -blocking 0
fconfigure $f2 -translation lf -blocking 0
set s0 [fcopy $f1 $f2 -size [expr [file size $thisScript] + 5]]
set s0 [fcopy $f1 $f2 -size [expr {[file size $thisScript] + 5}]]
set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]]
close $f1
close $f2
Expand Down Expand Up @@ -7653,7 +7653,7 @@ test io-53.7 {CopyData: Flooding fcopy from pipe} {stdio fcopy} {
catch {close $in}
close $out
# -1=error 0=script error N=number of bytes
expr ($fcopyTestDone == 0) ? $fcopyTestCount : -1
expr {($fcopyTestDone == 0) ? $fcopyTestCount : -1}
} {3450}
test io-53.8 {CopyData: async callback and error handling, Bug 1932639} -setup {
# copy progress callback. errors out intentionally
Expand Down
2 changes: 1 addition & 1 deletion tests/lmap.test
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ test lmap-7.2 {noncompiled lmap and shared variable or value list objects that a
} -body {
lmap {12.0} {a b c} {
set x 12.0
set x [expr $x + 1]
set x [expr {$x + 1}]
}
} -result {13.0 13.0 13.0}
# Test for incorrect "double evaluation" semantics
Expand Down
18 changes: 9 additions & 9 deletions tests/parse.test
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ test parse-6.9 {ParseTokens procedure, error in command substitution} {
} {0}
test parse-6.10 {ParseTokens procedure, incomplete sub-command} {
info complete {puts [
expr 1+1
expr {1+1}
#this is a comment ]}
} {0}
test parse-6.11 {ParseTokens procedure, memory allocation for big nested command} testparser {
Expand Down Expand Up @@ -485,7 +485,7 @@ test parse-10.3 {Tcl_EvalTokens, nested commands} testevalex {
} {8}
test parse-10.4 {Tcl_EvalTokens, nested commands} testevalex {
unset -nocomplain a
list [catch {testevalex {concat xxx[expr $a]}} msg] $msg
list [catch {testevalex {concat xxx[expr {$a}]}} msg] $msg
} {1 {can't read "a": no such variable}}
test parse-10.5 {Tcl_EvalTokens, simple variables} testevalex {
set a hello
Expand Down Expand Up @@ -518,7 +518,7 @@ test parse-10.11 {Tcl_EvalTokens, object values} testevalex {
testevalex {concat $a$a$a}
} {123123123}
test parse-10.12 {Tcl_EvalTokens, object values} testevalex {
testevalex {concat [expr 2][expr 4][expr 6]}
testevalex {concat [expr {2}][expr {4}][expr {6}]}
} {246}
test parse-10.13 {Tcl_EvalTokens, string values} testevalex {
testevalex {concat {a" b"}}
Expand Down Expand Up @@ -984,26 +984,26 @@ test parse-18.14 {Tcl_SubstObj, exception handling} {
subst {abc,[break],def}
} {abc,}
test parse-18.15 {Tcl_SubstObj, exception handling} {
subst {abc,[continue; expr 1+2],def}
subst {abc,[continue; expr {1+2}],def}
} {abc,,def}
test parse-18.16 {Tcl_SubstObj, exception handling} {
subst {abc,[return foo; expr 1+2],def}
subst {abc,[return foo; expr {1+2}],def}
} {abc,foo,def}
test parse-18.17 {Tcl_SubstObj, exception handling} {
subst {abc,[return -code 10 foo; expr 1+2],def}
subst {abc,[return -code 10 foo; expr {1+2}],def}
} {abc,foo,def}
test parse-18.18 {Tcl_SubstObj, exception handling} {
subst {abc,[break; set {} {}{}],def}
} {abc,}
test parse-18.19 {Tcl_SubstObj, exception handling} {
list [catch {subst {abc,[continue; expr 1+2; set {} {}{}],def}} msg] $msg
list [catch {subst {abc,[continue; expr {1+2}; set {} {}{}],def}} msg] $msg
} [list 1 "extra characters after close-brace"]
test parse-18.20 {Tcl_SubstObj, exception handling} {
list [catch {subst {abc,[return foo; expr 1+2; set {} {}{}],def}} msg] $msg
list [catch {subst {abc,[return foo; expr {1+2}; set {} {}{}],def}} msg] $msg
} [list 1 "extra characters after close-brace"]
test parse-18.21 {Tcl_SubstObj, exception handling} {
list [catch {
subst {abc,[return -code 10 foo; expr 1+2; set {} {}{}],def}
subst {abc,[return -code 10 foo; expr {1+2}; set {} {}{}],def}
} msg] $msg
} [list 1 "extra characters after close-brace"]

Expand Down
4 changes: 2 additions & 2 deletions tests/parseOld.test
Original file line number Diff line number Diff line change
Expand Up @@ -455,14 +455,14 @@ test parseOld-12.4 {comments} {

test parseOld-13.1 {comments at the end of a bracketed script} {
set x "[
expr 1+1
expr {1+1}
# skip this!
]"
} {2}

test parseOld-15.1 {TclScriptEnd procedure} {
info complete {puts [
expr 1+1
expr {1+1}
#this is a comment ]}
} {0}
test parseOld-15.2 {TclScriptEnd procedure} {
Expand Down
Loading

0 comments on commit 5a5b02c

Please sign in to comment.