Import Tcl-code 8.6.8

This commit is contained in:
Cheryl Sabella
2018-02-22 14:28:00 -05:00
parent 261a0e7c44
commit cc7c413b4f
509 changed files with 18473 additions and 18499 deletions

View File

@@ -11,7 +11,7 @@
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
package prefer latest
package require Tcl 8.5
package require Tcl 8.5-
package require tcltest 2.2
namespace import tcltest::*
configure {*}$argv -testdir [file dir [info script]]

View File

@@ -852,7 +852,7 @@ test assemble-8.5 {bad context} {
-body {
namespace eval assem {
set x 1
list [catch {assemble {load x}} result] $result $errorCode
list [catch {assemble {load x}} result opts] $result [dict get $opts -errorcode]
}
}
-result {1 {cannot use this instruction to create a variable in a non-proc context} {TCL ASSEM LVT}}

View File

@@ -224,6 +224,21 @@ test basic-15.1 {Tcl_CreateObjCommand, new cmd goes into a namespace specified i
list [test_ns_basic::cmd] \
[namespace delete test_ns_basic]
} {::test_ns_basic {}}
test basic-15.2 {Tcl_CreateObjCommand, Bug 0e4d88b650} -setup {
proc deleter {ns args} {
namespace delete $ns
}
namespace eval n {
proc p {} {}
}
trace add command n::p delete [list [namespace which deleter] [namespace current]::n]
} -body {
proc n::p {} {}
} -cleanup {
namespace delete n
rename deleter {}
}
test basic-16.1 {TclInvokeStringCommand} {emptyTest} {
} {}
@@ -969,6 +984,16 @@ test basic-49.2 {Tcl_EvalEx: verify TCL_EVAL_GLOBAL operation} testevalex {
set ::context
} {global}
test basic-50.1 {[586e71dce4] EvalObjv level #0 exception handling} -setup {
interp create slave
interp alias {} foo slave return
} -body {
list [catch foo m] $m
} -cleanup {
unset -nocomplain m
interp delete slave
} -result {0 {}}
# Clean up after expand tests
unset noComp l1 l2 constraints
rename l3 {}

View File

@@ -1506,6 +1506,18 @@ test binary-37.9 {GetFormatSpec: numbers} {
binary scan $x f* bla
set bla
} {1.0 -1.0 2.0 -2.0 0.0}
test binary-37.10 {GetFormatSpec: count overflow} {
binary scan x a[format %ld 0x7fffffff] r
} 0
test binary-37.11 {GetFormatSpec: count overflow} {
binary scan x a[format %ld 0x10000000] r
} 0
test binary-37.12 {GetFormatSpec: count overflow} {
binary scan x a[format %ld 0x100000000] r
} 0
test binary-37.13 {GetFormatSpec: count overflow} {
binary scan x a[format %lld 0x10000000000000000] r
} 0
test binary-38.1 {FormatNumber: word alignment} {
set x [binary format c1s1 1 1]

View File

@@ -5338,7 +5338,7 @@ test chan-io-40.2 {POSIX open access modes: CREAT} -setup {
} -constraints {unix} -body {
set f [open $path(test3) {WRONLY CREAT} 0600]
file stat $path(test3) stats
set x [format "0%o" [expr $stats(mode)&0o777]]
set x [format "%#o" [expr $stats(mode)&0o777]]
chan puts $f "line 1"
chan close $f
set f [open $path(test3) r]
@@ -5352,8 +5352,8 @@ test chan-io-40.3 {POSIX open access modes: CREAT} -setup {
# This test only works if your umask is 2, like ouster's.
chan close [open $path(test3) {WRONLY CREAT}]
file stat $path(test3) stats
format "0%o" [expr $stats(mode)&0o777]
} -result [format %04o [expr {0o666 & ~ $umaskValue}]]
format "%#o" [expr $stats(mode)&0o777]
} -result [format %#4o [expr {0o666 & ~ $umaskValue}]]
test chan-io-40.4 {POSIX open access modes: CREAT} -setup {
file delete $path(test3)
} -body {
@@ -6775,7 +6775,7 @@ test chan-io-52.10 {TclCopyChannel & encodings} {fcopy} {
} 5
test chan-io-52.11 {TclCopyChannel & encodings} -setup {
set f [open $path(utf8-fcopy.txt) w]
fconfigure $f -encoding utf-8
fconfigure $f -encoding utf-8 -translation lf
puts $f "\u0410\u0410"
close $f
} -constraints {fcopy} -body {

View File

@@ -35,9 +35,9 @@ testConstraint y2038 \
# TEST PLAN
# clock-1:
# [clock format] - tests of bad and empty arguments
# [clock format] - tests of bad and empty arguments
#
# clock-2
# clock-2
# formatting of year, month and day of month
#
# clock-3
@@ -195,7 +195,7 @@ namespace eval ::tcl::clock {
l li lii liii liv lv lvi lvii lviii lix
lx lxi lxii lxiii lxiv lxv lxvi lxvii lxviii lxix
lxx lxxi lxxii lxxiii lxxiv lxxv lxxvi lxxvii lxxviii lxxix
lxxx lxxxi lxxxii lxxxiii lxxxiv lxxxv lxxxvi lxxxvii lxxxviii
lxxx lxxxi lxxxii lxxxiii lxxxiv lxxxv lxxxvi lxxxvii lxxxviii
lxxxix
xc xci xcii xciii xciv xcv xcvi xcvii xcviii xcix
c
@@ -271,7 +271,7 @@ test clock-1.3 "clock format - empty val" {
test clock-1.4 "clock format - bad flag" {*}{
-body {
list [catch {clock format 0 -oops badflag} msg] $msg $::errorCode
}
}
-match glob
-result {1 {bad option "-oops": must be -format, -gmt, -locale, or -timezone} {CLOCK badOption -oops}}
}
@@ -15416,30 +15416,9 @@ test clock-5.29 {time zone boundary case 1948-09-26 01:00:01} detroit {
clock format -671047199 -format {%H:%M:%S %z %Z} \
-timezone :America/Detroit
} {01:00:01 -0500 EST}
test clock-5.30 {time zone boundary case 1967-06-14 01:59:59} detroit {
clock format -80499601 -format {%H:%M:%S %z %Z} \
-timezone :America/Detroit
} {01:59:59 -0500 EST}
test clock-5.31 {time zone boundary case 1967-06-14 03:00:00} detroit {
clock format -80499600 -format {%H:%M:%S %z %Z} \
-timezone :America/Detroit
} {03:00:00 -0400 EDT}
test clock-5.32 {time zone boundary case 1967-06-14 03:00:01} detroit {
clock format -80499599 -format {%H:%M:%S %z %Z} \
-timezone :America/Detroit
} {03:00:01 -0400 EDT}
test clock-5.33 {time zone boundary case 1967-10-29 01:59:59} detroit {
clock format -68666401 -format {%H:%M:%S %z %Z} \
-timezone :America/Detroit
} {01:59:59 -0400 EDT}
test clock-5.34 {time zone boundary case 1967-10-29 01:00:00} detroit {
clock format -68666400 -format {%H:%M:%S %z %Z} \
-timezone :America/Detroit
} {01:00:00 -0500 EST}
test clock-5.35 {time zone boundary case 1967-10-29 01:00:01} detroit {
clock format -68666399 -format {%H:%M:%S %z %Z} \
-timezone :America/Detroit
} {01:00:01 -0500 EST}
# Detroit did not observe Daylight Saving Time in 1967
test clock-5.36 {time zone boundary case 1972-12-31 23:59:59} detroit {
clock format 94712399 -format {%H:%M:%S %z %Z} \
-timezone :America/Detroit
@@ -35221,7 +35200,7 @@ test clock-30.25 {clock add seconds at DST conversion} {
test clock-31.1 {system locale} \
-constraints win \
-setup {
-setup {
namespace eval ::tcl::clock {
namespace import -force ::testClock::registry
}
@@ -35244,7 +35223,7 @@ test clock-31.1 {system locale} \
test clock-31.2 {system locale} \
-constraints win \
-setup {
-setup {
namespace eval ::tcl::clock {
namespace import -force ::testClock::registry
}
@@ -35267,7 +35246,7 @@ test clock-31.2 {system locale} \
test clock-31.3 {system locale} \
-constraints win \
-setup {
-setup {
namespace eval ::tcl::clock {
namespace import -force ::testClock::registry
}
@@ -35290,7 +35269,7 @@ test clock-31.3 {system locale} \
test clock-31.4 {system locale} \
-constraints win \
-setup {
-setup {
namespace eval ::tcl::clock {
namespace import -force ::testClock::registry
}
@@ -35327,7 +35306,7 @@ test clock-31.4 {system locale} \
test clock-31.5 {system locale} \
-constraints win \
-setup {
-setup {
namespace eval ::tcl::clock {
namespace import -force ::testClock::registry
}
@@ -35364,7 +35343,7 @@ test clock-31.5 {system locale} \
test clock-31.6 {system locale} \
-constraints win \
-setup {
-setup {
namespace eval ::tcl::clock {
namespace import -force ::testClock::registry
}
@@ -35434,7 +35413,7 @@ test clock-32.1 {scan/format across the Gregorian change} {
}
set problems
} {}
# Legacy tests
# clock clicks
@@ -35468,7 +35447,7 @@ test clock-33.5 {clock clicks tests, millisecond timing test} {
# 60 msecs seems to be the max time slice under Windows 95/98
expr {
($end > $start) && (($end - $start) <= 60) ?
"ok" :
"ok" :
"test should have taken 0-60 ms, actually took [expr $end - $start]"}
} {ok}
test clock-33.5a {clock tests, millisecond timing test} {
@@ -35480,7 +35459,7 @@ test clock-33.5a {clock tests, millisecond timing test} {
# 60 msecs seems to be the max time slice under Windows 95/98
expr {
($end > $start) && (($end - $start) <= 60) ?
"ok" :
"ok" :
"test should have taken 0-60 ms, actually took [expr $end - $start]"}
} {ok}
test clock-33.6 {clock clicks, milli with too much abbreviation} {
@@ -35804,31 +35783,31 @@ test clock-34.47 {ago with multiple relative units} {
} 180000
test clock-34.48 {more than one ToD} {*}{
-body {clock scan {10:00 11:00}}
-body {clock scan {10:00 11:00}}
-returnCodes error
-result {unable to convert date-time string "10:00 11:00": more than one time of day in string}
}
test clock-34.49 {more than one date} {*}{
-body {clock scan {1/1/2001 2/2/2002}}
-body {clock scan {1/1/2001 2/2/2002}}
-returnCodes error
-result {unable to convert date-time string "1/1/2001 2/2/2002": more than one date in string}
}
test clock-34.50 {more than one time zone} {*}{
-body {clock scan {10:00 EST CST}}
-body {clock scan {10:00 EST CST}}
-returnCodes error
-result {unable to convert date-time string "10:00 EST CST": more than one time zone in string}
}
test clock-34.51 {more than one weekday} {*}{
-body {clock scan {Monday Tuesday}}
-body {clock scan {Monday Tuesday}}
-returnCodes error
-result {unable to convert date-time string "Monday Tuesday": more than one weekday in string}
}
test clock-34.52 {more than one ordinal month} {*}{
-body {clock scan {next January next March}}
-body {clock scan {next January next March}}
-returnCodes error
-result {unable to convert date-time string "next January next March": more than one ordinal month in string}
}
@@ -35924,7 +35903,7 @@ test clock-38.2 {make sure TZ is not cached after unset} \
}
} \
-result 1
test clock-39.1 {regression - synonym timezones} {
clock format 0 -format {%H:%M:%S} -timezone :US/Eastern
@@ -35996,7 +35975,7 @@ test clock-44.1 {regression test - time zone name containing hyphen } \
}
} \
-result {12:34:56-0500}
test clock-45.1 {regression test - time zone containing only two digits} \
-body {
clock scan 1985-04-12T10:15:30+04 -format %Y-%m-%dT%H:%M:%S%Z
@@ -36041,7 +36020,7 @@ test clock-48.1 {Bug 1185933: 'i' destroyed by clock init} -setup {
test clock-49.1 {regression test - localtime with negative arg (Bug 1237907)} \
-body {
list [catch {
list [catch {
clock format -86400 -timezone :localtime -format %Y
} result] $result
} \
@@ -36280,7 +36259,7 @@ test clock-56.1 {use of zoneinfo, version 1} {*}{
}
-result {2004-01-01 00:00:00 MST}
}
test clock-56.2 {use of zoneinfo, version 2} {*}{
-setup {
clock format [clock seconds]
@@ -36330,7 +36309,7 @@ test clock-56.2 {use of zoneinfo, version 2} {*}{
removeFile PhoenixTwo $tzdir2
removeDirectory Test $tzdir
removeDirectory zoneinfo
}
}
-body {
clock format 1072940400 -timezone :Test/PhoenixTwo \
-format {%Y-%m-%d %H:%M:%S %Z}
@@ -36540,7 +36519,7 @@ test clock-56.3 {use of zoneinfo, version 2, Y2038 compliance} {*}{
removeFile TijuanaTwo $tzdir2
removeDirectory Test $tzdir
removeDirectory zoneinfo
}
}
-body {
clock format 2224738800 -timezone :Test/TijuanaTwo \
-format {%Y-%m-%d %H:%M:%S %Z}
@@ -36692,7 +36671,7 @@ test clock-56.4 {Bug 3470928} {*}{
removeFile Windhoek $tzdir2
removeDirectory Test $tzdir
removeDirectory zoneinfo
}
}
-result {Sun Jan 08 22:30:06 WAST 2012}
}
@@ -36703,7 +36682,7 @@ test clock-57.1 {clock scan - abbreviated options} {
test clock-58.1 {clock l10n - Japanese localisation} {*}{
-setup {
proc backslashify { string } {
set retval {}
foreach char [split $string {}] {
scan $char %c ccode
@@ -36809,52 +36788,52 @@ test clock-59.1 {military time zones} {
test clock-60.1 {case insensitive weekday names} {
clock scan "2000-W01 monday" -gmt true -format "%G-W%V %a"
} [clock scan "2000-W01-1" -gmt true -format "%G-W%V-%u"]
} [clock scan "2000-W01-1" -gmt true -format "%G-W%V-%u"]
test clock-60.2 {case insensitive weekday names} {
clock scan "2000-W01 Monday" -gmt true -format "%G-W%V %a"
} [clock scan "2000-W01-1" -gmt true -format "%G-W%V-%u"]
} [clock scan "2000-W01-1" -gmt true -format "%G-W%V-%u"]
test clock-60.3 {case insensitive weekday names} {
clock scan "2000-W01 MONDAY" -gmt true -format "%G-W%V %a"
} [clock scan "2000-W01-1" -gmt true -format "%G-W%V-%u"]
} [clock scan "2000-W01-1" -gmt true -format "%G-W%V-%u"]
test clock-60.4 {case insensitive weekday names} {
clock scan "2000-W01 friday" -gmt true -format "%G-W%V %a"
} [clock scan "2000-W01-5" -gmt true -format "%G-W%V-%u"]
} [clock scan "2000-W01-5" -gmt true -format "%G-W%V-%u"]
test clock-60.5 {case insensitive weekday names} {
clock scan "2000-W01 Friday" -gmt true -format "%G-W%V %a"
} [clock scan "2000-W01-5" -gmt true -format "%G-W%V-%u"]
} [clock scan "2000-W01-5" -gmt true -format "%G-W%V-%u"]
test clock-60.6 {case insensitive weekday names} {
clock scan "2000-W01 FRIDAY" -gmt true -format "%G-W%V %a"
} [clock scan "2000-W01-5" -gmt true -format "%G-W%V-%u"]
} [clock scan "2000-W01-5" -gmt true -format "%G-W%V-%u"]
test clock-60.7 {case insensitive month names} {
clock scan "1 january 2000" -gmt true -format "%d %b %Y"
} [clock scan "2000-01-01" -gmt true -format "%Y-%m-%d"]
} [clock scan "2000-01-01" -gmt true -format "%Y-%m-%d"]
test clock-60.8 {case insensitive month names} {
clock scan "1 January 2000" -gmt true -format "%d %b %Y"
} [clock scan "2000-01-01" -gmt true -format "%Y-%m-%d"]
} [clock scan "2000-01-01" -gmt true -format "%Y-%m-%d"]
test clock-60.9 {case insensitive month names} {
clock scan "1 JANUARY 2000" -gmt true -format "%d %b %Y"
} [clock scan "2000-01-01" -gmt true -format "%Y-%m-%d"]
} [clock scan "2000-01-01" -gmt true -format "%Y-%m-%d"]
test clock-60.10 {case insensitive month names} {
clock scan "1 december 2000" -gmt true -format "%d %b %Y"
} [clock scan "2000-12-01" -gmt true -format "%Y-%m-%d"]
} [clock scan "2000-12-01" -gmt true -format "%Y-%m-%d"]
test clock-60.11 {case insensitive month names} {
clock scan "1 December 2000" -gmt true -format "%d %b %Y"
} [clock scan "2000-12-01" -gmt true -format "%Y-%m-%d"]
} [clock scan "2000-12-01" -gmt true -format "%Y-%m-%d"]
test clock-60.12 {case insensitive month names} {
clock scan "1 DECEMBER 2000" -gmt true -format "%d %b %Y"
} [clock scan "2000-12-01" -gmt true -format "%Y-%m-%d"]
} [clock scan "2000-12-01" -gmt true -format "%Y-%m-%d"]
test clock-61.1 {overflow of a wide integer on output} {*}{
-body {
clock format 0x8000000000000000 -format %s -gmt true
}
}
-result {integer value too large to represent}
-returnCodes error
}
test clock-61.2 {overflow of a wide integer on output} {*}{
-body {
clock format -0x8000000000000001 -format %s -gmt true
}
}
-result {integer value too large to represent}
-returnCodes error
}
@@ -36954,10 +36933,10 @@ test clock-67.5 {Change scan %x output on global locale change [Bug 4a0c163d24]}
set current [msgcat::mclocale]
} -body {
msgcat::mclocale de_de
set res [clock scan "01.01.1970" -locale current -format %x]
set res [clock scan "01.01.1970" -locale current -format %x -gmt 1]
msgcat::mclocale en_uk
# This will fail without the bug fix, as still de_de is active
expr {$res == [clock scan "01/01/1970" -locale current -format %x]}
expr {$res == [clock scan "01/01/1970" -locale current -format %x -gmt 1]}
} -cleanup {
msgcat::mclocale $current
} -result {1}

View File

@@ -167,10 +167,10 @@ test cmdAH-3.2 {Tcl_ContinueObjCmd, success} {
test cmdAH-4.1 {Tcl_EncodingObjCmd} -returnCodes error -body {
encoding
} -result {wrong # args: should be "encoding option ?arg ...?"}
} -result {wrong # args: should be "encoding subcommand ?arg ...?"}
test cmdAH-4.2 {Tcl_EncodingObjCmd} -returnCodes error -body {
encoding foo
} -result {bad option "foo": must be convertfrom, convertto, dirs, names, or system}
} -result {unknown or ambiguous subcommand "foo": must be convertfrom, convertto, dirs, names, or system}
test cmdAH-4.3 {Tcl_EncodingObjCmd} -returnCodes error -body {
encoding convertto
} -result {wrong # args: should be "encoding convertto ?encoding? data"}
@@ -188,7 +188,7 @@ test cmdAH-4.5 {Tcl_EncodingObjCmd} -setup {
test cmdAH-4.6 {Tcl_EncodingObjCmd} -setup {
set system [encoding system]
} -body {
encoding system identity
encoding system iso8859-1
encoding convertto jis0208 \u4e4e
} -cleanup {
encoding system $system
@@ -210,7 +210,7 @@ test cmdAH-4.9 {Tcl_EncodingObjCmd} -setup {
test cmdAH-4.10 {Tcl_EncodingObjCmd} -setup {
set system [encoding system]
} -body {
encoding system identity
encoding system iso8859-1
encoding convertfrom jis0208 8C
} -cleanup {
encoding system $system
@@ -224,11 +224,11 @@ test cmdAH-4.12 {Tcl_EncodingObjCmd} -returnCodes error -body {
test cmdAH-4.13 {Tcl_EncodingObjCmd} -setup {
set system [encoding system]
} -body {
encoding system identity
encoding system iso8859-1
encoding system
} -cleanup {
encoding system $system
} -result identity
} -result iso8859-1
test cmdAH-5.1 {Tcl_FileObjCmd} -returnCodes error -body {
file

View File

@@ -741,6 +741,45 @@ test coroutine-7.12 {coro floor above street level #3008307} -body {
list
} -result {}
test coroutine-8.0.0 {coro inject executed} -body {
coroutine demo apply {{} { foreach i {1 2} yield }}
demo
set ::result none
tcl::unsupported::inject demo set ::result inject-executed
demo
set ::result
} -result {inject-executed}
test coroutine-8.0.1 {coro inject after error} -body {
coroutine demo apply {{} { foreach i {1 2} yield; error test }}
demo
set ::result none
tcl::unsupported::inject demo set ::result inject-executed
lappend ::result [catch {demo} err] $err
} -result {inject-executed 1 test}
test coroutine-8.1.1 {coro inject, ticket 42202ba1e5ff566e} -body {
interp create slave
slave eval {
coroutine demo apply {{} { while {1} yield }}
demo
tcl::unsupported::inject demo set ::result inject-executed
}
interp delete slave
} -result {}
test coroutine-8.1.2 {coro inject with result, ticket 42202ba1e5ff566e} -body {
interp create slave
slave eval {
coroutine demo apply {{} { while {1} yield }}
demo
tcl::unsupported::inject demo set ::result inject-executed
}
slave eval demo
set result [slave eval {set ::result}]
interp delete slave
set result
} -result {inject-executed}
# cleanup
unset lambda

View File

@@ -34,6 +34,7 @@ proc runtests {} {
# Some tests require the testencoding command
testConstraint testencoding [llength [info commands testencoding]]
testConstraint fullutf [expr {[format %c 0x010000] != "\ufffd"}]
testConstraint exec [llength [info commands exec]]
testConstraint testgetdefenc [llength [info commands testgetdefenc]]
@@ -73,12 +74,12 @@ test encoding-2.2 {Tcl_FreeEncoding: refcount != 0} -setup {
} -constraints {testencoding} -body {
encoding system shiftjis ;# incr ref count
encoding dirs [list [pwd]]
set x [encoding convertto shiftjis \u4e4e] ;# old one found
encoding system identity
set x [encoding convertto shiftjis \u4e4e] ;# old one found
encoding system iso8859-1
llength shiftjis ;# Shimmer away any cache of Tcl_Encoding
lappend x [catch {encoding convertto shiftjis \u4e4e} msg] $msg
} -cleanup {
encoding system identity
encoding system iso8859-1
encoding dirs $path
encoding system $system
} -result "\u008c\u00c1 1 {unknown encoding \"shiftjis\"}"
@@ -135,7 +136,7 @@ test encoding-5.1 {Tcl_SetSystemEncoding} -setup {
encoding system jis0208
encoding convertto \u4e4e
} -cleanup {
encoding system identity
encoding system iso8859-1
encoding system $old
} -result {8C}
test encoding-5.2 {Tcl_SetSystemEncoding: test ref count} {
@@ -182,7 +183,7 @@ test encoding-8.1 {Tcl_ExternalToUtf} {
puts -nonewline $f "ab\x8c\xc1g"
close $f
set f [open [file join [temporaryDirectory] dummy] r]
fconfigure $f -translation binary -encoding shiftjis
fconfigure $f -translation binary -encoding shiftjis
set x [read $f]
close $f
file delete [file join [temporaryDirectory] dummy]
@@ -258,14 +259,14 @@ test encoding-11.5.1 {LoadEncodingFile: escape file} {
test encoding-11.6 {LoadEncodingFile: invalid file} -constraints {testencoding} -setup {
set system [encoding system]
set path [encoding dirs]
encoding system identity
encoding system iso8859-1
} -body {
cd [temporaryDirectory]
encoding dirs [file join tmp encoding]
makeDirectory tmp
makeDirectory [file join tmp encoding]
set f [open [file join tmp encoding splat.enc] w]
fconfigure $f -translation binary
fconfigure $f -translation binary
puts $f "abcdefghijklmnop"
close $f
encoding convertto splat \u4e4e
@@ -286,11 +287,11 @@ test encoding-12.1 {LoadTableEncoding: normal encoding} {
append x [encoding convertfrom iso8859-3 \xd5]
} "\xd5?\u120"
test encoding-12.2 {LoadTableEncoding: single-byte encoding} {
set x [encoding convertto iso8859-3 ab\u0120g]
set x [encoding convertto iso8859-3 ab\u0120g]
append x [encoding convertfrom iso8859-3 ab\xd5g]
} "ab\xd5gab\u120g"
test encoding-12.3 {LoadTableEncoding: multi-byte encoding} {
set x [encoding convertto shiftjis ab\u4e4eg]
set x [encoding convertto shiftjis ab\u4e4eg]
append x [encoding convertfrom shiftjis ab\x8c\xc1g]
} "ab\x8c\xc1gab\u4e4eg"
test encoding-12.4 {LoadTableEncoding: double-byte encoding} {
@@ -332,9 +333,14 @@ test encoding-16.1 {UnicodeToUtfProc} {
set val [encoding convertfrom unicode NN]
list $val [format %x [scan $val %c]]
} "\u4e4e 4e4e"
test encoding-16.2 {UnicodeToUtfProc} -constraints fullutf -body {
set val [encoding convertfrom unicode "\xd8\xd8\xdc\xdc"]
list $val [format %x [scan $val %c]]
} -result "\U460dc 460dc"
test encoding-17.1 {UtfToUnicodeProc} {
} {}
test encoding-17.1 {UtfToUnicodeProc} -constraints fullutf -body {
encoding convertto unicode "\U460dc"
} -result "\xd8\xd8\xdc\xdc"
test encoding-18.1 {TableToUtfProc} {
} {}
@@ -448,6 +454,31 @@ test encoding-24.3 {EscapeFreeProc on open channels} {stdio} {
list $count [viewable $line]
} [list 3 "\u4e4e\u4e5e\u4e5f (\\u4e4e\\u4e5e\\u4e5f)"]
test encoding-24.4 {Parse valid or invalid utf-8} {
string length [encoding convertfrom utf-8 "\xc0\x80"]
} 1
test encoding-24.5 {Parse valid or invalid utf-8} {
string length [encoding convertfrom utf-8 "\xc0\x81"]
} 2
test encoding-24.6 {Parse valid or invalid utf-8} {
string length [encoding convertfrom utf-8 "\xc1\xbf"]
} 2
test encoding-24.7 {Parse valid or invalid utf-8} {
string length [encoding convertfrom utf-8 "\xc2\x80"]
} 1
test encoding-24.8 {Parse valid or invalid utf-8} {
string length [encoding convertfrom utf-8 "\xe0\x80\x80"]
} 3
test encoding-24.9 {Parse valid or invalid utf-8} {
string length [encoding convertfrom utf-8 "\xe0\x9f\xbf"]
} 3
test encoding-24.10 {Parse valid or invalid utf-8} {
string length [encoding convertfrom utf-8 "\xe0\xa0\x80"]
} 1
test encoding-24.11 {Parse valid or invalid utf-8} {
string length [encoding convertfrom utf-8 "\xef\xbf\xbf"]
} 1
file delete [file join [temporaryDirectory] iso2022.txt]
#

View File

@@ -670,9 +670,13 @@ test exec-19.1 {exec >> uses O_APPEND} -constraints {exec unix} -setup {
# file, which is why the result is 14 and not 12
exec /bin/sh -c \
{for a in 1 2 3; do sleep 1; echo $a; done} >>$tmpfile &
exec /bin/sh -c \
{for a in 4 5 6; do sleep 1; echo $a >&2; done} 2>>$tmpfile &
exec /bin/sh -c \
{for a in a b c; do sleep 1; echo $a; done} >>$tmpfile &
# The above two shell invokations take about 3 seconds to finish, so allow
exec /bin/sh -c \
{for a in d e f; do sleep 1; echo $a >&2; done} 2>>$tmpfile &
# The above four shell invokations take about 3 seconds to finish, so allow
# 5s (in case the machine is busy)
after 5000
# Check that no bytes have got lost through mixups with overlapping
@@ -681,7 +685,7 @@ test exec-19.1 {exec >> uses O_APPEND} -constraints {exec unix} -setup {
file size $tmpfile
} -cleanup {
removeFile $tmpfile
} -result 14
} -result 26
# Tests to ensure batch files and .CMD (Bug 9ece99d58b)
# can be executed on Windows

View File

@@ -724,7 +724,7 @@ test execute-6.14 {Tcl_ExprObj: exprcode context validation} -setup {
}
set result {}
lappend result [expr $e]
lappend result [namespace eval foo {expr $e}]
lappend result [namespace eval foo [list expr $e]]
} -cleanup {
namespace delete foo
} -result {1 2}
@@ -733,11 +733,11 @@ test execute-6.15 {Tcl_ExprObj: exprcode name resolution epoch validation} -setu
} -body {
set e { [llength {}]+1 }
set result {}
lappend result [namespace eval foo {expr $e}]
lappend result [namespace eval foo [list expr $e]]
namespace eval foo {
proc llength {args} {return 1}
}
lappend result [namespace eval foo {expr $e}]
lappend result [namespace eval foo [list expr $e]]
} -cleanup {
namespace delete foo
} -result {1 2}

View File

@@ -910,6 +910,15 @@ test expr-22.9 {non-numeric floats: shared object equality and NaN} {
set x NaN
expr {$x == $x}
} 0
# Make sure [Bug d0f7ba56f0] stays fixed.
test expr-22.10 {non-numeric arguments: equality and NaN} {
set x NaN
expr {$x > "Gran"}
} 1
test expr-22.11 {non-numeric arguments: equality and NaN} {
set x NaN
expr {"Gran" < $x}
} 1
# Tests for exponentiation handling
test expr-23.1 {CompileExponentialExpr: just exponential expr} {expr 4**2} 16

View File

@@ -441,6 +441,9 @@ test filename-7.18 {Tcl_JoinPath: unix} {testsetplatform} {
testsetplatform unix
file join /// a b
} "/a/b"
test filename-7.19 {[Bug f34cf83dd0]} {
file join foo //bar
} /bar
test filename-9.1 {Tcl_JoinPath: win} {testsetplatform} {
testsetplatform win

View File

@@ -367,6 +367,32 @@ test filesystem-1.51 {file normalisation .. beyond root (Bug 1379287)} {
test filesystem-1.51.1 {file normalisation .. beyond root (Bug 1379287)} {
testPathEqual [file norm /../../] [file norm /]
} ok
test filesystem-1.52 {bug f9f390d0fa: file join where strep is not canonical} -constraints unix -body {
set x //foo
file normalize $x
file join $x bar
} -result /foo/bar
test filesystem-1.52.1 {bug f9f390d0fa: file join where strep is not canonical} -body {
set x //foo
file normalize $x
file join $x
} -result /foo
test filesystem-1.53 {[Bug 3559678] - normalize when tail is empty} {
string match */ [file normalize [lindex [glob -dir [pwd] {{}}] 0]]
} 0
test filesystem-1.54 {[Bug ce3a211dcb] - normalize when tail is empty} -setup {
set save [pwd]
cd [set home [makeDirectory ce3a211dcb]]
makeDirectory A $home
cd [lindex [glob */] 0]
} -body {
string match */A [pwd]
} -cleanup {
cd $home
removeDirectory A $home
cd $save
removeDirectory ce3a211dcb
} -result 1
test filesystem-2.0 {new native path} {unix} {
foreach f [lsort [glob -nocomplain /usr/bin/c*]] {

View File

@@ -52,32 +52,51 @@ test format-1.7.1 {integer formatting} longIs64bit {
format "%4x %4x %4x %4x" 6 34 16923 -12 -1
} { 6 22 421b fffffffffffffff4}
test format-1.8 {integer formatting} longIs32bit {
format "%#x %#X %#X %#x" 6 34 16923 -12 -1
} {0x6 0X22 0X421B 0xfffffff4}
format "%#x %#x %#X %#X %#x" 0 6 34 16923 -12 -1
} {0x0 0x6 0X22 0X421B 0xfffffff4}
test format-1.8.1 {integer formatting} longIs64bit {
format "%#x %#X %#X %#x" 6 34 16923 -12 -1
} {0x6 0X22 0X421B 0xfffffffffffffff4}
format "%#x %#x %#X %#X %#x" 0 6 34 16923 -12 -1
} {0x0 0x6 0X22 0X421B 0xfffffffffffffff4}
test format-1.9 {integer formatting} longIs32bit {
format "%#20x %#20x %#20x %#20x" 6 34 16923 -12 -1
} { 0x6 0x22 0x421b 0xfffffff4}
format "%#5x %#20x %#20x %#20x %#20x" 0 6 34 16923 -12 -1
} { 0x0 0x6 0x22 0x421b 0xfffffff4}
test format-1.9.1 {integer formatting} longIs64bit {
format "%#20x %#20x %#20x %#20x" 6 34 16923 -12 -1
} { 0x6 0x22 0x421b 0xfffffffffffffff4}
format "%#5x %#20x %#20x %#20x %#20x" 0 6 34 16923 -12 -1
} { 0x0 0x6 0x22 0x421b 0xfffffffffffffff4}
test format-1.10 {integer formatting} longIs32bit {
format "%-#20x %-#20x %-#20x %-#20x" 6 34 16923 -12 -1
} {0x6 0x22 0x421b 0xfffffff4 }
format "%-#5x %-#20x %-#20x %-#20x %-#20x" 0 6 34 16923 -12 -1
} {0x0 0x6 0x22 0x421b 0xfffffff4 }
test format-1.10.1 {integer formatting} longIs64bit {
format "%-#20x %-#20x %-#20x %-#20x" 6 34 16923 -12 -1
} {0x6 0x22 0x421b 0xfffffffffffffff4 }
format "%-#5x %-#20x %-#20x %-#20x %-#20x" 0 6 34 16923 -12 -1
} {0x0 0x6 0x22 0x421b 0xfffffffffffffff4 }
test format-1.11 {integer formatting} longIs32bit {
format "%-#20o %#-20o %#-20o %#-20o" 6 34 16923 -12 -1
} {06 042 041033 037777777764 }
format "%-#5o %-#20o %#-20o %#-20o %#-20o" 0 6 34 16923 -12 -1
} {0 06 042 041033 037777777764 }
test format-1.11.1 {integer formatting} longIs64bit {
format "%-#20o %#-20o %#-20o %#-20o" 6 34 16923 -12 -1
} {06 042 041033 01777777777777777777764}
format "%-#5o %-#20o %#-20o %#-20o %#-20o" 0 6 34 16923 -12 -1
} {0 06 042 041033 01777777777777777777764}
test format-1.12 {integer formatting} {
format "%b %#b %llb" 5 5 [expr {2**100}]
} {101 0b101 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000}
format "%b %#b %#b %llb" 5 0 5 [expr {2**100}]
} {101 0b0 0b101 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000}
test format-1.13 {integer formatting} longIs32bit {
format "%#d %#d %#d %#d %#d" 0 6 34 16923 -12 -1
} {0 6 34 16923 -12}
test format-1.13.1 {integer formatting} longIs64bit {
format "%#d %#d %#d %#d %#d" 0 6 34 16923 -12 -1
} {0 6 34 16923 -12}
test format-1.14 {integer formatting} longIs32bit {
format "%#5d %#20d %#20d %#20d %#20d" 0 6 34 16923 -12 -1
} { 0 6 34 16923 -12}
test format-1.14.1 {integer formatting} longIs64bit {
format "%#5d %#20d %#20d %#20d %#20d" 0 6 34 16923 -12 -1
} { 0 6 34 16923 -12}
test format-1.15 {integer formatting} longIs32bit {
format "%-#5d %-#20d %-#20d %-#20d %-#20d" 0 6 34 16923 -12 -1
} {0 6 34 16923 -12 }
test format-1.15.1 {integer formatting} longIs64bit {
format "%-#5d %-#20d %-#20d %-#20d %-#20d" 0 6 34 16923 -12 -1
} {0 6 34 16923 -12 }
test format-2.1 {string formatting} {
format "%s %s %c %s" abcd {This is a very long test string.} 120 x
@@ -528,6 +547,12 @@ test format-17.3 {testing %ld with non-wide} {wideIs64bit} {
test format-17.4 {testing %l with non-integer} {
format %lf 1
} 1.000000
test format-17.5 {testing %llu with positive bignum} -body {
format %llu 0xabcdef0123456789abcdef
} -returnCodes 1 -result {unsigned bignum format is invalid}
test format-17.6 {testing %llu with negative number} -body {
format %llu -1
} -returnCodes 1 -result {unsigned bignum format is invalid}
test format-18.1 {do not demote existing numeric values} {
set a 0xaaaaaaaa
@@ -564,9 +589,12 @@ test format-19.3 {Bug 2830354} {
test format-20.1 {Bug 2932421: plain %s caused intrep change of args} -body {
set x [dict create a b c d]
format %s $x
# After this, obj in $x should be a dict with a non-NULL bytes field
# After this, obj in $x should be a dict
# We are testing to make sure it has not been shimmered to a
# different intrep when that is not necessary.
# Whether or not there is a string rep - we should not care!
tcl::unsupported::representation $x
} -match glob -result {value is a dict with *, string representation "*"}
} -match glob -result {value is a dict *}
# cleanup
catch {unset a}

View File

@@ -19,9 +19,10 @@ if {[lsearch [namespace children] ::tcltest] == -1} {
catch [list package require -exact Tcltest [info patchlevel]]
testConstraint testgetint [llength [info commands testgetint]]
testConstraint testdoubleobj [llength [info commands testdoubleobj]]
testConstraint longIs32bit [expr {int(0x80000000) < 0}]
testConstraint longIs64bit [expr {int(0x8000000000000000) < 0}]
test get-1.1 {Tcl_GetInt procedure} testgetint {
testgetint 44 { 22}
} {66}
@@ -95,7 +96,24 @@ test get-3.2 {Tcl_GetDouble(FromObj), bad numbers} {
}
set result
} {0 1 0 1 1 {expected floating-point number but got "++1.0"} 1 {expected floating-point number but got "+-1.0"} 1 {expected floating-point number but got "-+1.0"} 0 -1 1 {expected floating-point number but got "--1.0"} 1 {expected floating-point number but got "- +1.0"}}
# Bug 7114ac6141
test get-3.3 {tcl_GetInt with iffy numbers} testgetint {
lmap x {0 " 0" "0 " " 0 " " 0xa " " 010 " " 0o10 " " 0b10 "} {
catch {testgetint 44 $x} x
set x
}
} {44 44 44 44 54 52 52 46}
test get-3.4 {Tcl_GetDouble with iffy numbers} testdoubleobj {
lmap x {0 0.0 " .0" ".0 " " 0e0 " "09" "- 0" "-0" "0o12" "0b10"} {
catch {testdoubleobj set 1 $x} x
set x
}
} {0.0 0.0 0.0 0.0 0.0 {expected floating-point number but got "09" (looks like invalid octal number)} {expected floating-point number but got "- 0"} 0.0 10.0 2.0}
# cleanup
::tcltest::cleanupTests
return
# Local Variables:
# mode: tcl
# End:

View File

@@ -11,8 +11,8 @@
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
if {"::tcltest" ni [namespace children]} {
package require tcltest 2
namespace import -force ::tcltest::*
}
@@ -245,6 +245,60 @@ test history-9.2 {miscellaneous} history {
catch {history gorp} msg
set msg
} {unknown or ambiguous subcommand "gorp": must be add, change, clear, event, info, keep, nextid, or redo}
# History retains references; Bug 1ae12987cb
test history-10.1 {references kept by history} -constraints history -setup {
interp create histtest
histtest eval {
# Trigger any autoloading that might be present
catch {history}
proc refcount {x} {
set rep [::tcl::unsupported::representation $x]
regexp {with a refcount of (\d+)} $rep -> rc
# Ignore the references due to calling this procedure
return [expr {$rc - 3}]
}
}
} -body {
histtest eval {
# A fresh object, refcount 1 from the variable we write it to
set obj [expr rand()]
set baseline [refcount $obj]
lappend result [refcount $obj]
history add [list list $obj]
lappend result [refcount $obj]
history clear
lappend result [refcount $obj]
}
} -cleanup {
interp delete histtest
} -result {1 2 1}
test history-10.2 {references kept by history} -constraints history -setup {
interp create histtest
histtest eval {
# Trigger any autoloading that might be present
catch {history}
proc refcount {x} {
set rep [::tcl::unsupported::representation $x]
regexp {with a refcount of (\d+)} $rep -> rc
# Ignore the references due to calling this procedure
return [expr {$rc - 3}]
}
}
} -body {
histtest eval {
# A fresh object, refcount 1 from the variable we write it to
set obj [expr rand()]
set baseline [refcount $obj]
lappend result [refcount $obj]
history add [list list $obj]
lappend result [refcount $obj]
rename history {}
lappend result [refcount $obj]
}
} -cleanup {
interp delete histtest
} -result {1 2 1}
# cleanup
::tcltest::cleanupTests

View File

@@ -36,6 +36,13 @@ proc bgerror {args} {
puts stderr $errorInfo
}
if {$::tcl_platform(os) eq "Darwin"} {
# Name resolution often a problem on OSX; not focus of HTTP package anyway
set HOST localhost
} else {
set HOST [info hostname]
}
set port 8010
set bindata "This is binary data\x0d\x0amore\x0dmore\x0amore\x00null"
catch {unset data}
@@ -118,8 +125,8 @@ test http-3.1 {http::geturl} -returnCodes error -body {
test http-3.2 {http::geturl} -returnCodes error -body {
http::geturl http:junk
} -result {Unsupported URL: http:junk}
set url //[info hostname]:$port
set badurl //[info hostname]:[expr $port+1]
set url //${::HOST}:$port
set badurl //${::HOST}:[expr $port+1]
test http-3.3 {http::geturl} -body {
set token [http::geturl $url]
http::data $token
@@ -130,12 +137,13 @@ test http-3.3 {http::geturl} -body {
<h2>GET /</h2>
</body></html>"
set tail /a/b/c
set url //[info hostname]:$port/a/b/c
set fullurl HTTP://user:pass@[info hostname]:$port/a/b/c
set binurl //[info hostname]:$port/binary
set posturl //[info hostname]:$port/post
set badposturl //[info hostname]:$port/droppost
set authorityurl //[info hostname]:$port
set url //${::HOST}:$port/a/b/c
set fullurl HTTP://user:pass@${::HOST}:$port/a/b/c
set binurl //${::HOST}:$port/binary
set xmlurl //${::HOST}:$port/xml
set posturl //${::HOST}:$port/post
set badposturl //${::HOST}:$port/droppost
set authorityurl //${::HOST}:$port
set ipv6url http://\[::1\]:$port/
test http-3.4 {http::geturl} -body {
set token [http::geturl $url]
@@ -148,7 +156,7 @@ test http-3.4 {http::geturl} -body {
</body></html>"
proc selfproxy {host} {
global port
return [list [info hostname] $port]
return [list ${::HOST} $port]
}
test http-3.5 {http::geturl} -body {
http::config -proxyfilter selfproxy
@@ -431,6 +439,13 @@ Accept text/plain,application/tcl-test-value
Accept-Encoding .*
Content-Type application/x-www-form-urlencoded
Content-Length 5}
# Bug 838e99a76d
test http-3.33 {http::geturl application/xml is text} -body {
set token [http::geturl "$xmlurl"]
scan [http::data $token] "<%\[^>]>%c<%\[^>]>"
} -cleanup {
catch { http::cleanup $token }
} -result {test 4660 /test}
test http-4.1 {http::Event} -body {
set token [http::geturl $url -keepalive 0]
@@ -584,6 +599,20 @@ test http-4.15 {http::Event} -body {
} -cleanup {
catch {http::cleanup $token}
} -returnCodes 1 -match glob -result "couldn't open socket*"
test http-4.16 {Leak with Close vs Keepalive (bug [6ca52aec14]} -setup {
proc list-difference {l1 l2} {
lmap item $l2 {if {$item in $l1} continue; set item}
}
} -body {
set before [chan names]
set token [http::geturl $url -headers {X-Connection keep-alive}]
http::cleanup $token
update
# Compute what channels have been unexpectedly leaked past cleanup
list-difference $before [chan names]
} -cleanup {
rename list-difference {}
} -result {}
test http-5.1 {http::formatQuery} {
http::formatQuery name1 value1 name2 "value two"
@@ -604,7 +633,7 @@ test http-5.5 {http::formatQuery} {
} {name1=~bwelch&name2=%A1%A2%A2}
test http-6.1 {http::ProxyRequired} -body {
http::config -proxyhost [info hostname] -proxyport $port
http::config -proxyhost ${::HOST} -proxyport $port
set token [http::geturl $url]
http::wait $token
upvar #0 $token data

View File

@@ -10,6 +10,13 @@
#set httpLog 1
if {$::tcl_platform(os) eq "Darwin"} {
# Name resolution often a problem on OSX; not focus of HTTP package anyway
set HOST localhost
} else {
set HOST [info hostname]
}
proc httpd_init {{port 8015}} {
socket -server httpdAccept $port
}
@@ -168,9 +175,13 @@ proc httpdRespond { sock } {
switch -glob -- $data(url) {
*binary* {
set html "$bindata[info hostname]:$port$data(url)"
set html "$bindata${::HOST}:$port$data(url)"
set type application/octet-stream
}
*xml* {
set html [encoding convertto utf-8 "<test>\u1234</test>"]
set type "application/xml;charset=UTF-8"
}
*post* {
set html "Got [string length $data(query)] bytes"
set type text/plain

View File

@@ -8,7 +8,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
package require Tcl 8.6
package require Tcl 8.6-
proc ::tcl::dict::get? {dict key} {
if {[dict exists $dict $key]} {

View File

@@ -33,10 +33,17 @@ if {[catch {package require http 1.0}]} {
}
}
if {$::tcl_platform(os) eq "Darwin"} {
# Name resolution often a problem on OSX; not focus of HTTP package anyway
set HOST localhost
} else {
set HOST [info hostname]
}
set bindata "This is binary data\x0d\x0amore\x0dmore\x0amore\x00null"
catch {unset data}
##
##
## The httpd script implement a stub http server
##
source [file join [file dirname [info script]] httpd]
@@ -85,7 +92,7 @@ test httpold-3.2 {http_get} {
set err
} {Unsupported URL: http:junk}
set url [info hostname]:$port
set url ${::HOST}:$port
test httpold-3.3 {http_get} {
set token [http_get $url]
http_data $token
@@ -95,8 +102,8 @@ test httpold-3.3 {http_get} {
</body></html>"
set tail /a/b/c
set url [info hostname]:$port/a/b/c
set binurl [info hostname]:$port/binary
set url ${::HOST}:$port/a/b/c
set binurl ${::HOST}:$port/binary
test httpold-3.4 {http_get} {
set token [http_get $url]
@@ -108,7 +115,7 @@ test httpold-3.4 {http_get} {
proc selfproxy {host} {
global port
return [list [info hostname] $port]
return [list ${::HOST} $port]
}
test httpold-3.5 {http_get} {
http_config -proxyfilter selfproxy
@@ -273,7 +280,7 @@ test httpold-5.3 {http_formatQuery} {
test httpold-6.1 {httpProxyRequired} {
update
http_config -proxyhost [info hostname] -proxyport $port
http_config -proxyhost ${::HOST} -proxyport $port
set token [http_get $url]
http_wait $token
http_config -proxyhost {} -proxyport {}

View File

@@ -168,6 +168,16 @@ foreach arg [subst -nocommands -novariables {
incr count
}
test init-4.$count {[Bug 46f801ed5a]} -setup {
auto_reset
array set auto_index {demo {proc demo {} {tailcall error foo}}}
} -body {
demo
} -cleanup {
array unset auto_index demo
rename demo {}
} -returnCodes error -result foo
test init-5.0 {return options passed through ::unknown} -setup {
catch {rename xxx {}}
set ::auto_index(::xxx) {proc ::xxx {} {

View File

@@ -20,7 +20,7 @@ catch [list package require -exact Tcltest [info patchlevel]]
testConstraint testinterpdelete [llength [info commands testinterpdelete]]
set hidden_cmds {cd encoding exec exit fconfigure file glob load open pwd socket source tcl:file:atime tcl:file:attributes tcl:file:copy tcl:file:delete tcl:file:dirname tcl:file:executable tcl:file:exists tcl:file:extension tcl:file:isdirectory tcl:file:isfile tcl:file:link tcl:file:lstat tcl:file:mkdir tcl:file:mtime tcl:file:nativename tcl:file:normalize tcl:file:owned tcl:file:readable tcl:file:readlink tcl:file:rename tcl:file:rootname tcl:file:size tcl:file:stat tcl:file:tail tcl:file:tempfile tcl:file:type tcl:file:volumes tcl:file:writable unload}
set hidden_cmds {cd encoding exec exit fconfigure file glob load open pwd socket source tcl:encoding:dirs tcl:file:atime tcl:file:attributes tcl:file:copy tcl:file:delete tcl:file:dirname tcl:file:executable tcl:file:exists tcl:file:extension tcl:file:isdirectory tcl:file:isfile tcl:file:link tcl:file:lstat tcl:file:mkdir tcl:file:mtime tcl:file:nativename tcl:file:normalize tcl:file:owned tcl:file:readable tcl:file:readlink tcl:file:rename tcl:file:rootname tcl:file:size tcl:file:stat tcl:file:tail tcl:file:tempfile tcl:file:type tcl:file:volumes tcl:file:writable unload}
foreach i [interp slaves] {
interp delete $i
@@ -606,6 +606,19 @@ test interp-14.10 {testing interp-alias: error messages} -setup {
invoked from within
"a 1"}
test interp-14.11 {{interp alias} {target named the empty string} {bug 2bf56185}} -setup {
set interp [interp create [info cmdcount]]
interp eval $interp {
proc {} args {return $args}
}
} -body {
interp alias {} p1 $interp {}
p1 one two three
} -cleanup {
interp delete $interp
} -result {one two three}
# part 15: testing file sharing
test interp-15.1 {testing file sharing} {
catch {interp delete z}

View File

@@ -5652,8 +5652,8 @@ 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 "0%o" [expr $stats(mode)&0o777]
} [format %04o [expr {0o666 & ~ $umaskValue}]]
format "%#o" [expr $stats(mode)&0o777]
} [format %#4o [expr {0o666 & ~ $umaskValue}]]
test io-40.4 {POSIX open access modes: CREAT} {
file delete $path(test3)
set f [open $path(test3) w]

View File

@@ -89,6 +89,90 @@ test link-2.5 {writing bad values into variables} -setup {
testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
list [catch {set wide gorp} msg] $msg $bool
} -result {1 {can't set "wide": variable must have integer value} 1}
test link-2.6 {writing C variables from Tcl} -constraints {testlink} -setup {
testlink delete
} -body {
testlink set 43 1.21 4 - 56785678 64 250 30000 60000 0xbaadbeef 12321 32123 3.25 1231231234
testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
set int "+"
set real "+"
set bool 1
set string "+"
set wide "+"
set char "+"
set uchar "+"
set short "+"
set ushort "+"
set uint "+"
set long "+"
set ulong "+"
set float "+"
set uwide "+"
concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
} -result {1 1.0 1 + 1 1 1 1 1 1 1 1 1.0 1 | + + 1 + + + + + + + + + + +}
test link-2.7 {writing C variables from Tcl} -constraints {testlink} -setup {
testlink delete
} -body {
testlink set 43 1.21 4 - 56785678 64 250 30000 60000 0xbaadbeef 12321 32123 3.25 1231231234
testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
set int "-"
set real "-"
set bool 0
set string "-"
set wide "-"
set char "-"
set uchar "-"
set short "-"
set ushort "-"
set uint "-"
set long "-"
set ulong "-"
set float "-"
set uwide "-"
concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
} -result {0 0.0 0 - 0 0 0 0 0 0 0 0 0.0 0 | - - 0 - - - - - - - - - - -}
test link-2.8 {writing C variables from Tcl} -constraints {testlink} -setup {
testlink delete
} -body {
testlink set 43 1.21 4 - 56785678 64 250 30000 60000 0xbaadbeef 12321 32123 3.25 1231231234
testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
set int "0x"
set real "0b"
set bool 0
set string "0"
set wide "0O"
set char "0X"
set uchar "0B"
set short "0O"
set ushort "0x"
set uint "0b"
set long "0o"
set ulong "0X"
set float "0B"
set uwide "0O"
concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
} -result {0 0.0 0 0 0 0 0 0 0 0 0 0 0.0 0 | 0x 0b 0 0 0O 0X 0B 0O 0x 0b 0o 0X 0B 0O}
test link-2.9 {writing C variables from Tcl} -constraints {testlink} -setup {
testlink delete
} -body {
testlink set 43 1.21 4 - 56785678 64 250 30000 60000 0xbaadbeef 12321 32123 3.25 1231231234
testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
set int 0
set real 5000e
set bool 0
set string 0
set wide 0
set char 0
set uchar 0
set short 0
set ushort 0
set uint 0
set long 0
set ulong 0
set float -60.00e+
set uwide 0
concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
} -result {0 5000.0 0 0 0 0 0 0 0 0 0 0 -60.0 0 | 0 5000e 0 0 0 0 0 0 0 0 0 0 -60.00e+ 0}
test link-3.1 {read-only variables} -constraints {testlink} -setup {
testlink delete

View File

@@ -185,23 +185,30 @@ test load-7.4 {Tcl_StaticPackage procedure, redundant calls} -setup {
info loaded
} -result [list {{} Double} {{} More} {{} Another} {{} Test} {*}$currentRealPackages {*}$alreadyTotalLoaded]
teststaticpkg Test 1 1
teststaticpkg Another 0 1
teststaticpkg More 0 1
teststaticpkg Double 0 1
test load-8.1 {TclGetLoadedPackages procedure} [list teststaticpkg $dll $loaded] {
testConstraint teststaticpkg_8.x \
[if {[testConstraint teststaticpkg]} {
teststaticpkg Test 1 1
teststaticpkg Another 0 1
teststaticpkg More 0 1
teststaticpkg Double 0 1
expr 1
} else {
expr 0
}]
test load-8.1 {TclGetLoadedPackages procedure} [list teststaticpkg_8.x $dll $loaded] {
lsort -index 1 [info loaded]
} [lsort -index 1 [list {{} Double} {{} More} {{} Another} {{} Test} {*}$currentRealPackages {*}$alreadyTotalLoaded]]
test load-8.2 {TclGetLoadedPackages procedure} -body {
test load-8.2 {TclGetLoadedPackages procedure} -constraints {teststaticpkg_8.x} -body {
info loaded gorp
} -returnCodes error -result {could not find interpreter "gorp"}
test load-8.3a {TclGetLoadedPackages procedure} [list teststaticpkg $dll $loaded] {
test load-8.3a {TclGetLoadedPackages procedure} [list teststaticpkg_8.x $dll $loaded] {
lsort -index 1 [info loaded {}]
} [lsort -index 1 [list {{} Double} {{} More} {{} Another} {{} Test} [list [file join $testDir pkga$ext] Pkga] [list [file join $testDir pkgb$ext] Pkgb] {*}$alreadyLoaded]]
test load-8.3b {TclGetLoadedPackages procedure} [list teststaticpkg $dll $loaded] {
test load-8.3b {TclGetLoadedPackages procedure} [list teststaticpkg_8.x $dll $loaded] {
lsort -index 1 [info loaded child]
} [lsort -index 1 [list {{} Test} [list [file join $testDir pkgb$ext] Pkgb]]]
test load-8.4 {TclGetLoadedPackages procedure} [list $dll $loaded teststaticpkg] {
test load-8.4 {TclGetLoadedPackages procedure} [list teststaticpkg_8.x $dll $loaded] {
load [file join $testDir pkgb$ext] pkgb
list [lsort -index 1 [info loaded {}]] [lsort [info commands pkgb_*]]
} [list [lsort -index 1 [concat [list [list [file join $testDir pkgb$ext] Pkgb] {{} Double} {{} More} {{} Another} {{} Test} [list [file join $testDir pkga$ext] Pkga]] $alreadyLoaded]] {pkgb_demo pkgb_sub pkgb_unsafe}]

View File

@@ -12,7 +12,7 @@
# Note that after running these tests, entries will be left behind in the
# message catalogs for locales foo, foo_BAR, and foo_BAR_baz.
package require Tcl 8.5
package require Tcl 8.5-
if {[catch {package require tcltest 2}]} {
puts stderr "Skipping tests in [info script]. tcltest 2 required."
return
@@ -51,7 +51,7 @@ namespace eval ::msgcat::test {
variable body
variable result
variable setVars
foreach setVars [PowerSet $envVars] {
foreach setVars [PowerSet $envVars] {
set result [string tolower [lindex $setVars 0]]
if {[string length $result] == 0} {
if {[info exists ::tcl::mac::locale]} {
@@ -94,7 +94,7 @@ namespace eval ::msgcat::test {
incr count
}
unset -nocomplain result
# Could add tests of initialization from Windows registry here.
# Use a fake registry package.
@@ -294,11 +294,11 @@ namespace eval ::msgcat::test {
variable count 2
variable result
array set result {
foo,ov0 ov0_ROOT foo,ov1 ov1_foo foo,ov2 ov2_foo
foo,ov0 ov0_ROOT foo,ov1 ov1_foo foo,ov2 ov2_foo
foo,ov3 ov3_foo foo,ov4 ov4
foo_BAR,ov0 ov0_ROOT foo_BAR,ov1 ov1_foo foo_BAR,ov2 ov2_foo_BAR
foo_BAR,ov3 ov3_foo_BAR foo_BAR,ov4 ov4
foo_BAR_baz,ov0 ov0_ROOT foo_BAR_baz,ov1 ov1_foo
foo_BAR,ov0 ov0_ROOT foo_BAR,ov1 ov1_foo foo_BAR,ov2 ov2_foo_BAR
foo_BAR,ov3 ov3_foo_BAR foo_BAR,ov4 ov4
foo_BAR_baz,ov0 ov0_ROOT foo_BAR_baz,ov1 ov1_foo
foo_BAR_baz,ov2 ov2_foo_BAR
foo_BAR_baz,ov3 ov3_foo_BAR_baz foo_BAR_baz,ov4 ov4
}
@@ -417,12 +417,12 @@ namespace eval ::msgcat::test {
variable locale [mclocale]
::msgcat::mclocale ""
::msgcat::mcloadedlocales clear
::msgcat::mcpackageconfig unset mcfolder
::msgcat::mcpackageconfig unset mcfolder
mclocale $loc
} -cleanup {
mclocale $locale
::msgcat::mcloadedlocales clear
::msgcat::mcpackageconfig unset mcfolder
::msgcat::mcpackageconfig unset mcfolder
} -body {
mcload $msgdir
} -result [expr { $count+1 }]
@@ -437,7 +437,7 @@ namespace eval ::msgcat::test {
} -cleanup {
mclocale $locale
mcloadedlocales clear
mcpackageconfig unset mcfolder
mcpackageconfig unset mcfolder
} -body {
mcload $msgdir
} -result 3
@@ -448,7 +448,7 @@ namespace eval ::msgcat::test {
} -cleanup {
mclocale $locale
mcloadedlocales clear
mcpackageconfig unset mcfolder
mcpackageconfig unset mcfolder
} -body {
mcload $msgdir
} -result 1
@@ -517,7 +517,7 @@ namespace eval ::msgcat::test {
} -cleanup {
mclocale $locale
mcloadedlocales clear
mcpackageconfig unset mcfolder
mcpackageconfig unset mcfolder
} -body {
mclocale foo
mcpackageconfig set mcfolder $msgdir
@@ -536,7 +536,7 @@ namespace eval ::msgcat::test {
# Tests msgcat-6.*: [mcset], [mc] namespace inheritance
#
# Test mcset and mc, ensuring that resolution for messages
# proceeds from the current ns to its parent and so on to the
# proceeds from the current ns to its parent and so on to the
# global ns.
#
# Do this for the 12 permutations of
@@ -580,7 +580,7 @@ namespace eval ::msgcat::test {
::msgcat::mcset foo ov3 "ov3_foo_bar_baz"
}
}
}
variable locale [mclocale]
mclocale foo
@@ -689,12 +689,12 @@ namespace eval ::msgcat::test {
mcexists
} -returnCodes 1\
-result {wrong # args: should be "mcexists ?-exactnamespace? ?-exactlocale? src"}
test msgcat-9.2 {mcexists unknown option} -body {
mcexists -unknown src
mcexists -unknown src
} -returnCodes 1\
-result {unknown option "-unknown"}
test msgcat-9.3 {mcexists} -setup {
mcforgetpackage
variable locale [mclocale]
@@ -716,7 +716,7 @@ namespace eval ::msgcat::test {
} -body {
list [mcexists k1] [mcexists -exactlocale k1]
} -result {1 0}
test msgcat-9.5 {mcexists parent namespace} -setup {
mcforgetpackage
variable locale [mclocale]
@@ -730,19 +730,19 @@ namespace eval ::msgcat::test {
[::msgcat::mcexists -exactnamespace k1]
}
} -result {1 0}
# Tests msgcat-10.*: [mcloadedlocales]
test msgcat-10.1 {mcloadedlocales no arg} -body {
mcloadedlocales
} -returnCodes 1\
-result {wrong # args: should be "mcloadedlocales subcommand"}
test msgcat-10.2 {mcloadedlocales wrong subcommand} -body {
mcloadedlocales junk
} -returnCodes 1\
-result {unknown subcommand "junk": must be clear, or loaded}
test msgcat-10.3 {mcloadedlocales loaded} -setup {
mcforgetpackage
variable locale [mclocale]
@@ -755,7 +755,7 @@ namespace eval ::msgcat::test {
# The result is position independent so sort
set resultlist [lsort [mcloadedlocales loaded]]
} -result {{} foo foo_bar}
test msgcat-10.4 {mcloadedlocales clear} -setup {
mcforgetpackage
variable locale [mclocale]
@@ -961,9 +961,9 @@ namespace eval ::msgcat::test {
} -result {0 0 1 0}
# option mcfolder is already tested with 5.11
# Tests msgcat-14.*: callbacks: loadcmd, changecmd, unknowncmd
# This routine is used as bgerror and by direct callback invocation
proc callbackproc args {
variable resultvariable

View File

@@ -1785,7 +1785,10 @@ test namespace-42.7 {ensembles: nested} -body {
} -cleanup {
namespace delete ns
} -result {{1 ::ns::x0::z} 1 2 3}
test namespace-42.8 {ensembles: [Bug 1670091]} -setup {
test namespace-42.8 {
ensembles: [Bug 1670091], panic due to pointer to a deallocated List
struct.
} -setup {
proc demo args {}
variable target [list [namespace which demo] x]
proc trial args {variable target; string length $target}
@@ -1800,6 +1803,34 @@ test namespace-42.8 {ensembles: [Bug 1670091]} -setup {
rename foo {}
} -result {}
test namespace-42.9 {
ensembles: [Bug 4f6a1ebd64], segmentation fault due to pointer to a
deallocated List struct.
} -setup {
namespace eval n {namespace ensemble create}
set lst [dict create one ::two]
namespace ensemble configure n -subcommands $lst -map $lst
} -body {
n one
} -cleanup {
namespace delete n
unset -nocomplain lst
} -returnCodes error -match glob -result {invalid command name*}
test namespace-42.10 {
ensembles: [Bug 4f6a1ebd64] segmentation fault due to pointer to a
deallocated List struct (this time with duplicate of one in "dict").
} -setup {
namespace eval n {namespace ensemble create}
set lst [list one ::two one ::three]
namespace ensemble configure n -subcommands $lst -map $lst
} -body {
n one
} -cleanup {
namespace delete n
unset -nocomplain lst
} -returnCodes error -match glob -result {invalid command name *three*}
test namespace-43.1 {ensembles: dict-driven} {
namespace eval ns {
namespace export x*

View File

@@ -64,9 +64,11 @@ if {[testConstraint testnrelevels]} {
namespace import testnre::*
}
test nre-0.1 {levels while unwinding} {
test nre-0.1 {levels while unwinding} -body {
testnreunwind
} {0 0 0}
} -constraints {
testnrelevels
} -result {0 0 0}
test nre-1.1 {self-recursive procs} -setup {
proc a i [makebody {a $i}]

View File

@@ -626,6 +626,19 @@ test obj-33.7 {integer overflow on input} {
list [string is integer $x] [expr { wide($x) }]
} {0 -4294967296}
test obj-34.1 {mp_iseven} testobj {
set result ""
lappend result [testbignumobj set 1 0]
lappend result [testbignumobj iseven 1] ;
lappend result [testobj type 1]
} {0 1 int}
test obj-34.2 {mp_radix_size} testobj {
set result ""
lappend result [testbignumobj set 1 9]
lappend result [testbignumobj radixsize 1] ;
lappend result [testobj type 1]
} {9 2 int}
if {[testConstraint testobj]} {
testobj freeallvars
}

View File

@@ -2013,6 +2013,52 @@ test oo-15.10 {variable binding must not bleed through oo::copy} -setup {
} -cleanup {
FooClass destroy
} -result {foo bar grill bar}
test oo-15.11 {OO: object cloning} -returnCodes error -body {
oo::copy
} -result {wrong # args: should be "oo::copy sourceName ?targetName? ?targetNamespace?"}
test oo-15.12 {OO: object cloning with target NS} -setup {
oo::class create Super
oo::class create Cls {superclass Super}
} -body {
namespace eval ::existing {}
oo::copy Cls {} ::existing
} -returnCodes error -cleanup {
Super destroy
catch {namespace delete ::existing}
} -result {::existing refers to an existing namespace}
test oo-15.13 {OO: object cloning with target NS} -setup {
oo::class create Super
oo::class create Cls {superclass Super}
} -body {
list [namespace exist ::dupens] [oo::copy Cls Cls2 ::dupens] [namespace exist ::dupens]
} -cleanup {
Super destroy
} -result {0 ::Cls2 1}
test oo-15.14 {OO: object cloning with target NS} -setup {
oo::class create Cls {export eval}
set result {}
} -body {
Cls create obj
obj eval {
proc test-15.14 {} {}
}
lappend result [info commands ::dupens::t*]
oo::copy obj obj2 ::dupens
lappend result [info commands ::dupens::t*]
} -cleanup {
Cls destroy
} -result {{} ::dupens::test-15.14}
test oo-15.15 {method cloning must ensure that there is a string representation of bodies} -setup {
oo::class create cls
} -body {
cls create foo
oo::objdefine foo {
method m1 {} [string map {a b} {return hello}]
}
[oo::copy foo] m1
} -cleanup {
cls destroy
} -result hello
test oo-16.1 {OO: object introspection} -body {
info object
@@ -2241,6 +2287,43 @@ test oo-17.10 {OO: class introspection} -setup {
oo::define foo unexport {*}[info class methods foo -all]
info class methods foo -all
} -result {}
set stdmethods {<cloned> destroy eval unknown variable varname}
test oo-17.11 {OO: object method unexport (bug 900cb0284bc)} -setup {
oo::object create o
oo::objdefine o unexport m
} -body {
lsort [info object methods o -all -private]
} -cleanup {
o destroy
} -result $stdmethods
test oo-17.12 {OO: instance method unexport (bug 900cb0284bc)} -setup {
oo::class create c
c create o
oo::objdefine o unexport m
} -body {
lsort [info object methods o -all -private]
} -cleanup {
o destroy
c destroy
} -result $stdmethods
test oo-17.13 {OO: class method unexport (bug 900cb0284bc)} -setup {
oo::class create c
oo::define c unexport m
} -body {
lsort [info class methods c -all -private]
} -cleanup {
c destroy
} -result $stdmethods
test oo-17.14 {OO: instance method unexport (bug 900cb0284bc)} -setup {
oo::class create c
oo::define c unexport m
c create o
} -body {
lsort [info object methods o -all -private]
} -cleanup {
o destroy
c destroy
} -result $stdmethods
test oo-18.1 {OO: define command support} {
list [catch {oo::define oo::object {error foo}} msg] $msg $errorInfo
@@ -3727,7 +3810,29 @@ test oo-35.4 {Bug 593baa032c: mixins list teardown} {
oo::class create D {mixin B}
namespace eval [info object namespace D] [list [namespace which B] destroy]
} {}
test oo-35.5 {Bug 1a56550e96: introspectors must traverse mixin links correctly} -setup {
oo::class create base {
unexport destroy
}
} -body {
oo::class create C {
superclass base
method c {} {}
}
oo::class create D {
superclass base
mixin C
method d {} {}
}
oo::class create E {
superclass D
method e {} {}
}
E create e1
list [lsort [info class methods E -all]] [lsort [info object methods e1 -all]]
} -cleanup {
base destroy
} -result {{c d e} {c d e}}
cleanupTests
return

View File

@@ -599,6 +599,16 @@ test package-3.52 {Tcl_PkgRequire procedure, picking best stable version} -setup
package require t
return $x
} -result {1.3}
test pkg-3.53 {Tcl_PkgRequire procedure, picking best stable version} {
package forget t
foreach i {1.2b1 1.1} {
package ifneeded t $i "set x $i; package provide t $i"
}
set x xxx
package require t
set x
} {1.1}
test package-4.1 {Tcl_PackageCmd procedure} -returnCodes error -body {
package

View File

@@ -16,7 +16,9 @@ namespace eval ::tcl::test::platform {
namespace import ::tcltest::test
namespace import ::tcltest::cleanupTests
variable ::tcl_platform
# This is not how [variable] works. See TIP 276.
#variable ::tcl_platform
namespace upvar :: tcl_platform tcl_platform
::tcltest::loadTestedCommands
catch [list package require -exact Tcltest [info patchlevel]]

View File

@@ -139,13 +139,10 @@ test resolver-1.5 {cmdNameObj sharing vs. cmd resolver: other than global NS} -s
variable r2 ""
}
} -constraints testinterpresolver -body {
set r0 [namespace eval ::ns2 {x}]
set r1 [namespace eval ::ns2 {z}]
namespace eval ::ns2 {
list [namespace eval ::ns2 {x}] [namespace eval ::ns2 {z}] [namespace eval ::ns2 {
namespace import ::ns1::z
set r2 [z]
}
list $r0 $r1 $r2
z
}]
} -cleanup {
testinterpresolver down
namespace delete ::ns2
@@ -187,7 +184,7 @@ test resolver-2.1 {compiled var resolver: Bug #3383616} -setup {
# During the compilation the compiled var resolver, the resolve-specific
# var info is allocated, during the execution of the body, the variable is
# fetched and cached.
x;
x
# During later calls, the cached variable is reused.
x
# When the proc is freed, the resolver-specific resolver var info is
@@ -196,6 +193,121 @@ test resolver-2.1 {compiled var resolver: Bug #3383616} -setup {
} -cleanup {
testinterpresolver down
} -result {}
#
# The test resolver-3.1* test bad interactions of resolvers on the "global"
# (per interp) literal pools. A resolver might resolve a cmd literal depending
# on a context differently, whereas the cmd literal sharing assumed that the
# namespace containing the literal solely determines the resolved cmd (and is
# resolver-agnostic).
#
# In order to make the test cases for the per-interpreter cmd literal pool
# reproducable and to minimize interactions between test cases, we use a slave
# interpreter per test-case.
#
#
# Testing resolver in namespace-based context "ctx1"
#
test resolver-3.1a {
interp command resolver,
resolve literal "z" in proc "x1" in context "ctx1"
} -setup {
interp create i0
testinterpresolver up i0
i0 eval {
proc y {} { return yy }
namespace eval ::ns {
proc x1 {} { z }
}
}
} -constraints testinterpresolver -body {
set r [i0 eval {namespace eval ::ctx1 {
::ns::x1
}}]
return $r
} -cleanup {
testinterpresolver down i0
interp delete i0
} -result {yy}
#
# Testing resolver in namespace-based context "ctx2"
#
test resolver-3.1b {
interp command resolver,
resolve literal "z" in proc "x2" in context "ctx2"
} -setup {
interp create i0
testinterpresolver up i0
i0 eval {
proc Y {} { return YY }
namespace eval ::ns {
proc x2 {} { z }
}
}
} -constraints testinterpresolver -body {
set r [i0 eval {namespace eval ::ctx2 {
::ns::x2
}}]
return $r
} -cleanup {
testinterpresolver down i0
interp delete i0
} -result {YY}
#
# Testing resolver in namespace-based context "ctx1" and "ctx2" in the same
# interpreter.
#
test resolver-3.1c {
interp command resolver,
resolve literal "z" in proc "x1" in context "ctx1",
resolve literal "z" in proc "x2" in context "ctx2"
Test, whether the shared cmd literal created by the first byte-code
compilation interacts with the second one.
} -setup {
interp create i0
testinterpresolver up i0
i0 eval {
proc y {} { return yy }
proc Y {} { return YY }
namespace eval ::ns {
proc x1 {} { z }
proc x2 {} { z }
}
}
} -constraints testinterpresolver -body {
set r1 [i0 eval {namespace eval ::ctx1 {
::ns::x1
}}]
set r2 [i0 eval {namespace eval ::ctx2 {
::ns::x2
}}]
set r3 [i0 eval {namespace eval ::ctx1 {
::ns::x1
}}]
return [list $r1 $r2 $r3]
} -cleanup {
testinterpresolver down i0
interp delete i0
} -result {yy YY yy}
cleanupTests
return

View File

@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
package require Tcl 8.5
package require Tcl 8.5-
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2

View File

@@ -535,6 +535,30 @@ test scan-5.13 {integer scanning and overflow} {
test scan-5.14 {integer scanning} {
scan 0xff %u
} 0
test scan-5.15 {Bug be003d570f} {
scan 0x40 %o
} 0
test scan-5.16 {Bug be003d570f} {
scan 0x40 %b
} 0
test scan-5.17 {bigint scanning} -setup {
set a {}; set b {}; set c {}
} -body {
list [scan "207698809136909011942886895,abcdef0123456789abcdef,125715736004432126361152746757" \
%lld,%llx,%llo a b c] $a $b $c
} -result {3 207698809136909011942886895 207698809136909011942886895 207698809136909011942886895}
test scan-5.18 {bigint scanning underflow} -setup {
set a {};
} -body {
list [scan "-207698809136909011942886895" \
%llu a] $a
} -returnCodes 1 -result {unsigned bignum scans are invalid}
test scan-5.19 {bigint scanning invalid} -setup {
set a {};
} -body {
list [scan "207698809136909011942886895" \
%llu a] $a
} -returnCodes 1 -result {unsigned bignum scans are invalid}
test scan-6.1 {floating-point scanning} -setup {
set a {}; set b {}; set c {}; set d {}

View File

@@ -652,6 +652,13 @@ test set-old-8.52 {array command, array names -regexp on regexp pattern} {
set a(11) 1
list [catch {lsort [array names a -regexp ^1]} msg] $msg
} {0 {1*2 11 12}}
test set-old-8.52.1 {array command, array names -regexp, backrefs} {
catch {unset a}
set a(1*2) 1
set a(12) 1
set a(11) 1
list [catch {lsort [array names a -regexp {^(.)\1}]} msg] $msg
} {0 11}
test set-old-8.53 {array command, array names -regexp} {
catch {unset a}
set a(-glob) 1

View File

@@ -69,7 +69,22 @@ testConstraint exec [llength [info commands exec]]
# Produce a random port number in the Dynamic/Private range
# from 49152 through 65535.
proc randport {} { expr {int(rand()*16383+49152)} }
proc randport {} {
# firstly try dynamic port via server-socket(0):
set port 0x7fffffff
catch {
set port [lindex [fconfigure [set s [socket -server {} 0]] -sockname] 2]
close $s
}
while {[catch {
close [socket -server {} $port]
} msg]} {
if {[incr i] > 1000} {return -code error "too many iterations to get free random port: $msg"}
# try random port:
set port [expr {int(rand()*16383+49152)}]
}
return $port
}
# Test the latency of tcp connections over the loopback interface. Some OSes
# (e.g. NetBSD) seem to use the Nagle algorithm and delayed ACKs, so it takes

View File

@@ -70,6 +70,9 @@ test split-1.13 {basic split commands} {
test split-1.14 {basic split commands} {
split ",12,,,34,56," {,}
} {{} 12 {} {} 34 56 {}}
test split-1.15 {basic split commands} -body {
split "a\U01f4a9b" {}
} -result "a \U01f4a9 b"
test split-2.1 {split errors} {
list [catch split msg] $msg $errorCode

View File

@@ -219,7 +219,7 @@ test string-4.14 {string first, negative start index} {
} 1
test string-4.15 {string first, ability to two-byte encoded utf-8 chars} {
# Test for a bug in Tcl 8.3 where test for all-single-byte-encoded
# strings was incorrect, leading to an index returned by [string first]
# strings was incorrect, leading to an index returned by [string first]
# which pointed past the end of the string.
set uchar \u057e ;# character with two-byte encoding in utf-8
string first % %#$uchar$uchar#$uchar$uchar#% 3
@@ -419,7 +419,7 @@ test string-6.37 {string is double, false on int overflow} -setup {
} -result {1 priorValue}
# string-6.38 removed, underflow on input is no longer an error.
test string-6.39 {string is double, false} {
# This test is non-portable because IRIX thinks
# This test is non-portable because IRIX thinks
# that .e1 is a valid double - this is really a bug
# on IRIX as .e1 should NOT be a valid double
#
@@ -576,12 +576,12 @@ test string-6.85 {string is control} {
} 0
test string-6.86 {string is graph} {
## graph is any print char, except space
list [string is gra -fail var "0123abc!@#\$\u0100 "] $var
} {0 12}
list [string is gra -fail var "0123abc!@#\$\u0100\UE0100\UE01EF "] $var
} {0 14}
test string-6.87 {string is print} {
## basically any printable char
list [string is print -fail var "0123abc!@#\$\u0100 \u0010"] $var
} {0 13}
list [string is print -fail var "0123abc!@#\$\u0100 \UE0100\UE01EF\u0010"] $var
} {0 15}
test string-6.88 {string is punct} {
## any graph char that isn't alnum
list [string is punct -fail var "_!@#\u00beq0"] $var
@@ -901,6 +901,10 @@ test string-10.20 {string map, dictionaries don't alter map ordering} {
set map {aa X a Y}
list [string map [dict create aa X a Y] aaa] [string map $map aaa] [dict size $map] [string map $map aaa]
} {XY XY 2 XY}
test string-10.20.1 {string map, dictionaries don't alter map ordering} {
set map {a X b Y a Z}
list [string map [dict create a X b Y a Z] aaa] [string map $map aaa] [dict size $map] [string map $map aaa]
} {ZZZ XXX 2 XXX}
test string-10.21 {string map, ABR checks} {
string map {longstring foob} long
} long
@@ -1678,40 +1682,40 @@ test string-24.4 {string reverse command - unshared string} {
string reverse $x$y
} edcba
test string-24.5 {string reverse command - shared unicode string} {
set x abcde\udead
set x abcde\ud0ad
string reverse $x
} \udeadedcba
} \ud0adedcba
test string-24.6 {string reverse command - unshared string} {
set x abc
set y de\udead
set y de\ud0ad
string reverse $x$y
} \udeadedcba
} \ud0adedcba
test string-24.7 {string reverse command - simple case} {
string reverse a
} a
test string-24.8 {string reverse command - simple case} {
string reverse \udead
} \udead
string reverse \ud0ad
} \ud0ad
test string-24.9 {string reverse command - simple case} {
string reverse {}
} {}
test string-24.10 {string reverse command - corner case} {
set x \ubeef\udead
set x \ubeef\ud0ad
string reverse $x
} \udead\ubeef
} \ud0ad\ubeef
test string-24.11 {string reverse command - corner case} {
set x \ubeef
set y \udead
set y \ud0ad
string reverse $x$y
} \udead\ubeef
} \ud0ad\ubeef
test string-24.12 {string reverse command - corner case} {
set x \ubeef
set y \udead
set y \ud0ad
string is ascii [string reverse $x$y]
} 0
test string-24.13 {string reverse command - pure Unicode string} {
string reverse [string range \ubeef\udead\ubeef\udead\ubeef\udead 1 5]
} \udead\ubeef\udead\ubeef\udead
string reverse [string range \ubeef\ud0ad\ubeef\ud0ad\ubeef\ud0ad 1 5]
} \ud0ad\ubeef\ud0ad\ubeef\ud0ad
test string-24.14 {string reverse command - pure bytearray} {
binary scan [string reverse [binary format H* 010203]] H* x
set x
@@ -1833,7 +1837,7 @@ proc MemStress {args} {
set res {}
foreach body $args {
set end 0
for {set i 0} {$i < 5} {incr i} {
for {set i 0} {$i < 5} {incr i} {
proc MemStress_Body {} $body
uplevel 1 MemStress_Body
rename MemStress_Body {}

View File

@@ -738,6 +738,9 @@ test stringComp-14.4 {Bug 1af8de570511} {
string replace $val[unset val] 1 1 $y
}} 4 x
} 0x00
test stringComp-14.5 {} {
string length [string replace [string repeat a\u00fe 2] 3 end {}]
} 3
## string tolower
## not yet bc

View File

@@ -6,7 +6,7 @@
# Copyright (c) 2004 by Donal K. Fellows.
# All rights reserved.
package require Tcl 8.5
package require Tcl 8.5-
if {"::tcltest" ni [namespace children]} {
package require tcltest 2
namespace import -force ::tcltest::*
@@ -200,7 +200,7 @@ test tm-3.11 {tm: module path management, remove ignores unknown path} -setup {
proc genpaths {base} {
# Normalizing picks up drive letters on windows [Bug 1053568]
set base [file normalize $base]
lassign [split [package present Tcl] .] major minor
lassign [split [package present Tcl] .] major minor
set results {}
set base [file join $base tcl$major]
lappend results [file join $base site-tcl]

View File

@@ -20,6 +20,9 @@ testConstraint testbytestring [llength [info commands testbytestring]]
catch {unset x}
# Some tests require support for 4-byte UTF-8 sequences
testConstraint fullutf [expr {[format %c 0x010000] != "\ufffd"}]
test utf-1.1 {Tcl_UniCharToUtf: 1 byte sequences} testbytestring {
expr {"\x01" eq [testbytestring "\x01"]}
} 1
@@ -38,6 +41,9 @@ test utf-1.5 {Tcl_UniCharToUtf: overflowed Tcl_UniChar} testbytestring {
test utf-1.6 {Tcl_UniCharToUtf: negative Tcl_UniChar} testbytestring {
expr {[format %c -1] eq [testbytestring "\xef\xbf\xbd"]}
} 1
test utf-1.7 {Tcl_UniCharToUtf: 4 byte sequences} -constraints {fullutf testbytestring} -body {
expr {"\U014e4e" eq [testbytestring "\xf0\x94\xb9\x8e"]}
} -result 1
test utf-2.1 {Tcl_UtfToUniChar: low ascii} {
string length "abc"
@@ -60,14 +66,29 @@ test utf-2.6 {Tcl_UtfToUniChar: lead (3-byte) followed by 1 trail} testbytestrin
test utf-2.7 {Tcl_UtfToUniChar: lead (3-byte) followed by 2 trail} testbytestring {
string length [testbytestring "\xE4\xb9\x8e"]
} {1}
test utf-2.8 {Tcl_UtfToUniChar: longer UTF sequences not supported} testbytestring {
string length [testbytestring "\xF4\xA2\xA2\xA2"]
test utf-2.8 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} -constraints {fullutf testbytestring} -body {
string length [testbytestring "\xF0\x90\x80\x80"]
} -result {2}
test utf-2.9 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail} -constraints {fullutf testbytestring} -body {
string length [testbytestring "\xF4\x8F\xBF\xBF"]
} -result {2}
test utf-2.10 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail, underflow} testbytestring {
string length [testbytestring "\xF0\x8F\xBF\xBF"]
} {4}
test utf-2.11 {Tcl_UtfToUniChar: lead (4-byte) followed by 3 trail, overflow} testbytestring {
string length [testbytestring "\xF4\x90\x80\x80"]
} {4}
test utf-2.12 {Tcl_UtfToUniChar: longer UTF sequences not supported} testbytestring {
string length [testbytestring "\xF8\xA2\xA2\xA2\xA2"]
} {5}
test utf-3.1 {Tcl_UtfCharComplete} {
} {}
testConstraint testnumutfchars [llength [info commands testnumutfchars]]
testConstraint testfindfirst [llength [info commands testfindfirst]]
testConstraint testfindlast [llength [info commands testfindlast]]
test utf-4.1 {Tcl_NumUtfChars: zero length} testnumutfchars {
testnumutfchars ""
} {0}
@@ -81,20 +102,31 @@ test utf-4.4 {Tcl_NumUtfChars: #u0000} {testnumutfchars testbytestring} {
testnumutfchars [testbytestring "\xC0\x80"]
} {1}
test utf-4.5 {Tcl_NumUtfChars: zero length, calc len} testnumutfchars {
testnumutfchars "" 1
testnumutfchars "" 0
} {0}
test utf-4.6 {Tcl_NumUtfChars: length 1, calc len} {testnumutfchars testbytestring} {
testnumutfchars [testbytestring "\xC2\xA2"] 1
testnumutfchars [testbytestring "\xC2\xA2"] 2
} {1}
test utf-4.7 {Tcl_NumUtfChars: long string, calc len} {testnumutfchars testbytestring} {
testnumutfchars [testbytestring "abc\xC2\xA2\xe4\xb9\x8e\uA2\u4e4e"] 1
testnumutfchars [testbytestring "abc\xC2\xA2\xe4\xb9\x8e\uA2\u4e4e"] 10
} {7}
test utf-4.8 {Tcl_NumUtfChars: #u0000, calc len} {testnumutfchars testbytestring} {
testnumutfchars [testbytestring "\xC0\x80"] 1
testnumutfchars [testbytestring "\xC0\x80"] 2
} {1}
# Bug [2738427]: Tcl_NumUtfChars(...) no overflow check
test utf-4.9 {Tcl_NumUtfChars: #u20AC, calc len, incomplete} {testnumutfchars testbytestring} {
testnumutfchars [testbytestring "\xE2\x82\xAC"] 2
} {2}
test utf-4.10 {Tcl_NumUtfChars: #u0000, calc len, overcomplete} {testnumutfchars testbytestring} {
testnumutfchars [testbytestring "\x00"] 2
} {2}
test utf-5.1 {Tcl_UtfFindFirsts} {
} {}
test utf-5.1 {Tcl_UtfFindFirst} {testfindfirst testbytestring} {
testfindfirst [testbytestring "abcbc"] 98
} {bcbc}
test utf-5.2 {Tcl_UtfFindLast} {testfindlast testbytestring} {
testfindlast [testbytestring "abcbc"] 98
} {bc}
test utf-6.1 {Tcl_UtfNext} {
} {}
@@ -195,8 +227,16 @@ bsCheck \Ua1 161
bsCheck \U4e21 20001
bsCheck \U004e21 20001
bsCheck \U00004e21 20001
bsCheck \U00110000 65533
bsCheck \Uffffffff 65533
bsCheck \U0000004e21 78
if {[testConstraint fullutf]} {
bsCheck \U00110000 69632
bsCheck \U01100000 69632
bsCheck \U11000000 69632
bsCheck \U0010FFFF 1114111
bsCheck \U010FFFF0 1114111
bsCheck \U10FFFF00 1114111
bsCheck \UFFFFFFFF 1048575
}
test utf-11.1 {Tcl_UtfToUpper} {
string toupper {}
@@ -264,8 +304,8 @@ test utf-16.1 {Tcl_UniCharToLower, negative delta} {
string tolower aA
} aa
test utf-16.2 {Tcl_UniCharToLower, positive delta} {
string tolower \u0178\u00ff\uA78D\u01c5
} \u00ff\u00ff\u0265\u01c6
string tolower \u0178\u00ff\uA78D\u01c5\U10400
} \u00ff\u00ff\u0265\u01c6\U10428
test utf-17.1 {Tcl_UniCharToLower, no delta} {
string tolower !

View File

@@ -208,7 +208,7 @@ test util-4.6 {Tcl_ConcatObj - utf-8 sequence with "whitespace" char} {
} \xe0
test util-4.7 {Tcl_ConcatObj - refCount safety} testconcatobj {
# Check for Bug #1447328 (actually, bugs in its original "fix"). One of the
# symptoms was Bug #2055782.
# symptoms was Bug #2055782.
testconcatobj
} {}
@@ -566,7 +566,7 @@ test util-9.1.3 {TclGetIntForIndex} {
} k
test util-9.2.0 {TclGetIntForIndex} {
string index abcd end
} d
} d
test util-9.2.1 {TclGetIntForIndex} -body {
string index abcd { end}
} -returnCodes error -match glob -result *
@@ -4007,7 +4007,7 @@ test util-17.1 {bankers' rounding [Bug 3349507]} {ieeeFloatingPoint} {
}
set r
} [list {*}{
0x43fffffffffffffc 0xc3fffffffffffffc
0x43fffffffffffffc 0xc3fffffffffffffc
0x43fffffffffffffc 0xc3fffffffffffffc
0x43fffffffffffffd 0xc3fffffffffffffd
0x43fffffffffffffe 0xc3fffffffffffffe

View File

@@ -26,6 +26,20 @@ testConstraint testupvar [llength [info commands testupvar]]
testConstraint testgetvarfullname [llength [info commands testgetvarfullname]]
testConstraint testsetnoerr [llength [info commands testsetnoerr]]
testConstraint memory [llength [info commands memory]]
if {[testConstraint memory]} {
proc getbytes {} {
return [lindex [split [memory info] \n] 3 3]
}
proc leaktest {script {iterations 3}} {
set end [getbytes]
for {set i 0} {$i < $iterations} {incr i} {
uplevel 1 $script
set tmp $end
set end [getbytes]
}
return [expr {$end - $tmp}]
}
}
catch {rename p ""}
catch {namespace delete test_ns_var}
@@ -579,6 +593,22 @@ test var-8.2 {TclDeleteNamespaceVars, "unset" traces on ns delete are called wit
list [namespace delete test_ns_var] $::info
} -result {{} {::test_ns_var::v {} u}}
test var-8.3 {TclDeleteNamespaceVars, mem leak} -constraints memory -setup {
proc ::t {a i o} {
set $a 321
}
} -body {
leaktest {
namespace eval n {
variable v 123
trace variable v u ::t
}
namespace delete n
}
} -cleanup {
rename ::t {}
} -result 0
test var-9.1 {behaviour of TclGet/SetVar simple get/set} -setup {
catch {unset u}
catch {unset v}

View File

@@ -138,6 +138,67 @@ test zlib-7.7 {zlib stream: Bug 25842c161} -constraints zlib -body {
} -cleanup {
catch {$s close}
} -result ""
# Also causes Tk Bug 10f2e7872b
test zlib-7.8 {zlib stream: Bug b26e38a3e4} -constraints zlib -setup {
expr srand(12345)
set randdata {}
for {set i 0} {$i<6001} {incr i} {
append randdata [binary format c [expr {int(256*rand())}]]
}
} -body {
set strm [zlib stream compress]
for {set i 1} {$i<3000} {incr i} {
$strm put $randdata
}
$strm put -finalize $randdata
set data [$strm get]
list [string length $data] [string length [zlib decompress $data]]
} -cleanup {
catch {$strm close}
unset -nocomplain randdata data
} -result {120185 18003000}
test zlib-7.9 {zlib stream finalize (bug 25842c161)} -constraints zlib -setup {
set z1 [zlib stream gzip]
set z2 [zlib stream gzip]
} -body {
$z1 put ABCDEedbca..
$z1 finalize
zlib gunzip [$z1 get]
} -cleanup {
$z1 close
} -result ABCDEedbca..
test zlib-7.10 {zlib stream finalize (bug 25842c161)} -constraints zlib -setup {
set z2 [zlib stream gzip]
} -body {
$z2 put -finalize ABCDEedbca..
zlib gunzip [$z2 get]
} -cleanup {
$z2 close
} -result ABCDEedbca..
test zlib-7.11 {zlib stream put -finalize (bug 25842c161)} -constraints zlib -setup {
set c [zlib stream gzip]
set d [zlib stream gunzip]
} -body {
$c put abcdeEDCBA..
$c finalize
$d put [$c get]
$d finalize
$d get
} -cleanup {
$c close
$d close
} -result abcdeEDCBA..
test zlib-7.12 {zlib stream put; zlib stream finalize (bug 25842c161)} -constraints zlib -setup {
set c [zlib stream gzip]
set d [zlib stream gunzip]
} -body {
$c put -finalize abcdeEDCBA..
$d put -finalize [$c get]
$d get
} -cleanup {
$c close
$d close
} -result abcdeEDCBA..
test zlib-8.1 {zlib transformation} -constraints zlib -setup {
set file [makeFile {} test.gz]
@@ -250,7 +311,7 @@ test zlib-8.8 {transformation and fconfigure} -setup {
lassign [chan pipe] inSide outSide
} -constraints zlib -body {
zlib push compress $outSide -dictionary $spdyDict
fconfigure $outSide -blocking 0 -translation binary -buffering none
fconfigure $outSide -blocking 1 -translation binary -buffering none
fconfigure $inSide -blocking 1 -translation binary
puts -nonewline $outSide $spdyHeaders
chan pop $outSide
@@ -269,7 +330,7 @@ test zlib-8.9 {transformation and fconfigure} -setup {
set strm [zlib stream decompress]
} -constraints zlib -body {
zlib push compress $outSide -dictionary $spdyDict
fconfigure $outSide -blocking 0 -translation binary -buffering none
fconfigure $outSide -blocking 1 -translation binary -buffering none
fconfigure $inSide -blocking 1 -translation binary
puts -nonewline $outSide $spdyHeaders
set result [fconfigure $outSide -checksum]
@@ -286,7 +347,7 @@ test zlib-8.10 {transformation and fconfigure} -setup {
lassign [chan pipe] inSide outSide
} -constraints {zlib recentZlib} -body {
zlib push deflate $outSide -dictionary $spdyDict
fconfigure $outSide -blocking 0 -translation binary -buffering none
fconfigure $outSide -blocking 1 -translation binary -buffering none
fconfigure $inSide -blocking 1 -translation binary
puts -nonewline $outSide $spdyHeaders
chan pop $outSide
@@ -308,7 +369,7 @@ test zlib-8.11 {transformation and fconfigure} -setup {
set strm [zlib stream inflate]
} -constraints zlib -body {
zlib push deflate $outSide -dictionary $spdyDict
fconfigure $outSide -blocking 0 -translation binary -buffering none
fconfigure $outSide -blocking 1 -translation binary -buffering none
fconfigure $inSide -blocking 1 -translation binary
puts -nonewline $outSide $spdyHeaders
chan pop $outSide
@@ -326,7 +387,7 @@ test zlib-8.12 {transformation and fconfigure} -setup {
} -constraints zlib -body {
$strm put -dictionary $spdyDict -finalize $spdyHeaders
zlib push decompress $inSide
fconfigure $outSide -blocking 0 -translation binary
fconfigure $outSide -blocking 1 -translation binary
fconfigure $inSide -translation binary -dictionary $spdyDict
puts -nonewline $outSide [$strm get]
close $outSide
@@ -343,7 +404,7 @@ test zlib-8.13 {transformation and fconfigure} -setup {
} -constraints zlib -body {
$strm put -dictionary $spdyDict -finalize $spdyHeaders
zlib push decompress $inSide -dictionary $spdyDict
fconfigure $outSide -blocking 0 -translation binary
fconfigure $outSide -blocking 1 -translation binary
fconfigure $inSide -translation binary
puts -nonewline $outSide [$strm get]
close $outSide
@@ -360,7 +421,7 @@ test zlib-8.14 {transformation and fconfigure} -setup {
} -constraints zlib -body {
$strm put -finalize -dictionary $spdyDict $spdyHeaders
zlib push inflate $inSide
fconfigure $outSide -blocking 0 -buffering none -translation binary
fconfigure $outSide -blocking 1 -buffering none -translation binary
fconfigure $inSide -translation binary -dictionary $spdyDict
puts -nonewline $outSide [$strm get]
close $outSide
@@ -376,7 +437,7 @@ test zlib-8.15 {transformation and fconfigure} -setup {
} -constraints zlib -body {
$strm put -finalize -dictionary $spdyDict $spdyHeaders
zlib push inflate $inSide -dictionary $spdyDict
fconfigure $outSide -blocking 0 -buffering none -translation binary
fconfigure $outSide -blocking 1 -buffering none -translation binary
fconfigure $inSide -translation binary
puts -nonewline $outSide [$strm get]
close $outSide
@@ -447,6 +508,7 @@ test zlib-9.2 "socket fcopy with push" -constraints zlib -setup {
chan configure $c -translation binary -buffering none -blocking 0
puts -nonewline $c [zlib gzip [string repeat a 81920]]
close $c
set ::total -1
}}} 0]
set file [makeFile {} test.gz]
} -body {
@@ -454,7 +516,10 @@ test zlib-9.2 "socket fcopy with push" -constraints zlib -setup {
set sin [socket $addr $port]
chan configure $sin -translation binary
zlib push gunzip $sin
update
after 1000 {set ::total timeout}
vwait ::total
after cancel {set ::total timeout}
if {$::total != -1} {error "unexpected value $::total of ::total"}
set total [fcopy $sin [set fout [open $file wb]]]
close $sin
close $fout
@@ -917,6 +982,29 @@ test zlib-12.1 {Tk Bug 9eb55debc5} -constraints zlib -setup {
} -cleanup {
$stream close
} -result {12026 18000}
test zlib-12.2 {Patrick Dunnigan's issue} -constraints zlib -setup {
set filesrc [makeFile {} test.input]
set filedst [makeFile {} test.output]
set f [open $filesrc "wb"]
for {set i 0} {$i < 10000} {incr i} {
puts -nonewline $f "x"
}
close $f
} -body {
set fin [open $filesrc "rb"]
set fout [open $filedst "wb"]
set header [dict create filename "test.input" time 0]
try {
fcopy $fin [zlib push gzip $fout -header $header]
} finally {
close $fin
close $fout
}
file size $filedst
} -cleanup {
removeFile $filesrc
removeFile $filedst
} -result 56
::tcltest::cleanupTests
return