| 1 |
# This file contains tests for the package and ::pkg::* commands. |
| 2 |
# Note that the tests are limited to Tcl scripts only, there are no shared |
| 3 |
# libraries against which to test. |
| 4 |
# |
| 5 |
# Sourcing this file into Tcl runs the tests and generates output for errors. |
| 6 |
# No output means no errors were found. |
| 7 |
# |
| 8 |
# Copyright (c) 1995-1996 Sun Microsystems, Inc. |
| 9 |
# Copyright (c) 1998-1999 by Scriptics Corporation. |
| 10 |
# Copyright (c) 2011 Donal K. Fellows |
| 11 |
# |
| 12 |
# See the file "license.terms" for information on usage and redistribution of |
| 13 |
# this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 14 |
|
| 15 |
if {"::tcltest" ni [namespace children]} { |
| 16 |
package require tcltest 2.3.3 |
| 17 |
namespace import -force ::tcltest::* |
| 18 |
} |
| 19 |
|
| 20 |
# Do all this in a child interp to avoid garbaging the package list |
| 21 |
set i [interp create] |
| 22 |
tcltest::loadIntoChildInterpreter $i {*}$argv |
| 23 |
interp eval $i { |
| 24 |
namespace import -force ::tcltest::* |
| 25 |
package forget {*}[package names] |
| 26 |
set oldPkgUnknown [package unknown] |
| 27 |
package unknown {} |
| 28 |
set oldPath $auto_path |
| 29 |
set auto_path "" |
| 30 |
|
| 31 |
test package-1.1 {pkg::create gives error on insufficient args} -body { |
| 32 |
::pkg::create |
| 33 |
} -returnCodes error -match glob -result {wrong # args: should be "*"} |
| 34 |
test package-1.2 {pkg::create gives error on bad args} -body { |
| 35 |
::pkg::create -foo bar -bar baz -baz boo |
| 36 |
} -returnCodes error -match glob -result {unknown option "bar": *} |
| 37 |
test package-1.3 {pkg::create gives error on no value given} -body { |
| 38 |
::pkg::create -name foo -version 1.0 -source test.tcl -load |
| 39 |
} -returnCodes error -match glob -result {value for "-load" missing: *} |
| 40 |
test package-1.4 {pkg::create gives error on no name given} -body { |
| 41 |
::pkg::create -version 1.0 -source test.tcl -load foo.so |
| 42 |
} -returnCodes error -match glob -result {value for "-name" missing: *} |
| 43 |
test package-1.5 {pkg::create gives error on no version given} -body { |
| 44 |
::pkg::create -name foo -source test.tcl -load foo.so |
| 45 |
} -returnCodes error -match glob -result {value for "-version" missing: *} |
| 46 |
test package-1.6 {pkg::create gives error on no source or load options} -body { |
| 47 |
::pkg::create -name foo -version 1.0 -version 2.0 |
| 48 |
} -returnCodes error -result {at least one of -load and -source must be given} |
| 49 |
test package-1.7 {pkg::create gives correct output for 1 direct source} { |
| 50 |
::pkg::create -name foo -version 1.0 -source test.tcl |
| 51 |
} {package ifneeded foo 1.0 [list source [file join $dir test.tcl]]} |
| 52 |
test package-1.8 {pkg::create gives correct output for 2 direct sources} { |
| 53 |
::pkg::create -name foo -version 1.0 -source test.tcl -source test2.tcl |
| 54 |
} {package ifneeded foo 1.0 [list source [file join $dir test.tcl]]\n[list source [file join $dir test2.tcl]]} |
| 55 |
test package-1.9 {pkg::create gives correct output for 1 direct load} { |
| 56 |
::pkg::create -name foo -version 1.0 -load test.so |
| 57 |
} {package ifneeded foo 1.0 [list load [file join $dir test.so]]} |
| 58 |
test package-1.10 {pkg::create gives correct output for 2 direct loads} { |
| 59 |
::pkg::create -name foo -version 1.0 -load test.so -load test2.so |
| 60 |
} {package ifneeded foo 1.0 [list load [file join $dir test.so]]\n[list load [file join $dir test2.so]]} |
| 61 |
test package-1.11 {pkg::create gives correct output for 1 lazy source} { |
| 62 |
::pkg::create -name foo -version 1.0 -source {test.tcl {foo bar}} |
| 63 |
} {package ifneeded foo 1.0 [list tclPkgSetup $dir foo 1.0 {{test.tcl source {foo bar}}}]} |
| 64 |
test package-1.12 {pkg::create gives correct output for 2 lazy sources} { |
| 65 |
::pkg::create -name foo -version 1.0 -source {test.tcl {foo bar}} \ |
| 66 |
-source {test2.tcl {baz boo}} |
| 67 |
} {package ifneeded foo 1.0 [list tclPkgSetup $dir foo 1.0 {{test.tcl source {foo bar}} {test2.tcl source {baz boo}}}]} |
| 68 |
test package-1.13 {pkg::create gives correct output for 1 lazy load} { |
| 69 |
::pkg::create -name foo -version 1.0 -load {test.so {foo bar}} |
| 70 |
} {package ifneeded foo 1.0 [list tclPkgSetup $dir foo 1.0 {{test.so load {foo bar}}}]} |
| 71 |
test package-1.14 {pkg::create gives correct output for 2 lazy loads} { |
| 72 |
::pkg::create -name foo -version 1.0 -load {test.so {foo bar}} \ |
| 73 |
-load {test2.so {baz boo}} |
| 74 |
} {package ifneeded foo 1.0 [list tclPkgSetup $dir foo 1.0 {{test.so load {foo bar}} {test2.so load {baz boo}}}]} |
| 75 |
test package-1.15 {pkg::create gives correct output for 1 each, direct} { |
| 76 |
::pkg::create -name foo -version 1.0 -source test.tcl -load test2.so |
| 77 |
} {package ifneeded foo 1.0 [list load [file join $dir test2.so]]\n[list source [file join $dir test.tcl]]} |
| 78 |
test package-1.16 {pkg::create gives correct output for 1 direct, 1 lazy} { |
| 79 |
::pkg::create -name foo -version 1.0 -source test.tcl \ |
| 80 |
-source {test2.tcl {foo bar}} |
| 81 |
} {package ifneeded foo 1.0 [list source [file join $dir test.tcl]]\n[list tclPkgSetup $dir foo 1.0 {{test2.tcl source {foo bar}}}]} |
| 82 |
|
| 83 |
test package-2.1 {Tcl_PkgProvide procedure} { |
| 84 |
package forget t |
| 85 |
package provide t 2.3 |
| 86 |
} {} |
| 87 |
test package-2.2 {Tcl_PkgProvide procedure} -returnCodes error -setup { |
| 88 |
package forget t |
| 89 |
} -body { |
| 90 |
package provide t 2.3 |
| 91 |
package provide t 2.2 |
| 92 |
} -result {conflicting versions provided for package "t": 2.3, then 2.2} |
| 93 |
test package-2.3 {Tcl_PkgProvide procedure} -returnCodes error -setup { |
| 94 |
package forget t |
| 95 |
} -body { |
| 96 |
package provide t 2.3 |
| 97 |
package provide t 2.4 |
| 98 |
} -result {conflicting versions provided for package "t": 2.3, then 2.4} |
| 99 |
test package-2.4 {Tcl_PkgProvide procedure} -returnCodes error -setup { |
| 100 |
package forget t |
| 101 |
} -body { |
| 102 |
package provide t 2.3 |
| 103 |
package provide t 3.3 |
| 104 |
} -result {conflicting versions provided for package "t": 2.3, then 3.3} |
| 105 |
test package-2.5 {Tcl_PkgProvide procedure} -setup { |
| 106 |
package forget t |
| 107 |
} -body { |
| 108 |
package provide t 2.3 |
| 109 |
package provide t 2.3 |
| 110 |
} -result {} |
| 111 |
test package-2.6 {Tcl_PkgProvide procedure} { |
| 112 |
package forget t |
| 113 |
package provide t 2.3a1 |
| 114 |
} {} |
| 115 |
|
| 116 |
set n 0 |
| 117 |
foreach v { |
| 118 |
2.3k1 2a3a2 2ab3 2.a4 2.b4 2b.4 2a.4 2ba4 2a4b1 |
| 119 |
2b4a1 2b3b2 |
| 120 |
} { |
| 121 |
test package-2.7.$n {Tcl_PkgProvide procedure} -setup { |
| 122 |
package forget t |
| 123 |
} -returnCodes error -body " |
| 124 |
package provide t $v |
| 125 |
" -result "expected version number but got \"$v\"" |
| 126 |
incr n |
| 127 |
} |
| 128 |
|
| 129 |
test package-3.1 {Tcl_PkgRequire procedure, picking best version} -setup { |
| 130 |
package forget t |
| 131 |
set x xxx |
| 132 |
} -body { |
| 133 |
foreach i {1.4 3.4 2.3 2.4 2.2} { |
| 134 |
package ifneeded t $i "set x $i; package provide t $i" |
| 135 |
} |
| 136 |
package require t |
| 137 |
return $x |
| 138 |
} -result {3.4} |
| 139 |
test package-3.2 {Tcl_PkgRequire procedure, picking best version} -setup { |
| 140 |
package forget t |
| 141 |
set x xxx |
| 142 |
} -body { |
| 143 |
foreach i {1.4 3.4 2.3 2.4 2.2 3.5 3.2} { |
| 144 |
package ifneeded t $i "set x $i; package provide t $i" |
| 145 |
} |
| 146 |
package require t |
| 147 |
return $x |
| 148 |
} -result {3.5} |
| 149 |
test package-3.3 {Tcl_PkgRequire procedure, picking best version} -setup { |
| 150 |
package forget t |
| 151 |
set x xxx |
| 152 |
} -body { |
| 153 |
foreach i {3.5 2.1 2.3} { |
| 154 |
package ifneeded t $i "set x $i; package provide t $i" |
| 155 |
} |
| 156 |
package require t 2.2 |
| 157 |
return $x |
| 158 |
} -result {2.3} |
| 159 |
test package-3.4 {Tcl_PkgRequire procedure, picking best version} -setup { |
| 160 |
package forget t |
| 161 |
set x xxx |
| 162 |
} -body { |
| 163 |
foreach i {1.4 3.4 2.3 2.4 2.2} { |
| 164 |
package ifneeded t $i "set x $i; package provide t $i" |
| 165 |
} |
| 166 |
package require -exact t 2.3 |
| 167 |
return $x |
| 168 |
} -result {2.3} |
| 169 |
test package-3.5 {Tcl_PkgRequire procedure, picking best version} -setup { |
| 170 |
package forget t |
| 171 |
set x xxx |
| 172 |
} -body { |
| 173 |
foreach i {1.4 3.4 2.3 2.4 2.2} { |
| 174 |
package ifneeded t $i "set x $i; package provide t $i" |
| 175 |
} |
| 176 |
package require t 2.1 |
| 177 |
return $x |
| 178 |
} -result {2.4} |
| 179 |
test package-3.6 {Tcl_PkgRequire procedure, can't find suitable version} -setup { |
| 180 |
package forget t |
| 181 |
} -returnCodes error -body { |
| 182 |
package unknown {} |
| 183 |
foreach i {1.4 3.4 2.3 2.4 2.2} { |
| 184 |
package ifneeded t $i "set x $i" |
| 185 |
} |
| 186 |
package require t 2.5 |
| 187 |
} -result {can't find package t 2.5} |
| 188 |
test package-3.7 {Tcl_PkgRequire procedure, can't find suitable version} -setup { |
| 189 |
package forget t |
| 190 |
} -returnCodes error -body { |
| 191 |
package unknown {} |
| 192 |
foreach i {1.4 3.4 2.3 2.4 2.2} { |
| 193 |
package ifneeded t $i "set x $i" |
| 194 |
} |
| 195 |
package require t 4.1 |
| 196 |
} -result {can't find package t 4.1} |
| 197 |
test package-3.8 {Tcl_PkgRequire procedure, can't find suitable version} -setup { |
| 198 |
package forget t |
| 199 |
} -returnCodes error -body { |
| 200 |
package unknown {} |
| 201 |
foreach i {1.4 3.4 2.3 2.4 2.2} { |
| 202 |
package ifneeded t $i "set x $i" |
| 203 |
} |
| 204 |
package require -exact t 1.3 |
| 205 |
} -result {can't find package t exactly 1.3} |
| 206 |
test package-3.9 {Tcl_PkgRequire procedure, can't find suitable version} -setup { |
| 207 |
package forget t |
| 208 |
} -returnCodes error -body { |
| 209 |
package unknown {} |
| 210 |
package require t |
| 211 |
} -result {can't find package t} |
| 212 |
test package-3.10 {Tcl_PkgRequire procedure, error in ifneeded script} -setup { |
| 213 |
package forget t |
| 214 |
} -body { |
| 215 |
package ifneeded t 2.1 {package provide t 2.1; error "ifneeded test"} |
| 216 |
list [catch {package require t 2.1} msg] $msg $::errorInfo |
| 217 |
} -match glob -result {1 {ifneeded test} {ifneeded test |
| 218 |
while executing |
| 219 |
"error "ifneeded test"" |
| 220 |
("package ifneeded*" script) |
| 221 |
invoked from within |
| 222 |
"package require t 2.1"}} |
| 223 |
test package-3.11 {Tcl_PkgRequire procedure, ifneeded script doesn't provide package} -setup { |
| 224 |
package forget t |
| 225 |
set x xxx |
| 226 |
} -body { |
| 227 |
package ifneeded t 2.1 "set x invoked" |
| 228 |
list [catch {package require t 2.1} msg] $msg $x |
| 229 |
} -match glob -result {1 * invoked} |
| 230 |
test package-3.12 {Tcl_PkgRequire procedure, self-deleting script} -setup { |
| 231 |
package forget t |
| 232 |
set x xxx |
| 233 |
} -body { |
| 234 |
package ifneeded t 1.2 "package forget t; set x 1.2; package provide t 1.2" |
| 235 |
package require t 1.2 |
| 236 |
return $x |
| 237 |
} -result {1.2} |
| 238 |
test package-3.13 {Tcl_PkgRequire procedure, "package unknown" support} -setup { |
| 239 |
package forget t |
| 240 |
set x xxx |
| 241 |
} -body { |
| 242 |
proc pkgUnknown args { |
| 243 |
# args = name requirement |
| 244 |
# requirement = v-v (for exact version) |
| 245 |
global x |
| 246 |
set x $args |
| 247 |
package provide [lindex $args 0] [lindex [split [lindex $args 1] -] 0] |
| 248 |
} |
| 249 |
foreach i {1.4 3.4 2.3 2.4 2.2} { |
| 250 |
package ifneeded t $i "set x $i" |
| 251 |
} |
| 252 |
package unknown pkgUnknown |
| 253 |
package require -exact t 1.5 |
| 254 |
return $x |
| 255 |
} -cleanup { |
| 256 |
package unknown {} |
| 257 |
} -result {t 1.5-1.5} |
| 258 |
test package-3.14 {Tcl_PkgRequire procedure, "package unknown" support} -setup { |
| 259 |
package forget t |
| 260 |
set x xxx |
| 261 |
} -body { |
| 262 |
proc pkgUnknown args { |
| 263 |
package ifneeded t 1.2 "set x loaded; package provide t 1.2" |
| 264 |
} |
| 265 |
package unknown pkgUnknown |
| 266 |
list [package require t] $x |
| 267 |
} -cleanup { |
| 268 |
package unknown {} |
| 269 |
} -result {1.2 loaded} |
| 270 |
test package-3.15 {Tcl_PkgRequire procedure, "package unknown" support} -setup { |
| 271 |
package forget {a b} |
| 272 |
package unknown pkgUnknown |
| 273 |
set x xxx |
| 274 |
} -body { |
| 275 |
proc pkgUnknown args { |
| 276 |
global x |
| 277 |
set x $args |
| 278 |
package provide [lindex $args 0] 2.0 |
| 279 |
} |
| 280 |
package require {a b} |
| 281 |
return $x |
| 282 |
} -cleanup { |
| 283 |
package unknown {} |
| 284 |
} -result {{a b} 0-} |
| 285 |
test package-3.16 {Tcl_PkgRequire procedure, "package unknown" error} -setup { |
| 286 |
package forget t |
| 287 |
} -body { |
| 288 |
proc pkgUnknown args { |
| 289 |
error "testing package unknown" |
| 290 |
} |
| 291 |
package unknown pkgUnknown |
| 292 |
list [catch {package require t} msg] $msg $::errorInfo |
| 293 |
} -cleanup { |
| 294 |
package unknown {} |
| 295 |
} -result {1 {testing package unknown} {testing package unknown |
| 296 |
while executing |
| 297 |
"error "testing package unknown"" |
| 298 |
(procedure "pkgUnknown" line 2) |
| 299 |
invoked from within |
| 300 |
"pkgUnknown t 0-" |
| 301 |
("package unknown" script) |
| 302 |
invoked from within |
| 303 |
"package require t"}} |
| 304 |
test package-3.17 {Tcl_PkgRequire procedure, "package unknown" doesn't load package} -setup { |
| 305 |
package forget t |
| 306 |
set x xxx |
| 307 |
} -body { |
| 308 |
proc pkgUnknown args { |
| 309 |
global x |
| 310 |
set x $args |
| 311 |
} |
| 312 |
foreach i {1.4 3.4 2.3 2.4 2.2} { |
| 313 |
package ifneeded t $i "set x $i" |
| 314 |
} |
| 315 |
package unknown pkgUnknown |
| 316 |
list [catch {package require -exact t 1.5} msg] $msg $x |
| 317 |
} -cleanup { |
| 318 |
package unknown {} |
| 319 |
} -result {1 {can't find package t exactly 1.5} {t 1.5-1.5}} |
| 320 |
test package-3.18 {Tcl_PkgRequire procedure, version checks} -setup { |
| 321 |
package forget t |
| 322 |
} -body { |
| 323 |
package provide t 2.3 |
| 324 |
package require t |
| 325 |
} -result {2.3} |
| 326 |
test package-3.19 {Tcl_PkgRequire procedure, version checks} -setup { |
| 327 |
package forget t |
| 328 |
} -body { |
| 329 |
package provide t 2.3 |
| 330 |
package require t 2.1 |
| 331 |
} -result {2.3} |
| 332 |
test package-3.20 {Tcl_PkgRequire procedure, version checks} -setup { |
| 333 |
package forget t |
| 334 |
} -body { |
| 335 |
package provide t 2.3 |
| 336 |
package require t 2.3 |
| 337 |
} -result {2.3} |
| 338 |
test package-3.21 {Tcl_PkgRequire procedure, version checks} -setup { |
| 339 |
package forget t |
| 340 |
} -returnCodes error -body { |
| 341 |
package provide t 2.3 |
| 342 |
package require t 2.4 |
| 343 |
} -result {version conflict for package "t": have 2.3, need 2.4} |
| 344 |
test package-3.22 {Tcl_PkgRequire procedure, version checks} -setup { |
| 345 |
package forget t |
| 346 |
} -returnCodes error -body { |
| 347 |
package provide t 2.3 |
| 348 |
package require t 1.2 |
| 349 |
} -result {version conflict for package "t": have 2.3, need 1.2} |
| 350 |
test package-3.23 {Tcl_PkgRequire procedure, version checks} -setup { |
| 351 |
package forget t |
| 352 |
} -body { |
| 353 |
package provide t 2.3 |
| 354 |
package require -exact t 2.3 |
| 355 |
} -result {2.3} |
| 356 |
test package-3.24 {Tcl_PkgRequire procedure, version checks} -setup { |
| 357 |
package forget t |
| 358 |
} -returnCodes error -body { |
| 359 |
package provide t 2.3 |
| 360 |
package require -exact t 2.2 |
| 361 |
} -result {version conflict for package "t": have 2.3, need exactly 2.2} |
| 362 |
test package-3.25 {Tcl_PkgRequire procedure, error in ifneeded script} -setup { |
| 363 |
package forget t |
| 364 |
} -body { |
| 365 |
package ifneeded t 2.1 {package provide t 2.1; error "ifneeded test" EI} |
| 366 |
list [catch {package require t 2.1} msg] $msg $::errorInfo |
| 367 |
} -match glob -result {1 {ifneeded test} {EI |
| 368 |
("package ifneeded*" script) |
| 369 |
invoked from within |
| 370 |
"package require t 2.1"}} |
| 371 |
test package-3.26 {Tcl_PkgRequire procedure, error in ifneeded script} -setup { |
| 372 |
package forget t |
| 373 |
} -body { |
| 374 |
package ifneeded t 2.1 {package provide t 2.1; foreach x 1 {error "ifneeded test" EI}} |
| 375 |
list [catch {package require t 2.1} msg] $msg $::errorInfo |
| 376 |
} -match glob -result {1 {ifneeded test} {EI |
| 377 |
("foreach" body line 1) |
| 378 |
invoked from within |
| 379 |
"foreach x 1 {error "ifneeded test" EI}" |
| 380 |
("package ifneeded*" script) |
| 381 |
invoked from within |
| 382 |
"package require t 2.1"}} |
| 383 |
test package-3.27 {Tcl_PkgRequire: circular dependency} -setup { |
| 384 |
package forget foo |
| 385 |
} -body { |
| 386 |
package ifneeded foo 1 {package require foo 1} |
| 387 |
package require foo 1 |
| 388 |
} -cleanup { |
| 389 |
package forget foo |
| 390 |
} -returnCodes error -match glob -result {circular package dependency:*} |
| 391 |
test package-3.28 {Tcl_PkgRequire: circular dependency} -setup { |
| 392 |
package forget foo |
| 393 |
} -body { |
| 394 |
package ifneeded foo 1 {package require foo 2} |
| 395 |
package require foo 1 |
| 396 |
} -cleanup { |
| 397 |
package forget foo |
| 398 |
} -returnCodes error -match glob -result {circular package dependency:*} |
| 399 |
test package-3.29 {Tcl_PkgRequire: circular dependency} -setup { |
| 400 |
package forget foo |
| 401 |
package forget bar |
| 402 |
} -body { |
| 403 |
package ifneeded foo 1 {package require bar 1; package provide foo 1} |
| 404 |
package ifneeded bar 1 {package require foo 1; package provide bar 1} |
| 405 |
package require foo 1 |
| 406 |
} -cleanup { |
| 407 |
package forget foo |
| 408 |
package forget bar |
| 409 |
} -returnCodes error -match glob -result {circular package dependency:*} |
| 410 |
test package-3.30 {Tcl_PkgRequire: circular dependency} -setup { |
| 411 |
package forget foo |
| 412 |
package forget bar |
| 413 |
} -body { |
| 414 |
package ifneeded foo 1 {package require bar 1; package provide foo 1} |
| 415 |
package ifneeded foo 2 {package provide foo 2} |
| 416 |
package ifneeded bar 1 {package require foo 2; package provide bar 1} |
| 417 |
package require foo 1 |
| 418 |
} -cleanup { |
| 419 |
package forget foo |
| 420 |
package forget bar |
| 421 |
} -returnCodes error -match glob -result {circular package dependency:*} |
| 422 |
test package-3.31 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 423 |
package forget foo |
| 424 |
} -body { |
| 425 |
package ifneeded foo 1 {package provide foo 1; error foo} |
| 426 |
package require foo 1 |
| 427 |
} -cleanup { |
| 428 |
package forget foo |
| 429 |
} -returnCodes error -match glob -result foo |
| 430 |
test package-3.32 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 431 |
package forget foo |
| 432 |
} -body { |
| 433 |
package ifneeded foo 1 {package provide foo 1; error foo} |
| 434 |
catch {package require foo 1} |
| 435 |
package provide foo |
| 436 |
} -cleanup { |
| 437 |
package forget foo |
| 438 |
} -result {} |
| 439 |
test package-3.33 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 440 |
package forget foo |
| 441 |
} -body { |
| 442 |
package ifneeded foo 1 {package provide foo 2} |
| 443 |
package require foo 1 |
| 444 |
} -cleanup { |
| 445 |
package forget foo |
| 446 |
} -returnCodes error -match glob -result {attempt to provide package * failed:*} |
| 447 |
test package-3.34 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 448 |
package forget foo |
| 449 |
} -body { |
| 450 |
package ifneeded foo 1 {package provide foo 1.1} |
| 451 |
package require foo 1 |
| 452 |
} -cleanup { |
| 453 |
package forget foo |
| 454 |
} -returnCodes error -match glob -result {attempt to provide package * failed:*} |
| 455 |
test package-3.34.1 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 456 |
package forget foo |
| 457 |
} -body { |
| 458 |
package ifneeded foo 1.1 {package provide foo 1} |
| 459 |
package require foo 1 |
| 460 |
} -cleanup { |
| 461 |
package forget foo |
| 462 |
} -returnCodes error -match glob -result {attempt to provide package * failed:*} |
| 463 |
test package-3.34.2 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 464 |
package forget foo |
| 465 |
} -body { |
| 466 |
package ifneeded foo 1.1 {package provide foo 1} |
| 467 |
package require foo 1.1 |
| 468 |
} -cleanup { |
| 469 |
package forget foo |
| 470 |
} -returnCodes error -match glob -result {attempt to provide package * failed:*} |
| 471 |
test package-3.35 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 472 |
package forget foo |
| 473 |
} -body { |
| 474 |
package ifneeded foo 1 {} |
| 475 |
package require foo 1 |
| 476 |
} -cleanup { |
| 477 |
package forget foo |
| 478 |
} -returnCodes error -match glob -result {attempt to provide package * failed:*} |
| 479 |
test package-3.35.1 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 480 |
package forget foo |
| 481 |
} -body { |
| 482 |
package ifneeded foo 1 {break} |
| 483 |
package require foo 1 |
| 484 |
} -cleanup { |
| 485 |
package forget foo |
| 486 |
} -returnCodes error -match glob \ |
| 487 |
-result {attempt to provide package * failed: bad return code:*} |
| 488 |
test package-3.36 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 489 |
package forget foo |
| 490 |
} -body { |
| 491 |
package ifneeded foo 1 {continue} |
| 492 |
package require foo 1 |
| 493 |
} -cleanup { |
| 494 |
package forget foo |
| 495 |
} -returnCodes error -match glob \ |
| 496 |
-result {attempt to provide package * failed: bad return code:*} |
| 497 |
test package-3.37 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 498 |
package forget foo |
| 499 |
} -body { |
| 500 |
package ifneeded foo 1 {return} |
| 501 |
package require foo 1 |
| 502 |
} -cleanup { |
| 503 |
package forget foo |
| 504 |
} -returnCodes error -match glob \ |
| 505 |
-result {attempt to provide package * failed: bad return code:*} |
| 506 |
test package-3.38 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 507 |
package forget foo |
| 508 |
} -body { |
| 509 |
package ifneeded foo 1 {return -level 0 -code 10} |
| 510 |
package require foo 1 |
| 511 |
} -cleanup { |
| 512 |
package forget foo |
| 513 |
} -returnCodes error -match glob \ |
| 514 |
-result {attempt to provide package * failed: bad return code:*} |
| 515 |
test package-3.39 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 516 |
package forget foo |
| 517 |
set saveUnknown [package unknown] |
| 518 |
package unknown {package provide foo 2 ;#} |
| 519 |
} -body { |
| 520 |
package require foo 1 |
| 521 |
} -cleanup { |
| 522 |
package forget foo |
| 523 |
package unknown $saveUnknown |
| 524 |
} -returnCodes error -match glob -result * |
| 525 |
test package-3.40 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 526 |
package forget foo |
| 527 |
set saveUnknown [package unknown] |
| 528 |
package unknown {break ;#} |
| 529 |
} -body { |
| 530 |
package require foo 1 |
| 531 |
} -cleanup { |
| 532 |
package forget foo |
| 533 |
package unknown $saveUnknown |
| 534 |
} -returnCodes error -match glob -result {bad return code:*} |
| 535 |
test package-3.41 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 536 |
package forget foo |
| 537 |
set saveUnknown [package unknown] |
| 538 |
package unknown {continue ;#} |
| 539 |
} -body { |
| 540 |
package require foo 1 |
| 541 |
} -cleanup { |
| 542 |
package forget foo |
| 543 |
package unknown $saveUnknown |
| 544 |
} -returnCodes error -match glob -result {bad return code:*} |
| 545 |
test package-3.42 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 546 |
package forget foo |
| 547 |
set saveUnknown [package unknown] |
| 548 |
package unknown {return ;#} |
| 549 |
} -body { |
| 550 |
package require foo 1 |
| 551 |
} -cleanup { |
| 552 |
package forget foo |
| 553 |
package unknown $saveUnknown |
| 554 |
} -returnCodes error -match glob -result {bad return code:*} |
| 555 |
test package-3.43 {Tcl_PkgRequire: consistent return values (1162286)} -setup { |
| 556 |
package forget foo |
| 557 |
set saveUnknown [package unknown] |
| 558 |
package unknown {return -level 0 -code 10 ;#} |
| 559 |
} -body { |
| 560 |
package require foo 1 |
| 561 |
} -cleanup { |
| 562 |
package forget foo |
| 563 |
package unknown $saveUnknown |
| 564 |
} -returnCodes error -match glob -result {bad return code:*} |
| 565 |
test package-3.44 {Tcl_PkgRequire: exact version matching (1578344)} -setup { |
| 566 |
package provide demo 1.2.3 |
| 567 |
} -body { |
| 568 |
package require -exact demo 1.2 |
| 569 |
} -returnCodes error -cleanup { |
| 570 |
package forget demo |
| 571 |
} -result {version conflict for package "demo": have 1.2.3, need exactly 1.2} |
| 572 |
test package-3.50 {Tcl_PkgRequire procedure, picking best stable version} -setup { |
| 573 |
package forget t |
| 574 |
set x xxx |
| 575 |
} -body { |
| 576 |
foreach i {1.4 3.4 4.0a1 2.3 2.4 2.2} { |
| 577 |
package ifneeded t $i "set x $i; package provide t $i" |
| 578 |
} |
| 579 |
package require t |
| 580 |
return $x |
| 581 |
} -result {3.4} |
| 582 |
test package-3.51 {Tcl_PkgRequire procedure, picking best stable version} -setup { |
| 583 |
package forget t |
| 584 |
set x xxx |
| 585 |
} -body { |
| 586 |
foreach i {1.2b1 1.2 1.3a2 1.3} { |
| 587 |
package ifneeded t $i "set x $i; package provide t $i" |
| 588 |
} |
| 589 |
package require t |
| 590 |
return $x |
| 591 |
} -result {1.3} |
| 592 |
test package-3.52 {Tcl_PkgRequire procedure, picking best stable version} -setup { |
| 593 |
package forget t |
| 594 |
set x xxx |
| 595 |
} -body { |
| 596 |
foreach i {1.2b1 1.2 1.3 1.3a2} { |
| 597 |
package ifneeded t $i "set x $i; package provide t $i" |
| 598 |
} |
| 599 |
package require t |
| 600 |
return $x |
| 601 |
} -result {1.3} |
| 602 |
test pkg-3.53 {Tcl_PkgRequire procedure, picking best stable version} { |
| 603 |
package forget t |
| 604 |
foreach i {1.2b1 1.1} { |
| 605 |
package ifneeded t $i "set x $i; package provide t $i" |
| 606 |
} |
| 607 |
set x xxx |
| 608 |
package require t |
| 609 |
set x |
| 610 |
} {1.1} |
| 611 |
test package-3.54 {Tcl_PkgRequire procedure, coroutine support} -setup { |
| 612 |
package forget t |
| 613 |
} -body { |
| 614 |
coroutine coro1 apply {{} { |
| 615 |
package ifneeded t 2.1 { |
| 616 |
yield |
| 617 |
package provide t 2.1 |
| 618 |
} |
| 619 |
package require t 2.1 |
| 620 |
}} |
| 621 |
list [catch {coro1} msg] $msg |
| 622 |
} -match glob -result {0 2.1} |
| 623 |
|
| 624 |
|
| 625 |
test package-4.1 {Tcl_PackageCmd procedure} -returnCodes error -body { |
| 626 |
package |
| 627 |
} -result {wrong # args: should be "package option ?arg ...?"} |
| 628 |
test package-4.2 {Tcl_PackageCmd procedure, "forget" option} { |
| 629 |
package forget {*}[package names] |
| 630 |
package names |
| 631 |
} {} |
| 632 |
test package-4.3 {Tcl_PackageCmd procedure, "forget" option} { |
| 633 |
package forget {*}[package names] |
| 634 |
package forget foo |
| 635 |
} {} |
| 636 |
test package-4.4 {Tcl_PackageCmd procedure, "forget" option} -setup { |
| 637 |
package forget {*}[package names] |
| 638 |
set result {} |
| 639 |
} -body { |
| 640 |
package ifneeded t 1.1 {first script} |
| 641 |
package ifneeded t 2.3 {second script} |
| 642 |
package ifneeded x 1.4 {x's script} |
| 643 |
lappend result [lsort [package names]] [package versions t] |
| 644 |
package forget t |
| 645 |
lappend result [lsort [package names]] [package versions t] |
| 646 |
} -result {{t x} {1.1 2.3} x {}} |
| 647 |
test package-4.5 {Tcl_PackageCmd procedure, "forget" option} -setup { |
| 648 |
package forget {*}[package names] |
| 649 |
} -body { |
| 650 |
package ifneeded a 1.1 {first script} |
| 651 |
package ifneeded b 2.3 {second script} |
| 652 |
package ifneeded c 1.4 {third script} |
| 653 |
package forget |
| 654 |
set result [list [lsort [package names]]] |
| 655 |
package forget a c |
| 656 |
lappend result [lsort [package names]] |
| 657 |
} -result {{a b c} b} |
| 658 |
test package-4.5.1 {Tcl_PackageCmd procedure, "forget" option} -body { |
| 659 |
# Test for Bug 415273 |
| 660 |
package ifneeded a 1 "I should have been forgotten" |
| 661 |
package forget no-such-package a |
| 662 |
package ifneeded a 1 |
| 663 |
} -cleanup { |
| 664 |
package forget a |
| 665 |
} -result {} |
| 666 |
test package-4.6 {Tcl_PackageCmd procedure, "ifneeded" option} -body { |
| 667 |
package ifneeded a |
| 668 |
} -returnCodes error -result {wrong # args: should be "package ifneeded package version ?script?"} |
| 669 |
test package-4.7 {Tcl_PackageCmd procedure, "ifneeded" option} -body { |
| 670 |
package ifneeded a b c d |
| 671 |
} -returnCodes error -result {wrong # args: should be "package ifneeded package version ?script?"} |
| 672 |
test package-4.8 {Tcl_PackageCmd procedure, "ifneeded" option} -body { |
| 673 |
package ifneeded t xyz |
| 674 |
} -returnCodes error -result {expected version number but got "xyz"} |
| 675 |
test package-4.9 {Tcl_PackageCmd procedure, "ifneeded" option} { |
| 676 |
package forget {*}[package names] |
| 677 |
list [package ifneeded foo 1.1] [package names] |
| 678 |
} {{} {}} |
| 679 |
test package-4.10 {Tcl_PackageCmd procedure, "ifneeded" option} -setup { |
| 680 |
package forget t |
| 681 |
} -body { |
| 682 |
package ifneeded t 1.4 "script for t 1.4" |
| 683 |
list [package names] [package ifneeded t 1.4] [package versions t] |
| 684 |
} -result {t {script for t 1.4} 1.4} |
| 685 |
test package-4.11 {Tcl_PackageCmd procedure, "ifneeded" option} -setup { |
| 686 |
package forget t |
| 687 |
} -body { |
| 688 |
package ifneeded t 1.4 "script for t 1.4" |
| 689 |
list [package ifneeded t 1.5] [package names] [package versions t] |
| 690 |
} -result {{} t 1.4} |
| 691 |
test package-4.12 {Tcl_PackageCmd procedure, "ifneeded" option} -setup { |
| 692 |
package forget t |
| 693 |
} -body { |
| 694 |
package ifneeded t 1.4 "script for t 1.4" |
| 695 |
package ifneeded t 1.4 "second script for t 1.4" |
| 696 |
list [package ifneeded t 1.4] [package names] [package versions t] |
| 697 |
} -result {{second script for t 1.4} t 1.4} |
| 698 |
test package-4.13 {Tcl_PackageCmd procedure, "ifneeded" option} -setup { |
| 699 |
package forget t |
| 700 |
} -body { |
| 701 |
package ifneeded t 1.4 "script for t 1.4" |
| 702 |
package ifneeded t 1.2 "second script" |
| 703 |
package ifneeded t 3.1 "last script" |
| 704 |
list [package ifneeded t 1.2] [package versions t] |
| 705 |
} -result {{second script} {1.4 1.2 3.1}} |
| 706 |
test package-4.14 {Tcl_PackageCmd procedure, "names" option} -body { |
| 707 |
package names a |
| 708 |
} -returnCodes error -result {wrong # args: should be "package names"} |
| 709 |
test package-4.15 {Tcl_PackageCmd procedure, "names" option} { |
| 710 |
package forget {*}[package names] |
| 711 |
package names |
| 712 |
} {} |
| 713 |
test package-4.16 {Tcl_PackageCmd procedure, "names" option} -setup { |
| 714 |
package forget {*}[package names] |
| 715 |
} -body { |
| 716 |
package ifneeded x 1.2 {dummy} |
| 717 |
package provide x 1.3 |
| 718 |
package provide y 2.4 |
| 719 |
catch {package require z 47.16} |
| 720 |
lsort [package names] |
| 721 |
} -result {x y} |
| 722 |
test package-4.17 {Tcl_PackageCmd procedure, "provide" option} -body { |
| 723 |
package provide |
| 724 |
} -returnCodes error -result {wrong # args: should be "package provide package ?version?"} |
| 725 |
test package-4.18 {Tcl_PackageCmd procedure, "provide" option} -body { |
| 726 |
package provide a b c |
| 727 |
} -returnCodes error -result {wrong # args: should be "package provide package ?version?"} |
| 728 |
test package-4.19 {Tcl_PackageCmd procedure, "provide" option} -setup { |
| 729 |
package forget t |
| 730 |
} -body { |
| 731 |
package provide t |
| 732 |
} -result {} |
| 733 |
test package-4.20 {Tcl_PackageCmd procedure, "provide" option} -setup { |
| 734 |
package forget t |
| 735 |
} -body { |
| 736 |
package provide t 2.3 |
| 737 |
package provide t |
| 738 |
} -result {2.3} |
| 739 |
test package-4.21 {Tcl_PackageCmd procedure, "provide" option} -setup { |
| 740 |
package forget t |
| 741 |
} -returnCodes error -body { |
| 742 |
package provide t a.b |
| 743 |
} -result {expected version number but got "a.b"} |
| 744 |
test package-4.22 {Tcl_PackageCmd procedure, "require" option} -returnCodes error -body { |
| 745 |
package require |
| 746 |
} -result {wrong # args: should be "package require ?-exact? package ?requirement ...?"} |
| 747 |
test package-4.24 {Tcl_PackageCmd procedure, "require" option} -body { |
| 748 |
package require -exact a b c |
| 749 |
# Exact syntax: -exact name version |
| 750 |
# name ?requirement ...? |
| 751 |
} -returnCodes error -result {wrong # args: should be "package require ?-exact? package ?requirement ...?"} |
| 752 |
test package-4.26 {Tcl_PackageCmd procedure, "require" option} -body { |
| 753 |
package require x a.b |
| 754 |
} -returnCodes error -result {expected version number but got "a.b"} |
| 755 |
test package-4.27 {Tcl_PackageCmd procedure, "require" option} -body { |
| 756 |
package require -exact x a.b |
| 757 |
} -returnCodes error -result {expected version number but got "a.b"} |
| 758 |
test package-4.28 {Tcl_PackageCmd procedure, "require" option} -body { |
| 759 |
package require -exact x |
| 760 |
} -returnCodes error -result {wrong # args: should be "package require ?-exact? package ?requirement ...?"} |
| 761 |
test package-4.29 {Tcl_PackageCmd procedure, "require" option} -body { |
| 762 |
package require -exact |
| 763 |
} -returnCodes error -result {wrong # args: should be "package require ?-exact? package ?requirement ...?"} |
| 764 |
test package-4.30 {Tcl_PackageCmd procedure, "require" option} -setup { |
| 765 |
package forget t |
| 766 |
} -body { |
| 767 |
package provide t 2.3 |
| 768 |
package require t 2.1 |
| 769 |
} -result {2.3} |
| 770 |
test package-4.31 {Tcl_PackageCmd procedure, "require" option} -setup { |
| 771 |
package forget t |
| 772 |
} -body { |
| 773 |
package require t |
| 774 |
} -returnCodes error -result {can't find package t} |
| 775 |
test package-4.32 {Tcl_PackageCmd procedure, "require" option} -setup { |
| 776 |
package forget t |
| 777 |
} -body { |
| 778 |
package ifneeded t 2.3 "error {synthetic error}" |
| 779 |
package require t 2.3 |
| 780 |
} -returnCodes error -result {synthetic error} |
| 781 |
test package-4.33 {Tcl_PackageCmd procedure, "unknown" option} -body { |
| 782 |
package unknown a b |
| 783 |
} -returnCodes error -result {wrong # args: should be "package unknown ?command?"} |
| 784 |
test package-4.34 {Tcl_PackageCmd procedure, "unknown" option} { |
| 785 |
package unknown "test script" |
| 786 |
package unknown |
| 787 |
} {test script} |
| 788 |
test package-4.35 {Tcl_PackageCmd procedure, "unknown" option} { |
| 789 |
package unknown "test script" |
| 790 |
package unknown {} |
| 791 |
package unknown |
| 792 |
} {} |
| 793 |
test package-4.36 {Tcl_PackageCmd procedure, "vcompare" option} -body { |
| 794 |
package vcompare a |
| 795 |
} -returnCodes error -result {wrong # args: should be "package vcompare version1 version2"} |
| 796 |
test package-4.37 {Tcl_PackageCmd procedure, "vcompare" option} -body { |
| 797 |
package vcompare a b c |
| 798 |
} -returnCodes error -result {wrong # args: should be "package vcompare version1 version2"} |
| 799 |
test package-4.38 {Tcl_PackageCmd procedure, "vcompare" option} -body { |
| 800 |
package vcompare x.y 3.4 |
| 801 |
} -returnCodes error -result {expected version number but got "x.y"} |
| 802 |
test package-4.39 {Tcl_PackageCmd procedure, "vcompare" option} -body { |
| 803 |
package vcompare 2.1 a.b |
| 804 |
} -returnCodes error -result {expected version number but got "a.b"} |
| 805 |
test package-4.40 {Tcl_PackageCmd procedure, "vcompare" option} { |
| 806 |
package vc 2.1 2.3 |
| 807 |
} {-1} |
| 808 |
test package-4.41 {Tcl_PackageCmd procedure, "vcompare" option} { |
| 809 |
package vc 2.2.4 2.2.4 |
| 810 |
} {0} |
| 811 |
test package-4.42 {Tcl_PackageCmd procedure, "versions" option} -body { |
| 812 |
package versions |
| 813 |
} -returnCodes error -result {wrong # args: should be "package versions package"} |
| 814 |
test package-4.43 {Tcl_PackageCmd procedure, "versions" option} -body { |
| 815 |
package versions a b |
| 816 |
} -returnCodes error -result {wrong # args: should be "package versions package"} |
| 817 |
test package-4.44 {Tcl_PackageCmd procedure, "versions" option} -body { |
| 818 |
package forget t |
| 819 |
package versions t |
| 820 |
} -result {} |
| 821 |
test package-4.45 {Tcl_PackageCmd procedure, "versions" option} -setup { |
| 822 |
package forget t |
| 823 |
} -body { |
| 824 |
package provide t 2.3 |
| 825 |
package versions t |
| 826 |
} -result {} |
| 827 |
test package-4.46 {Tcl_PackageCmd procedure, "versions" option} -setup { |
| 828 |
package forget t |
| 829 |
} -body { |
| 830 |
package ifneeded t 2.3 x |
| 831 |
package ifneeded t 2.4 y |
| 832 |
package versions t |
| 833 |
} -result {2.3 2.4} |
| 834 |
test package-4.47 {Tcl_PackageCmd procedure, "vsatisfies" option} -body { |
| 835 |
package vsatisfies a |
| 836 |
} -returnCodes error -result {wrong # args: should be "package vsatisfies version ?requirement ...?"} |
| 837 |
test package-4.49 {Tcl_PackageCmd procedure, "vsatisfies" option} -body { |
| 838 |
package vsatisfies x.y 3.4 |
| 839 |
} -returnCodes error -result {expected version number but got "x.y"} |
| 840 |
test package-4.50 {Tcl_PackageCmd procedure, "vsatisfies" option} -body { |
| 841 |
package vcompare 2.1 a.b |
| 842 |
} -returnCodes error -result {expected version number but got "a.b"} |
| 843 |
test package-4.51 {Tcl_PackageCmd procedure, "vsatisfies" option} { |
| 844 |
package vs 2.3 2.1 |
| 845 |
} {1} |
| 846 |
test package-4.52 {Tcl_PackageCmd procedure, "vsatisfies" option} { |
| 847 |
package vs 2.3 1.2 |
| 848 |
} {0} |
| 849 |
test package-4.53 {Tcl_PackageCmd procedure, "versions" option} -body { |
| 850 |
package foo |
| 851 |
} -returnCodes error -result {bad option "foo": must be forget, ifneeded, names, prefer, present, provide, require, unknown, vcompare, versions, or vsatisfies} |
| 852 |
test package-4.54 {Tcl_PackageCmd procedure, "vsatisfies" option} -body { |
| 853 |
package vsatisfies 2.1 2.1-3.2-4.5 |
| 854 |
} -returnCodes error -result {expected versionMin-versionMax but got "2.1-3.2-4.5"} |
| 855 |
test package-4.55 {Tcl_PackageCmd procedure, "vsatisfies" option} -body { |
| 856 |
package vsatisfies 2.1 3.2-x.y |
| 857 |
} -returnCodes error -result {expected version number but got "x.y"} |
| 858 |
test package-4.56 {Tcl_PackageCmd procedure, "vsatisfies" option} -body { |
| 859 |
package vsatisfies 2.1 x.y-3.2 |
| 860 |
} -returnCodes error -result {expected version number but got "x.y"} |
| 861 |
|
| 862 |
# No tests for FindPackage; can't think up anything detectable errors. |
| 863 |
|
| 864 |
test package-5.1 {TclFreePackageInfo procedure} { |
| 865 |
interp create child |
| 866 |
child eval { |
| 867 |
package ifneeded t 2.3 x |
| 868 |
package ifneeded t 2.4 y |
| 869 |
package ifneeded x 3.1 z |
| 870 |
package provide q 4.3 |
| 871 |
package unknown "will this get freed?" |
| 872 |
} |
| 873 |
interp delete child |
| 874 |
} {} |
| 875 |
test package-5.2 {TclFreePackageInfo procedure} -body { |
| 876 |
interp create foo |
| 877 |
foo eval { |
| 878 |
package ifneeded t 2.3 x |
| 879 |
package ifneeded t 2.4 y |
| 880 |
package ifneeded x 3.1 z |
| 881 |
package provide q 4.3 |
| 882 |
} |
| 883 |
foo alias z kill |
| 884 |
proc kill {} { |
| 885 |
interp delete foo |
| 886 |
} |
| 887 |
foo eval package require x 3.1 |
| 888 |
} -returnCodes error -match glob -result * |
| 889 |
|
| 890 |
test package-6.1 {CheckVersion procedure} { |
| 891 |
package vcompare 1 2.1 |
| 892 |
} -1 |
| 893 |
test package-6.2 {CheckVersion procedure} -body { |
| 894 |
package vcompare .1 2.1 |
| 895 |
} -returnCodes error -result {expected version number but got ".1"} |
| 896 |
test package-6.3 {CheckVersion procedure} -body { |
| 897 |
package vcompare 111.2a.3 2.1 |
| 898 |
} -returnCodes error -result {expected version number but got "111.2a.3"} |
| 899 |
test package-6.4 {CheckVersion procedure} -body { |
| 900 |
package vcompare 1.2.3. 2.1 |
| 901 |
} -returnCodes error -result {expected version number but got "1.2.3."} |
| 902 |
test package-6.5 {CheckVersion procedure} -body { |
| 903 |
package vcompare 1.2..3 2.1 |
| 904 |
} -returnCodes error -result {expected version number but got "1.2..3"} |
| 905 |
|
| 906 |
test package-7.1 {ComparePkgVersions procedure} { |
| 907 |
package vcompare 1.23 1.22 |
| 908 |
} {1} |
| 909 |
test package-7.2 {ComparePkgVersions procedure} { |
| 910 |
package vcompare 1.22.1.2.3 1.22.1.2.3 |
| 911 |
} {0} |
| 912 |
test package-7.3 {ComparePkgVersions procedure} { |
| 913 |
package vcompare 1.21 1.22 |
| 914 |
} {-1} |
| 915 |
test package-7.4 {ComparePkgVersions procedure} { |
| 916 |
package vcompare 1.21 1.21.2 |
| 917 |
} {-1} |
| 918 |
test package-7.5 {ComparePkgVersions procedure} { |
| 919 |
package vcompare 1.21.1 1.21 |
| 920 |
} {1} |
| 921 |
test package-7.6 {ComparePkgVersions procedure} { |
| 922 |
package vsatisfies 1.21.1 1.21 |
| 923 |
} {1} |
| 924 |
test package-7.7 {ComparePkgVersions procedure} { |
| 925 |
package vsatisfies 2.22.3 1.21 |
| 926 |
} {0} |
| 927 |
test package-7.8 {ComparePkgVersions procedure} { |
| 928 |
package vsatisfies 1 1 |
| 929 |
} {1} |
| 930 |
test package-7.9 {ComparePkgVersions procedure} { |
| 931 |
package vsatisfies 2 1 |
| 932 |
} {0} |
| 933 |
|
| 934 |
test package-8.1 {Tcl_PkgPresent procedure, any version} -setup { |
| 935 |
package forget t |
| 936 |
} -body { |
| 937 |
package provide t 2.4 |
| 938 |
package present t |
| 939 |
} -result {2.4} |
| 940 |
test package-8.2 {Tcl_PkgPresent procedure, correct version} -setup { |
| 941 |
package forget t |
| 942 |
} -body { |
| 943 |
package provide t 2.4 |
| 944 |
package present t 2.4 |
| 945 |
} -result {2.4} |
| 946 |
test package-8.3 {Tcl_PkgPresent procedure, satisfying version} -setup { |
| 947 |
package forget t |
| 948 |
} -body { |
| 949 |
package provide t 2.4 |
| 950 |
package present t 2.0 |
| 951 |
} -result {2.4} |
| 952 |
test package-8.4 {Tcl_PkgPresent procedure, not satisfying version} -setup { |
| 953 |
package forget t |
| 954 |
} -returnCodes error -body { |
| 955 |
package provide t 2.4 |
| 956 |
package present t 2.6 |
| 957 |
} -result {version conflict for package "t": have 2.4, need 2.6} |
| 958 |
test package-8.5 {Tcl_PkgPresent procedure, not satisfying version} -setup { |
| 959 |
package forget t |
| 960 |
} -returnCodes error -body { |
| 961 |
package provide t 2.4 |
| 962 |
package present t 1.0 |
| 963 |
} -result {version conflict for package "t": have 2.4, need 1.0} |
| 964 |
test package-8.6 {Tcl_PkgPresent procedure, exact version} -setup { |
| 965 |
package forget t |
| 966 |
} -body { |
| 967 |
package provide t 2.4 |
| 968 |
package present -exact t 2.4 |
| 969 |
} -result {2.4} |
| 970 |
test package-8.7 {Tcl_PkgPresent procedure, not exact version} -setup { |
| 971 |
package forget t |
| 972 |
} -returnCodes error -body { |
| 973 |
package provide t 2.4 |
| 974 |
package present -exact t 2.3 |
| 975 |
} -result {version conflict for package "t": have 2.4, need exactly 2.3} |
| 976 |
test package-8.8 {Tcl_PkgPresent procedure, unknown package} -body { |
| 977 |
package forget t |
| 978 |
package present t |
| 979 |
} -returnCodes error -result {package t is not present} |
| 980 |
test package-8.9 {Tcl_PkgPresent procedure, unknown package} -body { |
| 981 |
package forget t |
| 982 |
package present t 2.4 |
| 983 |
} -returnCodes error -result {package t 2.4 is not present} |
| 984 |
test package-8.10 {Tcl_PkgPresent procedure, unknown package} -body { |
| 985 |
package forget t |
| 986 |
package present -exact t 2.4 |
| 987 |
} -returnCodes error -result {package t 2.4 is not present} |
| 988 |
test package-8.11 {Tcl_PackageCmd procedure, "present" option} -body { |
| 989 |
package present |
| 990 |
} -returnCodes error -result {wrong # args: should be "package present ?-exact? package ?requirement ...?"} |
| 991 |
test package-8.12 {Tcl_PackageCmd procedure, "present" option} -body { |
| 992 |
package present a b c |
| 993 |
} -returnCodes error -result {expected version number but got "b"} |
| 994 |
test package-8.13 {Tcl_PackageCmd procedure, "present" option} -body { |
| 995 |
package present -exact a b c |
| 996 |
} -returnCodes error -result {wrong # args: should be "package present ?-exact? package ?requirement ...?"} |
| 997 |
test package-8.14 {Tcl_PackageCmd procedure, "present" option} -body { |
| 998 |
package present -bs a b |
| 999 |
} -returnCodes error -result {expected version number but got "a"} |
| 1000 |
test package-8.15 {Tcl_PackageCmd procedure, "present" option} -body { |
| 1001 |
package present x a.b |
| 1002 |
} -returnCodes error -result {expected version number but got "a.b"} |
| 1003 |
test package-8.16 {Tcl_PackageCmd procedure, "present" option} -body { |
| 1004 |
package present -exact x a.b |
| 1005 |
} -returnCodes error -result {expected version number but got "a.b"} |
| 1006 |
test package-8.17 {Tcl_PackageCmd procedure, "present" option} -body { |
| 1007 |
package present -exact x |
| 1008 |
} -returnCodes error -result {wrong # args: should be "package present ?-exact? package ?requirement ...?"} |
| 1009 |
test package-8.18 {Tcl_PackageCmd procedure, "present" option} -body { |
| 1010 |
package present -exact |
| 1011 |
} -returnCodes error -result {wrong # args: should be "package present ?-exact? package ?requirement ...?"} |
| 1012 |
|
| 1013 |
set n 0 |
| 1014 |
foreach {r p vs vc} { |
| 1015 |
8.5a0 8.5a5 1 -1 |
| 1016 |
8.5a0 8.5b1 1 -1 |
| 1017 |
8.5a0 8.5.1 1 -1 |
| 1018 |
8.5a0 8.6a0 1 -1 |
| 1019 |
8.5a0 8.6b0 1 -1 |
| 1020 |
8.5a0 8.6.0 1 -1 |
| 1021 |
8.5a6 8.5a5 0 1 |
| 1022 |
8.5a6 8.5b1 1 -1 |
| 1023 |
8.5a6 8.5.1 1 -1 |
| 1024 |
8.5a6 8.6a0 1 -1 |
| 1025 |
8.5a6 8.6b0 1 -1 |
| 1026 |
8.5a6 8.6.0 1 -1 |
| 1027 |
8.5b0 8.5a5 0 1 |
| 1028 |
8.5b0 8.5b1 1 -1 |
| 1029 |
8.5b0 8.5.1 1 -1 |
| 1030 |
8.5b0 8.6a0 1 -1 |
| 1031 |
8.5b0 8.6b0 1 -1 |
| 1032 |
8.5b0 8.6.0 1 -1 |
| 1033 |
8.5b2 8.5a5 0 1 |
| 1034 |
8.5b2 8.5b1 0 1 |
| 1035 |
8.5b2 8.5.1 1 -1 |
| 1036 |
8.5b2 8.6a0 1 -1 |
| 1037 |
8.5b2 8.6b0 1 -1 |
| 1038 |
8.5b2 8.6.0 1 -1 |
| 1039 |
8.5 8.5a5 1 1 |
| 1040 |
8.5 8.5b1 1 1 |
| 1041 |
8.5 8.5.1 1 -1 |
| 1042 |
8.5 8.6a0 1 -1 |
| 1043 |
8.5 8.6b0 1 -1 |
| 1044 |
8.5 8.6.0 1 -1 |
| 1045 |
8.5.0 8.5a5 0 1 |
| 1046 |
8.5.0 8.5b1 0 1 |
| 1047 |
8.5.0 8.5.1 1 -1 |
| 1048 |
8.5.0 8.6a0 1 -1 |
| 1049 |
8.5.0 8.6b0 1 -1 |
| 1050 |
8.5.0 8.6.0 1 -1 |
| 1051 |
10 8 0 1 |
| 1052 |
8 10 0 -1 |
| 1053 |
0.0.1.2 0.1.2 1 -1 |
| 1054 |
} { |
| 1055 |
test package-9.$n {package vsatisfies} { |
| 1056 |
package vsatisfies $p $r |
| 1057 |
} $vs |
| 1058 |
test package-10.$n {package vcompare} { |
| 1059 |
package vcompare $r $p |
| 1060 |
} $vc |
| 1061 |
incr n |
| 1062 |
} |
| 1063 |
|
| 1064 |
test package-11.0.0 {package vcompare at 32bit boundary} { |
| 1065 |
package vcompare [expr {1<<31}] [expr {(1<<31)-1}] |
| 1066 |
} 1 |
| 1067 |
|
| 1068 |
# Note: It is correct that the result of the very first test, i.e. "5.0 5.0a0" |
| 1069 |
# is 1, i.e. that version 5.0a0 satisfies a 5.0 requirement. |
| 1070 |
|
| 1071 |
# The requirement "5.0" internally translates first to "5.0-6", and then to |
| 1072 |
# its final form of "5.0a0-6a0". These translations are explicitly specified |
| 1073 |
# by the TIP (Search for "padded/extended internally with 'a0'"). This was |
| 1074 |
# done intentionally for exactly the tested case, that an alpha package can |
| 1075 |
# satisfy a requirement for the regular package. An example would be a package |
| 1076 |
# FOO requiring Tcl 8.X for its operation. It can be used with Tcl 8.Xa0. |
| 1077 |
# Without our translation that would not be possible. |
| 1078 |
|
| 1079 |
set n 0 |
| 1080 |
foreach {required provided satisfied} { |
| 1081 |
5.0 5.0a0 1 |
| 1082 |
5.0a0 5.0 1 |
| 1083 |
|
| 1084 |
8.5a0- 8.5a5 1 |
| 1085 |
8.5a0- 8.5b1 1 |
| 1086 |
8.5a0- 8.5.1 1 |
| 1087 |
8.5a0- 8.6a0 1 |
| 1088 |
8.5a0- 8.6b0 1 |
| 1089 |
8.5a0- 8.6.0 1 |
| 1090 |
8.5a6- 8.5a5 0 |
| 1091 |
8.5a6- 8.5b1 1 |
| 1092 |
8.5a6- 8.5.1 1 |
| 1093 |
8.5a6- 8.6a0 1 |
| 1094 |
8.5a6- 8.6b0 1 |
| 1095 |
8.5a6- 8.6.0 1 |
| 1096 |
8.5b0- 8.5a5 0 |
| 1097 |
8.5b0- 8.5b1 1 |
| 1098 |
8.5b0- 8.5.1 1 |
| 1099 |
8.5b0- 8.6a0 1 |
| 1100 |
8.5b0- 8.6b0 1 |
| 1101 |
8.5b0- 8.6.0 1 |
| 1102 |
8.5b2- 8.5a5 0 |
| 1103 |
8.5b2- 8.5b1 0 |
| 1104 |
8.5b2- 8.5.1 1 |
| 1105 |
8.5b2- 8.6a0 1 |
| 1106 |
8.5b2- 8.6b0 1 |
| 1107 |
8.5b2- 8.6.0 1 |
| 1108 |
8.5- 8.5a5 1 |
| 1109 |
8.5- 8.5b1 1 |
| 1110 |
8.5- 8.5.1 1 |
| 1111 |
8.5- 8.6a0 1 |
| 1112 |
8.5- 8.6b0 1 |
| 1113 |
8.5- 8.6.0 1 |
| 1114 |
8.5.0- 8.5a5 0 |
| 1115 |
8.5.0- 8.5b1 0 |
| 1116 |
8.5.0- 8.5.1 1 |
| 1117 |
8.5.0- 8.6a0 1 |
| 1118 |
8.5.0- 8.6b0 1 |
| 1119 |
8.5.0- 8.6.0 1 |
| 1120 |
8.5a0-7 8.5a5 0 |
| 1121 |
8.5a0-7 8.5b1 0 |
| 1122 |
8.5a0-7 8.5.1 0 |
| 1123 |
8.5a0-7 8.6a0 0 |
| 1124 |
8.5a0-7 8.6b0 0 |
| 1125 |
8.5a0-7 8.6.0 0 |
| 1126 |
8.5a6-7 8.5a5 0 |
| 1127 |
8.5a6-7 8.5b1 0 |
| 1128 |
8.5a6-7 8.5.1 0 |
| 1129 |
8.5a6-7 8.6a0 0 |
| 1130 |
8.5a6-7 8.6b0 0 |
| 1131 |
8.5a6-7 8.6.0 0 |
| 1132 |
8.5b0-7 8.5a5 0 |
| 1133 |
8.5b0-7 8.5b1 0 |
| 1134 |
8.5b0-7 8.5.1 0 |
| 1135 |
8.5b0-7 8.6a0 0 |
| 1136 |
8.5b0-7 8.6b0 0 |
| 1137 |
8.5b0-7 8.6.0 0 |
| 1138 |
8.5b2-7 8.5a5 0 |
| 1139 |
8.5b2-7 8.5b1 0 |
| 1140 |
8.5b2-7 8.5.1 0 |
| 1141 |
8.5b2-7 8.6a0 0 |
| 1142 |
8.5b2-7 8.6b0 0 |
| 1143 |
8.5b2-7 8.6.0 0 |
| 1144 |
8.5-7 8.5a5 0 |
| 1145 |
8.5-7 8.5b1 0 |
| 1146 |
8.5-7 8.5.1 0 |
| 1147 |
8.5-7 8.6a0 0 |
| 1148 |
8.5-7 8.6b0 0 |
| 1149 |
8.5-7 8.6.0 0 |
| 1150 |
8.5.0-7 8.5a5 0 |
| 1151 |
8.5.0-7 8.5b1 0 |
| 1152 |
8.5.0-7 8.5.1 0 |
| 1153 |
8.5.0-7 8.6a0 0 |
| 1154 |
8.5.0-7 8.6b0 0 |
| 1155 |
8.5.0-7 8.6.0 0 |
| 1156 |
8.5a0-8.6.1 8.5a5 1 |
| 1157 |
8.5a0-8.6.1 8.5b1 1 |
| 1158 |
8.5a0-8.6.1 8.5.1 1 |
| 1159 |
8.5a0-8.6.1 8.6a0 1 |
| 1160 |
8.5a0-8.6.1 8.6b0 1 |
| 1161 |
8.5a0-8.6.1 8.6.0 1 |
| 1162 |
8.5a6-8.6.1 8.5a5 0 |
| 1163 |
8.5a6-8.6.1 8.5b1 1 |
| 1164 |
8.5a6-8.6.1 8.5.1 1 |
| 1165 |
8.5a6-8.6.1 8.6a0 1 |
| 1166 |
8.5a6-8.6.1 8.6b0 1 |
| 1167 |
8.5a6-8.6.1 8.6.0 1 |
| 1168 |
8.5b0-8.6.1 8.5a5 0 |
| 1169 |
8.5b0-8.6.1 8.5b1 1 |
| 1170 |
8.5b0-8.6.1 8.5.1 1 |
| 1171 |
8.5b0-8.6.1 8.6a0 1 |
| 1172 |
8.5b0-8.6.1 8.6b0 1 |
| 1173 |
8.5b0-8.6.1 8.6.0 1 |
| 1174 |
8.5b2-8.6.1 8.5a5 0 |
| 1175 |
8.5b2-8.6.1 8.5b1 0 |
| 1176 |
8.5b2-8.6.1 8.5.1 1 |
| 1177 |
8.5b2-8.6.1 8.6a0 1 |
| 1178 |
8.5b2-8.6.1 8.6b0 1 |
| 1179 |
8.5b2-8.6.1 8.6.0 1 |
| 1180 |
8.5-8.6.1 8.5a5 1 |
| 1181 |
8.5-8.6.1 8.5b1 1 |
| 1182 |
8.5-8.6.1 8.5.1 1 |
| 1183 |
8.5-8.6.1 8.6a0 1 |
| 1184 |
8.5-8.6.1 8.6b0 1 |
| 1185 |
8.5-8.6.1 8.6.0 1 |
| 1186 |
8.5.0-8.6.1 8.5a5 0 |
| 1187 |
8.5.0-8.6.1 8.5b1 0 |
| 1188 |
8.5.0-8.6.1 8.5.1 1 |
| 1189 |
8.5.0-8.6.1 8.6a0 1 |
| 1190 |
8.5.0-8.6.1 8.6b0 1 |
| 1191 |
8.5.0-8.6.1 8.6.0 1 |
| 1192 |
8.5a0-8.5a0 8.5a0 1 |
| 1193 |
8.5a0-8.5a0 8.5b1 0 |
| 1194 |
8.5a0-8.5a0 8.4 0 |
| 1195 |
8.5b0-8.5b0 8.5a5 0 |
| 1196 |
8.5b0-8.5b0 8.5b0 1 |
| 1197 |
8.5b0-8.5b0 8.5.1 0 |
| 1198 |
8.5-8.5 8.5a5 0 |
| 1199 |
8.5-8.5 8.5b1 0 |
| 1200 |
8.5-8.5 8.5 1 |
| 1201 |
8.5-8.5 8.5.1 0 |
| 1202 |
8.5.0-8.5.0 8.5a5 0 |
| 1203 |
8.5.0-8.5.0 8.5b1 0 |
| 1204 |
8.5.0-8.5.0 8.5.0 1 |
| 1205 |
8.5.0-8.5.0 8.5.1 0 |
| 1206 |
8.5.0-8.5.0 8.6a0 0 |
| 1207 |
8.5.0-8.5.0 8.6b0 0 |
| 1208 |
8.5.0-8.5.0 8.6.0 0 |
| 1209 |
8.2 9 0 |
| 1210 |
8.2- 9 1 |
| 1211 |
8.2-8.5 9 0 |
| 1212 |
8.2-9.1 9 1 |
| 1213 |
|
| 1214 |
8.5-8.5 8.5b1 0 |
| 1215 |
8.5a0-8.5 8.5b1 0 |
| 1216 |
8.5a0-8.5.1 8.5b1 1 |
| 1217 |
|
| 1218 |
8.5-8.5 8.5 1 |
| 1219 |
8.5.0-8.5.0 8.5 1 |
| 1220 |
8.5a0-8.5.0 8.5 0 |
| 1221 |
} { |
| 1222 |
test package-11.$n "package vsatisfies $provided $required" { |
| 1223 |
package vsatisfies $provided $required |
| 1224 |
} $satisfied |
| 1225 |
incr n |
| 1226 |
} |
| 1227 |
|
| 1228 |
test package-12.0 "package vsatisfies multiple" { |
| 1229 |
# yes no |
| 1230 |
package vsatisfies 8.4 8.4 7.3 |
| 1231 |
} 1 |
| 1232 |
test package-12.1 "package vsatisfies multiple" { |
| 1233 |
# no yes |
| 1234 |
package vsatisfies 8.4 7.3 8.4 |
| 1235 |
} 1 |
| 1236 |
test package-12.2 "package vsatisfies multiple" { |
| 1237 |
# yes yes |
| 1238 |
package vsatisfies 8.4.2 8.4 8.4.1 |
| 1239 |
} 1 |
| 1240 |
test package-12.3 "package vsatisfies multiple" { |
| 1241 |
# no no |
| 1242 |
package vsatisfies 8.4 7.3 6.1 |
| 1243 |
} 0 |
| 1244 |
|
| 1245 |
proc prefer {args} { |
| 1246 |
set ip [interp create] |
| 1247 |
try { |
| 1248 |
lappend res [$ip eval {package prefer}] |
| 1249 |
foreach mode $args { |
| 1250 |
lappend res [$ip eval [list package prefer $mode]] |
| 1251 |
} |
| 1252 |
return $res |
| 1253 |
} finally { |
| 1254 |
interp delete $ip |
| 1255 |
} |
| 1256 |
} |
| 1257 |
|
| 1258 |
test package-13.0 {package prefer defaults} { |
| 1259 |
prefer |
| 1260 |
} stable |
| 1261 |
test package-13.1 {package prefer defaults} -body { |
| 1262 |
set ::env(TCL_PKG_PREFER_LATEST) stable ;# value not relevant! |
| 1263 |
prefer |
| 1264 |
} -cleanup { |
| 1265 |
unset -nocomplain ::env(TCL_PKG_PREFER_LATEST) |
| 1266 |
} -result latest |
| 1267 |
|
| 1268 |
test package-14.0 {wrong\#args} -returnCodes error -body { |
| 1269 |
package prefer foo bar |
| 1270 |
} -result {wrong # args: should be "package prefer ?latest|stable?"} |
| 1271 |
test package-14.1 {bogus argument} -returnCodes error -body { |
| 1272 |
package prefer foo |
| 1273 |
} -result {bad preference "foo": must be latest or stable} |
| 1274 |
|
| 1275 |
test package-15.0 {set, keep} {package prefer stable} stable |
| 1276 |
test package-15.1 {set stable, keep} {prefer stable} {stable stable} |
| 1277 |
test package-15.2 {set latest, change} {prefer latest} {stable latest} |
| 1278 |
test package-15.3 {set latest, keep} { |
| 1279 |
prefer latest latest |
| 1280 |
} {stable latest latest} |
| 1281 |
test package-15.4 {set stable, rejected} { |
| 1282 |
prefer latest stable |
| 1283 |
} {stable latest latest} |
| 1284 |
|
| 1285 |
rename prefer {} |
| 1286 |
|
| 1287 |
set auto_path $oldPath |
| 1288 |
package unknown $oldPkgUnknown |
| 1289 |
|
| 1290 |
cleanupTests |
| 1291 |
} |
| 1292 |
|
| 1293 |
# cleanup |
| 1294 |
interp delete $i |
| 1295 |
::tcltest::cleanupTests |
| 1296 |
return |
| 1297 |
|
| 1298 |
# Local Variables: |
| 1299 |
# mode: tcl |
| 1300 |
# fill-column: 78 |
| 1301 |
# End: |