| [25] | 1 | # This file contains tests for the ::package::* 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 | 
|---|
 | 6 | # errors.  No output means no errors were found. | 
|---|
 | 7 | # | 
|---|
 | 8 | # Copyright (c) 1998-1999 by Scriptics Corporation. | 
|---|
 | 9 | # All rights reserved. | 
|---|
 | 10 | # | 
|---|
 | 11 | # RCS: @(#) $Id: package.test,v 1.3 2000/04/10 17:19:02 ericm Exp $ | 
|---|
 | 12 |  | 
|---|
 | 13 | if {[lsearch [namespace children] ::tcltest] == -1} { | 
|---|
 | 14 |     package require tcltest | 
|---|
 | 15 |     namespace import -force ::tcltest::* | 
|---|
 | 16 | } | 
|---|
 | 17 |  | 
|---|
 | 18 | test package-1.1 {pkg::create gives error on insufficient args} { | 
|---|
 | 19 |     catch {::pkg::create} | 
|---|
 | 20 | } 1 | 
|---|
 | 21 | test package-1.2 {pkg::create gives error on bad args} { | 
|---|
 | 22 |     catch {::pkg::create -foo bar -bar baz -baz boo} | 
|---|
 | 23 | } 1 | 
|---|
 | 24 | test package-1.3 {pkg::create gives error on no value given} { | 
|---|
 | 25 |     catch {::pkg::create -name foo -version 1.0 -source test.tcl -load} | 
|---|
 | 26 | } 1 | 
|---|
 | 27 | test package-1.4 {pkg::create gives error on no name given} { | 
|---|
 | 28 |     catch {::pkg::create -version 1.0 -source test.tcl -load foo.so} | 
|---|
 | 29 | } 1 | 
|---|
 | 30 | test package-1.5 {pkg::create gives error on no version given} { | 
|---|
 | 31 |     catch {::pkg::create -name foo -source test.tcl -load foo.so} | 
|---|
 | 32 | } 1 | 
|---|
 | 33 | test package-1.6 {pkg::create gives error on no source or load options} { | 
|---|
 | 34 |     catch {::pkg::create -name foo -version 1.0 -version 2.0} | 
|---|
 | 35 | } 1 | 
|---|
 | 36 | test package-1.7 {pkg::create gives correct output for 1 direct source} { | 
|---|
 | 37 |     ::pkg::create -name foo -version 1.0 -source test.tcl | 
|---|
 | 38 | } {package ifneeded foo 1.0 [list source [file join $dir test.tcl]]} | 
|---|
 | 39 | test package-1.8 {pkg::create gives correct output for 2 direct sources} { | 
|---|
 | 40 |     ::pkg::create -name foo -version 1.0 -source test.tcl -source test2.tcl | 
|---|
 | 41 | } {package ifneeded foo 1.0 [list source [file join $dir test.tcl]]\n[list source [file join $dir test2.tcl]]} | 
|---|
 | 42 | test package-1.9 {pkg::create gives correct output for 1 direct load} { | 
|---|
 | 43 |     ::pkg::create -name foo -version 1.0 -load test.so | 
|---|
 | 44 | } {package ifneeded foo 1.0 [list load [file join $dir test.so]]} | 
|---|
 | 45 | test package-1.10 {pkg::create gives correct output for 2 direct loads} { | 
|---|
 | 46 |     ::pkg::create -name foo -version 1.0 -load test.so -load test2.so | 
|---|
 | 47 | } {package ifneeded foo 1.0 [list load [file join $dir test.so]]\n[list load [file join $dir test2.so]]} | 
|---|
 | 48 | test package-1.11 {pkg::create gives correct output for 1 lazy source} { | 
|---|
 | 49 |     ::pkg::create -name foo -version 1.0 -source {test.tcl {foo bar}} | 
|---|
 | 50 | } {package ifneeded foo 1.0 [list tclPkgSetup $dir foo 1.0 {{test.tcl source {foo bar}}}]} | 
|---|
 | 51 | test package-1.12 {pkg::create gives correct output for 2 lazy sources} { | 
|---|
 | 52 |     ::pkg::create -name foo -version 1.0 -source {test.tcl {foo bar}} \ | 
|---|
 | 53 |             -source {test2.tcl {baz boo}} | 
|---|
 | 54 | } {package ifneeded foo 1.0 [list tclPkgSetup $dir foo 1.0 {{test.tcl source {foo bar}} {test2.tcl source {baz boo}}}]} | 
|---|
 | 55 | test package-1.13 {pkg::create gives correct output for 1 lazy load} { | 
|---|
 | 56 |     ::pkg::create -name foo -version 1.0 -load {test.so {foo bar}} | 
|---|
 | 57 | } {package ifneeded foo 1.0 [list tclPkgSetup $dir foo 1.0 {{test.so load {foo bar}}}]} | 
|---|
 | 58 | test package-1.14 {pkg::create gives correct output for 2 lazy loads} { | 
|---|
 | 59 |     ::pkg::create -name foo -version 1.0 -load {test.so {foo bar}} \ | 
|---|
 | 60 |             -load {test2.so {baz boo}} | 
|---|
 | 61 | } {package ifneeded foo 1.0 [list tclPkgSetup $dir foo 1.0 {{test.so load {foo bar}} {test2.so load {baz boo}}}]} | 
|---|
 | 62 | test package-1.15 {pkg::create gives correct output for 1 each, direct} { | 
|---|
 | 63 |     ::pkg::create -name foo -version 1.0 -source test.tcl -load test2.so | 
|---|
 | 64 | } {package ifneeded foo 1.0 [list load [file join $dir test2.so]]\n[list source [file join $dir test.tcl]]} | 
|---|
 | 65 | test package-1.16 {pkg::create gives correct output for 1 direct, 1 lazy} { | 
|---|
 | 66 |     ::pkg::create -name foo -version 1.0 -source test.tcl \ | 
|---|
 | 67 |             -source {test2.tcl {foo bar}} | 
|---|
 | 68 | } {package ifneeded foo 1.0 [list source [file join $dir test.tcl]]\n[list tclPkgSetup $dir foo 1.0 {{test2.tcl source {foo bar}}}]} | 
|---|
 | 69 |  | 
|---|
 | 70 | ::tcltest::cleanupTests | 
|---|
 | 71 | return | 
|---|