sl@0: # This file contains tests for the ::package::* commands. sl@0: # Note that the tests are limited to Tcl scripts only, there are no shared sl@0: # libraries against which to test. sl@0: # sl@0: # Sourcing this file into Tcl runs the tests and generates output for sl@0: # errors. No output means no errors were found. sl@0: # sl@0: # Copyright (c) 1998-1999 by Scriptics Corporation. sl@0: # All rights reserved. sl@0: # sl@0: # RCS: @(#) $Id: package.test,v 1.3 2000/04/10 17:19:02 ericm Exp $ sl@0: sl@0: if {[lsearch [namespace children] ::tcltest] == -1} { sl@0: package require tcltest sl@0: namespace import -force ::tcltest::* sl@0: } sl@0: sl@0: test package-1.1 {pkg::create gives error on insufficient args} { sl@0: catch {::pkg::create} sl@0: } 1 sl@0: test package-1.2 {pkg::create gives error on bad args} { sl@0: catch {::pkg::create -foo bar -bar baz -baz boo} sl@0: } 1 sl@0: test package-1.3 {pkg::create gives error on no value given} { sl@0: catch {::pkg::create -name foo -version 1.0 -source test.tcl -load} sl@0: } 1 sl@0: test package-1.4 {pkg::create gives error on no name given} { sl@0: catch {::pkg::create -version 1.0 -source test.tcl -load foo.so} sl@0: } 1 sl@0: test package-1.5 {pkg::create gives error on no version given} { sl@0: catch {::pkg::create -name foo -source test.tcl -load foo.so} sl@0: } 1 sl@0: test package-1.6 {pkg::create gives error on no source or load options} { sl@0: catch {::pkg::create -name foo -version 1.0 -version 2.0} sl@0: } 1 sl@0: test package-1.7 {pkg::create gives correct output for 1 direct source} { sl@0: ::pkg::create -name foo -version 1.0 -source test.tcl sl@0: } {package ifneeded foo 1.0 [list source [file join $dir test.tcl]]} sl@0: test package-1.8 {pkg::create gives correct output for 2 direct sources} { sl@0: ::pkg::create -name foo -version 1.0 -source test.tcl -source test2.tcl sl@0: } {package ifneeded foo 1.0 [list source [file join $dir test.tcl]]\n[list source [file join $dir test2.tcl]]} sl@0: test package-1.9 {pkg::create gives correct output for 1 direct load} { sl@0: ::pkg::create -name foo -version 1.0 -load test.so sl@0: } {package ifneeded foo 1.0 [list load [file join $dir test.so]]} sl@0: test package-1.10 {pkg::create gives correct output for 2 direct loads} { sl@0: ::pkg::create -name foo -version 1.0 -load test.so -load test2.so sl@0: } {package ifneeded foo 1.0 [list load [file join $dir test.so]]\n[list load [file join $dir test2.so]]} sl@0: test package-1.11 {pkg::create gives correct output for 1 lazy source} { sl@0: ::pkg::create -name foo -version 1.0 -source {test.tcl {foo bar}} sl@0: } {package ifneeded foo 1.0 [list tclPkgSetup $dir foo 1.0 {{test.tcl source {foo bar}}}]} sl@0: test package-1.12 {pkg::create gives correct output for 2 lazy sources} { sl@0: ::pkg::create -name foo -version 1.0 -source {test.tcl {foo bar}} \ sl@0: -source {test2.tcl {baz boo}} sl@0: } {package ifneeded foo 1.0 [list tclPkgSetup $dir foo 1.0 {{test.tcl source {foo bar}} {test2.tcl source {baz boo}}}]} sl@0: test package-1.13 {pkg::create gives correct output for 1 lazy load} { sl@0: ::pkg::create -name foo -version 1.0 -load {test.so {foo bar}} sl@0: } {package ifneeded foo 1.0 [list tclPkgSetup $dir foo 1.0 {{test.so load {foo bar}}}]} sl@0: test package-1.14 {pkg::create gives correct output for 2 lazy loads} { sl@0: ::pkg::create -name foo -version 1.0 -load {test.so {foo bar}} \ sl@0: -load {test2.so {baz boo}} sl@0: } {package ifneeded foo 1.0 [list tclPkgSetup $dir foo 1.0 {{test.so load {foo bar}} {test2.so load {baz boo}}}]} sl@0: test package-1.15 {pkg::create gives correct output for 1 each, direct} { sl@0: ::pkg::create -name foo -version 1.0 -source test.tcl -load test2.so sl@0: } {package ifneeded foo 1.0 [list load [file join $dir test2.so]]\n[list source [file join $dir test.tcl]]} sl@0: test package-1.16 {pkg::create gives correct output for 1 direct, 1 lazy} { sl@0: ::pkg::create -name foo -version 1.0 -source test.tcl \ sl@0: -source {test2.tcl {foo bar}} sl@0: } {package ifneeded foo 1.0 [list source [file join $dir test.tcl]]\n[list tclPkgSetup $dir foo 1.0 {{test2.tcl source {foo bar}}}]} sl@0: sl@0: ::tcltest::cleanupTests sl@0: return