summaryrefslogtreecommitdiff
path: root/tcl/tests/pkg.test
diff options
context:
space:
mode:
Diffstat (limited to 'tcl/tests/pkg.test')
-rw-r--r--tcl/tests/pkg.test107
1 files changed, 101 insertions, 6 deletions
diff --git a/tcl/tests/pkg.test b/tcl/tests/pkg.test
index 5d6314bce93..77848537b59 100644
--- a/tcl/tests/pkg.test
+++ b/tcl/tests/pkg.test
@@ -5,23 +5,26 @@
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 1995-1996 Sun Microsystems, Inc.
+# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id$
-if {[string compare test [info procs test]] == 1} then {source defs}
+if {[lsearch [namespace children] ::tcltest] == -1} {
+ package require tcltest
+ namespace import -force ::tcltest::*
+}
# Do all this in a slave interp to avoid garbaging the
# package list
set i [interp create]
-interp eval $i [list set VERBOSE $VERBOSE]
-interp eval $i [list set TESTS $TESTS]
+interp eval $i [list set argv $argv]
+interp eval $i [list package require tcltest]
+interp eval $i [list namespace import -force ::tcltest::*]
interp eval $i {
-if {[string compare test [info procs test]] == 1} then {source defs}
-
eval package forget [package names]
set oldPkgUnknown [package unknown]
package unknown {}
@@ -483,7 +486,7 @@ test pkg-3.52 {Tcl_PackageCmd procedure, "vsatisfies" option} {
} {0}
test pkg-3.53 {Tcl_PackageCmd procedure, "versions" option} {
list [catch {package foo} msg] $msg
-} {1 {bad option "foo": should be forget, ifneeded, names, provide, require, unknown, vcompare, versions, or vsatisfies}}
+} {1 {bad option "foo": must be forget, ifneeded, names, present, provide, require, unknown, vcompare, versions, or vsatisfies}}
# No tests for FindPackage; can't think up anything detectable
# errors.
@@ -526,6 +529,9 @@ test pkg-5.3 {CheckVersion procedure} {
test pkg-5.4 {CheckVersion procedure} {
list [catch {package vcompare 1.2.3. 2.1} msg] $msg
} {1 {expected version number but got "1.2.3."}}
+test pkg-5.5 {CheckVersion procedure} {
+ list [catch {package vcompare 1.2..3 2.1} msg] $msg
+} {1 {expected version number but got "1.2..3"}}
test pkg-6.1 {ComparePkgVersions procedure} {
package vcompare 1.23 1.22
@@ -555,9 +561,98 @@ test pkg-6.9 {ComparePkgVersions procedure} {
package vsatisfies 2 1
} {0}
+test pkg-7.1 {Tcl_PkgPresent procedure, any version} {
+ package forget t
+ package provide t 2.4
+ package present t
+} {2.4}
+test pkg-7.2 {Tcl_PkgPresent procedure, correct version} {
+ package forget t
+ package provide t 2.4
+ package present t 2.4
+} {2.4}
+test pkg-7.3 {Tcl_PkgPresent procedure, satisfying version} {
+ package forget t
+ package provide t 2.4
+ package present t 2.0
+} {2.4}
+test pkg-7.4 {Tcl_PkgPresent procedure, not satisfying version} {
+ package forget t
+ package provide t 2.4
+ list [catch {package present t 2.6} msg] $msg
+} {1 {version conflict for package "t": have 2.4, need 2.6}}
+test pkg-7.5 {Tcl_PkgPresent procedure, not satisfying version} {
+ package forget t
+ package provide t 2.4
+ list [catch {package present t 1.0} msg] $msg
+} {1 {version conflict for package "t": have 2.4, need 1.0}}
+test pkg-7.6 {Tcl_PkgPresent procedure, exact version} {
+ package forget t
+ package provide t 2.4
+ package present -exact t 2.4
+} {2.4}
+test pkg-7.7 {Tcl_PkgPresent procedure, not exact version} {
+ package forget t
+ package provide t 2.4
+ list [catch {package present -exact t 2.3} msg] $msg
+} {1 {version conflict for package "t": have 2.4, need 2.3}}
+test pkg-7.8 {Tcl_PkgPresent procedure, unknown package} {
+ package forget t
+ list [catch {package present t} msg] $msg
+} {1 {package t is not present}}
+test pkg-7.9 {Tcl_PkgPresent procedure, unknown package} {
+ package forget t
+ list [catch {package present t 2.4} msg] $msg
+} {1 {package t 2.4 is not present}}
+test pkg-7.10 {Tcl_PkgPresent procedure, unknown package} {
+ package forget t
+ list [catch {package present -exact t 2.4} msg] $msg
+} {1 {package t 2.4 is not present}}
+test pkg-7.11 {Tcl_PackageCmd procedure, "present" option} {
+ list [catch {package present} msg] $msg
+} {1 {wrong # args: should be "package present ?-exact? package ?version?"}}
+test pkg-7.12 {Tcl_PackageCmd procedure, "present" option} {
+ list [catch {package present a b c} msg] $msg
+} {1 {wrong # args: should be "package present ?-exact? package ?version?"}}
+test pkg-7.13 {Tcl_PackageCmd procedure, "present" option} {
+ list [catch {package present -exact a b c} msg] $msg
+} {1 {wrong # args: should be "package present ?-exact? package ?version?"}}
+test pkg-7.14 {Tcl_PackageCmd procedure, "present" option} {
+ list [catch {package present -bs a b} msg] $msg
+} {1 {wrong # args: should be "package present ?-exact? package ?version?"}}
+test pkg-7.15 {Tcl_PackageCmd procedure, "present" option} {
+ list [catch {package present x a.b} msg] $msg
+} {1 {expected version number but got "a.b"}}
+test pkg-7.16 {Tcl_PackageCmd procedure, "present" option} {
+ list [catch {package present -exact x a.b} msg] $msg
+} {1 {expected version number but got "a.b"}}
+test pkg-7.17 {Tcl_PackageCmd procedure, "present" option} {
+ list [catch {package present -exact x} msg] $msg
+} {1 {wrong # args: should be "package present ?-exact? package ?version?"}}
+test pkg-7.18 {Tcl_PackageCmd procedure, "present" option} {
+ list [catch {package present -exact} msg] $msg
+} {1 {wrong # args: should be "package present ?-exact? package ?version?"}}
+
set auto_path $oldPath
package unknown $oldPkgUnknown
concat
}
+
+# cleanup
interp delete $i
+::tcltest::cleanupTests
+return
+
+
+
+
+
+
+
+
+
+
+
+
+