diff options
author | cvs2fossil <cvs2fossil> | 1998-12-12 00:12:36 (GMT) |
---|---|---|
committer | cvs2fossil <cvs2fossil> | 1998-12-12 00:12:36 (GMT) |
commit | 04e47e8e81a0ba0b2f3b4647ff1cd4c0d8c05401 (patch) | |
tree | 00b224ddd30c4e1fa6a59d9d2c9bd2e8ccdc2b2e /tests | |
parent | 13ad37616211a5be8dbe22e63a25d058f58842e0 (diff) | |
download | tcl-core_8_1_b1_synthetic.zip tcl-core_8_1_b1_synthetic.tar.gz tcl-core_8_1_b1_synthetic.tar.bz2 |
Created branch core-8-1-b1-syntheticcore_8_1_b1core_8_1_b1_synthetic
Diffstat (limited to 'tests')
-rw-r--r-- | tests/all | 0 | ||||
-rw-r--r-- | tests/autoMkindex.tcl | 52 | ||||
-rw-r--r-- | tests/pkg/circ1.tcl | 34 | ||||
-rw-r--r-- | tests/pkg/circ2.tcl | 25 | ||||
-rw-r--r-- | tests/pkg/circ3.tcl | 25 | ||||
-rw-r--r-- | tests/pkg/global.tcl | 19 | ||||
-rw-r--r-- | tests/pkg/pkg1.tcl | 26 | ||||
-rw-r--r-- | tests/pkg/pkg2_a.tcl | 22 | ||||
-rw-r--r-- | tests/pkg/pkg2_b.tcl | 22 | ||||
-rw-r--r-- | tests/pkg/pkg3.tcl | 22 | ||||
-rw-r--r-- | tests/pkg/pkg4.tcl | 27 | ||||
-rw-r--r-- | tests/pkg/pkg5.tcl | 30 | ||||
-rw-r--r-- | tests/pkg/pkga.tcl | 15 | ||||
-rw-r--r-- | tests/pkg/simple.tcl | 23 | ||||
-rw-r--r-- | tests/pkg/std.tcl | 28 | ||||
-rw-r--r-- | tests/pkg1/direct1.tcl | 23 | ||||
-rw-r--r-- | tests/pkg1/pkgIndex.tcl | 11 | ||||
-rw-r--r-- | tests/stack.test | 23 |
18 files changed, 427 insertions, 0 deletions
diff --git a/tests/all b/tests/all new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/all diff --git a/tests/autoMkindex.tcl b/tests/autoMkindex.tcl new file mode 100644 index 0000000..7a72fbe --- /dev/null +++ b/tests/autoMkindex.tcl @@ -0,0 +1,52 @@ +# Test file for: +# auto_mkindex +# +# This file provides example cases for testing the Tcl autoloading +# facility. Things are much more complicated with namespaces and classes. +# The "auto_mkindex" facility can no longer be built on top of a simple +# regular expression parser. It must recognize constructs like this: +# +# namespace eval foo { +# proc test {x y} { ... } +# namespace eval bar { +# proc another {args} { ... } +# } +# } +# +# Note that procedures and itcl class definitions can be nested inside +# of namespaces. +# +# Copyright (c) 1993-1998 Lucent Technologies, Inc. + +# This shouldn't cause any problems +namespace import -force blt::* + +# Should be able to handle "proc" definitions, even if they are +# preceded by white space. + +proc normal {x y} {return [expr $x+$y]} + proc indented {x y} {return [expr $x+$y]} + +# +# Should be able to handle proc declarations within namespaces, +# even if they have explicit namespace paths. +# +namespace eval buried { + proc inside {args} {return "inside: $args"} + + namespace export pub_* + proc pub_one {args} {return "one: $args"} + proc pub_two {args} {return "two: $args"} +} +proc buried::within {args} {return "within: $args"} + +namespace eval buried { + namespace eval under { + proc neath {args} {return "neath: $args"} + } + namespace eval ::buried { + proc relative {args} {return "relative: $args"} + proc ::top {args} {return "top: $args"} + proc ::buried::explicit {args} {return "explicit: $args"} + } +} diff --git a/tests/pkg/circ1.tcl b/tests/pkg/circ1.tcl new file mode 100644 index 0000000..3616621 --- /dev/null +++ b/tests/pkg/circ1.tcl @@ -0,0 +1,34 @@ +# circ1.tcl -- +# +# Test package for pkg_mkIndex. This package requires circ2, and circ2 +# requires circ3, which in turn requires circ1. +# In case of cirularities, pkg_mkIndex should give up when it gets stuck. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: circ1.tcl,v 1.1 1998/10/17 00:21:39 escoffon Exp $ + +package require circ2 1.0 + +package provide circ1 1.0 + +namespace eval circ1 { + namespace export c1-1 c1-2 c1-3 c1-4 +} + +proc circ1::c1-1 { num } { + return [circ2::c2-1 $num] +} + +proc circ1::c1-2 { num } { + return [circ2::c2-2 $num] +} + +proc circ1::c1-3 {} { + return 10 +} + +proc circ1::c1-4 {} { + return 20 +} diff --git a/tests/pkg/circ2.tcl b/tests/pkg/circ2.tcl new file mode 100644 index 0000000..66a20a3 --- /dev/null +++ b/tests/pkg/circ2.tcl @@ -0,0 +1,25 @@ +# circ2.tcl -- +# +# Test package for pkg_mkIndex. This package is required by circ1, and +# requires circ3. Circ3, in turn, requires circ1 to give us a circularity. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: circ2.tcl,v 1.1 1998/10/17 00:21:39 escoffon Exp $ + +package require circ3 1.0 + +package provide circ2 1.0 + +namespace eval circ2 { + namespace export c2-1 c2-2 +} + +proc circ2::c2-1 { num } { + return [expr $num * [circ3::c3-1]] +} + +proc circ2::c2-2 { num } { + return [expr $num * [circ3::c3-2]] +} diff --git a/tests/pkg/circ3.tcl b/tests/pkg/circ3.tcl new file mode 100644 index 0000000..ddcb691 --- /dev/null +++ b/tests/pkg/circ3.tcl @@ -0,0 +1,25 @@ +# circ3.tcl -- +# +# Test package for pkg_mkIndex. This package is required by circ2, and in +# turn requires circ1. This closes the circularity. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: circ3.tcl,v 1.1 1998/10/17 00:21:40 escoffon Exp $ + +package require circ1 1.0 + +package provide circ3 1.0 + +namespace eval circ3 { + namespace export c3-1 c3-4 +} + +proc circ3::c3-1 {} { + return [circ1::c1-3] +} + +proc circ3::c3-2 {} { + return [circ1::c1-4] +} diff --git a/tests/pkg/global.tcl b/tests/pkg/global.tcl new file mode 100644 index 0000000..38925c5 --- /dev/null +++ b/tests/pkg/global.tcl @@ -0,0 +1,19 @@ +# global.tcl -- +# +# Test package for pkg_mkIndex. +# Contains global symbols, used to check that they don't have a leading :: +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: global.tcl,v 1.1 1998/10/17 00:21:40 escoffon Exp $ + +package provide global 1.0 + +proc global_lower { stg } { + return [string tolower $stg] +} + +proc global_upper { stg } { + return [string toupper $stg] +} diff --git a/tests/pkg/pkg1.tcl b/tests/pkg/pkg1.tcl new file mode 100644 index 0000000..e2cf960 --- /dev/null +++ b/tests/pkg/pkg1.tcl @@ -0,0 +1,26 @@ +# pkg1.tcl -- +# +# Test package for pkg_mkIndex. This package requires pkg3, but it does +# not use any of pkg3's procs in the code that is executed by the file +# (i.e. references to pkg3's procs are in the proc bodies only). +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: pkg1.tcl,v 1.1 1998/10/17 00:21:40 escoffon Exp $ + +package require pkg3 1.0 + +package provide pkg1 1.0 + +namespace eval pkg1 { + namespace export p1-1 p1-2 +} + +proc pkg1::p1-1 { num } { + return [pkg3::p3-1 $num] +} + +proc pkg1::p1-2 { num } { + return [pkg3::p3-2 $num] +} diff --git a/tests/pkg/pkg2_a.tcl b/tests/pkg/pkg2_a.tcl new file mode 100644 index 0000000..85e16c4 --- /dev/null +++ b/tests/pkg/pkg2_a.tcl @@ -0,0 +1,22 @@ +# pkg2_a.tcl -- +# +# Test package for pkg_mkIndex. This package is required by pkg1. +# This package is split into two files, to test packages that are split +# over multiple files. +# +# Copyright (c) 2998 by Scriptics Corporation. +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# +# SCCS: %Z% %M% %I% %E% %U% + +package provide pkg2 1.0 + +namespace eval pkg2 { + namespace export p2-1 +} + +proc pkg2::p2-1 { num } { + return [expr $num * 2] +} diff --git a/tests/pkg/pkg2_b.tcl b/tests/pkg/pkg2_b.tcl new file mode 100644 index 0000000..15fb1a8 --- /dev/null +++ b/tests/pkg/pkg2_b.tcl @@ -0,0 +1,22 @@ +# pkg2_b.tcl -- +# +# Test package for pkg_mkIndex. This package is required by pkg1. +# This package is split into two files, to test packages that are split +# over multiple files. +# +# Copyright (c) 2998 by Scriptics Corporation. +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# +# SCCS: %Z% %M% %I% %E% %U% + +package provide pkg2 1.0 + +namespace eval pkg2 { + namespace export p2-2 +} + +proc pkg2::p2-2 { num } { + return [expr $num * 3] +} diff --git a/tests/pkg/pkg3.tcl b/tests/pkg/pkg3.tcl new file mode 100644 index 0000000..fd769c4 --- /dev/null +++ b/tests/pkg/pkg3.tcl @@ -0,0 +1,22 @@ +# pkg3.tcl -- +# +# Test package for pkg_mkIndex. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: pkg3.tcl,v 1.1 1998/10/17 00:21:42 escoffon Exp $ + +package provide pkg3 1.0 + +namespace eval pkg3 { + namespace export p3-1 p3-2 +} + +proc pkg3::p3-1 { num } { + return {[expr $num * 2]} +} + +proc pkg3::p3-2 { num } { + return {[expr $num * 3]} +} diff --git a/tests/pkg/pkg4.tcl b/tests/pkg/pkg4.tcl new file mode 100644 index 0000000..ccb9291 --- /dev/null +++ b/tests/pkg/pkg4.tcl @@ -0,0 +1,27 @@ +# pkg4.tcl -- +# +# Test package for pkg_mkIndex. This package requires pkg3, and it calls +# a pkg3 proc in the code that is executed by the file +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: pkg4.tcl,v 1.1 1998/10/17 00:21:42 escoffon Exp $ + +package require pkg3 1.0 + +package provide pkg4 1.0 + +namespace eval pkg4 { + namespace export p4-1 p4-2 + variable m2 [pkg3::p3-1 10] +} + +proc pkg4::p4-1 { num } { + variable m2 + return [expr {$m2 * $num}] +} + +proc pkg4::p4-2 { num } { + return [pkg3::p3-2 $num] +} diff --git a/tests/pkg/pkg5.tcl b/tests/pkg/pkg5.tcl new file mode 100644 index 0000000..5e25e6d --- /dev/null +++ b/tests/pkg/pkg5.tcl @@ -0,0 +1,30 @@ +# pkg5.tcl -- +# +# Test package for pkg_mkIndex. This package requires pkg2, and it calls +# a pkg2 proc in the code that is executed by the file. +# Pkg2 is a split package. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: pkg5.tcl,v 1.1 1998/10/17 00:21:42 escoffon Exp $ + +package require pkg2 1.0 + +package provide pkg5 1.0 + +namespace eval pkg5 { + namespace export p5-1 p5-2 + variable m2 [pkg2::p2-1 10] + variable m3 [pkg2::p2-2 10] +} + +proc pkg5::p5-1 { num } { + variable m2 + return [expr {$m2 * $num}] +} + +proc pkg5::p5-2 { num } { + variable m2 + return [expr {$m2 * $num}] +} diff --git a/tests/pkg/pkga.tcl b/tests/pkg/pkga.tcl new file mode 100644 index 0000000..e964f51 --- /dev/null +++ b/tests/pkg/pkga.tcl @@ -0,0 +1,15 @@ +# pkga.tcl -- +# +# Test package for pkg_mkIndex. This package provides Pkga, +# which is also provided by a DLL. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: pkga.tcl,v 1.1 1998/12/04 06:28:11 welch Exp $ + +package provide Pkga 1.0 + +proc pkga_neq { x } { + return [expr {! [pkgq_eq $x]}] +} diff --git a/tests/pkg/simple.tcl b/tests/pkg/simple.tcl new file mode 100644 index 0000000..a2cf121 --- /dev/null +++ b/tests/pkg/simple.tcl @@ -0,0 +1,23 @@ +# simple.tcl -- +# +# Test package for pkg_mkIndex. This is a simple package, just to check +# basic functionality. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: simple.tcl,v 1.1 1998/10/17 00:21:43 escoffon Exp $ + +package provide simple 1.0 + +namespace eval simple { + namespace export lower upper +} + +proc simple::lower { stg } { + return [string tolower $stg] +} + +proc simple::upper { stg } { + return [string toupper $stg] +} diff --git a/tests/pkg/std.tcl b/tests/pkg/std.tcl new file mode 100644 index 0000000..48c4048 --- /dev/null +++ b/tests/pkg/std.tcl @@ -0,0 +1,28 @@ +# std.tcl -- +# +# Test package for pkg_mkIndex. +# Does a package require of direct1, whose pkgIndex.tcl entry (in pkg1) +# should be a -direct entry. +# This tests that pkg_mkIndex can handle code that is sourced in pkgIndex.tcl +# files. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: std.tcl,v 1.1 1998/10/17 00:21:43 escoffon Exp $ + +package require direct1 + +package provide std 1.0 + +namespace eval std { + namespace export p1 p2 +} + +proc std::p1 { stg } { + return [string tolower $stg] +} + +proc std::p2 { stg } { + return [string toupper $stg] +} diff --git a/tests/pkg1/direct1.tcl b/tests/pkg1/direct1.tcl new file mode 100644 index 0000000..cc10330 --- /dev/null +++ b/tests/pkg1/direct1.tcl @@ -0,0 +1,23 @@ +# std.tcl -- +# +# Test support package for pkg_mkIndex. +# This is referenced by pkgIndex.tcl as a -direct script. +# +# Copyright (c) 1998 by Scriptics Corporation. +# All rights reserved. +# +# RCS: @(#) $Id: direct1.tcl,v 1.1 1998/10/17 00:21:44 escoffon Exp $ + +package provide direct1 1.0 + +namespace eval direct1 { + namespace export pd1 pd2 +} + +proc direct1::pd1 { stg } { + return [string tolower $stg] +} + +proc direct1::pd2 { stg } { + return [string toupper $stg] +} diff --git a/tests/pkg1/pkgIndex.tcl b/tests/pkg1/pkgIndex.tcl new file mode 100644 index 0000000..5dc1d5e --- /dev/null +++ b/tests/pkg1/pkgIndex.tcl @@ -0,0 +1,11 @@ +# Tcl package index file, version 1.1 +# This file is generated by the "pkg_mkIndex -direct" command +# and sourced either when an application starts up or +# by a "package unknown" script. It invokes the +# "package ifneeded" command to set up package-related +# information so that packages will be loaded automatically +# in response to "package require" commands. When this +# script is sourced, the variable $dir must contain the +# full path name of this file's directory. + +package ifneeded direct1 1.0 [list source [file join $dir direct1.tcl]] diff --git a/tests/stack.test b/tests/stack.test new file mode 100644 index 0000000..2499220 --- /dev/null +++ b/tests/stack.test @@ -0,0 +1,23 @@ +# Tests that the stack size is big enough for the application. +# +# This file contains a collection of tests for one or more of the Tcl +# built-in commands. Sourcing this file into Tcl runs the tests and +# generates output for errors. No output means no errors were found. +# +# Copyright (c) 1998 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: stack.test,v 1.1 1998/09/30 20:52:01 escoffon Exp $ + +if {[string compare test [info procs test]] == 1} then {source defs} + +# Note that a failure in this test results in a crash of the executable. + +test stack-1.1 {maxNestingDepth reached on infinite recursion} { + proc recurse {} { return [recurse] } + catch {recurse} rv + rename recurse {} + set rv +} {too many nested calls to Tcl_EvalObj (infinite loop?)} |