summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2001-05-31 23:45:44 (GMT)
committerKevin B Kenny <kennykb@acm.org>2001-05-31 23:45:44 (GMT)
commitf16a9d29ec4b0f401338397dee7f5d24f9acffb5 (patch)
treefdd7e6cc3e4c627755440c7f60e6ebe4311248fc /tests
parent97464e6cba8eb0008cf2727c15718671992b913f (diff)
downloadtcl-f16a9d29ec4b0f401338397dee7f5d24f9acffb5.zip
tcl-f16a9d29ec4b0f401338397dee7f5d24f9acffb5.tar.gz
tcl-f16a9d29ec4b0f401338397dee7f5d24f9acffb5.tar.bz2
Development branch for TIPs 22 and 33 kennykb_tip_22_33_botched
Diffstat (limited to 'tests')
-rw-r--r--tests/README423
-rw-r--r--tests/all.tcl76
-rw-r--r--tests/append.test194
-rw-r--r--tests/assocd.test77
-rw-r--r--tests/async.test150
-rw-r--r--tests/autoMkindex.tcl73
-rw-r--r--tests/autoMkindex.test189
-rw-r--r--tests/basic.test545
-rw-r--r--tests/binary.test1462
-rw-r--r--tests/case.test102
-rw-r--r--tests/clock.test225
-rw-r--r--tests/cmdAH.test1484
-rw-r--r--tests/cmdIL.test325
-rw-r--r--tests/cmdInfo.test116
-rw-r--r--tests/cmdMZ.test581
-rw-r--r--tests/compExpr-old.test687
-rw-r--r--tests/compExpr.test340
-rw-r--r--tests/compile.test214
-rw-r--r--tests/concat.test65
-rw-r--r--tests/dcall.test60
-rw-r--r--tests/defs.tcl990
-rw-r--r--tests/dstring.test267
-rw-r--r--tests/encoding.test316
-rw-r--r--tests/env.test261
-rw-r--r--tests/error.test192
-rw-r--r--tests/eval.test74
-rw-r--r--tests/event.test589
-rw-r--r--tests/exec.test589
-rw-r--r--tests/execute.test548
-rw-r--r--tests/expr-old.test948
-rw-r--r--tests/expr.test709
-rw-r--r--tests/fCmd.test2164
-rw-r--r--tests/fileName.test1429
-rw-r--r--tests/for-old.test84
-rw-r--r--tests/for.test752
-rw-r--r--tests/foreach.test242
-rw-r--r--tests/format.test499
-rw-r--r--tests/get.test110
-rw-r--r--tests/history.test230
-rw-r--r--tests/http.test315
-rw-r--r--tests/httpd148
-rw-r--r--tests/httpold.test441
-rw-r--r--tests/if-old.test175
-rw-r--r--tests/if.test1091
-rw-r--r--tests/incr-old.test106
-rw-r--r--tests/incr.test513
-rw-r--r--tests/indexObj.test86
-rw-r--r--tests/info.test517
-rw-r--r--tests/init.test167
-rw-r--r--tests/interp.test2360
-rw-r--r--tests/io.test6809
-rw-r--r--tests/ioCmd.test528
-rw-r--r--tests/ioUtil.test318
-rw-r--r--tests/join.test65
-rw-r--r--tests/lindex.test93
-rw-r--r--tests/link.test255
-rw-r--r--tests/linsert.test123
-rw-r--r--tests/list.test126
-rw-r--r--tests/listObj.test199
-rw-r--r--tests/llength.test54
-rw-r--r--tests/load.test194
-rw-r--r--tests/lrange.test102
-rw-r--r--tests/lreplace.test149
-rw-r--r--tests/lsearch.test105
-rw-r--r--tests/macFCmd.test208
-rw-r--r--tests/misc.test75
-rw-r--r--tests/msgcat.test318
-rw-r--r--tests/namespace-old.test863
-rw-r--r--tests/namespace.test1115
-rw-r--r--tests/obj.test546
-rw-r--r--tests/opt.test290
-rw-r--r--tests/osa.test47
-rw-r--r--tests/parse.test743
-rw-r--r--tests/parseExpr.test637
-rw-r--r--tests/parseOld.test546
-rw-r--r--tests/pid.test70
-rw-r--r--tests/pkg.test652
-rw-r--r--tests/pkg/circ1.tcl34
-rw-r--r--tests/pkg/circ2.tcl25
-rw-r--r--tests/pkg/circ3.tcl25
-rw-r--r--tests/pkg/global.tcl19
-rw-r--r--tests/pkg/import.tcl16
-rw-r--r--tests/pkg/pkg1.tcl26
-rw-r--r--tests/pkg/pkg2_a.tcl22
-rw-r--r--tests/pkg/pkg2_b.tcl22
-rw-r--r--tests/pkg/pkg3.tcl22
-rw-r--r--tests/pkg/pkg4.tcl27
-rw-r--r--tests/pkg/pkg5.tcl30
-rw-r--r--tests/pkg/pkga.tcl15
-rw-r--r--tests/pkg/simple.tcl23
-rw-r--r--tests/pkg/std.tcl28
-rw-r--r--tests/pkg1/direct1.tcl23
-rw-r--r--tests/pkg1/pkgIndex.tcl11
-rw-r--r--tests/pkgMkIndex.test375
-rw-r--r--tests/platform.test39
-rw-r--r--tests/proc-old.test523
-rw-r--r--tests/proc.test312
-rw-r--r--tests/pwd.test41
-rw-r--r--tests/reg.test905
-rw-r--r--tests/regexp.test378
-rw-r--r--tests/registry.test601
-rw-r--r--tests/remote.tcl172
-rw-r--r--tests/rename.test186
-rw-r--r--tests/resource.test364
-rw-r--r--tests/result.test102
-rw-r--r--tests/safe.test527
-rw-r--r--tests/scan.test586
-rw-r--r--tests/security.test53
-rw-r--r--tests/set-old.test811
-rw-r--r--tests/set.test499
-rw-r--r--tests/socket.test1669
-rw-r--r--tests/source.test197
-rw-r--r--tests/split.test84
-rw-r--r--tests/stack.test41
-rw-r--r--tests/string.test403
-rw-r--r--tests/stringObj.test209
-rw-r--r--tests/subst.test125
-rw-r--r--tests/switch.test198
-rw-r--r--tests/thread.test240
-rw-r--r--tests/timer.test554
-rw-r--r--tests/trace.test984
-rw-r--r--tests/unixFCmd.test300
-rw-r--r--tests/unixFile.test77
-rw-r--r--tests/unixInit.test205
-rw-r--r--tests/unixNotfy.test99
-rw-r--r--tests/unknown.test78
-rw-r--r--tests/uplevel.test128
-rw-r--r--tests/upvar.test416
-rw-r--r--tests/utf.test276
-rw-r--r--tests/util.test306
-rw-r--r--tests/var.test610
-rw-r--r--tests/while-old.test132
-rw-r--r--tests/while.test633
-rw-r--r--tests/winConsole.test51
-rw-r--r--tests/winDde.test152
-rw-r--r--tests/winFCmd.test978
-rw-r--r--tests/winFile.test64
-rw-r--r--tests/winNotify.test173
-rw-r--r--tests/winPipe.test413
-rw-r--r--tests/winTime.test49
140 files changed, 0 insertions, 56216 deletions
diff --git a/tests/README b/tests/README
deleted file mode 100644
index fe4bb30..0000000
--- a/tests/README
+++ /dev/null
@@ -1,423 +0,0 @@
-README -- Tcl test suite design document.
-
-RCS: @(#) $Id: README,v 1.3 1999/04/16 00:47:22 stanton Exp $
-
-Contents:
----------
-
- 1. Introduction
- 2. Definitions file
- 3. Writing a new test
- 4. Constraints
- 5. Adding a New Test File
- 6. Test output
- 7. Selecting tests for execution within a file
- 8. Selecting files to be sourced by all.tcl
- 9. Incompatibilities with prior Tcl versions
-
-1. Introduction:
-----------------
-
-This directory contains a set of validation tests for the Tcl commands
-and C Library procedures for Tcl. Each of the files whose name ends
-in ".test" is intended to fully exercise the functions in the C source
-file that corresponds to the file prefix. The C functions and/or Tcl
-commands tested by a given file are listed in the first line of the
-file.
-
-You can run the tests in three ways:
-
- (a) type "make test" in ../unix; this will run all of the tests.
-
- (b) type "tcltest <testFile> ?<option> <value>?
- Command line options include:
-
- -verbose <level> set the level of verbosity to a substring
- of "bps". See the "Test output" section
- for an explanation of this option.
-
- -match <matchList> only run tests that match one or more of
- the glob patterns in <matchList>
-
- -skip <skipList> do not run tests that match one or more
- of the glob patterns in <skipList>
-
- -file <globPattern> only source test files that match
- <globPattern> (relative to the "tests"
- directory). This option only applies
- when you run the test suite with the
- "all.tcl" file.
-
- -constraints <list> tests with any constraints in <list> will
- not be skipped. Not that elements of
- <list> must exactly match the existing
- constraints.
-
- (c) start up tcltest in this directory, then "source" the test
- file (for example, type "source parse.test"). To run all
- of the tests, type "source all.tcl". To use the options in
- interactive mode, you can set their corresponding tcltest
- namespace variables after sourcing the defs.tcl file.
- ::tcltest::match
- ::tcltest::skip
- ::tcltest::testConfig(nonPortable)
- ::tcltest::testConfig(knownBug)
- ::tcltest::testConfig(userInteractive)
-
-In all cases, no output will be generated if all goes well, except for
-a listing of the test files and a statistical summary. If there are
-errors, then additional messages will appear in the format described
-below. Note that some tests will be skipped if you run as superuser.
-
-This approach to testing was designed and initially implemented by
-Mary Ann May-Pumphrey of Sun Microsystems in the early 1990's. Many
-thanks to her for donating her work back to the public Tcl release.
-
-
-2. Definitions file:
---------------------
-
-The file "defs.tcl" defines the "tcltest" namespace which contains a
-collection of procedures and variables used to run the tests. It is
-read in automatically by each of the .test files if needed, but once
-it has been read once it will not be read again by the .test files.
-Currently, the following procedures are exported from the "tcltest"
-namespace and automatically imported:
-
- test Run a test script.
-
- cleanupTests Print stats and remove files created by tests.
-
- dotests Source a test file and run tests of the
- specified pattern.
-
- makeFile Create a file--the file will automatically
- be removed by cleanupTests.
-
- removeFile Force a file to be removed.
-
- makeDirectory Create a directory--the directory will
- automatically be removed by cleanupTests.
-
- removeDirectory Force a directory to be removed.
-
- viewFile Returns the contents of a file.
-
- normalizeMsg Remove extra newlines from a string.
-
- bytestring Construct a string that consists of the
- requested sequence of bytes, as opposed to a
- string of properly formed UTF-8 characters.
-
- set_iso8859_1_locale Set the locale to iso8859_1.
-
- restore_locale Restore the locale to its original setting.
-
- saveState Save the procedure and global variable names.
-
- restoreState Restore the procedure and global variable names.
-
-Please refer to the defs.tcl file for more documentation on these
-procedures.
-
-
-3. Writing a new test:
-----------------------
-
-The test procedure runs a test script and prints an error message if
-the script's result does not match the expected result. The following
-is the spec for the "test" command:
-
- test <name> <description> ?<constraint>? <script> <expectedAnswer>
-
-The <name> argument should follow the pattern,
-"<target>-<majorNum>.<minorNum>". For white-box (regression) tests,
-the target should be the name of the c function or Tcl procedure being
-tested. For black-box tests, the target should be the name of the
-feature being tested. Related tests should share a major number.
-
-The <description> argument is a short textual description of the test,
-to help humans understand what it does.
-
-The optional <constraints> argument is list of one or more keywords,
-each of which must be the name of an element in the array
-"::tcltest::testConfig". If any of these elements is false or does
-not exist, the test is skipped. Add appropriate constraints (e.g.,
-unixOnly) to any tests that should not always be run. For example, a
-test that should only be run on Unix should look like the following:
-
- test getAttribute-1.1 {testing file permissions} {unixOnly} {
- lindex [file attributes foo.tcl] 5
- } {00644}
-
-See the "Constraints" section for a list of built-in
-constraints and information on how to add your own constraints.
-
-The <script> argument contains the script to run to carry out the
-test. It must return a result that can be checked for correctness.
-If your script requires that a file be created on the fly, please use
-the ::tcltest::makeFile procedure. If your test requires that a small
-file (<50 lines) be checked in, please consider creating the file on
-the fly using the ::tcltest::makeFile procedure. Files created by the
-::tcltest::makeFile procedure will automatically be removed by the
-::tcltest::cleanupTests call at the end of each test file.
-
-The <expectedAnswer> argument will be compared against the result of
-evaluating the <script> argument. If they match, the test passes,
-otherwise the test fails.
-
-
-4. Constraints:
----------------
-
-Constraints are used to determine whether a test should be skipped.
-Each constraint is stored as an index in the array
-::tcltest::testConfig. For example, the unixOnly constraint is
-defined as the following:
-
- set ::tcltest::testConfig(unixOnly) \
- [expr {$tcl_platform(platform) == "unix"}]
-
-If a test is constrained by "unixOnly", then it will only be run if
-the value of ::tcltest::testConfig(unixOnly) is true.
-
-The following is a list of constraints defined in the defs.tcl file:
-
-unix test can only be run on any UNIX platform
-pc test can only be run on any Windows platform
-nt test can only be run on any Windows NT platform
-95 test can only be run on any Windows 95 platform
-mac test can only be run on any Mac platform
-unixOrPc test can only be run on a UNIX or PC platform
-macOrPc test can only be run on a Mac or PC platform
-macOrUnix test can only be run on a Mac or UNIX platform
-tempNotPc test can not be run on Windows. This flag is used
- to temporarily disable a test.
-tempNotMac test can not be run on a Mac. This flag is used
- to temporarily disable a test.
-unixCrash test crashes if it's run on UNIX. This flag is used
- to temporarily disable a test.
-pcCrash test crashes if it's run on Windows. This flag is
- used to temporarily disable a test.
-macCrash test crashes if it's run on a Mac. This flag is used
- to temporarily disable a test.
-
-emptyTest test is empty, and so not worth running, but
- it remains as a place-holder for a test to be
- written in the future. This constraint always
- causes tests to be skipped.
-
-knownBug test is known to fail and the bug is not yet
- fixed. This constraint always causes tests to be
- skipped unless the user specifies otherwise. See the
- "Introduction" section for more details.
-
-nonPortable test can only be run in the master Tcl/Tk
- development environment. Some tests are inherently
- non-portable because they depend on things like word
- length, file system configuration, window manager,
- etc. These tests are only run in the main Tcl
- development directory where the configuration is
- well known. This constraint always causes tests to be
- skipped unless the user specifies otherwise. See the
- "Introduction" section for more details.
-
-userInteraction test requires interaction from the user. This
- constraint always causes tests to be skipped unless
- the user specifies otherwise. See the "Introduction"
- section for more details.
-
-interactive test can only be run in if the interpreter is in
- interactive mode, that is the global tcl_interactive
- variable is set to 1.
-
-nonBlockFiles test can only be run if platform supports setting
- files into nonblocking mode
-
-asyncPipeClose test can only be run if platform supports async
- flush and async close on a pipe
-
-unixExecs test can only be run if this machine has commands
- such as 'cat', 'echo', etc. available.
-
-hasIsoLocale test can only be run if can switch to an ISO locale
-
-fonts test can only be run if the wish app's fonts can
- be controlled by Tk.
-
-root test can only run if Unix user is root
-
-notRoot test can only run if Unix user is not root
-
-eformat test can only run if app has a working version of
- sprintf with respect to the "e" format of
- floating-point numbers.
-
-stdio test can only be run if the current app can be
- spawned via a pipe
-
-
-5. Adding a new test file:
---------------------------
-
-Tests files should begin by sourcing the defs.tcl file:
-
- if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
- }
-
-Test files sould end by cleaning up after themselves and calling
-::tcltest::cleanupTests. The ::tcltest::cleanupTests procedure prints
-statistics about the number of tests that passed, skipped, and failed,
-and removes all files that were created using the ::tcltest::makeFile
-and ::tcltest::makeDirectory procedures.
-
- # Remove files created by these tests
- # Change to original working directory
- # Unset global arrays
- ::tcltest::cleanupTests
- return
-
-The all.tcl file will source your new test file if the filename
-matches the tests/*.test pattern (as it should). The names of test
-files that contain regression (or glass-box) tests should correspond
-to the Tcl or C code file that they are testing. For example, the
-test file for the C file "tclCmdAH.c" is "cmdAH.test". Test files
-that contain black-box tests may not correspond to any Tcl or C code
-file so they should match the pattern "*_bb.test".
-
-Be sure your new test file can be run from any working directory.
-
-Be sure no temporary files are left behind by your test file.
-
-Be sure your tests can run cross-platform in both a build environment
-as well as an installation environment. If your test file contains
-tests that should not be run in one or more of those cases, please use
-the constraints mechanism to skip those tests.
-
-
-6. Test output:
----------------
-
-After all specified test files are sourced, the number of tests
-passed, skipped, and failed is printed to stdout. Aside from this
-statistical information, output can be controlled on a per-test basis
-by the ::tcltest::verbose variable.
-
-::tcltest::verbose can be set to any substring or permutation of "bps".
-In the string "bps", the 'b' stands for a test's "body", the 'p'
-stands for "passed" tests, and the 's' stands for "skipped" tests.
-The default value of ::tcltest::verbose is "b". If 'b' is present, then
-the entire body of the test is printed for each failed test, otherwise
-only the test's name, desired output, and actual output, are printed
-for each failed test. If 'p' is present, then a line is printed for
-each passed test, otherwise no line is printed for passed tests. If
-'s' is present, then a line (containing the consraints that cause the
-test to be skipped) is printed for each skipped test, otherwise no
-line is printed for skipped tests.
-
-You can set ::tcltest::verbose either interactively (after the defs.tcl
-file has been sourced) or by the command line argument -verbose, for
-example:
-
- tcltest socket.test -verbose bps
-
-
-7. Selecting tests for execution within a file:
------------------------------------------------
-
-Normally, all the tests in a file are run whenever the file is
-sourced. An individual test will be skipped if one of the following
-conditions is met:
-
- 1) the "name" of the tests does not match (using glob style
- matching) one or more elements in the ::tcltest::match
- variable
-
- 2) the "name" of the tests matches (using glob style matching) one
- or more elements in the ::tcltest::skip variable
-
- 3) the "constraints" argument to the "test" call, if given,
- contains one or more false elements.
-
-You can set ::tcltest::match and/or ::tcltest::skip
-either interactively (after the defs.tcl file has been sourced), or by
-the command line arguments -match and -skip, for example:
-
- tcltest info.test -match '*-5.* *-7.*' -skip '*-7.1*'
-
-Be sure to use the proper quoting convention so that your shell does
-not perform the glob substitution on the match or skip patterns you
-specify.
-
-The two predefined constraints (knownBug and nonPortable) can be
-overridden either interactively (after the defs.tcl file has been
-sourced) by setting the ::tcltest::testConfig(<constraint>) variable,
-or by using the -constraints command line option with the name of the
-constraint in the argument. The following example shows how to run
-tests that are constrained by the knownBug and nonPortable
-restricions:
-
- tcltest all.tcl -constraints "knownBug nonPortable"
-
-See the defs.tcl file for information about each of these constraints.
-Other constraints can be added at any time. See the "Writing a new
-test" section below for more details about using built-in constraints
-and adding new ones.
-
-
-8. Selecting files to be sourced by all.tcl:
---------------------------------------------
-
-You can specify the files you want all.tcl to source on the command
-line with the -file options. For example, if you call the
-following:
-
- tcltest all.tcl -file 'unix*.test'
-
-all files in "tests" directory that match the pattern unix*.test will
-be sourced by the all.tcl file. Another useful example is if a
-particular test hangs, say "get.test", and you just want to run the
-remaining tests, then you can call the following:
-
- tcltest all.tcl -file '[h-z]*.test'
-
-Note that the argument to -file will be substituted relative to the
-"tests" directory. Be sure to use the proper quoting convention so
-that your shell does not perform the glob substitution.
-
-
-9. Incompatibilities with prior Tcl versions:
----------------------------------------------
-
-1) Global variables such as VERBOSE, TESTS, and testConfig are now
- renamed to use the new "tcltest" namespace.
-
- old name new name
- -------- --------
- VERBOSE ::tcltest::verbose
- TESTS ::tcltest::match
- testConfig ::tcltest::testConfig
-
- The introduction of the "tcltest" namespace is a precursor to using
- a "tcltest" package. This next step will be part of a future Tcl
- version.
-
-2) VERBOSE values are no longer numeric. Please see the section above
- on "Test output" for the new usage of the ::tcltest::verbose variable.
-
-3) When you run "make test", the working dir for the test suite is now
- the one from which you called "make test", rather than the "tests"
- directory. This change allows for both unix and windows test
- suites to be run simultaneously without interference with each
- other or with existing files. All tests must now run independently
- of their working directory.
-
-4) The "all", "defs", and "visual" files are now called "all.tcl",
- "defs.tcl", and "visual_bb.test", respectively.
-
-5) Instead of creating a doAllTests file in the tests directory, to
- run all nonPortable tests, just use the "-constraints nonPortable"
- command line flag. If you are running interactively, you can set
- the ::tcltest::testConfig(nonPortable) variable to 1 (after
- sourcing the defs.tcl file).
diff --git a/tests/all.tcl b/tests/all.tcl
deleted file mode 100644
index a6c596a..0000000
--- a/tests/all.tcl
+++ /dev/null
@@ -1,76 +0,0 @@
-# all.tcl --
-#
-# This file contains a top-level script to run all of the Tcl
-# tests. Execute it by invoking "source all.test" when running tcltest
-# in this directory.
-#
-# Copyright (c) 1998-1999 by Scriptics Corporation.
-# All rights reserved.
-#
-# RCS: @(#) $Id: all.tcl,v 1.2 1999/04/16 00:47:23 stanton Exp $
-
-if {[lsearch ::tcltest [namespace children]] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-set ::tcltest::testSingleFile false
-
-puts stdout "Tcl $tcl_patchLevel tests running in interp: [info nameofexecutable]"
-puts stdout "Tests running in working dir: $::tcltest::workingDir"
-if {[llength $::tcltest::skip] > 0} {
- puts stdout "Skipping tests that match: $::tcltest::skip"
-}
-if {[llength $::tcltest::match] > 0} {
- puts stdout "Only running tests that match: $::tcltest::match"
-}
-
-# Use command line specified glob pattern (specified by -file or -f)
-# if one exists. Otherwise use *.test. If given, the file pattern
-# should be specified relative to the dir containing this file. If no
-# files are found to match the pattern, print an error message and exit.
-set fileIndex [expr {[lsearch $argv "-file"] + 1}]
-set fIndex [expr {[lsearch $argv "-f"] + 1}]
-if {($fileIndex < 1) || ($fIndex > $fileIndex)} {
- set fileIndex $fIndex
-}
-if {$fileIndex > 0} {
- set globPattern [file join $::tcltest::testsDir [lindex $argv $fileIndex]]
- puts stdout "Sourcing files that match: $globPattern"
-} else {
- set globPattern [file join $::tcltest::testsDir *.test]
-}
-set fileList [glob -nocomplain $globPattern]
-if {[llength $fileList] < 1} {
- puts "Error: no files found matching $globPattern"
- exit
-}
-set timeCmd {clock format [clock seconds]}
-puts stdout "Tests began at [eval $timeCmd]"
-
-# source each of the specified tests
-foreach file [lsort $fileList] {
- set tail [file tail $file]
- if {[string match l.*.test $tail]} {
- # This is an SCCS lockfile; ignore it
- continue
- }
- puts stdout $tail
- if {[catch {source $file} msg]} {
- puts stdout $msg
- }
-}
-
-# cleanup
-puts stdout "\nTests ended at [eval $timeCmd]"
-::tcltest::cleanupTests 1
-return
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/append.test b/tests/append.test
deleted file mode 100644
index e64df06..0000000
--- a/tests/append.test
+++ /dev/null
@@ -1,194 +0,0 @@
-# Commands covered: append lappend
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-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: append.test,v 1.3 1999/04/16 00:47:23 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-catch {unset x}
-
-test append-1.1 {append command} {
- catch {unset x}
- list [append x 1 2 abc "long string"] $x
-} {{12abclong string} {12abclong string}}
-test append-1.2 {append command} {
- set x ""
- list [append x first] [append x second] [append x third] $x
-} {first firstsecond firstsecondthird firstsecondthird}
-test append-1.3 {append command} {
- set x "abcd"
- append x
-} abcd
-
-test append-2.1 {long appends} {
- set x ""
- for {set i 0} {$i < 1000} {set i [expr $i+1]} {
- append x "foobar "
- }
- set y "foobar"
- set y "$y $y $y $y $y $y $y $y $y $y"
- set y "$y $y $y $y $y $y $y $y $y $y"
- set y "$y $y $y $y $y $y $y $y $y $y "
- expr {$x == $y}
-} 1
-
-test append-3.1 {append errors} {
- list [catch {append} msg] $msg
-} {1 {wrong # args: should be "append varName ?value value ...?"}}
-test append-3.2 {append errors} {
- set x ""
- list [catch {append x(0) 44} msg] $msg
-} {1 {can't set "x(0)": variable isn't array}}
-test append-3.3 {append errors} {
- catch {unset x}
- list [catch {append x} msg] $msg
-} {1 {can't read "x": no such variable}}
-
-test append-4.1 {lappend command} {
- catch {unset x}
- list [lappend x 1 2 abc "long string"] $x
-} {{1 2 abc {long string}} {1 2 abc {long string}}}
-test append-4.2 {lappend command} {
- set x ""
- list [lappend x first] [lappend x second] [lappend x third] $x
-} {first {first second} {first second third} {first second third}}
-test append-4.3 {lappend command} {
- proc foo {} {
- global x
- set x old
- unset x
- lappend x new
- }
- set result [foo]
- rename foo {}
- set result
-} {new}
-test append-4.4 {lappend command} {
- set x {}
- lappend x \{\ abc
-} {\{\ abc}
-test append-4.5 {lappend command} {
- set x {}
- lappend x \{ abc
-} {\{ abc}
-test append-4.6 {lappend command} {
- set x {1 2 3}
- lappend x
-} {1 2 3}
-test append-4.7 {lappend command} {
- set x "a\{"
- lappend x abc
-} "a\\\{ abc"
-test append-4.8 {lappend command} {
- set x "\\\{"
- lappend x abc
-} "\\{ abc"
-test append-4.9 {lappend command} {
- set x " \{"
- list [catch {lappend x abc} msg] $msg
-} {1 {unmatched open brace in list}}
-test append-4.10 {lappend command} {
- set x " \{"
- list [catch {lappend x abc} msg] $msg
-} {1 {unmatched open brace in list}}
-test append-4.11 {lappend command} {
- set x "\{\{\{"
- list [catch {lappend x abc} msg] $msg
-} {1 {unmatched open brace in list}}
-test append-4.12 {lappend command} {
- set x "x \{\{\{"
- list [catch {lappend x abc} msg] $msg
-} {1 {unmatched open brace in list}}
-test append-4.13 {lappend command} {
- set x "x\{\{\{"
- lappend x abc
-} "x\\\{\\\{\\\{ abc"
-test append-4.14 {lappend command} {
- set x " "
- lappend x abc
-} "abc"
-test append-4.15 {lappend command} {
- set x "\\ "
- lappend x abc
-} "{ } abc"
-test append-4.16 {lappend command} {
- set x "x "
- lappend x abc
-} "x abc"
-test append-4.17 {lappend command} {
- catch {unset x}
- lappend x
-} {}
-
-proc check {var size} {
- set l [llength $var]
- if {$l != $size} {
- return "length mismatch: should have been $size, was $l"
- }
- for {set i 0} {$i < $size} {set i [expr $i+1]} {
- set j [lindex $var $i]
- if {$j != "item $i"} {
- return "element $i should have been \"item $i\", was \"$j\""
- }
- }
- return ok
-}
-test append-5.1 {long lappends} {
- set x ""
- for {set i 0} {$i < 300} {set i [expr $i+1]} {
- lappend x "item $i"
- }
- check $x 300
-} ok
-
-test append-6.1 {lappend errors} {
- list [catch {lappend} msg] $msg
-} {1 {wrong # args: should be "lappend varName ?value value ...?"}}
-test append-6.2 {lappend errors} {
- set x ""
- list [catch {lappend x(0) 44} msg] $msg
-} {1 {can't set "x(0)": variable isn't array}}
-
-test append-7.1 {lappend-created var and error in trace on that var} {
- catch {rename foo ""}
- catch {unset x}
- trace variable x w foo
- proc foo {} {global x; unset x}
- catch {lappend x 1}
- proc foo {args} {global x; unset x}
- info exists x
- set x
- lappend x 1
- list [info exists x] [catch {set x} msg] $msg
-} {0 1 {can't read "x": no such variable}}
-
-catch {unset i x result y}
-catch {rename foo ""}
-catch {rename check ""}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/assocd.test b/tests/assocd.test
deleted file mode 100644
index a618606..0000000
--- a/tests/assocd.test
+++ /dev/null
@@ -1,77 +0,0 @@
-# This file tests the AssocData facility of Tcl
-#
-# 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) 1991-1994 The Regents of the University of California.
-# Copyright (c) 1994 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: assocd.test,v 1.3 1999/04/16 00:47:23 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[string compare testsetassocdata [info commands testsetassocdata]] != 0} {
- puts "This application hasn't been compiled with the tests for assocData,"
- puts "therefore I am skipping all of these tests."
- ::tcltest::cleanupTests
- return
-}
-
-test assocd-1.1 {testing setting assoc data} {
- testsetassocdata a 1
-} ""
-test assocd-1.2 {testing setting assoc data} {
- testsetassocdata a 2
-} ""
-test assocd-1.3 {testing setting assoc data} {
- testsetassocdata 123 456
-} ""
-test assocd-1.4 {testing setting assoc data} {
- testsetassocdata abc "abc d e f"
-} ""
-
-test assocd-2.1 {testing getting assoc data} {
- testgetassocdata a
-} 2
-test assocd-2.2 {testing getting assoc data} {
- testgetassocdata 123
-} 456
-test assocd-2.3 {testing getting assoc data} {
- testgetassocdata abc
-} {abc d e f}
-test assocd-2.4 {testing getting assoc data} {
- testgetassocdata xxx
-} ""
-
-test assocd-3.1 {testing deleting assoc data} {
- testdelassocdata a
-} ""
-test assocd-3.2 {testing deleting assoc data} {
- testdelassocdata 123
-} ""
-test assocd-3.3 {testing deleting assoc data} {
- list [catch {testdelassocdata nonexistent} msg] $msg
-} {0 {}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/async.test b/tests/async.test
deleted file mode 100644
index 4b4d655..0000000
--- a/tests/async.test
+++ /dev/null
@@ -1,150 +0,0 @@
-# Commands covered: none
-#
-# This file contains a collection of tests for Tcl_AsyncCreate and related
-# library procedures. Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-#
-# Copyright (c) 1993 The Regents of the University of California.
-# Copyright (c) 1994-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: async.test,v 1.3 1999/04/16 00:47:23 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[info commands testasync] == {}} {
- puts "This application hasn't been compiled with the \"testasync\""
- puts "command, so I can't test Tcl_AsyncCreate et al."
- ::tcltest::cleanupTests
- return
-}
-
-proc async1 {result code} {
- global aresult acode
- set aresult $result
- set acode $code
- return "new result"
-}
-proc async2 {result code} {
- global aresult acode
- set aresult $result
- set acode $code
- return -code error "xyzzy"
-}
-proc async3 {result code} {
- global aresult
- set aresult "test pattern"
- return -code $code $result
-}
-
-set handler1 [testasync create async1]
-set handler2 [testasync create async2]
-set handler3 [testasync create async3]
-test async-1.1 {basic async handlers} {
- set aresult xxx
- set acode yyy
- list [catch {testasync mark $handler1 "original" 0} msg] $msg \
- $acode $aresult
-} {0 {new result} 0 original}
-test async-1.2 {basic async handlers} {
- set aresult xxx
- set acode yyy
- list [catch {testasync mark $handler1 "original" 1} msg] $msg \
- $acode $aresult
-} {0 {new result} 1 original}
-test async-1.3 {basic async handlers} {
- set aresult xxx
- set acode yyy
- list [catch {testasync mark $handler2 "old" 0} msg] $msg \
- $acode $aresult
-} {1 xyzzy 0 old}
-test async-1.4 {basic async handlers} {
- set aresult xxx
- set acode yyy
- list [catch {testasync mark $handler2 "old" 3} msg] $msg \
- $acode $aresult
-} {1 xyzzy 3 old}
-test async-1.5 {basic async handlers} {
- set aresult xxx
- list [catch {testasync mark $handler3 "foobar" 0} msg] $msg $aresult
-} {0 foobar {test pattern}}
-test async-1.6 {basic async handlers} {
- set aresult xxx
- list [catch {testasync mark $handler3 "foobar" 1} msg] $msg $aresult
-} {1 foobar {test pattern}}
-
-proc mult1 {result code} {
- global x
- lappend x mult1
- return -code 7 mult1
-}
-set hm1 [testasync create mult1]
-proc mult2 {result code} {
- global x
- lappend x mult2
- return -code 9 mult2
-}
-set hm2 [testasync create mult2]
-proc mult3 {result code} {
- global x hm1 hm2
- lappend x [catch {testasync mark $hm2 serial2 0}]
- lappend x [catch {testasync mark $hm1 serial1 0}]
- lappend x mult3
- return -code 11 mult3
-}
-set hm3 [testasync create mult3]
-
-test async-2.1 {multiple handlers} {
- set x {}
- list [catch {testasync mark $hm3 "foobar" 5} msg] $msg $x
-} {9 mult2 {0 0 mult3 mult1 mult2}}
-
-proc del1 {result code} {
- global x hm1 hm2 hm3 hm4
- lappend x [catch {testasync mark $hm3 serial2 0}]
- lappend x [catch {testasync mark $hm1 serial1 0}]
- lappend x [catch {testasync mark $hm4 serial1 0}]
- testasync delete $hm1
- testasync delete $hm2
- testasync delete $hm3
- lappend x del1
- return -code 13 del1
-}
-proc del2 {result code} {
- global x
- lappend x del2
- return -code 3 del2
-}
-testasync delete $handler1
-testasync delete $hm2
-testasync delete $hm3
-set hm2 [testasync create del1]
-set hm3 [testasync create mult2]
-set hm4 [testasync create del2]
-
-test async-3.1 {deleting handlers} {
- set x {}
- list [catch {testasync mark $hm2 "foobar" 5} msg] $msg $x
-} {3 del2 {0 0 0 del1 del2}}
-
-# cleanup
-testasync delete
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/autoMkindex.tcl b/tests/autoMkindex.tcl
deleted file mode 100644
index 2756358..0000000
--- a/tests/autoMkindex.tcl
+++ /dev/null
@@ -1,73 +0,0 @@
-# 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"}
- }
-}
-
-# With proper hooks, we should be able to support other commands
-# that create procedures
-
-proc buried::myproc {name body args} {
- ::proc $name $body $args
-}
-namespace eval ::buried {
- proc mycmd1 args {return "mycmd"}
- myproc mycmd2 args {return "mycmd"}
-}
-::buried::myproc mycmd3 args {return "another"}
-
-proc {buried::my proc} {name body args} {
- ::proc $name $body $args
-}
-namespace eval ::buried {
- proc mycmd4 args {return "mycmd"}
- {my proc} mycmd5 args {return "mycmd"}
-}
-{::buried::my proc} mycmd6 args {return "another"}
diff --git a/tests/autoMkindex.test b/tests/autoMkindex.test
deleted file mode 100644
index 452eed6..0000000
--- a/tests/autoMkindex.test
+++ /dev/null
@@ -1,189 +0,0 @@
-# Commands covered: auto_mkindex auto_import
-#
-# This file contains tests related to autoloading and generating
-# the autoloading index.
-#
-# Copyright (c) 1998 Lucent Technologies, 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: autoMkindex.test,v 1.5 1999/04/16 00:47:23 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# temporarily copy the autoMkindex.tcl file from testsDir to tmpDir
-set origMkindexFile [file join $::tcltest::testsDir autoMkindex.tcl]
-set newMkindexFile [file join $::tcltest::workingDir autoMkindex.tcl]
-if {![catch {file copy $origMkindexFile $newMkindexFile}]} {
- set removeAutoMkindex 1
-}
-
-# Save initial state of auto_mkindex_parser
-
-auto_load auto_mkindex
-if {[info exist auto_mkindex_parser::initCommands]} {
- set saveCommands $auto_mkindex_parser::initCommands
-}
-proc AutoMkindexTestReset {} {
- global saveCommands
- if {[info exist saveCommands]} {
- set auto_mkindex_parser::initCommands $saveCommands
- } elseif {[info exist auto_mkindex_parser::initCommands]} {
- unset auto_mkindex_parser::initCommands
- }
-}
-
-set result ""
-
-test autoMkindex-1.1 {remove any existing tclIndex file} {
- file delete tclIndex
- file exists tclIndex
-} {0}
-
-test autoMkindex-1.2 {build tclIndex based on a test file} {
- auto_mkindex . autoMkindex.tcl
- file exists tclIndex
-} {1}
-
-set element "{source [file join . autoMkindex.tcl]}"
-
-test autoMkindex-1.3 {examine tclIndex} {
- file delete tclIndex
- auto_mkindex . autoMkindex.tcl
- namespace eval tcl_autoMkindex_tmp {
- set dir "."
- variable auto_index
- source tclIndex
- set ::result ""
- foreach elem [lsort [array names auto_index]] {
- lappend ::result [list $elem $auto_index($elem)]
- }
- }
- namespace delete tcl_autoMkindex_tmp
- set ::result
-} "{::buried::explicit $element} {::buried::inside $element} {{::buried::my proc} $element} {::buried::mycmd1 $element} {::buried::mycmd4 $element} {::buried::myproc $element} {::buried::pub_one $element} {::buried::pub_two $element} {::buried::relative $element} {::buried::under::neath $element} {::buried::within $element} {indented $element} {normal $element} {top $element}"
-
-
-test autoMkindex-2.1 {commands on the autoload path can be imported} {
- file delete tclIndex
- auto_mkindex . autoMkindex.tcl
- set interp [interp create]
- set final [$interp eval {
- namespace eval blt {}
- set auto_path [linsert $auto_path 0 .]
- set info [list [catch {namespace import buried::*} result] $result]
- foreach name [lsort [info commands pub_*]] {
- lappend info $name [namespace origin $name]
- }
- set info
- }]
- interp delete $interp
- set final
-} "0 {} pub_one ::buried::pub_one pub_two ::buried::pub_two"
-
-# Test auto_mkindex hooks
-
-# Slave hook executes interesting code in the interp used to watch code.
-
-test autoMkindex-3.1 {slaveHook} {
- auto_mkindex_parser::slavehook {
- _%@namespace eval ::blt {
- proc foo {} {}
- _%@namespace export foo
- }
- }
- auto_mkindex_parser::slavehook { _%@namespace import -force ::blt::* }
- file delete tclIndex
- auto_mkindex . autoMkindex.tcl
-
- # Reset initCommands to avoid trashing other tests
-
- AutoMkindexTestReset
- file exists tclIndex
-} 1
-
-# The auto_mkindex_parser::command is used to register commands
-# that create new commands.
-
-test autoMkindex-3.2 {auto_mkindex_parser::command} {
- auto_mkindex_parser::command buried::myproc {name args} {
- variable index
- variable scriptFile
- append index [list set auto_index([fullname $name])] \
- " \[list source \[file join \$dir [list $scriptFile]\]\]\n"
- }
- file delete tclIndex
- auto_mkindex . autoMkindex.tcl
- namespace eval tcl_autoMkindex_tmp {
- set dir "."
- variable auto_index
- source tclIndex
- set ::result ""
- foreach elem [lsort [array names auto_index]] {
- lappend ::result [list $elem $auto_index($elem)]
- }
- }
- namespace delete tcl_autoMkindex_tmp
-
- # Reset initCommands to avoid trashing other tests
-
- AutoMkindexTestReset
- set ::result
-} "{::buried::explicit $element} {::buried::inside $element} {{::buried::my proc} $element} {::buried::mycmd1 $element} {::buried::mycmd2 $element} {::buried::mycmd4 $element} {::buried::myproc $element} {::buried::pub_one $element} {::buried::pub_two $element} {::buried::relative $element} {::buried::under::neath $element} {::buried::within $element} {indented $element} {mycmd3 $element} {normal $element} {top $element}"
-
-
-test autoMkindex-3.3 {auto_mkindex_parser::command} {knownBug} {
- auto_mkindex_parser::command {buried::my proc} {name args} {
- variable index
- variable scriptFile
- puts "my proc $name"
- append index [list set auto_index([fullname $name])] \
- " \[list source \[file join \$dir [list $scriptFile]\]\]\n"
- }
- file delete tclIndex
- auto_mkindex . autoMkindex.tcl
- namespace eval tcl_autoMkindex_tmp {
- set dir "."
- variable auto_index
- source tclIndex
- set ::result ""
- foreach elem [lsort [array names auto_index]] {
- lappend ::result [list $elem $auto_index($elem)]
- }
- }
- namespace delete tcl_autoMkindex_tmp
-
- # Reset initCommands to avoid trashing other tests
-
- AutoMkindexTestReset
- proc lvalue {list pattern} {
- set ix [lsearch $list $pattern]
- if {$ix >= 0} {
- return [lindex $list $ix]
- } else {
- return {}
- }
- }
- list [lvalue $::result *mycmd4*] [lvalue $::result *mycmd5*] [lvalue $::result *mycmd6*]
-} "{::buried::mycmd4 $element} {::buried::mycmd5 $element} {mycmd6 $element}"
-
-# Clean up.
-
-unset result
-AutoMkindexTestReset
-if {[info exist saveCommands]} {
- unset saveCommands
-}
-rename AutoMkindexTestReset ""
-
-if {[info exists removeAutoMkindex]} {
- catch {file delete $newMkindexFile}
-}
-if {[file exists tclIndex]} {
- file delete -force tclIndex
-}
-::tcltest::cleanupTests
diff --git a/tests/basic.test b/tests/basic.test
deleted file mode 100644
index b6274bf..0000000
--- a/tests/basic.test
+++ /dev/null
@@ -1,545 +0,0 @@
-# This file contains tests for the tclBasic.c source file. Tests appear in
-# the same order as the C code that they test. The set of tests is
-# currently incomplete since it currently includes only new tests for
-# code changed for the addition of Tcl namespaces. Other variable-
-# related tests appear in several other test files including
-# assocd.test, cmdInfo.test, eval.test, expr.test, interp.test,
-# and trace.test.
-#
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 1997 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: basic.test,v 1.5 1999/04/16 00:47:23 stanton Exp $
-#
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-catch {namespace delete test_ns_basic}
-catch {interp delete test_interp}
-catch {rename p ""}
-catch {rename q ""}
-catch {rename cmd ""}
-catch {unset x}
-
-test basic-1.1 {Tcl_CreateInterp, creates interp's global namespace} {
- catch {interp delete test_interp}
- interp create test_interp
- interp eval test_interp {
- namespace eval test_ns_basic {
- proc p {} {
- return [namespace current]
- }
- }
- }
- list [interp eval test_interp {test_ns_basic::p}] \
- [interp delete test_interp]
-} {::test_ns_basic {}}
-
-test basic-2.1 {TclHideUnsafeCommands} {emptyTest} {
-} {}
-
-test basic-3.1 {Tcl_CallWhenDeleted: see dcall.test} {emptyTest} {
-} {}
-
-test basic-4.1 {Tcl_DontCallWhenDeleted: see dcall.test} {emptyTest} {
-} {}
-
-test basic-5.1 {Tcl_SetAssocData: see assoc.test} {emptyTest} {
-} {}
-
-test basic-6.1 {Tcl_DeleteAssocData: see assoc.test} {emptyTest} {
-} {}
-
-test basic-7.1 {Tcl_GetAssocData: see assoc.test} {emptyTest} {
-} {}
-
-test basic-8.1 {Tcl_InterpDeleted} {emptyTest} {
-} {}
-
-test basic-9.1 {Tcl_DeleteInterp: see interp.test} {emptyTest} {
-} {}
-
-test basic-10.1 {DeleteInterpProc, destroys interp's global namespace} {
- catch {interp delete test_interp}
- interp create test_interp
- interp eval test_interp {
- namespace eval test_ns_basic {
- namespace export p
- proc p {} {
- return [namespace current]
- }
- }
- namespace eval test_ns_2 {
- namespace import ::test_ns_basic::p
- variable v 27
- proc q {} {
- variable v
- return "[p] $v"
- }
- }
- }
- list [interp eval test_interp {test_ns_2::q}] \
- [interp eval test_interp {namespace delete ::}] \
- [catch {interp eval test_interp {set a 123}} msg] $msg \
- [interp delete test_interp]
-} {{::test_ns_basic 27} {} 1 {invalid command name "set"} {}}
-
-test basic-11.1 {HiddenCmdsDeleteProc, invalidate cached refs to deleted hidden cmd} {
- catch {interp delete test_interp}
- interp create test_interp
- interp eval test_interp {
- proc p {} {
- return 27
- }
- }
- interp alias {} localP test_interp p
- list [interp eval test_interp {p}] \
- [localP] \
- [test_interp hide p] \
- [catch {localP} msg] $msg \
- [interp delete test_interp] \
- [catch {localP} msg] $msg
-} {27 27 {} 1 {invalid command name "p"} {} 1 {invalid command name "localP"}}
-
-# NB: More tests about hide/expose are found in interp.test
-
-test basic-12.1 {Tcl_HideCommand, names of hidden cmds can't have namespace qualifiers} {
- catch {interp delete test_interp}
- interp create test_interp
- interp eval test_interp {
- namespace eval test_ns_basic {
- proc p {} {
- return [namespace current]
- }
- }
- }
- list [catch {test_interp hide test_ns_basic::p x} msg] $msg \
- [catch {test_interp hide x test_ns_basic::p} msg1] $msg1 \
- [interp delete test_interp]
-} {1 {can only hide global namespace commands (use rename then hide)} 1 {cannot use namespace qualifiers as hidden commandtoken (rename)} {}}
-
-test basic-12.2 {Tcl_HideCommand, a hidden cmd remembers its containing namespace} {
- catch {namespace delete test_ns_basic}
- catch {rename cmd ""}
- proc cmd {} { ;# note that this is global
- return [namespace current]
- }
- namespace eval test_ns_basic {
- proc hideCmd {} {
- interp hide {} cmd
- }
- proc exposeCmd {} {
- interp expose {} cmd
- }
- proc callCmd {} {
- cmd
- }
- }
- list [test_ns_basic::callCmd] \
- [test_ns_basic::hideCmd] \
- [catch {cmd} msg] $msg \
- [test_ns_basic::exposeCmd] \
- [test_ns_basic::callCmd] \
- [namespace delete test_ns_basic]
-} {:: {} 1 {invalid command name "cmd"} {} :: {}}
-
-test basic-13.1 {Tcl_ExposeCommand, a command stays in the global namespace and can not go to another namespace} {
- catch {namespace delete test_ns_basic}
- catch {rename cmd ""}
- proc cmd {} { ;# note that this is global
- return [namespace current]
- }
- namespace eval test_ns_basic {
- proc hideCmd {} {
- interp hide {} cmd
- }
- proc exposeCmdFailing {} {
- interp expose {} cmd ::test_ns_basic::newCmd
- }
- proc exposeCmdWorkAround {} {
- interp expose {} cmd;
- rename cmd ::test_ns_basic::newCmd;
- }
- proc callCmd {} {
- cmd
- }
- }
- list [test_ns_basic::callCmd] \
- [test_ns_basic::hideCmd] \
- [catch {test_ns_basic::exposeCmdFailing} msg] $msg \
- [test_ns_basic::exposeCmdWorkAround] \
- [test_ns_basic::newCmd] \
- [namespace delete test_ns_basic]
-} {:: {} 1 {can not expose to a namespace (use expose to toplevel, then rename)} {} ::test_ns_basic {}}
-test basic-13.2 {Tcl_ExposeCommand, invalidate cached refs to cmd now being exposed} {
- catch {rename p ""}
- catch {rename cmd ""}
- proc p {} {
- cmd
- }
- proc cmd {} {
- return 42
- }
- list [p] \
- [interp hide {} cmd] \
- [proc cmd {} {return Hello}] \
- [cmd] \
- [rename cmd ""] \
- [interp expose {} cmd] \
- [p]
-} {42 {} {} Hello {} {} 42}
-
-if {[info commands testcreatecommand] == ""} {
- puts "This application hasn't been compiled with the testcreatecommand"
- puts "command. Skipping affected tests."
-} else {
-test basic-14.1 {Tcl_CreateCommand, new cmd goes into a namespace specified in its name, if any} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [testcreatecommand create] \
- [test_ns_basic::createdcommand] \
- [testcreatecommand delete]
-} {{} {CreatedCommandProc in ::test_ns_basic} {}}
-test basic-14.2 {Tcl_CreateCommand, namespace code ignore single ":"s in middle or end of names} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {rename value:at: ""}
- list [testcreatecommand create2] \
- [value:at:] \
- [testcreatecommand delete2]
-} {{} {CreatedCommandProc2 in ::} {}}
-}
-
-test basic-15.1 {Tcl_CreateObjCommand, new cmd goes into a namespace specified in its name, if any} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_basic {}
- proc test_ns_basic::cmd {} { ;# proc requires that ns already exist
- return [namespace current]
- }
- list [test_ns_basic::cmd] \
- [namespace delete test_ns_basic]
-} {::test_ns_basic {}}
-
-test basic-16.1 {TclInvokeStringCommand} {emptyTest} {
-} {}
-
-test basic-17.1 {TclInvokeObjCommand} {emptyTest} {
-} {}
-
-test basic-18.1 {TclRenameCommand, name of existing cmd can have namespace qualifiers} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {rename cmd ""}
- namespace eval test_ns_basic {
- proc p {} {
- return "p in [namespace current]"
- }
- }
- list [test_ns_basic::p] \
- [rename test_ns_basic::p test_ns_basic::q] \
- [test_ns_basic::q]
-} {{p in ::test_ns_basic} {} {p in ::test_ns_basic}}
-test basic-18.2 {TclRenameCommand, existing cmd must be found} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {rename test_ns_basic::p test_ns_basic::q} msg] $msg
-} {1 {can't rename "test_ns_basic::p": command doesn't exist}}
-test basic-18.3 {TclRenameCommand, delete cmd if new name is empty} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_basic {
- proc p {} {
- return "p in [namespace current]"
- }
- }
- list [info commands test_ns_basic::*] \
- [rename test_ns_basic::p ""] \
- [info commands test_ns_basic::*]
-} {::test_ns_basic::p {} {}}
-test basic-18.4 {TclRenameCommand, bad new name} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_basic {
- proc p {} {
- return "p in [namespace current]"
- }
- }
- rename test_ns_basic::p :::george::martha
-} {}
-test basic-18.5 {TclRenameCommand, new name must not already exist} {
- namespace eval test_ns_basic {
- proc q {} {
- return 42
- }
- }
- list [catch {rename test_ns_basic::q :::george::martha} msg] $msg
-} {1 {can't rename to ":::george::martha": command already exists}}
-test basic-18.6 {TclRenameCommand, check for command shadowing by newly renamed cmd} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {rename p ""}
- catch {rename q ""}
- proc p {} {
- return "p in [namespace current]"
- }
- proc q {} {
- return "q in [namespace current]"
- }
- namespace eval test_ns_basic {
- proc callP {} {
- p
- }
- }
- list [test_ns_basic::callP] \
- [rename q test_ns_basic::p] \
- [test_ns_basic::callP]
-} {{p in ::} {} {q in ::test_ns_basic}}
-
-test basic-19.1 {Tcl_SetCommandInfo} {emptyTest} {
-} {}
-
-if {[info commands testcmdtoken] == {}} {
- puts "This application hasn't been compiled with the \"testcmdtoken\""
- puts "command, so I can't test Tcl_GetCommandInfo."
-} else {
-test basic-20.1 {Tcl_GetCommandInfo, names for commands created inside namespaces} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {rename p ""}
- catch {rename q ""}
- catch {unset x}
- set x [namespace eval test_ns_basic::test_ns_basic2 {
- # the following creates a cmd in the global namespace
- testcmdtoken create p
- }]
- list [testcmdtoken name $x] \
- [rename ::p q] \
- [testcmdtoken name $x]
-} {{p ::p} {} {q ::q}}
-test basic-20.2 {Tcl_GetCommandInfo, names for commands created outside namespaces} {
- catch {rename q ""}
- set x [testcmdtoken create test_ns_basic::test_ns_basic2::p]
- list [testcmdtoken name $x] \
- [rename test_ns_basic::test_ns_basic2::p q] \
- [testcmdtoken name $x]
-} {{p ::test_ns_basic::test_ns_basic2::p} {} {q ::q}}
-}
-
-test basic-21.1 {Tcl_GetCommandName} {emptyTest} {
-} {}
-
-test basic-22.1 {Tcl_GetCommandFullName} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_basic1 {
- namespace export cmd*
- proc cmd1 {} {}
- proc cmd2 {} {}
- }
- namespace eval test_ns_basic2 {
- namespace export *
- namespace import ::test_ns_basic1::*
- proc p {} {}
- }
- namespace eval test_ns_basic3 {
- namespace import ::test_ns_basic2::*
- proc q {} {}
- list [namespace which -command foreach] \
- [namespace which -command q] \
- [namespace which -command p] \
- [namespace which -command cmd1] \
- [namespace which -command ::test_ns_basic2::cmd2]
- }
-} {::foreach ::test_ns_basic3::q ::test_ns_basic3::p ::test_ns_basic3::cmd1 ::test_ns_basic2::cmd2}
-
-test basic-23.1 {Tcl_DeleteCommand} {emptyTest} {
-} {}
-
-test basic-24.1 {Tcl_DeleteCommandFromToken, invalidate all compiled code if cmd has compile proc} {
- catch {interp delete test_interp}
- catch {unset x}
- interp create test_interp
- interp eval test_interp {
- proc useSet {} {
- return [set a 123]
- }
- }
- set x [interp eval test_interp {useSet}]
- interp eval test_interp {
- rename set ""
- proc set {args} {
- return "set called with $args"
- }
- }
- list $x \
- [interp eval test_interp {useSet}] \
- [interp delete test_interp]
-} {123 {set called with a 123} {}}
-test basic-24.2 {Tcl_DeleteCommandFromToken, deleting commands changes command epoch} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {rename p ""}
- proc p {} {
- return "global p"
- }
- namespace eval test_ns_basic {
- proc p {} {
- return "namespace p"
- }
- proc callP {} {
- p
- }
- }
- list [test_ns_basic::callP] \
- [rename test_ns_basic::p ""] \
- [test_ns_basic::callP]
-} {{namespace p} {} {global p}}
-test basic-24.3 {Tcl_DeleteCommandFromToken, delete imported cmds that refer to a deleted cmd} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {rename p ""}
- namespace eval test_ns_basic {
- namespace export p
- proc p {} {return 42}
- }
- namespace eval test_ns_basic2 {
- namespace import ::test_ns_basic::*
- proc callP {} {
- p
- }
- }
- list [test_ns_basic2::callP] \
- [info commands test_ns_basic2::*] \
- [rename test_ns_basic::p ""] \
- [catch {test_ns_basic2::callP} msg] $msg \
- [info commands test_ns_basic2::*]
-} {42 {::test_ns_basic2::callP ::test_ns_basic2::p} {} 1 {invalid command name "p"} ::test_ns_basic2::callP}
-
-test basic-25.1 {TclCleanupCommand} {emptyTest} {
-} {}
-
-test basic-26.1 {Tcl_EvalObj: preserve object while evaling it} {
- # If object isn't preserved, errorInfo would be set to
- # "foo\n while executing\n\"garbage bytes\"" because the object's
- # string would have been freed, leaving garbage bytes for the error
- # message.
-
- proc bgerror {args} {set ::x $::errorInfo}
- set f [open test1 w]
- fileevent $f writable "fileevent $f writable {}; error foo"
- set x {}
- vwait x
- close $f
- file delete test1
- rename bgerror {}
- set x
-} "foo\n while executing\n\"error foo\""
-
-test basic-27.1 {Tcl_ExprLong} {emptyTest} {
-} {}
-
-test basic-28.1 {Tcl_ExprDouble} {emptyTest} {
-} {}
-
-test basic-29.1 {Tcl_ExprBoolean} {emptyTest} {
-} {}
-
-test basic-30.1 {Tcl_ExprLongObj} {emptyTest} {
-} {}
-
-test basic-31.1 {Tcl_ExprDoubleObj} {emptyTest} {
-} {}
-
-test basic-32.1 {Tcl_ExprBooleanObj} {emptyTest} {
-} {}
-
-test basic-33.1 {TclInvoke} {emptyTest} {
-} {}
-
-test basic-34.1 {TclGlobalInvoke} {emptyTest} {
-} {}
-
-test basic-35.1 {TclObjInvokeGlobal} {emptyTest} {
-} {}
-
-test basic-36.1 {TclObjInvoke, lookup of "unknown" command} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {interp delete test_interp}
- interp create test_interp
- interp eval test_interp {
- proc unknown {args} {
- return "global unknown"
- }
- namespace eval test_ns_basic {
- proc unknown {args} {
- return "namespace unknown"
- }
- }
- }
- list [interp alias test_interp newAlias test_interp doesntExist] \
- [catch {interp eval test_interp {newAlias}} msg] $msg \
- [interp delete test_interp]
-} {newAlias 0 {global unknown} {}}
-
-test basic-37.1 {Tcl_ExprString: see expr.test} {emptyTest} {
-} {}
-
-test basic-38.1 {Tcl_ExprObj} {emptyTest} {
-} {}
-
-if {[info commands testcmdtrace] == {}} {
- puts "This application hasn't been compiled with the \"testcmdtrace\""
- puts "command, so I can't test Tcl_CreateTrace."
-} else {
-test basic-39.1 {Tcl_CreateTrace, correct command and argc/argv arguments of trace proc} {
- testcmdtrace tracetest {set stuff [expr 14 + 16]}
-} {{expr 14 + 16} {expr 14 + 16} {set stuff [expr 14 + 16]} {set stuff 30}}
-test basic-39.2 {Tcl_CreateTrace, correct command and argc/argv arguments of trace proc} {
- testcmdtrace tracetest {set stuff [info tclversion]}
-} {{info tclversion} {info tclversion} {set stuff [info tclversion]} {set stuff 8.1}}
-test basic-39.3 {Tcl_CreateTrace, correct command and argc/argv arguments of trace proc} {
- testcmdtrace deletetest {set stuff [info tclversion]}
-} 8.1
-}
-
-test basic-40.1 {Tcl_DeleteTrace} {emptyTest} {
-} {}
-
-test basic-41.1 {Tcl_AddErrorInfo} {emptyTest} {
-} {}
-
-test basic-42.1 {Tcl_AddObjErrorInfo} {emptyTest} {
-} {}
-
-test basic-43.1 {Tcl_VarEval} {emptyTest} {
-} {}
-
-test basic-44.1 {Tcl_GlobalEval} {emptyTest} {
-} {}
-
-test basic-45.1 {Tcl_SetRecursionLimit: see interp.test} {emptyTest} {
-} {}
-
-test basic-46.1 {Tcl_AllowExceptions} {emptyTest} {
-} {}
-
-# cleanup
-catch {eval namespace delete [namespace children :: test_ns_*]}
-catch {namespace delete george}
-catch {interp delete test_interp}
-catch {rename p ""}
-catch {rename q ""}
-catch {rename cmd ""}
-catch {rename value:at: ""}
-catch {unset x}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/binary.test b/tests/binary.test
deleted file mode 100644
index 1399edd..0000000
--- a/tests/binary.test
+++ /dev/null
@@ -1,1462 +0,0 @@
-# This file tests the tclBinary.c file and the "binary" Tcl command.
-#
-# 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) 1997 by 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: binary.test,v 1.3 1999/04/16 00:47:23 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test binary-1.1 {Tcl_BinaryObjCmd: bad args} {
- list [catch {binary} msg] $msg
-} {1 {wrong # args: should be "binary option ?arg arg ...?"}}
-test binary-1.2 {Tcl_BinaryObjCmd: bad args} {
- list [catch {binary foo} msg] $msg
-} {1 {bad option "foo": must be format or scan}}
-
-test binary-1.3 {Tcl_BinaryObjCmd: format error} {
- list [catch {binary f} msg] $msg
-} {1 {wrong # args: should be "binary format formatString ?arg arg ...?"}}
-test binary-1.4 {Tcl_BinaryObjCmd: format} {
- binary format ""
-} {}
-
-
-
-test binary-2.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format a } msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-2.2 {Tcl_BinaryObjCmd: format} {
- binary format a0 foo
-} {}
-test binary-2.3 {Tcl_BinaryObjCmd: format} {
- binary format a f
-} {f}
-test binary-2.4 {Tcl_BinaryObjCmd: format} {
- binary format a foo
-} {f}
-test binary-2.5 {Tcl_BinaryObjCmd: format} {
- binary format a3 foo
-} {foo}
-test binary-2.6 {Tcl_BinaryObjCmd: format} {
- binary format a5 foo
-} foo\x00\x00
-test binary-2.7 {Tcl_BinaryObjCmd: format} {
- binary format a*a3 foobarbaz blat
-} foobarbazbla
-test binary-2.8 {Tcl_BinaryObjCmd: format} {
- binary format a*X3a2 foobar x
-} foox\x00r
-
-test binary-3.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format A} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-3.2 {Tcl_BinaryObjCmd: format} {
- binary format A0 f
-} {}
-test binary-3.3 {Tcl_BinaryObjCmd: format} {
- binary format A f
-} {f}
-test binary-3.4 {Tcl_BinaryObjCmd: format} {
- binary format A foo
-} {f}
-test binary-3.5 {Tcl_BinaryObjCmd: format} {
- binary format A3 foo
-} {foo}
-test binary-3.6 {Tcl_BinaryObjCmd: format} {
- binary format A5 foo
-} {foo }
-test binary-3.7 {Tcl_BinaryObjCmd: format} {
- binary format A*A3 foobarbaz blat
-} foobarbazbla
-test binary-3.8 {Tcl_BinaryObjCmd: format} {
- binary format A*X3A2 foobar x
-} {foox r}
-
-test binary-4.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format B} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-4.2 {Tcl_BinaryObjCmd: format} {
- binary format B0 1
-} {}
-test binary-4.3 {Tcl_BinaryObjCmd: format} {
- binary format B 1
-} \x80
-test binary-4.4 {Tcl_BinaryObjCmd: format} {
- binary format B* 010011
-} \x4c
-test binary-4.5 {Tcl_BinaryObjCmd: format} {
- binary format B8 01001101
-} \x4d
-test binary-4.6 {Tcl_BinaryObjCmd: format} {
- binary format A2X2B9 oo 01001101
-} \x4d\x00
-test binary-4.7 {Tcl_BinaryObjCmd: format} {
- binary format B9 010011011010
-} \x4d\x80
-test binary-4.8 {Tcl_BinaryObjCmd: format} {
- binary format B2B3 10 010
-} \x80\x40
-test binary-4.9 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format B1B5 1 foo} msg] $msg
-} {1 {expected binary string but got "foo" instead}}
-
-test binary-5.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format b} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-5.2 {Tcl_BinaryObjCmd: format} {
- binary format b0 1
-} {}
-test binary-5.3 {Tcl_BinaryObjCmd: format} {
- binary format b 1
-} \x01
-test binary-5.4 {Tcl_BinaryObjCmd: format} {
- binary format b* 010011
-} 2
-test binary-5.5 {Tcl_BinaryObjCmd: format} {
- binary format b8 01001101
-} \xb2
-test binary-5.6 {Tcl_BinaryObjCmd: format} {
- binary format A2X2b9 oo 01001101
-} \xb2\x00
-test binary-5.7 {Tcl_BinaryObjCmd: format} {
- binary format b9 010011011010
-} \xb2\x01
-test binary-5.8 {Tcl_BinaryObjCmd: format} {
- binary format b17 1
-} \x01\00\00
-test binary-5.9 {Tcl_BinaryObjCmd: format} {
- binary format b2b3 10 010
-} \x01\x02
-test binary-5.10 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format b1b5 1 foo} msg] $msg
-} {1 {expected binary string but got "foo" instead}}
-
-test binary-6.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format h} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-6.2 {Tcl_BinaryObjCmd: format} {
- binary format h0 1
-} {}
-test binary-6.3 {Tcl_BinaryObjCmd: format} {
- binary format h 1
-} \x01
-test binary-6.4 {Tcl_BinaryObjCmd: format} {
- binary format h c
-} \x0c
-test binary-6.5 {Tcl_BinaryObjCmd: format} {
- binary format h* baadf00d
-} \xab\xda\x0f\xd0
-test binary-6.6 {Tcl_BinaryObjCmd: format} {
- binary format h4 c410
-} \x4c\x01
-test binary-6.7 {Tcl_BinaryObjCmd: format} {
- binary format h6 c4102
-} \x4c\x01\x02
-test binary-6.8 {Tcl_BinaryObjCmd: format} {
- binary format h5 c41020304
-} \x4c\x01\x02
-test binary-6.9 {Tcl_BinaryObjCmd: format} {
- binary format a3X3h5 foo 2
-} \x02\x00\x00
-test binary-6.10 {Tcl_BinaryObjCmd: format} {
- binary format h2h3 23 456
-} \x32\x54\x06
-test binary-6.11 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format h2 foo} msg] $msg
-} {1 {expected hexadecimal string but got "foo" instead}}
-
-test binary-7.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format H} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-7.2 {Tcl_BinaryObjCmd: format} {
- binary format H0 1
-} {}
-test binary-7.3 {Tcl_BinaryObjCmd: format} {
- binary format H 1
-} \x10
-test binary-7.4 {Tcl_BinaryObjCmd: format} {
- binary format H c
-} \xc0
-test binary-7.5 {Tcl_BinaryObjCmd: format} {
- binary format H* baadf00d
-} \xba\xad\xf0\x0d
-test binary-7.6 {Tcl_BinaryObjCmd: format} {
- binary format H4 c410
-} \xc4\x10
-test binary-7.7 {Tcl_BinaryObjCmd: format} {
- binary format H6 c4102
-} \xc4\x10\x20
-test binary-7.8 {Tcl_BinaryObjCmd: format} {
- binary format H5 c41023304
-} \xc4\x10\x20
-test binary-7.9 {Tcl_BinaryObjCmd: format} {
- binary format a3X3H5 foo 2
-} \x20\x00\x00
-test binary-7.10 {Tcl_BinaryObjCmd: format} {
- binary format H2H3 23 456
-} \x23\x45\x60
-test binary-7.11 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format H2 foo} msg] $msg
-} {1 {expected hexadecimal string but got "foo" instead}}
-
-test binary-8.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format c} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-8.2 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format c blat} msg] $msg
-} {1 {expected integer but got "blat"}}
-test binary-8.3 {Tcl_BinaryObjCmd: format} {
- binary format c0 0x50
-} {}
-test binary-8.4 {Tcl_BinaryObjCmd: format} {
- binary format c 0x50
-} P
-test binary-8.5 {Tcl_BinaryObjCmd: format} {
- binary format c 0x5052
-} R
-test binary-8.6 {Tcl_BinaryObjCmd: format} {
- binary format c2 {0x50 0x52}
-} PR
-test binary-8.7 {Tcl_BinaryObjCmd: format} {
- binary format c2 {0x50 0x52 0x53}
-} PR
-test binary-8.8 {Tcl_BinaryObjCmd: format} {
- binary format c* {0x50 0x52}
-} PR
-test binary-8.9 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format c2 {0x50}} msg] $msg
-} {1 {number of elements in list does not match count}}
-test binary-8.10 {Tcl_BinaryObjCmd: format} {
- set a {0x50 0x51}
- list [catch {binary format c $a} msg] $msg
-} [list 1 "expected integer but got \"0x50 0x51\""]
-test binary-8.11 {Tcl_BinaryObjCmd: format} {
- set a {0x50 0x51}
- binary format c1 $a
-} P
-
-test binary-9.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format s} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-9.2 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format s blat} msg] $msg
-} {1 {expected integer but got "blat"}}
-test binary-9.3 {Tcl_BinaryObjCmd: format} {
- binary format s0 0x50
-} {}
-test binary-9.4 {Tcl_BinaryObjCmd: format} {
- binary format s 0x50
-} P\x00
-test binary-9.5 {Tcl_BinaryObjCmd: format} {
- binary format s 0x5052
-} RP
-test binary-9.6 {Tcl_BinaryObjCmd: format} {
- binary format s 0x505251 0x53
-} QR
-test binary-9.7 {Tcl_BinaryObjCmd: format} {
- binary format s2 {0x50 0x52}
-} P\x00R\x00
-test binary-9.8 {Tcl_BinaryObjCmd: format} {
- binary format s* {0x5051 0x52}
-} QPR\x00
-test binary-9.9 {Tcl_BinaryObjCmd: format} {
- binary format s2 {0x50 0x52 0x53} 0x54
-} P\x00R\x00
-test binary-9.10 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format s2 {0x50}} msg] $msg
-} {1 {number of elements in list does not match count}}
-test binary-9.11 {Tcl_BinaryObjCmd: format} {
- set a {0x50 0x51}
- list [catch {binary format s $a} msg] $msg
-} [list 1 "expected integer but got \"0x50 0x51\""]
-test binary-9.12 {Tcl_BinaryObjCmd: format} {
- set a {0x50 0x51}
- binary format s1 $a
-} P\x00
-
-test binary-10.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format S} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-10.2 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format S blat} msg] $msg
-} {1 {expected integer but got "blat"}}
-test binary-10.3 {Tcl_BinaryObjCmd: format} {
- binary format S0 0x50
-} {}
-test binary-10.4 {Tcl_BinaryObjCmd: format} {
- binary format S 0x50
-} \x00P
-test binary-10.5 {Tcl_BinaryObjCmd: format} {
- binary format S 0x5052
-} PR
-test binary-10.6 {Tcl_BinaryObjCmd: format} {
- binary format S 0x505251 0x53
-} RQ
-test binary-10.7 {Tcl_BinaryObjCmd: format} {
- binary format S2 {0x50 0x52}
-} \x00P\x00R
-test binary-10.8 {Tcl_BinaryObjCmd: format} {
- binary format S* {0x5051 0x52}
-} PQ\x00R
-test binary-10.9 {Tcl_BinaryObjCmd: format} {
- binary format S2 {0x50 0x52 0x53} 0x54
-} \x00P\x00R
-test binary-10.10 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format S2 {0x50}} msg] $msg
-} {1 {number of elements in list does not match count}}
-test binary-10.11 {Tcl_BinaryObjCmd: format} {
- set a {0x50 0x51}
- list [catch {binary format S $a} msg] $msg
-} [list 1 "expected integer but got \"0x50 0x51\""]
-test binary-10.12 {Tcl_BinaryObjCmd: format} {
- set a {0x50 0x51}
- binary format S1 $a
-} \x00P
-
-test binary-11.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format i} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-11.2 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format i blat} msg] $msg
-} {1 {expected integer but got "blat"}}
-test binary-11.3 {Tcl_BinaryObjCmd: format} {
- binary format i0 0x50
-} {}
-test binary-11.4 {Tcl_BinaryObjCmd: format} {
- binary format i 0x50
-} P\x00\x00\x00
-test binary-11.5 {Tcl_BinaryObjCmd: format} {
- binary format i 0x5052
-} RP\x00\x00
-test binary-11.6 {Tcl_BinaryObjCmd: format} {
- binary format i 0x505251 0x53
-} QRP\x00
-test binary-11.7 {Tcl_BinaryObjCmd: format} {
- binary format i1 {0x505251 0x53}
-} QRP\x00
-test binary-11.8 {Tcl_BinaryObjCmd: format} {
- binary format i 0x53525150
-} PQRS
-test binary-11.9 {Tcl_BinaryObjCmd: format} {
- binary format i2 {0x50 0x52}
-} P\x00\x00\x00R\x00\x00\x00
-test binary-11.10 {Tcl_BinaryObjCmd: format} {
- binary format i* {0x50515253 0x52}
-} SRQPR\x00\x00\x00
-test binary-11.11 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format i2 {0x50}} msg] $msg
-} {1 {number of elements in list does not match count}}
-test binary-11.12 {Tcl_BinaryObjCmd: format} {
- set a {0x50 0x51}
- list [catch {binary format i $a} msg] $msg
-} [list 1 "expected integer but got \"0x50 0x51\""]
-test binary-11.13 {Tcl_BinaryObjCmd: format} {
- set a {0x50 0x51}
- binary format i1 $a
-} P\x00\x00\x00
-
-test binary-12.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format I} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-12.2 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format I blat} msg] $msg
-} {1 {expected integer but got "blat"}}
-test binary-12.3 {Tcl_BinaryObjCmd: format} {
- binary format I0 0x50
-} {}
-test binary-12.4 {Tcl_BinaryObjCmd: format} {
- binary format I 0x50
-} \x00\x00\x00P
-test binary-12.5 {Tcl_BinaryObjCmd: format} {
- binary format I 0x5052
-} \x00\x00PR
-test binary-12.6 {Tcl_BinaryObjCmd: format} {
- binary format I 0x505251 0x53
-} \x00PRQ
-test binary-12.7 {Tcl_BinaryObjCmd: format} {
- binary format I1 {0x505251 0x53}
-} \x00PRQ
-test binary-12.8 {Tcl_BinaryObjCmd: format} {
- binary format I 0x53525150
-} SRQP
-test binary-12.9 {Tcl_BinaryObjCmd: format} {
- binary format I2 {0x50 0x52}
-} \x00\x00\x00P\x00\x00\x00R
-test binary-12.10 {Tcl_BinaryObjCmd: format} {
- binary format I* {0x50515253 0x52}
-} PQRS\x00\x00\x00R
-test binary-12.11 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format i2 {0x50}} msg] $msg
-} {1 {number of elements in list does not match count}}
-test binary-12.12 {Tcl_BinaryObjCmd: format} {
- set a {0x50 0x51}
- list [catch {binary format I $a} msg] $msg
-} [list 1 "expected integer but got \"0x50 0x51\""]
-test binary-12.13 {Tcl_BinaryObjCmd: format} {
- set a {0x50 0x51}
- binary format I1 $a
-} \x00\x00\x00P
-
-test binary-13.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format f} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-13.2 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format f blat} msg] $msg
-} {1 {expected floating-point number but got "blat"}}
-test binary-13.3 {Tcl_BinaryObjCmd: format} {
- binary format f0 1.6
-} {}
-test binary-13.4 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
- binary format f 1.6
-} \x3f\xcc\xcc\xcd
-test binary-13.5 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
- binary format f 1.6
-} \xcd\xcc\xcc\x3f
-test binary-13.6 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
- binary format f* {1.6 3.4}
-} \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
-test binary-13.7 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
- binary format f* {1.6 3.4}
-} \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
-test binary-13.8 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
- binary format f2 {1.6 3.4}
-} \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
-test binary-13.9 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
- binary format f2 {1.6 3.4}
-} \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
-test binary-13.10 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
- binary format f2 {1.6 3.4 5.6}
-} \x3f\xcc\xcc\xcd\x40\x59\x99\x9a
-test binary-13.11 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
- binary format f2 {1.6 3.4 5.6}
-} \xcd\xcc\xcc\x3f\x9a\x99\x59\x40
-test binary-13.12 {Tcl_BinaryObjCmd: float overflow} {nonPortable macOrUnix} {
- binary format f -3.402825e+38
-} \xff\x7f\xff\xff
-test binary-13.13 {Tcl_BinaryObjCmd: float overflow} {nonPortable pcOnly} {
- binary format f -3.402825e+38
-} \xff\xff\x7f\xff
-test binary-13.14 {Tcl_BinaryObjCmd: float underflow} {nonPortable macOrUnix} {
- binary format f -3.402825e-100
-} \x80\x00\x00\x00
-test binary-13.15 {Tcl_BinaryObjCmd: float underflow} {nonPortable pcOnly} {
- binary format f -3.402825e-100
-} \x00\x00\x00\x80
-test binary-13.16 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format f2 {1.6}} msg] $msg
-} {1 {number of elements in list does not match count}}
-test binary-13.17 {Tcl_BinaryObjCmd: format} {
- set a {1.6 3.4}
- list [catch {binary format f $a} msg] $msg
-} [list 1 "expected floating-point number but got \"1.6 3.4\""]
-test binary-13.18 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
- set a {1.6 3.4}
- binary format f1 $a
-} \x3f\xcc\xcc\xcd
-test binary-13.19 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
- set a {1.6 3.4}
- binary format f1 $a
-} \xcd\xcc\xcc\x3f
-
-test binary-14.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format d} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-14.2 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format d blat} msg] $msg
-} {1 {expected floating-point number but got "blat"}}
-test binary-14.3 {Tcl_BinaryObjCmd: format} {
- binary format d0 1.6
-} {}
-test binary-14.4 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
- binary format d 1.6
-} \x3f\xf9\x99\x99\x99\x99\x99\x9a
-test binary-14.5 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
- binary format d 1.6
-} \x9a\x99\x99\x99\x99\x99\xf9\x3f
-test binary-14.6 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
- binary format d* {1.6 3.4}
-} \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
-test binary-14.7 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
- binary format d* {1.6 3.4}
-} \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
-test binary-14.8 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
- binary format d2 {1.6 3.4}
-} \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
-test binary-14.9 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
- binary format d2 {1.6 3.4}
-} \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
-test binary-14.10 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
- binary format d2 {1.6 3.4 5.6}
-} \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33
-test binary-14.11 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
- binary format d2 {1.6 3.4 5.6}
-} \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40
-test binary-14.12 {Tcl_BinaryObjCmd: float overflow} {nonPortable unixOnly} {
- binary format d NaN
-} \x7f\xff\xff\xff\xff\xff\xff\xff
-test binary-14.13 {Tcl_BinaryObjCmd: float overflow} {nonPortable macOnly} {
- binary format d NaN
-} \x7f\xf8\x02\xa0\x00\x00\x00\x00
-test binary-14.14 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format d2 {1.6}} msg] $msg
-} {1 {number of elements in list does not match count}}
-test binary-14.15 {Tcl_BinaryObjCmd: format} {
- set a {1.6 3.4}
- list [catch {binary format d $a} msg] $msg
-} [list 1 "expected floating-point number but got \"1.6 3.4\""]
-test binary-14.16 {Tcl_BinaryObjCmd: format} {nonPortable macOrUnix} {
- set a {1.6 3.4}
- binary format d1 $a
-} \x3f\xf9\x99\x99\x99\x99\x99\x9a
-test binary-14.17 {Tcl_BinaryObjCmd: format} {nonPortable pcOnly} {
- set a {1.6 3.4}
- binary format d1 $a
-} \x9a\x99\x99\x99\x99\x99\xf9\x3f
-
-test binary-15.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format ax*a "y" "z"} msg] $msg
-} {1 {cannot use "*" in format string with "x"}}
-test binary-15.2 {Tcl_BinaryObjCmd: format} {
- binary format axa "y" "z"
-} y\x00z
-test binary-15.3 {Tcl_BinaryObjCmd: format} {
- binary format ax3a "y" "z"
-} y\x00\x00\x00z
-test binary-15.4 {Tcl_BinaryObjCmd: format} {
- binary format a*X3x3a* "foo" "z"
-} \x00\x00\x00z
-
-test binary-16.1 {Tcl_BinaryObjCmd: format} {
- binary format a*X*a "foo" "z"
-} zoo
-test binary-16.2 {Tcl_BinaryObjCmd: format} {
- binary format aX3a "y" "z"
-} z
-test binary-16.3 {Tcl_BinaryObjCmd: format} {
- binary format a*Xa* "foo" "zy"
-} fozy
-test binary-16.4 {Tcl_BinaryObjCmd: format} {
- binary format a*X3a "foobar" "z"
-} foozar
-test binary-16.5 {Tcl_BinaryObjCmd: format} {
- binary format a*X3aX2a "foobar" "z" "b"
-} fobzar
-
-test binary-17.1 {Tcl_BinaryObjCmd: format} {
- binary format @1
-} \x00
-test binary-17.2 {Tcl_BinaryObjCmd: format} {
- binary format @5a2 "ab"
-} \x00\x00\x00\x00\x00\x61\x62
-test binary-17.3 {Tcl_BinaryObjCmd: format} {
- binary format {a* @0 a2 @* a*} "foobar" "ab" "blat"
-} abobarblat
-
-test binary-18.1 {Tcl_BinaryObjCmd: format} {
- list [catch {binary format u0a3 abc abd} msg] $msg
-} {1 {bad field specifier "u"}}
-
-
-test binary-19.1 {Tcl_BinaryObjCmd: errors} {
- list [catch {binary s} msg] $msg
-} {1 {wrong # args: should be "binary scan value formatString ?varName varName ...?"}}
-test binary-19.2 {Tcl_BinaryObjCmd: errors} {
- list [catch {binary scan foo} msg] $msg
-} {1 {wrong # args: should be "binary scan value formatString ?varName varName ...?"}}
-test binary-19.3 {Tcl_BinaryObjCmd: scan} {
- binary scan {} {}
-} 0
-
-test binary-20.1 {Tcl_BinaryObjCmd: scan} {
- list [catch {binary scan abc a} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-20.2 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 1
- list [catch {binary scan abc a arg1(a)} msg] $msg
-} {1 {can't set "arg1(a)": variable isn't array}}
-test binary-20.3 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 abc
- list [binary scan abc a0 arg1] $arg1
-} {1 {}}
-test binary-20.4 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abc a* arg1] $arg1
-} {1 abc}
-test binary-20.5 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abc a5 arg1] [info exist arg1]
-} {0 0}
-test binary-20.6 {Tcl_BinaryObjCmd: scan} {
- set arg1 foo
- list [binary scan abc a2 arg1] $arg1
-} {1 ab}
-test binary-20.7 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- catch {unset arg2}
- list [binary scan abcdef a2a2 arg1 arg2] $arg1 $arg2
-} {2 ab cd}
-test binary-20.8 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abc a2 arg1(a)] $arg1(a)
-} {1 ab}
-test binary-20.9 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abc a arg1(a)] $arg1(a)
-} {1 a}
-
-test binary-21.1 {Tcl_BinaryObjCmd: scan} {
- list [catch {binary scan abc A} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-21.2 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 1
- list [catch {binary scan abc A arg1(a)} msg] $msg
-} {1 {can't set "arg1(a)": variable isn't array}}
-test binary-21.3 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 abc
- list [binary scan abc A0 arg1] $arg1
-} {1 {}}
-test binary-21.4 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abc A* arg1] $arg1
-} {1 abc}
-test binary-21.5 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abc A5 arg1] [info exist arg1]
-} {0 0}
-test binary-21.6 {Tcl_BinaryObjCmd: scan} {
- set arg1 foo
- list [binary scan abc A2 arg1] $arg1
-} {1 ab}
-test binary-21.7 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- catch {unset arg2}
- list [binary scan abcdef A2A2 arg1 arg2] $arg1 $arg2
-} {2 ab cd}
-test binary-21.8 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abc A2 arg1(a)] $arg1(a)
-} {1 ab}
-test binary-21.9 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abc A2 arg1(a)] $arg1(a)
-} {1 ab}
-test binary-21.10 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abc A arg1(a)] $arg1(a)
-} {1 a}
-test binary-21.11 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan "abc def \x00 " A* arg1] $arg1
-} {1 {abc def}}
-test binary-21.12 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan "abc def \x00ghi " A* arg1] $arg1
-} [list 1 "abc def \x00ghi"]
-
-test binary-22.1 {Tcl_BinaryObjCmd: scan} {
- list [catch {binary scan abc b} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-22.2 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\x53 b* arg1] $arg1
-} {1 0100101011001010}
-test binary-22.3 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x82\x53 b arg1] $arg1
-} {1 0}
-test binary-22.4 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x82\x53 b1 arg1] $arg1
-} {1 0}
-test binary-22.5 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x82\x53 b0 arg1] $arg1
-} {1 {}}
-test binary-22.6 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\x53 b5 arg1] $arg1
-} {1 01001}
-test binary-22.7 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\x53 b8 arg1] $arg1
-} {1 01001010}
-test binary-22.8 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\x53 b14 arg1] $arg1
-} {1 01001010110010}
-test binary-22.9 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 foo
- list [binary scan \x52 b14 arg1] $arg1
-} {0 foo}
-test binary-22.10 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 1
- list [catch {binary scan \x52\x53 b1 arg1(a)} msg] $msg
-} {1 {can't set "arg1(a)": variable isn't array}}
-test binary-22.11 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1 arg2}
- set arg1 foo
- set arg2 bar
- list [binary scan \x07\x87\x05 b5b* arg1 arg2] $arg1 $arg2
-} {2 11100 1110000110100000}
-
-
-test binary-23.1 {Tcl_BinaryObjCmd: scan} {
- list [catch {binary scan abc B} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-23.2 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\x53 B* arg1] $arg1
-} {1 0101001001010011}
-test binary-23.3 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x82\x53 B arg1] $arg1
-} {1 1}
-test binary-23.4 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x82\x53 B1 arg1] $arg1
-} {1 1}
-test binary-23.5 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\x53 B0 arg1] $arg1
-} {1 {}}
-test binary-23.6 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\x53 B5 arg1] $arg1
-} {1 01010}
-test binary-23.7 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\x53 B8 arg1] $arg1
-} {1 01010010}
-test binary-23.8 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\x53 B14 arg1] $arg1
-} {1 01010010010100}
-test binary-23.9 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 foo
- list [binary scan \x52 B14 arg1] $arg1
-} {0 foo}
-test binary-23.10 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 1
- list [catch {binary scan \x52\x53 B1 arg1(a)} msg] $msg
-} {1 {can't set "arg1(a)": variable isn't array}}
-test binary-23.11 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1 arg2}
- set arg1 foo
- set arg2 bar
- list [binary scan \x70\x87\x05 B5B* arg1 arg2] $arg1 $arg2
-} {2 01110 1000011100000101}
-
-test binary-24.1 {Tcl_BinaryObjCmd: scan} {
- list [catch {binary scan abc h} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-24.2 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3 h* arg1] $arg1
-} {1 253a}
-test binary-24.3 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \xc2\xa3 h arg1] $arg1
-} {1 2}
-test binary-24.4 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x82\x53 h1 arg1] $arg1
-} {1 2}
-test binary-24.5 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\x53 h0 arg1] $arg1
-} {1 {}}
-test binary-24.6 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \xf2\x53 h2 arg1] $arg1
-} {1 2f}
-test binary-24.7 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\x53 h3 arg1] $arg1
-} {1 253}
-test binary-24.8 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 foo
- list [binary scan \x52 h3 arg1] $arg1
-} {0 foo}
-test binary-24.9 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 1
- list [catch {binary scan \x52\x53 h1 arg1(a)} msg] $msg
-} {1 {can't set "arg1(a)": variable isn't array}}
-test binary-24.10 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1 arg2}
- set arg1 foo
- set arg2 bar
- list [binary scan \x70\x87\x05 h2h* arg1 arg2] $arg1 $arg2
-} {2 07 7850}
-
-test binary-25.1 {Tcl_BinaryObjCmd: scan} {
- list [catch {binary scan abc H} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-25.2 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3 H* arg1] $arg1
-} {1 52a3}
-test binary-25.3 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \xc2\xa3 H arg1] $arg1
-} {1 c}
-test binary-25.4 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x82\x53 H1 arg1] $arg1
-} {1 8}
-test binary-25.5 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\x53 H0 arg1] $arg1
-} {1 {}}
-test binary-25.6 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \xf2\x53 H2 arg1] $arg1
-} {1 f2}
-test binary-25.7 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\x53 H3 arg1] $arg1
-} {1 525}
-test binary-25.8 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 foo
- list [binary scan \x52 H3 arg1] $arg1
-} {0 foo}
-test binary-25.9 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 1
- list [catch {binary scan \x52\x53 H1 arg1(a)} msg] $msg
-} {1 {can't set "arg1(a)": variable isn't array}}
-test binary-25.10 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1 arg2}
- set arg1 foo
- set arg2 bar
- list [binary scan \x70\x87\x05 H2H* arg1 arg2] $arg1 $arg2
-} {2 70 8705}
-
-test binary-26.1 {Tcl_BinaryObjCmd: scan} {
- list [catch {binary scan abc c} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-26.2 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3 c* arg1] $arg1
-} {1 {82 -93}}
-test binary-26.3 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3 c arg1] $arg1
-} {1 82}
-test binary-26.4 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3 c1 arg1] $arg1
-} {1 82}
-test binary-26.5 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3 c0 arg1] $arg1
-} {1 {}}
-test binary-26.6 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3 c2 arg1] $arg1
-} {1 {82 -93}}
-test binary-26.7 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \xff c arg1] $arg1
-} {1 -1}
-test binary-26.8 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 foo
- list [binary scan \x52 c3 arg1] $arg1
-} {0 foo}
-test binary-26.9 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 1
- list [catch {binary scan \x52\x53 c1 arg1(a)} msg] $msg
-} {1 {can't set "arg1(a)": variable isn't array}}
-test binary-26.10 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1 arg2}
- set arg1 foo
- set arg2 bar
- list [binary scan \x70\x87\x05 c2c* arg1 arg2] $arg1 $arg2
-} {2 {112 -121} 5}
-
-test binary-27.1 {Tcl_BinaryObjCmd: scan} {
- list [catch {binary scan abc s} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-27.2 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53\x54 s* arg1] $arg1
-} {1 {-23726 21587}}
-test binary-27.3 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53\x54 s arg1] $arg1
-} {1 -23726}
-test binary-27.4 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3 s1 arg1] $arg1
-} {1 -23726}
-test binary-27.5 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3 s0 arg1] $arg1
-} {1 {}}
-test binary-27.6 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53\x54 s2 arg1] $arg1
-} {1 {-23726 21587}}
-test binary-27.7 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 foo
- list [binary scan \x52 s1 arg1] $arg1
-} {0 foo}
-test binary-27.8 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 1
- list [catch {binary scan \x52\x53 s1 arg1(a)} msg] $msg
-} {1 {can't set "arg1(a)": variable isn't array}}
-test binary-27.9 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1 arg2}
- set arg1 foo
- set arg2 bar
- list [binary scan \x52\xa3\x53\x54\x05 s2c* arg1 arg2] $arg1 $arg2
-} {2 {-23726 21587} 5}
-
-test binary-28.1 {Tcl_BinaryObjCmd: scan} {
- list [catch {binary scan abc S} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-28.2 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53\x54 S* arg1] $arg1
-} {1 {21155 21332}}
-test binary-28.3 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53\x54 S arg1] $arg1
-} {1 21155}
-test binary-28.4 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3 S1 arg1] $arg1
-} {1 21155}
-test binary-28.5 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3 S0 arg1] $arg1
-} {1 {}}
-test binary-28.6 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53\x54 S2 arg1] $arg1
-} {1 {21155 21332}}
-test binary-28.7 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 foo
- list [binary scan \x52 S1 arg1] $arg1
-} {0 foo}
-test binary-28.8 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 1
- list [catch {binary scan \x52\x53 S1 arg1(a)} msg] $msg
-} {1 {can't set "arg1(a)": variable isn't array}}
-test binary-28.9 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1 arg2}
- set arg1 foo
- set arg2 bar
- list [binary scan \x52\xa3\x53\x54\x05 S2c* arg1 arg2] $arg1 $arg2
-} {2 {21155 21332} 5}
-
-test binary-29.1 {Tcl_BinaryObjCmd: scan} {
- list [catch {binary scan abc i} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-29.2 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i* arg1] $arg1
-} {1 {1414767442 67305985}}
-test binary-29.3 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i arg1] $arg1
-} {1 1414767442}
-test binary-29.4 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53\x54 i1 arg1] $arg1
-} {1 1414767442}
-test binary-29.5 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53 i0 arg1] $arg1
-} {1 {}}
-test binary-29.6 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 i2 arg1] $arg1
-} {1 {1414767442 67305985}}
-test binary-29.7 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 foo
- list [binary scan \x52 i1 arg1] $arg1
-} {0 foo}
-test binary-29.8 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 1
- list [catch {binary scan \x52\x53\x53\x54 i1 arg1(a)} msg] $msg
-} {1 {can't set "arg1(a)": variable isn't array}}
-test binary-29.9 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1 arg2}
- set arg1 foo
- set arg2 bar
- list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 i2c* arg1 arg2] $arg1 $arg2
-} {2 {1414767442 67305985} 5}
-
-test binary-30.1 {Tcl_BinaryObjCmd: scan} {
- list [catch {binary scan abc I} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-30.2 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I* arg1] $arg1
-} {1 {1386435412 16909060}}
-test binary-30.3 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I arg1] $arg1
-} {1 1386435412}
-test binary-30.4 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53\x54 I1 arg1] $arg1
-} {1 1386435412}
-test binary-30.5 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53 I0 arg1] $arg1
-} {1 {}}
-test binary-30.6 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04 I2 arg1] $arg1
-} {1 {1386435412 16909060}}
-test binary-30.7 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 foo
- list [binary scan \x52 I1 arg1] $arg1
-} {0 foo}
-test binary-30.8 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 1
- list [catch {binary scan \x52\x53\x53\x54 I1 arg1(a)} msg] $msg
-} {1 {can't set "arg1(a)": variable isn't array}}
-test binary-30.9 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1 arg2}
- set arg1 foo
- set arg2 bar
- list [binary scan \x52\xa3\x53\x54\x01\x02\x03\x04\x05 I2c* arg1 arg2] $arg1 $arg2
-} {2 {1386435412 16909060} 5}
-
-test binary-31.1 {Tcl_BinaryObjCmd: scan} {
- list [catch {binary scan abc f} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-31.2 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
- catch {unset arg1}
- list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f* arg1] $arg1
-} {1 {1.60000002384 3.40000009537}}
-test binary-31.3 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
- catch {unset arg1}
- list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f* arg1] $arg1
-} {1 {1.60000002384 3.40000009537}}
-test binary-31.4 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
- catch {unset arg1}
- list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f arg1] $arg1
-} {1 1.60000002384}
-test binary-31.5 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
- catch {unset arg1}
- list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f arg1] $arg1
-} {1 1.60000002384}
-test binary-31.6 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
- catch {unset arg1}
- list [binary scan \x3f\xcc\xcc\xcd f1 arg1] $arg1
-} {1 1.60000002384}
-test binary-31.7 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
- catch {unset arg1}
- list [binary scan \xcd\xcc\xcc\x3f f1 arg1] $arg1
-} {1 1.60000002384}
-test binary-31.8 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
- catch {unset arg1}
- list [binary scan \x3f\xcc\xcc\xcd f0 arg1] $arg1
-} {1 {}}
-test binary-31.9 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
- catch {unset arg1}
- list [binary scan \xcd\xcc\xcc\x3f f0 arg1] $arg1
-} {1 {}}
-test binary-31.10 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
- catch {unset arg1}
- list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a f2 arg1] $arg1
-} {1 {1.60000002384 3.40000009537}}
-test binary-31.11 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
- catch {unset arg1}
- list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40 f2 arg1] $arg1
-} {1 {1.60000002384 3.40000009537}}
-test binary-31.12 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 foo
- list [binary scan \x52 f1 arg1] $arg1
-} {0 foo}
-test binary-31.13 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 1
- list [catch {binary scan \x3f\xcc\xcc\xcd f1 arg1(a)} msg] $msg
-} {1 {can't set "arg1(a)": variable isn't array}}
-test binary-31.14 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
- catch {unset arg1 arg2}
- set arg1 foo
- set arg2 bar
- list [binary scan \x3f\xcc\xcc\xcd\x40\x59\x99\x9a\x05 f2c* arg1 arg2] $arg1 $arg2
-} {2 {1.60000002384 3.40000009537} 5}
-test binary-31.15 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
- catch {unset arg1 arg2}
- set arg1 foo
- set arg2 bar
- list [binary scan \xcd\xcc\xcc\x3f\x9a\x99\x59\x40\x05 f2c* arg1 arg2] $arg1 $arg2
-} {2 {1.60000002384 3.40000009537} 5}
-
-test binary-32.1 {Tcl_BinaryObjCmd: scan} {
- list [catch {binary scan abc d} msg] $msg
-} {1 {not enough arguments for all format specifiers}}
-test binary-32.2 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
- catch {unset arg1}
- list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d* arg1] $arg1
-} {1 {1.6 3.4}}
-test binary-32.3 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
- catch {unset arg1}
- list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d* arg1] $arg1
-} {1 {1.6 3.4}}
-test binary-32.4 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
- catch {unset arg1}
- list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d arg1] $arg1
-} {1 1.6}
-test binary-32.5 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
- catch {unset arg1}
- list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d arg1] $arg1
-} {1 1.6}
-test binary-32.6 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
- catch {unset arg1}
- list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d1 arg1] $arg1
-} {1 1.6}
-test binary-32.7 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
- catch {unset arg1}
- list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f d1 arg1] $arg1
-} {1 1.6}
-test binary-32.8 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
- catch {unset arg1}
- list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d0 arg1] $arg1
-} {1 {}}
-test binary-32.9 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
- catch {unset arg1}
- list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f d0 arg1] $arg1
-} {1 {}}
-test binary-32.10 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
- catch {unset arg1}
- list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33 d2 arg1] $arg1
-} {1 {1.6 3.4}}
-test binary-32.11 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
- catch {unset arg1}
- list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40 d2 arg1] $arg1
-} {1 {1.6 3.4}}
-test binary-32.12 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 foo
- list [binary scan \x52 d1 arg1] $arg1
-} {0 foo}
-test binary-32.13 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- set arg1 1
- list [catch {binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a d1 arg1(a)} msg] $msg
-} {1 {can't set "arg1(a)": variable isn't array}}
-test binary-32.14 {Tcl_BinaryObjCmd: scan} {nonPortable macOrUnix} {
- catch {unset arg1 arg2}
- set arg1 foo
- set arg2 bar
- list [binary scan \x3f\xf9\x99\x99\x99\x99\x99\x9a\x40\x0b\x33\x33\x33\x33\x33\x33\x05 d2c* arg1 arg2] $arg1 $arg2
-} {2 {1.6 3.4} 5}
-test binary-32.15 {Tcl_BinaryObjCmd: scan} {nonPortable pcOnly} {
- catch {unset arg1 arg2}
- set arg1 foo
- set arg2 bar
- list [binary scan \x9a\x99\x99\x99\x99\x99\xf9\x3f\x33\x33\x33\x33\x33\x33\x0b\x40\x05 d2c* arg1 arg2] $arg1 $arg2
-} {2 {1.6 3.4} 5}
-
-test binary-33.1 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- catch {unset arg2}
- list [binary scan abcdefg a2xa3 arg1 arg2] $arg1 $arg2
-} {2 ab def}
-test binary-33.2 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- catch {unset arg2}
- set arg2 foo
- list [binary scan abcdefg a3x*a3 arg1 arg2] $arg1 $arg2
-} {1 abc foo}
-test binary-33.3 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- catch {unset arg2}
- set arg2 foo
- list [binary scan abcdefg a3x20a3 arg1 arg2] $arg1 $arg2
-} {1 abc foo}
-test binary-33.4 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- catch {unset arg2}
- set arg2 foo
- list [binary scan abc a3x20a3 arg1 arg2] $arg1 $arg2
-} {1 abc foo}
-test binary-33.5 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abcdef x1a1 arg1] $arg1
-} {1 b}
-test binary-33.6 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abcdef x5a1 arg1] $arg1
-} {1 f}
-test binary-33.7 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abcdef x0a1 arg1] $arg1
-} {1 a}
-
-test binary-34.1 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- catch {unset arg2}
- list [binary scan abcdefg a2Xa3 arg1 arg2] $arg1 $arg2
-} {2 ab bcd}
-test binary-34.2 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- catch {unset arg2}
- set arg2 foo
- list [binary scan abcdefg a3X*a3 arg1 arg2] $arg1 $arg2
-} {2 abc abc}
-test binary-34.3 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- catch {unset arg2}
- set arg2 foo
- list [binary scan abcdefg a3X20a3 arg1 arg2] $arg1 $arg2
-} {2 abc abc}
-test binary-34.4 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abc X20a3 arg1] $arg1
-} {1 abc}
-test binary-34.5 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abcdef x*X1a1 arg1] $arg1
-} {1 f}
-test binary-34.6 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abcdef x*X5a1 arg1] $arg1
-} {1 b}
-test binary-34.7 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abcdef x3X0a1 arg1] $arg1
-} {1 d}
-
-test binary-35.1 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- catch {unset arg2}
- list [catch {binary scan abcdefg a2@a3 arg1 arg2} msg] $msg
-} {1 {missing count for "@" field specifier}}
-test binary-35.2 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- catch {unset arg2}
- set arg2 foo
- list [binary scan abcdefg a3@*a3 arg1 arg2] $arg1 $arg2
-} {1 abc foo}
-test binary-35.3 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- catch {unset arg2}
- set arg2 foo
- list [binary scan abcdefg a3@20a3 arg1 arg2] $arg1 $arg2
-} {1 abc foo}
-test binary-35.4 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abcdef @2a3 arg1] $arg1
-} {1 cde}
-test binary-35.5 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abcdef x*@1a1 arg1] $arg1
-} {1 b}
-test binary-35.6 {Tcl_BinaryObjCmd: scan} {
- catch {unset arg1}
- list [binary scan abcdef x*@0a1 arg1] $arg1
-} {1 a}
-
-test binary-36.1 {Tcl_BinaryObjCmd: scan} {
- list [catch {binary scan abcdef u0a3} msg] $msg
-} {1 {bad field specifier "u"}}
-
-# GetFormatSpec is pretty thoroughly tested above, but there are a few
-# cases we should text explicitly
-
-test binary-37.1 {GetFormatSpec: whitespace} {
- binary format "a3 a5 a3" foo barblat baz
-} foobarblbaz
-test binary-37.2 {GetFormatSpec: whitespace} {
- binary format " " foo
-} {}
-test binary-37.3 {GetFormatSpec: whitespace} {
- binary format " a3" foo
-} foo
-test binary-37.4 {GetFormatSpec: whitespace} {
- binary format "" foo
-} {}
-test binary-37.5 {GetFormatSpec: whitespace} {
- binary format "" foo
-} {}
-test binary-37.6 {GetFormatSpec: whitespace} {
- binary format " a3 " foo
-} foo
-test binary-37.7 {GetFormatSpec: numbers} {
- list [catch {binary scan abcdef "x-1" foo} msg] $msg
-} {1 {bad field specifier "-"}}
-test binary-37.8 {GetFormatSpec: numbers} {
- catch {unset arg1}
- set arg1 foo
- list [binary scan abcdef "a0x3" arg1] $arg1
-} {1 {}}
-test binary-37.9 {GetFormatSpec: numbers} {
- # test format of neg numbers
- # bug report/fix provided by Harald Kirsch
- set x [binary format f* {1 -1 2 -2 0}]
- binary scan $x f* bla
- set bla
-} {1.0 -1.0 2.0 -2.0 0.0}
-
-test binary-38.1 {FormatNumber: word alignment} {
- set x [binary format c1s1 1 1]
-} \x01\x01\x00
-test binary-38.2 {FormatNumber: word alignment} {
- set x [binary format c1S1 1 1]
-} \x01\x00\x01
-test binary-38.3 {FormatNumber: word alignment} {
- set x [binary format c1i1 1 1]
-} \x01\x01\x00\x00\x00
-test binary-38.4 {FormatNumber: word alignment} {
- set x [binary format c1I1 1 1]
-} \x01\x00\x00\x00\x01
-test binary-38.5 {FormatNumber: word alignment} {nonPortable macOrUnix} {
- set x [binary format c1d1 1 1.6]
-} \x01\x3f\xf9\x99\x99\x99\x99\x99\x9a
-test binary-38.6 {FormatNumber: word alignment} {nonPortable pcOnly} {
- set x [binary format c1d1 1 1.6]
-} \x01\x9a\x99\x99\x99\x99\x99\xf9\x3f
-test binary-38.7 {FormatNumber: word alignment} {nonPortable macOrUnix} {
- set x [binary format c1f1 1 1.6]
-} \x01\x3f\xcc\xcc\xcd
-test binary-38.8 {FormatNumber: word alignment} {nonPortable pcOnly} {
- set x [binary format c1f1 1 1.6]
-} \x01\xcd\xcc\xcc\x3f
-
-test binary-39.1 {ScanNumber: sign extension} {
- catch {unset arg1}
- list [binary scan \x52\xa3 c2 arg1] $arg1
-} {1 {82 -93}}
-test binary-39.2 {ScanNumber: sign extension} {
- catch {unset arg1}
- list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 s4 arg1] $arg1
-} {1 {513 -32511 386 -32127}}
-test binary-39.3 {ScanNumber: sign extension} {
- catch {unset arg1}
- list [binary scan \x01\x02\x01\x81\x82\x01\x81\x82 S4 arg1] $arg1
-} {1 {258 385 -32255 -32382}}
-test binary-39.4 {ScanNumber: sign extension} {
- catch {unset arg1}
- list [binary scan \x01\x01\x01\x02\x81\x01\x01\x01\x01\x82\x01\x01\x01\x01\x82\x01\x01\x01\x01\x81 i5 arg1] $arg1
-} {1 {33620225 16843137 16876033 25297153 -2130640639}}
-test binary-39.5 {ScanNumber: sign extension} {
- catch {unset arg1}
- list [binary scan \x01\x01\x01\x02\x81\x01\x01\x01\x01\x82\x01\x01\x01\x01\x82\x01\x01\x01\x01\x81 I5 arg1] $arg1
-} {1 {16843010 -2130640639 25297153 16876033 16843137}}
-
-test binary-40.1 {ScanNumber: floating point overflow} {nonPortable unixOnly} {
- catch {unset arg1}
- list [binary scan \xff\xff\xff\xff f1 arg1] $arg1
-} {1 -NaN}
-test binary-40.2 {ScanNumber: floating point overflow} {nonPortable macOnly} {
- catch {unset arg1}
- list [binary scan \xff\xff\xff\xff f1 arg1] $arg1
-} {1 -NAN(255)}
-test binary-40.3 {ScanNumber: floating point overflow} {nonPortable pcOnly} {
- catch {unset arg1}
- set result [binary scan \xff\xff\xff\xff f1 arg1]
- if {([string compare $arg1 -1.\#QNAN] == 0)
- || ([string compare $arg1 -NAN] == 0)} {
- lappend result success
- } else {
- lappend result failure
- }
-} {1 success}
-test binary-40.4 {ScanNumber: floating point overflow} {nonPortable unixOnly} {
- catch {unset arg1}
- list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff d1 arg1] $arg1
-} {1 -NaN}
-test binary-40.5 {ScanNumber: floating point overflow} {nonPortable macOnly} {
- catch {unset arg1}
- list [binary scan \xff\xff\xff\xff\xff\xff\xff\xff d1 arg1] $arg1
-} {1 -NAN(255)}
-test binary-40.6 {ScanNumber: floating point overflow} {nonPortable pcOnly} {
- catch {unset arg1}
- set result [binary scan \xff\xff\xff\xff\xff\xff\xff\xff d1 arg1]
- if {([string compare $arg1 -1.\#QNAN] == 0)
- || ([string compare $arg1 -NAN] == 0)} {
- lappend result success
- } else {
- lappend result failure
- }
-} {1 success}
-
-test binary-41.1 {ScanNumber: word alignment} {
- catch {unset arg1; unset arg2}
- list [binary scan \x01\x01\x00 c1s1 arg1 arg2] $arg1 $arg2
-} {2 1 1}
-test binary-41.2 {ScanNumber: word alignment} {
- catch {unset arg1; unset arg2}
- list [binary scan \x01\x00\x01 c1S1 arg1 arg2] $arg1 $arg2
-} {2 1 1}
-test binary-41.3 {ScanNumber: word alignment} {
- catch {unset arg1; unset arg2}
- list [binary scan \x01\x01\x00\x00\x00 c1i1 arg1 arg2] $arg1 $arg2
-} {2 1 1}
-test binary-41.4 {ScanNumber: word alignment} {
- catch {unset arg1; unset arg2}
- list [binary scan \x01\x00\x00\x00\x01 c1I1 arg1 arg2] $arg1 $arg2
-} {2 1 1}
-test binary-41.5 {ScanNumber: word alignment} {nonPortable macOrUnix} {
- catch {unset arg1; unset arg2}
- list [binary scan \x01\x3f\xcc\xcc\xcd c1f1 arg1 arg2] $arg1 $arg2
-} {2 1 1.60000002384}
-test binary-41.6 {ScanNumber: word alignment} {nonPortable pcOnly} {
- catch {unset arg1; unset arg2}
- list [binary scan \x01\xcd\xcc\xcc\x3f c1f1 arg1 arg2] $arg1 $arg2
-} {2 1 1.60000002384}
-test binary-41.7 {ScanNumber: word alignment} {nonPortable macOrUnix} {
- catch {unset arg1; unset arg2}
- list [binary scan \x01\x3f\xf9\x99\x99\x99\x99\x99\x9a c1d1 arg1 arg2] $arg1 $arg2
-} {2 1 1.6}
-test binary-41.8 {ScanNumber: word alignment} {nonPortable pcOnly} {
- catch {unset arg1; unset arg2}
- list [binary scan \x01\x9a\x99\x99\x99\x99\x99\xf9\x3f c1d1 arg1 arg2] $arg1 $arg2
-} {2 1 1.6}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/case.test b/tests/case.test
deleted file mode 100644
index ee0b97f..0000000
--- a/tests/case.test
+++ /dev/null
@@ -1,102 +0,0 @@
-# Commands covered: case
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: case.test,v 1.3 1999/04/16 00:47:23 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test case-1.1 {simple pattern} {
- case a in a {format 1} b {format 2} c {format 3} default {format 4}
-} 1
-test case-1.2 {simple pattern} {
- case b a {format 1} b {format 2} c {format 3} default {format 4}
-} 2
-test case-1.3 {simple pattern} {
- case x in a {format 1} b {format 2} c {format 3} default {format 4}
-} 4
-test case-1.4 {simple pattern} {
- case x a {format 1} b {format 2} c {format 3}
-} {}
-test case-1.5 {simple pattern matches many times} {
- case b a {format 1} b {format 2} b {format 3} b {format 4}
-} 2
-test case-1.6 {fancier pattern} {
- case cx a {format 1} *c {format 2} *x {format 3} default {format 4}
-} 3
-test case-1.7 {list of patterns} {
- case abc in {a b c} {format 1} {def abc ghi} {format 2}
-} 2
-
-test case-2.1 {error in executed command} {
- list [catch {case a in a {error "Just a test"} default {format 1}} msg] \
- $msg $errorInfo
-} {1 {Just a test} {Just a test
- while executing
-"error "Just a test""
- ("a" arm line 1)
- invoked from within
-"case a in a {error "Just a test"} default {format 1}"}}
-test case-2.2 {error: not enough args} {
- list [catch {case} msg] $msg
-} {1 {wrong # args: should be "case string ?in? patList body ... ?default body?"}}
-test case-2.3 {error: pattern with no body} {
- list [catch {case a b} msg] $msg
-} {1 {extra case pattern with no body}}
-test case-2.4 {error: pattern with no body} {
- list [catch {case a in b {format 1} c} msg] $msg
-} {1 {extra case pattern with no body}}
-test case-2.5 {error in default command} {
- list [catch {case foo in a {error case1} default {error case2} \
- b {error case 3}} msg] $msg $errorInfo
-} {1 case2 {case2
- while executing
-"error case2"
- ("default" arm line 1)
- invoked from within
-"case foo in a {error case1} default {error case2} b {error case 3}"}}
-
-test case-3.1 {single-argument form for pattern/command pairs} {
- case b in {
- a {format 1}
- b {format 2}
- default {format 6}
- }
-} {2}
-test case-3.2 {single-argument form for pattern/command pairs} {
- case b {
- a {format 1}
- b {format 2}
- default {format 6}
- }
-} {2}
-test case-3.3 {single-argument form for pattern/command pairs} {
- list [catch {case z in {a 2 b}} msg] $msg
-} {1 {extra case pattern with no body}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/clock.test b/tests/clock.test
deleted file mode 100644
index d0072ad..0000000
--- a/tests/clock.test
+++ /dev/null
@@ -1,225 +0,0 @@
-# Commands covered: clock
-#
-# 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) 1995-1998 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: clock.test,v 1.3 1999/04/16 00:47:24 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test clock-1.1 {clock tests} {
- list [catch {clock} msg] $msg
-} {1 {wrong # args: should be "clock option ?arg ...?"}}
-test clock-1.2 {clock tests} {
- list [catch {clock foo} msg] $msg
-} {1 {bad option "foo": must be clicks, format, scan, or seconds}}
-
-# clock clicks
-test clock-2.1 {clock clicks tests} {
- expr [clock clicks]+1
- concat {}
-} {}
-test clock-2.2 {clock clicks tests} {
- list [catch {clock clicks foo} msg] $msg
-} {1 {wrong # args: should be "clock clicks"}}
-test clock-2.3 {clock clicks tests} {
- set start [clock clicks]
- after 10
- set end [clock clicks]
- expr "$end > $start"
-} {1}
-
-# clock format
-test clock-3.1 {clock format tests} {unixOnly} {
- set clockval 657687766
- clock format $clockval -format {%a %b %d %I:%M:%S %p %Y} -gmt true
-} {Sun Nov 04 03:02:46 AM 1990}
-test clock-3.2 {clock format tests} {
- # TCL_USE_TIMEZONE_VAR
-
- catch {set oldtz $env(TZ)}
- set env(TZ) PST
- set x {}
- append x [clock format 863800000 -format %Z -gmt 1]
- append x [set env(TZ)]
- catch {unset env(TZ); set env(TZ) $oldtz}
- set x
-} {GMTPST}
-test clock-3.3 {clock format tests} {
- # tzset() under Borland doesn't seem to set up tzname[] for local
- # timezone, which caused "clock format" to think that %Z was an invalid
- # string. Don't care about answer, just that test runs w/o error.
-
- clock format 863800000 -format %Z
- set x {}
-} {}
-test clock-3.4 {clock format tests} {
- # tzset() under Borland doesn't seem to set up tzname[] for gmt timezone.
- # tzset() under MSVC has the following weird observed behavior:
- # First time we call "clock format [clock seconds] -format %Z -gmt 1"
- # we get "GMT", but on all subsequent calls we get the current time
- # zone string, even though env(TZ) is GMT and the variable _timezone
- # is 0.
-
- set x {}
- append x [clock format 863800000 -format %Z -gmt 1]
- append x [clock format 863800000 -format %Z -gmt 1]
-} {GMTGMT}
-test clock-3.5 {clock format tests} {
- list [catch {clock format} msg] $msg
-} {1 {wrong # args: should be "clock format clockval ?-format string? ?-gmt boolean?"}}
-test clock-3.6 {clock format tests} {
- list [catch {clock format foo} msg] $msg
-} {1 {expected integer but got "foo"}}
-test clock-3.7 {clock format tests} {unixOrPc} {
- set clockval 657687766
- clock format $clockval -format "%a %b %d %I:%M:%S %p %Y" -gmt true
-} "Sun Nov 04 03:02:46 AM 1990"
-test clock-3.8 {clock format tests} {
- list [catch {clock format a b c d e g} msg] $msg
-} {1 {wrong # args: should be "clock format clockval ?-format string? ?-gmt boolean?"}}
-test clock-3.9 {clock format tests} {unixOrPc nonPortable} {
- set clockval -1
- clock format $clockval -format "%a %b %d %I:%M:%S %p %Y" -gmt true
-} "Wed Dec 31 11:59:59 PM 1969"
-test clock-3.10 {clock format tests} {
- list [catch {clock format 123 -bad arg} msg] $msg
-} {1 {bad switch "-bad": must be -format or -gmt}}
-test clock-3.11 {clock format tests} {
- clock format 123 -format "x"
-} x
-test clock-3.12 {clock format tests} {
- clock format 123 -format ""
-} ""
-
-# clock scan
-test clock-4.1 {clock scan tests} {
- list [catch {clock scan} msg] $msg
-} {1 {wrong # args: should be "clock scan dateString ?-base clockValue? ?-gmt boolean?"}}
-test clock-4.2 {clock scan tests} {
- list [catch {clock scan "bad-string"} msg] $msg
-} {1 {unable to convert date-time string "bad-string"}}
-test clock-4.3 {clock scan tests} {
- clock format [clock scan "14 Feb 92" -gmt true] \
- -format {%m/%d/%y %I:%M:%S %p} -gmt true
-} {02/14/92 12:00:00 AM}
-test clock-4.4 {clock scan tests} {
- clock format [clock scan "Feb 14, 1992 12:20 PM" -gmt true] \
- -format {%m/%d/%y %I:%M:%S %p} -gmt true
-} {02/14/92 12:20:00 PM}
-test clock-4.5 {clock scan tests} {
- clock format \
- [clock scan "Feb 14, 1992 12:20 PM" -base 319363200 -gmt true] \
- -format {%m/%d/%y %I:%M:%S %p} -gmt true
-} {02/14/92 12:20:00 PM}
-test clock-4.6 {clock scan tests} {
- set time [clock scan "Oct 23,1992 15:00"]
- clock format $time -format {%b %d,%Y %H:%M}
-} {Oct 23,1992 15:00}
-test clock-4.7 {clock scan tests} {
- set time [clock scan "Oct 23,1992 15:00 GMT"]
- clock format $time -format {%b %d,%Y %H:%M GMT} -gmt true
-} {Oct 23,1992 15:00 GMT}
-test clock-4.8 {clock scan tests} {
- set time [clock scan "Oct 23,1992 15:00" -gmt true]
- clock format $time -format {%b %d,%Y %H:%M GMT} -gmt true
-} {Oct 23,1992 15:00 GMT}
-test clock-4.9 {clock scan tests} {
- list [catch {clock scan "Jan 12" -bad arg} msg] $msg
-} {1 {bad switch "-bad": must be -base or -gmt}}
-# The following two two tests test the two year date policy
-test clock-4.10 {clock scan tests} {
- set time [clock scan "1/1/71" -gmt true]
- clock format $time -format {%b %d,%Y %H:%M GMT} -gmt true
-} {Jan 01,1971 00:00 GMT}
-test clock-4.11 {clock scan tests} {
- set time [clock scan "1/1/37" -gmt true]
- clock format $time -format {%b %d,%Y %H:%M GMT} -gmt true
-} {Jan 01,2037 00:00 GMT}
-
-# clock seconds
-test clock-5.1 {clock seconds tests} {
- expr [clock seconds]+1
- concat {}
-} {}
-test clock-5.2 {clock seconds tests} {
- list [catch {clock seconds foo} msg] $msg
-} {1 {wrong # args: should be "clock seconds"}}
-test clock-5.3 {clock seconds tests} {
- set start [clock seconds]
- after 2000
- set end [clock seconds]
- expr "$end > $start"
-} {1}
-
-# The following dates check certain roll over dates
-set day [expr 24 * 60 * 60]
-test clock-6.1 {clock roll over dates} {
- set time [clock scan "12/31/1998" -gmt true]
- clock format [expr $time + $day] -format {%b %d,%Y %H:%M GMT} -gmt true
-} {Jan 01,1999 00:00 GMT}
-test clock-6.2 {clock roll over dates} {
- set time [clock scan "12/31/1999" -gmt true]
- clock format [expr $time + $day] -format {%b %d,%Y %H:%M GMT} -gmt true
-} {Jan 01,2000 00:00 GMT}
-test clock-6.3 {clock roll over dates} {
- set time [clock scan "2/28/2000" -gmt true]
- clock format [expr $time + $day] -format {%b %d,%Y %H:%M GMT} -gmt true
-} {Feb 29,2000 00:00 GMT}
-test clock-6.4 {clock roll over dates} {
- set time [clock scan "2/29/2000" -gmt true]
- clock format [expr $time + $day] -format {%b %d,%Y %H:%M GMT} -gmt true
-} {Mar 01,2000 00:00 GMT}
-test clock-6.5 {clock roll over dates} {
- set time [clock scan "January 1, 2000" -gmt true]
- clock format $time -format %A -gmt true
-} {Saturday}
-test clock-6.6 {clock roll over dates} {
- set time [clock scan "January 1, 2000" -gmt true]
- clock format $time -format %j -gmt true
-} {001}
-test clock-6.7 {clock roll over dates} {
- set time [clock scan "February 29, 2000" -gmt true]
- clock format $time -format %A -gmt true
-} {Tuesday}
-test clock-6.8 {clock roll over dates} {
- set time [clock scan "February 29, 2000" -gmt true]
- clock format $time -format %j -gmt true
-} {060}
-test clock-6.9 {clock roll over dates} {
- set time [clock scan "March 1, 2000" -gmt true]
- clock format $time -format %A -gmt true
-} {Wednesday}
-test clock-6.10 {clock roll over dates} {
- set time [clock scan "March 1, 2000" -gmt true]
- clock format $time -format %j -gmt true
-} {061}
-test clock-6.11 {clock roll over dates} {
- set time [clock scan "March 1, 2001" -gmt true]
- clock format $time -format %j -gmt true
-} {060}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/cmdAH.test b/tests/cmdAH.test
deleted file mode 100644
index 19ef9c4..0000000
--- a/tests/cmdAH.test
+++ /dev/null
@@ -1,1484 +0,0 @@
-# The file tests the tclCmdAH.c file.
-#
-# 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) 1996-1998 by 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: cmdAH.test,v 1.5 1999/04/16 00:47:24 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-global env
-set cmdAHwd [pwd]
-catch {set platform [testgetplatform]}
-
-test cmdAH-0.1 {Tcl_BreakObjCmd, errors} {
- list [catch {break foo} msg] $msg
-} {1 {wrong # args: should be "break"}}
-test cmdAH-0.2 {Tcl_BreakObjCmd, success} {
- list [catch {break} msg] $msg
-} {3 {}}
-
-# Tcl_CaseObjCmd is tested in case.test
-
-test cmdAH-1.1 {Tcl_CatchObjCmd, errors} {
- list [catch {catch} msg] $msg
-} {1 {wrong # args: should be "catch command ?varName?"}}
-test cmdAH-1.2 {Tcl_CatchObjCmd, errors} {
- list [catch {catch foo bar baz} msg] $msg
-} {1 {wrong # args: should be "catch command ?varName?"}}
-
-test cmdAH-2.1 {Tcl_CdObjCmd} {
- list [catch {cd foo bar} msg] $msg
-} {1 {wrong # args: should be "cd ?dirName?"}}
-test cmdAH-2.2 {Tcl_CdObjCmd} {
- file delete -force foo
- file mkdir foo
- cd foo
- set result [file tail [pwd]]
- cd ..
- file delete foo
- set result
-} foo
-test cmdAH-2.3 {Tcl_CdObjCmd} {
- global env
- set oldpwd [pwd]
- set temp $env(HOME)
- set env(HOME) $oldpwd
- file delete -force foo
- file mkdir foo
- cd foo
- cd ~
- set result [string match [pwd] $oldpwd]
- file delete foo
- set env(HOME) $temp
- set result
-} 1
-test cmdAH-2.4 {Tcl_CdObjCmd} {
- global env
- set oldpwd [pwd]
- set temp $env(HOME)
- set env(HOME) $oldpwd
- file delete -force foo
- file mkdir foo
- cd foo
- cd
- set result [string match [pwd] $oldpwd]
- file delete foo
- set env(HOME) $temp
- set result
-} 1
-test cmdAH-2.5 {Tcl_CdObjCmd} {
- list [catch {cd ~~} msg] $msg
-} {1 {user "~" doesn't exist}}
-test cmdAH-2.6 {Tcl_CdObjCmd} {
- list [catch {cd _foobar} msg] $msg
-} {1 {couldn't change working directory to "_foobar": no such file or directory}}
-
-test cmdAH-2.7 {Tcl_ConcatObjCmd} {
- concat
-} {}
-test cmdAH-2.8 {Tcl_ConcatObjCmd} {
- concat a
-} a
-test cmdAH-2.9 {Tcl_ConcatObjCmd} {
- concat a {b c}
-} {a b c}
-
-test cmdAH-3.1 {Tcl_ContinueObjCmd, errors} {
- list [catch {continue foo} msg] $msg
-} {1 {wrong # args: should be "continue"}}
-test cmdAH-3.2 {Tcl_ContinueObjCmd, success} {
- list [catch {continue} msg] $msg
-} {4 {}}
-
-test cmdAH-4.1 {Tcl_EncodingObjCmd} {
- list [catch {encoding} msg] $msg
-} {1 {wrong # args: should be "encoding option ?arg ...?"}}
-test cmdAH-4.2 {Tcl_EncodingObjCmd} {
- list [catch {encoding foo} msg] $msg
-} {1 {bad option "foo": must be convertfrom, convertto, names, or system}}
-test cmdAH-4.3 {Tcl_EncodingObjCmd} {
- list [catch {encoding convertto} msg] $msg
-} {1 {wrong # args: should be "encoding convertto ?encoding? data"}}
-test cmdAH-4.4 {Tcl_EncodingObjCmd} {
- list [catch {encoding convertto foo bar} msg] $msg
-} {1 {unknown encoding "foo"}}
-test cmdAH-4.5 {Tcl_EncodingObjCmd} {
- set system [encoding system]
- encoding system jis0208
- set x [encoding convertto \u4e4e]
- encoding system $system
- set x
-} 8C
-test cmdAH-4.6 {Tcl_EncodingObjCmd} {
- set system [encoding system]
- encoding system identity
- set x [encoding convertto jis0208 \u4e4e]
- encoding system $system
- set x
-} 8C
-test cmdAH-4.7 {Tcl_EncodingObjCmd} {
- list [catch {encoding convertfrom} msg] $msg
-} {1 {wrong # args: should be "encoding convertfrom ?encoding? data"}}
-test cmdAH-4.8 {Tcl_EncodingObjCmd} {
- list [catch {encoding convertfrom foo bar} msg] $msg
-} {1 {unknown encoding "foo"}}
-test cmdAH-4.9 {Tcl_EncodingObjCmd} {
- set system [encoding system]
- encoding system jis0208
- set x [encoding convertfrom 8C]
- encoding system $system
- set x
-} \u4e4e
-test cmdAH-4.10 {Tcl_EncodingObjCmd} {
- set system [encoding system]
- encoding system identity
- set x [encoding convertfrom jis0208 8C]
- encoding system $system
- set x
-} \u4e4e
-test cmdAH-4.11 {Tcl_EncodingObjCmd} {
- list [catch {encoding names foo} msg] $msg
-} {1 {wrong # args: should be "encoding names"}}
-test cmdAH-4.12 {Tcl_EncodingObjCmd} {
- list [catch {encoding system foo bar} msg] $msg
-} {1 {wrong # args: should be "encoding system ?encoding?"}}
-test cmdAH-4.13 {Tcl_EncodingObjCmd} {
- set system [encoding system]
- encoding system identity
- set x [encoding system]
- encoding system $system
- set x
-} identity
-
-test cmdAH-5.1 {Tcl_FileObjCmd} {
- list [catch file msg] $msg
-} {1 {wrong # args: should be "file option ?arg ...?"}}
-test cmdAH-5.2 {Tcl_FileObjCmd} {
- list [catch {file x} msg] $msg
-} {1 {bad option "x": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
-test cmdAH-5.3 {Tcl_FileObjCmd} {
- list [catch {file atime} msg] $msg
-} {1 {wrong # args: should be "file atime name"}}
-
-
-#volume
-
-test cmdAH-6.1 {Tcl_FileObjCmd: volumes} {
- list [catch {file volumes x} msg] $msg
-} {1 {wrong # args: should be "file volumes"}}
-test cmdAH-6.2 {Tcl_FileObjCmd: volumes} {
- set volumeList [file volumes]
- if { [llength $volumeList] == 0 } {
- set result 0
- } else {
- set result 1
- }
-} {1}
-test cmdAH-6.3 {Tcl_FileObjCmd: volumes} {macOrUnix} {
- set volumeList [file volumes]
- catch [list glob -nocomplain [lindex $volumeList 0]*]
-} {0}
-test cmdAH-6.4 {Tcl_FileObjCmd: volumes} {pcOnly} {
- set volumeList [string tolower [file volumes]]
- list [catch {lsearch $volumeList "c:/"} element] [expr $element != -1] [catch {list glob -nocomplain [lindex $volumeList $element]*}]
-} {0 1 0}
-
-# attributes
-
-test cmdAH-7.1 {Tcl_FileObjCmd - file attrs} {
- catch {file delete -force foo.file}
- close [open foo.file w]
- list [catch {file attributes foo.file}] [file delete -force foo.file]
-} {0 {}}
-
-# dirname
-
-if {[info commands testsetplatform] == {}} {
- puts "This application hasn't been compiled with the \"testsetplatform\""
- puts "command, so I can't test Tcl_FileObjCmd etc."
-} else {
-test cmdAH-8.1 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- list [catch {file dirname a b} msg] $msg
-} {1 {wrong # args: should be "file dirname name"}}
-test cmdAH-8.2 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- file dirname /a/b
-} /a
-test cmdAH-8.3 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- file dirname {}
-} .
-test cmdAH-8.4 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- file dirname {}
-} :
-test cmdAH-8.5 {Tcl_FileObjCmd: dirname} {
- testsetplatform win
- file dirname {}
-} .
-test cmdAH-8.6 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- file dirname .def
-} .
-test cmdAH-8.7 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- file dirname a
-} :
-test cmdAH-8.8 {Tcl_FileObjCmd: dirname} {
- testsetplatform win
- file dirname a
-} .
-test cmdAH-8.9 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- file dirname a/b/c.d
-} a/b
-test cmdAH-8.10 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- file dirname a/b.c/d
-} a/b.c
-test cmdAH-8.11 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- file dirname /.
-} /
-test cmdAH-8.12 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- list [catch {file dirname /} msg] $msg
-} {0 /}
-test cmdAH-8.13 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- list [catch {file dirname /foo} msg] $msg
-} {0 /}
-test cmdAH-8.14 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- list [catch {file dirname //foo} msg] $msg
-} {0 /}
-test cmdAH-8.15 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- list [catch {file dirname //foo/bar} msg] $msg
-} {0 /foo}
-test cmdAH-8.16 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- list [catch {file dirname {//foo\/bar/baz}} msg] $msg
-} {0 {/foo\/bar}}
-test cmdAH-8.17 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- list [catch {file dirname {//foo\/bar/baz/blat}} msg] $msg
-} {0 {/foo\/bar/baz}}
-test cmdAH-8.18 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- list [catch {file dirname /foo//} msg] $msg
-} {0 /}
-test cmdAH-8.19 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- list [catch {file dirname ./a} msg] $msg
-} {0 .}
-test cmdAH-8.20 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- list [catch {file dirname a/.a} msg] $msg
-} {0 a}
-test cmdAH-8.21 {Tcl_FileObjCmd: dirname} {
- testsetplatform windows
- list [catch {file dirname c:foo} msg] $msg
-} {0 c:}
-test cmdAH-8.22 {Tcl_FileObjCmd: dirname} {
- testsetplatform windows
- list [catch {file dirname c:} msg] $msg
-} {0 c:}
-test cmdAH-8.23 {Tcl_FileObjCmd: dirname} {
- testsetplatform windows
- list [catch {file dirname c:/} msg] $msg
-} {0 c:/}
-test cmdAH-8.24 {Tcl_FileObjCmd: dirname} {
- testsetplatform windows
- list [catch {file dirname {c:\foo}} msg] $msg
-} {0 c:/}
-test cmdAH-8.25 {Tcl_FileObjCmd: dirname} {
- testsetplatform windows
- list [catch {file dirname {//foo/bar/baz}} msg] $msg
-} {0 //foo/bar}
-test cmdAH-8.26 {Tcl_FileObjCmd: dirname} {
- testsetplatform windows
- list [catch {file dirname {//foo/bar}} msg] $msg
-} {0 //foo/bar}
-test cmdAH-8.27 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- list [catch {file dirname :} msg] $msg
-} {0 :}
-test cmdAH-8.28 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- list [catch {file dirname :Foo} msg] $msg
-} {0 :}
-test cmdAH-8.29 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- list [catch {file dirname Foo:} msg] $msg
-} {0 Foo:}
-test cmdAH-8.30 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- list [catch {file dirname Foo:bar} msg] $msg
-} {0 Foo:}
-test cmdAH-8.31 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- list [catch {file dirname :Foo:bar} msg] $msg
-} {0 :Foo}
-test cmdAH-8.32 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- list [catch {file dirname ::} msg] $msg
-} {0 :}
-test cmdAH-8.33 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- list [catch {file dirname :::} msg] $msg
-} {0 ::}
-test cmdAH-8.34 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- list [catch {file dirname /foo/bar/} msg] $msg
-} {0 foo:}
-test cmdAH-8.35 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- list [catch {file dirname /foo/bar} msg] $msg
-} {0 foo:}
-test cmdAH-8.36 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- list [catch {file dirname /foo} msg] $msg
-} {0 foo:}
-test cmdAH-8.37 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- list [catch {file dirname foo} msg] $msg
-} {0 :}
-test cmdAH-8.38 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- list [catch {file dirname ~/foo} msg] $msg
-} {0 ~}
-test cmdAH-8.39 {Tcl_FileObjCmd: dirname} {
- testsetplatform unix
- list [catch {file dirname ~bar/foo} msg] $msg
-} {0 ~bar}
-test cmdAH-8.40 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- list [catch {file dirname ~bar/foo} msg] $msg
-} {0 ~bar:}
-test cmdAH-8.41 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- list [catch {file dirname ~/foo} msg] $msg
-} {0 ~:}
-test cmdAH-8.42 {Tcl_FileObjCmd: dirname} {
- testsetplatform mac
- list [catch {file dirname ~:baz} msg] $msg
-} {0 ~:}
-test cmdAH-8.43 {Tcl_FileObjCmd: dirname} {
- global env
- set temp $env(HOME)
- set env(HOME) "/home/test"
- testsetplatform unix
- set result [list [catch {file dirname ~} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 /home}
-test cmdAH-8.44 {Tcl_FileObjCmd: dirname} {
- global env
- set temp $env(HOME)
- set env(HOME) "~"
- testsetplatform unix
- set result [list [catch {file dirname ~} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 ~}
-test cmdAH-8.45 {Tcl_FileObjCmd: dirname} {
- global env
- set temp $env(HOME)
- set env(HOME) "/home/test"
- testsetplatform windows
- set result [list [catch {file dirname ~} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 /home}
-test cmdAH-8.46 {Tcl_FileObjCmd: dirname} {
- global env
- set temp $env(HOME)
- set env(HOME) "/home/test"
- testsetplatform mac
- set result [list [catch {file dirname ~} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 home:}
-
-# tail
-
-test cmdAH-9.1 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- list [catch {file tail a b} msg] $msg
-} {1 {wrong # args: should be "file tail name"}}
-test cmdAH-9.2 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail /a/b
-} b
-test cmdAH-9.3 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail {}
-} {}
-test cmdAH-9.4 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail {}
-} {}
-test cmdAH-9.5 {Tcl_FileObjCmd: tail} {
- testsetplatform win
- file tail {}
-} {}
-test cmdAH-9.6 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail .def
-} .def
-test cmdAH-9.7 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail a
-} a
-test cmdAH-9.8 {Tcl_FileObjCmd: tail} {
- testsetplatform win
- file tail a
-} a
-test cmdAH-9.9 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file ta a/b/c.d
-} c.d
-test cmdAH-9.10 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail a/b.c/d
-} d
-test cmdAH-9.11 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail /.
-} .
-test cmdAH-9.12 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail /
-} {}
-test cmdAH-9.13 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail /foo
-} foo
-test cmdAH-9.14 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail //foo
-} foo
-test cmdAH-9.15 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail //foo/bar
-} bar
-test cmdAH-9.16 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail {//foo\/bar/baz}
-} baz
-test cmdAH-9.17 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail {//foo\/bar/baz/blat}
-} blat
-test cmdAH-9.18 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail /foo//
-} foo
-test cmdAH-9.19 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail ./a
-} a
-test cmdAH-9.20 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail a/.a
-} .a
-test cmdAH-9.21 {Tcl_FileObjCmd: tail} {
- testsetplatform windows
- file tail c:foo
-} foo
-test cmdAH-9.22 {Tcl_FileObjCmd: tail} {
- testsetplatform windows
- file tail c:
-} {}
-test cmdAH-9.23 {Tcl_FileObjCmd: tail} {
- testsetplatform windows
- file tail c:/
-} {}
-test cmdAH-9.24 {Tcl_FileObjCmd: tail} {
- testsetplatform windows
- file tail {c:\foo}
-} foo
-test cmdAH-9.25 {Tcl_FileObjCmd: tail} {
- testsetplatform windows
- file tail {//foo/bar/baz}
-} baz
-test cmdAH-9.26 {Tcl_FileObjCmd: tail} {
- testsetplatform windows
- file tail {//foo/bar}
-} {}
-test cmdAH-9.27 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail :
-} :
-test cmdAH-9.28 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail :Foo
-} Foo
-test cmdAH-9.29 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail Foo:
-} {}
-test cmdAH-9.30 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail Foo:bar
-} bar
-test cmdAH-9.31 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail :Foo:bar
-} bar
-test cmdAH-9.32 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail ::
-} ::
-test cmdAH-9.33 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail :::
-} ::
-test cmdAH-9.34 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail /foo/bar/
-} bar
-test cmdAH-9.35 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail /foo/bar
-} bar
-test cmdAH-9.36 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail /foo
-} {}
-test cmdAH-9.37 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail foo
-} foo
-test cmdAH-9.38 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail ~:foo
-} foo
-test cmdAH-9.39 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail ~bar:foo
-} foo
-test cmdAH-9.40 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail ~bar/foo
-} foo
-test cmdAH-9.41 {Tcl_FileObjCmd: tail} {
- testsetplatform mac
- file tail ~/foo
-} foo
-test cmdAH-9.42 {Tcl_FileObjCmd: tail} {
- global env
- set temp $env(HOME)
- set env(HOME) "/home/test"
- testsetplatform unix
- set result [file tail ~]
- set env(HOME) $temp
- set result
-} test
-test cmdAH-9.43 {Tcl_FileObjCmd: tail} {
- global env
- set temp $env(HOME)
- set env(HOME) "~"
- testsetplatform unix
- set result [file tail ~]
- set env(HOME) $temp
- set result
-} {}
-test cmdAH-9.44 {Tcl_FileObjCmd: tail} {
- global env
- set temp $env(HOME)
- set env(HOME) "/home/test"
- testsetplatform windows
- set result [file tail ~]
- set env(HOME) $temp
- set result
-} test
-test cmdAH-9.45 {Tcl_FileObjCmd: tail} {
- global env
- set temp $env(HOME)
- set env(HOME) "/home/test"
- testsetplatform mac
- set result [file tail ~]
- set env(HOME) $temp
- set result
-} test
-test cmdAH-9.46 {Tcl_FileObjCmd: tail} {
- testsetplatform unix
- file tail {f.oo\bar/baz.bat}
-} baz.bat
-test cmdAH-9.47 {Tcl_FileObjCmd: tail} {
- testsetplatform windows
- file tail c:foo
-} foo
-test cmdAH-9.48 {Tcl_FileObjCmd: tail} {
- testsetplatform windows
- file tail c:
-} {}
-test cmdAH-9.49 {Tcl_FileObjCmd: tail} {
- testsetplatform windows
- file tail c:/foo
-} foo
-test cmdAH-9.50 {Tcl_FileObjCmd: tail} {
- testsetplatform windows
- file tail {c:/foo\bar}
-} bar
-test cmdAH-9.51 {Tcl_FileObjCmd: tail} {
- testsetplatform windows
- file tail {foo\bar}
-} bar
-
-# rootname
-
-test cmdAH-10.1 {Tcl_FileObjCmd: rootname} {
- testsetplatform unix
- list [catch {file rootname a b} msg] $msg
-} {1 {wrong # args: should be "file rootname name"}}
-test cmdAH-10.2 {Tcl_FileObjCmd: rootname} {
- testsetplatform unix
- file rootname {}
-} {}
-test cmdAH-10.3 {Tcl_FileObjCmd: rootname} {
- testsetplatform unix
- file ro foo
-} foo
-test cmdAH-10.4 {Tcl_FileObjCmd: rootname} {
- testsetplatform unix
- file rootname foo.
-} foo
-test cmdAH-10.5 {Tcl_FileObjCmd: rootname} {
- testsetplatform unix
- file rootname .foo
-} {}
-test cmdAH-10.6 {Tcl_FileObjCmd: rootname} {
- testsetplatform unix
- file rootname abc.def
-} abc
-test cmdAH-10.7 {Tcl_FileObjCmd: rootname} {
- testsetplatform unix
- file rootname abc.def.ghi
-} abc.def
-test cmdAH-10.8 {Tcl_FileObjCmd: rootname} {
- testsetplatform unix
- file rootname a/b/c.d
-} a/b/c
-test cmdAH-10.9 {Tcl_FileObjCmd: rootname} {
- testsetplatform unix
- file rootname a/b.c/d
-} a/b.c/d
-test cmdAH-10.10 {Tcl_FileObjCmd: rootname} {
- testsetplatform unix
- file rootname a/b.c/
-} a/b.c/
-test cmdAH-10.11 {Tcl_FileObjCmd: rootname} {
- testsetplatform mac
- file ro foo
-} foo
-test cmdAH-10.12 {Tcl_FileObjCmd: rootname} {
- testsetplatform mac
- file rootname {}
-} {}
-test cmdAH-10.13 {Tcl_FileObjCmd: rootname} {
- testsetplatform mac
- file rootname foo.
-} foo
-test cmdAH-10.14 {Tcl_FileObjCmd: rootname} {
- testsetplatform mac
- file rootname .foo
-} {}
-test cmdAH-10.15 {Tcl_FileObjCmd: rootname} {
- testsetplatform mac
- file rootname abc.def
-} abc
-test cmdAH-10.16 {Tcl_FileObjCmd: rootname} {
- testsetplatform mac
- file rootname abc.def.ghi
-} abc.def
-test cmdAH-10.17 {Tcl_FileObjCmd: rootname} {
- testsetplatform mac
- file rootname a:b:c.d
-} a:b:c
-test cmdAH-10.18 {Tcl_FileObjCmd: rootname} {
- testsetplatform mac
- file rootname a:b.c:d
-} a:b.c:d
-test cmdAH-10.19 {Tcl_FileObjCmd: rootname} {
- testsetplatform mac
- file rootname a/b/c.d
-} a/b/c
-test cmdAH-10.20 {Tcl_FileObjCmd: rootname} {
- testsetplatform mac
- file rootname a/b.c/d
-} a/b.c/d
-test cmdAH-10.21 {Tcl_FileObjCmd: rootname} {
- testsetplatform mac
- file rootname /a.b
-} /a
-test cmdAH-10.22 {Tcl_FileObjCmd: rootname} {
- testsetplatform mac
- file rootname foo.c:
-} foo.c:
-test cmdAH-10.23 {Tcl_FileObjCmd: rootname} {
- testsetplatform windows
- file rootname {}
-} {}
-test cmdAH-10.24 {Tcl_FileObjCmd: rootname} {
- testsetplatform windows
- file ro foo
-} foo
-test cmdAH-10.25 {Tcl_FileObjCmd: rootname} {
- testsetplatform windows
- file rootname foo.
-} foo
-test cmdAH-10.26 {Tcl_FileObjCmd: rootname} {
- testsetplatform windows
- file rootname .foo
-} {}
-test cmdAH-10.27 {Tcl_FileObjCmd: rootname} {
- testsetplatform windows
- file rootname abc.def
-} abc
-test cmdAH-10.28 {Tcl_FileObjCmd: rootname} {
- testsetplatform windows
- file rootname abc.def.ghi
-} abc.def
-test cmdAH-10.29 {Tcl_FileObjCmd: rootname} {
- testsetplatform windows
- file rootname a/b/c.d
-} a/b/c
-test cmdAH-10.30 {Tcl_FileObjCmd: rootname} {
- testsetplatform windows
- file rootname a/b.c/d
-} a/b.c/d
-test cmdAH-10.31 {Tcl_FileObjCmd: rootname} {
- testsetplatform windows
- file rootname a\\b.c\\
-} a\\b.c\\
-test cmdAH-10.32 {Tcl_FileObjCmd: rootname} {
- testsetplatform windows
- file rootname a\\b\\c.d
-} a\\b\\c
-test cmdAH-10.33 {Tcl_FileObjCmd: rootname} {
- testsetplatform windows
- file rootname a\\b.c\\d
-} a\\b.c\\d
-test cmdAH-10.34 {Tcl_FileObjCmd: rootname} {
- testsetplatform windows
- file rootname a\\b.c\\
-} a\\b.c\\
-set num 35
-foreach outer { {} a .a a. a.a } {
- foreach inner { {} a .a a. a.a } {
- set thing [format %s/%s $outer $inner]
-; test cmdAH-6.$num {Tcl_FileObjCmd: rootname and extension options} {
- testsetplatform unix
- format %s%s [file rootname $thing] [file ext $thing]
- } $thing
- set num [expr $num+1]
- }
-}
-
-# extension
-
-test cmdAH-11.1 {Tcl_FileObjCmd: extension} {
- testsetplatform unix
- list [catch {file extension a b} msg] $msg
-} {1 {wrong # args: should be "file extension name"}}
-test cmdAH-11.2 {Tcl_FileObjCmd: extension} {
- testsetplatform unix
- file extension {}
-} {}
-test cmdAH-11.3 {Tcl_FileObjCmd: extension} {
- testsetplatform unix
- file ext foo
-} {}
-test cmdAH-11.4 {Tcl_FileObjCmd: extension} {
- testsetplatform unix
- file extension foo.
-} .
-test cmdAH-11.5 {Tcl_FileObjCmd: extension} {
- testsetplatform unix
- file extension .foo
-} .foo
-test cmdAH-11.6 {Tcl_FileObjCmd: extension} {
- testsetplatform unix
- file extension abc.def
-} .def
-test cmdAH-11.7 {Tcl_FileObjCmd: extension} {
- testsetplatform unix
- file extension abc.def.ghi
-} .ghi
-test cmdAH-11.8 {Tcl_FileObjCmd: extension} {
- testsetplatform unix
- file extension a/b/c.d
-} .d
-test cmdAH-11.9 {Tcl_FileObjCmd: extension} {
- testsetplatform unix
- file extension a/b.c/d
-} {}
-test cmdAH-11.10 {Tcl_FileObjCmd: extension} {
- testsetplatform unix
- file extension a/b.c/
-} {}
-test cmdAH-11.11 {Tcl_FileObjCmd: extension} {
- testsetplatform mac
- file ext foo
-} {}
-test cmdAH-11.12 {Tcl_FileObjCmd: extension} {
- testsetplatform mac
- file extension {}
-} {}
-test cmdAH-11.13 {Tcl_FileObjCmd: extension} {
- testsetplatform mac
- file extension foo.
-} .
-test cmdAH-11.14 {Tcl_FileObjCmd: extension} {
- testsetplatform mac
- file extension .foo
-} .foo
-test cmdAH-11.15 {Tcl_FileObjCmd: extension} {
- testsetplatform mac
- file extension abc.def
-} .def
-test cmdAH-11.16 {Tcl_FileObjCmd: extension} {
- testsetplatform mac
- file extension abc.def.ghi
-} .ghi
-test cmdAH-11.17 {Tcl_FileObjCmd: extension} {
- testsetplatform mac
- file extension a:b:c.d
-} .d
-test cmdAH-11.18 {Tcl_FileObjCmd: extension} {
- testsetplatform mac
- file extension a:b.c:d
-} {}
-test cmdAH-11.19 {Tcl_FileObjCmd: extension} {
- testsetplatform mac
- file extension a/b/c.d
-} .d
-test cmdAH-11.20 {Tcl_FileObjCmd: extension} {
- testsetplatform mac
- file extension a/b.c/d
-} {}
-test cmdAH-11.21 {Tcl_FileObjCmd: extension} {
- testsetplatform mac
- file extension /a.b
-} .b
-test cmdAH-11.22 {Tcl_FileObjCmd: extension} {
- testsetplatform mac
- file extension foo.c:
-} {}
-test cmdAH-11.23 {Tcl_FileObjCmd: extension} {
- testsetplatform windows
- file extension {}
-} {}
-test cmdAH-11.24 {Tcl_FileObjCmd: extension} {
- testsetplatform windows
- file ext foo
-} {}
-test cmdAH-11.25 {Tcl_FileObjCmd: extension} {
- testsetplatform windows
- file extension foo.
-} .
-test cmdAH-11.26 {Tcl_FileObjCmd: extension} {
- testsetplatform windows
- file extension .foo
-} .foo
-test cmdAH-11.27 {Tcl_FileObjCmd: extension} {
- testsetplatform windows
- file extension abc.def
-} .def
-test cmdAH-11.28 {Tcl_FileObjCmd: extension} {
- testsetplatform windows
- file extension abc.def.ghi
-} .ghi
-test cmdAH-11.29 {Tcl_FileObjCmd: extension} {
- testsetplatform windows
- file extension a/b/c.d
-} .d
-test cmdAH-11.30 {Tcl_FileObjCmd: extension} {
- testsetplatform windows
- file extension a/b.c/d
-} {}
-test cmdAH-11.31 {Tcl_FileObjCmd: extension} {
- testsetplatform windows
- file extension a\\b.c\\
-} {}
-test cmdAH-11.32 {Tcl_FileObjCmd: extension} {
- testsetplatform windows
- file extension a\\b\\c.d
-} .d
-test cmdAH-11.33 {Tcl_FileObjCmd: extension} {
- testsetplatform windows
- file extension a\\b.c\\d
-} {}
-test cmdAH-11.34 {Tcl_FileObjCmd: extension} {
- testsetplatform windows
- file extension a\\b.c\\
-} {}
-set num 35
-foreach value {a..b a...b a.c..b ..b} result {.b .b .b .b} {
- foreach p {unix mac windows} {
-; test cmdAH-7.$num {Tcl_FileObjCmd: extension} "
- testsetplatform $p
- file extension $value
- " $result
- incr num
- }
-}
-
-# pathtype
-
-test cmdAH-12.1 {Tcl_FileObjCmd: pathtype} {
- testsetplatform unix
- list [catch {file pathtype a b} msg] $msg
-} {1 {wrong # args: should be "file pathtype name"}}
-test cmdAH-12.2 {Tcl_FileObjCmd: pathtype} {
- testsetplatform unix
- file pathtype /a
-} absolute
-test cmdAH-12.3 {Tcl_FileObjCmd: pathtype} {
- testsetplatform unix
- file p a
-} relative
-test cmdAH-12.4 {Tcl_FileObjCmd: pathtype} {
- testsetplatform windows
- file pathtype c:a
-} volumerelative
-
-# split
-
-test cmdAH-13.1 {Tcl_FileObjCmd: split} {
- testsetplatform unix
- list [catch {file split a b} msg] $msg
-} {1 {wrong # args: should be "file split name"}}
-test cmdAH-13.2 {Tcl_FileObjCmd: split} {
- testsetplatform unix
- file split a
-} a
-test cmdAH-13.3 {Tcl_FileObjCmd: split} {
- testsetplatform unix
- file split a/b
-} {a b}
-
-# join
-
-test cmdAH-14.1 {Tcl_FileObjCmd: join} {
- testsetplatform unix
- file join a
-} a
-test cmdAH-14.2 {Tcl_FileObjCmd: join} {
- testsetplatform unix
- file join a b
-} a/b
-test cmdAH-14.3 {Tcl_FileObjCmd: join} {
- testsetplatform unix
- file join a b c d
-} a/b/c/d
-
-# error handling of Tcl_TranslateFileName
-
-test cmdAH-15.1 {Tcl_FileObjCmd} {
- testsetplatform unix
- list [catch {file atime ~_bad_user} msg] $msg
-} {1 {user "_bad_user" doesn't exist}}
-
-testsetplatform $platform
-}
-
-# readable
-
-if {[info commands testchmod] == {}} {
- puts "This application hasn't been compiled with the \"testchmod\""
- puts "command, so I can't test Tcl_FileObjCmd etc."
-} else {
-makeFile abcde gorp.file
-makeDirectory dir.file
-
-test cmdAH-16.1 {Tcl_FileObjCmd: readable} {
- list [catch {file readable a b} msg] $msg
-} {1 {wrong # args: should be "file readable name"}}
-testchmod 444 gorp.file
-test cmdAH-16.2 {Tcl_FileObjCmd: readable} {
- file readable gorp.file
-} 1
-testchmod 333 gorp.file
-test cmdAH-16.3 {Tcl_FileObjCmd: readable} {unixOnly notRoot} {
- file reada gorp.file
-} 0
-
-# writable
-
-test cmdAH-17.1 {Tcl_FileObjCmd: writable} {
- list [catch {file writable a b} msg] $msg
-} {1 {wrong # args: should be "file writable name"}}
-testchmod 555 gorp.file
-test cmdAH-17.2 {Tcl_FileObjCmd: writable} {notRoot} {
- file writable gorp.file
-} 0
-testchmod 222 gorp.file
-test cmdAH-17.3 {Tcl_FileObjCmd: writable} {
- file writable gorp.file
-} 1
-
-# executable
-
-file delete -force dir.file gorp.file
-file mkdir dir.file
-makeFile abcde gorp.file
-
-test cmdAH-18.1 {Tcl_FileObjCmd: executable} {
- list [catch {file executable a b} msg] $msg
-} {1 {wrong # args: should be "file executable name"}}
-test cmdAH-18.2 {Tcl_FileObjCmd: executable} {
- file executable gorp.file
-} 0
-test cmdAH-18.3 {Tcl_FileObjCmd: executable} {unixOnly} {
- # Only on unix will setting the execute bit on a regular file
- # cause that file to be executable.
-
- testchmod 775 gorp.file
- file exe gorp.file
-} 1
-
-test cmdAH-18.4 {Tcl_FileObjCmd: executable} {macOnly} {
- # On mac, the only executable files are of type APPL.
-
- set x [file exe gorp.file]
- file attrib gorp.file -type APPL
- lappend x [file exe gorp.file]
-} {0 1}
-test cmdAH-18.5 {Tcl_FileObjCmd: executable} {pcOnly} {
- # On pc, must be a .exe, .com, etc.
-
- set x [file exe gorp.file]
- makeFile foo gorp.exe
- lappend x [file exe gorp.exe]
- file delete gorp.exe
- set x
-} {0 1}
-test cmdAH-18.6 {Tcl_FileObjCmd: executable} {
- # Directories are always executable.
-
- file exe dir.file
-} 1
-
-file delete -force dir.file
-file delete gorp.file
-file delete link.file
-}
-
-# exists
-
-test cmdAH-19.1 {Tcl_FileObjCmd: exists} {
- list [catch {file exists a b} msg] $msg
-} {1 {wrong # args: should be "file exists name"}}
-test cmdAH-19.2 {Tcl_FileObjCmd: exists} {file exists gorp.file} 0
-test cmdAH-19.3 {Tcl_FileObjCmd: exists} {
- file exists [file join dir.file gorp.file]
-} 0
-catch {
- makeFile abcde gorp.file
- makeDirectory dir.file
- makeFile 12345 [file join dir.file gorp.file]
-}
-test cmdAH-19.4 {Tcl_FileObjCmd: exists} {
- file exists gorp.file
-} 1
-test cmdAH-19.5 {Tcl_FileObjCmd: exists} {
- file exists [file join dir.file gorp.file]
-} 1
-
-# nativename
-if {[info commands testsetplatform] == {}} {
- puts "This application hasn't been compiled with the \"testsetplatform\""
- puts "command, so I can't test Tcl_FileObjCmd etc."
-} else {
-test cmdAH-19.6 {Tcl_FileObjCmd: nativename} {
- testsetplatform unix
- list [catch {file nativename a/b} msg] $msg [testsetplatform $platform]
-} {0 a/b {}}
-test cmdAH-19.7 {Tcl_FileObjCmd: nativename} {
- testsetplatform windows
- list [catch {file nativename a/b} msg] $msg [testsetplatform $platform]
-} {0 {a\b} {}}
-test cmdAH-19.8 {Tcl_FileObjCmd: nativename} {
- testsetplatform mac
- list [catch {file nativename a/b} msg] $msg [testsetplatform $platform]
-} {0 :a:b {}}
-}
-
-test cmdAH-19.9 {Tcl_FileObjCmd: ~ : exists} {
- file exists ~nOsUcHuSeR
-} 0
-test cmdAH-19.10 {Tcl_FileObjCmd: ~ : nativename} {
- # should probably be 0 in fact...
- catch {file nativename ~nOsUcHuSeR}
-} 1
-
-# The test below has to be done in /tmp rather than the current
-# directory in order to guarantee (?) a local file system: some
-# NFS file systems won't do the stuff below correctly.
-
-test cmdAH-19.11 {Tcl_FileObjCmd: exists} {unixOnly notRoot} {
- removeFile /tmp/tcl.foo.dir/file
- removeDirectory /tmp/tcl.foo.dir
- makeDirectory /tmp/tcl.foo.dir
- makeFile 12345 /tmp/tcl.foo.dir/file
- exec chmod 000 /tmp/tcl.foo.dir
-
- set result [file exists /tmp/tcl.foo.dir/file]
-
- exec chmod 775 /tmp/tcl.foo.dir
- removeFile /tmp/tcl.foo.dir/file
- removeDirectory /tmp/tcl.foo.dir
- set result
-} 0
-
-# Stat related commands
-
-catch {testsetplatform $platform}
-file delete gorp.file
-makeFile "Test string" gorp.file
-catch {exec chmod 765 gorp.file}
-
-# atime
-
-test cmdAH-20.1 {Tcl_FileObjCmd: atime} {
- list [catch {file atime a b} msg] $msg
-} {1 {wrong # args: should be "file atime name"}}
-test cmdAH-20.2 {Tcl_FileObjCmd: atime} {
- catch {unset stat}
- file stat gorp.file stat
- list [expr {[file mtime gorp.file] == $stat(mtime)}] \
- [expr {[file atime gorp.file] == $stat(atime)}]
-} {1 1}
-test cmdAH-20.3 {Tcl_FileObjCmd: atime} {
- string tolower [list [catch {file atime _bogus_} msg] \
- $msg $errorCode]
-} {1 {could not read "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
-
-# isdirectory
-
-test cmdAH-21.1 {Tcl_FileObjCmd: isdirectory} {
- list [catch {file isdirectory a b} msg] $msg
-} {1 {wrong # args: should be "file isdirectory name"}}
-test cmdAH-21.2 {Tcl_FileObjCmd: isdirectory} {
- file isdirectory gorp.file
-} 0
-test cmdAH-21.3 {Tcl_FileObjCmd: isdirectory} {
- file isd dir.file
-} 1
-
-# isfile
-
-test cmdAH-22.1 {Tcl_FileObjCmd: isfile} {
- list [catch {file isfile a b} msg] $msg
-} {1 {wrong # args: should be "file isfile name"}}
-test cmdAH-22.2 {Tcl_FileObjCmd: isfile} {file isfile gorp.file} 1
-test cmdAH-22.3 {Tcl_FileObjCmd: isfile} {file isfile dir.file} 0
-
-# lstat and readlink: don't run these tests everywhere, since not all
-# sites will have symbolic links
-
-catch {exec ln -s gorp.file link.file}
-test cmdAH-23.1 {Tcl_FileObjCmd: lstat} {
- list [catch {file lstat a} msg] $msg
-} {1 {wrong # args: should be "file lstat name varName"}}
-test cmdAH-23.2 {Tcl_FileObjCmd: lstat} {
- list [catch {file lstat a b c} msg] $msg
-} {1 {wrong # args: should be "file lstat name varName"}}
-test cmdAH-23.3 {Tcl_FileObjCmd: lstat} {unixOnly nonPortable} {
- catch {unset stat}
- file lstat link.file stat
- lsort [array names stat]
-} {atime ctime dev gid ino mode mtime nlink size type uid}
-test cmdAH-23.4 {Tcl_FileObjCmd: lstat} {unixOnly nonPortable} {
- catch {unset stat}
- file lstat link.file stat
- list $stat(nlink) [expr $stat(mode)&0777] $stat(type)
-} {1 511 link}
-test cmdAH-23.5 {Tcl_FileObjCmd: lstat errors} {nonPortable} {
- string tolower [list [catch {file lstat _bogus_ stat} msg] \
- $msg $errorCode]
-} {1 {could not read "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
-test cmdAH-23.6 {Tcl_FileObjCmd: lstat errors} {
- catch {unset x}
- set x 44
- list [catch {file lstat gorp.file x} msg] $msg $errorCode
-} {1 {can't set "x(dev)": variable isn't array} NONE}
-catch {unset stat}
-
-# mtime
-
-test cmdAH-24.1 {Tcl_FileObjCmd: mtime} {
- list [catch {file mtime a b} msg] $msg
-} {1 {wrong # args: should be "file mtime name"}}
-test cmdAH-24.2 {Tcl_FileObjCmd: mtime} {
- set old [file mtime gorp.file]
- after 2000
- set f [open gorp.file w]
- puts $f "More text"
- close $f
- set new [file mtime gorp.file]
- expr {($new > $old) && ($new <= ($old+5))}
-} {1}
-test cmdAH-24.3 {Tcl_FileObjCmd: mtime} {
- catch {unset stat}
- file stat gorp.file stat
- list [expr {[file mtime gorp.file] == $stat(mtime)}] \
- [expr {[file atime gorp.file] == $stat(atime)}]
-} {1 1}
-test cmdAH-24.4 {Tcl_FileObjCmd: mtime} {
- string tolower [list [catch {file mtime _bogus_} msg] $msg \
- $errorCode]
-} {1 {could not read "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
-test cmdAH-24.5 {Tcl_FileObjCmd: mtime} {
- # Under Unix, use a file in /tmp to avoid clock skew due to NFS.
- # On other platforms, just use a file in the local directory.
-
- if {$tcl_platform(platform) == "unix"} {
- set name /tmp/tcl.test
- } else {
- set name tf
- }
-
- # Make sure that a new file's time is correct. 10 seconds variance
- # is allowed used due to slow networks or clock skew on a network drive.
-
- file delete -force $name
- close [open $name w]
- set a [expr abs([clock seconds]-[file mtime $name])<10]
- file delete $name
- set a
-} {1}
-
-
-# owned
-
-test cmdAH-25.1 {Tcl_FileObjCmd: owned} {
- list [catch {file owned a b} msg] $msg
-} {1 {wrong # args: should be "file owned name"}}
-test cmdAH-25.2 {Tcl_FileObjCmd: owned} {
- file owned gorp.file
-} 1
-test cmdAH-25.3 {Tcl_FileObjCmd: owned} {unixOnly notRoot} {
- file owned /
-} 0
-
-# readlink
-
-test cmdAH-26.1 {Tcl_FileObjCmd: readlink} {
- list [catch {file readlink a b} msg] $msg
-} {1 {wrong # args: should be "file readlink name"}}
-test cmdAH-26.2 {Tcl_FileObjCmd: readlink} {unixOnly nonPortable} {
- file readlink link.file
-} gorp.file
-test cmdAH-26.3 {Tcl_FileObjCmd: readlink errors} {unixOnly nonPortable} {
- list [catch {file readlink _bogus_} msg] [string tolower $msg] \
- [string tolower $errorCode]
-} {1 {could not readlink "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
-test cmdAH-26.4 {Tcl_FileObjCmd: readlink errors} {macOnly nonPortable} {
- list [catch {file readlink _bogus_} msg] [string tolower $msg] \
- [string tolower $errorCode]
-} {1 {could not readlink "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
-test cmdAH-26.5 {Tcl_FileObjCmd: readlink errors} {pcOnly nonPortable} {
- list [catch {file readlink _bogus_} msg] [string tolower $msg] \
- [string tolower $errorCode]
-} {1 {could not readlink "_bogus_": invalid argument} {posix einval {invalid argument}}}
-
-# size
-
-test cmdAH-27.1 {Tcl_FileObjCmd: size} {
- list [catch {file size a b} msg] $msg
-} {1 {wrong # args: should be "file size name"}}
-test cmdAH-27.2 {Tcl_FileObjCmd: size} {
- set oldsize [file size gorp.file]
- set f [open gorp.file a]
- fconfigure $f -translation lf -eofchar {}
- puts $f "More text"
- close $f
- expr {[file size gorp.file] - $oldsize}
-} {10}
-test cmdAH-27.3 {Tcl_FileObjCmd: size} {
- string tolower [list [catch {file size _bogus_} msg] $msg \
- $errorCode]
-} {1 {could not read "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
-
-# stat
-
-catch {testsetplatform $platform}
-makeFile "Test string" gorp.file
-catch {exec chmod 765 gorp.file}
-
-test cmdAH-28.1 {Tcl_FileObjCmd: stat} {
- list [catch {file stat _bogus_} msg] $msg $errorCode
-} {1 {wrong # args: should be "file stat name varName"} NONE}
-test cmdAH-28.2 {Tcl_FileObjCmd: stat} {
- list [catch {file stat _bogus_ a b} msg] $msg $errorCode
-} {1 {wrong # args: should be "file stat name varName"} NONE}
-test cmdAH-28.3 {Tcl_FileObjCmd: stat} {
- catch {unset stat}
- file stat gorp.file stat
- lsort [array names stat]
-} {atime ctime dev gid ino mode mtime nlink size type uid}
-test cmdAH-28.4 {Tcl_FileObjCmd: stat} {
- catch {unset stat}
- file stat gorp.file stat
- list $stat(nlink) $stat(size) $stat(type)
-} {1 12 file}
-test cmdAH-28.5 {Tcl_FileObjCmd: stat} {unixOnly} {
- catch {unset stat}
- file stat gorp.file stat
- expr $stat(mode)&0777
-} {501}
-test cmdAH-28.6 {Tcl_FileObjCmd: stat} {
- string tolower [list [catch {file stat _bogus_ stat} msg] \
- $msg $errorCode]
-} {1 {could not read "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
-test cmdAH-28.7 {Tcl_FileObjCmd: stat} {
- catch {unset x}
- set x 44
- list [catch {file stat gorp.file x} msg] $msg $errorCode
-} {1 {can't set "x(dev)": variable isn't array} NONE}
-test cmdAH-28.8 {Tcl_FileObjCmd: stat} {
- # Sign extension of purported unsigned short to int.
-
- close [open foo.test w]
- file stat foo.test stat
- set x [expr {$stat(mode) > 0}]
- file delete foo.test
- set x
-} 1
-test cmdAH-28.9 {Tcl_FileObjCmd: stat} {pcOnly} {
- # stat of root directory was failing.
- # don't care about answer, just that test runs.
-
- # relative paths that resolve to root
- set old [pwd]
- cd c:/
- file stat c: stat
- file stat c:. stat
- file stat . stat
- cd $old
-
- file stat / stat
- file stat c:/ stat
- file stat c:/. stat
-} {}
-test cmdAH-28.10 {Tcl_FileObjCmd: stat} {pcOnly nonPortable} {
- # stat of root directory was failing.
- # don't care about answer, just that test runs.
-
- file stat //pop/$env(USERNAME) stat
- file stat //pop/$env(USERNAME)/ stat
- file stat //pop/$env(USERNAME)/. stat
-} {}
-test cmdAH-28.11 {Tcl_FileObjCmd: stat} {pcOnly nonPortable} {
- # stat of network directory was returning id of current local drive.
-
- set old [pwd]
- cd c:/
-
- file stat //pop/$env(USERNAME) stat
- cd $old
- expr {$stat(dev) == 2}
-} 0
-test cmdAH-28.12 {Tcl_FileObjCmd: stat} {
- # stat(mode) with S_IFREG flag was returned as a negative number
- # if mode_t was a short instead of an unsigned short.
-
- close [open foo.test w]
- file stat foo.test stat
- file delete foo.test
- expr {$stat(mode) > 0}
-} 1
-catch {unset stat}
-
-# type
-
-file delete link.file
-
-test cmdAH-29.1 {Tcl_FileObjCmd: type} {
- list [catch {file size a b} msg] $msg
-} {1 {wrong # args: should be "file size name"}}
-test cmdAH-29.2 {Tcl_FileObjCmd: type} {
- file type dir.file
-} directory
-test cmdAH-29.3 {Tcl_FileObjCmd: type} {
- file type gorp.file
-} file
-test cmdAH-29.4 {Tcl_FileObjCmd: type} {unixOnly nonPortable} {
- exec ln -s a/b/c link.file
- set result [file type link.file]
- file delete link.file
- set result
-} link
-test cmdAH-29.5 {Tcl_FileObjCmd: type} {
- string tolower [list [catch {file type _bogus_} msg] $msg $errorCode]
-} {1 {could not read "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
-
-# Error conditions
-
-test cmdAH-30.1 {error conditions} {
- list [catch {file gorp x} msg] $msg
-} {1 {bad option "gorp": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
-test cmdAH-30.2 {error conditions} {
- list [catch {file ex x} msg] $msg
-} {1 {ambiguous option "ex": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
-test cmdAH-30.3 {error conditions} {
- list [catch {file is x} msg] $msg
-} {1 {ambiguous option "is": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
-test cmdAH-30.4 {error conditions} {
- list [catch {file z x} msg] $msg
-} {1 {bad option "z": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
-test cmdAH-30.5 {error conditions} {
- list [catch {file read x} msg] $msg
-} {1 {ambiguous option "read": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
-test cmdAH-30.6 {error conditions} {
- list [catch {file s x} msg] $msg
-} {1 {ambiguous option "s": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
-test cmdAH-30.7 {error conditions} {
- list [catch {file t x} msg] $msg
-} {1 {ambiguous option "t": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}
-test cmdAH-30.8 {error conditions} {
- list [catch {file dirname ~woohgy} msg] $msg
-} {1 {user "woohgy" doesn't exist}}
-
-# cleanup
-catch {testsetplatform $platform}
-catch {unset platform}
-
-catch {exec chmod 777 dir.file}
-file delete -force dir.file
-file delete gorp.file
-file delete link.file
-
-cd $cmdAHwd
-
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/cmdIL.test b/tests/cmdIL.test
deleted file mode 100644
index ac39ec0..0000000
--- a/tests/cmdIL.test
+++ /dev/null
@@ -1,325 +0,0 @@
-# This file contains a collection of tests for the procedures in the
-# file tclCmdIL.c. Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-#
-# Copyright (c) 1997 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: cmdIL.test,v 1.6 1999/04/16 00:47:24 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test cmdIL-1.1 {Tcl_LsortObjCmd procedure} {
- list [catch {lsort} msg] $msg
-} {1 {wrong # args: should be "lsort ?options? list"}}
-test cmdIL-1.2 {Tcl_LsortObjCmd procedure} {
- list [catch {lsort -foo {1 3 2 5}} msg] $msg
-} {1 {bad option "-foo": must be -ascii, -command, -decreasing, -dictionary, -increasing, -index, -integer, or -real}}
-test cmdIL-1.3 {Tcl_LsortObjCmd procedure, default options} {
- lsort {d e c b a \{ d35 d300}
-} {a b c d d300 d35 e \{}
-test cmdIL-1.4 {Tcl_LsortObjCmd procedure, -ascii option} {
- lsort -integer -ascii {d e c b a d35 d300}
-} {a b c d d300 d35 e}
-test cmdIL-1.5 {Tcl_LsortObjCmd procedure, -command option} {
- list [catch {lsort -command {1 3 2 5}} msg] $msg
-} {1 {"-command" option must be followed by comparison command}}
-test cmdIL-1.6 {Tcl_LsortObjCmd procedure, -command option} {
- proc cmp {a b} {
- expr {[string match x* $b] - [string match x* $a]}
- }
- lsort -command cmp {x1 abc x2 def x3 x4}
-} {x1 x2 x3 x4 abc def}
-test cmdIL-1.7 {Tcl_LsortObjCmd procedure, -decreasing option} {
- lsort -decreasing {d e c b a d35 d300}
-} {e d35 d300 d c b a}
-test cmdIL-1.8 {Tcl_LsortObjCmd procedure, -dictionary option} {
- lsort -dictionary {d e c b a d35 d300}
-} {a b c d d35 d300 e}
-test cmdIL-1.9 {Tcl_LsortObjCmd procedure, -dictionary option} {
- lsort -dictionary {1k 0k 10k}
-} {0k 1k 10k}
-test cmdIL-1.10 {Tcl_LsortObjCmd procedure, -increasing option} {
- lsort -decreasing -increasing {d e c b a d35 d300}
-} {a b c d d300 d35 e}
-test cmdIL-1.11 {Tcl_LsortObjCmd procedure, -index option} {
- list [catch {lsort -index {1 3 2 5}} msg] $msg
-} {1 {"-index" option must be followed by list index}}
-test cmdIL-1.12 {Tcl_LsortObjCmd procedure, -index option} {
- list [catch {lsort -index foo {1 3 2 5}} msg] $msg
-} {1 {bad index "foo": must be integer or "end"}}
-test cmdIL-1.13 {Tcl_LsortObjCmd procedure, -index option} {
- lsort -index end -integer {{2 25} {10 20 50 100} {3 16 42} 1}
-} {1 {2 25} {3 16 42} {10 20 50 100}}
-test cmdIL-1.14 {Tcl_LsortObjCmd procedure, -index option} {
- lsort -index 1 -integer {{1 25 100} {3 16 42} {10 20 50}}
-} {{3 16 42} {10 20 50} {1 25 100}}
-test cmdIL-1.15 {Tcl_LsortObjCmd procedure, -integer option} {
- lsort -integer {24 6 300 18}
-} {6 18 24 300}
-test cmdIL-1.16 {Tcl_LsortObjCmd procedure, -integer option} {
- list [catch {lsort -integer {1 3 2.4}} msg] $msg
-} {1 {expected integer but got "2.4"}}
-test cmdIL-1.17 {Tcl_LsortObjCmd procedure, -real option} {
- lsort -real {24.2 6e3 150e-1}
-} {150e-1 24.2 6e3}
-test cmdIL-1.18 {Tcl_LsortObjCmd procedure, bogus list} {
- list [catch {lsort "1 2 3 \{ 4"} msg] $msg
-} {1 {unmatched open brace in list}}
-test cmdIL-1.19 {Tcl_LsortObjCmd procedure, empty list} {
- lsort {}
-} {}
-
-# Can't think of any good tests for the MergeSort and MergeLists
-# procedures, except a bunch of random lists to sort.
-
-test cmdIL-2.1 {MergeSort and MergeLists procedures} {
- set result {}
- set r 1435753299
- proc rand {} {
- global r
- set r [expr (16807 * $r) % (0x7fffffff)]
- }
- for {set i 0} {$i < 150} {incr i} {
- set x {}
- for {set j 0} {$j < $i} {incr j} {
- lappend x [expr [rand] & 0xfff]
- }
- set y [lsort -integer $x]
- set old -1
- foreach el $y {
- if {$el < $old} {
- append result "list {$x} sorted to {$y}, element $el out of order\n"
- break
- }
- set old $el
- }
- }
- set result
-} {}
-
-test cmdIL-3.1 {SortCompare procedure, skip comparisons after error} {
- set x 0
- proc cmp {a b} {
- global x
- incr x
- error "error #$x"
- }
- list [catch {lsort -integer -command cmp {48 6 28 190 16 2 3 6 1}} msg] \
- $msg $x
-} {1 {error #1} 1}
-test cmdIL-3.2 {SortCompare procedure, -index option} {
- list [catch {lsort -integer -index 2 "\\\{ {30 40 50}"} msg] $msg
-} {1 {unmatched open brace in list}}
-test cmdIL-3.3 {SortCompare procedure, -index option} {
- list [catch {lsort -integer -index 2 {{20 10} {15 30 40}}} msg] $msg
-} {1 {element 2 missing from sublist "20 10"}}
-test cmdIL-3.4 {SortCompare procedure, -index option} {
- list [catch {lsort -integer -index 2 "{a b c} \\\{"} msg] $msg
-} {1 {unmatched open brace in list}}
-test cmdIL-3.5 {SortCompare procedure, -index option} {
- list [catch {lsort -integer -index 2 {{20 10 13} {15}}} msg] $msg
-} {1 {element 2 missing from sublist "15"}}
-test cmdIL-3.6 {SortCompare procedure, -index option} {
- lsort -integer -index 2 {{1 15 30} {2 5 25} {3 25 20}}
-} {{3 25 20} {2 5 25} {1 15 30}}
-test cmdIL-3.7 {SortCompare procedure, -ascii option} {
- lsort -ascii {d e c b a d35 d300 100 20}
-} {100 20 a b c d d300 d35 e}
-test cmdIL-3.8 {SortCompare procedure, -dictionary option} {
- lsort -dictionary {d e c b a d35 d300 100 20}
-} {20 100 a b c d d35 d300 e}
-test cmdIL-3.9 {SortCompare procedure, -integer option} {
- list [catch {lsort -integer {x 3}} msg] $msg
-} {1 {expected integer but got "x"}}
-test cmdIL-3.10 {SortCompare procedure, -integer option} {
- list [catch {lsort -integer {3 q}} msg] $msg
-} {1 {expected integer but got "q"}}
-test cmdIL-3.11 {SortCompare procedure, -integer option} {
- lsort -integer {35 21 0x20 30 023 100 8}
-} {8 023 21 30 0x20 35 100}
-test cmdIL-3.12 {SortCompare procedure, -real option} {
- list [catch {lsort -real {6...4 3}} msg] $msg
-} {1 {expected floating-point number but got "6...4"}}
-test cmdIL-3.13 {SortCompare procedure, -real option} {
- list [catch {lsort -real {3 1x7}} msg] $msg
-} {1 {expected floating-point number but got "1x7"}}
-test cmdIL-3.14 {SortCompare procedure, -real option} {
- lsort -real {24 2.5e01 16.7 85e-1 10.004}
-} {85e-1 10.004 16.7 24 2.5e01}
-test cmdIL-3.15 {SortCompare procedure, -command option} {
- proc cmp {a b} {
- error "comparison error"
- }
- list [catch {lsort -command cmp {48 6}} msg] $msg $errorInfo
-} {1 {comparison error} {comparison error
- while executing
-"error "comparison error""
- (procedure "cmp" line 2)
- invoked from within
-"cmp 48 6"
- (-compare command)
- invoked from within
-"lsort -command cmp {48 6}"}}
-test cmdIL-3.16 {SortCompare procedure, -command option, long command} {
- proc cmp {dummy a b} {
- string compare $a $b
- }
- lsort -command {cmp {this argument is very very long in order to make the dstring overflow its statically allocated space}} {{this first element is also long in order to help expand the dstring} {the second element, last but not least, is quite long also, in order to make absolutely sure that space is allocated dynamically for the dstring}}
-} {{the second element, last but not least, is quite long also, in order to make absolutely sure that space is allocated dynamically for the dstring} {this first element is also long in order to help expand the dstring}}
-test cmdIL-3.17 {SortCompare procedure, -command option, non-integer result} {
- proc cmp {a b} {
- return foow
- }
- list [catch {lsort -command cmp {48 6}} msg] $msg
-} {1 {-compare command returned non-numeric result}}
-test cmdIL-3.18 {SortCompare procedure, -command option} {
- proc cmp {a b} {
- expr $b - $a
- }
- lsort -command cmp {48 6 18 22 21 35 36}
-} {48 36 35 22 21 18 6}
-test cmdIL-3.19 {SortCompare procedure, -decreasing option} {
- lsort -decreasing -integer {35 21 0x20 30 023 100 8}
-} {100 35 0x20 30 21 023 8}
-
-test cmdIL-4.1 {DictionaryCompare procedure, numerics, leading zeros} {
- lsort -dictionary {a003b a03b}
-} {a03b a003b}
-test cmdIL-4.2 {DictionaryCompare procedure, numerics, leading zeros} {
- lsort -dictionary {a3b a03b}
-} {a3b a03b}
-test cmdIL-4.3 {DictionaryCompare procedure, numerics, leading zeros} {
- lsort -dictionary {a3b A03b}
-} {A03b a3b}
-test cmdIL-4.4 {DictionaryCompare procedure, numerics, leading zeros} {
- lsort -dictionary {a3b a03B}
-} {a3b a03B}
-test cmdIL-4.5 {DictionaryCompare procedure, numerics, leading zeros} {
- lsort -dictionary {00000 000}
-} {000 00000}
-test cmdIL-4.6 {DictionaryCompare procedure, numerics, different lengths} {
- lsort -dictionary {a321b a03210b}
-} {a321b a03210b}
-test cmdIL-4.7 {DictionaryCompare procedure, numerics, different lengths} {
- lsort -dictionary {a03210b a321b}
-} {a321b a03210b}
-test cmdIL-4.8 {DictionaryCompare procedure, numerics} {
- lsort -dictionary {48 6a 18b 22a 21aa 35 36}
-} {6a 18b 21aa 22a 35 36 48}
-test cmdIL-4.9 {DictionaryCompare procedure, numerics} {
- lsort -dictionary {a123x a123b}
-} {a123b a123x}
-test cmdIL-4.10 {DictionaryCompare procedure, numerics} {
- lsort -dictionary {a123b a123x}
-} {a123b a123x}
-test cmdIL-4.11 {DictionaryCompare procedure, numerics} {
- lsort -dictionary {a1b aab}
-} {a1b aab}
-test cmdIL-4.12 {DictionaryCompare procedure, numerics} {
- lsort -dictionary {a1b a!b}
-} {a!b a1b}
-test cmdIL-4.13 {DictionaryCompare procedure, numerics} {
- lsort -dictionary {a1b2c a1b1c}
-} {a1b1c a1b2c}
-test cmdIL-4.14 {DictionaryCompare procedure, numerics} {
- lsort -dictionary {a1b2c a1b3c}
-} {a1b2c a1b3c}
-test cmdIL-4.15 {DictionaryCompare procedure, long numbers} {
- lsort -dictionary {a7654884321988762b a7654884321988761b}
-} {a7654884321988761b a7654884321988762b}
-test cmdIL-4.16 {DictionaryCompare procedure, long numbers} {
- lsort -dictionary {a8765488432198876b a7654884321988761b}
-} {a7654884321988761b a8765488432198876b}
-test cmdIL-4.17 {DictionaryCompare procedure, case} {
- lsort -dictionary {aBCd abcc}
-} {abcc aBCd}
-test cmdIL-4.18 {DictionaryCompare procedure, case} {
- lsort -dictionary {aBCd abce}
-} {aBCd abce}
-test cmdIL-4.19 {DictionaryCompare procedure, case} {
- lsort -dictionary {abcd ABcc}
-} {ABcc abcd}
-test cmdIL-4.20 {DictionaryCompare procedure, case} {
- lsort -dictionary {abcd ABce}
-} {abcd ABce}
-test cmdIL-4.21 {DictionaryCompare procedure, case} {
- lsort -dictionary {abCD ABcd}
-} {ABcd abCD}
-test cmdIL-4.22 {DictionaryCompare procedure, case} {
- lsort -dictionary {ABcd aBCd}
-} {ABcd aBCd}
-test cmdIL-4.23 {DictionaryCompare procedure, case} {
- lsort -dictionary {ABcd AbCd}
-} {ABcd AbCd}
-test cmdIL-4.24 {DictionaryCompare procedure, international characters} {hasIsoLocale} {
- ::tcltest::set_iso8859_1_locale
- set result [lsort -dictionary "a b c A B C \xe3 \xc4"]
- ::tcltest::restore_locale
- set result
-} "A a B b C c \xe3 \xc4"
-test cmdIL-4.25 {DictionaryCompare procedure, international characters} {hasIsoLocale} {
- ::tcltest::set_iso8859_1_locale
- set result [lsort -dictionary "a23\xe3 a23\xc5 a23\xe4"]
- ::tcltest::restore_locale
- set result
-} "a23\xe3 a23\xe4 a23\xc5"
-test cmdIL-4.26 {DefaultCompare procedure, signed characters} {
- set l [lsort [list "abc\200" "abc"]]
- set viewlist {}
- foreach s $l {
- set viewelem ""
- set len [string length $s]
- for {set i 0} {$i < $len} {incr i} {
- set c [string index $s $i]
- scan $c %c d
- if {$d > 0 && $d < 128} {
- append viewelem $c
- } else {
- append viewelem "\\[format %03o $d]"
- }
- }
- lappend viewlist $viewelem
- }
- set viewlist
-} [list "abc" "abc\\200"]
-test cmdIL-4.27 {DictionaryCompare procedure, signed characters} {
- set l [lsort -dictionary [list "abc\200" "abc"]]
- set viewlist {}
- foreach s $l {
- set viewelem ""
- set len [string length $s]
- for {set i 0} {$i < $len} {incr i} {
- set c [string index $s $i]
- scan $c %c d
- if {$d > 0 && $d < 128} {
- append viewelem $c
- } else {
- append viewelem "\\[format %03o $d]"
- }
- }
- lappend viewlist $viewelem
- }
- set viewlist
-} [list "abc" "abc\\200"]
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/cmdInfo.test b/tests/cmdInfo.test
deleted file mode 100644
index ad18e70..0000000
--- a/tests/cmdInfo.test
+++ /dev/null
@@ -1,116 +0,0 @@
-# Commands covered: none
-#
-# This file contains a collection of tests for Tcl_GetCommandInfo,
-# Tcl_SetCommandInfo, Tcl_CreateCommand, Tcl_DeleteCommand, and
-# Tcl_NameOfCommand. Sourcing this file into Tcl runs the tests
-# and generates output for errors. No output means no errors were
-# found.
-#
-# Copyright (c) 1993 The Regents of the University of California.
-# Copyright (c) 1994-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: cmdInfo.test,v 1.3 1999/04/16 00:47:24 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[info commands testcmdinfo] == {}} {
- puts "This application hasn't been compiled with the \"testcmdinfo\""
- puts "command, so I can't test Tcl_GetCommandInfo etc."
- ::tcltest::cleanupTests
- return
-}
-
-test cmdinfo-1.1 {command procedure and clientData} {
- testcmdinfo create x1
- testcmdinfo get x1
-} {CmdProc1 original CmdDelProc1 original :: stringProc}
-test cmdinfo-1.2 {command procedure and clientData} {
- testcmdinfo create x1
- x1
-} {CmdProc1 original}
-test cmdinfo-1.3 {command procedure and clientData} {
- testcmdinfo create x1
- testcmdinfo modify x1
- testcmdinfo get x1
-} {CmdProc2 new_command_data CmdDelProc2 new_delete_data :: stringProc}
-test cmdinfo-1.4 {command procedure and clientData} {
- testcmdinfo create x1
- testcmdinfo modify x1
- x1
-} {CmdProc2 new_command_data}
-
-test cmdinfo-2.1 {command deletion callbacks} {
- testcmdinfo create x1
- testcmdinfo delete x1
-} {CmdDelProc1 original}
-test cmdinfo-2.2 {command deletion callbacks} {
- testcmdinfo create x1
- testcmdinfo modify x1
- testcmdinfo delete x1
-} {CmdDelProc2 new_delete_data}
-
-test cmdinfo-3.1 {Tcl_Get/SetCommandInfo return values} {
- testcmdinfo get non_existent
-} {??}
-test cmdinfo-3.2 {Tcl_Get/SetCommandInfo return values} {
- testcmdinfo create x1
- testcmdinfo modify x1
-} 1
-test cmdinfo-3.3 {Tcl_Get/SetCommandInfo return values} {
- testcmdinfo modify non_existent
-} 0
-
-test cmdinfo-4.1 {Tcl_GetCommandName/Tcl_GetCommandFullName procedures} {
- set x [testcmdtoken create x1]
- rename x1 newName
- set y [testcmdtoken name $x]
- rename newName x1
- eval lappend y [testcmdtoken name $x]
-} {newName ::newName x1 ::x1}
-
-catch {rename newTestCmd {}}
-catch {rename newTestCmd2 {}}
-
-test cmdinfo-5.1 {Names for commands created when inside namespaces} {
- # create namespace cmdInfoNs1
- namespace eval cmdInfoNs1 {} ;# creates namespace cmdInfoNs1
- # create namespace cmdInfoNs1::cmdInfoNs2 and execute a script in it
- set x [namespace eval cmdInfoNs1::cmdInfoNs2 {
- # the following creates a cmd in the global namespace
- testcmdtoken create testCmd
- }]
- set y [testcmdtoken name $x]
- rename ::testCmd newTestCmd
- eval lappend y [testcmdtoken name $x]
-} {testCmd ::testCmd newTestCmd ::newTestCmd}
-
-test cmdinfo-6.1 {Names for commands created when outside namespaces} {
- set x [testcmdtoken create cmdInfoNs1::cmdInfoNs2::testCmd]
- set y [testcmdtoken name $x]
- rename cmdInfoNs1::cmdInfoNs2::testCmd newTestCmd2
- eval lappend y [testcmdtoken name $x]
-} {testCmd ::cmdInfoNs1::cmdInfoNs2::testCmd newTestCmd2 ::newTestCmd2}
-
-# cleanup
-catch {namespace delete cmdInfoNs1::cmdInfoNs2 cmdInfoNs1}
-catch {rename x1 ""}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/cmdMZ.test b/tests/cmdMZ.test
deleted file mode 100644
index 4cd72d2..0000000
--- a/tests/cmdMZ.test
+++ /dev/null
@@ -1,581 +0,0 @@
-# The tests in this file cover the procedures in tclCmdMZ.c.
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: cmdMZ.test,v 1.2 1999/04/16 00:47:24 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Tcl_PwdObjCmd
-
-test cmdMZ-1.1 {Tcl_PwdObjCmd} {
- list [catch {pwd a} msg] $msg
-} {1 {wrong # args: should be "pwd"}}
-test cmdMZ-1.2 {Tcl_PwdObjCmd: simple pwd} {
- catch pwd
-} 0
-test cmdMZ-1.3 {Tcl_PwdObjCmd: simple pwd} {
- expr [string length pwd]>0
-} 1
-test cmdMZ-1.4 {Tcl_PwdObjCmd: failure} {unixOnly} {
- file delete -force foo
- file mkdir foo
- set cwd [pwd]
- cd foo
- file attr . -permissions 000
- set result [list [catch {pwd} msg] $msg]
- cd $cwd
- file delete -force foo
- set result
-} {1 {error getting working directory name: permission denied}}
-
-# The tests for Tcl_RegexpObjCmd, Tcl_RegsubObjCmd are in regexp.test
-
-# Tcl_RenameObjCmd
-
-test cmdMZ-2.1 {Tcl_RenameObjCmd: error conditions} {
- list [catch {rename r1} msg] $msg $errorCode
-} {1 {wrong # args: should be "rename oldName newName"} NONE}
-test cmdMZ-2.2 {Tcl_RenameObjCmd: error conditions} {
- list [catch {rename r1 r2 r3} msg] $msg $errorCode
-} {1 {wrong # args: should be "rename oldName newName"} NONE}
-test cmdMZ-2.3 {Tcl_RenameObjCmd: success} {
- catch {rename r2 {}}
- proc r1 {} {return "r1"}
- rename r1 r2
- r2
-} {r1}
-test cmdMZ-2.4 {Tcl_RenameObjCmd: success} {
- proc r1 {} {return "r1"}
- rename r1 {}
- list [catch {r1} msg] $msg
-} {1 {invalid command name "r1"}}
-
-# The tests for Tcl_ReturnObjCmd are in proc-old.test
-# The tests for Tcl_ScanObjCmd are in scan.test
-
-# Tcl_SourceObjCmd
-
-test cmdMZ-3.1 {Tcl_SourceObjCmd: error conditions} {macOnly} {
- list [catch {source} msg] $msg
-} {1 {wrong # args: should be "source fileName" or "source -rsrc name ?fileName?" or "source -rsrcid id ?fileName?"}}
-test cmdMZ-3.2 {Tcl_SourceObjCmd: error conditions} {macOnly} {
- list [catch {source a b} msg] $msg
-} {1 {wrong # args: should be "source fileName" or "source -rsrc name ?fileName?" or "source -rsrcid id ?fileName?"}}
-test cmdMZ-3.3 {Tcl_SourceObjCmd: error conditions} {unixOrPc} {
- list [catch {source} msg] $msg
-} {1 {wrong # args: should be "source fileName"}}
-test cmdMZ-3.4 {Tcl_SourceObjCmd: error conditions} {unixOrPc} {
- list [catch {source a b} msg] $msg
-} {1 {wrong # args: should be "source fileName"}}
-test cmdMZ-3.5 {Tcl_SourceObjCmd: error in script} {
- makeFile {
- set x 146
- error "error in sourced file"
- set y $x
- } source.file
- list [catch {source source.file} msg] $msg $errorInfo
-} {1 {error in sourced file} {error in sourced file
- while executing
-"error "error in sourced file""
- (file "source.file" line 3)
- invoked from within
-"source source.file"}}
-test cmdMZ-3.6 {Tcl_SourceObjCmd: simple script} {
- makeFile {list result} source.file
- source source.file
-} result
-
-# Tcl_SplitObjCmd
-
-test cmdMZ-4.1 {Tcl_SplitObjCmd: split errors} {
- list [catch split msg] $msg $errorCode
-} {1 {wrong # args: should be "split string ?splitChars?"} NONE}
-test cmdMZ-4.2 {Tcl_SplitObjCmd: split errors} {
- list [catch {split a b c} msg] $msg $errorCode
-} {1 {wrong # args: should be "split string ?splitChars?"} NONE}
-test cmdMZ-4.3 {Tcl_SplitObjCmd: basic split commands} {
- split "a\n b\t\r c\n "
-} {a {} b {} {} c {} {}}
-test cmdMZ-4.4 {Tcl_SplitObjCmd: basic split commands} {
- split "word 1xyzword 2zword 3" xyz
-} {{word 1} {} {} {word 2} {word 3}}
-test cmdMZ-4.5 {Tcl_SplitObjCmd: basic split commands} {
- split "12345" {}
-} {1 2 3 4 5}
-test cmdMZ-4.6 {Tcl_SplitObjCmd: basic split commands} {
- split "a\}b\[c\{\]\$"
-} "a\\}b\\\[c\\{\\\]\\\$"
-test cmdMZ-4.7 {Tcl_SplitObjCmd: basic split commands} {
- split {} {}
-} {}
-test cmdMZ-4.8 {Tcl_SplitObjCmd: basic split commands} {
- split {}
-} {}
-test cmdMZ-4.9 {Tcl_SplitObjCmd: basic split commands} {
- split { }
-} {{} {} {} {}}
-test cmdMZ-4.10 {Tcl_SplitObjCmd: basic split commands} {
- proc foo {} {
- set x {}
- foreach f [split {]\n} {}] {
- append x $f
- }
- return $x
- }
- foo
-} {]\n}
-test cmdMZ-4.11 {Tcl_SplitObjCmd: basic split commands} {
- proc foo {} {
- set x ab\000c
- set y [split $x {}]
- return $y
- }
- foo
-} "a b \000 c"
-test cmdMZ-4.12 {Tcl_SplitObjCmd: basic split commands} {
- split "a0ab1b2bbb3\000c4" ab\000c
-} {{} 0 {} 1 2 {} {} 3 {} 4}
-test cmdMZ-4.13 {Tcl_SplitObjCmd: basic split commands} {
- # if not UTF-8 aware, result is "a {} {} b qw\xe5 {} N wq"
- split "a\u4e4eb qw\u5e4e\x4e wq" " \u4e4e"
-} "a b qw\u5e4eN wq"
-
-# Tcl_StringObjCmd
-
-test cmdMZ-5.1 {Tcl_StringObjCmd: error conditions} {
- list [catch {string} msg] $msg
-} {1 {wrong # args: should be "string option arg ?arg ...?"}}
-test cmdMZ-5.2 {Tcl_StringObjCmd: error conditions} {
- list [catch {string gorp a b} msg] $msg
-} {1 {bad option "gorp": must be compare, first, index, last, length, match, range, tolower, toupper, totitle, trim, trimleft, trimright, wordend, or wordstart}}
-
-test cmdMZ-6.1 {Tcl_StringObjCmd: string compare} {
- list [catch {string compare a} msg] $msg
-} {1 {wrong # args: should be "string compare string1 string2"}}
-test cmdMZ-6.2 {Tcl_StringObjCmd: string compare} {
- list [catch {string compare a b c} msg] $msg
-} {1 {wrong # args: should be "string compare string1 string2"}}
-test cmdMZ-6.3 {Tcl_StringObjCmd: string compare} {
- string compare abcde abdef
-} -1
-test cmdMZ-6.4 {Tcl_StringObjCmd: string compare} {
- string c abcde ABCDE
-} 1
-test cmdMZ-6.5 {Tcl_StringObjCmd: string compare} {
- string compare abcde abcde
-} 0
-test cmdMZ-6.6 {Tcl_StringObjCmd: string compare} {
- string compare ab abcde
-} -1
-test cmdMZ-6.7 {Tcl_StringObjCmd: string compare} {
- string compare abcde ab
-} 1
-test cmdMZ-6.8 {Tcl_StringObjCmd: string compare} {
- string compare cde ab
-} 1
-test cmdMZ-6.9 {Tcl_StringObjCmd: string compare} {
- string compare ab cde
-} -1
-test cmdMZ-6.10 {Tcl_StringObjCmd: string compare, unicode} {
- string compare ab\u7266 ab\u7267
-} -1
-test cmdMZ-6.11 {Tcl_StringObjCmd: string compare, high bit} {
- # This test will fail if the underlying comparaison
- # is using signed chars instead of unsigned chars.
- # (like SunOS's default memcmp thus the compat/memcmp.c)
- string compare "\x80" "@"
- # Nb this tests works also in utf8 space because \x80 is
- # translated into a 2 or more bytes but whose first byte has
- # the high bit set.
-} 1
-
-test cmdMZ-7.1 {Tcl_StringObjCmd: string first} {
- list [catch {string first a} msg] $msg
-} {1 {wrong # args: should be "string first string1 string2"}}
-test cmdMZ-7.2 {Tcl_StringObjCmd: string first} {
- list [catch {string first a b c} msg] $msg
-} {1 {wrong # args: should be "string first string1 string2"}}
-test cmdMZ-7.3 {Tcl_StringObjCmd: string first} {
- string first bq abcdefgbcefgbqrs
-} 12
-test cmdMZ-7.4 {Tcl_StringObjCmd: string first} {
- string fir bcd abcdefgbcefgbqrs
-} 1
-test cmdMZ-7.5 {Tcl_StringObjCmd: string first} {
- string f b abcdefgbcefgbqrs
-} 1
-test cmdMZ-7.6 {Tcl_StringObjCmd: string first} {
- string first xxx x123xx345xxx789xxx012
-} 9
-test cmdMZ-7.7 {Tcl_StringObjCmd: string first} {
- string first "" x123xx345xxx789xxx012
-} -1
-test cmdMZ-7.8 {Tcl_StringObjCmd: string first, unicode} {
- string first x abc\u7266x
-} 4
-test cmdMZ-7.9 {Tcl_StringObjCmd: string first, unicode} {
- string first \u7266 abc\u7266x
-} 3
-
-test cmdMZ-8.1 {Tcl_StringObjCmd: string index} {
- list [catch {string index} msg] $msg
-} {1 {wrong # args: should be "string index string charIndex"}}
-test cmdMZ-8.2 {Tcl_StringObjCmd: string index} {
- list [catch {string index a b c} msg] $msg
-} {1 {wrong # args: should be "string index string charIndex"}}
-test cmdMZ-8.3 {Tcl_StringObjCmd: string index} {
- list [catch {string index a xyz} msg] $msg
-} {1 {expected integer but got "xyz"}}
-test cmdMZ-8.4 {Tcl_StringObjCmd: string index} {
- string index abcde 0
-} a
-test cmdMZ-8.5 {Tcl_StringObjCmd: string index} {
- string i abcde 4
-} e
-test cmdMZ-8.6 {Tcl_StringObjCmd: string index} {
- string index abcde 5
-} {}
-test cmdMZ-8.7 {Tcl_StringObjCmd: string index} {
- list [catch {string index abcde -10} msg] $msg
-} {0 {}}
-test cmdMZ-8.8 {Tcl_StringObjCmd: string index, unicode} {
- string index abc\u7266d 4
-} d
-test cmdMZ-8.9 {Tcl_StringObjCmd: string index, unicode} {
- string index abc\u7266d 3
-} \u7266
-
-test cmdMZ-9.1 {Tcl_StringObjCmd: string last} {
- list [catch {string last a} msg] $msg
-} {1 {wrong # args: should be "string last string1 string2"}}
-test cmdMZ-9.2 {Tcl_StringObjCmd: string last} {
- list [catch {string last a b c} msg] $msg
-} {1 {wrong # args: should be "string last string1 string2"}}
-test cmdMZ-9.3 {Tcl_StringObjCmd: string last} {
- string la xxx xxxx123xx345x678
-} 1
-test cmdMZ-9.4 {Tcl_StringObjCmd: string last} {
- string last xx xxxx123xx345x678
-} 7
-test cmdMZ-9.5 {Tcl_StringObjCmd: string last} {
- string las x xxxx123xx345x678
-} 12
-test cmdMZ-9.6 {Tcl_StringObjCmd: string last, unicode} {
- string las x xxxx12\u7266xx345x678
-} 12
-test cmdMZ-9.7 {Tcl_StringObjCmd: string last, unicode} {
- string las \u7266 xxxx12\u7266xx345x678
-} 6
-
-test cmdMZ-10.1 {Tcl_StringObjCmd: string length} {
- list [catch {string length} msg] $msg
-} {1 {wrong # args: should be "string length string"}}
-test cmdMZ-10.2 {Tcl_StringObjCmd: string length} {
- list [catch {string length a b} msg] $msg
-} {1 {wrong # args: should be "string length string"}}
-test cmdMZ-10.3 {Tcl_StringObjCmd: string length} {
- string length "a little string"
-} 15
-test cmdMZ-10.4 {Tcl_StringObjCmd: string length} {
- string le ""
-} 0
-test cmdMZ-10.5 {Tcl_StringObjCmd: string length, unicode} {
- string le "abcd\u7266"
-} 5
-
-test cmdMZ-11.1 {Tcl_StringObjCmd: string match} {
- list [catch {string match a} msg] $msg
-} {1 {wrong # args: should be "string match pattern string"}}
-test cmdMZ-11.2 {Tcl_StringObjCmd: string match} {
- list [catch {string match a b c} msg] $msg
-} {1 {wrong # args: should be "string match pattern string"}}
-test cmdMZ-11.3 {Tcl_StringObjCmd: string match} {
- string match abc abc
-} 1
-test cmdMZ-11.4 {Tcl_StringObjCmd: string match} {
- string m abc abd
-} 0
-
-test cmdMZ-12.1 {Tcl_StringObjCmd: string range} {
- list [catch {string range} msg] $msg
-} {1 {wrong # args: should be "string range string first last"}}
-test cmdMZ-12.2 {Tcl_StringObjCmd: string range} {
- list [catch {string range a 1} msg] $msg
-} {1 {wrong # args: should be "string range string first last"}}
-test cmdMZ-12.3 {Tcl_StringObjCmd: string range} {
- list [catch {string range a 1 2 3} msg] $msg
-} {1 {wrong # args: should be "string range string first last"}}
-test cmdMZ-12.4 {Tcl_StringObjCmd: string range} {
- list [catch {string range abc abc 1} msg] $msg
-} {1 {bad index "abc": must be integer or "end"}}
-test cmdMZ-12.5 {Tcl_StringObjCmd: string range} {
- list [catch {string range abc 1 eof} msg] $msg
-} {1 {bad index "eof": must be integer or "end"}}
-test cmdMZ-12.6 {Tcl_StringObjCmd: string range, first < 0} {
- string range abcdefghijklmnop -3 2
-} {abc}
-test cmdMZ-12.7 {Tcl_StringObjCmd: string range} {
- string range abcdefghijklmnop 2 14
-} {cdefghijklmno}
-test cmdMZ-12.8 {Tcl_StringObjCmd: string range, last > length} {
- string range abcdefghijklmnop 7 1000
-} {hijklmnop}
-test cmdMZ-12.9 {Tcl_StringObjCmd: string range} {
- string range abcdefghijklmnop 10 e
-} {klmnop}
-test cmdMZ-12.10 {Tcl_StringObjCmd: string range, last < first} {
- string range abcdefghijklmnop 10 9
-} {}
-test cmdMZ-12.11 {Tcl_StringObjCmd: string range} {
- string range abcdefghijklmnop -3 -2
-} {}
-test cmdMZ-12.12 {Tcl_StringObjCmd: string range} {
- string range abcdefghijklmnop 1000 1010
-} {}
-test cmdMZ-12.13 {Tcl_StringObjCmd: string range} {
- string range abcdefghijklmnop -100 end
-} {abcdefghijklmnop}
-test cmdMZ-12.14 {Tcl_StringObjCmd: string range} {
- string range abcdefghijklmnop end end
-} {p}
-test cmdMZ-12.15 {Tcl_StringObjCmd: string range} {
- string range abcdefghijklmnop e 1000
-} {p}
-test cmdMZ-12.16 {Tcl_StringObjCmd: string range, unicode} {
- string range ab\u7266cdefghijklmnop 5 5
-} e
-test cmdMZ-12.17 {Tcl_StringObjCmd: string range, unicode} {
- string range ab\u7266cdefghijklmnop 2 3
-} \u7266c
-
-test cmdMZ-13.1 {Tcl_StringObjCmd: string tolower} {
- list [catch {string tolower} msg] $msg
-} {1 {wrong # args: should be "string tolower string"}}
-test cmdMZ-13.2 {Tcl_StringObjCmd: string tolower} {
- list [catch {string tolower a b} msg] $msg
-} {1 {wrong # args: should be "string tolower string"}}
-test cmdMZ-13.3 {Tcl_StringObjCmd: string tolower} {
- string tolower ABCDeF
-} {abcdef}
-test cmdMZ-13.4 {Tcl_StringObjCmd: string tolower} {
- string tolower "ABC XyZ"
-} {abc xyz}
-test cmdMZ-13.5 {Tcl_StringObjCmd: string tolower} {
- string tolower {123#$&*()}
-} {123#$&*()}
-test cmdMZ-13.6 {Tcl_StringObjCmd: string tolower, unicode} {
- string tolower ABCabc\xc7\xe7
-} "abcabc\xe7\xe7"
-
-test cmdMZ-14.1 {Tcl_StringObjCmd: string toupper} {
- list [catch {string toupper} msg] $msg
-} {1 {wrong # args: should be "string toupper string"}}
-test cmdMZ-14.2 {Tcl_StringObjCmd: string toupper} {
- list [catch {string toupper a b} msg] $msg
-} {1 {wrong # args: should be "string toupper string"}}
-test cmdMZ-14.3 {Tcl_StringObjCmd: string toupper} {
- string toupper abCDEf
-} {ABCDEF}
-test cmdMZ-14.4 {Tcl_StringObjCmd: string toupper} {
- string toupper "abc xYz"
-} {ABC XYZ}
-test cmdMZ-14.5 {Tcl_StringObjCmd: string toupper} {
- string toupper {123#$&*()}
-} {123#$&*()}
-test cmdMZ-14.6 {Tcl_StringObjCmd: string toupper, unicode} {
- string toupper ABCabc\xc7\xe7
-} "ABCABC\xc7\xc7"
-
-test cmdMZ-15.1 {Tcl_StringObjCmd: string totitle} {
- list [catch {string totitle} msg] $msg
-} {1 {wrong # args: should be "string totitle string"}}
-test cmdMZ-15.2 {Tcl_StringObjCmd: string totitle} {
- list [catch {string totitle a b} msg] $msg
-} {1 {wrong # args: should be "string totitle string"}}
-test cmdMZ-15.3 {Tcl_StringObjCmd: string totitle} {
- string totitle abCDEf
-} {Abcdef}
-test cmdMZ-15.4 {Tcl_StringObjCmd: string totitle} {
- string totitle "abc xYz"
-} {Abc xyz}
-test cmdMZ-15.5 {Tcl_StringObjCmd: string totitle} {
- string totitle {123#$&*()}
-} {123#$&*()}
-test cmdMZ-15.6 {Tcl_StringObjCmd: string totitle, unicode} {
- string totitle ABCabc\xc7\xe7
-} "Abcabc\xe7\xe7"
-test cmdMZ-15.7 {Tcl_StringObjCmd: string totitle, unicode} {
- string totitle \u01f3BCabc\xc7\xe7
-} "\u01f2bcabc\xe7\xe7"
-
-test cmdMZ-16.1 {Tcl_StringObjCmd: string trim} {
- list [catch {string trim} msg] $msg
-} {1 {wrong # args: should be "string trim string ?chars?"}}
-test cmdMZ-16.2 {Tcl_StringObjCmd: string trim} {
- list [catch {string trim a b c} msg] $msg
-} {1 {wrong # args: should be "string trim string ?chars?"}}
-test cmdMZ-16.3 {Tcl_StringObjCmd: string trim} {
- string trim " XYZ "
-} {XYZ}
-test cmdMZ-16.4 {Tcl_StringObjCmd: string trim} {
- string trim "\t\nXYZ\t\n\r\n"
-} {XYZ}
-test cmdMZ-16.5 {Tcl_StringObjCmd: string trim} {
- string trim " A XYZ A "
-} {A XYZ A}
-test cmdMZ-16.6 {Tcl_StringObjCmd: string trim} {
- string trim "XXYYZZABC XXYYZZ" ZYX
-} {ABC }
-test cmdMZ-16.7 {Tcl_StringObjCmd: string trim} {
- string trim " \t\r "
-} {}
-test cmdMZ-16.8 {Tcl_StringObjCmd: string trim} {
- string trim {abcdefg} {}
-} {abcdefg}
-test cmdMZ-16.9 {Tcl_StringObjCmd: string trim} {
- string trim {}
-} {}
-test cmdMZ-16.10 {Tcl_StringObjCmd: string trim} {
- string trim ABC DEF
-} {ABC}
-test cmdMZ-16.11 {Tcl_StringObjCmd: string trim, unicode} {
- string trim "\xe7\xe8 AB\xe7C \xe8\xe7" \xe7\xe8
-} " AB\xe7C "
-
-test cmdMZ-17.1 {Tcl_StringObjCmd: string trimleft} {
- string trimleft " XYZ "
-} {XYZ }
-test cmdMZ-17.2 {Tcl_StringObjCmd: string trimleft} {
- list [catch {string trimleft} msg] $msg
-} {1 {wrong # args: should be "string trimleft string ?chars?"}}
-test cmdMZ-17.3 {Tcl_StringObjCmd: string trimleft} {
- string length [string trimleft " "]
-} {0}
-
-test cmdMZ-18.1 {Tcl_StringObjCmd: string trimright} {
- string trimright " XYZ "
-} { XYZ}
-test cmdMZ-18.2 {Tcl_StringObjCmd: string trimright} {
- string trimright " "
-} {}
-test cmdMZ-18.3 {Tcl_StringObjCmd: string trimright} {
- string trimright ""
-} {}
-test cmdMZ-18.4 {Tcl_StringObjCmd: string trimright errors} {
- list [catch {string trimright} msg] $msg
-} {1 {wrong # args: should be "string trimright string ?chars?"}}
-test cmdMZ-18.5 {Tcl_StringObjCmd: string trimright errors} {
- list [catch {string trimg a} msg] $msg
-} {1 {bad option "trimg": must be compare, first, index, last, length, match, range, tolower, toupper, totitle, trim, trimleft, trimright, wordend, or wordstart}}
-
-test cmdMZ-19.1 {Tcl_StringObjCmd: string wordend} {
- list [catch {string wordend a} msg] $msg
-} {1 {wrong # args: should be "string wordend string index"}}
-test cmdMZ-19.2 {Tcl_StringObjCmd: string wordend} {
- list [catch {string wordend a b c} msg] $msg
-} {1 {wrong # args: should be "string wordend string index"}}
-test cmdMZ-19.3 {Tcl_StringObjCmd: string wordend} {
- list [catch {string wordend a gorp} msg] $msg
-} {1 {expected integer but got "gorp"}}
-test cmdMZ-19.4 {Tcl_StringObjCmd: string wordend} {
- string wordend abc. -1
-} 3
-test cmdMZ-19.5 {Tcl_StringObjCmd: string wordend} {
- string wordend abc. 100
-} 4
-test cmdMZ-19.6 {Tcl_StringObjCmd: string wordend} {
- string wordend "word_one two three" 2
-} 8
-test cmdMZ-19.7 {Tcl_StringObjCmd: string wordend} {
- string wordend "one .&# three" 5
-} 6
-test cmdMZ-19.8 {Tcl_StringObjCmd: string wordend} {
- string worde "x.y" 0
-} 1
-test cmdMZ-19.9 {Tcl_StringObjCmd: string wordend, unicode} {
- string wordend "xyz\u00c7de fg" 0
-} 6
-test cmdMZ-19.10 {Tcl_StringObjCmd: string wordend, unicode} {
- string wordend "xyz\uc700de fg" 0
-} 6
-test cmdMZ-19.11 {Tcl_StringObjCmd: string wordend, unicode} {
- string wordend "xyz\u203fde fg" 0
-} 6
-test cmdMZ-19.12 {Tcl_StringObjCmd: string wordend, unicode} {
- string wordend "xyz\u2045de fg" 0
-} 3
-test cmdMZ-19.13 {Tcl_StringObjCmd: string wordend, unicode} {
- string wordend "\uc700\uc700 abc" 8
-} 6
-
-test cmdMZ-20.1 {Tcl_StringObjCmd: string wordstart} {
- list [catch {string word a} msg] $msg
-} {1 {ambiguous option "word": must be compare, first, index, last, length, match, range, tolower, toupper, totitle, trim, trimleft, trimright, wordend, or wordstart}}
-test cmdMZ-20.2 {Tcl_StringObjCmd: string wordstart} {
- list [catch {string wordstart a} msg] $msg
-} {1 {wrong # args: should be "string wordstart string index"}}
-test cmdMZ-20.3 {Tcl_StringObjCmd: string wordstart} {
- list [catch {string wordstart a b c} msg] $msg
-} {1 {wrong # args: should be "string wordstart string index"}}
-test cmdMZ-20.4 {Tcl_StringObjCmd: string wordstart} {
- list [catch {string wordstart a gorp} msg] $msg
-} {1 {expected integer but got "gorp"}}
-test cmdMZ-20.5 {Tcl_StringObjCmd: string wordstart} {
- string wordstart "one two three_words" 400
-} 8
-test cmdMZ-20.6 {Tcl_StringObjCmd: string wordstart} {
- string wordstart "one two three_words" 2
-} 0
-test cmdMZ-20.7 {Tcl_StringObjCmd: string wordstart} {
- string wordstart "one two three_words" -2
-} 0
-test cmdMZ-20.8 {Tcl_StringObjCmd: string wordstart} {
- string wordstart "one .*&^ three" 6
-} 6
-test cmdMZ-20.9 {Tcl_StringObjCmd: string wordstart} {
- string wordstart "one two three" 4
-} 4
-test cmdMZ-20.10 {Tcl_StringObjCmd: string wordstart, unicode} {
- string wordstart "one tw\u00c7o three" 7
-} 4
-test cmdMZ-20.11 {Tcl_StringObjCmd: string wordstart, unicode} {
- string wordstart "ab\uc700\uc700 cdef ghi" 12
-} 10
-test cmdMZ-20.12 {Tcl_StringObjCmd: string wordstart, unicode} {
- string wordstart "\uc700\uc700 abc" 8
-} 3
-
-# The tests for Tcl_SubstObjCmd are in subst.test
-# The tests for Tcl_SwitchObjCmd are in switch.test
-# There are no tests for Tcl_TimeObjCmd
-# The tests for Tcl_TraceObjCmd and TraceVarProc are in trace.test
-# The tests for Tcl_WhileObjCmd are in while.test
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/compExpr-old.test b/tests/compExpr-old.test
deleted file mode 100644
index 5e1fa9a..0000000
--- a/tests/compExpr-old.test
+++ /dev/null
@@ -1,687 +0,0 @@
-# Commands covered: expr
-#
-# This file contains the original set of tests for the compilation (and
-# indirectly execution) of Tcl's expr command. A new set of tests covering
-# the new implementation are in the files "parseExpr.test and
-# "compExpr.test". Sourcing this file into Tcl runs the tests and generates
-# output for errors. No output means no errors were found.
-#
-# Copyright (c) 1996-1997 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: compExpr-old.test,v 1.2 1999/04/16 00:47:24 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {([catch {expr T1()} msg] == 1) && ($msg == {unknown math function "T1"})} {
- set gotT1 0
- puts "This application hasn't been compiled with the \"T1\" and"
- puts "\"T2\" math functions, so I'll skip some of the expr tests."
-} else {
- set gotT1 1
-}
-
-# procedures used below
-
-proc put_hello_char {c} {
- global a
- append a [format %c $c]
- return $c
-}
-proc hello_world {} {
- global a
- set a ""
- set L1 [set l0 [set h_1 [set q 0]]]
- for {put_hello_char [expr [put_hello_char [expr [set h 7]*10+2]]+29]} {$l0?[put_hello_char $l0]
- :!$h_1} {put_hello_char $ll;expr {$L1==2?[set ll [expr 32+0-0+[set bar 0]]]:0}} {expr {[incr L1]==[expr 1+([string length "abc"]-[string length "abc"])]
- ?[set ll [set l0 [expr 54<<1]]]:$ll==108&&$L1<3?
- [incr ll [expr 1|1<<1]; set ll $ll; set ll $ll; set ll $ll; set ll $ll; set l0 [expr ([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])]; set l0; set l0 $l0; set l0; set l0]:$L1==4&&$ll==32?[set ll [expr 19+$h1+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])+[set foo [expr ([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])]]]]
- :[set q [expr $q-$h1+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])]]};expr {$L1==5?[incr ll -8; set ll $ll; set ll]:$q&&$h1&&1};expr {$L1==4+2
- ?[incr ll 3]:[expr ([string length "abc"]-[string length "abc"])+1]};expr {$ll==($h<<4)+2+0&&$L1!=6?[incr ll -6]:[set h1 [expr 100+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])]]}
- expr {$L1!=1<<3?[incr q [expr ([string length "abc"]-[string length "abc"])-1]]:[set h_1 [set ll $h1]]}
- }
- set a
-}
-
-proc 12days {a b c} {
- global xxx
- expr {1<$a?[expr {$a<3?[12days -79 -13 [string range $c [12days -87 \
- [expr 1-$b] [string range $c [12days -86 0 [string range $c 1 end]] \
- end]] end]]:1};expr {$a<$b?[12days [expr $a+1] $b $c]:3};expr {[12days \
- -94 [expr $a-27] $c]&&$a==2?$b<13?[12days 2 [expr $b+1] "%s %d %d\n"]:9
- :16}]:$a<0?$a<-72?[12days $b $a "@n'+,#'/*\{\}w+/w#cdnr/+,\{\}r/*de\}+,/*\{*+,/w\{%+,/w#q#n+,/#\{l+,/n\{n+,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,\}\{w+K w'K:'+\}e#';dq#'l q#'+d'K#!/+k#;q#'r\}eKK#\}w'r\}eKK\{nl\]'/#;#q#n')\{)#\}w')\{)\{nl\]'/+#n';d\}rw' i;# )\{nl\]!/n\{n#'; r\{#w'r nc\{nl\]'/#\{l,+'K \{rw' iK\{;\[\{nl\]'/w#q#n'wk nw' iwk\{KK\{nl\]!/w\{%'l##w#' i; :\{nl\]'/*\{q#'ld;r'\}\{nlwb!/*de\}'c ;;\{nl'-\{\}rw\]'/+,\}##'*\}#nc,',#nw\]'/+kd'+e\}+;#'rdq#w! nr'/ ') \}+\}\{rl#'\{n' ')# \}'+\}##(!!/"]
- :$a<-50?[string compare [format %c $b] [string index $c 0]]==0?[append \
- xxx [string index $c 31];scan [string index $c 31] %c x;set x]
- :[12days -65 $b [string range $c 1 end]]:[12days [expr ([string compare \
- [string index $c 0] "/"]==0)+$a] $b [string range $c 1 end]]:0<$a
- ?[12days 2 2 "%s"]:[string compare [string index $c 0] "/"]==0||
- [12days 0 [12days -61 [scan [string index $c 0] %c x; set x] \
- "!ek;dc i@bK'(q)-\[w\]*%n+r3#l,\{\}:\nuwloca-O;m .vpbks,fxntdCeghiry"] \
- [string range $c 1 end]]}
-}
-proc do_twelve_days {} {
- global xxx
- set xxx ""
- 12days 1 1 1
- string length $xxx
-}
-
-# start of tests
-
-catch {unset a b i x}
-
-test expr-1.1 {TclCompileExprCmd: no expression} {
- list [catch {expr } msg] $msg
-} {1 {wrong # args: should be "expr arg ?arg ...?"}}
-test expr-1.2 {TclCompileExprCmd: one expression word} {
- expr -25
-} -25
-test expr-1.3 {TclCompileExprCmd: two expression words} {
- expr -8.2 -6
-} -14.2
-test expr-1.4 {TclCompileExprCmd: five expression words} {
- expr 20 - 5 +10 -7
-} 18
-test expr-1.5 {TclCompileExprCmd: quoted expression word} {
- expr "0005"
-} 5
-test expr-1.6 {TclCompileExprCmd: quoted expression word} {
- catch {expr "0005"zxy} msg
- set msg
-} {extra characters after close-quote}
-test expr-1.7 {TclCompileExprCmd: expression word in braces} {
- expr {-0005}
-} -5
-test expr-1.8 {TclCompileExprCmd: expression word in braces} {
- expr {{-0x1234}}
-} -4660
-test expr-1.9 {TclCompileExprCmd: expression word in braces} {
- catch {expr {-0005}foo} msg
- set msg
-} {extra characters after close-brace}
-test expr-1.10 {TclCompileExprCmd: other expression word in braces} {
- expr 4*[llength "6 2"]
-} 8
-test expr-1.11 {TclCompileExprCmd: expression word terminated by ;} {
- expr 4*[llength "6 2"];
-} 8
-test expr-1.12 {TclCompileExprCmd: inlined expr (in "catch") inside other catch} {
- set a xxx
- catch {
- # Might not be a number
- set a [expr 10*$a]
- }
-} 1
-test expr-1.13 {TclCompileExprCmd: second level of substitutions in expr not in braces with single var reference} {
- set a xxx
- set x 27; set bool {$x}; if $bool {set a foo}
- set a
-} foo
-test expr-1.14 {TclCompileExprCmd: second level of substitutions in expr with comparison as top-level operator} {
- set a xxx
- set x 2; set b {$x}; set a [expr $b == 2]
- set a
-} 1
-
-test expr-2.1 {TclCompileExpr: are builtin functions registered?} {
- expr double(5*[llength "6 2"])
-} 10.0
-test expr-2.2 {TclCompileExpr: error in expr} {
- catch {expr 2**3} msg
- set msg
-} {syntax error in expression "2**3"}
-test expr-2.3 {TclCompileExpr: junk after legal expr} {
- catch {expr 7*[llength "a b"]foo} msg
- set msg
-} {syntax error in expression "7*2foo"}
-test expr-2.4 {TclCompileExpr: numeric expr string rep == formatted int rep} {
- expr {0001}
-} 1
-
-test expr-3.1 {CompileCondExpr: just lor expr} {expr 3||0} 1
-test expr-3.2 {CompileCondExpr: error in lor expr} {
- catch {expr x||3} msg
- set msg
-} {syntax error in expression "x||3"}
-test expr-3.3 {CompileCondExpr: test true arm} {expr 3>2?44:66} 44
-test expr-3.4 {CompileCondExpr: error compiling true arm} {
- catch {expr 3>2?2**3:66} msg
- set msg
-} {syntax error in expression "3>2?2**3:66"}
-test expr-3.5 {CompileCondExpr: test false arm} {expr 2>3?44:66} 66
-test expr-3.6 {CompileCondExpr: error compiling false arm} {
- catch {expr 2>3?44:2**3} msg
- set msg
-} {syntax error in expression "2>3?44:2**3"}
-test expr-3.7 {CompileCondExpr: long arms & nested cond exprs} {nonPortable} {
- puts "Note: doing test expr-3.7 which can take several minutes to run"
- hello_world
-} {Hello world}
-catch {unset xxx}
-test expr-3.8 {CompileCondExpr: long arms & nested cond exprs} {nonPortable} {
- puts "Note: doing test expr-3.8 which can take several minutes to run"
- do_twelve_days
-} 2358
-catch {unset xxx}
-
-test expr-4.1 {CompileLorExpr: just land expr} {expr 1.3&&3.3} 1
-test expr-4.2 {CompileLorExpr: error in land expr} {
- catch {expr x&&3} msg
- set msg
-} {syntax error in expression "x&&3"}
-test expr-4.3 {CompileLorExpr: simple lor exprs} {expr 0||1.0} 1
-test expr-4.4 {CompileLorExpr: simple lor exprs} {expr 3.0||0.0} 1
-test expr-4.5 {CompileLorExpr: simple lor exprs} {expr 0||0||1} 1
-test expr-4.6 {CompileLorExpr: error compiling lor arm} {
- catch {expr 2**3||4.0} msg
- set msg
-} {syntax error in expression "2**3||4.0"}
-test expr-4.7 {CompileLorExpr: error compiling lor arm} {
- catch {expr 1.3||2**3} msg
- set msg
-} {syntax error in expression "1.3||2**3"}
-test expr-4.8 {CompileLorExpr: error compiling lor arms} {
- list [catch {expr {"a"||"b"}} msg] $msg
-} {1 {expected boolean value but got "a"}}
-test expr-4.9 {CompileLorExpr: long lor arm} {
- set a "abcdefghijkl"
- set i 7
- expr {[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]}
-} 1
-
-test expr-5.1 {CompileLandExpr: just bitor expr} {expr 7|0x13} 23
-test expr-5.2 {CompileLandExpr: error in bitor expr} {
- catch {expr x|3} msg
- set msg
-} {syntax error in expression "x|3"}
-test expr-5.3 {CompileLandExpr: simple land exprs} {expr 0&&1.0} 0
-test expr-5.4 {CompileLandExpr: simple land exprs} {expr 0&&0} 0
-test expr-5.5 {CompileLandExpr: simple land exprs} {expr 3.0&&1.2} 1
-test expr-5.6 {CompileLandExpr: simple land exprs} {expr 1&&1&&2} 1
-test expr-5.7 {CompileLandExpr: error compiling land arm} {
- catch {expr 2**3&&4.0} msg
- set msg
-} {syntax error in expression "2**3&&4.0"}
-test expr-5.8 {CompileLandExpr: error compiling land arm} {
- catch {expr 1.3&&2**3} msg
- set msg
-} {syntax error in expression "1.3&&2**3"}
-test expr-5.9 {CompileLandExpr: error compiling land arm} {
- list [catch {expr {"a"&&"b"}} msg] $msg
-} {1 {expected boolean value but got "a"}}
-test expr-5.10 {CompileLandExpr: long land arms} {
- set a "abcdefghijkl"
- set i 7
- expr {[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]] && [string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]] && [string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]] && [string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]}
-} 1
-
-test expr-6.1 {CompileBitXorExpr: just bitand expr} {expr 7&0x13} 3
-test expr-6.2 {CompileBitXorExpr: error in bitand expr} {
- catch {expr x|3} msg
- set msg
-} {syntax error in expression "x|3"}
-test expr-6.3 {CompileBitXorExpr: simple bitxor exprs} {expr 7^0x13} 20
-test expr-6.4 {CompileBitXorExpr: simple bitxor exprs} {expr 3^0x10} 19
-test expr-6.5 {CompileBitXorExpr: simple bitxor exprs} {expr 0^7} 7
-test expr-6.6 {CompileBitXorExpr: simple bitxor exprs} {expr -1^7} -8
-test expr-6.7 {CompileBitXorExpr: error compiling bitxor arm} {
- catch {expr 2**3|6} msg
- set msg
-} {syntax error in expression "2**3|6"}
-test expr-6.8 {CompileBitXorExpr: error compiling bitxor arm} {
- catch {expr 2^x} msg
- set msg
-} {syntax error in expression "2^x"}
-test expr-6.9 {CompileBitXorExpr: runtime error in bitxor arm} {
- list [catch {expr {24.0^3}} msg] $msg
-} {1 {can't use floating-point value as operand of "^"}}
-test expr-6.10 {CompileBitXorExpr: runtime error in bitxor arm} {
- list [catch {expr {"a"^"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "^"}}
-
-test expr-7.1 {CompileBitAndExpr: just equality expr} {expr 3==2} 0
-test expr-7.2 {CompileBitAndExpr: just equality expr} {expr 2.0==2} 1
-test expr-7.3 {CompileBitAndExpr: just equality expr} {expr 3.2!=2.2} 1
-test expr-7.4 {CompileBitAndExpr: just equality expr} {expr {"abc" == "abd"}} 0
-test expr-7.5 {CompileBitAndExpr: error in equality expr} {
- catch {expr x==3} msg
- set msg
-} {syntax error in expression "x==3"}
-test expr-7.6 {CompileBitAndExpr: simple bitand exprs} {expr 7&0x13} 3
-test expr-7.7 {CompileBitAndExpr: simple bitand exprs} {expr 0xf2&0x53} 82
-test expr-7.8 {CompileBitAndExpr: simple bitand exprs} {expr 3&6} 2
-test expr-7.9 {CompileBitAndExpr: simple bitand exprs} {expr -1&-7} -7
-test expr-7.10 {CompileBitAndExpr: error compiling bitand arm} {
- catch {expr 2**3&6} msg
- set msg
-} {syntax error in expression "2**3&6"}
-test expr-7.11 {CompileBitAndExpr: error compiling bitand arm} {
- catch {expr 2&x} msg
- set msg
-} {syntax error in expression "2&x"}
-test expr-7.12 {CompileBitAndExpr: runtime error in bitand arm} {
- list [catch {expr {24.0&3}} msg] $msg
-} {1 {can't use floating-point value as operand of "&"}}
-test expr-7.13 {CompileBitAndExpr: runtime error in bitand arm} {
- list [catch {expr {"a"&"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "&"}}
-
-test expr-8.1 {CompileEqualityExpr: just relational expr} {expr 3>=2} 1
-test expr-8.2 {CompileEqualityExpr: just relational expr} {expr 2<=2.1} 1
-test expr-8.3 {CompileEqualityExpr: just relational expr} {expr 3.2>"2.2"} 1
-test expr-8.4 {CompileEqualityExpr: just relational expr} {expr {"0y"<"0x12"}} 0
-test expr-8.5 {CompileEqualityExpr: error in relational expr} {
- catch {expr x>3} msg
- set msg
-} {syntax error in expression "x>3"}
-test expr-8.6 {CompileEqualityExpr: simple equality exprs} {expr 7==0x13} 0
-test expr-8.7 {CompileEqualityExpr: simple equality exprs} {expr -0xf2!=0x53} 1
-test expr-8.8 {CompileEqualityExpr: simple equality exprs} {expr {"12398712938788234-1298379" != ""}} 1
-test expr-8.9 {CompileEqualityExpr: simple equality exprs} {expr -1!="abc"} 1
-test expr-8.10 {CompileEqualityExpr: error compiling equality arm} {
- catch {expr 2**3==6} msg
- set msg
-} {syntax error in expression "2**3==6"}
-test expr-8.11 {CompileEqualityExpr: error compiling equality arm} {
- catch {expr 2!=x} msg
- set msg
-} {syntax error in expression "2!=x"}
-
-
-test expr-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12
-test expr-9.2 {CompileRelationalExpr: just shift expr} {expr 0xff>>2} 63
-test expr-9.3 {CompileRelationalExpr: just shift expr} {expr -1>>2} -1
-test expr-9.4 {CompileRelationalExpr: just shift expr} {expr {1<<3}} 8
-
-# The following test is different for 32-bit versus 64-bit
-# architectures because LONG_MIN is different
-
-if {0x80000000 > 0} {
- test expr-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} {
- expr {1<<63}
- } -9223372036854775808
-} else {
- test expr-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} {
- expr {1<<31}
- } -2147483648
-}
-test expr-9.6 {CompileRelationalExpr: error in shift expr} {
- catch {expr x>>3} msg
- set msg
-} {syntax error in expression "x>>3"}
-test expr-9.7 {CompileRelationalExpr: simple relational exprs} {expr 0xff>=+0x3} 1
-test expr-9.8 {CompileRelationalExpr: simple relational exprs} {expr -0xf2<0x3} 1
-test expr-9.9 {CompileRelationalExpr: error compiling relational arm} {
- catch {expr 2**3>6} msg
- set msg
-} {syntax error in expression "2**3>6"}
-test expr-9.10 {CompileRelationalExpr: error compiling relational arm} {
- catch {expr 2<x} msg
- set msg
-} {syntax error in expression "2<x"}
-
-test expr-10.1 {CompileShiftExpr: just add expr} {expr 4+-2} 2
-test expr-10.2 {CompileShiftExpr: just add expr} {expr 0xff-2} 253
-test expr-10.3 {CompileShiftExpr: just add expr} {expr -1--2} 1
-test expr-10.4 {CompileShiftExpr: just add expr} {expr 1-0123} -82
-test expr-10.5 {CompileShiftExpr: error in add expr} {
- catch {expr x+3} msg
- set msg
-} {syntax error in expression "x+3"}
-test expr-10.6 {CompileShiftExpr: simple shift exprs} {expr 0xff>>0x3} 31
-test expr-10.7 {CompileShiftExpr: simple shift exprs} {expr -0xf2<<0x3} -1936
-test expr-10.8 {CompileShiftExpr: error compiling shift arm} {
- catch {expr 2**3>>6} msg
- set msg
-} {syntax error in expression "2**3>>6"}
-test expr-10.9 {CompileShiftExpr: error compiling shift arm} {
- catch {expr 2<<x} msg
- set msg
-} {syntax error in expression "2<<x"}
-test expr-10.10 {CompileShiftExpr: runtime error} {
- list [catch {expr {24.0>>43}} msg] $msg
-} {1 {can't use floating-point value as operand of ">>"}}
-test expr-10.11 {CompileShiftExpr: runtime error} {
- list [catch {expr {"a"<<"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "<<"}}
-
-test expr-11.1 {CompileAddExpr: just multiply expr} {expr 4*-2} -8
-test expr-11.2 {CompileAddExpr: just multiply expr} {expr 0xff%2} 1
-test expr-11.3 {CompileAddExpr: just multiply expr} {expr -1/2} -1
-test expr-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0123} 6
-test expr-11.5 {CompileAddExpr: error in multiply expr} {
- catch {expr x*3} msg
- set msg
-} {syntax error in expression "x*3"}
-test expr-11.6 {CompileAddExpr: simple add exprs} {expr 0xff++0x3} 258
-test expr-11.7 {CompileAddExpr: simple add exprs} {expr -0xf2--0x3} -239
-test expr-11.8 {CompileAddExpr: error compiling add arm} {
- catch {expr 2**3+6} msg
- set msg
-} {syntax error in expression "2**3+6"}
-test expr-11.9 {CompileAddExpr: error compiling add arm} {
- catch {expr 2-x} msg
- set msg
-} {syntax error in expression "2-x"}
-test expr-11.10 {CompileAddExpr: runtime error} {
- list [catch {expr {24.0+"xx"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "+"}}
-test expr-11.11 {CompileAddExpr: runtime error} {
- list [catch {expr {"a"-"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "-"}}
-test expr-11.12 {CompileAddExpr: runtime error} {
- list [catch {expr {3/0}} msg] $msg
-} {1 {divide by zero}}
-test expr-11.13 {CompileAddExpr: runtime error} {
- list [catch {expr {2.3/0.0}} msg] $msg
-} {1 {divide by zero}}
-
-test expr-12.1 {CompileMultiplyExpr: just unary expr} {expr ~4} -5
-test expr-12.2 {CompileMultiplyExpr: just unary expr} {expr --5} 5
-test expr-12.3 {CompileMultiplyExpr: just unary expr} {expr !27} 0
-test expr-12.4 {CompileMultiplyExpr: just unary expr} {expr ~0xff00ff} -16711936
-test expr-12.5 {CompileMultiplyExpr: error in unary expr} {
- catch {expr ~x} msg
- set msg
-} {syntax error in expression "~x"}
-test expr-12.6 {CompileMultiplyExpr: simple multiply exprs} {expr 0xff*0x3} 765
-test expr-12.7 {CompileMultiplyExpr: simple multiply exprs} {expr -0xf2%-0x3} -2
-test expr-12.8 {CompileMultiplyExpr: error compiling multiply arm} {
- catch {expr 2*3%%6} msg
- set msg
-} {syntax error in expression "2*3%%6"}
-test expr-12.9 {CompileMultiplyExpr: error compiling multiply arm} {
- catch {expr 2*x} msg
- set msg
-} {syntax error in expression "2*x"}
-test expr-12.10 {CompileMultiplyExpr: runtime error} {
- list [catch {expr {24.0*"xx"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "*"}}
-test expr-12.11 {CompileMultiplyExpr: runtime error} {
- list [catch {expr {"a"/"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "/"}}
-
-test expr-13.1 {CompileUnaryExpr: unary exprs} {expr -0xff} -255
-test expr-13.2 {CompileUnaryExpr: unary exprs} {expr +000123} 83
-test expr-13.3 {CompileUnaryExpr: unary exprs} {expr +--++36} 36
-test expr-13.4 {CompileUnaryExpr: unary exprs} {expr !2} 0
-test expr-13.5 {CompileUnaryExpr: unary exprs} {expr +--+-62.0} -62.0
-test expr-13.6 {CompileUnaryExpr: unary exprs} {expr !0.0} 1
-test expr-13.7 {CompileUnaryExpr: unary exprs} {expr !0xef} 0
-test expr-13.8 {CompileUnaryExpr: error compiling unary expr} {
- catch {expr ~x} msg
- set msg
-} {syntax error in expression "~x"}
-test expr-13.9 {CompileUnaryExpr: error compiling unary expr} {
- catch {expr !1.x} msg
- set msg
-} {syntax error in expression "!1.x"}
-test expr-13.10 {CompileUnaryExpr: runtime error} {
- list [catch {expr {~"xx"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "~"}}
-test expr-13.11 {CompileUnaryExpr: runtime error} {
- list [catch {expr ~4.0} msg] $msg
-} {1 {can't use floating-point value as operand of "~"}}
-test expr-13.12 {CompileUnaryExpr: just primary expr} {expr 0x123} 291
-test expr-13.13 {CompileUnaryExpr: just primary expr} {
- set a 27
- expr $a
-} 27
-test expr-13.14 {CompileUnaryExpr: just primary expr} {
- expr double(27)
-} 27.0
-test expr-13.15 {CompileUnaryExpr: just primary expr} {expr "123"} 123
-test expr-13.16 {CompileUnaryExpr: error in primary expr} {
- catch {expr [set]} msg
- set msg
-} {wrong # args: should be "set varName ?newValue?"}
-test expr-14.1 {CompilePrimaryExpr: literal primary} {expr 1} 1
-test expr-14.2 {CompilePrimaryExpr: literal primary} {expr 123} 123
-test expr-14.3 {CompilePrimaryExpr: literal primary} {expr 0xff} 255
-test expr-14.4 {CompilePrimaryExpr: literal primary} {expr 00010} 8
-test expr-14.5 {CompilePrimaryExpr: literal primary} {expr 62.0} 62.0
-test expr-14.6 {CompilePrimaryExpr: literal primary} {
- expr 3.1400000
-} 3.14
-test expr-14.7 {CompilePrimaryExpr: literal primary} {expr {{abcde}<{abcdef}}} 1
-test expr-14.8 {CompilePrimaryExpr: literal primary} {expr {{abc\
-def} < {abcdef}}} 1
-test expr-14.9 {CompilePrimaryExpr: literal primary} {expr {{abc\tde} > {abc\tdef}}} 0
-test expr-14.10 {CompilePrimaryExpr: literal primary} {expr {{123}}} 123
-test expr-14.11 {CompilePrimaryExpr: var reference primary} {
- set i 789
- list [expr {$i}] [expr $i]
-} {789 789}
-test expr-14.12 {CompilePrimaryExpr: var reference primary} {
- set i {789} ;# test expr's aggressive conversion to numeric semantics
- list [expr {$i}] [expr $i]
-} {789 789}
-test expr-14.13 {CompilePrimaryExpr: var reference primary} {
- catch {unset a}
- set a(foo) foo
- set a(bar) bar
- set a(123) 123
- set result ""
- lappend result [expr $a(123)] [expr {$a(bar)<$a(foo)}]
- catch {unset a}
- set result
-} {123 1}
-test expr-14.14 {CompilePrimaryExpr: var reference primary} {
- set i 123 ;# test "$var.0" floating point conversion hack
- list [expr $i] [expr $i.0] [expr $i.0/12.0]
-} {123 123.0 10.25}
-test expr-14.15 {CompilePrimaryExpr: var reference primary} {
- set i 123
- catch {expr $i.2} msg
- set msg
-} 123.2
-test expr-14.16 {CompilePrimaryExpr: error compiling var reference primary} {
- catch {expr {$a(foo}} msg
- set errorInfo
-} {missing )
- while compiling
-"expr {$a(foo}"}
-test expr-14.17 {CompilePrimaryExpr: string primary that looks like var ref} {
- expr $
-} $
-test expr-14.18 {CompilePrimaryExpr: quoted string primary} {
- expr "21"
-} 21
-test expr-14.19 {CompilePrimaryExpr: quoted string primary} {
- set i 123
- set x 456
- expr "$i+$x"
-} 579
-test expr-14.20 {CompilePrimaryExpr: quoted string primary} {
- set i 3
- set x 6
- expr 2+"$i.$x"
-} 5.6
-test expr-14.21 {CompilePrimaryExpr: error in quoted string primary} {
- catch {expr "[set]"} msg
- set msg
-} {wrong # args: should be "set varName ?newValue?"}
-test expr-14.22 {CompilePrimaryExpr: subcommand primary} {
- expr {[set i 123; set i]}
-} 123
-test expr-14.23 {CompilePrimaryExpr: error in subcommand primary} {
- catch {expr {[set]}} msg
- set errorInfo
-} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- while compiling
-"expr {[set]}"}
-test expr-14.24 {CompilePrimaryExpr: error in subcommand primary} {
- catch {expr {[set i}} msg
- set errorInfo
-} {missing close-bracket
- while compiling
-"expr {[set i}"}
-test expr-14.25 {CompilePrimaryExpr: math function primary} {
- format %.6g [expr exp(1.0)]
-} 2.71828
-test expr-14.26 {CompilePrimaryExpr: math function primary} {
- format %.6g [expr pow(2.0+0.1,3.0+0.1)]
-} 9.97424
-test expr-14.27 {CompilePrimaryExpr: error in math function primary} {
- catch {expr sinh::(2.0)} msg
- set errorInfo
-} {syntax error in expression "sinh::(2.0)"
- while compiling
-"expr sinh::(2.0)"}
-test expr-14.28 {CompilePrimaryExpr: subexpression primary} {
- expr 2+(3*4)
-} 14
-test expr-14.29 {CompilePrimaryExpr: error in subexpression primary} {
- catch {expr 2+(3*[set])} msg
- set errorInfo
-} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- while compiling
-"expr 2+(3*[set])"}
-test expr-14.30 {CompilePrimaryExpr: missing paren in subexpression primary} {
- catch {expr 2+(3*(4+5)} msg
- set errorInfo
-} {syntax error in expression "2+(3*(4+5)"
- while compiling
-"expr 2+(3*(4+5)"}
-test expr-14.31 {CompilePrimaryExpr: just var ref in subexpression primary} {
- set i "5+10"
- list "[expr $i] == 15" "[expr ($i)] == 15" "[eval expr ($i)] == 15"
-} {{15 == 15} {15 == 15} {15 == 15}}
-test expr-14.32 {CompilePrimaryExpr: unexpected token} {
- catch {expr @} msg
- set errorInfo
-} {syntax error in expression "@"
- while compiling
-"expr @"}
-
-test expr-15.1 {CompileMathFuncCall: missing parenthesis} {
- catch {expr sinh2.0)} msg
- set errorInfo
-} {syntax error in expression "sinh2.0)"
- while compiling
-"expr sinh2.0)"}
-test expr-15.2 {CompileMathFuncCall: unknown math function} {
- catch {expr whazzathuh(1)} msg
- set errorInfo
-} {unknown math function "whazzathuh"
- while compiling
-"expr whazzathuh(1)"}
-test expr-15.3 {CompileMathFuncCall: too many arguments} {
- catch {expr sin(1,2,3)} msg
- set errorInfo
-} {too many arguments for math function
- while compiling
-"expr sin(1,2,3)"}
-test expr-15.4 {CompileMathFuncCall: ')' found before last required arg} {
- catch {expr sin()} msg
- set errorInfo
-} {too few arguments for math function
- while compiling
-"expr sin()"}
-test expr-15.5 {CompileMathFuncCall: too few arguments} {
- catch {expr pow(1)} msg
- set errorInfo
-} {too few arguments for math function
- while compiling
-"expr pow(1)"}
-test expr-15.6 {CompileMathFuncCall: missing ')'} {
- catch {expr sin(1} msg
- set errorInfo
-} {syntax error in expression "sin(1"
- while compiling
-"expr sin(1"}
-if $gotT1 {
- test expr-15.7 {CompileMathFuncCall: call registered math function} {
- expr 2*T1()
- } 246
- test expr-15.8 {CompileMathFuncCall: call registered math function} {
- expr T2()*3
- } 1035
-
- test expr-15.9 {CompileMathFuncCall: call registered math function} {
- expr T3(21, 37)
- } 37
- test expr-15.10 {CompileMathFuncCall: call registered math function} {
- expr T3(21.2, 37)
- } 37.0
- test expr-15.11 {CompileMathFuncCall: call registered math function} {
- expr T3(-21.2, -17.5)
- } -17.5
-}
-
-test expr-16.1 {GetToken: checks whether integer token starting with "0x" (e.g., "0x$") is invalid} {
- catch {unset a}
- set a(VALUE) ff15
- set i 123
- if {[expr 0x$a(VALUE)] & 16} {
- set i {}
- }
- set i
-} {}
-test expr-16.2 {GetToken: check for string literal in braces} {
- expr {{1}}
-} {1}
-
-# Check "expr" and computed command names.
-
-test expr-17.1 {expr and computed command names} {
- set i 0
- set z expr
- $z 1+2
-} 3
-
-# Check correct conversion of operands to numbers: If the string looks like
-# an integer, convert to integer. Otherwise, if the string looks like a
-# double, convert to double.
-
-test expr-18.1 {expr and conversion of operands to numbers} {
- set x [lindex 11 0]
- catch {expr int($x)}
- expr {$x}
-} 11
-
-# Check "expr" and interpreter result object resetting before appending
-# an error msg during evaluation of exprs not in {}s
-
-test expr-19.1 {expr and interpreter result object resetting} {
- proc p {} {
- set t 10.0
- set x 2.0
- set dx 0.2
- set f {$dx-$x/10}
- set g {-$x/5}
- set center 1.0
- set x [expr $x-$center]
- set dx [expr $dx+$g]
- set x [expr $x+$f+$center]
- set x [expr $x+$f+$center]
- set y [expr round($x)]
- }
- p
-} 3
-
-# cleanup
-unset a
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/compExpr.test b/tests/compExpr.test
deleted file mode 100644
index 17728b9..0000000
--- a/tests/compExpr.test
+++ /dev/null
@@ -1,340 +0,0 @@
-# This file contains a collection of tests for the procedures in the
-# file tclCompExpr.c. Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-#
-# Copyright (c) 1997 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: compExpr.test,v 1.2 1999/04/16 00:47:25 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {([catch {expr T1()} msg] == 1) && ($msg == {unknown math function "T1"})} {
- set gotT1 0
- puts "This application hasn't been compiled with the \"T1\" and"
- puts "\"T2\" math functions, so I'll skip some of the expr tests."
-} else {
- set gotT1 1
-}
-
-catch {unset a}
-
-test compExpr-1.1 {TclCompileExpr procedure, successful expr parse and compile} {
- expr 1+2
-} 3
-test compExpr-1.2 {TclCompileExpr procedure, error parsing expr} {
- list [catch {expr 1+2+} msg] $msg
-} {1 {syntax error in expression "1+2+"}}
-test compExpr-1.3 {TclCompileExpr procedure, error compiling expr} {
- list [catch {expr "foo(123)"} msg] $msg
-} {1 {unknown math function "foo"}}
-test compExpr-1.4 {TclCompileExpr procedure, expr has no operators} {
- set a {000123}
- expr {$a}
-} 83
-
-test compExpr-2.1 {CompileSubExpr procedure, TCL_TOKEN_WORD parse token} {
- catch {unset a}
- set a 27
- expr {"foo$a" < "bar"}
-} 0
-test compExpr-2.2 {CompileSubExpr procedure, error compiling TCL_TOKEN_WORD parse token} {
- list [catch {expr {"00[expr 1+]" + 17}} msg] $msg
-} {1 {syntax error in expression "1+"}}
-test compExpr-2.3 {CompileSubExpr procedure, TCL_TOKEN_TEXT parse token} {
- expr {{12345}}
-} 12345
-test compExpr-2.4 {CompileSubExpr procedure, empty TCL_TOKEN_TEXT parse token} {
- expr {{}}
-} {}
-test compExpr-2.5 {CompileSubExpr procedure, TCL_TOKEN_BS parse token} {
- expr "\{ \\
- +123 \}"
-} 123
-test compExpr-2.6 {CompileSubExpr procedure, TCL_TOKEN_COMMAND parse token} {
- expr {[info tclversion] != ""}
-} 1
-test compExpr-2.7 {CompileSubExpr procedure, TCL_TOKEN_COMMAND parse token} {
- expr {[]}
-} {}
-test compExpr-2.8 {CompileSubExpr procedure, error in TCL_TOKEN_COMMAND parse token} {
- list [catch {expr {[foo "bar"xxx] + 17}} msg] $msg
-} {1 {extra characters after close-quote}}
-test compExpr-2.9 {CompileSubExpr procedure, TCL_TOKEN_VARIABLE parse token} {
- catch {unset a}
- set a 123
- expr {$a*2}
-} 246
-test compExpr-2.10 {CompileSubExpr procedure, TCL_TOKEN_VARIABLE parse token} {
- catch {unset a}
- catch {unset b}
- set a(george) martha
- set b geo
- expr {$a(${b}rge)}
-} martha
-test compExpr-2.11 {CompileSubExpr procedure, error in TCL_TOKEN_VARIABLE parse token} {
- catch {unset a}
- list [catch {expr {$a + 17}} msg] $msg
-} {1 {can't read "a": no such variable}}
-test compExpr-2.12 {CompileSubExpr procedure, TCL_TOKEN_SUB_EXPR parse token} {
- expr {27||3? 3<<(1+4) : 4&&9}
-} 96
-test compExpr-2.13 {CompileSubExpr procedure, error in TCL_TOKEN_SUB_EXPR parse token} {
- catch {unset a}
- set a 15
- list [catch {expr {27 || "$a[expr 1+]00"}} msg] $msg
-} {1 {syntax error in expression "1+"}}
-test compExpr-2.14 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, op found} {
- expr {5*6}
-} 30
-test compExpr-2.15 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, math function found} {
- format %.6g [expr {sin(2.0)}]
-} 0.909297
-test compExpr-2.16 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, math function not found} {
- list [catch {expr {fred(2.0)}} msg] $msg
-} {1 {unknown math function "fred"}}
-test compExpr-2.17 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator} {
- expr {4*2}
-} 8
-test compExpr-2.18 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator} {
- expr {4/2}
-} 2
-test compExpr-2.19 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator} {
- expr {4%2}
-} 0
-test compExpr-2.20 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator} {
- expr {4<<2}
-} 16
-test compExpr-2.21 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator} {
- expr {4>>2}
-} 1
-test compExpr-2.22 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator} {
- expr {4<2}
-} 0
-test compExpr-2.23 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator} {
- expr {4>2}
-} 1
-test compExpr-2.24 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator} {
- expr {4<=2}
-} 0
-test compExpr-2.25 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator} {
- expr {4>=2}
-} 1
-test compExpr-2.26 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator} {
- expr {4==2}
-} 0
-test compExpr-2.27 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator} {
- expr {4!=2}
-} 1
-test compExpr-2.28 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator} {
- expr {4&2}
-} 0
-test compExpr-2.29 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator} {
- expr {4^2}
-} 6
-test compExpr-2.30 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator} {
- expr {4|2}
-} 6
-test compExpr-2.31 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator, 1 operand} {
- expr {!4}
-} 0
-test compExpr-2.32 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator, 1 operand} {
- expr {~4}
-} -5
-test compExpr-2.33 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, normal operator, comparison} {
- catch {unset a}
- set a 15
- expr {$a==15} ;# compiled out-of-line to runtime call on Tcl_ExprObjCmd
-} 1
-test compExpr-2.34 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, special operator} {
- expr {+2}
-} 2
-test compExpr-2.35 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, error in special operator} {
- list [catch {expr {+[expr 1+]}} msg] $msg
-} {1 {syntax error in expression "1+"}}
-test compExpr-2.36 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, special operator} {
- expr {4+2}
-} 6
-test compExpr-2.37 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, error in special operator} {
- list [catch {expr {[expr 1+]+5}} msg] $msg
-} {1 {syntax error in expression "1+"}}
-test compExpr-2.38 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, error in special operator} {
- list [catch {expr {5+[expr 1+]}} msg] $msg
-} {1 {syntax error in expression "1+"}}
-test compExpr-2.39 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, special operator} {
- expr {-2}
-} -2
-test compExpr-2.40 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, special operator} {
- expr {4-2}
-} 2
-test compExpr-2.41 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, special operator} {
- catch {unset a}
- set a true
- expr {0||$a}
-} 1
-test compExpr-2.42 {CompileSubExpr procedure, error in TCL_TOKEN_SUB_EXPR parse token} {
- catch {unset a}
- set a 15
- list [catch {expr {27 || "$a[expr 1+]00"}} msg] $msg
-} {1 {syntax error in expression "1+"}}
-test compExpr-2.43 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, special operator} {
- catch {unset a}
- set a false
- expr {3&&$a}
-} 0
-test compExpr-2.44 {CompileSubExpr procedure, TCL_TOKEN_OPERATOR token, special operator} {
- catch {unset a}
- set a false
- expr {$a||1? 1 : 0}
-} 1
-test compExpr-2.45 {CompileSubExpr procedure, error in TCL_TOKEN_SUB_EXPR parse token} {
- catch {unset a}
- set a 15
- list [catch {expr {1? 54 : "$a[expr 1+]00"}} msg] $msg
-} {1 {syntax error in expression "1+"}}
-
-test compExpr-3.1 {CompileLandOrLorExpr procedure, numeric 1st operand} {
- catch {unset a}
- set a 2
- expr {[set a]||0}
-} 1
-test compExpr-3.2 {CompileLandOrLorExpr procedure, nonnumeric 1st operand} {
- catch {unset a}
- set a no
- expr {$a&&1}
-} 0
-test compExpr-3.3 {CompileSubExpr procedure, error in 1st operand} {
- list [catch {expr {[expr *2]||0}} msg] $msg
-} {1 {syntax error in expression "*2"}}
-test compExpr-3.4 {CompileLandOrLorExpr procedure, result is 1 or 0} {
- catch {unset a}
- catch {unset b}
- set a no
- set b true
- expr {$a || $b}
-} 1
-test compExpr-3.5 {CompileLandOrLorExpr procedure, short-circuit semantics} {
- catch {unset a}
- set a yes
- expr {$a || [exit]}
-} 1
-test compExpr-3.6 {CompileLandOrLorExpr procedure, short-circuit semantics} {
- catch {unset a}
- set a no
- expr {$a && [exit]}
-} 0
-test compExpr-3.7 {CompileLandOrLorExpr procedure, numeric 2nd operand} {
- catch {unset a}
- set a 2
- expr {0||[set a]}
-} 1
-test compExpr-3.8 {CompileLandOrLorExpr procedure, nonnumeric 2nd operand} {
- catch {unset a}
- set a no
- expr {1&&$a}
-} 0
-test compExpr-3.9 {CompileLandOrLorExpr procedure, error in 2nd operand} {
- list [catch {expr {0||[expr %2]}} msg] $msg
-} {1 {syntax error in expression "%2"}}
-test compExpr-3.10 {CompileLandOrLorExpr procedure, long lor/land arm} {
- set a "abcdefghijkl"
- set i 7
- expr {[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]}
-} 1
-
-test compExpr-4.1 {CompileCondExpr procedure, simple test} {
- catch {unset a}
- set a 2
- expr {($a > 1)? "ok" : "nope"}
-} ok
-test compExpr-4.2 {CompileCondExpr procedure, complex test, convert to numeric} {
- catch {unset a}
- set a no
- expr {[set a]? 27 : -54}
-} -54
-test compExpr-4.3 {CompileCondExpr procedure, error in test} {
- list [catch {expr {[expr *2]? +1 : -1}} msg] $msg
-} {1 {syntax error in expression "*2"}}
-test compExpr-4.4 {CompileCondExpr procedure, simple "true" clause} {
- catch {unset a}
- set a no
- expr {1? (27-2) : -54}
-} 25
-test compExpr-4.5 {CompileCondExpr procedure, convert "true" clause to numeric} {
- catch {unset a}
- set a no
- expr {1? $a : -54}
-} no
-test compExpr-4.6 {CompileCondExpr procedure, error in "true" clause} {
- list [catch {expr {1? [expr *2] : -127}} msg] $msg
-} {1 {syntax error in expression "*2"}}
-test compExpr-4.7 {CompileCondExpr procedure, simple "false" clause} {
- catch {unset a}
- set a no
- expr {(2-2)? -3.14159 : "nope"}
-} nope
-test compExpr-4.8 {CompileCondExpr procedure, convert "false" clause to numeric} {
- catch {unset a}
- set a 00123
- expr {0? 42 : $a}
-} 83
-test compExpr-4.9 {CompileCondExpr procedure, error in "false" clause} {
- list [catch {expr {1? 15 : [expr *2]}} msg] $msg
-} {1 {syntax error in expression "*2"}}
-
-test compExpr-5.1 {CompileMathFuncCall procedure, math function found} {
- format %.6g [expr atan2(1.0, 2.0)]
-} 0.463648
-test compExpr-5.2 {CompileMathFuncCall procedure, math function not found} {
- list [catch {expr {do_it()}} msg] $msg
-} {1 {unknown math function "do_it"}}
-if $gotT1 {
- test compExpr-5.3 {CompileMathFuncCall: call registered math function} {
- expr 3*T1()-1
- } 368
- test compExpr-5.4 {CompileMathFuncCall: call registered math function} {
- expr T2()*3
- } 1035
-}
-test compExpr-5.5 {CompileMathFuncCall procedure, too few arguments} {
- list [catch {expr {atan2(1.0)}} msg] $msg
-} {1 {too few arguments for math function}}
-test compExpr-5.6 {CompileMathFuncCall procedure, complex argument} {
- format %.6g [expr pow(2.1, 27.5-(24.4*(5%2)))]
-} 9.97424
-test compExpr-5.7 {CompileMathFuncCall procedure, error in argument} {
- list [catch {expr {sinh(2.*)}} msg] $msg
-} {1 {syntax error in expression "sinh(2.*)"}}
-test compExpr-5.8 {CompileMathFuncCall procedure, too many arguments} {
- list [catch {expr {sinh(2.0, 3.0)}} msg] $msg
-} {1 {too many arguments for math function}}
-test compExpr-5.9 {CompileMathFuncCall procedure, too many arguments} {
- list [catch {expr {0 <= rand(5.2)}} msg] $msg
-} {1 {too many arguments for math function}}
-
-test compExpr-6.1 {LogSyntaxError procedure, error in expr longer than 60 chars} {
- list [catch {expr {(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)/} -1 foo 3} msg] $msg
-} {1 {syntax error in expression "(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+012"}}
-
-# cleanup
-catch {unset a}
-catch {unset b}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/compile.test b/tests/compile.test
deleted file mode 100644
index 382e85e..0000000
--- a/tests/compile.test
+++ /dev/null
@@ -1,214 +0,0 @@
-# This file contains tests for the file tclCompile.c.
-#
-# 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) 1997 by 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: compile.test,v 1.6 1999/04/16 00:47:25 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# The following tests are very incomplete, although the rest of the
-# test suite covers this file fairly well.
-
-catch {rename p ""}
-catch {namespace delete test_ns_compile}
-catch {unset x}
-catch {unset y}
-catch {unset a}
-
-test compile-1.1 {TclCompileString: look up cmds in proc ns, not current ns} {
- catch {namespace delete test_ns_compile}
- catch {unset x}
- set x 123
- namespace eval test_ns_compile {
- proc set {args} {
- global x
- lappend x test_ns_compile::set
- }
- proc p {} {
- set 0
- }
- }
- list [test_ns_compile::p] [set x]
-} {{123 test_ns_compile::set} {123 test_ns_compile::set}}
-test compile-1.2 {TclCompileString, error result is reset if TclGetLong determines word isn't an integer} {
- proc p {x} {info commands 3m}
- list [catch {p} msg] $msg
-} {1 {no value given for parameter "x" to "p"}}
-
-test compile-2.1 {TclCompileDollarVar: global scalar name with ::s} {
- catch {unset x}
- set x 123
- list $::x [expr {[lsearch -exact [info globals] x] != 0}]
-} {123 1}
-test compile-2.2 {TclCompileDollarVar: global scalar name with ::s} {
- catch {unset y}
- proc p {} {
- set ::y 789
- return $::y
- }
- list [p] $::y [expr {[lsearch -exact [info globals] y] != 0}]
-} {789 789 1}
-test compile-2.3 {TclCompileDollarVar: global array name with ::s} {
- catch {unset a}
- set ::a(1) 2
- list $::a(1) [set ::a($::a(1)) 3] $::a(2) [expr {[lsearch -exact [info globals] a] != 0}]
-} {2 3 3 1}
-test compile-2.4 {TclCompileDollarVar: global scalar name with ::s} {
- catch {unset a}
- proc p {} {
- set ::a(1) 1
- return $::a($::a(1))
- }
- list [p] $::a(1) [expr {[lsearch -exact [info globals] a] != 0}]
-} {1 1 1}
-
-test compile-3.1 {TclCompileCatchCmd: only catch cmds with scalar vars are compiled inline} {
- catch {unset a}
- set a(1) xyzzyx
- proc p {} {
- global a
- catch {set x 123} a(1)
- }
- list [p] $a(1)
-} {0 123}
-test compile-3.2 {TclCompileCatchCmd: non-local variables} {
- set ::foo 1
- proc catch-test {} {
- catch {set x 3} ::foo
- }
- catch-test
- set ::foo
-} 3
-
-test compile-4.1 {TclCompileForCmd: command substituted test expression} {
- set i 0
- set j 0
- # Should be "forever"
- for {} [expr $i < 3] {} {
- set j [incr i]
- if {$j > 3} break
- }
- set j
-} {4}
-
-test compile-5.1 {TclCompileForeachCmd: exception stack} {
- proc foreach-exception-test {} {
- foreach array(index) [list 1 2 3] break
- foreach array(index) [list 1 2 3] break
- foreach scalar [list 1 2 3] break
- }
- list [catch foreach-exception-test result] $result
-} {0 {}}
-test compile-5.2 {TclCompileForeachCmd: non-local variables} {
- set ::foo 1
- proc foreach-test {} {
- foreach ::foo {1 2 3} {}
- }
- foreach-test
- set ::foo
-} 3
-
-test compile-6.1 {TclCompileSetCmd: global scalar names with ::s} {
- catch {unset x}
- catch {unset y}
- set x 123
- proc p {} {
- set ::y 789
- return $::y
- }
- list $::x [expr {[lsearch -exact [info globals] x] != 0}] \
- [p] $::y [expr {[lsearch -exact [info globals] y] != 0}]
-} {123 1 789 789 1}
-test compile-6.2 {TclCompileSetCmd: global array names with ::s} {
- catch {unset a}
- set ::a(1) 2
- proc p {} {
- set ::a(1) 1
- return $::a($::a(1))
- }
- list $::a(1) [p] [set ::a($::a(1)) 3] $::a(1) [expr {[lsearch -exact [info globals] a] != 0}]
-} {2 1 3 3 1}
-test compile-6.3 {TclCompileSetCmd: namespace var names with ::s} {
- catch {namespace delete test_ns_compile}
- catch {unset x}
- namespace eval test_ns_compile {
- variable v hello
- variable arr
- set ::x $::test_ns_compile::v
- set ::test_ns_compile::arr(1) 123
- }
- list $::x $::test_ns_compile::arr(1)
-} {hello 123}
-
-test compile-7.1 {TclCompileWhileCmd: command substituted test expression} {
- set i 0
- set j 0
- # Should be "forever"
- while [expr $i < 3] {
- set j [incr i]
- if {$j > 3} break
- }
- set j
-} {4}
-
-test compile-8.1 {CollectArgInfo: binary data} {
- list [catch "string length \000foo" msg] $msg
-} {0 4}
-test compile-8.2 {CollectArgInfo: binary data} {
- list [catch "string length foo\000" msg] $msg
-} {0 4}
-test compile-8.3 {CollectArgInfo: handle "]" at end of command properly} {
- set x ]
-} {]}
-
-test compile-9.1 {UpdateStringOfByteCode: called for duplicate of compiled empty object} {
- proc p {} {
- set x {}
- eval $x
- append x { }
- eval $x
- }
- p
-} {}
-
-test compile-10.1 {BLACKBOX: exception stack overflow} {
- set x {{0}}
- set y 0
- while {$y < 100} {
- if !$x {incr y}
- }
-} {}
-
-
-
-# cleanup
-catch {rename p ""}
-catch {namespace delete test_ns_compile}
-catch {unset x}
-catch {unset y}
-catch {unset a}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/concat.test b/tests/concat.test
deleted file mode 100644
index 69a4f21..0000000
--- a/tests/concat.test
+++ /dev/null
@@ -1,65 +0,0 @@
-# Commands covered: concat
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-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: concat.test,v 1.3 1999/04/16 00:47:25 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test concat-1.1 {simple concatenation} {
- concat a b c d e f g
-} {a b c d e f g}
-test concat-1.2 {merging lists together} {
- concat a {b c d} {e f g h}
-} {a b c d e f g h}
-test concat-1.3 {merge lists, retain sub-lists} {
- concat a {b {c d}} {{e f}} g h
-} {a b {c d} {e f} g h}
-test concat-1.4 {special characters} {
- concat a\{ {b \{c d} \{d
-} "a{ b \\{c d {d"
-
-test concat-2.1 {error: one empty argument} {
- concat {}
-} {}
-
-test concat-3.1 {error: no arguments} {
- list [catch concat msg] $msg
-} {0 {}}
-
-test concat-4.1 {pruning off extra white space} {
- concat {} {a b c}
-} {a b c}
-test concat-4.2 {pruning off extra white space} {
- concat x y " a b c \n\t " " " " def "
-} {x y a b c def}
-test concat-4.3 {pruning off extra white space sets length correctly} {
- llength [concat { {{a}} }]
-} 1
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/dcall.test b/tests/dcall.test
deleted file mode 100644
index 2114071..0000000
--- a/tests/dcall.test
+++ /dev/null
@@ -1,60 +0,0 @@
-# Commands covered: none
-#
-# This file contains a collection of tests for Tcl_CallWhenDeleted.
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 1993 The Regents of the University of California.
-# Copyright (c) 1994 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: dcall.test,v 1.3 1999/04/16 00:47:25 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[info commands testdcall] == {}} {
- puts "This application hasn't been compiled with the \"testdcall\""
- puts "command, so I can't test Tcl_CallWhenDeleted."
- ::tcltest::cleanupTests
- return
-}
-
-test dcall-1.1 {deletion callbacks} {
- lsort -increasing [testdcall 1 2 3]
-} {1 2 3}
-test dcall-1.2 {deletion callbacks} {
- testdcall
-} {}
-test dcall-1.3 {deletion callbacks} {
- lsort -increasing [testdcall 20 21 22 -22]
-} {20 21}
-test dcall-1.4 {deletion callbacks} {
- lsort -increasing [testdcall 20 21 22 -20]
-} {21 22}
-test dcall-1.5 {deletion callbacks} {
- lsort -increasing [testdcall 20 21 22 -21]
-} {20 22}
-test dcall-1.6 {deletion callbacks} {
- lsort -increasing [testdcall 20 21 22 -21 -22 -20]
-} {}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/defs.tcl b/tests/defs.tcl
deleted file mode 100644
index 1e7d8fc..0000000
--- a/tests/defs.tcl
+++ /dev/null
@@ -1,990 +0,0 @@
-# defs.tcl --
-#
-# This file contains support code for the Tcl/Tk test suite.It is
-# It is normally sourced by the individual files in the test suite
-# before they run their tests. This improved approach to testing
-# was designed and initially implemented by Mary Ann May-Pumphrey
-# of Sun Microsystems.
-#
-# Copyright (c) 1990-1994 The Regents of the University of California.
-# Copyright (c) 1994-1996 Sun Microsystems, Inc.
-# Copyright (c) 1998-1999 by Scriptics Corporation.
-# All rights reserved.
-#
-# RCS: @(#) $Id: defs.tcl,v 1.2 1999/04/16 00:47:26 stanton Exp $
-
-# Initialize wish shell
-if {[info exists tk_version]} {
- tk appname tktest
- wm title . tktest
-} else {
- # Ensure that we have a minimal auto_path so we don't pick up extra junk.
- set auto_path [list [info library]]
-}
-
-# create the "tcltest" namespace for all testing variables and procedures
-namespace eval tcltest {
- set procList [list test cleanupTests dotests saveState restoreState \
- normalizeMsg makeFile removeFile makeDirectory removeDirectory \
- viewFile bytestring set_iso8859_1_locale restore_locale \
- safeFetch]
- if {[info exists tk_version]} {
- lappend procList setupbg dobg bgReady cleanupbg fixfocus
- }
- foreach proc $procList {
- namespace export $proc
- }
-
- # ::tcltest::verbose defaults to "b"
- variable verbose "b"
-
- # match defaults to the empty list
- variable match {}
-
- # skip defaults to the empty list
- variable skip {}
-
- # Tests should not rely on the current working directory.
- # Files that are part of the test suite should be accessed relative to
- # ::tcltest::testsDir.
-
- set originalDir [pwd]
- set tDir [file join $originalDir [file dirname [info script]]]
- cd $tDir
- variable testsDir [pwd]
- cd $originalDir
-
- # Count the number of files tested (0 if all.tcl wasn't called).
- # The all.tcl file will set testSingleFile to false, so stats will
- # not be printed until all.tcl calls the cleanupTests proc.
- # The currentFailure var stores the boolean value of whether the
- # current test file has had any failures. The failFiles list
- # stores the names of test files that had failures.
-
- variable numTestFiles 0
- variable testSingleFile true
- variable currentFailure false
- variable failFiles {}
-
- # Tests should remove all files they create. The test suite will
- # check the current working dir for files created by the tests.
- # ::tcltest::filesMade keeps track of such files created using the
- # ::tcltest::makeFile and ::tcltest::makeDirectory procedures.
- # ::tcltest::filesExisted stores the names of pre-existing files.
-
- variable filesMade {}
- variable filesExisted {}
-
- # ::tcltest::numTests will store test files as indices and the list
- # of files (that should not have been) left behind by the test files.
- array set ::tcltest::createdNewFiles {}
-
- # initialize ::tcltest::numTests array to keep track fo the number of
- # tests that pass, fial, and are skipped.
- array set numTests [list Total 0 Passed 0 Skipped 0 Failed 0]
-
- # initialize ::tcltest::skippedBecause array to keep track of
- # constraints that kept tests from running
- array set ::tcltest::skippedBecause {}
-}
-
-# If there is no "memory" command (because memory debugging isn't
-# enabled), generate a dummy command that does nothing.
-
-if {[info commands memory] == ""} {
- proc memory args {}
-}
-
-# ::tcltest::initConfig --
-#
-# Check configuration information that will determine which tests
-# to run. To do this, create an array ::tcltest::testConfig. Each
-# element has a 0 or 1 value. If the element is "true" then tests
-# with that constraint will be run, otherwise tests with that constraint
-# will be skipped. See the README file for the list of built-in
-# constraints defined in this procedure.
-#
-# Arguments:
-# none
-#
-# Results:
-# The ::tcltest::testConfig array is reset to have an index for
-# each built-in test constraint.
-
-proc ::tcltest::initConfig {} {
-
- global tcl_platform tcl_interactive tk_version
-
- catch {unset ::tcltest::testConfig}
-
- # The following trace procedure makes it so that we can safely refer to
- # non-existent members of the ::tcltest::testConfig array without causing an
- # error. Instead, reading a non-existent member will return 0. This is
- # necessary because tests are allowed to use constraint "X" without ensuring
- # that ::tcltest::testConfig("X") is defined.
-
- trace variable ::tcltest::testConfig r ::tcltest::safeFetch
-
- proc ::tcltest::safeFetch {n1 n2 op} {
- if {($n2 != {}) && ([info exists ::tcltest::testConfig($n2)] == 0)} {
- set ::tcltest::testConfig($n2) 0
- }
- }
-
- set ::tcltest::testConfig(unixOnly) \
- [expr {$tcl_platform(platform) == "unix"}]
- set ::tcltest::testConfig(macOnly) \
- [expr {$tcl_platform(platform) == "macintosh"}]
- set ::tcltest::testConfig(pcOnly) \
- [expr {$tcl_platform(platform) == "windows"}]
-
- set ::tcltest::testConfig(unix) $::tcltest::testConfig(unixOnly)
- set ::tcltest::testConfig(mac) $::tcltest::testConfig(macOnly)
- set ::tcltest::testConfig(pc) $::tcltest::testConfig(pcOnly)
-
- set ::tcltest::testConfig(unixOrPc) \
- [expr {$::tcltest::testConfig(unix) || $::tcltest::testConfig(pc)}]
- set ::tcltest::testConfig(macOrPc) \
- [expr {$::tcltest::testConfig(mac) || $::tcltest::testConfig(pc)}]
- set ::tcltest::testConfig(macOrUnix) \
- [expr {$::tcltest::testConfig(mac) || $::tcltest::testConfig(unix)}]
-
- set ::tcltest::testConfig(nt) [expr {$tcl_platform(os) == "Windows NT"}]
- set ::tcltest::testConfig(95) [expr {$tcl_platform(os) == "Windows 95"}]
-
- # The following config switches are used to mark tests that should work,
- # but have been temporarily disabled on certain platforms because they don't
- # and we haven't gotten around to fixing the underlying problem.
-
- set ::tcltest::testConfig(tempNotPc) [expr {!$::tcltest::testConfig(pc)}]
- set ::tcltest::testConfig(tempNotMac) [expr {!$::tcltest::testConfig(mac)}]
- set ::tcltest::testConfig(tempNotUnix) [expr {!$::tcltest::testConfig(unix)}]
-
- # The following config switches are used to mark tests that crash on
- # certain platforms, so that they can be reactivated again when the
- # underlying problem is fixed.
-
- set ::tcltest::testConfig(pcCrash) [expr {!$::tcltest::testConfig(pc)}]
- set ::tcltest::testConfig(macCrash) [expr {!$::tcltest::testConfig(mac)}]
- set ::tcltest::testConfig(unixCrash) [expr {!$::tcltest::testConfig(unix)}]
-
- # Set the "fonts" constraint for wish apps
- if {[info exists tk_version]} {
- set ::tcltest::testConfig(fonts) 1
- catch {destroy .e}
- entry .e -width 0 -font {Helvetica -12} -bd 1
- .e insert end "a.bcd"
- if {([winfo reqwidth .e] != 37) || ([winfo reqheight .e] != 20)} {
- set ::tcltest::testConfig(fonts) 0
- }
- destroy .e
- catch {destroy .t}
- text .t -width 80 -height 20 -font {Times -14} -bd 1
- pack .t
- .t insert end "This is\na dot."
- update
- set x [list [.t bbox 1.3] [.t bbox 2.5]]
- destroy .t
- if {[string match {{22 3 6 15} {31 18 [34] 15}} $x] == 0} {
- set ::tcltest::testConfig(fonts) 0
- }
- }
-
- # Skip empty tests
- set ::tcltest::testConfig(emptyTest) 0
-
- # By default, tests that expost known bugs are skipped.
- set ::tcltest::testConfig(knownBug) 0
-
- # By default, non-portable tests are skipped.
- set ::tcltest::testConfig(nonPortable) 0
-
- # Some tests require user interaction.
- set ::tcltest::testConfig(userInteraction) 0
-
- # Some tests must be skipped if the interpreter is not in interactive mode
- set ::tcltest::testConfig(interactive) $tcl_interactive
-
- # Some tests must be skipped if you are running as root on Unix.
- # Other tests can only be run if you are running as root on Unix.
- set ::tcltest::testConfig(root) 0
- set ::tcltest::testConfig(notRoot) 1
- set user {}
- if {$tcl_platform(platform) == "unix"} {
- catch {set user [exec whoami]}
- if {$user == ""} {
- catch {regexp {^[^(]*\(([^)]*)\)} [exec id] dummy user}
- }
- if {($user == "root") || ($user == "")} {
- set ::tcltest::testConfig(root) 1
- set ::tcltest::testConfig(notRoot) 0
- }
- }
-
- # Set nonBlockFiles constraint: 1 means this platform supports
- # setting files into nonblocking mode.
- if {[catch {set f [open defs r]}]} {
- set ::tcltest::testConfig(nonBlockFiles) 1
- } else {
- if {[catch {fconfigure $f -blocking off}] == 0} {
- set ::tcltest::testConfig(nonBlockFiles) 1
- } else {
- set ::tcltest::testConfig(nonBlockFiles) 0
- }
- close $f
- }
-
- # Set asyncPipeClose constraint: 1 means this platform supports
- # async flush and async close on a pipe.
- #
- # Test for SCO Unix - cannot run async flushing tests because a
- # potential problem with select is apparently interfering.
- # (Mark Diekhans).
- if {$tcl_platform(platform) == "unix"} {
- if {[catch {exec uname -X | fgrep {Release = 3.2v}}] == 0} {
- set ::tcltest::testConfig(asyncPipeClose) 0
- } else {
- set ::tcltest::testConfig(asyncPipeClose) 1
- }
- } else {
- set ::tcltest::testConfig(asyncPipeClose) 1
- }
-
- # Test to see if we have a broken version of sprintf with respect
- # to the "e" format of floating-point numbers.
- set ::tcltest::testConfig(eformat) 1
- if {[string compare "[format %g 5e-5]" "5e-05"] != 0} {
- set ::tcltest::testConfig(eformat) 0
- }
-
- # Test to see if execed commands such as cat, echo, rm and so forth are
- # present on this machine.
- set ::tcltest::testConfig(unixExecs) 1
- if {$tcl_platform(platform) == "macintosh"} {
- set ::tcltest::testConfig(unixExecs) 0
- }
- if {($::tcltest::testConfig(unixExecs) == 1) && \
- ($tcl_platform(platform) == "windows")} {
- if {[catch {exec cat defs}] == 1} {
- set ::tcltest::testConfig(unixExecs) 0
- }
- if {($::tcltest::testConfig(unixExecs) == 1) && \
- ([catch {exec echo hello}] == 1)} {
- set ::tcltest::testConfig(unixExecs) 0
- }
- if {($::tcltest::testConfig(unixExecs) == 1) && \
- ([catch {exec sh -c echo hello}] == 1)} {
- set ::tcltest::testConfig(unixExecs) 0
- }
- if {($::tcltest::testConfig(unixExecs) == 1) && \
- ([catch {exec wc defs}] == 1)} {
- set ::tcltest::testConfig(unixExecs) 0
- }
- if {$::tcltest::testConfig(unixExecs) == 1} {
- exec echo hello > removeMe
- if {[catch {exec rm removeMe}] == 1} {
- set ::tcltest::testConfig(unixExecs) 0
- }
- }
- if {($::tcltest::testConfig(unixExecs) == 1) && \
- ([catch {exec sleep 1}] == 1)} {
- set ::tcltest::testConfig(unixExecs) 0
- }
- if {($::tcltest::testConfig(unixExecs) == 1) && \
- ([catch {exec fgrep unixExecs defs}] == 1)} {
- set ::tcltest::testConfig(unixExecs) 0
- }
- if {($::tcltest::testConfig(unixExecs) == 1) && \
- ([catch {exec ps}] == 1)} {
- set ::tcltest::testConfig(unixExecs) 0
- }
- if {($::tcltest::testConfig(unixExecs) == 1) && \
- ([catch {exec echo abc > removeMe}] == 0) && \
- ([catch {exec chmod 644 removeMe}] == 1) && \
- ([catch {exec rm removeMe}] == 0)} {
- set ::tcltest::testConfig(unixExecs) 0
- } else {
- catch {exec rm -f removeMe}
- }
- if {($::tcltest::testConfig(unixExecs) == 1) && \
- ([catch {exec mkdir removeMe}] == 1)} {
- set ::tcltest::testConfig(unixExecs) 0
- } else {
- catch {exec rm -r removeMe}
- }
- }
-}
-
-::tcltest::initConfig
-
-
-# ::tcltest::processCmdLineArgs --
-#
-# Use command line args to set the verbose, skip, and
-# match variables. This procedure must be run after
-# constraints are initialized, because some constraints can be
-# overridden.
-#
-# Arguments:
-# none
-#
-# Results:
-# ::tcltest::verbose is set to <value>
-
-proc ::tcltest::processCmdLineArgs {} {
- global argv
-
- # The "argv" var doesn't exist in some cases, so use {}
- # The "argv" var doesn't exist in some cases.
- if {(![info exists argv]) || ([llength $argv] < 2)} {
- set flagArray {}
- } else {
- set flagArray $argv
- }
-
- if {[catch {array set flag $flagArray}]} {
- puts stderr "Error: odd number of command line args specified:"
- puts stderr " $argv"
- exit
- }
-
- # Allow for 1-char abbreviations, where applicable (e.g., -match == -m).
- # Note that -verbose cannot be abbreviated to -v in wish because it
- # conflicts with the wish option -visual.
- foreach arg {-verbose -match -skip -constraints} {
- set abbrev [string range $arg 0 1]
- if {([info exists flag($abbrev)]) && \
- ([lsearch -exact $flagArray $arg] < \
- [lsearch -exact $flagArray $abbrev])} {
- set flag($arg) $flag($abbrev)
- }
- }
-
- # Set ::tcltest::workingDir to [pwd].
- # Save the names of files that already exist in ::tcltest::workingDir.
- set ::tcltest::workingDir [pwd]
- foreach file [glob -nocomplain [file join $::tcltest::workingDir *]] {
- lappend ::tcltest::filesExisted [file tail $file]
- }
-
- # Set ::tcltest::verbose to the arg of the -verbose flag, if given
- if {[info exists flag(-verbose)]} {
- set ::tcltest::verbose $flag(-verbose)
- }
-
- # Set ::tcltest::match to the arg of the -match flag, if given
- if {[info exists flag(-match)]} {
- set ::tcltest::match $flag(-match)
- }
-
- # Set ::tcltest::skip to the arg of the -skip flag, if given
- if {[info exists flag(-skip)]} {
- set ::tcltest::skip $flag(-skip)
- }
-
- # Use the -constraints flag, if given, to turn on constraints that are
- # turned off by default: userInteractive knownBug nonPortable. This
- # code fragment must be run after constraints are initialized.
- if {[info exists flag(-constraints)]} {
- foreach elt $flag(-constraints) {
- set ::tcltest::testConfig($elt) 1
- }
- }
-}
-
-::tcltest::processCmdLineArgs
-
-
-# ::tcltest::cleanupTests --
-#
-# Remove files and dirs created using the makeFile and makeDirectory
-# commands since the last time this proc was invoked.
-#
-# Print the names of the files created without the makeFile command
-# since the tests were invoked.
-#
-# Print the number tests (total, passed, failed, and skipped) since the
-# tests were invoked.
-#
-
-proc ::tcltest::cleanupTests {{calledFromAllFile 0}} {
- set tail [file tail [info script]]
-
- # Remove files and directories created by the :tcltest::makeFile and
- # ::tcltest::makeDirectory procedures.
- # Record the names of files in ::tcltest::workingDir that were not
- # pre-existing, and associate them with the test file that created them.
- if {!$calledFromAllFile} {
-
- foreach file $::tcltest::filesMade {
- if {[file exists $file]} {
- catch {file delete -force $file}
- }
- }
- set currentFiles {}
- foreach file [glob -nocomplain [file join $::tcltest::workingDir *]] {
- lappend currentFiles [file tail $file]
- }
- set newFiles {}
- foreach file $currentFiles {
- if {[lsearch -exact $::tcltest::filesExisted $file] == -1} {
- lappend newFiles $file
- }
- }
- set ::tcltest::filesExisted $currentFiles
- if {[llength $newFiles] > 0} {
- set ::tcltest::createdNewFiles($tail) $newFiles
- }
- }
-
- if {$calledFromAllFile || $::tcltest::testSingleFile} {
- # print stats
- puts -nonewline stdout "$tail:"
- foreach index [list "Total" "Passed" "Skipped" "Failed"] {
- puts -nonewline stdout "\t$index\t$::tcltest::numTests($index)"
- }
- puts stdout ""
-
- # print number test files sourced
- # print names of files that ran tests which failed
- if {$calledFromAllFile} {
- puts stdout "Sourced $::tcltest::numTestFiles Test Files."
- set ::tcltest::numTestFiles 0
- if {[llength $::tcltest::failFiles] > 0} {
- puts stdout "Files with failing tests: $::tcltest::failFiles"
- set ::tcltest::failFiles {}
- }
- }
-
- # if any tests were skipped, print the constraints that kept them
- # from running.
- set constraintList [array names ::tcltest::skippedBecause]
- if {[llength $constraintList] > 0} {
- puts stdout "Number of tests skipped for each constraint:"
- foreach constraint [lsort $constraintList] {
- puts stdout \
- "\t$::tcltest::skippedBecause($constraint)\t$constraint"
- unset ::tcltest::skippedBecause($constraint)
- }
- }
-
- # report the names of test files in ::tcltest::createdNewFiles, and
- # reset the array to be empty.
- set testFilesThatTurded [lsort [array names ::tcltest::createdNewFiles]]
- if {[llength $testFilesThatTurded] > 0} {
- puts stdout "Warning: test files left files behind:"
- foreach testFile $testFilesThatTurded {
- puts "\t$testFile:\t$::tcltest::createdNewFiles($testFile)"
- unset ::tcltest::createdNewFiles($testFile)
- }
- }
-
- # reset filesMade, filesExisted, and numTests
- set ::tcltest::filesMade {}
- foreach index [list "Total" "Passed" "Skipped" "Failed"] {
- set ::tcltest::numTests($index) 0
- }
-
- # exit only if running Tk in non-interactive mode
- global tk_version tcl_interactive
- if {[info exists tk_version] && !$tcl_interactive} {
- exit
- }
- } else {
- # if we're deferring stat-reporting until all files are sourced,
- # then add current file to failFile list if any tests in this file
- # failed
- incr ::tcltest::numTestFiles
- if {($::tcltest::currentFailure) && \
- ([lsearch -exact $::tcltest::failFiles $tail] == -1)} {
- lappend ::tcltest::failFiles $tail
- }
- set ::tcltest::currentFailure false
- }
-}
-
-
-# test --
-#
-# This procedure runs a test and prints an error message if the test fails.
-# If ::tcltest::verbose has been set, it also prints a message even if the
-# test succeeds. The test will be skipped if it doesn't match the
-# ::tcltest::match variable, if it matches an element in
-# ::tcltest::skip, or if one of the elements of "constraints" turns
-# out not to be true.
-#
-# Arguments:
-# name - Name of test, in the form foo-1.2.
-# description - Short textual description of the test, to
-# help humans understand what it does.
-# constraints - A list of one or more keywords, each of
-# which must be the name of an element in
-# the array "::tcltest::testConfig". If any of these
-# elements is zero, the test is skipped.
-# This argument may be omitted.
-# script - Script to run to carry out the test. It must
-# return a result that can be checked for
-# correctness.
-# expectedAnswer - Expected result from script.
-
-proc ::tcltest::test {name description script expectedAnswer args} {
- incr ::tcltest::numTests(Total)
-
- # skip the test if it's name matches an element of skip
- foreach pattern $::tcltest::skip {
- if {[string match $pattern $name]} {
- incr ::tcltest::numTests(Skipped)
- return
- }
- }
- # skip the test if it's name doesn't match any element of match
- if {[llength $::tcltest::match] > 0} {
- set ok 0
- foreach pattern $::tcltest::match {
- if {[string match $pattern $name]} {
- set ok 1
- break
- }
- }
- if {!$ok} {
- incr ::tcltest::numTests(Skipped)
- return
- }
- }
- set i [llength $args]
- if {$i == 0} {
- set constraints {}
- } elseif {$i == 1} {
- # "constraints" argument exists; shuffle arguments down, then
- # make sure that the constraints are satisfied.
-
- set constraints $script
- set script $expectedAnswer
- set expectedAnswer [lindex $args 0]
- set doTest 0
- if {[string match {*[$\[]*} $constraints] != 0} {
- # full expression, e.g. {$foo > [info tclversion]}
-
- catch {set doTest [uplevel #0 expr $constraints]}
- } elseif {[regexp {[^.a-zA-Z0-9 ]+} $constraints] != 0} {
- # something like {a || b} should be turned into
- # $::tcltest::testConfig(a) || $::tcltest::testConfig(b).
-
- regsub -all {[.a-zA-Z0-9]+} $constraints \
- {$::tcltest::testConfig(&)} c
- catch {set doTest [eval expr $c]}
- } else {
- # just simple constraints such as {unixOnly fonts}.
-
- set doTest 1
- foreach constraint $constraints {
- if {![info exists ::tcltest::testConfig($constraint)]
- || !$::tcltest::testConfig($constraint)} {
- set doTest 0
- # store the constraint that kept the test from running
- set constraints $constraint
- break
- }
- }
- }
- if {$doTest == 0} {
- incr ::tcltest::numTests(Skipped)
- if {[string first s $::tcltest::verbose] != -1} {
- puts stdout "++++ $name SKIPPED: $constraints"
- }
- # add the constraint to the list of constraints the kept tests
- # from running
- if {[info exists ::tcltest::skippedBecause($constraints)]} {
- incr ::tcltest::skippedBecause($constraints)
- } else {
- set ::tcltest::skippedBecause($constraints) 1
- }
- return
- }
- } else {
- error "wrong # args: must be \"test name description ?constraints? script expectedAnswer\""
- }
- memory tag $name
- set code [catch {uplevel $script} actualAnswer]
- if {$code != 0 || [string compare $actualAnswer $expectedAnswer] != 0} {
- incr ::tcltest::numTests(Failed)
- set ::tcltest::currentFailure true
- if {[string first b $::tcltest::verbose] == -1} {
- set script ""
- }
- puts stdout "\n==== $name $description FAILED"
- if {$script != ""} {
- puts stdout "==== Contents of test case:"
- puts stdout $script
- }
- if {$code != 0} {
- if {$code == 1} {
- puts stdout "==== Test generated error:"
- puts stdout $actualAnswer
- } elseif {$code == 2} {
- puts stdout "==== Test generated return exception; result was:"
- puts stdout $actualAnswer
- } elseif {$code == 3} {
- puts stdout "==== Test generated break exception"
- } elseif {$code == 4} {
- puts stdout "==== Test generated continue exception"
- } else {
- puts stdout "==== Test generated exception $code; message was:"
- puts stdout $actualAnswer
- }
- } else {
- puts stdout "---- Result was:\n$actualAnswer"
- }
- puts stdout "---- Result should have been:\n$expectedAnswer"
- puts stdout "==== $name FAILED\n"
- } else {
- incr ::tcltest::numTests(Passed)
- if {[string first p $::tcltest::verbose] != -1} {
- puts stdout "++++ $name PASSED"
- }
- }
-}
-
-# ::tcltest::dotests --
-#
-# takes two arguments--the name of the test file (such
-# as "parse.test"), and a pattern selecting the tests you want to
-# execute. It sets ::tcltest::matching to the second argument, calls
-# "source" on the file specified in the first argument, and restores
-# ::tcltest::matching to its pre-call value at the end.
-#
-# Arguments:
-# file name of tests file to source
-# args pattern selecting the tests you want to execute
-#
-# Results:
-# none
-
-proc ::tcltest::dotests {file args} {
- set savedTests $::tcltest::match
- set ::tcltest::match $args
- source $file
- set ::tcltest::match $savedTests
-}
-
-proc ::tcltest::openfiles {} {
- if {[catch {testchannel open} result]} {
- return {}
- }
- return $result
-}
-
-proc ::tcltest::leakfiles {old} {
- if {[catch {testchannel open} new]} {
- return {}
- }
- set leak {}
- foreach p $new {
- if {[lsearch $old $p] < 0} {
- lappend leak $p
- }
- }
- return $leak
-}
-
-set ::tcltest::saveState {}
-
-proc ::tcltest::saveState {} {
- uplevel #0 {set ::tcltest::saveState [list [info procs] [info vars]]}
-}
-
-proc ::tcltest::restoreState {} {
- foreach p [info procs] {
- if {[lsearch [lindex $::tcltest::saveState 0] $p] < 0} {
- rename $p {}
- }
- }
- foreach p [uplevel #0 {info vars}] {
- if {[lsearch [lindex $::tcltest::saveState 1] $p] < 0} {
- uplevel #0 "unset $p"
- }
- }
-}
-
-proc ::tcltest::normalizeMsg {msg} {
- regsub "\n$" [string tolower $msg] "" msg
- regsub -all "\n\n" $msg "\n" msg
- regsub -all "\n\}" $msg "\}" msg
- return $msg
-}
-
-# makeFile --
-#
-# Create a new file with the name <name>, and write <contents> to it.
-#
-# If this file hasn't been created via makeFile since the last time
-# cleanupTests was called, add it to the $filesMade list, so it will
-# be removed by the next call to cleanupTests.
-#
-proc ::tcltest::makeFile {contents name} {
- set fd [open $name w]
- fconfigure $fd -translation lf
- if {[string index $contents [expr {[string length $contents] - 1}]] == "\n"} {
- puts -nonewline $fd $contents
- } else {
- puts $fd $contents
- }
- close $fd
-
- set fullName [file join [pwd] $name]
- if {[lsearch -exact $::tcltest::filesMade $fullName] == -1} {
- lappend ::tcltest::filesMade $fullName
- }
-}
-
-proc ::tcltest::removeFile {name} {
- file delete $name
-}
-
-# makeDirectory --
-#
-# Create a new dir with the name <name>.
-#
-# If this dir hasn't been created via makeDirectory since the last time
-# cleanupTests was called, add it to the $directoriesMade list, so it will
-# be removed by the next call to cleanupTests.
-#
-proc ::tcltest::makeDirectory {name} {
- file mkdir $name
-
- set fullName [file join [pwd] $name]
- if {[lsearch -exact $::tcltest::filesMade $fullName] == -1} {
- lappend ::tcltest::filesMade $fullName
- }
-}
-
-proc ::tcltest::removeDirectory {name} {
- file delete -force $name
-}
-
-proc ::tcltest::viewFile {name} {
- global tcl_platform
- if {($tcl_platform(platform) == "macintosh") || \
- ($::tcltest::testConfig(unixExecs) == 0)} {
- set f [open $name]
- set data [read -nonewline $f]
- close $f
- return $data
- } else {
- exec cat $name
- }
-}
-
-#
-# Construct a string that consists of the requested sequence of bytes,
-# as opposed to a string of properly formed UTF-8 characters.
-# This allows the tester to
-# 1. Create denormalized or improperly formed strings to pass to C procedures
-# that are supposed to accept strings with embedded NULL bytes.
-# 2. Confirm that a string result has a certain pattern of bytes, for instance
-# to confirm that "\xe0\0" in a Tcl script is stored internally in
-# UTF-8 as the sequence of bytes "\xc3\xa0\xc0\x80".
-#
-# Generally, it's a bad idea to examine the bytes in a Tcl string or to
-# construct improperly formed strings in this manner, because it involves
-# exposing that Tcl uses UTF-8 internally.
-
-proc ::tcltest::bytestring {string} {
- encoding convertfrom identity $string
-}
-
-# Locate tcltest executable
-
-if {![info exists tk_version]} {
- set tcltest [info nameofexecutable]
-
- if {$tcltest == "{}"} {
- set tcltest {}
- }
-}
-
-set ::tcltest::testConfig(stdio) 0
-catch {
- catch {file delete -force tmp}
- set f [open tmp w]
- puts $f {
- exit
- }
- close $f
-
- set f [open "|[list $tcltest tmp]" r]
- close $f
-
- set ::tcltest::testConfig(stdio) 1
-}
-catch {file delete -force tmp}
-
-# Deliberately call the socket with the wrong number of arguments. The error
-# message you get will indicate whether sockets are available on this system.
-catch {socket} msg
-set ::tcltest::testConfig(socket) \
- [expr {$msg != "sockets are not available on this system"}]
-
-#
-# Internationalization / ISO support procs -- dl
-#
-if {[info commands testlocale]==""} {
- # No testlocale command, no tests...
- # (it could be that we are a sub interp and we could just load
- # the Tcltest package but that would interfere with tests
- # that tests packages/loading in slaves...)
- set ::tcltest::testConfig(hasIsoLocale) 0
-} else {
- proc ::tcltest::set_iso8859_1_locale {} {
- set ::tcltest::previousLocale [testlocale ctype]
- testlocale ctype $::tcltest::isoLocale
- }
-
- proc ::tcltest::restore_locale {} {
- testlocale ctype $::tcltest::previousLocale
- }
-
- if {![info exists ::tcltest::isoLocale]} {
- set ::tcltest::isoLocale fr
- switch $tcl_platform(platform) {
- "unix" {
- # Try some 'known' values for some platforms:
- switch -exact -- $tcl_platform(os) {
- "FreeBSD" {
- set ::tcltest::isoLocale fr_FR.ISO_8859-1
- }
- HP-UX {
- set ::tcltest::isoLocale fr_FR.iso88591
- }
- Linux -
- IRIX {
- set ::tcltest::isoLocale fr
- }
- default {
- # Works on SunOS 4 and Solaris, and maybe others...
- # define it to something else on your system
- #if you want to test those.
- set ::tcltest::isoLocale iso_8859_1
- }
- }
- }
- "windows" {
- set ::tcltest::isoLocale French
- }
- }
- }
-
- set ::tcltest::testConfig(hasIsoLocale) \
- [string length [::tcltest::set_iso8859_1_locale]]
- ::tcltest::restore_locale
-}
-
-#
-# procedures that are Tk specific
-#
-if {[info exists tk_version]} {
- # If the main window isn't already mapped (e.g. because the tests are
- # being run automatically) , specify a precise size for it so that the
- # user won't have to position it manually.
-
- if {![winfo ismapped .]} {
- wm geometry . +0+0
- update
- }
-
- # The following code can be used to perform tests involving a second
- # process running in the background.
-
- # Locate the tktest executable
-
- set ::tcltest::tktest [info nameofexecutable]
- if {$::tcltest::tktest == "{}"} {
- set ::tcltest::tktest {}
- puts stdout \
- "Unable to find tktest executable, skipping multiple process tests."
- }
-
- # Create background process
-
- proc ::tcltest::setupbg args {
- if {$::tcltest::tktest == ""} {
- error "you're not running tktest so setupbg should not have been called"
- }
- if {[info exists ::tcltest::fd] && ($::tcltest::fd != "")} {
- cleanupbg
- }
-
- # The following code segment cannot be run on Windows in Tk8.1b2
- # This bug is logged as a pipe bug (bugID 1495).
-
- global tcl_platform
- if {$tcl_platform(platform) != "windows"} {
- set ::tcltest::fd [open "|[list $::tcltest::tktest -geometry +0+0 -name tktest] $args" r+]
- puts $::tcltest::fd "puts foo; flush stdout"
- flush $::tcltest::fd
- if {[gets $::tcltest::fd data] < 0} {
- error "unexpected EOF from \"$::tcltest::tktest\""
- }
- if {[string compare $data foo]} {
- error "unexpected output from background process \"$data\""
- }
- fileevent $::tcltest::fd readable bgReady
- }
- }
-
- # Send a command to the background process, catching errors and
- # flushing I/O channels
- proc ::tcltest::dobg {command} {
- puts $::tcltest::fd "catch [list $command] msg; update; puts \$msg; puts **DONE**; flush stdout"
- flush $::tcltest::fd
- set ::tcltest::bgDone 0
- set ::tcltest::bgData {}
- tkwait variable ::tcltest::bgDone
- set ::tcltest::bgData
- }
-
- # Data arrived from background process. Check for special marker
- # indicating end of data for this command, and make data available
- # to dobg procedure.
- proc ::tcltest::bgReady {} {
- set x [gets $::tcltest::fd]
- if {[eof $::tcltest::fd]} {
- fileevent $::tcltest::fd readable {}
- set ::tcltest::bgDone 1
- } elseif {$x == "**DONE**"} {
- set ::tcltest::bgDone 1
- } else {
- append ::tcltest::bgData $x
- }
- }
-
- # Exit the background process, and close the pipes
- proc ::tcltest::cleanupbg {} {
- catch {
- puts $::tcltest::fd "exit"
- close $::tcltest::fd
- }
- set ::tcltest::fd ""
- }
-
- # Clean up focus after using generate event, which
- # can leave the window manager with the wrong impression
- # about who thinks they have the focus. (BW)
-
- proc ::tcltest::fixfocus {} {
- catch {destroy .focus}
- toplevel .focus
- wm geometry .focus +0+0
- entry .focus.e
- .focus.e insert 0 "fixfocus"
- pack .focus.e
- update
- focus -force .focus.e
- destroy .focus
- }
-}
-
-# Need to catch the import because it fails if defs.tcl is sourced
-# more than once.
-catch {namespace import ::tcltest::*}
-return
diff --git a/tests/dstring.test b/tests/dstring.test
deleted file mode 100644
index e614b97..0000000
--- a/tests/dstring.test
+++ /dev/null
@@ -1,267 +0,0 @@
-# Commands covered: none
-#
-# This file contains a collection of tests for Tcl's dynamic string
-# library procedures. Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-#
-# Copyright (c) 1993 The Regents of the University of California.
-# Copyright (c) 1994 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: dstring.test,v 1.3 1999/04/16 00:47:26 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[info commands testdstring] == {}} {
- puts "This application hasn't been compiled with the \"testdstring\""
- puts "command, so I can't test Tcl_DStringAppend et al."
- ::tcltest::cleanupTests
- return
-}
-
-test dstring-1.1 {appending and retrieving} {
- testdstring free
- testdstring append "abc" -1
- list [testdstring get] [testdstring length]
-} {abc 3}
-test dstring-1.2 {appending and retrieving} {
- testdstring free
- testdstring append "abc" -1
- testdstring append " xyzzy" 3
- testdstring append " 12345" -1
- list [testdstring get] [testdstring length]
-} {{abc xy 12345} 12}
-test dstring-1.3 {appending and retrieving} {
- testdstring free
- foreach l {a b c d e f g h i j k l m n o p} {
- testdstring append $l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l\n -1
- }
- list [testdstring get] [testdstring length]
-} {{aaaaaaaaaaaaaaaaaaaaa
-bbbbbbbbbbbbbbbbbbbbb
-ccccccccccccccccccccc
-ddddddddddddddddddddd
-eeeeeeeeeeeeeeeeeeeee
-fffffffffffffffffffff
-ggggggggggggggggggggg
-hhhhhhhhhhhhhhhhhhhhh
-iiiiiiiiiiiiiiiiiiiii
-jjjjjjjjjjjjjjjjjjjjj
-kkkkkkkkkkkkkkkkkkkkk
-lllllllllllllllllllll
-mmmmmmmmmmmmmmmmmmmmm
-nnnnnnnnnnnnnnnnnnnnn
-ooooooooooooooooooooo
-ppppppppppppppppppppp
-} 352}
-
-test dstring-2.1 {appending list elements} {
- testdstring free
- testdstring element "abc"
- testdstring element "d e f"
- list [testdstring get] [testdstring length]
-} {{abc {d e f}} 11}
-test dstring-2.2 {appending list elements} {
- testdstring free
- testdstring element "x"
- testdstring element "\{"
- testdstring element "ab\}"
- testdstring get
-} {x \{ ab\}}
-test dstring-2.3 {appending list elements} {
- testdstring free
- foreach l {a b c d e f g h i j k l m n o p} {
- testdstring element $l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l
- }
- testdstring get
-} {aaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbb ccccccccccccccccccccc ddddddddddddddddddddd eeeeeeeeeeeeeeeeeeeee fffffffffffffffffffff ggggggggggggggggggggg hhhhhhhhhhhhhhhhhhhhh iiiiiiiiiiiiiiiiiiiii jjjjjjjjjjjjjjjjjjjjj kkkkkkkkkkkkkkkkkkkkk lllllllllllllllllllll mmmmmmmmmmmmmmmmmmmmm nnnnnnnnnnnnnnnnnnnnn ooooooooooooooooooooo ppppppppppppppppppppp}
-test dstring-2.4 {appending list elements} {
- testdstring free
- testdstring append "a\{" -1
- testdstring element abc
- testdstring append " \{" -1
- testdstring element xyzzy
- testdstring get
-} "a{ abc {xyzzy"
-test dstring-2.5 {appending list elements} {
- testdstring free
- testdstring append " \{" -1
- testdstring element abc
- testdstring get
-} " {abc"
-test dstring-2.6 {appending list elements} {
- testdstring free
- testdstring append " " -1
- testdstring element abc
- testdstring get
-} { abc}
-test dstring-2.7 {appending list elements} {
- testdstring free
- testdstring append "\\ " -1
- testdstring element abc
- testdstring get
-} "\\ abc"
-test dstring-2.8 {appending list elements} {
- testdstring free
- testdstring append "x " -1
- testdstring element abc
- testdstring get
-} {x abc}
-
-test dstring-3.1 {nested sublists} {
- testdstring free
- testdstring start
- testdstring element foo
- testdstring element bar
- testdstring end
- testdstring element another
- testdstring get
-} {{foo bar} another}
-test dstring-3.2 {nested sublists} {
- testdstring free
- testdstring start
- testdstring start
- testdstring element abc
- testdstring element def
- testdstring end
- testdstring end
- testdstring element ghi
- testdstring get
-} {{{abc def}} ghi}
-test dstring-3.3 {nested sublists} {
- testdstring free
- testdstring start
- testdstring start
- testdstring start
- testdstring element foo
- testdstring element foo2
- testdstring end
- testdstring end
- testdstring element foo3
- testdstring end
- testdstring element foo4
- testdstring get
-} {{{{foo foo2}} foo3} foo4}
-test dstring-3.4 {nested sublists} {
- testdstring free
- testdstring element before
- testdstring start
- testdstring element during
- testdstring element more
- testdstring end
- testdstring element last
- testdstring get
-} {before {during more} last}
-test dstring-3.5 {nested sublists} {
- testdstring free
- testdstring element "\{"
- testdstring start
- testdstring element first
- testdstring element second
- testdstring end
- testdstring get
-} {\{ {first second}}
-
-test dstring-4.1 {truncation} {
- testdstring free
- testdstring append "abcdefg" -1
- testdstring trunc 3
- list [testdstring get] [testdstring length]
-} {abc 3}
-test dstring-4.2 {truncation} {
- testdstring free
- testdstring append "xyzzy" -1
- testdstring trunc 0
- list [testdstring get] [testdstring length]
-} {{} 0}
-
-test dstring-5.1 {copying to result} {
- testdstring free
- testdstring append xyz -1
- testdstring result
-} xyz
-test dstring-5.2 {copying to result} {
- testdstring free
- catch {unset a}
- foreach l {a b c d e f g h i j k l m n o p} {
- testdstring append $l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l\n -1
- }
- set a [testdstring result]
- testdstring append abc -1
- list $a [testdstring get]
-} {{aaaaaaaaaaaaaaaaaaaaa
-bbbbbbbbbbbbbbbbbbbbb
-ccccccccccccccccccccc
-ddddddddddddddddddddd
-eeeeeeeeeeeeeeeeeeeee
-fffffffffffffffffffff
-ggggggggggggggggggggg
-hhhhhhhhhhhhhhhhhhhhh
-iiiiiiiiiiiiiiiiiiiii
-jjjjjjjjjjjjjjjjjjjjj
-kkkkkkkkkkkkkkkkkkkkk
-lllllllllllllllllllll
-mmmmmmmmmmmmmmmmmmmmm
-nnnnnnnnnnnnnnnnnnnnn
-ooooooooooooooooooooo
-ppppppppppppppppppppp
-} abc}
-
-test dstring-6.1 {Tcl_DStringGetResult} {
- testdstring free
- list [testdstring gresult staticsmall] [testdstring get]
-} {{} short}
-test dstring-6.2 {Tcl_DStringGetResult} {
- testdstring free
- foreach l {a b c d e f g h i j k l m n o p} {
- testdstring append $l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l$l\n -1
- }
- list [testdstring gresult staticsmall] [testdstring get]
-} {{} short}
-test dstring-6.3 {Tcl_DStringGetResult} {
- set result {}
- lappend result [testdstring gresult staticlarge]
- testdstring append x 1
- lappend result [testdstring get]
-} {{} {first0 first1 first2 first3 first4 first5 first6 first7 first8 first9
-second0 second1 second2 second3 second4 second5 second6 second7 second8 second9
-third0 third1 third2 third3 third4 third5 third6 third7 third8 third9
-fourth0 fourth1 fourth2 fourth3 fourth4 fourth5 fourth6 fourth7 fourth8 fourth9
-fifth0 fifth1 fifth2 fifth3 fifth4 fifth5 fifth6 fifth7 fifth8 fifth9
-sixth0 sixth1 sixth2 sixth3 sixth4 sixth5 sixth6 sixth7 sixth8 sixth9
-seventh0 seventh1 seventh2 seventh3 seventh4 seventh5 seventh6 seventh7 seventh8 seventh9
-x}}
-test dstring-6.4 {Tcl_DStringGetResult} {
- set result {}
- lappend result [testdstring gresult free]
- testdstring append y 1
- lappend result [testdstring get]
-} {{} {This is a malloc-ed stringy}}
-test dstring-6.5 {Tcl_DStringGetResult} {
- set result {}
- lappend result [testdstring gresult special]
- testdstring append z 1
- lappend result [testdstring get]
-} {{} {This is a specially-allocated stringz}}
-
-# cleanup
-testdstring free
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/encoding.test b/tests/encoding.test
deleted file mode 100644
index 3852749..0000000
--- a/tests/encoding.test
+++ /dev/null
@@ -1,316 +0,0 @@
-# This file contains a collection of tests for tclEncoding.c
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 1997 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: encoding.test,v 1.2 1999/04/16 00:47:26 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-proc toutf {args} {
- global x
- lappend x "toutf $args"
-}
-proc fromutf {args} {
- global x
- lappend x "fromutf $args"
-}
-
-# Some tests require the testencoding command
-
-set ::tcltest::testConfig(testencoding) \
- [expr {[info commands testencoding] != {}}]
-
-
-# TclInitEncodingSubsystem is tested by the rest of this file
-# TclFinalizeEncodingSubsystem is not currently tested
-
-test encoding-1.1 {Tcl_GetEncoding: system encoding} {testencoding} {
- testencoding create foo toutf fromutf
- set old [encoding system]
- encoding system foo
- set x {}
- encoding convertto abcd
- encoding system $old
- testencoding delete foo
- set x
-} {{fromutf }}
-test encoding-1.2 {Tcl_GetEncoding: existing encoding} {testencoding} {
- testencoding create foo toutf fromutf
- set x {}
- encoding convertto foo abcd
- testencoding delete foo
- set x
-} {{fromutf }}
-test encoding-1.3 {Tcl_GetEncoding: load encoding} {
- list [encoding convertto jis0208 \u4e4e] \
- [encoding convertfrom jis0208 8C]
-} "8C \u4e4e"
-
-test encoding-2.1 {Tcl_FreeEncoding: refcount == 0} {
- encoding convertto jis0208 \u4e4e
-} {8C}
-test encoding-2.2 {Tcl_FreeEncoding: refcount != 0} {testencoding} {
- set system [encoding system]
- set path [testencoding path]
- encoding system jis0208 ;# incr ref count
- testencoding path .
- set x [encoding convertto jis0208 \u4e4e] ;# old one found
- encoding system identity
- lappend x [catch {encoding convertto jis0208 \u4e4e} msg] $msg
- encoding system identity
- testencoding path $path
- encoding system $system
- set x
-} {8C 1 {unknown encoding "jis0208"}}
-
-test encoding-3.1 {Tcl_GetEncodingName, NULL} {
- set old [encoding system]
- encoding system jis0208
- set x [encoding system]
- encoding system $old
- set x
-} {jis0208}
-test encoding-3.2 {Tcl_GetEncodingName, non-null} {
- set old [fconfigure stdout -encoding]
- fconfigure stdout -encoding jis0208
- set x [fconfigure stdout -encoding]
- fconfigure stdout -encoding $old
- set x
-} {jis0208}
-
-test encoding-4.1 {Tcl_GetEncodingNames} {testencoding} {
- file mkdir tmp/encoding
- close [open tmp/encoding/junk.enc w]
- close [open tmp/encoding/junk2.enc w]
- cd tmp
- set path [testencoding path]
- testencoding path {}
- catch {unset encodings}
- catch {unset x}
- foreach encoding [encoding names] {
- set encodings($encoding) 1
- }
- testencoding path .
- foreach encoding [encoding names] {
- if {![info exists encodings($encoding)]} {
- lappend x $encoding
- }
- }
- testencoding path $path
- cd ..
- file delete -force tmp
- lsort $x
-} {junk junk2}
-
-test encoding-5.1 {Tcl_SetSystemEncoding} {
- set old [encoding system]
- encoding system jis0208
- set x [encoding convertto \u4e4e]
- encoding system identity
- encoding system $old
- set x
-} {8C}
-test encoding-5.2 {Tcl_SetSystemEncoding: test ref count} {
- set old [encoding system]
- encoding system $old
- string compare $old [encoding system]
-} {0}
-
-test encoding-6.1 {Tcl_CreateEncoding: new} {testencoding} {
- testencoding create foo {toutf 1} {fromutf 2}
- set x {}
- encoding convertfrom foo abcd
- encoding convertto foo abcd
- testencoding delete foo
- set x
-} {{toutf 1} {fromutf 2}}
-test encoding-6.2 {Tcl_CreateEncoding: replace encoding} {testencoding} {
- testencoding create foo {toutf a} {fromutf b}
- set x {}
- encoding convertfrom foo abcd
- encoding convertto foo abcd
- testencoding delete foo
- set x
-} {{toutf a} {fromutf b}}
-
-test encoding-7.1 {Tcl_ExternalToUtfDString: small buffer} {
- encoding convertfrom jis0208 8c8c8c8c
-} "\u543e\u543e\u543e\u543e"
-test encoding-7.2 {Tcl_UtfToExternalDString: big buffer} {
- set a 8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C
- append a $a
- append a $a
- append a $a
- append a $a
- set x [encoding convertfrom jis0208 $a]
- list [string length $x] [string index $x 0]
-} "512 \u4e4e"
-
-test encoding-8.1 {Tcl_ExternalToUtf} {
- set f [open dummy w]
- fconfigure $f -translation binary -encoding iso8859-1
- puts -nonewline $f "ab\x8c\xc1g"
- close $f
- set f [open dummy r]
- fconfigure $f -translation binary -encoding shiftjis
- set x [read $f]
- close $f
- file delete dummy
- set x
-} "ab\u4e4eg"
-
-test encoding-9.1 {Tcl_UtfToExternalDString: small buffer} {
- encoding convertto jis0208 "\u543e\u543e\u543e\u543e"
-} {8c8c8c8c}
-test encoding-9.2 {Tcl_UtfToExternalDString: big buffer} {
- set a \u4e4e\u4e4e\u4e4e\u4e4e\u4e4e\u4e4e\u4e4e\u4e4e
- append a $a
- append a $a
- append a $a
- append a $a
- append a $a
- append a $a
- set x [encoding convertto jis0208 $a]
- list [string length $x] [string range $x 0 1]
-} "1024 8C"
-
-test encoding-10.1 {Tcl_UtfToExternal} {
- set f [open dummy w]
- fconfigure $f -translation binary -encoding shiftjis
- puts -nonewline $f "ab\u4e4eg"
- close $f
- set f [open dummy r]
- fconfigure $f -translation binary -encoding iso8859-1
- set x [read $f]
- close $f
- file delete dummy
- set x
-} "ab\x8c\xc1g"
-
-test encoding-11.1 {LoadEncodingFile: unknown encoding} {testencoding} {
- set system [encoding system]
- set path [testencoding path]
- encoding system iso8859-1
- testencoding path {}
- set x [list [catch {encoding convertto jis0208 \u4e4e} msg] $msg]
- testencoding path $path
- encoding system $system
- lappend x [encoding convertto jis0208 \u4e4e]
-} {1 {unknown encoding "jis0208"} 8C}
-test encoding-11.2 {LoadEncodingFile: single-byte} {
- encoding convertfrom jis0201 \xa1
-} "\uff61"
-test encoding-11.3 {LoadEncodingFile: double-byte} {
- encoding convertfrom jis0208 8C
-} "\u4e4e"
-test encoding-11.4 {LoadEncodingFile: multi-byte} {
- encoding convertfrom shiftjis \x8c\xc1
-} "\u4e4e"
-test encoding-11.5 {LoadEncodingFile: escape file} {
- encoding convertto iso2022 \u4e4e
-} "\x1b(B\x1b$@8C"
-test encoding-11.6 {LoadEncodingFile: invalid file} {testencoding} {
- set system [encoding system]
- set path [testencoding path]
- encoding system identity
- testencoding path tmp
- file mkdir tmp/encoding
- set f [open tmp/encoding/splat.enc w]
- fconfigure $f -translation binary
- puts $f "abcdefghijklmnop"
- close $f
- set x [list [catch {encoding convertto splat \u4e4e} msg] $msg]
- file delete -force tmp
- catch {file delete encoding}
- testencoding path $path
- encoding system $system
- set x
-} {1 {invalid encoding file "splat"}}
-
-# OpenEncodingFile is fully tested by the rest of the tests in this file.
-
-test encoding-12.1 {LoadTableEncoding: normal encoding} {
- set x [encoding convertto iso8859-3 \u120]
- append x [encoding convertto iso8859-3 \ud5]
- append x [encoding convertfrom iso8859-3 \xd5]
-} "\xd5?\u120"
-test encoding-12.2 {LoadTableEncoding: single-byte encoding} {
- set x [encoding convertto iso8859-3 ab\u0120g]
- append x [encoding convertfrom iso8859-3 ab\xd5g]
-} "ab\xd5gab\u120g"
-test encoding-12.3 {LoadTableEncoding: multi-byte encoding} {
- set x [encoding convertto shiftjis ab\u4e4eg]
- append x [encoding convertfrom shiftjis ab\x8c\xc1g]
-} "ab\x8c\xc1gab\u4e4eg"
-test encoding-12.4 {LoadTableEncoding: double-byte encoding} {
- set x [encoding convertto jis0208 \u4e4e\u3b1]
- append x [encoding convertfrom jis0208 8C&A]
-} "8C&A\u4e4e\u3b1"
-test encoding-12.5 {LoadTableEncoding: symbol encoding} {
- set x [encoding convertto symbol \u3b3]
- append x [encoding convertto symbol \u67]
- append x [encoding convertfrom symbol \x67]
-} "\x67\x67\u3b3"
-
-test encoding-13.1 {LoadEscapeTable} {
- set x [encoding convertto iso2022 ab\u4e4e\u68d9g]
-} "\x1b(Bab\x1b$@8C\x1b$(DD%\x1b(Bg"
-
-test encoding-14.1 {BinaryProc} {
- encoding convertto identity \x12\x34\x56\xff\x69
-} "\x12\x34\x56\xc3\xbf\x69"
-
-test encoding-15.1 {UtfToUtfProc} {
- encoding convertto utf-8 \xa3
-} "\xc2\xa3"
-
-test encoding-16.1 {UnicodeToUtfProc} {
- encoding convertfrom unicode NN
-} "\u4e4e"
-
-test encoding-17.1 {UtfToUnicodeProc} {
-} {}
-
-test encoding-18.1 {TableToUtfProc} {
-} {}
-
-test encoding-19.1 {TableFromUtfProc} {
-} {}
-
-test encoding-20.1 {TableFreefProc} {
-} {}
-
-test encoding-21.1 {EscapeToUtfProc} {
-} {}
-
-test encoding-22.1 {EscapeFromUtfProc} {
-} {}
-
-# EscapeFreeProc, GetTableEncoding, unilen
-# are fully tested by the rest of this file
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/env.test b/tests/env.test
deleted file mode 100644
index 27656e4..0000000
--- a/tests/env.test
+++ /dev/null
@@ -1,261 +0,0 @@
-# Commands covered: none (tests environment variable implementation)
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: env.test,v 1.4 1999/04/16 00:47:26 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-#
-# These tests will run on any platform (and indeed crashed
-# on the Mac). So put them before you test for the existance
-# of exec.
-#
-test env-1.1 {propagation of env values to child interpreters} {
- catch {interp delete child}
- catch {unset env(test)}
- interp create child
- set env(test) garbage
- set return [child eval {set env(test)}]
- interp delete child
- unset env(test)
- set return
-} {garbage}
-#
-# This one crashed on Solaris under Tcl8.0, so we only
-# want to make sure it runs.
-#
-test env-1.2 {lappend to env value} {
- catch {unset env(test)}
- set env(test) aaaaaaaaaaaaaaaa
- append env(test) bbbbbbbbbbbbbb
- unset env(test)
-} {}
-test env-1.3 {reflection of env by "array names"} {
- catch {interp delete child}
- catch {unset env(test)}
- interp create child
- child eval {set env(test) garbage}
- set names [array names env]
- interp delete child
- set ix [lsearch $names test]
- catch {unset env(test)}
- expr {$ix >= 0}
-} {1}
-
-
-# Some tests require the "exec" command.
-# Skip them if exec is not defined.
-set ::tcltest::testConfig(execCommandExists) [expr {[info commands exec] != ""}]
-
-set f [open printenv w]
-puts $f {
- proc lrem {listname name} {
- upvar $listname list
- set i [lsearch $list $name]
- if {$i >= 0} {
- set list [lreplace $list $i $i]
- }
- return $list
- }
-
- set names [lsort [array names env]]
- if {$tcl_platform(platform) == "windows"} {
- lrem names HOME
- lrem names COMSPEC
- lrem names ComSpec
- lrem names ""
- }
- foreach name {TCL_LIBRARY PATH LD_LIBRARY_PATH PURE_PROG_NAME DISPLAY SHLIB_PATH } {
- lrem names $name
- }
- foreach p $names {
- puts "$p=$env($p)"
- }
-}
-close $f
-
-proc getenv {} {
- global printenv tcltest
- catch {exec $tcltest printenv} out
- if {$out == "child process exited abnormally"} {
- set out {}
- }
- return $out
-}
-
-# Save the current environment variables at the start of the test.
-
-foreach name [array names env] {
- set env2($name) $env($name)
- unset env($name)
-}
-
-# Added the following lines so that child tcltest can actually find its
-# library if the initial tcltest is run from a non-standard place.
-# ('saved' env vars)
-foreach name {TCL_LIBRARY PATH LD_LIBRARY_PATH DISPLAY SHLIB_PATH} {
- if {[info exists env2($name)]} {
- set env($name) $env2($name);
- }
-}
-
-test env-2.1 {adding environment variables} {execCommandExists} {
- getenv
-} {}
-
-set env(NAME1) "test string"
-test env-2.2 {adding environment variables} {execCommandExists} {
- getenv
-} {NAME1=test string}
-
-set env(NAME2) "more"
-test env-2.3 {adding environment variables} {execCommandExists} {
- getenv
-} {NAME1=test string
-NAME2=more}
-
-set env(XYZZY) "garbage"
-test env-2.4 {adding environment variables} {execCommandExists} {
- getenv
-} {NAME1=test string
-NAME2=more
-XYZZY=garbage}
-
-set env(NAME2) "new value"
-test env-3.1 {changing environment variables} {execCommandExists} {
- set result [getenv]
- unset env(NAME2)
- set result
-} {NAME1=test string
-NAME2=new value
-XYZZY=garbage}
-
-test env-4.1 {unsetting environment variables} {execCommandExists} {
- set result [getenv]
- unset env(NAME1)
- set result
-} {NAME1=test string
-XYZZY=garbage}
-
-test env-4.2 {unsetting environment variables} {execCommandExists} {
- set result [getenv]
- unset env(XYZZY)
- set result
-} {XYZZY=garbage}
-
-test env-4.3 {setting international environment variables} {execCommandExists} {
- set env(\ua7) \ub6
- getenv
-} "\ua7=\ub6"
-test env-4.4 {changing international environment variables} {execCommandExists} {
- set env(\ua7) \ua7
- getenv
-} "\ua7=\ua7"
-test env-4.5 {unsetting international environment variables} {execCommandExists} {
- set env(\ub6) \ua7
- unset env(\ua7)
- set result [getenv]
- unset env(\ub6)
- set result
-} "\ub6=\ua7"
-
-test env-5.0 {corner cases - set a value, it should exist} {} {
- set temp [lindex [array names env] end]
- set x env($temp)
- set env($temp) a
- set result [set env($temp)]
- set env($temp) $x
- set result
-} {a}
-test env-5.1 {corner cases - remove one elem at a time} {} {
- # When no environment variables exist, the env var will
- # contain no entries. The "array names" call synchs up
- # the C-level environ array with the Tcl level env array.
- # Make sure an empty Tcl array is created.
-
- set x [array get env]
- foreach e [array names env] {
- unset env($e)
- }
- set result [catch {array names env}]
- array set env $x
- set result
-} {0}
-test env-5.2 {corner cases - unset the env array} {} {
- # Unsetting a variable in an interp detaches the C-level
- # traces from the Tcl "env" variable.
-
- interp create i
- i eval { unset env }
- i eval { set env(THIS_SHOULDNT_EXIST) a}
- set result [info exist env(THIS_SHOULDNT_EXIST)]
- interp delete i
- set result
-} {0}
-test env-5.3 {corner cases - unset the env in master should unset child} {} {
- # Variables deleted in a master interp should be deleted in
- # child interp too.
-
- interp create i
- i eval { set env(THIS_SHOULD_EXIST) a}
- set result [set env(THIS_SHOULD_EXIST)]
- unset env(THIS_SHOULD_EXIST)
- lappend result [i eval {catch {set env(THIS_SHOULD_EXIST)}}]
- interp delete i
- set result
-} {a 1}
-test env-5.4 {corner cases - unset the env array} {knownBug} {
- # The info exist command should be in synch with the env array.
- # Know Bug: 1737
-
- interp create i
- i eval { set env(THIS_SHOULD_EXIST) a}
- set result [info exists env(THIS_SHOULD_EXIST)]
- lappend result [set env(THIS_SHOULD_EXIST)]
- lappend result [info exists env(THIS_SHOULD_EXIST)]
- interp delete i
- set result
-} {1 a 1}
-test env-5.5 {corner cases - cannot have null entries on Windows} {pcOnly} {
- set env() a
- catch {set env()}
-} {1}
-
-
-# Restore the environment variables at the end of the test.
-
-foreach name [array names env] {
- unset env($name)
-}
-foreach name [array names env2] {
- set env($name) $env2($name)
-}
-
-# cleanup
-file delete printenv
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/error.test b/tests/error.test
deleted file mode 100644
index 45e8f1d..0000000
--- a/tests/error.test
+++ /dev/null
@@ -1,192 +0,0 @@
-# Commands covered: error, catch
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-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: error.test,v 1.3 1999/04/16 00:47:26 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-proc foo {} {
- global errorInfo
- set a [catch {format [error glorp2]} b]
- error {Human-generated}
-}
-
-proc foo2 {} {
- global errorInfo
- set a [catch {format [error glorp2]} b]
- error {Human-generated} $errorInfo
-}
-
-# Catch errors occurring in commands and errors from "error" command
-
-test error-1.1 {simple errors from commands} {
- catch {format [string compare]} b
-} 1
-
-test error-1.2 {simple errors from commands} {
- catch {format [string compare]} b
- set b
-} {wrong # args: should be "string compare string1 string2"}
-
-test error-1.3 {simple errors from commands} {
- catch {format [string compare]} b
- set errorInfo
-} {wrong # args: should be "string compare string1 string2"
- while executing
-"string compare"}
-
-test error-1.4 {simple errors from commands} {
- catch {error glorp} b
-} 1
-
-test error-1.5 {simple errors from commands} {
- catch {error glorp} b
- set b
-} glorp
-
-test error-1.6 {simple errors from commands} {
- catch {catch a b c} b
-} 1
-
-test error-1.7 {simple errors from commands} {
- catch {catch a b c} b
- set b
-} {wrong # args: should be "catch command ?varName?"}
-
-test error-1.8 {simple errors from commands} {nonPortable} {
- # This test is non-portable: it generates a memory fault on
- # machines like DEC Alphas (infinite recursion overflows
- # stack?)
-
- proc p {} {
- uplevel 1 catch p error
- }
- p
-} 0
-
-# Check errors nested in procedures. Also check the optional argument
-# to "error" to generate a new error trace.
-
-test error-2.1 {errors in nested procedures} {
- catch foo b
-} 1
-
-test error-2.2 {errors in nested procedures} {
- catch foo b
- set b
-} {Human-generated}
-
-test error-2.3 {errors in nested procedures} {
- catch foo b
- set errorInfo
-} {Human-generated
- while executing
-"error {Human-generated}"
- (procedure "foo" line 4)
- invoked from within
-"foo"}
-
-test error-2.4 {errors in nested procedures} {
- catch foo2 b
-} 1
-
-test error-2.5 {errors in nested procedures} {
- catch foo2 b
- set b
-} {Human-generated}
-
-test error-2.6 {errors in nested procedures} {
- catch foo2 b
- set errorInfo
-} {glorp2
- while executing
-"error glorp2"
- (procedure "foo2" line 3)
- invoked from within
-"foo2"}
-
-# Error conditions related to "catch".
-
-test error-3.1 {errors in catch command} {
- list [catch {catch} msg] $msg
-} {1 {wrong # args: should be "catch command ?varName?"}}
-test error-3.2 {errors in catch command} {
- list [catch {catch a b c} msg] $msg
-} {1 {wrong # args: should be "catch command ?varName?"}}
-test error-3.3 {errors in catch command} {
- catch {unset a}
- set a(0) 22
- list [catch {catch {format 44} a} msg] $msg
-} {1 {couldn't save command result in variable}}
-catch {unset a}
-
-# More tests related to errorInfo and errorCode
-
-test error-4.1 {errorInfo and errorCode variables} {
- list [catch {error msg1 msg2 msg3} msg] $msg $errorInfo $errorCode
-} {1 msg1 msg2 msg3}
-test error-4.2 {errorInfo and errorCode variables} {
- list [catch {error msg1 {} msg3} msg] $msg $errorInfo $errorCode
-} {1 msg1 {msg1
- while executing
-"error msg1 {} msg3"} msg3}
-test error-4.3 {errorInfo and errorCode variables} {
- list [catch {error msg1 {}} msg] $msg $errorInfo $errorCode
-} {1 msg1 {msg1
- while executing
-"error msg1 {}"} NONE}
-test error-4.4 {errorInfo and errorCode variables} {
- set errorCode bogus
- list [catch {error msg1} msg] $msg $errorInfo $errorCode
-} {1 msg1 {msg1
- while executing
-"error msg1"} NONE}
-test error-4.5 {errorInfo and errorCode variables} {
- set errorCode bogus
- list [catch {error msg1 msg2 {}} msg] $msg $errorInfo $errorCode
-} {1 msg1 msg2 {}}
-
-# Errors in error command itself
-
-test error-5.1 {errors in error command} {
- list [catch {error} msg] $msg
-} {1 {wrong # args: should be "error message ?errorInfo? ?errorCode?"}}
-test error-5.2 {errors in error command} {
- list [catch {error a b c d} msg] $msg
-} {1 {wrong # args: should be "error message ?errorInfo? ?errorCode?"}}
-
-# Make sure that catch resets error information
-
-test error-6.1 {catch must reset error state} {
- catch {error outer [catch {error inner inner.errorInfo inner.errorCode}]}
- list $errorCode $errorInfo
-} {NONE 1}
-
-# cleanup
-catch {rename p ""}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/eval.test b/tests/eval.test
deleted file mode 100644
index 6c53bb8..0000000
--- a/tests/eval.test
+++ /dev/null
@@ -1,74 +0,0 @@
-# Commands covered: eval
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: eval.test,v 1.3 1999/04/16 00:47:26 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test eval-1.1 {single argument} {
- eval {format 22}
-} 22
-test eval-1.2 {multiple arguments} {
- set a {$b}
- set b xyzzy
- eval format $a
-} xyzzy
-test eval-1.3 {single argument} {
- eval concat a b c d e f g
-} {a b c d e f g}
-
-test eval-2.1 {error: not enough arguments} {catch eval} 1
-test eval-2.2 {error: not enough arguments} {
- catch eval msg
- set msg
-} {wrong # args: should be "eval arg ?arg ...?"}
-test eval-2.3 {error in eval'ed command} {
- catch {eval {error "test error"}}
-} 1
-test eval-2.4 {error in eval'ed command} {
- catch {eval {error "test error"}} msg
- set msg
-} {test error}
-test eval-2.5 {error in eval'ed command: setting errorInfo} {
- catch {eval {
- set a 1
- error "test error"
- }} msg
- set errorInfo
-} "test error
- while executing
-\"error \"test error\"\"
- (\"eval\" body line 3)
- invoked from within
-\"eval {
- set a 1
- error \"test error\"
- }\""
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/event.test b/tests/event.test
deleted file mode 100644
index d75c959..0000000
--- a/tests/event.test
+++ /dev/null
@@ -1,589 +0,0 @@
-# This file contains a collection of tests for the procedures in the file
-# tclEvent.c, which includes the "update", and "vwait" Tcl
-# commands. Sourcing this file into Tcl runs the tests and generates
-# output for errors. No output means no errors were found.
-#
-# Copyright (c) 1995-1997 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: event.test,v 1.4 1999/04/16 00:47:26 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-set ::tcltest::testConfig(testfilehandler) \
- [expr {[info commands testfilehandler] != {}}]
-set ::tcltest::testConfig(testexithandler) \
- [expr {[info commands testexithandler] != {}}]
-set ::tcltest::testConfig(testfilewait) \
- [expr {[info commands testfilewait] != {}}]
-
-
-test event-1.1 {Tcl_CreateFileHandler, reading} {testfilehandler} {
- testfilehandler close
- testfilehandler create 0 readable off
- testfilehandler clear 0
- testfilehandler oneevent
- set result ""
- lappend result [testfilehandler counts 0]
- testfilehandler fillpartial 0
- testfilehandler oneevent
- lappend result [testfilehandler counts 0]
- testfilehandler oneevent
- lappend result [testfilehandler counts 0]
- testfilehandler close
- set result
-} {{0 0} {1 0} {2 0}}
-test event-1.2 {Tcl_CreateFileHandler, writing} {testfilehandler nonPortable} {
- # This test is non-portable because on some systems (e.g.
- # SunOS 4.1.3) pipes seem to be writable always.
- testfilehandler close
- testfilehandler create 0 off writable
- testfilehandler clear 0
- testfilehandler oneevent
- set result ""
- lappend result [testfilehandler counts 0]
- testfilehandler fillpartial 0
- testfilehandler oneevent
- lappend result [testfilehandler counts 0]
- testfilehandler fill 0
- testfilehandler oneevent
- lappend result [testfilehandler counts 0]
- testfilehandler close
- set result
-} {{0 1} {0 2} {0 2}}
-test event-1.3 {Tcl_DeleteFileHandler} {testfilehandler nonPortable} {
- testfilehandler close
- testfilehandler create 2 disabled disabled
- testfilehandler create 1 readable writable
- testfilehandler create 0 disabled disabled
- testfilehandler fillpartial 1
- set result ""
- testfilehandler oneevent
- lappend result [testfilehandler counts 1]
- testfilehandler oneevent
- lappend result [testfilehandler counts 1]
- testfilehandler oneevent
- lappend result [testfilehandler counts 1]
- testfilehandler create 1 off off
- testfilehandler oneevent
- lappend result [testfilehandler counts 1]
- testfilehandler close
- set result
-} {{0 1} {1 1} {1 2} {0 0}}
-
-test event-2.1 {Tcl_DeleteFileHandler} {testfilehandler nonPortable} {
- testfilehandler close
- testfilehandler create 2 disabled disabled
- testfilehandler create 1 readable writable
- testfilehandler fillpartial 1
- set result ""
- testfilehandler oneevent
- lappend result [testfilehandler counts 1]
- testfilehandler oneevent
- lappend result [testfilehandler counts 1]
- testfilehandler oneevent
- lappend result [testfilehandler counts 1]
- testfilehandler create 1 off off
- testfilehandler oneevent
- lappend result [testfilehandler counts 1]
- testfilehandler close
- set result
-} {{0 1} {1 1} {1 2} {0 0}}
-test event-2.2 {Tcl_DeleteFileHandler, fd reused & events still pending} \
- {testfilehandler nonPortable} {
- testfilehandler close
- testfilehandler create 0 readable writable
- testfilehandler fillpartial 0
- set result ""
- testfilehandler oneevent
- lappend result [testfilehandler counts 0]
- testfilehandler close
- testfilehandler create 0 readable writable
- testfilehandler oneevent
- lappend result [testfilehandler counts 0]
- testfilehandler close
- set result
-} {{0 1} {0 0}}
-
-test event-3.1 {FileHandlerCheckProc, TCL_FILE_EVENTS off } {testfilehandler} {
- testfilehandler close
- testfilehandler create 1 readable writable
- testfilehandler fillpartial 1
- testfilehandler windowevent
- set result [testfilehandler counts 1]
- testfilehandler close
- set result
-} {0 0}
-
-test event-4.1 {FileHandlerEventProc, race between event and disabling} \
- {testfilehandler nonPortable} {
- update
- testfilehandler close
- testfilehandler create 2 disabled disabled
- testfilehandler create 1 readable writable
- testfilehandler fillpartial 1
- set result ""
- testfilehandler oneevent
- lappend result [testfilehandler counts 1]
- testfilehandler oneevent
- lappend result [testfilehandler counts 1]
- testfilehandler oneevent
- lappend result [testfilehandler counts 1]
- testfilehandler create 1 disabled disabled
- testfilehandler oneevent
- lappend result [testfilehandler counts 1]
- testfilehandler close
- set result
-} {{0 1} {1 1} {1 2} {0 0}}
-test event-4.2 {FileHandlerEventProc, TCL_FILE_EVENTS off} \
- {testfilehandler nonPortable} {
- update
- testfilehandler close
- testfilehandler create 1 readable writable
- testfilehandler create 2 readable writable
- testfilehandler fillpartial 1
- testfilehandler fillpartial 2
- testfilehandler oneevent
- set result ""
- lappend result [testfilehandler counts 1] [testfilehandler counts 2]
- testfilehandler windowevent
- lappend result [testfilehandler counts 1] [testfilehandler counts 2]
- testfilehandler close
- set result
-} {{0 0} {0 1} {0 0} {0 1}}
-update
-
-test event-5.1 {Tcl_BackgroundError, HandleBgErrors procedures} {
- catch {rename bgerror {}}
- proc bgerror msg {
- global errorInfo errorCode x
- lappend x [list $msg $errorInfo $errorCode]
- }
- after idle {error "a simple error"}
- after idle {open non_existent}
- after idle {set errorInfo foobar; set errorCode xyzzy}
- set x {}
- update idletasks
- rename bgerror {}
- set x
-} {{{a simple error} {a simple error
- while executing
-"error "a simple error""
- ("after" script)} NONE} {{couldn't open "non_existent": no such file or directory} {couldn't open "non_existent": no such file or directory
- while executing
-"open non_existent"
- ("after" script)} {POSIX ENOENT {no such file or directory}}}}
-test event-5.2 {Tcl_BackgroundError, HandleBgErrors procedures} {
- catch {rename bgerror {}}
- proc bgerror msg {
- global x
- lappend x $msg
- return -code break
- }
- after idle {error "a simple error"}
- after idle {open non_existent}
- set x {}
- update idletasks
- rename bgerror {}
- set x
-} {{a simple error}}
-
-test event-6.1 {BgErrorDeleteProc procedure} {
- catch {interp delete foo}
- interp create foo
- foo eval {
- proc bgerror args {
- global errorInfo
- set f [open err.out r+]
- seek $f 0 end
- puts $f "$args $errorInfo"
- close $f
- }
- after 100 {error "first error"}
- after 100 {error "second error"}
- }
- makeFile Unmodified err.out
- after 100 {interp delete foo}
- after 200
- update
- set f [open err.out r]
- set result [read $f]
- close $f
- removeFile err.out
- set result
-} {Unmodified
-}
-
-test event-7.1 {bgerror / regular} {
- set errRes {}
- proc bgerror {err} {
- global errRes;
- set errRes $err;
- }
- after 0 {error err1}
- vwait errRes;
- set errRes;
-} err1
-
-test event-7.2 {bgerror / accumulation} {
- set errRes {}
- proc bgerror {err} {
- global errRes;
- lappend errRes $err;
- }
- after 0 {error err1}
- after 0 {error err2}
- after 0 {error err3}
- update
- set errRes;
-} {err1 err2 err3}
-
-test event-7.3 {bgerror / accumulation / break} {
- set errRes {}
- proc bgerror {err} {
- global errRes;
- lappend errRes $err;
- return -code break "skip!";
- }
- after 0 {error err1}
- after 0 {error err2}
- after 0 {error err3}
- update
- set errRes;
-} err1
-
-test event-7.4 {tkerror is nothing special anymore to tcl} {
- set errRes {}
- # we don't just rename bgerror to empty because it could then
- # be autoloaded...
- proc bgerror {err} {
- global errRes;
- lappend errRes "bg:$err";
- }
- proc tkerror {err} {
- global errRes;
- lappend errRes "tk:$err";
- }
- after 0 {error err1}
- update
- rename tkerror {}
- set errRes
-} bg:err1
-
-# someday : add a test checking that
-# when there is no bgerror, an error msg goes to stderr
-# ideally one would use sub interp and transfer a fake stderr
-# to it, unfortunatly the current interp tcl API does not allow
-# that. the other option would be to use fork a test but it
-# then becomes more a file/exec test than a bgerror test.
-
-# end of bgerror tests
-catch {rename bgerror {}}
-
-
-test event-8.1 {Tcl_CreateExitHandler procedure} {stdio testexithandler} {
- set child [open |[list [info nameofexecutable]] r+]
- puts $child "testexithandler create 41; testexithandler create 4"
- puts $child "testexithandler create 6; exit"
- flush $child
- set result [read $child]
- close $child
- set result
-} {even 6
-even 4
-odd 41
-}
-
-test event-9.1 {Tcl_DeleteExitHandler procedure} {stdio testexithandler} {
- set child [open |[list [info nameofexecutable]] r+]
- puts $child "testexithandler create 41; testexithandler create 4"
- puts $child "testexithandler create 6; testexithandler delete 41"
- puts $child "testexithandler create 16; exit"
- flush $child
- set result [read $child]
- close $child
- set result
-} {even 16
-even 6
-even 4
-}
-test event-9.2 {Tcl_DeleteExitHandler procedure} {stdio testexithandler} {
- set child [open |[list [info nameofexecutable]] r+]
- puts $child "testexithandler create 41; testexithandler create 4"
- puts $child "testexithandler create 6; testexithandler delete 4"
- puts $child "testexithandler create 16; exit"
- flush $child
- set result [read $child]
- close $child
- set result
- } {even 16
-even 6
-odd 41
-}
-test event-9.3 {Tcl_DeleteExitHandler procedure} {stdio testexithandler} {
- set child [open |[list [info nameofexecutable]] r+]
- puts $child "testexithandler create 41; testexithandler create 4"
- puts $child "testexithandler create 6; testexithandler delete 6"
- puts $child "testexithandler create 16; exit"
- flush $child
- set result [read $child]
- close $child
- set result
-} {even 16
-even 4
-odd 41
-}
-test event-9.4 {Tcl_DeleteExitHandler procedure} {stdio testexithandler} {
- set child [open |[list [info nameofexecutable]] r+]
- puts $child "testexithandler create 41; testexithandler delete 41"
- puts $child "testexithandler create 16; exit"
- flush $child
- set result [read $child]
- close $child
- set result
-} {even 16
-}
-
-test event-10.1 {Tcl_Exit procedure} {stdio} {
- set child [open |[list [info nameofexecutable]] r+]
- puts $child "exit 3"
- list [catch {close $child} msg] $msg [lindex $errorCode 0] \
- [lindex $errorCode 2]
-} {1 {child process exited abnormally} CHILDSTATUS 3}
-
-test event-11.1 {Tcl_VwaitCmd procedure} {
- list [catch {vwait} msg] $msg
-} {1 {wrong # args: should be "vwait name"}}
-test event-11.2 {Tcl_VwaitCmd procedure} {
- list [catch {vwait a b} msg] $msg
-} {1 {wrong # args: should be "vwait name"}}
-test event-11.3 {Tcl_VwaitCmd procedure} {
- catch {unset x}
- set x 1
- list [catch {vwait x(1)} msg] $msg
-} {1 {can't trace "x(1)": variable isn't array}}
-test event-11.4 {Tcl_VwaitCmd procedure} {
- foreach i [after info] {
- after cancel $i
- }
- after 10; update; # On Mac make sure update won't take long
- after 100 {set x x-done}
- after 200 {set y y-done}
- after 300 {set z z-done}
- after idle {set q q-done}
- set x before
- set y before
- set z before
- set q before
- list [vwait y] $x $y $z $q
-} {{} x-done y-done before q-done}
-
-foreach i [after info] {
- after cancel $i
-}
-
-test event-11.5 {Tcl_VwaitCmd procedure: round robin scheduling, 2 sources} {socket} {
- set f1 [open test1 w]
- proc accept {s args} {
- puts $s foobar
- close $s
- }
- set s1 [socket -server accept 5001]
- set s2 [socket 127.0.0.1 5001]
- close $s1
- set x 0
- set y 0
- set z 0
- fileevent $s2 readable { incr z }
- vwait z
- fileevent $f1 writable { incr x; if { $y == 3 } { set z done } }
- fileevent $s2 readable { incr y; if { $x == 3 } { set z done } }
- vwait z
- close $f1
- close $s2
- file delete test1 test2
- list $x $y $z
-} {3 3 done}
-test event-11.6 {Tcl_VwaitCmd procedure: round robin scheduling, same source} {
- file delete test1 test2
- set f1 [open test1 w]
- set f2 [open test2 w]
- set x 0
- set y 0
- set z 0
- update
- fileevent $f1 writable { incr x; if { $y == 3 } { set z done } }
- fileevent $f2 writable { incr y; if { $x == 3 } { set z done } }
- vwait z
- close $f1
- close $f2
- file delete test1 test2
- list $x $y $z
-} {3 3 done}
-
-
-test event-12.1 {Tcl_UpdateCmd procedure} {
- list [catch {update a b} msg] $msg
-} {1 {wrong # args: should be "update ?idletasks?"}}
-test event-12.2 {Tcl_UpdateCmd procedure} {
- list [catch {update bogus} msg] $msg
-} {1 {bad option "bogus": must be idletasks}}
-test event-12.3 {Tcl_UpdateCmd procedure} {
- foreach i [after info] {
- after cancel $i
- }
- after 500 {set x after}
- after idle {set y after}
- after idle {set z "after, y = $y"}
- set x before
- set y before
- set z before
- update idletasks
- list $x $y $z
-} {before after {after, y = after}}
-test event-12.4 {Tcl_UpdateCmd procedure} {
- foreach i [after info] {
- after cancel $i
- }
- after 10; update; # On Mac make sure update won't take long
- after 200 {set x x-done}
- after 600 {set y y-done}
- after idle {set z z-done}
- set x before
- set y before
- set z before
- after 300
- update
- list $x $y $z
-} {x-done before z-done}
-
-test event-13.1 {Tcl_WaitForFile procedure, readable} {testfilehandler} {
- foreach i [after info] {
- after cancel $i
- }
- after 100 set x timeout
- testfilehandler close
- testfilehandler create 1 off off
- set x "no timeout"
- set result [testfilehandler wait 1 readable 0]
- update
- testfilehandler close
- list $result $x
-} {{} {no timeout}}
-test event-13.2 {Tcl_WaitForFile procedure, readable} testfilehandler {
- foreach i [after info] {
- after cancel $i
- }
- after 100 set x timeout
- testfilehandler close
- testfilehandler create 1 off off
- set x "no timeout"
- set result [testfilehandler wait 1 readable 100]
- update
- testfilehandler close
- list $result $x
-} {{} timeout}
-test event-13.3 {Tcl_WaitForFile procedure, readable} testfilehandler {
- foreach i [after info] {
- after cancel $i
- }
- after 100 set x timeout
- testfilehandler close
- testfilehandler create 1 off off
- testfilehandler fillpartial 1
- set x "no timeout"
- set result [testfilehandler wait 1 readable 100]
- update
- testfilehandler close
- list $result $x
-} {readable {no timeout}}
-test event-13.4 {Tcl_WaitForFile procedure, writable} \
- {testfilehandler nonPortable} {
- foreach i [after info] {
- after cancel $i
- }
- after 100 set x timeout
- testfilehandler close
- testfilehandler create 1 off off
- testfilehandler fill 1
- set x "no timeout"
- set result [testfilehandler wait 1 writable 0]
- update
- testfilehandler close
- list $result $x
-} {{} {no timeout}}
-test event-13.5 {Tcl_WaitForFile procedure, writable} \
- {testfilehandler nonPortable} {
- foreach i [after info] {
- after cancel $i
- }
- after 100 set x timeout
- testfilehandler close
- testfilehandler create 1 off off
- testfilehandler fill 1
- set x "no timeout"
- set result [testfilehandler wait 1 writable 100]
- update
- testfilehandler close
- list $result $x
-} {{} timeout}
-test event-13.6 {Tcl_WaitForFile procedure, writable} testfilehandler {
- foreach i [after info] {
- after cancel $i
- }
- after 100 set x timeout
- testfilehandler close
- testfilehandler create 1 off off
- set x "no timeout"
- set result [testfilehandler wait 1 writable 100]
- update
- testfilehandler close
- list $result $x
-} {writable {no timeout}}
-test event-13.7 {Tcl_WaitForFile procedure, don't call other event handlers} testfilehandler {
- foreach i [after info] {
- after cancel $i
- }
- after 100 lappend x timeout
- after idle lappend x idle
- testfilehandler close
- testfilehandler create 1 off off
- set x ""
- set result [list [testfilehandler wait 1 readable 200] $x]
- update
- testfilehandler close
- lappend result $x
-} {{} {} {timeout idle}}
-
-test event-13.8 {Tcl_WaitForFile procedure, waiting indefinitely} testfilewait {
- set f [open "|sleep 2" r]
- set result ""
- lappend result [testfilewait $f readable 100]
- lappend result [testfilewait $f readable -1]
- close $f
- set result
-} {{} readable}
-
-# cleanup
-foreach i [after info] {
- after cancel $i
-}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/exec.test b/tests/exec.test
deleted file mode 100644
index ceb677b..0000000
--- a/tests/exec.test
+++ /dev/null
@@ -1,589 +0,0 @@
-# Commands covered: exec
-#
-# 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) 1991-1994 The Regents of the University of California.
-# Copyright (c) 1994-1997 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: exec.test,v 1.3 1999/04/16 00:47:27 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# All tests require the "exec" command.
-# Skip them if exec is not defined.
-set ::tcltest::testConfig(execCommandExists) [expr {[info commands exec] != ""}]
-
-set f [open echo w]
-puts $f {
- puts -nonewline [lindex $argv 0]
- foreach str [lrange $argv 1 end] {
- puts -nonewline " $str"
- }
- puts {}
-}
-close $f
-
-set f [open cat w]
-puts $f {
- if {$argv == {}} {
- set argv -
- }
- foreach name $argv {
- if {$name == "-"} {
- set f stdin
- } elseif {[catch {open $name r} f] != 0} {
- puts stderr $f
- continue
- }
- while {[eof $f] == 0} {
- puts -nonewline [read $f]
- }
- if {$f != "stdin"} {
- close $f
- }
- }
-}
-close $f
-
-set f [open wc w]
-puts $f {
- set data [read stdin]
- set lines [regsub -all "\n" $data {} dummy]
- set words [regsub -all "\[^ \t\n]+" $data {} dummy]
- set chars [string length $data]
- puts [format "%8.d%8.d%8.d" $lines $words $chars]
-}
-close $f
-
-set f [open sh w]
-puts $f {
- if {[lindex $argv 0] != "-c"} {
- error "sh: unexpected arguments $argv"
- }
- set cmd [lindex $argv 1]
- lappend cmd ";"
-
- set newcmd {}
-
- foreach arg $cmd {
- if {$arg == ";"} {
- eval exec >@stdout 2>@stderr [list [info nameofexecutable]] $newcmd
- set newcmd {}
- continue
- }
- if {$arg == "1>&2"} {
- set arg >@stderr
- }
- lappend newcmd $arg
- }
-}
-close $f
-
-set f [open sleep w]
-puts $f {
- after [expr $argv*1000]
-}
-close $f
-
-set f [open exit w]
-puts $f {
- exit $argv
-}
-close $f
-
-# Basic operations.
-
-test exec-1.1 {basic exec operation} {execCommandExists stdio} {
- exec $tcltest echo a b c
-} "a b c"
-test exec-1.2 {pipelining} {execCommandExists stdio} {
- exec $tcltest echo a b c d | $tcltest cat | $tcltest cat
-} "a b c d"
-test exec-1.3 {pipelining} {execCommandExists stdio} {
- set a [exec $tcltest echo a b c d | $tcltest cat | $tcltest wc]
- list [scan $a "%d %d %d" b c d] $b $c
-} {3 1 4}
-set arg {12345678901234567890123456789012345678901234567890}
-set arg "$arg$arg$arg$arg$arg$arg"
-test exec-1.4 {long command lines} {execCommandExists stdio} {
- exec $tcltest echo $arg
-} $arg
-set arg {}
-
-# I/O redirection: input from Tcl command.
-
-test exec-2.1 {redirecting input from immediate source} {execCommandExists stdio} {
- exec $tcltest cat << "Sample text"
-} {Sample text}
-test exec-2.2 {redirecting input from immediate source} {execCommandExists stdio} {
- exec << "Sample text" $tcltest cat | $tcltest cat
-} {Sample text}
-test exec-2.3 {redirecting input from immediate source} {execCommandExists stdio} {
- exec $tcltest cat << "Sample text" | $tcltest cat
-} {Sample text}
-test exec-2.4 {redirecting input from immediate source} {execCommandExists stdio} {
- exec $tcltest cat | $tcltest cat << "Sample text"
-} {Sample text}
-test exec-2.5 {redirecting input from immediate source} {execCommandExists stdio} {
- exec $tcltest cat "<<Joined to arrows"
-} {Joined to arrows}
-
-# I/O redirection: output to file.
-
-file delete gorp.file
-test exec-3.1 {redirecting output to file} {execCommandExists stdio} {
- exec $tcltest echo "Some simple words" > gorp.file
- exec $tcltest cat gorp.file
-} "Some simple words"
-test exec-3.2 {redirecting output to file} {execCommandExists stdio} {
- exec $tcltest echo "More simple words" | >gorp.file $tcltest cat | $tcltest cat
- exec $tcltest cat gorp.file
-} "More simple words"
-test exec-3.3 {redirecting output to file} {execCommandExists stdio} {
- exec > gorp.file $tcltest echo "Different simple words" | $tcltest cat | $tcltest cat
- exec $tcltest cat gorp.file
-} "Different simple words"
-test exec-3.4 {redirecting output to file} {execCommandExists stdio} {
- exec $tcltest echo "Some simple words" >gorp.file
- exec $tcltest cat gorp.file
-} "Some simple words"
-test exec-3.5 {redirecting output to file} {execCommandExists stdio} {
- exec $tcltest echo "First line" >gorp.file
- exec $tcltest echo "Second line" >> gorp.file
- exec $tcltest cat gorp.file
-} "First line\nSecond line"
-test exec-3.6 {redirecting output to file} {execCommandExists stdio} {
- exec $tcltest echo "First line" >gorp.file
- exec $tcltest echo "Second line" >>gorp.file
- exec $tcltest cat gorp.file
-} "First line\nSecond line"
-test exec-3.7 {redirecting output to file} {execCommandExists stdio} {
- set f [open gorp.file w]
- puts $f "Line 1"
- flush $f
- exec $tcltest echo "More text" >@ $f
- exec $tcltest echo >@$f "Even more"
- puts $f "Line 3"
- close $f
- exec $tcltest cat gorp.file
-} "Line 1\nMore text\nEven more\nLine 3"
-
-# I/O redirection: output and stderr to file.
-
-file delete gorp.file
-test exec-4.1 {redirecting output and stderr to file} {execCommandExists stdio} {
- exec $tcltest echo "test output" >& gorp.file
- exec $tcltest cat gorp.file
-} "test output"
-test exec-4.2 {redirecting output and stderr to file} {execCommandExists stdio} {
- list [exec $tcltest sh -c "echo foo bar 1>&2" >&gorp.file] \
- [exec $tcltest cat gorp.file]
-} {{} {foo bar}}
-test exec-4.3 {redirecting output and stderr to file} {execCommandExists stdio} {
- exec $tcltest echo "first line" > gorp.file
- list [exec $tcltest sh -c "echo foo bar 1>&2" >>&gorp.file] \
- [exec $tcltest cat gorp.file]
-} "{} {first line\nfoo bar}"
-test exec-4.4 {redirecting output and stderr to file} {execCommandExists stdio} {
- set f [open gorp.file w]
- puts $f "Line 1"
- flush $f
- exec $tcltest echo "More text" >&@ $f
- exec $tcltest echo >&@$f "Even more"
- puts $f "Line 3"
- close $f
- exec $tcltest cat gorp.file
-} "Line 1\nMore text\nEven more\nLine 3"
-test exec-4.5 {redirecting output and stderr to file} {execCommandExists stdio} {
- set f [open gorp.file w]
- puts $f "Line 1"
- flush $f
- exec >&@ $f $tcltest sh -c "echo foo bar 1>&2"
- exec >&@$f $tcltest sh -c "echo xyzzy 1>&2"
- puts $f "Line 3"
- close $f
- exec $tcltest cat gorp.file
-} "Line 1\nfoo bar\nxyzzy\nLine 3"
-
-# I/O redirection: input from file.
-
-exec $tcltest echo "Just a few thoughts" > gorp.file
-test exec-5.1 {redirecting input from file} {execCommandExists stdio} {
- exec $tcltest cat < gorp.file
-} {Just a few thoughts}
-test exec-5.2 {redirecting input from file} {execCommandExists stdio} {
- exec $tcltest cat | $tcltest cat < gorp.file
-} {Just a few thoughts}
-test exec-5.3 {redirecting input from file} {execCommandExists stdio} {
- exec $tcltest cat < gorp.file | $tcltest cat
-} {Just a few thoughts}
-test exec-5.4 {redirecting input from file} {execCommandExists stdio} {
- exec < gorp.file $tcltest cat | $tcltest cat
-} {Just a few thoughts}
-test exec-5.5 {redirecting input from file} {execCommandExists stdio} {
- exec $tcltest cat <gorp.file
-} {Just a few thoughts}
-test exec-5.6 {redirecting input from file} {execCommandExists stdio} {
- set f [open gorp.file r]
- set result [exec $tcltest cat <@ $f]
- close $f
- set result
-} {Just a few thoughts}
-test exec-5.7 {redirecting input from file} {execCommandExists stdio} {
- set f [open gorp.file r]
- set result [exec <@$f $tcltest cat]
- close $f
- set result
-} {Just a few thoughts}
-
-# I/O redirection: standard error through a pipeline.
-
-test exec-6.1 {redirecting stderr through a pipeline} {execCommandExists stdio} {
- exec $tcltest sh -c "echo foo bar" |& $tcltest cat
-} "foo bar"
-test exec-6.2 {redirecting stderr through a pipeline} {execCommandExists stdio} {
- exec $tcltest sh -c "echo foo bar 1>&2" |& $tcltest cat
-} "foo bar"
-test exec-6.3 {redirecting stderr through a pipeline} {execCommandExists stdio} {
- exec $tcltest sh -c "echo foo bar 1>&2" \
- |& $tcltest sh -c "echo second msg 1>&2 ; cat" |& $tcltest cat
-} "second msg\nfoo bar"
-
-# I/O redirection: combinations.
-
-file delete gorp.file2
-test exec-7.1 {multiple I/O redirections} {execCommandExists stdio} {
- exec << "command input" > gorp.file2 $tcltest cat < gorp.file
- exec $tcltest cat gorp.file2
-} {Just a few thoughts}
-test exec-7.2 {multiple I/O redirections} {execCommandExists stdio} {
- exec < gorp.file << "command input" $tcltest cat
-} {command input}
-
-# Long input to command and output from command.
-
-set a "0123456789 xxxxxxxxx abcdefghi ABCDEFGHIJK\n"
-set a [concat $a $a $a $a]
-set a [concat $a $a $a $a]
-set a [concat $a $a $a $a]
-set a [concat $a $a $a $a]
-test exec-8.1 {long input and output} {execCommandExists stdio} {
- exec $tcltest cat << $a
-} $a
-
-# More than 20 arguments to exec.
-
-test exec-8.1 {long input and output} {execCommandExists stdio} {
- exec $tcltest echo 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
-} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23}
-
-# Commands that return errors.
-
-test exec-9.1 {commands returning errors} {execCommandExists stdio} {
- set x [catch {exec gorp456} msg]
- list $x [string tolower $msg] [string tolower $errorCode]
-} {1 {couldn't execute "gorp456": no such file or directory} {posix enoent {no such file or directory}}}
-test exec-9.2 {commands returning errors} {execCommandExists stdio} {
- string tolower [list [catch {exec $tcltest echo foo | foo123} msg] $msg $errorCode]
-} {1 {couldn't execute "foo123": no such file or directory} {posix enoent {no such file or directory}}}
-test exec-9.3 {commands returning errors} {execCommandExists stdio} {
- list [catch {exec $tcltest sleep 1 | $tcltest exit 43 | $tcltest sleep 1} msg] $msg
-} {1 {child process exited abnormally}}
-test exec-9.4 {commands returning errors} {execCommandExists stdio} {
- list [catch {exec $tcltest exit 43 | $tcltest echo "foo bar"} msg] $msg
-} {1 {foo bar
-child process exited abnormally}}
-test exec-9.5 {commands returning errors} {execCommandExists stdio} {
- list [catch {exec gorp456 | $tcltest echo a b c} msg] [string tolower $msg]
-} {1 {couldn't execute "gorp456": no such file or directory}}
-test exec-9.6 {commands returning errors} {execCommandExists stdio} {
- list [catch {exec $tcltest sh -c "echo error msg 1>&2"} msg] $msg
-} {1 {error msg}}
-test exec-9.7 {commands returning errors} {execCommandExists stdio} {
- list [catch {exec $tcltest sh -c "echo error msg 1>&2" \
- | $tcltest sh -c "echo error msg 1>&2"} msg] $msg
-} {1 {error msg
-error msg}}
-test exec-9.8 {commands returning errors} {execCommandExists stdio} {
- set f [open err w]
- puts $f {
- puts stdout out
- puts stderr err
- }
- close $f
- list [catch {exec $tcltest err} msg] $msg
-} {1 {out
-err}}
-
-# Errors in executing the Tcl command, as opposed to errors in the
-# processes that are invoked.
-
-test exec-10.1 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec} msg] $msg
-} {1 {wrong # args: should be "exec ?switches? arg ?arg ...?"}}
-test exec-10.2 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec | cat} msg] $msg
-} {1 {illegal use of | or |& in command}}
-test exec-10.3 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat |} msg] $msg
-} {1 {illegal use of | or |& in command}}
-test exec-10.4 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat | | cat} msg] $msg
-} {1 {illegal use of | or |& in command}}
-test exec-10.5 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat | |& cat} msg] $msg
-} {1 {illegal use of | or |& in command}}
-test exec-10.6 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat |&} msg] $msg
-} {1 {illegal use of | or |& in command}}
-test exec-10.7 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat <} msg] $msg
-} {1 {can't specify "<" as last word in command}}
-test exec-10.8 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat >} msg] $msg
-} {1 {can't specify ">" as last word in command}}
-test exec-10.9 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat <<} msg] $msg
-} {1 {can't specify "<<" as last word in command}}
-test exec-10.10 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat >>} msg] $msg
-} {1 {can't specify ">>" as last word in command}}
-test exec-10.11 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat >&} msg] $msg
-} {1 {can't specify ">&" as last word in command}}
-test exec-10.12 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat >>&} msg] $msg
-} {1 {can't specify ">>&" as last word in command}}
-test exec-10.13 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat >@} msg] $msg
-} {1 {can't specify ">@" as last word in command}}
-test exec-10.14 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat <@} msg] $msg
-} {1 {can't specify "<@" as last word in command}}
-test exec-10.15 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat < a/b/c} msg] [string tolower $msg]
-} {1 {couldn't read file "a/b/c": no such file or directory}}
-test exec-10.16 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat << foo > a/b/c} msg] [string tolower $msg]
-} {1 {couldn't write file "a/b/c": no such file or directory}}
-test exec-10.17 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat << foo > a/b/c} msg] [string tolower $msg]
-} {1 {couldn't write file "a/b/c": no such file or directory}}
-set f [open gorp.file w]
-test exec-10.18 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat <@ $f} msg] $msg
-} "1 {channel \"$f\" wasn't opened for reading}"
-close $f
-set f [open gorp.file r]
-test exec-10.19 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec cat >@ $f} msg] $msg
-} "1 {channel \"$f\" wasn't opened for writing}"
-close $f
-test exec-10.20 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec ~non_existent_user/foo/bar} msg] $msg
-} {1 {user "non_existent_user" doesn't exist}}
-test exec-10.21 {errors in exec invocation} {execCommandExists stdio} {
- list [catch {exec $tcltest true | ~xyzzy_bad_user/x | false} msg] $msg
-} {1 {user "xyzzy_bad_user" doesn't exist}}
-
-# Commands in background.
-
-test exec-11.1 {commands in background} {execCommandExists stdio} {
- set x [lindex [time {exec $tcltest sleep 2 &}] 0]
- expr $x<1000000
-} 1
-test exec-11.2 {commands in background} {execCommandExists stdio} {
- list [catch {exec $tcltest echo a &b} msg] $msg
-} {0 {a &b}}
-test exec-11.3 {commands in background} {execCommandExists stdio} {
- llength [exec $tcltest sleep 1 &]
-} 1
-test exec-11.4 {commands in background} {execCommandExists stdio} {
- llength [exec $tcltest sleep 1 | $tcltest sleep 1 | $tcltest sleep 1 &]
-} 3
-test exec-11.5 {commands in background} {execCommandExists stdio} {
- set f [open gorp.file w]
- puts $f { catch { exec [info nameofexecutable] echo foo & } }
- close $f
- string compare "foo" [exec $tcltest gorp.file]
-} 0
-
-# Make sure that background commands are properly reaped when
-# they eventually die.
-
-exec $tcltest sleep 3
-test exec-12.1 {reaping background processes} \
- {execCommandExists stdio unixOnly nonPortable} {
- for {set i 0} {$i < 20} {incr i} {
- exec echo foo > /dev/null &
- }
- exec sleep 1
- catch {exec ps | fgrep "echo foo" | fgrep -v fgrep | wc} msg
- lindex $msg 0
-} 0
-test exec-12.2 {reaping background processes} \
- {execCommandExists stdio unixOnly nonPortable} {
- exec sleep 2 | sleep 2 | sleep 2 &
- catch {exec ps | fgrep -i "sleep" | fgrep -i -v fgrep | wc} msg
- set x [lindex $msg 0]
- exec sleep 3
- catch {exec ps | fgrep -i "sleep" | fgrep -i -v fgrep | wc} msg
- list $x [lindex $msg 0]
-} {3 0}
-test exec-12.3 {reaping background processes} \
- {execCommandExists stdio unixOnly nonPortable} {
- exec sleep 1000 &
- exec sleep 1000 &
- set x [exec ps | fgrep "sleep" | fgrep -v fgrep]
- set pids {}
- foreach i [split $x \n] {
- lappend pids [lindex $i 0]
- }
- foreach i $pids {
- catch {exec kill -STOP $i}
- }
- catch {exec ps | fgrep "sleep" | fgrep -v fgrep | wc} msg
- set x [lindex $msg 0]
-
- foreach i $pids {
- catch {exec kill -KILL $i}
- }
- catch {exec ps | fgrep "sleep" | fgrep -v fgrep | wc} msg
- list $x [lindex $msg 0]
-} {2 0}
-
-# Make sure "errorCode" is set correctly.
-
-test exec-13.1 {setting errorCode variable} {execCommandExists stdio} {
- list [catch {exec $tcltest cat < a/b/c} msg] [string tolower $errorCode]
-} {1 {posix enoent {no such file or directory}}}
-test exec-13.2 {setting errorCode variable} {execCommandExists stdio} {
- list [catch {exec $tcltest cat > a/b/c} msg] [string tolower $errorCode]
-} {1 {posix enoent {no such file or directory}}}
-test exec-13.3 {setting errorCode variable} {execCommandExists stdio} {
- set x [catch {exec _weird_cmd_} msg]
- list $x [string tolower $msg] [lindex $errorCode 0] \
- [string tolower [lrange $errorCode 2 end]]
-} {1 {couldn't execute "_weird_cmd_": no such file or directory} POSIX {{no such file or directory}}}
-
-# Switches before the first argument
-
-test exec-14.1 {-keepnewline switch} {execCommandExists stdio} {
- exec -keepnewline $tcltest echo foo
-} "foo\n"
-test exec-14.2 {-keepnewline switch} {execCommandExists stdio} {
- list [catch {exec -keepnewline} msg] $msg
-} {1 {wrong # args: should be "exec ?switches? arg ?arg ...?"}}
-test exec-14.3 {unknown switch} {execCommandExists stdio} {
- list [catch {exec -gorp} msg] $msg
-} {1 {bad switch "-gorp": must be -keepnewline or --}}
-test exec-14.4 {-- switch} {execCommandExists stdio} {
- list [catch {exec -- -gorp} msg] [string tolower $msg]
-} {1 {couldn't execute "-gorp": no such file or directory}}
-
-# Redirecting standard error separately from standard output
-
-test exec-15.1 {standard error redirection} {execCommandExists stdio} {
- exec $tcltest echo "First line" > gorp.file
- list [exec $tcltest sh -c "echo foo bar 1>&2" 2> gorp.file] \
- [exec $tcltest cat gorp.file]
-} {{} {foo bar}}
-test exec-15.2 {standard error redirection} {execCommandExists stdio} {
- list [exec $tcltest sh -c "echo foo bar 1>&2" \
- | $tcltest echo biz baz >gorp.file 2> gorp.file2] \
- [exec $tcltest cat gorp.file] \
- [exec $tcltest cat gorp.file2]
-} {{} {biz baz} {foo bar}}
-test exec-15.3 {standard error redirection} {execCommandExists stdio} {
- list [exec $tcltest sh -c "echo foo bar 1>&2" \
- | $tcltest echo biz baz 2>gorp.file > gorp.file2] \
- [exec $tcltest cat gorp.file] \
- [exec $tcltest cat gorp.file2]
-} {{} {foo bar} {biz baz}}
-test exec-15.4 {standard error redirection} {execCommandExists stdio} {
- set f [open gorp.file w]
- puts $f "Line 1"
- flush $f
- exec $tcltest sh -c "echo foo bar 1>&2" 2>@ $f
- puts $f "Line 3"
- close $f
- exec $tcltest cat gorp.file
-} {Line 1
-foo bar
-Line 3}
-test exec-15.5 {standard error redirection} {execCommandExists stdio} {
- exec $tcltest echo "First line" > gorp.file
- exec $tcltest sh -c "echo foo bar 1>&2" 2>> gorp.file
- exec $tcltest cat gorp.file
-} {First line
-foo bar}
-test exec-15.6 {standard error redirection} {execCommandExists stdio} {
- exec $tcltest sh -c "echo foo bar 1>&2" > gorp.file2 2> gorp.file \
- >& gorp.file 2> gorp.file2 | $tcltest echo biz baz
- list [exec $tcltest cat gorp.file] [exec $tcltest cat gorp.file2]
-} {{biz baz} {foo bar}}
-
-test exec-16.1 {flush output before exec} {execCommandExists stdio} {
- set f [open gorp.file w]
- puts $f "First line"
- exec $tcltest echo "Second line" >@ $f
- puts $f "Third line"
- close $f
- exec $tcltest cat gorp.file
-} {First line
-Second line
-Third line}
-test exec-16.2 {flush output before exec} {execCommandExists stdio} {
- set f [open gorp.file w]
- puts $f "First line"
- exec $tcltest << {puts stderr {Second line}} >&@ $f > gorp.file2
- puts $f "Third line"
- close $f
- exec $tcltest cat gorp.file
-} {First line
-Second line
-Third line}
-
-test exec-17.1 { inheriting standard I/O } {execCommandExists stdio} {
- set f [open script w]
- puts $f {close stdout
- set f [open gorp.file w]
- catch {exec [info nameofexecutable] echo foobar &}
- exec [info nameofexecutable] sleep 2
- close $f
- }
- close $f
- catch {exec $tcltest script} result
- set f [open gorp.file r]
- lappend result [read $f]
- close $f
- set result
-} {{foobar
-}}
-
-# cleanup
-file delete script gorp.file gorp.file2
-file delete echo cat wc sh sleep exit
-file delete err
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/execute.test b/tests/execute.test
deleted file mode 100644
index aebe67b..0000000
--- a/tests/execute.test
+++ /dev/null
@@ -1,548 +0,0 @@
-# This file contains tests for the tclExecute.c source file. Tests appear
-# in the same order as the C code that they test. The set of tests is
-# currently incomplete since it currently includes only new tests for
-# code changed for the addition of Tcl namespaces. Other execution-
-# related tests appear in several other test files including
-# namespace.test, basic.test, eval.test, for.test, etc.
-#
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 1997 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: execute.test,v 1.3 1999/04/16 00:47:27 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-catch {eval namespace delete [namespace children :: test_ns_*]}
-catch {rename foo ""}
-catch {unset x}
-catch {unset y}
-catch {unset msg}
-
-set ::tcltest::testConfig(testobj) \
- [expr {[info commands testobj] != {} \
- && [info commands testdoubleobj] != {} \
- && [info commands teststringobj] != {} \
- && [info commands testobj] != {}}]
-
-# Tests for the omnibus TclExecuteByteCode function:
-
-# INST_DONE not tested
-# INST_PUSH1 not tested
-# INST_PUSH4 not tested
-# INST_POP not tested
-# INST_DUP not tested
-# INST_CONCAT1 not tested
-# INST_INVOKE_STK4 not tested
-# INST_INVOKE_STK1 not tested
-# INST_EVAL_STK not tested
-# INST_EXPR_STK not tested
-# INST_LOAD_SCALAR1 not tested
-# INST_LOAD_SCALAR4 not tested
-# INST_LOAD_SCALAR_STK not tested
-# INST_LOAD_ARRAY4 not tested
-# INST_LOAD_ARRAY1 not tested
-# INST_LOAD_ARRAY_STK not tested
-# INST_LOAD_STK not tested
-# INST_STORE_SCALAR4 not tested
-# INST_STORE_SCALAR1 not tested
-# INST_STORE_SCALAR_STK not tested
-# INST_STORE_ARRAY4 not tested
-# INST_STORE_ARRAY1 not tested
-# INST_STORE_ARRAY_STK not tested
-# INST_STORE_STK not tested
-# INST_INCR_SCALAR1 not tested
-# INST_INCR_SCALAR_STK not tested
-# INST_INCR_STK not tested
-# INST_INCR_ARRAY1 not tested
-# INST_INCR_ARRAY_STK not tested
-# INST_INCR_SCALAR1_IMM not tested
-# INST_INCR_SCALAR_STK_IMM not tested
-# INST_INCR_STK_IMM not tested
-# INST_INCR_ARRAY1_IMM not tested
-# INST_INCR_ARRAY_STK_IMM not tested
-# INST_JUMP1 not tested
-# INST_JUMP4 not tested
-# INST_JUMP_TRUE4 not tested
-# INST_JUMP_TRUE1 not tested
-# INST_JUMP_FALSE4 not tested
-# INST_JUMP_FALSE1 not tested
-# INST_LOR not tested
-# INST_LAND not tested
-# INST_EQ not tested
-# INST_NEQ not tested
-# INST_LT not tested
-# INST_GT not tested
-# INST_LE not tested
-# INST_GE not tested
-# INST_MOD not tested
-# INST_LSHIFT not tested
-# INST_RSHIFT not tested
-# INST_BITOR not tested
-# INST_BITXOR not tested
-# INST_BITAND not tested
-
-# INST_ADD is partially tested:
-test execute-1.1 {TclExecuteByteCode, INST_ADD, op1 is int} {testobj} {
- set x [testintobj set 0 1]
- expr {$x + 1}
-} 2
-test execute-1.2 {TclExecuteByteCode, INST_ADD, op1 is double} {testobj} {
- set x [testdoubleobj set 0 1]
- expr {$x + 1}
-} 2.0
-test execute-1.3 {TclExecuteByteCode, INST_ADD, op1 is double with string} {testobj} {
- set x [testintobj set 0 1]
- testobj convert 0 double
- expr {$x + 1}
-} 2
-test execute-1.4 {TclExecuteByteCode, INST_ADD, op1 is string int} {testobj} {
- set x [teststringobj set 0 1]
- expr {$x + 1}
-} 2
-test execute-1.5 {TclExecuteByteCode, INST_ADD, op1 is string double} {testobj} {
- set x [teststringobj set 0 1.0]
- expr {$x + 1}
-} 2.0
-test execute-1.6 {TclExecuteByteCode, INST_ADD, op1 is non-numeric} {testobj} {
- set x [teststringobj set 0 foo]
- list [catch {expr {$x + 1}} msg] $msg
-} {1 {can't use non-numeric string as operand of "+"}}
-test execute-1.7 {TclExecuteByteCode, INST_ADD, op2 is int} {testobj} {
- set x [testintobj set 0 1]
- expr {1 + $x}
-} 2
-test execute-1.8 {TclExecuteByteCode, INST_ADD, op2 is double} {testobj} {
- set x [testdoubleobj set 0 1]
- expr {1 + $x}
-} 2.0
-test execute-1.9 {TclExecuteByteCode, INST_ADD, op2 is double with string} {testobj} {
- set x [testintobj set 0 1]
- testobj convert 0 double
- expr {1 + $x}
-} 2
-test execute-1.10 {TclExecuteByteCode, INST_ADD, op2 is string int} {testobj} {
- set x [teststringobj set 0 1]
- expr {1 + $x}
-} 2
-test execute-1.11 {TclExecuteByteCode, INST_ADD, op2 is string double} {testobj} {
- set x [teststringobj set 0 1.0]
- expr {1 + $x}
-} 2.0
-test execute-1.12 {TclExecuteByteCode, INST_ADD, op2 is non-numeric} {testobj} {
- set x [teststringobj set 0 foo]
- list [catch {expr {1 + $x}} msg] $msg
-} {1 {can't use non-numeric string as operand of "+"}}
-
-# INST_SUB is partially tested:
-test execute-1.13 {TclExecuteByteCode, INST_SUB, op1 is int} {testobj} {
- set x [testintobj set 0 1]
- expr {$x - 1}
-} 0
-test execute-1.14 {TclExecuteByteCode, INST_SUB, op1 is double} {testobj} {
- set x [testdoubleobj set 0 1]
- expr {$x - 1}
-} 0.0
-test execute-1.15 {TclExecuteByteCode, INST_SUB, op1 is double with string} {testobj} {
- set x [testintobj set 0 1]
- testobj convert 0 double
- expr {$x - 1}
-} 0
-test execute-1.16 {TclExecuteByteCode, INST_SUB, op1 is string int} {testobj} {
- set x [teststringobj set 0 1]
- expr {$x - 1}
-} 0
-test execute-1.17 {TclExecuteByteCode, INST_SUB, op1 is string double} {testobj} {
- set x [teststringobj set 0 1.0]
- expr {$x - 1}
-} 0.0
-test execute-1.18 {TclExecuteByteCode, INST_SUB, op1 is non-numeric} {testobj} {
- set x [teststringobj set 0 foo]
- list [catch {expr {$x - 1}} msg] $msg
-} {1 {can't use non-numeric string as operand of "-"}}
-test execute-1.19 {TclExecuteByteCode, INST_SUB, op2 is int} {testobj} {
- set x [testintobj set 0 1]
- expr {1 - $x}
-} 0
-test execute-1.20 {TclExecuteByteCode, INST_SUB, op2 is double} {testobj} {
- set x [testdoubleobj set 0 1]
- expr {1 - $x}
-} 0.0
-test execute-1.21 {TclExecuteByteCode, INST_SUB, op2 is double with string} {testobj} {
- set x [testintobj set 0 1]
- testobj convert 0 double
- expr {1 - $x}
-} 0
-test execute-1.22 {TclExecuteByteCode, INST_SUB, op2 is string int} {testobj} {
- set x [teststringobj set 0 1]
- expr {1 - $x}
-} 0
-test execute-1.23 {TclExecuteByteCode, INST_SUB, op2 is string double} {testobj} {
- set x [teststringobj set 0 1.0]
- expr {1 - $x}
-} 0.0
-test execute-1.24 {TclExecuteByteCode, INST_SUB, op2 is non-numeric} {testobj} {
- set x [teststringobj set 0 foo]
- list [catch {expr {1 - $x}} msg] $msg
-} {1 {can't use non-numeric string as operand of "-"}}
-
-# INST_MULT is partially tested:
-test execute-1.25 {TclExecuteByteCode, INST_MULT, op1 is int} {testobj} {
- set x [testintobj set 1 1]
- expr {$x * 1}
-} 1
-test execute-1.26 {TclExecuteByteCode, INST_MULT, op1 is double} {testobj} {
- set x [testdoubleobj set 1 2.0]
- expr {$x * 1}
-} 2.0
-test execute-1.27 {TclExecuteByteCode, INST_MULT, op1 is double with string} {testobj} {
- set x [testintobj set 1 2]
- testobj convert 1 double
- expr {$x * 1}
-} 2
-test execute-1.28 {TclExecuteByteCode, INST_MULT, op1 is string int} {testobj} {
- set x [teststringobj set 1 1]
- expr {$x * 1}
-} 1
-test execute-1.29 {TclExecuteByteCode, INST_MULT, op1 is string double} {testobj} {
- set x [teststringobj set 1 1.0]
- expr {$x * 1}
-} 1.0
-test execute-1.30 {TclExecuteByteCode, INST_MULT, op1 is non-numeric} {testobj} {
- set x [teststringobj set 1 foo]
- list [catch {expr {$x * 1}} msg] $msg
-} {1 {can't use non-numeric string as operand of "*"}}
-test execute-1.31 {TclExecuteByteCode, INST_MULT, op2 is int} {testobj} {
- set x [testintobj set 1 1]
- expr {1 * $x}
-} 1
-test execute-1.32 {TclExecuteByteCode, INST_MULT, op2 is double} {testobj} {
- set x [testdoubleobj set 1 2.0]
- expr {1 * $x}
-} 2.0
-test execute-1.33 {TclExecuteByteCode, INST_MULT, op2 is double with string} {testobj} {
- set x [testintobj set 1 2]
- testobj convert 1 double
- expr {1 * $x}
-} 2
-test execute-1.34 {TclExecuteByteCode, INST_MULT, op2 is string int} {testobj} {
- set x [teststringobj set 1 1]
- expr {1 * $x}
-} 1
-test execute-1.35 {TclExecuteByteCode, INST_MULT, op2 is string double} {testobj} {
- set x [teststringobj set 1 1.0]
- expr {1 * $x}
-} 1.0
-test execute-1.36 {TclExecuteByteCode, INST_MULT, op2 is non-numeric} {testobj} {
- set x [teststringobj set 1 foo]
- list [catch {expr {1 * $x}} msg] $msg
-} {1 {can't use non-numeric string as operand of "*"}}
-
-# INST_DIV is partially tested:
-test execute-1.37 {TclExecuteByteCode, INST_DIV, op1 is int} {testobj} {
- set x [testintobj set 1 1]
- expr {$x / 1}
-} 1
-test execute-1.38 {TclExecuteByteCode, INST_DIV, op1 is double} {testobj} {
- set x [testdoubleobj set 1 2.0]
- expr {$x / 1}
-} 2.0
-test execute-1.39 {TclExecuteByteCode, INST_DIV, op1 is double with string} {testobj} {
- set x [testintobj set 1 2]
- testobj convert 1 double
- expr {$x / 1}
-} 2
-test execute-1.40 {TclExecuteByteCode, INST_DIV, op1 is string int} {testobj} {
- set x [teststringobj set 1 1]
- expr {$x / 1}
-} 1
-test execute-1.41 {TclExecuteByteCode, INST_DIV, op1 is string double} {testobj} {
- set x [teststringobj set 1 1.0]
- expr {$x / 1}
-} 1.0
-test execute-1.42 {TclExecuteByteCode, INST_DIV, op1 is non-numeric} {testobj} {
- set x [teststringobj set 1 foo]
- list [catch {expr {$x / 1}} msg] $msg
-} {1 {can't use non-numeric string as operand of "/"}}
-test execute-1.43 {TclExecuteByteCode, INST_DIV, op2 is int} {testobj} {
- set x [testintobj set 1 1]
- expr {2 / $x}
-} 2
-test execute-1.44 {TclExecuteByteCode, INST_DIV, op2 is double} {testobj} {
- set x [testdoubleobj set 1 1.0]
- expr {2 / $x}
-} 2.0
-test execute-1.45 {TclExecuteByteCode, INST_DIV, op2 is double with string} {testobj} {
- set x [testintobj set 1 1]
- testobj convert 1 double
- expr {2 / $x}
-} 2
-test execute-1.46 {TclExecuteByteCode, INST_DIV, op2 is string int} {testobj} {
- set x [teststringobj set 1 1]
- expr {2 / $x}
-} 2
-test execute-1.47 {TclExecuteByteCode, INST_DIV, op2 is string double} {testobj} {
- set x [teststringobj set 1 1.0]
- expr {2 / $x}
-} 2.0
-test execute-1.48 {TclExecuteByteCode, INST_DIV, op2 is non-numeric} {testobj} {
- set x [teststringobj set 1 foo]
- list [catch {expr {1 / $x}} msg] $msg
-} {1 {can't use non-numeric string as operand of "/"}}
-
-# INST_UPLUS is partially tested:
-test execute-1.49 {TclExecuteByteCode, INST_UPLUS, op is int} {testobj} {
- set x [testintobj set 1 1]
- expr {+ $x}
-} 1
-test execute-1.50 {TclExecuteByteCode, INST_UPLUS, op is double} {testobj} {
- set x [testdoubleobj set 1 1.0]
- expr {+ $x}
-} 1.0
-test execute-1.51 {TclExecuteByteCode, INST_UPLUS, op is double with string} {testobj} {
- set x [testintobj set 1 1]
- testobj convert 1 double
- expr {+ $x}
-} 1
-test execute-1.52 {TclExecuteByteCode, INST_UPLUS, op is string int} {testobj} {
- set x [teststringobj set 1 1]
- expr {+ $x}
-} 1
-test execute-1.53 {TclExecuteByteCode, INST_UPLUS, op is string double} {testobj} {
- set x [teststringobj set 1 1.0]
- expr {+ $x}
-} 1.0
-test execute-1.54 {TclExecuteByteCode, INST_UPLUS, op is non-numeric} {testobj} {
- set x [teststringobj set 1 foo]
- list [catch {expr {+ $x}} msg] $msg
-} {1 {can't use non-numeric string as operand of "+"}}
-
-# INST_UMINUS is partially tested:
-test execute-1.55 {TclExecuteByteCode, INST_UMINUS, op is int} {testobj} {
- set x [testintobj set 1 1]
- expr {- $x}
-} -1
-test execute-1.56 {TclExecuteByteCode, INST_UMINUS, op is double} {testobj} {
- set x [testdoubleobj set 1 1.0]
- expr {- $x}
-} -1.0
-test execute-1.57 {TclExecuteByteCode, INST_UMINUS, op is double with string} {testobj} {
- set x [testintobj set 1 1]
- testobj convert 1 double
- expr {- $x}
-} -1
-test execute-1.58 {TclExecuteByteCode, INST_UMINUS, op is string int} {testobj} {
- set x [teststringobj set 1 1]
- expr {- $x}
-} -1
-test execute-1.59 {TclExecuteByteCode, INST_UMINUS, op is string double} {testobj} {
- set x [teststringobj set 1 1.0]
- expr {- $x}
-} -1.0
-test execute-1.60 {TclExecuteByteCode, INST_UMINUS, op is non-numeric} {testobj} {
- set x [teststringobj set 1 foo]
- list [catch {expr {- $x}} msg] $msg
-} {1 {can't use non-numeric string as operand of "-"}}
-
-# INST_LNOT is partially tested:
-test execute-1.61 {TclExecuteByteCode, INST_LNOT, op is int} {testobj} {
- set x [testintobj set 1 2]
- expr {! $x}
-} 0
-test execute-1.62 {TclExecuteByteCode, INST_LNOT, op is int} {testobj} {
- set x [testintobj set 1 0]
- expr {! $x}
-} 1
-test execute-1.63 {TclExecuteByteCode, INST_LNOT, op is double} {testobj} {
- set x [testdoubleobj set 1 1.0]
- expr {! $x}
-} 0
-test execute-1.64 {TclExecuteByteCode, INST_LNOT, op is double} {testobj} {
- set x [testdoubleobj set 1 0.0]
- expr {! $x}
-} 1
-test execute-1.65 {TclExecuteByteCode, INST_LNOT, op is double with string} {testobj} {
- set x [testintobj set 1 1]
- testobj convert 1 double
- expr {! $x}
-} 0
-test execute-1.66 {TclExecuteByteCode, INST_LNOT, op is double with string} {testobj} {
- set x [testintobj set 1 0]
- testobj convert 1 double
- expr {! $x}
-} 1
-test execute-1.67 {TclExecuteByteCode, INST_LNOT, op is string int} {testobj} {
- set x [teststringobj set 1 1]
- expr {! $x}
-} 0
-test execute-1.68 {TclExecuteByteCode, INST_LNOT, op is string int} {testobj} {
- set x [teststringobj set 1 0]
- expr {! $x}
-} 1
-test execute-1.69 {TclExecuteByteCode, INST_LNOT, op is string double} {testobj} {
- set x [teststringobj set 1 1.0]
- expr {! $x}
-} 0
-test execute-1.70 {TclExecuteByteCode, INST_LNOT, op is string double} {testobj} {
- set x [teststringobj set 1 0.0]
- expr {! $x}
-} 1
-test execute-1.71 {TclExecuteByteCode, INST_LNOT, op is non-numeric} {testobj} {
- set x [teststringobj set 1 foo]
- list [catch {expr {! $x}} msg] $msg
-} {1 {can't use non-numeric string as operand of "!"}}
-
-# INST_BITNOT not tested
-# INST_CALL_BUILTIN_FUNC1 not tested
-# INST_CALL_FUNC1 not tested
-
-# INST_TRY_CVT_TO_NUMERIC is partially tested:
-test execute-1.72 {TclExecuteByteCode, INST_TRY_CVT_TO_NUMERIC, op is int} {testobj} {
- set x [testintobj set 1 1]
- expr {$x}
-} 1
-test execute-1.73 {TclExecuteByteCode, INST_TRY_CVT_TO_NUMERIC, op is double} {testobj} {
- set x [testdoubleobj set 1 1.0]
- expr {$x}
-} 1.0
-test execute-1.74 {TclExecuteByteCode, INST_TRY_CVT_TO_NUMERIC, op is double with string} {testobj} {
- set x [testintobj set 1 1]
- testobj convert 1 double
- expr {$x}
-} 1
-test execute-1.75 {TclExecuteByteCode, INST_TRY_CVT_TO_NUMERIC, op is string int} {testobj} {
- set x [teststringobj set 1 1]
- expr {$x}
-} 1
-test execute-1.76 {TclExecuteByteCode, INST_TRY_CVT_TO_NUMERIC, op is string double} {testobj} {
- set x [teststringobj set 1 1.0]
- expr {$x}
-} 1.0
-test execute-1.77 {TclExecuteByteCode, INST_TRY_CVT_TO_NUMERIC, op is non-numeric} {testobj} {
- set x [teststringobj set 1 foo]
- expr {$x}
-} foo
-
-# INST_BREAK not tested
-# INST_CONTINUE not tested
-# INST_FOREACH_START4 not tested
-# INST_FOREACH_STEP4 not tested
-# INST_BEGIN_CATCH4 not tested
-# INST_END_CATCH not tested
-# INST_PUSH_RESULT not tested
-# INST_PUSH_RETURN_CODE not tested
-
-test execute-2.1 {Tcl_GetCommandFromObj, convert to tclCmdNameType} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {unset x}
- catch {unset y}
- namespace eval test_ns_1 {
- namespace export cmd1
- proc cmd1 {args} {return "cmd1: $args"}
- proc cmd2 {args} {return "cmd2: $args"}
- }
- namespace eval test_ns_1::test_ns_2 {
- namespace import ::test_ns_1::*
- }
- set x "test_ns_1::"
- set y "test_ns_2::"
- list [namespace which -command ${x}${y}cmd1] \
- [catch {namespace which -command ${x}${y}cmd2} msg] $msg \
- [catch {namespace which -command ${x}${y}:cmd2} msg] $msg
-} {::test_ns_1::test_ns_2::cmd1 0 {} 0 {}}
-test execute-2.2 {Tcl_GetCommandFromObj, check if cached tclCmdNameType is invalid} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {rename foo ""}
- catch {unset l}
- proc foo {} {
- return "global foo"
- }
- namespace eval test_ns_1 {
- proc whichFoo {} {
- return [namespace which -command foo]
- }
- }
- set l ""
- lappend l [test_ns_1::whichFoo]
- namespace eval test_ns_1 {
- proc foo {} {
- return "namespace foo"
- }
- }
- lappend l [test_ns_1::whichFoo]
- set l
-} {::foo ::test_ns_1::foo}
-test execute-2.3 {Tcl_GetCommandFromObj, command never found} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {rename foo ""}
- namespace eval test_ns_1 {
- proc foo {} {
- return "namespace foo"
- }
- }
- namespace eval test_ns_1 {
- proc foo {} {
- return "namespace foo"
- }
- }
- list [namespace eval test_ns_1 {namespace which -command foo}] \
- [rename test_ns_1::foo ""] \
- [catch {namespace eval test_ns_1 {namespace which -command foo}} msg] $msg
-} {::test_ns_1::foo {} 0 {}}
-
-test execute-3.1 {SetCmdNameFromAny, set cmd name to empty heap string if NULL} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {unset l}
- proc {} {} {return {}}
- {}
- set l {}
- lindex {} 0
- {}
-} {}
-
-test execute-4.1 {UpdateStringOfCmdName: called for duplicate of empty cmdName object} {
- proc {} {} {}
- proc { } {} {}
- proc p {} {
- set x {}
- $x
- append x { }
- $x
- }
- p
-} {}
-
-# cleanup
-catch {eval namespace delete [namespace children :: test_ns_*]}
-catch {rename foo ""}
-catch {rename p ""}
-catch {rename {} ""}
-catch {rename { } ""}
-catch {unset x}
-catch {unset y}
-catch {unset msg}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/expr-old.test b/tests/expr-old.test
deleted file mode 100644
index aa5e035..0000000
--- a/tests/expr-old.test
+++ /dev/null
@@ -1,948 +0,0 @@
-# Commands covered: expr
-#
-# This file contains the original set of tests for Tcl's expr command.
-# Since the expr command is now compiled, a new set of tests covering
-# the new implementation are in the files "parseExpr.test and
-# "compExpr.test". Sourcing this file into Tcl runs the tests and generates
-# output for errors. No output means no errors were found.
-#
-# Copyright (c) 1991-1994 The Regents of the University of California.
-# Copyright (c) 1994-1997 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: expr-old.test,v 1.5 1999/04/16 00:47:27 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {([catch {expr T1()} msg] == 1) && ($msg == {unknown math function "T1"})} {
- set gotT1 0
- puts "This application hasn't been compiled with the \"T1\" and"
- puts "\"T2\" math functions, so I'll skip some of the expr tests."
-} else {
- set gotT1 1
-}
-
-# First, test all of the integer operators individually.
-
-test expr-old-1.1 {integer operators} {expr -4} -4
-test expr-old-1.2 {integer operators} {expr -(1+4)} -5
-test expr-old-1.3 {integer operators} {expr ~3} -4
-test expr-old-1.4 {integer operators} {expr !2} 0
-test expr-old-1.5 {integer operators} {expr !0} 1
-test expr-old-1.6 {integer operators} {expr 4*6} 24
-test expr-old-1.7 {integer operators} {expr 36/12} 3
-test expr-old-1.8 {integer operators} {expr 27/4} 6
-test expr-old-1.9 {integer operators} {expr 27%4} 3
-test expr-old-1.10 {integer operators} {expr 2+2} 4
-test expr-old-1.11 {integer operators} {expr 2-6} -4
-test expr-old-1.12 {integer operators} {expr 1<<3} 8
-test expr-old-1.13 {integer operators} {expr 0xff>>2} 63
-test expr-old-1.14 {integer operators} {expr -1>>2} -1
-test expr-old-1.15 {integer operators} {expr 3>2} 1
-test expr-old-1.16 {integer operators} {expr 2>2} 0
-test expr-old-1.17 {integer operators} {expr 1>2} 0
-test expr-old-1.18 {integer operators} {expr 3<2} 0
-test expr-old-1.19 {integer operators} {expr 2<2} 0
-test expr-old-1.20 {integer operators} {expr 1<2} 1
-test expr-old-1.21 {integer operators} {expr 3>=2} 1
-test expr-old-1.22 {integer operators} {expr 2>=2} 1
-test expr-old-1.23 {integer operators} {expr 1>=2} 0
-test expr-old-1.24 {integer operators} {expr 3<=2} 0
-test expr-old-1.25 {integer operators} {expr 2<=2} 1
-test expr-old-1.26 {integer operators} {expr 1<=2} 1
-test expr-old-1.27 {integer operators} {expr 3==2} 0
-test expr-old-1.28 {integer operators} {expr 2==2} 1
-test expr-old-1.29 {integer operators} {expr 3!=2} 1
-test expr-old-1.30 {integer operators} {expr 2!=2} 0
-test expr-old-1.31 {integer operators} {expr 7&0x13} 3
-test expr-old-1.32 {integer operators} {expr 7^0x13} 20
-test expr-old-1.33 {integer operators} {expr 7|0x13} 23
-test expr-old-1.34 {integer operators} {expr 0&&1} 0
-test expr-old-1.35 {integer operators} {expr 0&&0} 0
-test expr-old-1.36 {integer operators} {expr 1&&3} 1
-test expr-old-1.37 {integer operators} {expr 0||1} 1
-test expr-old-1.38 {integer operators} {expr 3||0} 1
-test expr-old-1.39 {integer operators} {expr 0||0} 0
-test expr-old-1.40 {integer operators} {expr 3>2?44:66} 44
-test expr-old-1.41 {integer operators} {expr 2>3?44:66} 66
-test expr-old-1.42 {integer operators} {expr 36/5} 7
-test expr-old-1.43 {integer operators} {expr 36%5} 1
-test expr-old-1.44 {integer operators} {expr -36/5} -8
-test expr-old-1.45 {integer operators} {expr -36%5} 4
-test expr-old-1.46 {integer operators} {expr 36/-5} -8
-test expr-old-1.47 {integer operators} {expr 36%-5} -4
-test expr-old-1.48 {integer operators} {expr -36/-5} 7
-test expr-old-1.49 {integer operators} {expr -36%-5} -1
-test expr-old-1.50 {integer operators} {expr +36} 36
-test expr-old-1.51 {integer operators} {expr +--++36} 36
-test expr-old-1.52 {integer operators} {expr +36%+5} 1
-test expr-old-1.53 {integer operators} {
- catch {unset x}
- set x yes
- list [expr {1 && $x}] [expr {$x && 1}] \
- [expr {0 || $x}] [expr {$x || 0}]
-} {1 1 1 1}
-
-# Check the floating-point operators individually, along with
-# automatic conversion to integers where needed.
-
-test expr-old-2.1 {floating-point operators} {expr -4.2} -4.2
-test expr-old-2.2 {floating-point operators} {expr -(1.1+4.2)} -5.3
-test expr-old-2.3 {floating-point operators} {expr +5.7} 5.7
-test expr-old-2.4 {floating-point operators} {expr +--+-62.0} -62.0
-test expr-old-2.5 {floating-point operators} {expr !2.1} 0
-test expr-old-2.6 {floating-point operators} {expr !0.0} 1
-test expr-old-2.7 {floating-point operators} {expr 4.2*6.3} 26.46
-test expr-old-2.8 {floating-point operators} {expr 36.0/12.0} 3.0
-test expr-old-2.9 {floating-point operators} {expr 27/4.0} 6.75
-test expr-old-2.10 {floating-point operators} {expr 2.3+2.1} 4.4
-test expr-old-2.11 {floating-point operators} {expr 2.3-6.5} -4.2
-test expr-old-2.12 {floating-point operators} {expr 3.1>2.1} 1
-test expr-old-2.13 {floating-point operators} {expr {2.1 > 2.1}} 0
-test expr-old-2.14 {floating-point operators} {expr 1.23>2.34e+1} 0
-test expr-old-2.15 {floating-point operators} {expr 3.45<2.34} 0
-test expr-old-2.16 {floating-point operators} {expr 0.002e3<--200e-2} 0
-test expr-old-2.17 {floating-point operators} {expr 1.1<2.1} 1
-test expr-old-2.18 {floating-point operators} {expr 3.1>=2.2} 1
-test expr-old-2.19 {floating-point operators} {expr 2.345>=2.345} 1
-test expr-old-2.20 {floating-point operators} {expr 1.1>=2.2} 0
-test expr-old-2.21 {floating-point operators} {expr 3.0<=2.0} 0
-test expr-old-2.22 {floating-point operators} {expr 2.2<=2.2} 1
-test expr-old-2.23 {floating-point operators} {expr 2.2<=2.2001} 1
-test expr-old-2.24 {floating-point operators} {expr 3.2==2.2} 0
-test expr-old-2.25 {floating-point operators} {expr 2.2==2.2} 1
-test expr-old-2.26 {floating-point operators} {expr 3.2!=2.2} 1
-test expr-old-2.27 {floating-point operators} {expr 2.2!=2.2} 0
-test expr-old-2.28 {floating-point operators} {expr 0.0&&0.0} 0
-test expr-old-2.29 {floating-point operators} {expr 0.0&&1.3} 0
-test expr-old-2.30 {floating-point operators} {expr 1.3&&0.0} 0
-test expr-old-2.31 {floating-point operators} {expr 1.3&&3.3} 1
-test expr-old-2.32 {floating-point operators} {expr 0.0||0.0} 0
-test expr-old-2.33 {floating-point operators} {expr 0.0||1.3} 1
-test expr-old-2.34 {floating-point operators} {expr 1.3||0.0} 1
-test expr-old-2.35 {floating-point operators} {expr 3.3||0.0} 1
-test expr-old-2.36 {floating-point operators} {expr 3.3>2.3?44.3:66.3} 44.3
-test expr-old-2.37 {floating-point operators} {expr 2.3>3.3?44.3:66.3} 66.3
-test expr-old-2.38 {floating-point operators} {
- list [catch {expr 028.1 + 09.2} msg] $msg
-} {0 37.3}
-
-# Operators that aren't legal on floating-point numbers
-
-test expr-old-3.1 {illegal floating-point operations} {
- list [catch {expr ~4.0} msg] $msg
-} {1 {can't use floating-point value as operand of "~"}}
-test expr-old-3.2 {illegal floating-point operations} {
- list [catch {expr 27%4.0} msg] $msg
-} {1 {can't use floating-point value as operand of "%"}}
-test expr-old-3.3 {illegal floating-point operations} {
- list [catch {expr 27.0%4} msg] $msg
-} {1 {can't use floating-point value as operand of "%"}}
-test expr-old-3.4 {illegal floating-point operations} {
- list [catch {expr 1.0<<3} msg] $msg
-} {1 {can't use floating-point value as operand of "<<"}}
-test expr-old-3.5 {illegal floating-point operations} {
- list [catch {expr 3<<1.0} msg] $msg
-} {1 {can't use floating-point value as operand of "<<"}}
-test expr-old-3.6 {illegal floating-point operations} {
- list [catch {expr 24.0>>3} msg] $msg
-} {1 {can't use floating-point value as operand of ">>"}}
-test expr-old-3.7 {illegal floating-point operations} {
- list [catch {expr 24>>3.0} msg] $msg
-} {1 {can't use floating-point value as operand of ">>"}}
-test expr-old-3.8 {illegal floating-point operations} {
- list [catch {expr 24&3.0} msg] $msg
-} {1 {can't use floating-point value as operand of "&"}}
-test expr-old-3.9 {illegal floating-point operations} {
- list [catch {expr 24.0|3} msg] $msg
-} {1 {can't use floating-point value as operand of "|"}}
-test expr-old-3.10 {illegal floating-point operations} {
- list [catch {expr 24.0^3} msg] $msg
-} {1 {can't use floating-point value as operand of "^"}}
-
-# Check the string operators individually.
-
-test expr-old-4.1 {string operators} {expr {"abc" > "def"}} 0
-test expr-old-4.2 {string operators} {expr {"def" > "def"}} 0
-test expr-old-4.3 {string operators} {expr {"g" > "def"}} 1
-test expr-old-4.4 {string operators} {expr {"abc" < "abd"}} 1
-test expr-old-4.5 {string operators} {expr {"abd" < "abd"}} 0
-test expr-old-4.6 {string operators} {expr {"abe" < "abd"}} 0
-test expr-old-4.7 {string operators} {expr {"abc" >= "def"}} 0
-test expr-old-4.8 {string operators} {expr {"def" >= "def"}} 1
-test expr-old-4.9 {string operators} {expr {"g" >= "def"}} 1
-test expr-old-4.10 {string operators} {expr {"abc" <= "abd"}} 1
-test expr-old-4.11 {string operators} {expr {"abd" <= "abd"}} 1
-test expr-old-4.12 {string operators} {expr {"abe" <= "abd"}} 0
-test expr-old-4.13 {string operators} {expr {"abc" == "abd"}} 0
-test expr-old-4.14 {string operators} {expr {"abd" == "abd"}} 1
-test expr-old-4.15 {string operators} {expr {"abc" != "abd"}} 1
-test expr-old-4.16 {string operators} {expr {"abd" != "abd"}} 0
-test expr-old-4.17 {string operators} {expr {"0y" < "0x12"}} 0
-test expr-old-4.18 {string operators} {expr {"." < " "}} 0
-
-# The following tests are non-portable because on some systems "+"
-# and "-" can be parsed as numbers.
-
-test expr-old-4.19 {string operators} {nonPortable} {expr {"0" == "+"}} 0
-test expr-old-4.20 {string operators} {nonPortable} {expr {"0" == "-"}} 0
-test expr-old-4.21 {string operators} {expr {1?"foo":"bar"}} foo
-test expr-old-4.22 {string operators} {expr {0?"foo":"bar"}} bar
-
-# Operators that aren't legal on string operands.
-
-test expr-old-5.1 {illegal string operations} {
- list [catch {expr {-"a"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "-"}}
-test expr-old-5.2 {illegal string operations} {
- list [catch {expr {+"a"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "+"}}
-test expr-old-5.3 {illegal string operations} {
- list [catch {expr {~"a"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "~"}}
-test expr-old-5.4 {illegal string operations} {
- list [catch {expr {!"a"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "!"}}
-test expr-old-5.5 {illegal string operations} {
- list [catch {expr {"a"*"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "*"}}
-test expr-old-5.6 {illegal string operations} {
- list [catch {expr {"a"/"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "/"}}
-test expr-old-5.7 {illegal string operations} {
- list [catch {expr {"a"%"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "%"}}
-test expr-old-5.8 {illegal string operations} {
- list [catch {expr {"a"+"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "+"}}
-test expr-old-5.9 {illegal string operations} {
- list [catch {expr {"a"-"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "-"}}
-test expr-old-5.10 {illegal string operations} {
- list [catch {expr {"a"<<"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "<<"}}
-test expr-old-5.11 {illegal string operations} {
- list [catch {expr {"a">>"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of ">>"}}
-test expr-old-5.12 {illegal string operations} {
- list [catch {expr {"a"&"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "&"}}
-test expr-old-5.13 {illegal string operations} {
- list [catch {expr {"a"^"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "^"}}
-test expr-old-5.14 {illegal string operations} {
- list [catch {expr {"a"|"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "|"}}
-test expr-old-5.15 {illegal string operations} {
- list [catch {expr {"a"&&"b"}} msg] $msg
-} {1 {expected boolean value but got "a"}}
-test expr-old-5.16 {illegal string operations} {
- list [catch {expr {"a"||"b"}} msg] $msg
-} {1 {expected boolean value but got "a"}}
-test expr-old-5.17 {illegal string operations} {
- list [catch {expr {"a"?4:2}} msg] $msg
-} {1 {expected boolean value but got "a"}}
-
-# Check precedence pairwise.
-
-test expr-old-6.1 {precedence checks} {expr -~3} 4
-test expr-old-6.2 {precedence checks} {expr -!3} 0
-test expr-old-6.3 {precedence checks} {expr -~0} 1
-
-test expr-old-7.1 {precedence checks} {expr 2*4/6} 1
-test expr-old-7.2 {precedence checks} {expr 24/6*3} 12
-test expr-old-7.3 {precedence checks} {expr 24/6/2} 2
-
-test expr-old-8.1 {precedence checks} {expr -2+4} 2
-test expr-old-8.2 {precedence checks} {expr -2-4} -6
-test expr-old-8.3 {precedence checks} {expr +2-4} -2
-
-test expr-old-9.1 {precedence checks} {expr 2*3+4} 10
-test expr-old-9.2 {precedence checks} {expr 8/2+4} 8
-test expr-old-9.3 {precedence checks} {expr 8%3+4} 6
-test expr-old-9.4 {precedence checks} {expr 2*3-1} 5
-test expr-old-9.5 {precedence checks} {expr 8/2-1} 3
-test expr-old-9.6 {precedence checks} {expr 8%3-1} 1
-
-test expr-old-10.1 {precedence checks} {expr 6-3-2} 1
-
-test expr-old-11.1 {precedence checks} {expr 7+1>>2} 2
-test expr-old-11.2 {precedence checks} {expr 7+1<<2} 32
-test expr-old-11.3 {precedence checks} {expr 7>>3-2} 3
-test expr-old-11.4 {precedence checks} {expr 7<<3-2} 14
-
-test expr-old-12.1 {precedence checks} {expr 6>>1>4} 0
-test expr-old-12.2 {precedence checks} {expr 6>>1<2} 0
-test expr-old-12.3 {precedence checks} {expr 6>>1>=3} 1
-test expr-old-12.4 {precedence checks} {expr 6>>1<=2} 0
-test expr-old-12.5 {precedence checks} {expr 6<<1>5} 1
-test expr-old-12.6 {precedence checks} {expr 6<<1<5} 0
-test expr-old-12.7 {precedence checks} {expr 5<=6<<1} 1
-test expr-old-12.8 {precedence checks} {expr 5>=6<<1} 0
-
-test expr-old-13.1 {precedence checks} {expr 2<3<4} 1
-test expr-old-13.2 {precedence checks} {expr 0<4>2} 0
-test expr-old-13.3 {precedence checks} {expr 4>2<1} 0
-test expr-old-13.4 {precedence checks} {expr 4>3>2} 0
-test expr-old-13.5 {precedence checks} {expr 4>3>=2} 0
-test expr-old-13.6 {precedence checks} {expr 4>=3>2} 0
-test expr-old-13.7 {precedence checks} {expr 4>=3>=2} 0
-test expr-old-13.8 {precedence checks} {expr 0<=4>=2} 0
-test expr-old-13.9 {precedence checks} {expr 4>=2<=0} 0
-test expr-old-13.10 {precedence checks} {expr 2<=3<=4} 1
-
-test expr-old-14.1 {precedence checks} {expr 1==4>3} 1
-test expr-old-14.2 {precedence checks} {expr 0!=4>3} 1
-test expr-old-14.3 {precedence checks} {expr 1==3<4} 1
-test expr-old-14.4 {precedence checks} {expr 0!=3<4} 1
-test expr-old-14.5 {precedence checks} {expr 1==4>=3} 1
-test expr-old-14.6 {precedence checks} {expr 0!=4>=3} 1
-test expr-old-14.7 {precedence checks} {expr 1==3<=4} 1
-test expr-old-14.8 {precedence checks} {expr 0!=3<=4} 1
-
-test expr-old-15.1 {precedence checks} {expr 1==3==3} 0
-test expr-old-15.2 {precedence checks} {expr 3==3!=2} 1
-test expr-old-15.3 {precedence checks} {expr 2!=3==3} 0
-test expr-old-15.4 {precedence checks} {expr 2!=1!=1} 0
-
-test expr-old-16.1 {precedence checks} {expr 2&3==2} 0
-test expr-old-16.2 {precedence checks} {expr 1&3!=3} 0
-
-test expr-old-17.1 {precedence checks} {expr 7&3^0x10} 19
-test expr-old-17.2 {precedence checks} {expr 7^0x10&3} 7
-
-test expr-old-18.1 {precedence checks} {expr 7^0x10|3} 23
-test expr-old-18.2 {precedence checks} {expr 7|0x10^3} 23
-
-test expr-old-19.1 {precedence checks} {expr 7|3&&1} 1
-test expr-old-19.2 {precedence checks} {expr 1&&3|7} 1
-test expr-old-19.3 {precedence checks} {expr 0&&1||1} 1
-test expr-old-19.4 {precedence checks} {expr 1||1&&0} 1
-
-test expr-old-20.1 {precedence checks} {expr 1||0?3:4} 3
-test expr-old-20.2 {precedence checks} {expr 1?0:4||1} 0
-test expr-old-20.3 {precedence checks} {expr 1?2:0?3:4} 2
-test expr-old-20.4 {precedence checks} {expr 0?2:0?3:4} 4
-test expr-old-20.5 {precedence checks} {expr 1?2?3:4:0} 3
-test expr-old-20.6 {precedence checks} {expr 0?2?3:4:0} 0
-
-# Parentheses.
-
-test expr-old-21.1 {parenthesization} {expr (2+4)*6} 36
-test expr-old-21.2 {parenthesization} {expr (1?0:4)||1} 1
-test expr-old-21.3 {parenthesization} {expr +(3-4)} -1
-
-# Embedded commands and variable names.
-
-set a 16
-test expr-old-22.1 {embedded variables} {expr {2*$a}} 32
-test expr-old-22.2 {embedded variables} {
- set x -5
- set y 10
- expr {$x + $y}
-} {5}
-test expr-old-22.3 {embedded variables} {
- set x " -5"
- set y " +10"
- expr {$x + $y}
-} {5}
-test expr-old-22.4 {embedded commands and variables} {expr {[set a] - 14}} 2
-test expr-old-22.5 {embedded commands and variables} {
- list [catch {expr {12 - [bad_command_name]}} msg] $msg
-} {1 {invalid command name "bad_command_name"}}
-
-# Double-quotes and things inside them.
-
-test expr-old-23.1 {double quotes} {expr {"abc"}} abc
-test expr-old-23.2 {double quotes} {
- set a 189
- expr {"$a.bc"}
-} 189.bc
-test expr-old-23.3 {double quotes} {
- set b2 xyx
- expr {"$b2$b2$b2.[set b2].[set b2]"}
-} xyxxyxxyx.xyx.xyx
-test expr-old-23.4 {double quotes} {expr {"11\}\}22"}} 11}}22
-test expr-old-23.5 {double quotes} {expr {"\*bc"}} {*bc}
-test expr-old-23.6 {double quotes} {
- catch {unset bogus__}
- list [catch {expr {"$bogus__"}} msg] $msg
-} {1 {can't read "bogus__": no such variable}}
-test expr-old-23.7 {double quotes} {
- list [catch {expr {"a[error Testing]bc"}} msg] $msg
-} {1 Testing}
-test expr-old-23.8 {double quotes} {
- list [catch {expr {"12398712938788234-1298379" != ""}} msg] $msg
-} {0 1}
-
-# Numbers in various bases.
-
-test expr-old-24.1 {numbers in different bases} {expr 0x20} 32
-test expr-old-24.2 {numbers in different bases} {expr 015} 13
-
-# Conversions between various data types.
-
-test expr-old-25.1 {type conversions} {expr 2+2.5} 4.5
-test expr-old-25.2 {type conversions} {expr 2.5+2} 4.5
-test expr-old-25.3 {type conversions} {expr 2-2.5} -0.5
-test expr-old-25.4 {type conversions} {expr 2/2.5} 0.8
-test expr-old-25.5 {type conversions} {expr 2>2.5} 0
-test expr-old-25.6 {type conversions} {expr 2.5>2} 1
-test expr-old-25.7 {type conversions} {expr 2<2.5} 1
-test expr-old-25.8 {type conversions} {expr 2>=2.5} 0
-test expr-old-25.9 {type conversions} {expr 2<=2.5} 1
-test expr-old-25.10 {type conversions} {expr 2==2.5} 0
-test expr-old-25.11 {type conversions} {expr 2!=2.5} 1
-test expr-old-25.12 {type conversions} {expr 2>"ab"} 0
-test expr-old-25.13 {type conversions} {expr {2>" "}} 1
-test expr-old-25.14 {type conversions} {expr {"24.1a" > 24.1}} 1
-test expr-old-25.15 {type conversions} {expr {24.1 > "24.1a"}} 0
-test expr-old-25.16 {type conversions} {expr 2+2.5} 4.5
-test expr-old-25.17 {type conversions} {expr 2+2.5} 4.5
-test expr-old-25.18 {type conversions} {expr 2.0e2} 200.0
-test expr-old-25.19 {type conversions} {eformat} {expr 2.0e15} 2e+15
-test expr-old-25.20 {type conversions} {expr 10.0} 10.0
-
-# Various error conditions.
-
-test expr-old-26.1 {error conditions} {
- list [catch {expr 2+"a"} msg] $msg
-} {1 {can't use non-numeric string as operand of "+"}}
-test expr-old-26.2 {error conditions} {
- list [catch {expr 2+4*} msg] $msg
-} {1 {syntax error in expression "2+4*"}}
-test expr-old-26.3 {error conditions} {
- list [catch {expr 2+4*(} msg] $msg
-} {1 {syntax error in expression "2+4*("}}
-catch {unset _non_existent_}
-test expr-old-26.4 {error conditions} {
- list [catch {expr 2+$_non_existent_} msg] $msg
-} {1 {can't read "_non_existent_": no such variable}}
-set a xx
-test expr-old-26.5 {error conditions} {
- list [catch {expr {2+$a}} msg] $msg
-} {1 {can't use non-numeric string as operand of "+"}}
-test expr-old-26.6 {error conditions} {
- list [catch {expr {2+[set a]}} msg] $msg
-} {1 {can't use non-numeric string as operand of "+"}}
-test expr-old-26.7 {error conditions} {
- list [catch {expr {2+(4}} msg] $msg
-} {1 {syntax error in expression "2+(4"}}
-test expr-old-26.8 {error conditions} {
- list [catch {expr 2/0} msg] $msg $errorCode
-} {1 {divide by zero} {ARITH DIVZERO {divide by zero}}}
-test expr-old-26.9 {error conditions} {
- list [catch {expr 2%0} msg] $msg $errorCode
-} {1 {divide by zero} {ARITH DIVZERO {divide by zero}}}
-test expr-old-26.10 {error conditions} {
- list [catch {expr 2.0/0.0} msg] $msg $errorCode
-} {1 {divide by zero} {ARITH DIVZERO {divide by zero}}}
-test expr-old-26.11 {error conditions} {
- list [catch {expr 2#} msg] $msg
-} {1 {syntax error in expression "2#"}}
-test expr-old-26.12 {error conditions} {
- list [catch {expr a.b} msg] $msg
-} {1 {syntax error in expression "a.b"}}
-test expr-old-26.13 {error conditions} {
- list [catch {expr {"a"/"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "/"}}
-test expr-old-26.14 {error conditions} {
- list [catch {expr 2:3} msg] $msg
-} {1 {syntax error in expression "2:3"}}
-test expr-old-26.15 {error conditions} {
- list [catch {expr a@b} msg] $msg
-} {1 {syntax error in expression "a@b"}}
-test expr-old-26.16 {error conditions} {
- list [catch {expr a[b} msg] $msg
-} {1 {missing close-bracket}}
-test expr-old-26.17 {error conditions} {
- list [catch {expr a`b} msg] $msg
-} {1 {syntax error in expression "a`b"}}
-test expr-old-26.18 {error conditions} {
- list [catch {expr \"a\"\{b} msg] $msg
-} {1 syntax\ error\ in\ expression\ \"\"a\"\{b\"}
-test expr-old-26.19 {error conditions} {
- list [catch {expr a} msg] $msg
-} {1 {syntax error in expression "a"}}
-test expr-old-26.20 {error conditions} {
- list [catch expr msg] $msg
-} {1 {wrong # args: should be "expr arg ?arg ...?"}}
-
-# Cancelled evaluation.
-
-test expr-old-27.1 {cancelled evaluation} {
- set a 1
- expr {0&&[set a 2]}
- set a
-} 1
-test expr-old-27.2 {cancelled evaluation} {
- set a 1
- expr {1||[set a 2]}
- set a
-} 1
-test expr-old-27.3 {cancelled evaluation} {
- set a 1
- expr {0?[set a 2]:1}
- set a
-} 1
-test expr-old-27.4 {cancelled evaluation} {
- set a 1
- expr {1?2:[set a 2]}
- set a
-} 1
-catch {unset x}
-test expr-old-27.5 {cancelled evaluation} {
- list [catch {expr {[info exists x] && $x}} msg] $msg
-} {0 0}
-test expr-old-27.6 {cancelled evaluation} {
- list [catch {expr {0 && [concat $x]}} msg] $msg
-} {0 0}
-test expr-old-27.7 {cancelled evaluation} {
- set one 1
- list [catch {expr {1 || 1/$one}} msg] $msg
-} {0 1}
-test expr-old-27.8 {cancelled evaluation} {
- list [catch {expr {1 || -"string"}} msg] $msg
-} {0 1}
-test expr-old-27.9 {cancelled evaluation} {
- list [catch {expr {1 || ("string" * ("x" && "y"))}} msg] $msg
-} {0 1}
-test expr-old-27.10 {cancelled evaluation} {
- set x -1.0
- list [catch {expr {($x > 0) ? round(log($x)) : 0}} msg] $msg
-} {0 0}
-test expr-old-27.11 {cancelled evaluation} {
- list [catch {expr {0 && foo}} msg] $msg
-} {1 {syntax error in expression "0 && foo"}}
-test expr-old-27.12 {cancelled evaluation} {
- list [catch {expr {0 ? 1 : foo}} msg] $msg
-} {1 {syntax error in expression "0 ? 1 : foo"}}
-
-# Tcl_ExprBool as used in "if" statements
-
-test expr-old-28.1 {Tcl_ExprBoolean usage} {
- set a 1
- if {2} {set a 2}
- set a
-} 2
-test expr-old-28.2 {Tcl_ExprBoolean usage} {
- set a 1
- if {0} {set a 2}
- set a
-} 1
-test expr-old-28.3 {Tcl_ExprBoolean usage} {
- set a 1
- if {1.2} {set a 2}
- set a
-} 2
-test expr-old-28.4 {Tcl_ExprBoolean usage} {
- set a 1
- if {-1.1} {set a 2}
- set a
-} 2
-test expr-old-28.5 {Tcl_ExprBoolean usage} {
- set a 1
- if {0.0} {set a 2}
- set a
-} 1
-test expr-old-28.6 {Tcl_ExprBoolean usage} {
- set a 1
- if {"YES"} {set a 2}
- set a
-} 2
-test expr-old-28.7 {Tcl_ExprBoolean usage} {
- set a 1
- if {"no"} {set a 2}
- set a
-} 1
-test expr-old-28.8 {Tcl_ExprBoolean usage} {
- set a 1
- if {"true"} {set a 2}
- set a
-} 2
-test expr-old-28.9 {Tcl_ExprBoolean usage} {
- set a 1
- if {"fAlse"} {set a 2}
- set a
-} 1
-test expr-old-28.10 {Tcl_ExprBoolean usage} {
- set a 1
- if {"on"} {set a 2}
- set a
-} 2
-test expr-old-28.11 {Tcl_ExprBoolean usage} {
- set a 1
- if {"Off"} {set a 2}
- set a
-} 1
-test expr-old-28.12 {Tcl_ExprBool usage} {
- list [catch {if {"abc"} {}} msg] $msg
-} {1 {expected boolean value but got "abc"}}
-test expr-old-28.13 {Tcl_ExprBool usage} {
- list [catch {if {"ogle"} {}} msg] $msg
-} {1 {expected boolean value but got "ogle"}}
-test expr-old-28.14 {Tcl_ExprBool usage} {
- list [catch {if {"o"} {}} msg] $msg
-} {1 {expected boolean value but got "o"}}
-
-# Operands enclosed in braces
-
-test expr-old-29.1 {braces} {expr {{abc}}} abc
-test expr-old-29.2 {braces} {expr {{00010}}} 8
-test expr-old-29.3 {braces} {expr {{3.1200000}}} 3.12
-test expr-old-29.4 {braces} {expr {{a{b}{1 {2 3}}c}}} "a{b}{1 {2 3}}c"
-test expr-old-29.5 {braces} {
- list [catch {expr "\{abc"} msg] $msg
-} {1 {missing close-brace}}
-
-# Very long values
-
-test expr-old-30.1 {long values} {
- set a "0000 1111 2222 3333 4444"
- set a "$a | $a | $a | $a | $a"
- set a "$a || $a || $a || $a || $a"
- expr {$a}
-} {0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 || 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 || 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 || 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 || 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444}
-test expr-old-30.2 {long values} {
- set a "000000000000000000000000000000"
- set a "$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a${a}5"
- expr $a
-} 5
-
-# Expressions spanning multiple arguments
-
-test expr-old-31.1 {multiple arguments to expr command} {
- expr 4 + ( 6 *12) -3
-} 73
-test expr-old-31.2 {multiple arguments to expr command} {
- list [catch {expr 2 + (3 + 4} msg] $msg
-} {1 {syntax error in expression "2 + (3 + 4"}}
-test expr-old-31.3 {multiple arguments to expr command} {
- list [catch {expr 2 + 3 +} msg] $msg
-} {1 {syntax error in expression "2 + 3 +"}}
-test expr-old-31.4 {multiple arguments to expr command} {
- list [catch {expr 2 + 3 )} msg] $msg
-} {1 {syntax error in expression "2 + 3 )"}}
-
-# Math functions
-
-test expr-old-32.1 {math functions in expressions} {
- format %.6g [expr acos(0.5)]
-} {1.0472}
-test expr-old-32.2 {math functions in expressions} {
- format %.6g [expr asin(0.5)]
-} {0.523599}
-test expr-old-32.3 {math functions in expressions} {
- format %.6g [expr atan(1.0)]
-} {0.785398}
-test expr-old-32.4 {math functions in expressions} {
- format %.6g [expr atan2(2.0, 2.0)]
-} {0.785398}
-test expr-old-32.5 {math functions in expressions} {
- format %.6g [expr ceil(1.999)]
-} {2}
-test expr-old-32.6 {math functions in expressions} {
- format %.6g [expr cos(.1)]
-} {0.995004}
-test expr-old-32.7 {math functions in expressions} {
- format %.6g [expr cosh(.1)]
-} {1.005}
-test expr-old-32.8 {math functions in expressions} {
- format %.6g [expr exp(1.0)]
-} {2.71828}
-test expr-old-32.9 {math functions in expressions} {
- format %.6g [expr floor(2.000)]
-} {2}
-test expr-old-32.10 {math functions in expressions} {
- format %.6g [expr floor(2.001)]
-} {2}
-test expr-old-32.11 {math functions in expressions} {
- format %.6g [expr fmod(7.3, 3.2)]
-} {0.9}
-test expr-old-32.12 {math functions in expressions} {
- format %.6g [expr hypot(3.0, 4.0)]
-} {5}
-test expr-old-32.13 {math functions in expressions} {
- format %.6g [expr log(2.8)]
-} {1.02962}
-test expr-old-32.14 {math functions in expressions} {
- format %.6g [expr log10(2.8)]
-} {0.447158}
-test expr-old-32.15 {math functions in expressions} {
- format %.6g [expr pow(2.1, 3.1)]
-} {9.97424}
-test expr-old-32.16 {math functions in expressions} {
- format %.6g [expr sin(.1)]
-} {0.0998334}
-test expr-old-32.17 {math functions in expressions} {
- format %.6g [expr sinh(.1)]
-} {0.100167}
-test expr-old-32.18 {math functions in expressions} {
- format %.6g [expr sqrt(2.0)]
-} {1.41421}
-test expr-old-32.19 {math functions in expressions} {
- format %.6g [expr tan(0.8)]
-} {1.02964}
-test expr-old-32.20 {math functions in expressions} {
- format %.6g [expr tanh(0.8)]
-} {0.664037}
-test expr-old-32.21 {math functions in expressions} {
- format %.6g [expr abs(-1.8)]
-} {1.8}
-test expr-old-32.22 {math functions in expressions} {
- expr abs(10.0)
-} {10.0}
-test expr-old-32.23 {math functions in expressions} {
- format %.6g [expr abs(-4)]
-} {4}
-test expr-old-32.24 {math functions in expressions} {
- format %.6g [expr abs(66)]
-} {66}
-
-# The following test is different for 32-bit versus 64-bit architectures.
-
-if {0x80000000 > 0} {
- test expr-old-32.25 {math functions in expressions} {nonPortable} {
- list [catch {expr abs(0x8000000000000000)} msg] $msg
- } {1 {integer value too large to represent}}
-} else {
- test expr-old-32.25 {math functions in expressions} {nonPortable} {
- list [catch {expr abs(0x80000000)} msg] $msg
- } {1 {integer value too large to represent}}
-}
-
-test expr-old-32.26 {math functions in expressions} {
- expr double(1)
-} {1.0}
-test expr-old-32.27 {math functions in expressions} {
- expr double(1.1)
-} {1.1}
-test expr-old-32.28 {math functions in expressions} {
- expr int(1)
-} {1}
-test expr-old-32.29 {math functions in expressions} {
- expr int(1.4)
-} {1}
-test expr-old-32.30 {math functions in expressions} {
- expr int(1.6)
-} {1}
-test expr-old-32.31 {math functions in expressions} {
- expr int(-1.4)
-} {-1}
-test expr-old-32.32 {math functions in expressions} {
- expr int(-1.6)
-} {-1}
-test expr-old-32.33 {math functions in expressions} {
- list [catch {expr int(1e60)} msg] $msg
-} {1 {integer value too large to represent}}
-test expr-old-32.34 {math functions in expressions} {
- list [catch {expr int(-1e60)} msg] $msg
-} {1 {integer value too large to represent}}
-test expr-old-32.35 {math functions in expressions} {
- expr round(1.49)
-} {1}
-test expr-old-32.36 {math functions in expressions} {
- expr round(1.51)
-} {2}
-test expr-old-32.37 {math functions in expressions} {
- expr round(-1.49)
-} {-1}
-test expr-old-32.38 {math functions in expressions} {
- expr round(-1.51)
-} {-2}
-test expr-old-32.39 {math functions in expressions} {
- list [catch {expr round(1e60)} msg] $msg
-} {1 {integer value too large to represent}}
-test expr-old-32.40 {math functions in expressions} {
- list [catch {expr round(-1e60)} msg] $msg
-} {1 {integer value too large to represent}}
-test expr-old-32.41 {math functions in expressions} {
- list [catch {expr pow(1.0 + 3.0 - 2, .8 * 5)} msg] $msg
-} {0 16.0}
-test expr-old-32.42 {math functions in expressions} {
- list [catch {expr hypot(5*.8,3)} msg] $msg
-} {0 5.0}
-if $gotT1 {
- test expr-old-32.43 {math functions in expressions} {
- expr 2*T1()
- } 246
- test expr-old-32.44 {math functions in expressions} {
- expr T2()*3
- } 1035
-}
-test expr-old-32.45 {math functions in expressions} {
- expr (0 <= rand()) && (rand() < 1)
-} {1}
-test expr-old-32.46 {math functions in expressions} {
- list [catch {expr rand(24)} msg] $msg
-} {1 {too many arguments for math function}}
-test expr-old-32.47 {math functions in expressions} {
- list [catch {expr srand()} msg] $msg
-} {1 {too few arguments for math function}}
-test expr-old-32.48 {math functions in expressions} {
- list [catch {expr srand(3.79)} msg] $msg
-} {1 {can't use floating-point value as argument to srand}}
-test expr-old-32.49 {math functions in expressions} {
- list [catch {expr srand("")} msg] $msg
-} {1 {can't use non-numeric string as argument to srand}}
-test expr-old-32.50 {math functions in expressions} {
- set result [expr round(srand(12345) * 1000)]
- for {set i 0} {$i < 10} {incr i} {
- lappend result [expr round(rand() * 1000)]
- }
- set result
-} {97 834 948 36 12 51 766 585 914 784 333}
-test expr-old-32.51 {math functions in expressions} {
- list [catch {expr {srand([lindex "6ty" 0])}} msg] $msg
-} {1 {can't use non-numeric string as argument to srand}}
-
-test expr-old-33.1 {conversions and fancy args to math functions} {
- expr hypot ( 3 , 4 )
-} 5.0
-test expr-old-33.2 {conversions and fancy args to math functions} {
- expr hypot ( (2.0+1.0) , 4 )
-} 5.0
-test expr-old-33.3 {conversions and fancy args to math functions} {
- expr hypot ( 3 , (3.0 + 1.0) )
-} 5.0
-test expr-old-33.4 {conversions and fancy args to math functions} {
- format %.6g [expr cos(acos(0.1))]
-} 0.1
-
-test expr-old-34.1 {errors in math functions} {
- list [catch {expr func_2(1.0)} msg] $msg
-} {1 {unknown math function "func_2"}}
-test expr-old-34.2 {errors in math functions} {
- list [catch {expr func|(1.0)} msg] $msg
-} {1 {syntax error in expression "func|(1.0)"}}
-test expr-old-34.3 {errors in math functions} {
- list [catch {expr {hypot("a b", 2.0)}} msg] $msg
-} {1 {argument to math function didn't have numeric value}}
-test expr-old-34.4 {errors in math functions} {
- list [catch {expr hypot(1.0 2.0)} msg] $msg
-} {1 {syntax error in expression "hypot(1.0 2.0)"}}
-test expr-old-34.5 {errors in math functions} {
- list [catch {expr hypot(1.0, 2.0} msg] $msg
-} {1 {syntax error in expression "hypot(1.0, 2.0"}}
-test expr-old-34.6 {errors in math functions} {
- list [catch {expr hypot(1.0 ,} msg] $msg
-} {1 {syntax error in expression "hypot(1.0 ,"}}
-test expr-old-34.7 {errors in math functions} {
- list [catch {expr hypot(1.0)} msg] $msg
-} {1 {too few arguments for math function}}
-test expr-old-34.8 {errors in math functions} {
- list [catch {expr hypot(1.0, 2.0, 3.0)} msg] $msg
-} {1 {too many arguments for math function}}
-test expr-old-34.9 {errors in math functions} {
- list [catch {expr acos(-2.0)} msg] $msg $errorCode
-} {1 {domain error: argument not in valid range} {ARITH DOMAIN {domain error: argument not in valid range}}}
-test expr-old-34.10 {errors in math functions} {nonPortable} {
- list [catch {expr pow(-3, 1000001)} msg] $msg $errorCode
-} {1 {floating-point value too large to represent} {ARITH OVERFLOW {floating-point value too large to represent}}}
-test expr-old-34.11 {errors in math functions} {
- list [catch {expr pow(3, 1000001)} msg] $msg $errorCode
-} {1 {floating-point value too large to represent} {ARITH OVERFLOW {floating-point value too large to represent}}}
-test expr-old-34.12 {errors in math functions} {
- list [catch {expr -14.0*exp(100000)} msg] $msg $errorCode
-} {1 {floating-point value too large to represent} {ARITH OVERFLOW {floating-point value too large to represent}}}
-test expr-old-34.13 {errors in math functions} {
- list [catch {expr int(1.0e30)} msg] $msg $errorCode
-} {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
-test expr-old-34.14 {errors in math functions} {
- list [catch {expr int(-1.0e30)} msg] $msg $errorCode
-} {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
-test expr-old-34.15 {errors in math functions} {
- list [catch {expr round(1.0e30)} msg] $msg $errorCode
-} {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
-test expr-old-34.16 {errors in math functions} {
- list [catch {expr round(-1.0e30)} msg] $msg $errorCode
-} {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
-if $gotT1 {
- test expr-old-34.17 {errors in math functions} {
- list [catch {expr T1(4)} msg] $msg
- } {1 {too many arguments for math function}}
-}
-
-test expr-old-36.1 {ExprLooksLikeInt procedure} {
- list [catch {expr 0289} msg] $msg
-} {1 {syntax error in expression "0289"}}
-test expr-old-36.2 {ExprLooksLikeInt procedure} {
- set x 0289
- list [catch {expr {$x+1}} msg] $msg
-} {1 {can't use floating-point value as operand of "+"}}
-test expr-old-36.3 {ExprLooksLikeInt procedure} {
- list [catch {expr 0289.1} msg] $msg
-} {0 289.1}
-test expr-old-36.4 {ExprLooksLikeInt procedure} {
- set x 0289.1
- list [catch {expr {$x+1}} msg] $msg
-} {0 290.1}
-test expr-old-36.5 {ExprLooksLikeInt procedure} {
- set x { +22}
- list [catch {expr {$x+1}} msg] $msg
-} {0 23}
-test expr-old-36.6 {ExprLooksLikeInt procedure} {
- set x { -22}
- list [catch {expr {$x+1}} msg] $msg
-} {0 -21}
-test expr-old-36.7 {ExprLooksLikeInt procedure} {nonPortable unixOnly} {
- list [catch {expr nan} msg] $msg
-} {1 {domain error: argument not in valid range}}
-test expr-old-36.8 {ExprLooksLikeInt procedure} {
- list [catch {expr 78e1} msg] $msg
-} {0 780.0}
-test expr-old-36.9 {ExprLooksLikeInt procedure} {
- list [catch {expr 24E1} msg] $msg
-} {0 240.0}
-test expr-old-36.10 {ExprLooksLikeInt procedure} {nonPortable unixOnly} {
- list [catch {expr 78e} msg] $msg
-} {1 {syntax error in expression "78e"}}
-
-if {[info commands testexprlong] == {}} {
- puts "This application hasn't been compiled with the \"testexprlong\""
- puts "command, so I can't test Tcl_ExprLong etc."
-} else {
-test expr-old-37.1 {Check that Tcl_ExprLong doesn't modify interpreter result if no error} {
- testexprlong
-} {This is a result: 5}
-}
-
-if {[info commands testexprstring] == {}} {
- puts "This application hasn't been compiled with the \"testexprstring\""
- puts "command, so I can't test Tcl_ExprString etc."
-} else {
-test expr-old-38.1 {Verify Tcl_ExprString's basic operation} {
- list [testexprstring "1+4"] [testexprstring "2*3+4.2"] \
- [catch {testexprstring "1+"} msg] $msg
-} {5 10.2 1 {syntax error in expression "1+"}}
-}
-
-# Special test for Pentium arithmetic bug of 1994:
-
-if {(4195835.0 - (4195835.0/3145727.0)*3145727.0) == 256.0} {
- puts "Warning: this machine contains a defective Pentium processor"
- puts "that performs arithmetic incorrectly. I recommend that you"
- puts "call Intel customer service immediately at 1-800-628-8686"
- puts "to request a replacement processor."
-}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/expr.test b/tests/expr.test
deleted file mode 100644
index 7b0135a..0000000
--- a/tests/expr.test
+++ /dev/null
@@ -1,709 +0,0 @@
-# Commands covered: expr
-#
-# 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) 1996-1997 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: expr.test,v 1.3 1999/04/16 00:47:27 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {([catch {expr T1()} msg] == 1) && ($msg == {unknown math function "T1"})} {
- set gotT1 0
- puts "This application hasn't been compiled with the \"T1\" and"
- puts "\"T2\" math functions, so I'll skip some of the expr tests."
-} else {
- set gotT1 1
-}
-
-# procedures used below
-
-proc put_hello_char {c} {
- global a
- append a [format %c $c]
- return $c
-}
-proc hello_world {} {
- global a
- set a ""
- set L1 [set l0 [set h_1 [set q 0]]]
- for {put_hello_char [expr [put_hello_char [expr [set h 7]*10+2]]+29]} {$l0?[put_hello_char $l0]
- :!$h_1} {put_hello_char $ll;expr {$L1==2?[set ll [expr 32+0-0+[set bar 0]]]:0}} {expr {[incr L1]==[expr 1+([string length "abc"]-[string length "abc"])]
- ?[set ll [set l0 [expr 54<<1]]]:$ll==108&&$L1<3?
- [incr ll [expr 1|1<<1]; set ll $ll; set ll $ll; set ll $ll; set ll $ll; set l0 [expr ([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])]; set l0; set l0 $l0; set l0; set l0]:$L1==4&&$ll==32?[set ll [expr 19+$h1+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])+[set foo [expr ([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])]]]]
- :[set q [expr $q-$h1+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])]]};expr {$L1==5?[incr ll -8; set ll $ll; set ll]:$q&&$h1&&1};expr {$L1==4+2
- ?[incr ll 3]:[expr ([string length "abc"]-[string length "abc"])+1]};expr {$ll==($h<<4)+2+0&&$L1!=6?[incr ll -6]:[set h1 [expr 100+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])]]}
- expr {$L1!=1<<3?[incr q [expr ([string length "abc"]-[string length "abc"])-1]]:[set h_1 [set ll $h1]]}
- }
- set a
-}
-
-proc 12days {a b c} {
- global xxx
- expr {1<$a?[expr {$a<3?[12days -79 -13 [string range $c [12days -87 \
- [expr 1-$b] [string range $c [12days -86 0 [string range $c 1 end]] \
- end]] end]]:1};expr {$a<$b?[12days [expr $a+1] $b $c]:3};expr {[12days \
- -94 [expr $a-27] $c]&&$a==2?$b<13?[12days 2 [expr $b+1] "%s %d %d\n"]:9
- :16}]:$a<0?$a<-72?[12days $b $a "@n'+,#'/*\{\}w+/w#cdnr/+,\{\}r/*de\}+,/*\{*+,/w\{%+,/w#q#n+,/#\{l+,/n\{n+,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,\}\{w+K w'K:'+\}e#';dq#'l q#'+d'K#!/+k#;q#'r\}eKK#\}w'r\}eKK\{nl\]'/#;#q#n')\{)#\}w')\{)\{nl\]'/+#n';d\}rw' i;# )\{nl\]!/n\{n#'; r\{#w'r nc\{nl\]'/#\{l,+'K \{rw' iK\{;\[\{nl\]'/w#q#n'wk nw' iwk\{KK\{nl\]!/w\{%'l##w#' i; :\{nl\]'/*\{q#'ld;r'\}\{nlwb!/*de\}'c ;;\{nl'-\{\}rw\]'/+,\}##'*\}#nc,',#nw\]'/+kd'+e\}+;#'rdq#w! nr'/ ') \}+\}\{rl#'\{n' ')# \}'+\}##(!!/"]
- :$a<-50?[string compare [format %c $b] [string index $c 0]]==0?[append \
- xxx [string index $c 31];scan [string index $c 31] %c x;set x]
- :[12days -65 $b [string range $c 1 end]]:[12days [expr ([string compare \
- [string index $c 0] "/"]==0)+$a] $b [string range $c 1 end]]:0<$a
- ?[12days 2 2 "%s"]:[string compare [string index $c 0] "/"]==0||
- [12days 0 [12days -61 [scan [string index $c 0] %c x; set x] \
- "!ek;dc i@bK'(q)-\[w\]*%n+r3#l,\{\}:\nuwloca-O;m .vpbks,fxntdCeghiry"] \
- [string range $c 1 end]]}
-}
-proc do_twelve_days {} {
- global xxx
- set xxx ""
- 12days 1 1 1
- string length $xxx
-}
-
-# start of tests
-
-catch {unset a b i x}
-
-test expr-1.1 {TclCompileExprCmd: no expression} {
- list [catch {expr } msg] $msg
-} {1 {wrong # args: should be "expr arg ?arg ...?"}}
-test expr-1.2 {TclCompileExprCmd: one expression word} {
- expr -25
-} -25
-test expr-1.3 {TclCompileExprCmd: two expression words} {
- expr -8.2 -6
-} -14.2
-test expr-1.4 {TclCompileExprCmd: five expression words} {
- expr 20 - 5 +10 -7
-} 18
-test expr-1.5 {TclCompileExprCmd: quoted expression word} {
- expr "0005"
-} 5
-test expr-1.6 {TclCompileExprCmd: quoted expression word} {
- catch {expr "0005"zxy} msg
- set msg
-} {extra characters after close-quote}
-test expr-1.7 {TclCompileExprCmd: expression word in braces} {
- expr {-0005}
-} -5
-test expr-1.8 {TclCompileExprCmd: expression word in braces} {
- expr {{-0x1234}}
-} -4660
-test expr-1.9 {TclCompileExprCmd: expression word in braces} {
- catch {expr {-0005}foo} msg
- set msg
-} {extra characters after close-brace}
-test expr-1.10 {TclCompileExprCmd: other expression word in braces} {
- expr 4*[llength "6 2"]
-} 8
-test expr-1.11 {TclCompileExprCmd: expression word terminated by ;} {
- expr 4*[llength "6 2"];
-} 8
-test expr-1.12 {TclCompileExprCmd: inlined expr (in "catch") inside other catch} {
- set a xxx
- catch {
- # Might not be a number
- set a [expr 10*$a]
- }
-} 1
-test expr-1.13 {TclCompileExprCmd: second level of substitutions in expr not in braces with single var reference} {
- set a xxx
- set x 27; set bool {$x}; if $bool {set a foo}
- set a
-} foo
-test expr-1.14 {TclCompileExprCmd: second level of substitutions in expr with comparison as top-level operator} {
- set a xxx
- set x 2; set b {$x}; set a [expr $b == 2]
- set a
-} 1
-
-test expr-2.1 {TclCompileExpr: are builtin functions registered?} {
- expr double(5*[llength "6 2"])
-} 10.0
-test expr-2.2 {TclCompileExpr: error in expr} {
- catch {expr 2**3} msg
- set msg
-} {syntax error in expression "2**3"}
-test expr-2.3 {TclCompileExpr: junk after legal expr} {
- catch {expr 7*[llength "a b"]foo} msg
- set msg
-} {syntax error in expression "7*2foo"}
-test expr-2.4 {TclCompileExpr: numeric expr string rep == formatted int rep} {
- expr {0001}
-} 1
-
-test expr-3.1 {CompileCondExpr: just lor expr} {expr 3||0} 1
-test expr-3.2 {CompileCondExpr: error in lor expr} {
- catch {expr x||3} msg
- set msg
-} {syntax error in expression "x||3"}
-test expr-3.3 {CompileCondExpr: test true arm} {expr 3>2?44:66} 44
-test expr-3.4 {CompileCondExpr: error compiling true arm} {
- catch {expr 3>2?2**3:66} msg
- set msg
-} {syntax error in expression "3>2?2**3:66"}
-test expr-3.5 {CompileCondExpr: test false arm} {expr 2>3?44:66} 66
-test expr-3.6 {CompileCondExpr: error compiling false arm} {
- catch {expr 2>3?44:2**3} msg
- set msg
-} {syntax error in expression "2>3?44:2**3"}
-test expr-3.7 {CompileCondExpr: long arms & nested cond exprs} {unixOnly nonPortable} {
- puts "Note: doing test expr-3.7 which can take several minutes to run"
- hello_world
-} {Hello world}
-catch {unset xxx}
-test expr-3.8 {CompileCondExpr: long arms & nested cond exprs} {unixOnly nonPortable} {
- puts "Note: doing test expr-3.8 which can take several minutes to run"
- do_twelve_days
-} 2358
-catch {unset xxx}
-
-test expr-4.1 {CompileLorExpr: just land expr} {expr 1.3&&3.3} 1
-test expr-4.2 {CompileLorExpr: error in land expr} {
- catch {expr x&&3} msg
- set msg
-} {syntax error in expression "x&&3"}
-test expr-4.3 {CompileLorExpr: simple lor exprs} {expr 0||1.0} 1
-test expr-4.4 {CompileLorExpr: simple lor exprs} {expr 3.0||0.0} 1
-test expr-4.5 {CompileLorExpr: simple lor exprs} {expr 0||0||1} 1
-test expr-4.6 {CompileLorExpr: error compiling lor arm} {
- catch {expr 2**3||4.0} msg
- set msg
-} {syntax error in expression "2**3||4.0"}
-test expr-4.7 {CompileLorExpr: error compiling lor arm} {
- catch {expr 1.3||2**3} msg
- set msg
-} {syntax error in expression "1.3||2**3"}
-test expr-4.8 {CompileLorExpr: error compiling lor arms} {
- list [catch {expr {"a"||"b"}} msg] $msg
-} {1 {expected boolean value but got "a"}}
-test expr-4.9 {CompileLorExpr: long lor arm} {
- set a "abcdefghijkl"
- set i 7
- expr {[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]}
-} 1
-
-test expr-5.1 {CompileLandExpr: just bitor expr} {expr 7|0x13} 23
-test expr-5.2 {CompileLandExpr: error in bitor expr} {
- catch {expr x|3} msg
- set msg
-} {syntax error in expression "x|3"}
-test expr-5.3 {CompileLandExpr: simple land exprs} {expr 0&&1.0} 0
-test expr-5.4 {CompileLandExpr: simple land exprs} {expr 0&&0} 0
-test expr-5.5 {CompileLandExpr: simple land exprs} {expr 3.0&&1.2} 1
-test expr-5.6 {CompileLandExpr: simple land exprs} {expr 1&&1&&2} 1
-test expr-5.7 {CompileLandExpr: error compiling land arm} {
- catch {expr 2**3&&4.0} msg
- set msg
-} {syntax error in expression "2**3&&4.0"}
-test expr-5.8 {CompileLandExpr: error compiling land arm} {
- catch {expr 1.3&&2**3} msg
- set msg
-} {syntax error in expression "1.3&&2**3"}
-test expr-5.9 {CompileLandExpr: error compiling land arm} {
- list [catch {expr {"a"&&"b"}} msg] $msg
-} {1 {expected boolean value but got "a"}}
-test expr-5.10 {CompileLandExpr: long land arms} {
- set a "abcdefghijkl"
- set i 7
- expr {[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]] && [string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]] && [string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]] && [string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]}
-} 1
-
-test expr-6.1 {CompileBitXorExpr: just bitand expr} {expr 7&0x13} 3
-test expr-6.2 {CompileBitXorExpr: error in bitand expr} {
- catch {expr x|3} msg
- set msg
-} {syntax error in expression "x|3"}
-test expr-6.3 {CompileBitXorExpr: simple bitxor exprs} {expr 7^0x13} 20
-test expr-6.4 {CompileBitXorExpr: simple bitxor exprs} {expr 3^0x10} 19
-test expr-6.5 {CompileBitXorExpr: simple bitxor exprs} {expr 0^7} 7
-test expr-6.6 {CompileBitXorExpr: simple bitxor exprs} {expr -1^7} -8
-test expr-6.7 {CompileBitXorExpr: error compiling bitxor arm} {
- catch {expr 2**3|6} msg
- set msg
-} {syntax error in expression "2**3|6"}
-test expr-6.8 {CompileBitXorExpr: error compiling bitxor arm} {
- catch {expr 2^x} msg
- set msg
-} {syntax error in expression "2^x"}
-test expr-6.9 {CompileBitXorExpr: runtime error in bitxor arm} {
- list [catch {expr {24.0^3}} msg] $msg
-} {1 {can't use floating-point value as operand of "^"}}
-test expr-6.10 {CompileBitXorExpr: runtime error in bitxor arm} {
- list [catch {expr {"a"^"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "^"}}
-
-test expr-7.1 {CompileBitAndExpr: just equality expr} {expr 3==2} 0
-test expr-7.2 {CompileBitAndExpr: just equality expr} {expr 2.0==2} 1
-test expr-7.3 {CompileBitAndExpr: just equality expr} {expr 3.2!=2.2} 1
-test expr-7.4 {CompileBitAndExpr: just equality expr} {expr {"abc" == "abd"}} 0
-test expr-7.5 {CompileBitAndExpr: error in equality expr} {
- catch {expr x==3} msg
- set msg
-} {syntax error in expression "x==3"}
-test expr-7.6 {CompileBitAndExpr: simple bitand exprs} {expr 7&0x13} 3
-test expr-7.7 {CompileBitAndExpr: simple bitand exprs} {expr 0xf2&0x53} 82
-test expr-7.8 {CompileBitAndExpr: simple bitand exprs} {expr 3&6} 2
-test expr-7.9 {CompileBitAndExpr: simple bitand exprs} {expr -1&-7} -7
-test expr-7.10 {CompileBitAndExpr: error compiling bitand arm} {
- catch {expr 2**3&6} msg
- set msg
-} {syntax error in expression "2**3&6"}
-test expr-7.11 {CompileBitAndExpr: error compiling bitand arm} {
- catch {expr 2&x} msg
- set msg
-} {syntax error in expression "2&x"}
-test expr-7.12 {CompileBitAndExpr: runtime error in bitand arm} {
- list [catch {expr {24.0&3}} msg] $msg
-} {1 {can't use floating-point value as operand of "&"}}
-test expr-7.13 {CompileBitAndExpr: runtime error in bitand arm} {
- list [catch {expr {"a"&"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "&"}}
-
-test expr-8.1 {CompileEqualityExpr: just relational expr} {expr 3>=2} 1
-test expr-8.2 {CompileEqualityExpr: just relational expr} {expr 2<=2.1} 1
-test expr-8.3 {CompileEqualityExpr: just relational expr} {expr 3.2>"2.2"} 1
-test expr-8.4 {CompileEqualityExpr: just relational expr} {expr {"0y"<"0x12"}} 0
-test expr-8.5 {CompileEqualityExpr: error in relational expr} {
- catch {expr x>3} msg
- set msg
-} {syntax error in expression "x>3"}
-test expr-8.6 {CompileEqualityExpr: simple equality exprs} {expr 7==0x13} 0
-test expr-8.7 {CompileEqualityExpr: simple equality exprs} {expr -0xf2!=0x53} 1
-test expr-8.8 {CompileEqualityExpr: simple equality exprs} {expr {"12398712938788234-1298379" != ""}} 1
-test expr-8.9 {CompileEqualityExpr: simple equality exprs} {expr -1!="abc"} 1
-test expr-8.10 {CompileEqualityExpr: error compiling equality arm} {
- catch {expr 2**3==6} msg
- set msg
-} {syntax error in expression "2**3==6"}
-test expr-8.11 {CompileEqualityExpr: error compiling equality arm} {
- catch {expr 2!=x} msg
- set msg
-} {syntax error in expression "2!=x"}
-
-
-test expr-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12
-test expr-9.2 {CompileRelationalExpr: just shift expr} {expr 0xff>>2} 63
-test expr-9.3 {CompileRelationalExpr: just shift expr} {expr -1>>2} -1
-test expr-9.4 {CompileRelationalExpr: just shift expr} {expr {1<<3}} 8
-
-# The following test is different for 32-bit versus 64-bit
-# architectures because LONG_MIN is different
-
-if {0x80000000 > 0} {
- test expr-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} {
- expr {1<<63}
- } -9223372036854775808
-} else {
- test expr-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} {
- expr {1<<31}
- } -2147483648
-}
-test expr-9.6 {CompileRelationalExpr: error in shift expr} {
- catch {expr x>>3} msg
- set msg
-} {syntax error in expression "x>>3"}
-test expr-9.7 {CompileRelationalExpr: simple relational exprs} {expr 0xff>=+0x3} 1
-test expr-9.8 {CompileRelationalExpr: simple relational exprs} {expr -0xf2<0x3} 1
-test expr-9.9 {CompileRelationalExpr: error compiling relational arm} {
- catch {expr 2**3>6} msg
- set msg
-} {syntax error in expression "2**3>6"}
-test expr-9.10 {CompileRelationalExpr: error compiling relational arm} {
- catch {expr 2<x} msg
- set msg
-} {syntax error in expression "2<x"}
-
-test expr-10.1 {CompileShiftExpr: just add expr} {expr 4+-2} 2
-test expr-10.2 {CompileShiftExpr: just add expr} {expr 0xff-2} 253
-test expr-10.3 {CompileShiftExpr: just add expr} {expr -1--2} 1
-test expr-10.4 {CompileShiftExpr: just add expr} {expr 1-0123} -82
-test expr-10.5 {CompileShiftExpr: error in add expr} {
- catch {expr x+3} msg
- set msg
-} {syntax error in expression "x+3"}
-test expr-10.6 {CompileShiftExpr: simple shift exprs} {expr 0xff>>0x3} 31
-test expr-10.7 {CompileShiftExpr: simple shift exprs} {expr -0xf2<<0x3} -1936
-test expr-10.8 {CompileShiftExpr: error compiling shift arm} {
- catch {expr 2**3>>6} msg
- set msg
-} {syntax error in expression "2**3>>6"}
-test expr-10.9 {CompileShiftExpr: error compiling shift arm} {
- catch {expr 2<<x} msg
- set msg
-} {syntax error in expression "2<<x"}
-test expr-10.10 {CompileShiftExpr: runtime error} {
- list [catch {expr {24.0>>43}} msg] $msg
-} {1 {can't use floating-point value as operand of ">>"}}
-test expr-10.11 {CompileShiftExpr: runtime error} {
- list [catch {expr {"a"<<"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "<<"}}
-
-test expr-11.1 {CompileAddExpr: just multiply expr} {expr 4*-2} -8
-test expr-11.2 {CompileAddExpr: just multiply expr} {expr 0xff%2} 1
-test expr-11.3 {CompileAddExpr: just multiply expr} {expr -1/2} -1
-test expr-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0123} 6
-test expr-11.5 {CompileAddExpr: error in multiply expr} {
- catch {expr x*3} msg
- set msg
-} {syntax error in expression "x*3"}
-test expr-11.6 {CompileAddExpr: simple add exprs} {expr 0xff++0x3} 258
-test expr-11.7 {CompileAddExpr: simple add exprs} {expr -0xf2--0x3} -239
-test expr-11.8 {CompileAddExpr: error compiling add arm} {
- catch {expr 2**3+6} msg
- set msg
-} {syntax error in expression "2**3+6"}
-test expr-11.9 {CompileAddExpr: error compiling add arm} {
- catch {expr 2-x} msg
- set msg
-} {syntax error in expression "2-x"}
-test expr-11.10 {CompileAddExpr: runtime error} {
- list [catch {expr {24.0+"xx"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "+"}}
-test expr-11.11 {CompileAddExpr: runtime error} {
- list [catch {expr {"a"-"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "-"}}
-test expr-11.12 {CompileAddExpr: runtime error} {
- list [catch {expr {3/0}} msg] $msg
-} {1 {divide by zero}}
-test expr-11.13 {CompileAddExpr: runtime error} {
- list [catch {expr {2.3/0.0}} msg] $msg
-} {1 {divide by zero}}
-
-test expr-12.1 {CompileMultiplyExpr: just unary expr} {expr ~4} -5
-test expr-12.2 {CompileMultiplyExpr: just unary expr} {expr --5} 5
-test expr-12.3 {CompileMultiplyExpr: just unary expr} {expr !27} 0
-test expr-12.4 {CompileMultiplyExpr: just unary expr} {expr ~0xff00ff} -16711936
-test expr-12.5 {CompileMultiplyExpr: error in unary expr} {
- catch {expr ~x} msg
- set msg
-} {syntax error in expression "~x"}
-test expr-12.6 {CompileMultiplyExpr: simple multiply exprs} {expr 0xff*0x3} 765
-test expr-12.7 {CompileMultiplyExpr: simple multiply exprs} {expr -0xf2%-0x3} -2
-test expr-12.8 {CompileMultiplyExpr: error compiling multiply arm} {
- catch {expr 2*3%%6} msg
- set msg
-} {syntax error in expression "2*3%%6"}
-test expr-12.9 {CompileMultiplyExpr: error compiling multiply arm} {
- catch {expr 2*x} msg
- set msg
-} {syntax error in expression "2*x"}
-test expr-12.10 {CompileMultiplyExpr: runtime error} {
- list [catch {expr {24.0*"xx"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "*"}}
-test expr-12.11 {CompileMultiplyExpr: runtime error} {
- list [catch {expr {"a"/"b"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "/"}}
-
-test expr-13.1 {CompileUnaryExpr: unary exprs} {expr -0xff} -255
-test expr-13.2 {CompileUnaryExpr: unary exprs} {expr +000123} 83
-test expr-13.3 {CompileUnaryExpr: unary exprs} {expr +--++36} 36
-test expr-13.4 {CompileUnaryExpr: unary exprs} {expr !2} 0
-test expr-13.5 {CompileUnaryExpr: unary exprs} {expr +--+-62.0} -62.0
-test expr-13.6 {CompileUnaryExpr: unary exprs} {expr !0.0} 1
-test expr-13.7 {CompileUnaryExpr: unary exprs} {expr !0xef} 0
-test expr-13.8 {CompileUnaryExpr: error compiling unary expr} {
- catch {expr ~x} msg
- set msg
-} {syntax error in expression "~x"}
-test expr-13.9 {CompileUnaryExpr: error compiling unary expr} {
- catch {expr !1.x} msg
- set msg
-} {syntax error in expression "!1.x"}
-test expr-13.10 {CompileUnaryExpr: runtime error} {
- list [catch {expr {~"xx"}} msg] $msg
-} {1 {can't use non-numeric string as operand of "~"}}
-test expr-13.11 {CompileUnaryExpr: runtime error} {
- list [catch {expr ~4.0} msg] $msg
-} {1 {can't use floating-point value as operand of "~"}}
-test expr-13.12 {CompileUnaryExpr: just primary expr} {expr 0x123} 291
-test expr-13.13 {CompileUnaryExpr: just primary expr} {
- set a 27
- expr $a
-} 27
-test expr-13.14 {CompileUnaryExpr: just primary expr} {
- expr double(27)
-} 27.0
-test expr-13.15 {CompileUnaryExpr: just primary expr} {expr "123"} 123
-test expr-13.16 {CompileUnaryExpr: error in primary expr} {
- catch {expr [set]} msg
- set msg
-} {wrong # args: should be "set varName ?newValue?"}
-test expr-14.1 {CompilePrimaryExpr: literal primary} {expr 1} 1
-test expr-14.2 {CompilePrimaryExpr: literal primary} {expr 123} 123
-test expr-14.3 {CompilePrimaryExpr: literal primary} {expr 0xff} 255
-test expr-14.4 {CompilePrimaryExpr: literal primary} {expr 00010} 8
-test expr-14.5 {CompilePrimaryExpr: literal primary} {expr 62.0} 62.0
-test expr-14.6 {CompilePrimaryExpr: literal primary} {
- expr 3.1400000
-} 3.14
-test expr-14.7 {CompilePrimaryExpr: literal primary} {expr {{abcde}<{abcdef}}} 1
-test expr-14.8 {CompilePrimaryExpr: literal primary} {expr {{abc\
-def} < {abcdef}}} 1
-test expr-14.9 {CompilePrimaryExpr: literal primary} {expr {{abc\tde} > {abc\tdef}}} 0
-test expr-14.10 {CompilePrimaryExpr: literal primary} {expr {{123}}} 123
-test expr-14.11 {CompilePrimaryExpr: var reference primary} {
- set i 789
- list [expr {$i}] [expr $i]
-} {789 789}
-test expr-14.12 {CompilePrimaryExpr: var reference primary} {
- set i {789} ;# test expr's aggressive conversion to numeric semantics
- list [expr {$i}] [expr $i]
-} {789 789}
-test expr-14.13 {CompilePrimaryExpr: var reference primary} {
- catch {unset a}
- set a(foo) foo
- set a(bar) bar
- set a(123) 123
- set result ""
- lappend result [expr $a(123)] [expr {$a(bar)<$a(foo)}]
- catch {unset a}
- set result
-} {123 1}
-test expr-14.14 {CompilePrimaryExpr: var reference primary} {
- set i 123 ;# test "$var.0" floating point conversion hack
- list [expr $i] [expr $i.0] [expr $i.0/12.0]
-} {123 123.0 10.25}
-test expr-14.15 {CompilePrimaryExpr: var reference primary} {
- set i 123
- catch {expr $i.2} msg
- set msg
-} 123.2
-test expr-14.16 {CompilePrimaryExpr: error compiling var reference primary} {
- catch {expr {$a(foo}} msg
- set errorInfo
-} {missing )
- while compiling
-"expr {$a(foo}"}
-test expr-14.17 {CompilePrimaryExpr: string primary that looks like var ref} {
- expr $
-} $
-test expr-14.18 {CompilePrimaryExpr: quoted string primary} {
- expr "21"
-} 21
-test expr-14.19 {CompilePrimaryExpr: quoted string primary} {
- set i 123
- set x 456
- expr "$i+$x"
-} 579
-test expr-14.20 {CompilePrimaryExpr: quoted string primary} {
- set i 3
- set x 6
- expr 2+"$i.$x"
-} 5.6
-test expr-14.21 {CompilePrimaryExpr: error in quoted string primary} {
- catch {expr "[set]"} msg
- set msg
-} {wrong # args: should be "set varName ?newValue?"}
-test expr-14.22 {CompilePrimaryExpr: subcommand primary} {
- expr {[set i 123; set i]}
-} 123
-test expr-14.23 {CompilePrimaryExpr: error in subcommand primary} {
- catch {expr {[set]}} msg
- set errorInfo
-} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- while compiling
-"expr {[set]}"}
-test expr-14.24 {CompilePrimaryExpr: error in subcommand primary} {
- catch {expr {[set i}} msg
- set errorInfo
-} {missing close-bracket
- while compiling
-"expr {[set i}"}
-test expr-14.25 {CompilePrimaryExpr: math function primary} {
- format %.6g [expr exp(1.0)]
-} 2.71828
-test expr-14.26 {CompilePrimaryExpr: math function primary} {
- format %.6g [expr pow(2.0+0.1,3.0+0.1)]
-} 9.97424
-test expr-14.27 {CompilePrimaryExpr: error in math function primary} {
- catch {expr sinh::(2.0)} msg
- set errorInfo
-} {syntax error in expression "sinh::(2.0)"
- while compiling
-"expr sinh::(2.0)"}
-test expr-14.28 {CompilePrimaryExpr: subexpression primary} {
- expr 2+(3*4)
-} 14
-test expr-14.29 {CompilePrimaryExpr: error in subexpression primary} {
- catch {expr 2+(3*[set])} msg
- set errorInfo
-} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- while compiling
-"expr 2+(3*[set])"}
-test expr-14.30 {CompilePrimaryExpr: missing paren in subexpression primary} {
- catch {expr 2+(3*(4+5)} msg
- set errorInfo
-} {syntax error in expression "2+(3*(4+5)"
- while compiling
-"expr 2+(3*(4+5)"}
-test expr-14.31 {CompilePrimaryExpr: just var ref in subexpression primary} {
- set i "5+10"
- list "[expr $i] == 15" "[expr ($i)] == 15" "[eval expr ($i)] == 15"
-} {{15 == 15} {15 == 15} {15 == 15}}
-test expr-14.32 {CompilePrimaryExpr: unexpected token} {
- catch {expr @} msg
- set errorInfo
-} {syntax error in expression "@"
- while compiling
-"expr @"}
-
-test expr-15.1 {CompileMathFuncCall: missing parenthesis} {
- catch {expr sinh2.0)} msg
- set errorInfo
-} {syntax error in expression "sinh2.0)"
- while compiling
-"expr sinh2.0)"}
-test expr-15.2 {CompileMathFuncCall: unknown math function} {
- catch {expr whazzathuh(1)} msg
- set errorInfo
-} {unknown math function "whazzathuh"
- while compiling
-"expr whazzathuh(1)"}
-test expr-15.3 {CompileMathFuncCall: too many arguments} {
- catch {expr sin(1,2,3)} msg
- set errorInfo
-} {too many arguments for math function
- while compiling
-"expr sin(1,2,3)"}
-test expr-15.4 {CompileMathFuncCall: ')' found before last required arg} {
- catch {expr sin()} msg
- set errorInfo
-} {too few arguments for math function
- while compiling
-"expr sin()"}
-test expr-15.5 {CompileMathFuncCall: too few arguments} {
- catch {expr pow(1)} msg
- set errorInfo
-} {too few arguments for math function
- while compiling
-"expr pow(1)"}
-test expr-15.6 {CompileMathFuncCall: missing ')'} {
- catch {expr sin(1} msg
- set errorInfo
-} {syntax error in expression "sin(1"
- while compiling
-"expr sin(1"}
-if $gotT1 {
- test expr-15.7 {CompileMathFuncCall: call registered math function} {
- expr 2*T1()
- } 246
- test expr-15.8 {CompileMathFuncCall: call registered math function} {
- expr T2()*3
- } 1035
-
- test expr-15.9 {CompileMathFuncCall: call registered math function} {
- expr T3(21, 37)
- } 37
- test expr-15.10 {CompileMathFuncCall: call registered math function} {
- expr T3(21.2, 37)
- } 37.0
- test expr-15.11 {CompileMathFuncCall: call registered math function} {
- expr T3(-21.2, -17.5)
- } -17.5
-}
-
-test expr-16.1 {GetToken: checks whether integer token starting with "0x" (e.g., "0x$") is invalid} {
- catch {unset a}
- set a(VALUE) ff15
- set i 123
- if {[expr 0x$a(VALUE)] & 16} {
- set i {}
- }
- set i
-} {}
-test expr-16.2 {GetToken: check for string literal in braces} {
- expr {{1}}
-} {1}
-
-# Check "expr" and computed command names.
-
-test expr-17.1 {expr and computed command names} {
- set i 0
- set z expr
- $z 1+2
-} 3
-
-# Check correct conversion of operands to numbers: If the string looks like
-# an integer, convert to integer. Otherwise, if the string looks like a
-# double, convert to double.
-
-test expr-18.1 {expr and conversion of operands to numbers} {
- set x [lindex 11 0]
- catch {expr int($x)}
- expr {$x}
-} 11
-
-# Check "expr" and interpreter result object resetting before appending
-# an error msg during evaluation of exprs not in {}s
-
-test expr-19.1 {expr and interpreter result object resetting} {
- proc p {} {
- set t 10.0
- set x 2.0
- set dx 0.2
- set f {$dx-$x/10}
- set g {-$x/5}
- set center 1.0
- set x [expr $x-$center]
- set dx [expr $dx+$g]
- set x [expr $x+$f+$center]
- set x [expr $x+$f+$center]
- set y [expr round($x)]
- }
- p
-} 3
-
-# Test for incorrect "double evaluation" semantics
-
-test expr-20.1 {wrong brace matching} {
- catch {unset l}
- catch {unset r}
- catch {unset q}
- catch {unset cmd}
- catch {unset a}
- set l "\{"; set r "\}"; set q "\""
- set cmd "expr $l$q|$q == $q$r$q$r"
- list [catch $cmd a] $a
-} {1 {extra characters after close-brace}}
-test expr-20.2 {double invocation of variable traces} {knownBug} {
- set exprtracecounter 0
- proc exprtraceproc {args} {
- upvar #0 exprtracecounter counter
- set argc [llength $args]
- set extraargs [lrange $args 0 [expr {$argc - 4}]]
- set name [lindex $args [expr {$argc - 3}]]
- upvar 1 $name var
- if {[incr counter] % 2 == 1} {
- set var "$counter oops [concat $extraargs]"
- } else {
- set var "$counter + [concat $extraargs]"
- }
- }
- trace variable exprtracevar r [list exprtraceproc 10]
- list [catch {expr "$exprtracevar + 20"} a] $a \
- [catch {expr "$exprtracevar + 20"} b] $b \
- [unset exprtracevar exprtracecounter]
-} {1 {syntax error in expression "1 oops 10 + 20"} 0 32 {}}
-test expr-20.3 {broken substitution of integer digits} {
- # fails with 8.0.x, but not 8.1b2
- list [set a 000; expr 0x1$a] [set a 1; expr ${a}000]
-} {4096 1000}
-
-# cleanup
-unset a
-::tcltest::cleanupTests
-return
diff --git a/tests/fCmd.test b/tests/fCmd.test
deleted file mode 100644
index e1fc391..0000000
--- a/tests/fCmd.test
+++ /dev/null
@@ -1,2164 +0,0 @@
-# This file tests the tclFCmd.c file.
-#
-# 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) 1996-1997 Sun Microsystems, Inc.
-# Copyright (c) 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: fCmd.test,v 1.4 1999/04/16 00:47:27 stanton Exp $
-#
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[string compare testgetplatform [info commands testgetplatform]] != 0} {
- puts "This application hasn't been compiled with the \"testgetplatform\""
- puts "command, therefore I am skipping all of these tests."
- ::tcltest::cleanupTests
- return
-}
-
-set platform [testgetplatform]
-
-if {"[info commands testchmod]" != "testchmod"} {
- puts "Skipping fCmd tests. This application does not seem to have the"
- puts "testchmod command that is needed to run these tests."
- ::tcltest::cleanupTests
- return
-}
-
-# Several tests require need to match results against the unix username
-set user {}
-if {$tcl_platform(platform) == "unix"} {
- catch {set user [exec whoami]}
- if {$user == ""} {
- catch {regexp {^[^(]*\(([^)]*)\)} [exec id] dummy user}
- }
- if {$user == ""} {
- set user "root"
- }
-}
-
-proc createfile {file {string a}} {
- set f [open $file w]
- puts -nonewline $f $string
- close $f
- return $string
-}
-
-#
-# checkcontent --
-#
-# Ensures that file "file" contains only the string "matchString"
-# returns 0 if the file does not exist, or has a different content
-#
-proc checkcontent {file matchString} {
- if {[catch {
- set f [open $file]
- set fileString [read $f]
- close $f
- }]} {
- return 0
- }
- return [string match $matchString $fileString]
-}
-
-proc openup {path} {
- testchmod 777 $path
- if {[file isdirectory $path]} {
- catch {
- foreach p [glob [file join $path *]] {
- openup $p
- }
- }
- }
-}
-
-proc cleanup {args} {
- foreach p ". $args" {
- set x ""
- catch {
- set x [glob [file join $p tf*] [file join $p td*]]
- }
- foreach file $x {
- if {[catch {file delete -force -- $file}]} {
- catch {openup $file}
- catch {file delete -force -- $file}
- }
- }
- }
-}
-
-proc contents {file} {
- set f [open $file r]
- set r [read $f]
- close $f
- set r
-}
-
-set ::tcltest::testConfig(fileSharing) 0
-set ::tcltest::testConfig(notFileSharing) 1
-
-if {$tcl_platform(platform) == "macintosh"} {
- catch {file delete -force foo.dir}
- file mkdir foo.dir
- if {[catch {file attributes foo.dir -readonly 1}] == 0} {
- set ::tcltest::testConfig(fileSharing) 1
- set ::tcltest::testConfig(notFileSharing) 0
- }
- file delete -force foo.dir
-}
-
-set ::tcltest::testConfig(xdev) 0
-
-if {$tcl_platform(platform) == "unix"} {
- if {[catch {set m1 [exec df .]; set m2 [exec df /tmp]}] == 0} {
- set m1 [string range $m1 0 [expr [string first " " $m1]-1]]
- set m2 [string range $m2 0 [expr [string first " " $m2]-1]]
- if {$m1 != "" && $m2 != "" && $m1 != $m2 && [file exists $m1] && [file exists $m2]} {
- set ::tcltest::testConfig(xdev) 1
- }
- }
-}
-
-set root [lindex [file split [pwd]] 0]
-
-# A really long file name
-# length of long is 1216 chars, which should be greater than any static
-# buffer or allowable filename.
-
-set long "abcdefghihjllmnopqrstuvwxyz01234567890"
-append long $long
-append long $long
-append long $long
-append long $long
-append long $long
-
-test fCmd-1.1 {TclFileRenameCmd} {notRoot} {
- cleanup
- createfile tf1
- file rename tf1 tf2
- glob tf*
-} {tf2}
-
-test fCmd-2.1 {TclFileCopyCmd} {notRoot} {
- cleanup
- createfile tf1
- file copy tf1 tf2
- lsort [glob tf*]
-} {tf1 tf2}
-
-test fCmd-3.1 {FileCopyRename: FileForceOption fails} {notRoot} {
- list [catch {file rename -xyz} msg] $msg
-} {1 {bad option "-xyz": should be -force or --}}
-test fCmd-3.2 {FileCopyRename: not enough args} {notRoot} {
- list [catch {file rename xyz} msg] $msg
-} {1 {wrong # args: should be "file rename ?options? source ?source ...? target"}}
-test fCmd-3.3 {FileCopyRename: Tcl_TranslateFileName fails} {notRoot} {
- list [catch {file rename xyz ~nonexistantuser} msg] $msg
-} {1 {user "nonexistantuser" doesn't exist}}
-test fCmd-3.4 {FileCopyRename: Tcl_TranslateFileName passes} {notRoot} {
- cleanup
- list [catch {file copy tf1 ~} msg] $msg
-} {1 {error copying "tf1": no such file or directory}}
-test fCmd-3.5 {FileCopyRename: target doesn't exist: stat(target) != 0} {notRoot} {
- cleanup
- list [catch {file rename tf1 tf2 tf3} msg] $msg
-} {1 {error renaming: target "tf3" is not a directory}}
-test fCmd-3.6 {FileCopyRename: target tf3 is not a dir: !S_ISDIR(target)} \
- {notRoot} {
- cleanup
- createfile tf3
- list [catch {file rename tf1 tf2 tf3} msg] $msg
-} {1 {error renaming: target "tf3" is not a directory}}
-test fCmd-3.7 {FileCopyRename: target exists & is directory} {notRoot} {
- cleanup
- file mkdir td1
- createfile tf1 tf1
- file rename tf1 td1
- contents [file join td1 tf1]
-} {tf1}
-test fCmd-3.8 {FileCopyRename: too many arguments: argc - i > 2} {notRoot} {
- cleanup
- list [catch {file rename tf1 tf2 tf3} msg] $msg
-} {1 {error renaming: target "tf3" is not a directory}}
-test fCmd-3.9 {FileCopyRename: too many arguments: argc - i > 2} {notRoot} {
- cleanup
- list [catch {file copy -force -- tf1 tf2 tf3} msg] $msg
-} {1 {error copying: target "tf3" is not a directory}}
-test fCmd-3.10 {FileCopyRename: just 2 arguments} {notRoot} {
- cleanup
- createfile tf1 tf1
- file rename tf1 tf2
- contents tf2
-} {tf1}
-test fCmd-3.11 {FileCopyRename: just 2 arguments} {notRoot} {
- cleanup
- createfile tf1 tf1
- file rename -force -force -- tf1 tf2
- contents tf2
-} {tf1}
-test fCmd-3.12 {FileCopyRename: move each source: 1 source} {notRoot} {
- cleanup
- createfile tf1 tf1
- file mkdir td1
- file rename tf1 td1
- contents [file join td1 tf1]
-} {tf1}
-test fCmd-3.13 {FileCopyRename: move each source: multiple sources} {notRoot} {
- cleanup
- createfile tf1 tf1
- createfile tf2 tf2
- createfile tf3 tf3
- createfile tf4 tf4
- file mkdir td1
- file rename tf1 tf2 tf3 tf4 td1
- list [contents [file join td1 tf1]] [contents [file join td1 tf2]] \
- [contents [file join td1 tf3]] [contents [file join td1 tf4]]
-} {tf1 tf2 tf3 tf4}
-test fCmd-3.14 {FileCopyRename: FileBasename fails} {notRoot} {
- cleanup
- file mkdir td1
- list [catch {file rename ~nonexistantuser td1} msg] $msg
-} {1 {user "nonexistantuser" doesn't exist}}
-test fCmd-3.15 {FileCopyRename: source[0] == '\0'} {notRoot unixOrPc} {
- cleanup
- file mkdir td1
- list [catch {file rename / td1} msg] $msg
-} {1 {error renaming "/" to "td1": file already exists}}
-test fCmd-3.16 {FileCopyRename: break on first error} {notRoot} {
- cleanup
- createfile tf1
- createfile tf2
- createfile tf3
- createfile tf4
- file mkdir td1
- createfile [file join td1 tf3]
- list [catch {file rename tf1 tf2 tf3 tf4 td1} msg] $msg
-} [subst {1 {error renaming "tf3" to "[file join td1 tf3]": file already exists}}]
-
-test fCmd-4.1 {TclFileMakeDirsCmd: make each dir: 1 dir} {notRoot} {
- cleanup
- file mkdir td1
- glob td*
-} {td1}
-test fCmd-4.2 {TclFileMakeDirsCmd: make each dir: multiple dirs} {notRoot} {
- cleanup
- file mkdir td1 td2 td3
- lsort [glob td*]
-} {td1 td2 td3}
-test fCmd-4.3 {TclFileMakeDirsCmd: stops on first error} {notRoot} {
- cleanup
- createfile tf1
- catch {file mkdir td1 td2 tf1 td3 td4}
- glob td1 td2 tf1 td3 td4
-} {td1 td2 tf1}
-test fCmd-4.4 {TclFileMakeDirsCmd: Tcl_TranslateFileName fails} {notRoot} {
- cleanup
- list [catch {file mkdir ~nonexistantuser} msg] $msg
-} {1 {user "nonexistantuser" doesn't exist}}
-test fCmd-4.5 {TclFileMakeDirsCmd: Tcl_SplitPath returns 0: *name == '\0'} \
- {notRoot} {
- cleanup
- list [catch {file mkdir ""} msg] $msg
-} {1 {can't create directory "": no such file or directory}}
-test fCmd-4.6 {TclFileMakeDirsCmd: one level deep} {notRoot} {
- cleanup
- file mkdir td1
- glob td1
-} {td1}
-test fCmd-4.7 {TclFileMakeDirsCmd: multi levels deep} {notRoot} {
- cleanup
- file mkdir [file join td1 td2 td3 td4]
- glob td1 [file join td1 td2]
-} "td1 [file join td1 td2]"
-test fCmd-4.8 {TclFileMakeDirsCmd: already exist: lstat(target) == 0} {notRoot} {
- cleanup
- file mkdir td1
- set x [file exist td1]
- file mkdir td1
- list $x [file exist td1]
-} {1 1}
-test fCmd-4.9 {TclFileMakeDirsCmd: exists, not dir} {notRoot} {
- cleanup
- createfile tf1
- list [catch {file mkdir tf1} msg] $msg
-} [subst {1 {can't create directory "[file join tf1]": file already exists}}]
-test fCmd-4.10 {TclFileMakeDirsCmd: exists, is dir} {notRoot} {
- cleanup
- file mkdir td1
- set x [file exist td1]
- file mkdir td1
- list $x [file exist td1]
-} {1 1}
-test fCmd-4.11 {TclFileMakeDirsCmd: doesn't exist: errno != ENOENT} \
- {unixOnly notRoot} {
- cleanup
- file mkdir td1/td2/td3
- testchmod 000 td1/td2
- set msg [list [catch {file mkdir td1/td2/td3/td4} msg] $msg]
- testchmod 755 td1/td2
- set msg
-} {1 {can't create directory "td1/td2/td3": permission denied}}
-test fCmd-4.12 {TclFileMakeDirsCmd: doesn't exist: errno != ENOENT} {macOnly} {
- cleanup
- list [catch {file mkdir nonexistantvolume:} msg] $msg
-} {1 {can't create directory "nonexistantvolume:": invalid argument}}
-test fCmd-4.13 {TclFileMakeDirsCmd: doesn't exist: errno == ENOENT} {notRoot} {
- cleanup
- set x [file exist td1]
- file mkdir td1
- list $x [file exist td1]
-} {0 1}
-test fCmd-4.14 {TclFileMakeDirsCmd: TclpCreateDirectory fails} \
- {unixOnly notRoot} {
- cleanup
- file delete -force foo
- file mkdir foo
- file attr foo -perm 040000
- set result [list [catch {file mkdir foo/tf1} msg] $msg]
- file delete -force foo
- set result
-} {1 {can't create directory "foo/tf1": permission denied}}
-test fCmd-4.15 {TclFileMakeDirsCmd: TclpCreateDirectory fails} {macOnly} {
- list [catch {file mkdir ${root}:} msg] $msg
-} [subst {1 {can't create directory "${root}:": no such file or directory}}]
-test fCmd-4.16 {TclFileMakeDirsCmd: TclpCreateDirectory succeeds} {notRoot} {
- cleanup
- file mkdir tf1
- file exists tf1
-} {1}
-
-test fCmd-5.1 {TclFileDeleteCmd: FileForceOption fails} {notRoot} {
- list [catch {file delete -xyz} msg] $msg
-} {1 {bad option "-xyz": should be -force or --}}
-test fCmd-5.2 {TclFileDeleteCmd: not enough args} {notRoot} {
- list [catch {file delete -force -force} msg] $msg
-} {1 {wrong # args: should be "file delete ?options? file ?file ...?"}}
-test fCmd-5.3 {TclFileDeleteCmd: 1 file} {notRoot} {
- cleanup
- createfile tf1
- createfile tf2
- file mkdir td1
- file delete tf2
- glob tf* td*
-} {tf1 td1}
-test fCmd-5.4 {TclFileDeleteCmd: multiple files} {notRoot} {
- cleanup
- createfile tf1
- createfile tf2
- file mkdir td1
- set x [list [file exist tf1] [file exist tf2] [file exist td1]]
- file delete tf1 td1 tf2
- lappend x [file exist tf1] [file exist tf2] [file exist tf3]
-} {1 1 1 0 0 0}
-test fCmd-5.5 {TclFileDeleteCmd: stop at first error} {notRoot unixOrPc} {
- cleanup
- createfile tf1
- createfile tf2
- file mkdir td1
- catch {file delete tf1 td1 $root tf2}
- list [file exist tf1] [file exist tf2] [file exist td1]
-} {0 1 0}
-test fCmd-5.6 {TclFileDeleteCmd: Tcl_TranslateFileName fails} {notRoot} {
- list [catch {file delete ~nonexistantuser} msg] $msg
-} {1 {user "nonexistantuser" doesn't exist}}
-test fCmd-5.7 {TclFileDeleteCmd: Tcl_TranslateFileName succeeds} {notRoot} {
- catch {file delete ~/tf1}
- createfile ~/tf1
- file delete ~/tf1
-} {}
-test fCmd-5.8 {TclFileDeleteCmd: file doesn't exist: lstat(name) != 0} {notRoot} {
- cleanup
- set x [file exist tf1]
- file delete tf1
- list $x [file exist tf1]
-} {0 0}
-test fCmd-5.9 {TclFileDeleteCmd: is directory} {notRoot} {
- cleanup
- file mkdir td1
- file delete td1
- file exist td1
-} {0}
-test fCmd-5.10 {TclFileDeleteCmd: TclpRemoveDirectory fails} {notRoot} {
- cleanup
- file mkdir td1/td2
- list [catch {file delete td1} msg] $msg
-} {1 {error deleting "td1": directory not empty}}
-
-test fCmd-6.1 {CopyRenameOneFile: bad source} {notRoot} {
- # can't test this, because it's caught by FileCopyRename
-} {}
-test fCmd-6.2 {CopyRenameOneFile: bad target} {notRoot} {
- # can't test this, because it's caught by FileCopyRename
-} {}
-test fCmd-6.3 {CopyRenameOneFile: lstat(source) != 0} {notRoot} {
- cleanup
- list [catch {file rename tf1 tf2} msg] $msg
-} {1 {error renaming "tf1": no such file or directory}}
-test fCmd-6.4 {CopyRenameOneFile: lstat(source) == 0} {notRoot} {
- cleanup
- createfile tf1
- file rename tf1 tf2
- glob tf*
-} {tf2}
-test fCmd-6.5 {CopyRenameOneFile: lstat(target) != 0} {notRoot} {
- cleanup
- createfile tf1
- file rename tf1 tf2
- glob tf*
-} {tf2}
-test fCmd-6.6 {CopyRenameOneFile: errno != ENOENT} {unixOnly notRoot} {
- cleanup
- file mkdir td1
- testchmod 000 td1
- createfile tf1
- set msg [list [catch {file rename tf1 td1} msg] $msg]
- testchmod 755 td1
- set msg
-} {1 {error renaming "tf1" to "td1/tf1": permission denied}}
-test fCmd-6.7 {CopyRenameOneFile: errno != ENOENT} {95} {
- cleanup
- createfile tf1
- list [catch {file rename tf1 $long} msg] $msg
-} [subst {1 {error renaming "tf1" to "$long": file name too long}}]
-test fCmd-6.8 {CopyRenameOneFile: errno != ENOENT} {macOnly} {
- cleanup
- createfile tf1
- list [catch {file rename tf1 $long} msg] $msg
-} [subst {1 {error renaming "tf1" to "$long": file name too long}}]
-test fCmd-6.9 {CopyRenameOneFile: errno == ENOENT} {unixOnly notRoot} {
- cleanup
- createfile tf1
- file rename tf1 tf2
- glob tf*
-} {tf2}
-test fCmd-6.10 {CopyRenameOneFile: lstat(target) == 0} {notRoot} {
- cleanup
- createfile tf1
- createfile tf2
- list [catch {file rename tf1 tf2} msg] $msg
-} {1 {error renaming "tf1" to "tf2": file already exists}}
-test fCmd-6.11 {CopyRenameOneFile: force == 0} {notRoot} {
- cleanup
- createfile tf1
- createfile tf2
- list [catch {file rename tf1 tf2} msg] $msg
-} {1 {error renaming "tf1" to "tf2": file already exists}}
-test fCmd-6.12 {CopyRenameOneFile: force != 0} {notRoot} {
- cleanup
- createfile tf1
- createfile tf2
- file rename -force tf1 tf2
- glob tf*
-} {tf2}
-test fCmd-6.13 {CopyRenameOneFile: source is dir, target is file} {notRoot} {
- cleanup
- file mkdir td1
- file mkdir td2
- createfile [file join td2 td1]
- list [catch {file rename -force td1 td2} msg] $msg
-} [subst {1 {can't overwrite file "[file join td2 td1]" with directory "td1"}}]
-test fCmd-6.14 {CopyRenameOneFile: source is file, target is dir} {notRoot} {
- cleanup
- createfile tf1
- file mkdir [file join td1 tf1]
- list [catch {file rename -force tf1 td1} msg] $msg
-} [subst {1 {can't overwrite directory "[file join td1 tf1]" with file "tf1"}}]
-test fCmd-6.15 {CopyRenameOneFile: TclpRenameFile succeeds} {notRoot} {
- cleanup
- file mkdir [file join td1 td2]
- file mkdir td2
- createfile [file join td2 tf1]
- file rename -force td2 td1
- file exists [file join td1 td2 tf1]
-} {1}
-test fCmd-6.16 {CopyRenameOneFile: TclpCopyRenameOneFile fails} {notRoot} {
- cleanup
- file mkdir [file join td1 td2]
- createfile [file join td1 td2 tf1]
- file mkdir td2
- list [catch {file rename -force td2 td1} msg] $msg
-} [subst {1 {error renaming "td2" to "[file join td1 td2]": file already exists}}]
-
-test fCmd-6.17 {CopyRenameOneFile: errno == EINVAL} {notRoot} {
- cleanup
- list [catch {file rename -force $root tf1} msg] $msg
-} [subst {1 {error renaming "$root" to "tf1": trying to rename a volume or move a directory into itself}}]
-test fCmd-6.18 {CopyRenameOneFile: errno != EXDEV} {notRoot} {
- cleanup
- file mkdir [file join td1 td2]
- createfile [file join td1 td2 tf1]
- file mkdir td2
- list [catch {file rename -force td2 td1} msg] $msg
-} [subst {1 {error renaming "td2" to "[file join td1 td2]": file already exists}}]
-test fCmd-6.19 {CopyRenameOneFile: errno == EXDEV} {unixOnly notRoot} {
- cleanup /tmp
- createfile tf1
- file rename tf1 /tmp
- glob tf* /tmp/tf1
-} {/tmp/tf1}
-test fCmd-6.20 {CopyRenameOneFile: errno == EXDEV} {pcOnly} {
- catch {file delete -force c:/tcl8975@ d:/tcl8975@}
- file mkdir c:/tcl8975@
- if [catch {file rename c:/tcl8975@ d:/}] {
- list d:/tcl8975@
- } else {
- set msg [glob c:/tcl8975@ d:/tcl8975@]
- file delete -force d:/tcl8975@
- set msg
- }
-} {d:/tcl8975@}
-test fCmd-6.21 {CopyRenameOneFile: copy/rename: S_ISDIR(source)} \
- {unixOnly notRoot} {
- cleanup /tmp
- file mkdir td1
- file rename td1 /tmp
- glob td* /tmp/td*
-} {/tmp/td1}
-test fCmd-6.22 {CopyRenameOneFile: copy/rename: !S_ISDIR(source)} \
- {unixOnly notRoot} {
- cleanup /tmp
- createfile tf1
- file rename tf1 /tmp
- glob tf* /tmp/tf*
-} {/tmp/tf1}
-test fCmd-6.23 {CopyRenameOneFile: TclpCopyDirectory failed} \
- {unixOnly notRoot xdev} {
- cleanup /tmp
- file mkdir td1/td2/td3
- exec chmod 000 td1
- set msg [list [catch {file rename td1 /tmp} msg] $msg]
- exec chmod 755 td1
- set msg
-} {1 {error renaming "td1": permission denied}}
-test fCmd-6.24 {CopyRenameOneFile: error uses original name} \
- {unixOnly notRoot} {
- cleanup
- file mkdir ~/td1/td2
- exec chmod 000 [file join [file dirname ~] [file tail ~] td1]
- set msg [list [catch {file copy ~/td1 td1} msg] $msg]
- exec chmod 755 [file join [file dirname ~] [file tail ~] td1]
- file delete -force ~/td1
- set msg
-} {1 {error copying "~/td1": permission denied}}
-test fCmd-6.25 {CopyRenameOneFile: error uses original name} \
- {unixOnly notRoot} {
- cleanup
- file mkdir td2
- file mkdir ~/td1
- exec chmod 000 [file join [file dirname ~] [file tail ~] td1]
- set msg [list [catch {file copy td2 ~/td1} msg] $msg]
- exec chmod 755 [file join [file dirname ~] [file tail ~] td1]
- file delete -force ~/td1
- set msg
-} {1 {error copying "td2" to "~/td1/td2": permission denied}}
-test fCmd-6.26 {CopyRenameOneFile: doesn't use original name} \
- {unixOnly notRoot} {
- cleanup
- file mkdir ~/td1/td2
- exec chmod 000 [file join [file dirname ~] [file tail ~] td1 td2]
- set msg [list [catch {file copy ~/td1 td1} msg] $msg]
- exec chmod 755 [file join [file dirname ~] [file tail ~] td1 td2]
- file delete -force ~/td1
- set msg
-} "1 {error copying \"~/td1\" to \"td1\": \"[file join [file dirname ~] [file tail ~] td1 td2]\": permission denied}"
-test fCmd-6.27 {CopyRenameOneFile: TclpCopyDirectory failed} \
- {unixOnly notRoot xdev} {
- cleanup /tmp
- file mkdir td1/td2/td3
- file mkdir /tmp/td1
- createfile /tmp/td1/tf1
- list [catch {file rename -force td1 /tmp} msg] $msg
-} {1 {error renaming "td1" to "/tmp/td1": file already exists}}
-test fCmd-6.28 {CopyRenameOneFile: TclpCopyDirectory failed} \
- {unixOnly notRoot xdev} {
- cleanup /tmp
- file mkdir td1/td2/td3
- exec chmod 000 td1/td2/td3
- set msg [list [catch {file rename td1 /tmp} msg] $msg]
- exec chmod 755 td1/td2/td3
- set msg
-} {1 {error renaming "td1" to "/tmp/td1": "td1/td2/td3": permission denied}}
-test fCmd-6.29 {CopyRenameOneFile: TclpCopyDirectory passed} \
- {unixOnly notRoot xdev} {
- cleanup /tmp
- file mkdir td1/td2/td3
- file rename td1 /tmp
- glob td* /tmp/td1/t*
-} {/tmp/td1/td2}
-test fCmd-6.30 {CopyRenameOneFile: TclpRemoveDirectory failed} \
- {unixOnly notRoot} {
- cleanup
- file mkdir foo/bar
- file attr foo -perm 040555
- set catchResult [catch {file rename foo/bar /tmp} msg]
- set msg [lindex [split $msg :] end]
- catch {file delete /tmp/bar}
- catch {file attr foo -perm 040777}
- catch {file delete -force foo}
- list $catchResult $msg
-} {1 { permission denied}}
-test fCmd-6.31 {CopyRenameOneFile: TclpDeleteFile passed} \
- {unixOnly notRoot xdev} {
- catch {cleanup /tmp}
- file mkdir /tmp/td1
- createfile /tmp/td1/tf1
- file rename /tmp/td1/tf1 tf1
- list [file exists /tmp/td1/tf1] [file exists tf1]
-} {0 1}
-test fCmd-6.32 {CopyRenameOneFile: copy} {notRoot} {
- cleanup
- list [catch {file copy tf1 tf2} msg] $msg
-} {1 {error copying "tf1": no such file or directory}}
-catch {cleanup /tmp}
-
-test fCmd-7.1 {FileForceOption: none} {notRoot} {
- cleanup
- file mkdir [file join tf1 tf2]
- list [catch {file delete tf1} msg] $msg
-} {1 {error deleting "tf1": directory not empty}}
-test fCmd-7.2 {FileForceOption: -force} {notRoot} {
- cleanup
- file mkdir [file join tf1 tf2]
- file delete -force tf1
-} {}
-test fCmd-7.3 {FileForceOption: --} {notRoot} {
- createfile -tf1
- file delete -- -tf1
-} {}
-test fCmd-7.4 {FileForceOption: bad option} {notRoot} {
- createfile -tf1
- set msg [list [catch {file delete -tf1} msg] $msg]
- file delete -- -tf1
- set msg
-} {1 {bad option "-tf1": should be -force or --}}
-test fCmd-7.5 {FileForceOption: multiple times through loop} {notRoot} {
- createfile --
- createfile -force
- file delete -force -force -- -- -force
- list [catch {glob -- -- -force} msg] $msg
-} {1 {no files matched glob patterns "-- -force"}}
-
-test fCmd-8.1 {FileBasename: basename of ~user: argc == 1 && *path == ~} \
- {unixOnly notRoot} {
- file mkdir td1
- file attr td1 -perm 040000
- set result [list [catch {file rename ~$user td1} msg] $msg]
- file delete -force td1
- set result
-} "1 {error renaming \"~$user\" to \"td1/[file tail ~$user]\": permission denied}"
-
-test fCmd-9.1 {file rename: comprehensive: EACCES} {unixOnly notRoot} {
- cleanup
- file mkdir td1
- file mkdir td2
- file attr td2 -perm 040000
- set result [list [catch {file rename td1 td2/} msg] $msg]
- file delete -force td2
- file delete -force td1
- set result
-} {1 {error renaming "td1" to "td2/td1": permission denied}}
-test fCmd-9.2 {file rename: comprehensive: source doesn't exist} {notRoot} {
- cleanup
- list [catch {file rename tf1 tf2} msg] $msg
-} {1 {error renaming "tf1": no such file or directory}}
-test fCmd-9.3 {file rename: comprehensive: file to new name} {notRoot} {
- cleanup
- createfile tf1
- createfile tf2
- testchmod 444 tf2
- file rename tf1 tf3
- file rename tf2 tf4
- list [lsort [glob tf*]] [file writable tf3] [file writable tf4]
-} {{tf3 tf4} 1 0}
-test fCmd-9.4 {file rename: comprehensive: dir to new name} {unixOrPc notRoot} {
- cleanup
- file mkdir td1 td2
- testchmod 555 td2
- file rename td1 td3
- file rename td2 td4
- list [lsort [glob td*]] [file writable td3] [file writable td4]
-} {{td3 td4} 1 0}
-test fCmd-9.5 {file rename: comprehensive: file to self} {notRoot} {
- cleanup
- createfile tf1 tf1
- createfile tf2 tf2
- testchmod 444 tf2
- file rename -force tf1 tf1
- file rename -force tf2 tf2
- list [contents tf1] [contents tf2] [file writable tf1] [file writable tf2]
-} {tf1 tf2 1 0}
-test fCmd-9.6 {file rename: comprehensive: dir to self} {notRoot unixOrPc} {
- cleanup
- file mkdir td1
- file mkdir td2
- testchmod 555 td2
- file rename -force td1 .
- file rename -force td2 .
- list [lsort [glob td*]] [file writable td1] [file writable td2]
-} {{td1 td2} 1 0}
-test fCmd-9.7 {file rename: comprehensive: file to existing file} {notRoot} {
- cleanup
- createfile tf1
- createfile tf2
- createfile tfs1
- createfile tfs2
- createfile tfs3
- createfile tfs4
- createfile tfd1
- createfile tfd2
- createfile tfd3
- createfile tfd4
- testchmod 444 tfs3
- testchmod 444 tfs4
- testchmod 444 tfd2
- testchmod 444 tfd4
- set msg [list [catch {file rename tf1 tf2} msg] $msg]
- file rename -force tfs1 tfd1
- file rename -force tfs2 tfd2
- file rename -force tfs3 tfd3
- file rename -force tfs4 tfd4
- list [lsort [glob tf*]] $msg [file writable tfd1] [file writable tfd2] [file writable tfd3] [file writable tfd4]
-} {{tf1 tf2 tfd1 tfd2 tfd3 tfd4} {1 {error renaming "tf1" to "tf2": file already exists}} 1 1 0 0}
-test fCmd-9.8 {file rename: comprehensive: dir to empty dir} {notRoot} {
- # Under unix, you can rename a read-only directory, but you can't
- # move it into another directory.
-
- cleanup
- file mkdir td1
- file mkdir [file join td2 td1]
- file mkdir tds1
- file mkdir tds2
- file mkdir tds3
- file mkdir tds4
- file mkdir [file join tdd1 tds1]
- file mkdir [file join tdd2 tds2]
- file mkdir [file join tdd3 tds3]
- file mkdir [file join tdd4 tds4]
- if {$tcl_platform(platform) != "unix" && $tcl_platform(platform) != "macintosh"} {
- testchmod 555 tds3
- testchmod 555 tds4
- }
- if {$tcl_platform(platform) != "macintosh"} {
- testchmod 555 [file join tdd2 tds2]
- testchmod 555 [file join tdd4 tds4]
- }
- set msg [list [catch {file rename td1 td2} msg] $msg]
- file rename -force tds1 tdd1
- file rename -force tds2 tdd2
- file rename -force tds3 tdd3
- file rename -force tds4 tdd4
- if {$tcl_platform(platform) != "unix" && $tcl_platform(platform) != "macintosh"} {
- set w3 [file writable [file join tdd3 tds3]]
- set w4 [file writable [file join tdd4 tds4]]
- } else {
- set w3 0
- set w4 0
- }
- list [lsort [glob td*]] $msg [file writable [file join tdd1 tds1]] \
- [file writable [file join tdd2 tds2]] $w3 $w4
-} [subst {{td1 td2 tdd1 tdd2 tdd3 tdd4} {1 {error renaming "td1" to "[file join td2 td1]": file already exists}} 1 1 0 0}]
-test fCmd-9.9 {file rename: comprehensive: dir to non-empty dir} {notRoot} {
- cleanup
- file mkdir tds1
- file mkdir tds2
- file mkdir [file join tdd1 tds1 xxx]
- file mkdir [file join tdd2 tds2 xxx]
- if {$tcl_platform(platform) != "unix" && $tcl_platform(platform) != "macintosh"} {
- testchmod 555 tds2
- }
- set a1 [list [catch {file rename -force tds1 tdd1} msg] $msg]
- set a2 [list [catch {file rename -force tds2 tdd2} msg] $msg]
- if {$tcl_platform(platform) != "unix" && $tcl_platform(platform) != "macintosh"} {
- set w2 [file writable tds2]
- } else {
- set w2 0
- }
- list [lsort [glob td*]] $a1 $a2 [file writable tds1] $w2
-} [subst {{tdd1 tdd2 tds1 tds2} {1 {error renaming "tds1" to "[file join tdd1 tds1]": file already exists}} {1 {error renaming "tds2" to "[file join tdd2 tds2]": file already exists}} 1 0}]
-test fCmd-9.10 {file rename: comprehensive: file to new name and dir} {notRoot} {
- cleanup
- createfile tf1
- createfile tf2
- file mkdir td1
- testchmod 444 tf2
- file rename tf1 [file join td1 tf3]
- file rename tf2 [file join td1 tf4]
- list [catch {glob tf*}] [lsort [glob [file join td1 t*]]] \
- [file writable [file join td1 tf3]] [file writable [file join td1 tf4]]
-} [subst {1 {[file join td1 tf3] [file join td1 tf4]} 1 0}]
-test fCmd-9.11 {file rename: comprehensive: dir to new name and dir} {notRoot} {
- cleanup
- file mkdir td1
- file mkdir td2
- file mkdir td3
- if {$tcl_platform(platform) != "unix" && $tcl_platform(platform) != "macintosh"} {
- testchmod 555 td2
- }
- file rename td1 [file join td3 td3]
- file rename td2 [file join td3 td4]
- if {$tcl_platform(platform) != "unix" && $tcl_platform(platform) != "macintosh"} {
- set w4 [file writable [file join td3 td4]]
- } else {
- set w4 0
- }
- list [lsort [glob td*]] [lsort [glob [file join td3 t*]]] \
- [file writable [file join td3 td3]] $w4
-} [subst {td3 {[file join td3 td3] [file join td3 td4]} 1 0}]
-test fCmd-9.12 {file rename: comprehensive: target exists} {notRoot} {
- cleanup
- file mkdir [file join td1 td2] [file join td2 td1]
- if {$tcl_platform(platform) != "macintosh"} {
- testchmod 555 [file join td2 td1]
- }
- file mkdir [file join td3 td4] [file join td4 td3]
- file rename -force td3 td4
- set msg [list [file exists td3] [file exists [file join td4 td3 td4]] \
- [catch {file rename td1 td2} msg] $msg]
- if {$tcl_platform(platform) != "macintosh"} {
- testchmod 755 [file join td2 td1]
- }
- set msg
-} [subst {0 1 1 {error renaming "td1" to "[file join td2 td1]": file already exists}}]
-test fCmd-9.13 {file rename: comprehensive: can't overwrite target} {notRoot} {
- cleanup
- file mkdir [file join td1 td2] [file join td2 td1 td4]
- list [catch {file rename -force td1 td2} msg] $msg
-} [subst {1 {error renaming "td1" to "[file join td2 td1]": file already exists}}]
-test fCmd-9.14 {file rename: comprehensive: dir into self} {notRoot} {
- cleanup
- file mkdir td1
- list [glob td*] [list [catch {file rename td1 td1} msg] $msg]
-} [subst {td1 {1 {error renaming "td1" to "[file join td1 td1]": trying to rename a volume or move a directory into itself}}}]
-test fCmd-9.15 {file rename: comprehensive: source and target incompatible} \
- {notRoot} {
- cleanup
- file mkdir td1
- createfile tf1
- list [catch {file rename -force td1 tf1} msg] $msg
-} {1 {can't overwrite file "tf1" with directory "td1"}}
-test fCmd-9.16 {file rename: comprehensive: source and target incompatible} \
- {notRoot} {
- cleanup
- file mkdir td1/tf1
- createfile tf1
- list [catch {file rename -force tf1 td1} msg] $msg
-} [subst {1 {can't overwrite directory "[file join td1 tf1]" with file "tf1"}}]
-
-test fCmd-10.1 {file copy: comprehensive: source doesn't exist} {notRoot} {
- cleanup
- list [catch {file copy tf1 tf2} msg] $msg
-} {1 {error copying "tf1": no such file or directory}}
-test fCmd-10.2 {file copy: comprehensive: file to new name} {notRoot} {
- cleanup
- createfile tf1 tf1
- createfile tf2 tf2
- testchmod 444 tf2
- file copy tf1 tf3
- file copy tf2 tf4
- list [lsort [glob tf*]] [contents tf3] [contents tf4] [file writable tf3] [file writable tf4]
-} {{tf1 tf2 tf3 tf4} tf1 tf2 1 0}
-test fCmd-10.3 {file copy: comprehensive: dir to new name} {notRoot unixOrPc} {
- cleanup
- file mkdir [file join td1 tdx]
- file mkdir [file join td2 tdy]
- testchmod 555 td2
- file copy td1 td3
- file copy td2 td4
- set msg [list [lsort [glob td*]] [glob [file join td3 t*]] \
- [glob [file join td4 t*]] [file writable td3] [file writable td4]]
- if {$tcl_platform(platform) != "macintosh"} {
- testchmod 755 td2
- testchmod 755 td4
- }
- set msg
-} [subst {{td1 td2 td3 td4} [file join td3 tdx] [file join td4 tdy] 1 0}]
-test fCmd-10.4 {file copy: comprehensive: file to existing file} {notRoot} {
- cleanup
- createfile tf1
- createfile tf2
- createfile tfs1
- createfile tfs2
- createfile tfs3
- createfile tfs4
- createfile tfd1
- createfile tfd2
- createfile tfd3
- createfile tfd4
- testchmod 444 tfs3
- testchmod 444 tfs4
- testchmod 444 tfd2
- testchmod 444 tfd4
- set msg [list [catch {file copy tf1 tf2} msg] $msg]
- file copy -force tfs1 tfd1
- file copy -force tfs2 tfd2
- file copy -force tfs3 tfd3
- file copy -force tfs4 tfd4
- list [lsort [glob tf*]] $msg [file writable tfd1] [file writable tfd2] [file writable tfd3] [file writable tfd4]
-} {{tf1 tf2 tfd1 tfd2 tfd3 tfd4 tfs1 tfs2 tfs3 tfs4} {1 {error copying "tf1" to "tf2": file already exists}} 1 1 0 0}
-test fCmd-10.5 {file copy: comprehensive: dir to empty dir} {notRoot} {
- cleanup
- file mkdir td1
- file mkdir [file join td2 td1]
- file mkdir tds1
- file mkdir tds2
- file mkdir tds3
- file mkdir tds4
- file mkdir [file join tdd1 tds1]
- file mkdir [file join tdd2 tds2]
- file mkdir [file join tdd3 tds3]
- file mkdir [file join tdd4 tds4]
- if {$tcl_platform(platform) != "macintosh"} {
- testchmod 555 tds3
- testchmod 555 tds4
- testchmod 555 [file join tdd2 tds2]
- testchmod 555 [file join tdd4 tds4]
- }
- set a1 [list [catch {file copy td1 td2} msg] $msg]
- set a2 [list [catch {file copy -force tds1 tdd1} msg] $msg]
- set a3 [catch {file copy -force tds2 tdd2}]
- set a4 [catch {file copy -force tds3 tdd3}]
- set a5 [catch {file copy -force tds4 tdd4}]
- list [lsort [glob td*]] $a1 $a2 $a3 $a4 $a5
-} [subst {{td1 td2 tdd1 tdd2 tdd3 tdd4 tds1 tds2 tds3 tds4} {1 {error copying "td1" to "[file join td2 td1]": file already exists}} {1 {error copying "tds1" to "[file join tdd1 tds1]": file already exists}} 1 1 1}]
-test fCmd-10.6 {file copy: comprehensive: dir to non-empty dir} \
- {notRoot unixOrPc} {
- cleanup
- file mkdir tds1
- file mkdir tds2
- file mkdir [file join tdd1 tds1 xxx]
- file mkdir [file join tdd2 tds2 xxx]
- testchmod 555 tds2
- set a1 [list [catch {file copy -force tds1 tdd1} msg] $msg]
- set a2 [list [catch {file copy -force tds2 tdd2} msg] $msg]
- list [lsort [glob td*]] $a1 $a2 [file writable tds1] [file writable tds2]
-} [subst {{tdd1 tdd2 tds1 tds2} {1 {error copying "tds1" to "[file join tdd1 tds1]": file already exists}} {1 {error copying "tds2" to "[file join tdd2 tds2]": file already exists}} 1 0}]
-test fCmd-10.7 {file rename: comprehensive: file to new name and dir} {notRoot} {
- cleanup
- createfile tf1
- createfile tf2
- file mkdir td1
- testchmod 444 tf2
- file copy tf1 [file join td1 tf3]
- file copy tf2 [file join td1 tf4]
- list [lsort [glob tf*]] [lsort [glob [file join td1 t*]]] \
- [file writable [file join td1 tf3]] [file writable [file join td1 tf4]]
-} [subst {{tf1 tf2} {[file join td1 tf3] [file join td1 tf4]} 1 0}]
-test fCmd-10.8 {file rename: comprehensive: dir to new name and dir} \
- {notRoot unixOrPc} {
- cleanup
- file mkdir td1
- file mkdir td2
- file mkdir td3
- testchmod 555 td2
- file copy td1 [file join td3 td3]
- file copy td2 [file join td3 td4]
- list [lsort [glob td*]] [lsort [glob [file join td3 t*]]] \
- [file writable [file join td3 td3]] [file writable [file join td3 td4]]
-} [subst {{td1 td2 td3} {[file join td3 td3] [file join td3 td4]} 1 0}]
-test fCmd-10.9 {file copy: comprehensive: source and target incompatible} \
- {notRoot} {
- cleanup
- file mkdir td1
- createfile tf1
- list [catch {file copy -force td1 tf1} msg] $msg
-} {1 {can't overwrite file "tf1" with directory "td1"}}
-test fCmd-10.10 {file copy: comprehensive: source and target incompatible} \
- {notRoot} {
- cleanup
- file mkdir [file join td1 tf1]
- createfile tf1
- list [catch {file copy -force tf1 td1} msg] $msg
-} [subst {1 {can't overwrite directory "[file join td1 tf1]" with file "tf1"}}]
-cleanup
-
-# old tests
-
-test fCmd-11.1 {TclFileRenameCmd: -- option } {notRoot} {
- catch {file delete -force -- -tfa1}
- set s [createfile -tfa1]
- file rename -- -tfa1 tfa2
- set result [expr [checkcontent tfa2 $s] && ![file exists -tfa1]]
- file delete tfa2
- set result
-} {1}
-
-test fCmd-11.2 {TclFileRenameCmd: bad option } {notRoot} {
- catch {file delete -force -- tfa1}
- set s [createfile tfa1]
- set r1 [catch {file rename -x tfa1 tfa2}]
- set result [expr $r1 && [checkcontent tfa1 $s] && ![file exists tfa2]]
- file delete tfa1
- set result
-} {1}
-
-test fCmd-11.3 {TclFileRenameCmd: bad \# args} {
- catch {file rename -- }
-} {1}
-
-test fCmd-11.4 {TclFileRenameCmd: target filename translation failing} {notRoot} {
- global env
- set temp $env(HOME)
- unset env(HOME)
- set result [catch {file rename tfa ~/foobar }]
- set env(HOME) $temp
- set result
- } {1}
-
-test fCmd-11.5 {TclFileRenameCmd: > 1 source & target is not a dir} {notRoot} {
- catch {file delete -force -- tfa1 tfa2 tfa3}
- createfile tfa1
- createfile tfa2
- createfile tfa3
- set result [catch {file rename tfa1 tfa2 tfa3}]
- file delete tfa1 tfa2 tfa3
- set result
-} {1}
-
-test fCmd-11.6 {TclFileRenameCmd: : single file into directory} {notRoot} {
- catch {file delete -force -- tfa1 tfad}
- set s [createfile tfa1]
- file mkdir tfad
- file rename tfa1 tfad
- set result [expr [checkcontent tfad/tfa1 $s] && ![file exists tfa1]]
- file delete -force tfad
- set result
-} {1}
-
-test fCmd-11.7 {TclFileRenameCmd: : multiple files into directory} {notRoot} {
- catch {file delete -force -- tfa1 tfa2 tfad}
- set s1 [createfile tfa1 ]
- set s2 [createfile tfa2 ]
- file mkdir tfad
- file rename tfa1 tfa2 tfad
- set r1 [checkcontent tfad/tfa1 $s1]
- set r2 [checkcontent tfad/tfa2 $s2]
-
- set result [expr $r1 && $r2 && ![file exists tfa1] && ![file exists tfa2]]
-
- file delete -force tfad
- set result
-} {1}
-
-test fCmd-11.8 {TclFileRenameCmd: error renaming file to directory} {notRoot} {
- catch {file delete -force -- tfa tfad}
- set s [createfile tfa ]
- file mkdir tfad
- file mkdir tfad/tfa
- set r1 [catch {file rename tfa tfad}]
- set r2 [checkcontent tfa $s]
- set r3 [file isdir tfad]
- set result [expr $r1 && $r2 && $r3 ]
- file delete -force tfa tfad
- set result
-} {1}
-
-#
-# Coverage tests for renamefile() ;
-#
-test fCmd-12.1 {renamefile: source filename translation failing} {notRoot} {
- global env
- set temp $env(HOME)
- unset env(HOME)
- set result [catch {file rename ~/tfa1 tfa2}]
- set env(HOME) $temp
- set result
-} {1}
-
-test fCmd-12.2 {renamefile: src filename translation failing} {notRoot} {
- global env
- set temp $env(HOME)
- unset env(HOME)
- set s [createfile tfa1]
- file mkdir tfad
- set result [catch {file rename tfa1 ~/tfa2 tfad}]
- set env(HOME) $temp
- file delete -force tfad
- set result
-} {1}
-
-test fCmd-12.3 {renamefile: stat failing on source} {notRoot} {
- catch {file delete -force -- tfa1 tfa2}
- set r1 [catch {file rename tfa1 tfa2}]
- expr {$r1 && ![file exists tfa1] && ![file exists tfa2]}
-} {1}
-
-test fCmd-12.4 {renamefile: error renaming file to directory} {notRoot} {
- catch {file delete -force -- tfa tfad}
- set s1 [createfile tfa ]
- file mkdir tfad
- file mkdir tfad/tfa
- set r1 [catch {file rename tfa tfad}]
- set r2 [checkcontent tfa $s1]
- set r3 [file isdir tfad/tfa]
- set result [expr $r1 && $r2 && $r3]
- file delete -force tfa tfad
- set result
-} {1}
-
-test fCmd-12.5 {renamefile: error renaming directory to file} {notRoot} {
- catch {file delete -force -- tfa tfad}
- file mkdir tfa
- file mkdir tfad
- set s [createfile tfad/tfa]
- set r1 [catch {file rename tfa tfad}]
- set r2 [checkcontent tfad/tfa $s]
- set r3 [file isdir tfad]
- set r4 [file isdir tfa]
- set result [expr $r1 && $r2 && $r3 && $r4 ]
- file delete -force tfa tfad
- set result
-} {1}
-
-test fCmd-12.6 {renamefile: TclRenameFile succeeding} {notRoot} {
- catch {file delete -force -- tfa1 tfa2}
- set s [createfile tfa1]
- file rename tfa1 tfa2
- set result [expr [checkcontent tfa2 $s] && ![file exists tfa1]]
- file delete tfa2
- set result
-} {1}
-
-test fCmd-12.7 {renamefile: renaming directory into offspring} {notRoot} {
- catch {file delete -force -- tfad}
- file mkdir tfad
- file mkdir tfad/dir
- set result [catch {file rename tfad tfad/dir}]
- file delete -force tfad
- set result
-} {1}
-
-test fCmd-12.8 {renamefile: generic error} {unixOnly notRoot} {
- catch {file delete -force -- tfa}
- file mkdir tfa
- file mkdir tfa/dir
- exec chmod 555 tfa
- set result [catch {file rename tfa/dir tfa2}]
- exec chmod 777 tfa
- file delete -force tfa
- set result
-} {1}
-
-
-test fCmd-12.9 {renamefile: moving a file across volumes} {unixOnly notRoot} {
- catch {file delete -force -- tfa /tmp/tfa}
- set s [createfile tfa ]
- file rename tfa /tmp
- set result [expr [checkcontent /tmp/tfa $s] && ![file exists tfa]]
- file delete /tmp/tfa
- set result
-} {1}
-
-test fCmd-12.10 {renamefile: moving a directory across volumes } \
- {unixOnly notRoot} {
- catch {file delete -force -- tfad /tmp/tfad}
- file mkdir tfad
- set s [createfile tfad/a ]
- file rename tfad /tmp
- set restul [expr [checkcontent /tmp/tfad/a $s] && ![file exists tfad]]
- file delete -force /tmp/tfad
- set result
-} {1}
-
-#
-# Coverage tests for TclCopyFilesCmd()
-#
-test fCmd-13.1 {TclCopyFilesCmd: -force option} {notRoot} {
- catch {file delete -force -- tfa1}
- set s [createfile tfa1]
- file copy -force tfa1 tfa2
- set result [expr [checkcontent tfa2 $s] && [checkcontent tfa1 $s]]
- file delete tfa1 tfa2
- set result
-} {1}
-
-test fCmd-13.2 {TclCopyFilesCmd: -- option} {notRoot} {
- catch {file delete -force -- tfa1}
- set s [createfile -tfa1]
- file copy -- -tfa1 tfa2
- set result [expr [checkcontent tfa2 $s] && [checkcontent -tfa1 $s]]
- file delete -- -tfa1 tfa2
- set result
-} {1}
-
-test fCmd-13.3 {TclCopyFilesCmd: bad option} {notRoot} {
- catch {file delete -force -- tfa1}
- set s [createfile tfa1]
- set r1 [catch {file copy -x tfa1 tfa2}]
- set result [expr $r1 && [checkcontent tfa1 $s] && ![file exists tfa2]]
- file delete tfa1
- set result
-} {1}
-
-test fCmd-13.4 {TclCopyFilesCmd: bad \# args} {notRoot} {
- catch {file copy -- }
-} {1}
-
-test fCmd-13.5 {TclCopyFilesCmd: target filename translation failing} {
- global env
- set temp $env(HOME)
- unset env(HOME)
- set result [catch {file copy tfa ~/foobar }]
- set env(HOME) $temp
- set result
- } {1}
-
-test fCmd-13.6 {TclCopyFilesCmd: > 1 source & target is not a dir} {notRoot} {
- catch {file delete -force -- tfa1 tfa2 tfa3}
- createfile tfa1
- createfile tfa2
- createfile tfa3
- set result [catch {file copy tfa1 tfa2 tfa3}]
- file delete tfa1 tfa2 tfa3
- set result
-} {1}
-
-test fCmd-13.7 {TclCopyFilesCmd: single file into directory} {notRoot} {
- catch {file delete -force -- tfa1 tfad}
- set s [createfile tfa1]
- file mkdir tfad
- file copy tfa1 tfad
- set result [expr [checkcontent tfad/tfa1 $s] && [checkcontent tfa1 $s]]
- file delete -force tfad tfa1
- set result
-} {1}
-
-test fCmd-13.8 {TclCopyFilesCmd: multiple files into directory} {notRoot} {
- catch {file delete -force -- tfa1 tfa2 tfad}
- set s1 [createfile tfa1 ]
- set s2 [createfile tfa2 ]
- file mkdir tfad
- file copy tfa1 tfa2 tfad
- set r1 [checkcontent tfad/tfa1 $s1]
- set r2 [checkcontent tfad/tfa2 $s2]
- set r3 [checkcontent tfa1 $s1]
- set r4 [checkcontent tfa2 $s2]
- set result [expr $r1 && $r2 && $r3 && $r4 ]
-
- file delete -force tfad tfa1 tfa2
- set result
-} {1}
-
-test fCmd-13.9 {TclCopyFilesCmd: error copying file to directory} {notRoot} {
- catch {file delete -force -- tfa tfad}
- set s [createfile tfa ]
- file mkdir tfad
- file mkdir tfad/tfa
- set r1 [catch {file copy tfa tfad}]
- set r2 [expr [checkcontent tfa $s] && [file isdir tfad/tfa]]
- set r3 [file isdir tfad]
- set result [expr $r1 && $r2 && $r3 ]
- file delete -force tfa tfad
- set result
-} {1}
-
-#
-# Coverage tests for copyfile()
-#
-test fCmd-14.1 {copyfile: source filename translation failing} {notRoot} {
- global env
- set temp $env(HOME)
- unset env(HOME)
- set result [catch {file copy ~/tfa1 tfa2}]
- set env(HOME) $temp
- set result
-} {1}
-
-test fCmd-14.2 {copyfile: dst filename translation failing} {notRoot} {
- global env
- set temp $env(HOME)
- unset env(HOME)
- set s [createfile tfa1]
- file mkdir tfad
- set r1 [catch {file copy tfa1 ~/tfa2 tfad}]
- set result [expr $r1 && [checkcontent tfad/tfa1 $s]]
- set env(HOME) $temp
- file delete -force tfa1 tfad
- set result
-} {1}
-
-test fCmd-14.3 {copyfile: stat failing on source} {notRoot} {
- catch {file delete -force -- tfa1 tfa2}
- set r1 [catch {file copy tfa1 tfa2}]
- expr $r1 && ![file exists tfa1] && ![file exists tfa2]
-} {1}
-
-test fCmd-14.4 {copyfile: error copying file to directory} {notRoot} {
- catch {file delete -force -- tfa tfad}
- set s1 [createfile tfa ]
- file mkdir tfad
- file mkdir tfad/tfa
- set r1 [catch {file copy tfa tfad}]
- set r2 [checkcontent tfa $s1]
- set r3 [file isdir tfad]
- set r4 [file isdir tfad/tfa]
- set result [expr $r1 && $r2 && $r3 && $r4 ]
- file delete -force tfa tfad
- set result
-} {1}
-
- test fCmd-14.5 {copyfile: error copying directory to file} {notRoot} {
- catch {file delete -force -- tfa tfad}
- file mkdir tfa
- file mkdir tfad
- set s [createfile tfad/tfa]
- set r1 [catch {file copy tfa tfad}]
- set r2 [checkcontent tfad/tfa $s]
- set r3 [file isdir tfad]
- set r4 [file isdir tfa]
- set result [expr $r1 && $r2 && $r3 && $r4 ]
- file delete -force tfa tfad
- set result
-} {1}
-
-test fCmd-14.6 {copyfile: copy file succeeding} {notRoot} {
- catch {file delete -force -- tfa tfa2}
- set s [createfile tfa]
- file copy tfa tfa2
- set result [expr [checkcontent tfa $s] && [checkcontent tfa2 $s]]
- file delete tfa tfa2
- set result
-} {1}
-
-test fCmd-14.7 {copyfile: copy directory succeeding} {notRoot} {
- catch {file delete -force -- tfa tfa2}
- file mkdir tfa
- set s [createfile tfa/file]
- file copy tfa tfa2
- set result [expr [checkcontent tfa/file $s] && [checkcontent tfa2/file $s]]
- file delete -force tfa tfa2
- set result
-} {1}
-
-test fCmd-14.8 {copyfile: copy directory failing} {unixOnly notRoot} {
- catch {file delete -force -- tfa}
- file mkdir tfa/dir/a/b/c
- exec chmod 000 tfa/dir
- set r1 [catch {file copy tfa tfa2}]
- exec chmod 777 tfa/dir
- set result $r1
- file delete -force tfa tfa2
- set result
-} {1}
-
-#
-# Coverage tests for TclMkdirCmd()
-#
-test fCmd-15.1 {TclMakeDirsCmd: target filename translation failing} {notRoot} {
- global env
- set temp $env(HOME)
- unset env(HOME)
- set result [catch {file mkdir ~/tfa}]
- set env(HOME) $temp
- set result
-} {1}
-#
-# Can Tcl_SplitPath return argc == 0? If so them we need a
-# test for that code.
-#
-test fCmd-15.2 {TclMakeDirsCmd - one directory } {notRoot} {
- catch {file delete -force -- tfa}
- file mkdir tfa
- set result [file isdirectory tfa]
- file delete tfa
- set result
-} {1}
-
-test fCmd-15.3 {TclMakeDirsCmd: - two directories} {notRoot} {
- catch {file delete -force -- tfa1 tfa2}
- file mkdir tfa1 tfa2
- set result [expr [file isdirectory tfa1] && [file isdirectory tfa2]]
- file delete tfa1 tfa2
- set result
-} {1}
-
-test fCmd-15.4 {TclMakeDirsCmd - stat failing} {unixOnly notRoot} {
- catch {file delete -force -- tfa}
- file mkdir tfa
- createfile tfa/file
- exec chmod 000 tfa
- set result [catch {file mkdir tfa/file}]
- exec chmod 777 tfa
- file delete -force tfa
- set result
-} {1}
-
-test fCmd-15.5 {TclMakeDirsCmd: - making a directory several levels deep} \
- {notRoot} {
- catch {file delete -force -- tfa}
- file mkdir tfa/a/b/c
- set result [file isdir tfa/a/b/c]
- file delete -force tfa
- set result
-} {1}
-
-
-test fCmd-15.6 {TclMakeDirsCmd: - trying to overwrite a file} {notRoot} {
- catch {file delete -force -- tfa}
- set s [createfile tfa]
- set r1 [catch {file mkdir tfa}]
- set r2 [file isdir tfa]
- set r3 [file exists tfa]
- set result [expr $r1 && !$r2 && $r3 && [checkcontent tfa $s]]
- file delete tfa
- set result
-} {1}
-
-test fCmd-15.7 {TclMakeDirsCmd - making several directories} {notRoot} {
- catch {file delete -force -- tfa1 tfa2}
- file mkdir tfa1 tfa2/a/b/c
- set result [expr [file isdir tfa1] && [file isdir tfa2/a/b/c]]
- file delete -force tfa1 tfa2
- set result
-} {1}
-
-test fCmd-15.8 {TclFileMakeDirsCmd: trying to create an existing dir} {notRoot} {
- file mkdir tfa
- file mkdir tfa
- set result [file isdir tfa]
- file delete tfa
- set result
-} {1}
-
-
-# Coverage tests for TclDeleteFilesCommand()
-test fCmd-16.1 { test the -- argument } {notRoot} {
- catch {file delete -force -- tfa}
- createfile tfa
- file delete -- tfa
- file exists tfa
-} {0}
-
-test fCmd-16.2 { test the -force and -- arguments } {notRoot} {
- catch {file delete -force -- tfa}
- createfile tfa
- file delete -force -- tfa
- file exists tfa
-} {0}
-
-test fCmd-16.3 { test bad option } {notRoot} {
- catch {file delete -force -- tfa}
- createfile tfa
- set result [catch {file delete -dog tfa}]
- file delete tfa
- set result
-} {1}
-
-test fCmd-16.4 { test not enough args } {notRoot} {
- catch {file delete}
-} {1}
-
-test fCmd-16.5 { test not enough args with options } {notRoot} {
- catch {file delete --}
-} {1}
-
-test fCmd-16.6 {delete: source filename translation failing} {notRoot} {
- global env
- set temp $env(HOME)
- unset env(HOME)
- set result [catch {file delete ~/tfa}]
- set env(HOME) $temp
- set result
-} {1}
-
-test fCmd-16.7 {remove a non-empty directory without -force } {notRoot} {
- catch {file delete -force -- tfa}
- file mkdir tfa
- createfile tfa/a
- set result [catch {file delete tfa }]
- file delete -force tfa
- set result
-} {1}
-
-test fCmd-16.8 {remove a normal file } {notRoot} {
- catch {file delete -force -- tfa}
- file mkdir tfa
- createfile tfa/a
- set result [catch {file delete tfa }]
- file delete -force tfa
- set result
-} {1}
-
-test fCmd-16.9 {error while deleting file } {unixOnly notRoot} {
- catch {file delete -force -- tfa}
- file mkdir tfa
- createfile tfa/a
- exec chmod 555 tfa
- set result [catch {file delete tfa/a }]
- #######
- ####### If any directory in a tree that is being removed does not
- ####### have write permission, the process will fail!
- ####### This is also the case with "rm -rf"
- #######
- exec chmod 777 tfa
- file delete -force tfa
- set result
-} {1}
-
-test fCmd-16.10 {deleting multiple files} {notRoot} {
- catch {file delete -force -- tfa1 tfa2}
- createfile tfa1
- createfile tfa2
- file delete tfa1 tfa2
- expr ![file exists tfa1] && ![file exists tfa2]
-} {1}
-
-test fCmd-16.11 { TclFileDeleteCmd: removing a nonexistant file} {notRoot} {
- catch {file delete -force -- tfa}
- file delete tfa
- set result 1
-} {1}
-
-# More coverage tests for mkpath()
- test fCmd-17.1 {mkdir stat failing on target but not ENOENT} {unixOnly notRoot} {
- catch {file delete -force -- tfa1}
- file mkdir tfa1
- exec chmod 555 tfa1
- set result [catch {file mkdir tfa1/tfa2}]
- exec chmod 777 tfa1
- file delete -force tfa1
- set result
-} {1}
-
-test fCmd-17.2 {mkdir several levels deep - relative } {notRoot} {
- catch {file delete -force -- tfa}
- file mkdir tfa/a/b
- set result [file isdir tfa/a/b ]
- file delete tfa/a/b tfa/a tfa
- set result
-} {1}
-
-test fCmd-17.3 {mkdir several levels deep - absolute } {notRoot} {
- catch {file delete -force -- tfa}
- set f [file join [pwd] tfa a ]
- file mkdir $f
- set result [file isdir $f ]
- file delete $f [file join [pwd] tfa]
- set result
-} {1}
-
-#
-# Functionality tests for TclFileRenameCmd()
-#
-
-test fCmd-18.1 {TclFileRenameCmd: rename (first form) in the same directory} \
- {notRoot} {
- catch {file delete -force -- tfad}
- file mkdir tfad/dir
- cd tfad/dir
- set s [createfile foo ]
- file rename foo bar
- file rename bar ./foo
- file rename ./foo bar
- file rename ./bar ./foo
- file rename foo ../dir/bar
- file rename ../dir/bar ./foo
- file rename ../../tfad/dir/foo ../../tfad/dir/bar
- file rename [file join [pwd] bar] foo
- file rename foo [file join [pwd] bar]
- set result [expr [checkcontent bar $s] && ![file exists foo]]
- cd ../..
- file delete -force tfad
- set result
-} {1}
-
-test fCmd-18.2 {TclFileRenameCmd: single dir to nonexistant} {notRoot} {
- catch {file delete -force -- tfa1 tfa2}
- file mkdir tfa1
- file rename tfa1 tfa2
- set result [expr [file exists tfa2] && ![file exists tfa1]]
- file delete tfa2
- set result
-} {1}
-
-test fCmd-18.3 {TclFileRenameCmd: mixed dirs and files into directory} {notRoot} {
- catch {file delete -force -- tfa1 tfad1 tfad2}
- set s [createfile tfa1 ]
- file mkdir tfad1 tfad2
- file rename tfa1 tfad1 tfad2
- set r1 [checkcontent tfad2/tfa1 $s]
- set r2 [file isdir tfad2/tfad1]
- set result [expr $r1 && $r2 && ![file exists tfa1] && ![file exists tfad1]]
- file delete tfad2/tfa1
- file delete -force tfad2
- set result
-} {1}
-
-test fCmd-18.4 {TclFileRenameCmd: attempt to replace non-dir with dir} {notRoot} {
- catch {file delete -force -- tfa tfad}
- set s [createfile tfa ]
- file mkdir tfad
- set r1 [catch {file rename tfad tfa}]
- set r2 [checkcontent tfa $s]
- set r3 [file isdir tfad]
- set result [expr $r1 && $r2 && $r3 ]
- file delete tfa tfad
- set result
-} {1}
-
-test fCmd-18.5 {TclFileRenameCmd: attempt to replace dir with non-dir} {notRoot} {
- catch {file delete -force -- tfa tfad}
- set s [createfile tfa ]
- file mkdir tfad/tfa
- set r1 [catch {file rename tfa tfad}]
- set r2 [checkcontent tfa $s]
- set r3 [file isdir tfad/tfa]
- set result [expr $r1 && $r2 && $r3 ]
- file delete -force tfa tfad
- set result
-} {1}
-
-#
-# On Windows there is no easy way to determine if two files are the same
-#
-test fCmd-18.6 {TclFileRenameCmd: rename a file to itself} {macOrUnix notRoot} {
- catch {file delete -force -- tfa}
- set s [createfile tfa]
- set r1 [catch {file rename tfa tfa}]
- set result [expr $r1 && [checkcontent tfa $s]]
- file delete tfa
- set result
-} {1}
-
-test fCmd-18.7 {TclFileRenameCmd: rename dir on top of another empty dir w/o -force} \
- {notRoot} {
- catch {file delete -force -- tfa tfad}
- file mkdir tfa tfad/tfa
- set r1 [catch {file rename tfa tfad}]
- set result [expr $r1 && [file isdir tfa]]
- file delete -force tfa tfad
- set result
-} {1}
-
-test fCmd-18.8 {TclFileRenameCmd: rename dir on top of another empty dir w/ -force} \
- {notRoot} {
- catch {file delete -force -- tfa tfad}
- file mkdir tfa tfad/tfa
- file rename -force tfa tfad
- set result [expr ![file isdir tfa]]
- file delete -force tfad
- set result
-} {1}
-
-test fCmd-18.9 {TclFileRenameCmd: rename dir on top of a non-empty dir w/o -force} \
- {notRoot} {
- catch {file delete -force -- tfa tfad}
- file mkdir tfa tfad/tfa/file
- set r1 [catch {file rename tfa tfad}]
- set result [expr $r1 && [file isdir tfa] && [file isdir tfad/tfa/file]]
- file delete -force tfa tfad
- set result
-} {1}
-
-test fCmd-18.10 {TclFileRenameCmd: rename dir on top of a non-empty dir w/ -force} \
- {notRoot} {
- catch {file delete -force -- tfa tfad}
- file mkdir tfa tfad/tfa/file
- set r1 [catch {file rename -force tfa tfad}]
- set result [expr $r1 && [file isdir tfa] && [file isdir tfad/tfa/file]]
- file delete -force tfa tfad
- set result
-} {1}
-
-test fCmd-18.11 {TclFileRenameCmd: rename a non-existant file} {notRoot} {
- catch {file delete -force -- tfa1}
- set r1 [catch {file rename tfa1 tfa2}]
- set result [expr $r1 && ![file exists tfa1] && ![file exists tfa2]]
-} {1}
-
-test fCmd-18.12 {TclFileRenameCmd : rename a symbolic link to file} \
- {unixOnly notRoot} {
- catch {file delete -force -- tfa1 tfa2 tfa3}
-
- set s [createfile tfa1]
- exec ln -s tfa1 tfa2
- file rename tfa2 tfa3
- set t [file type tfa3]
- set result [expr { $t == "link" }]
- file delete tfa1 tfa3
- set result
-} {1}
-
-test fCmd-18.13 {TclFileRenameCmd : rename a symbolic link to dir} \
- {unixOnly notRoot} {
- catch {file delete -force -- tfa1 tfa2 tfa3}
-
- file mkdir tfa1
- exec ln -s tfa1 tfa2
- file rename tfa2 tfa3
- set t [file type tfa3]
- set result [expr { $t == "link" }]
- file delete tfa1 tfa3
- set result
-} {1}
-
-test fCmd-18.14 {TclFileRenameCmd : rename a path with sym link} \
- {unixOnly notRoot} {
- catch {file delete -force -- tfa1 tfa2 tfa3}
-
- file mkdir tfa1/a/b/c/d
- file mkdir tfa2
- set f [file join [pwd] tfa1/a/b]
- set f2 [file join [pwd] {tfa2/b alias}]
- exec ln -s $f $f2
- file rename {tfa2/b alias/c} tfa3
- set r1 [file isdir tfa3]
- set r2 [file exists tfa1/a/b/c]
- set result [expr $r1 && !$r2]
- file delete -force tfa1 tfa2 tfa3
- set result
-} {1}
-
-test fCmd-18.15 {TclFileRenameCmd : rename a file to a symlink dir} \
- {unixOnly notRoot} {
- catch {file delete -force -- tfa1 tfa2 tfalink}
-
- file mkdir tfa1
- set s [createfile tfa2]
- exec ln -s tfa1 tfalink
-
- file rename tfa2 tfalink
- set result [checkcontent tfa1/tfa2 $s ]
- file delete -force tfa1 tfalink
- set result
-} {1}
-
-test fCmd-18.16 {TclFileRenameCmd: rename a dangling symlink} {unixOnly notRoot} {
- catch {file delete -force -- tfa1 tfalink}
-
- file mkdir tfa1
- exec ln -s tfa1 tfalink
- file delete tfa1
- file rename tfalink tfa2
- set result [expr [string compare [file type tfa2] "link"] == 0]
- file delete tfa2
- set result
-} {1}
-
-
-#
-# Coverage tests for TclUnixRmdir
-#
-test fCmd-19.1 { remove empty directory } {notRoot} {
- catch {file delete -force -- tfa}
- file mkdir tfa
- file delete tfa
- file exists tfa
-} {0}
-
-test fCmd-19.2 { rmdir error besides EEXIST} {unixOnly notRoot} {
- catch {file delete -force -- tfa}
- file mkdir tfa
- file mkdir tfa/a
- exec chmod 555 tfa
- set result [catch {file delete tfa/a}]
- exec chmod 777 tfa
- file delete -force tfa
- set result
-} {1}
-
-test fCmd-19.3 { recursive remove } {notRoot} {
- catch {file delete -force -- tfa}
- file mkdir tfa
- file mkdir tfa/a
- file delete -force tfa
- file exists tfa
-} {0}
-
-#
-# TclUnixDeleteFile and TraversalDelete are covered by tests from the
-# TclDeleteFilesCmd suite
-#
-#
-
-#
-# Coverage tests for TraverseUnixTree(), called from TclDeleteFilesCmd
-#
-
-test fCmd-20.1 {TraverseUnixTree : failure opening a subdirectory directory } \
- {unixOnly notRoot} {
- catch {file delete -force -- tfa}
- file mkdir tfa
- file mkdir tfa/a
- exec chmod 000 tfa/a
- set result [catch {file delete -force tfa}]
- exec chmod 777 tfa/a
- file delete -force tfa
- set result
-} {1}
-
-
-#
-# Feature testing for TclCopyFilesCmd
-#
-test fCmd-21.1 {copy : single file to nonexistant } {notRoot} {
- catch {file delete -force -- tfa1 tfa2}
- set s [createfile tfa1]
- file copy tfa1 tfa2
- set result [expr [checkcontent tfa2 $s] && [checkcontent tfa1 $s]]
- file delete tfa1 tfa2
- set result
-} {1}
-
-test fCmd-21.2 {copy : single dir to nonexistant } {notRoot} {
- catch {file delete -force -- tfa1 tfa2}
- file mkdir tfa1
- file copy tfa1 tfa2
- set result [expr [file isdir tfa2] && [file isdir tfa1]]
- file delete tfa1 tfa2
- set result
-} {1}
-
-test fCmd-21.3 {copy : single file into directory } {notRoot} {
- catch {file delete -force -- tfa1 tfad}
- set s [createfile tfa1]
- file mkdir tfad
- file copy tfa1 tfad
- set result [expr [checkcontent tfad/tfa1 $s] && [checkcontent tfa1 $s]]
- file delete -force tfa1 tfad
- set result
-} {1}
-
-test fCmd-21.4 {copy : more than one source and target is not a directory} \
- {notRoot} {
- catch {file delete -force -- tfa1 tfa2 tfa3}
- createfile tfa1
- createfile tfa2
- createfile tfa3
- set result [catch {file copy tfa1 tfa2 tfa3}]
- file delete tfa1 tfa2 tfa3
- set result
-} {1}
-
-test fCmd-21.5 {copy : multiple files into directory } {notRoot} {
- catch {file delete -force -- tfa1 tfa2 tfad}
- set s1 [createfile tfa1 ]
- set s2 [createfile tfa2 ]
- file mkdir tfad
- file copy tfa1 tfa2 tfad
- set r1 [checkcontent tfad/tfa1 $s1]
- set r2 [checkcontent tfad/tfa2 $s2]
- set r3 [checkcontent tfa1 $s1]
- set r4 [checkcontent tfa2 $s2]
- set result [expr $r1 && $r2 && $r3 && $r4]
- file delete -force tfa1 tfa2 tfad
- set result
-} {1}
-
-test fCmd-21.6 {copy: mixed dirs and files into directory} \
- {notRoot notFileSharing} {
- catch {file delete -force -- tfa1 tfad1 tfad2}
- set s [createfile tfa1 ]
- file mkdir tfad1 tfad2
- file copy tfa1 tfad1 tfad2
- set r1 [checkcontent [file join tfad2 tfa1] $s]
- set r2 [file isdir [file join tfad2 tfad1]]
- set r3 [checkcontent tfa1 $s]
- set result [expr $r1 && $r2 && $r3 && [file isdir tfad1]]
- file delete -force tfa1 tfad1 tfad2
- set result
-} {1}
-
-test fCmd-21.7 {TclCopyFilesCmd: copy a dangling link} {unixOnly notRoot} {
- file mkdir tfad1
- exec ln -s tfad1 tfalink
- file delete tfad1
- file copy tfalink tfalink2
- set result [string match [file type tfalink2] link]
- file delete tfalink tfalink2
- set result
-} {1}
-
-test fCmd-21.8 {TclCopyFilesCmd : copy a link } {unixOnly notRoot} {
- file mkdir tfad1
- exec ln -s tfad1 tfalink
- file copy tfalink tfalink2
- set r1 [file type tfalink]
- set r2 [file type tfalink2]
- set r3 [file isdir tfad1]
- set result [expr {("$r1" == "link" ) && ("$r2" == "link" ) && $r3}]
- file delete tfad1 tfalink tfalink2
- set result
-} {1}
-
-test fCmd-21.9 {TclCopyFilesCmd: copy dir with a link in it} {unixOnly notRoot} {
- file mkdir tfad1
- exec ln -s "[pwd]/tfad1" tfad1/tfalink
- file copy tfad1 tfad2
- set result [string match [file type tfad2/tfalink] link]
- file delete -force tfad1 tfad2
- set result
-} {1}
-
-test fCmd-21.10 {TclFileCopyCmd: copy dir on top of another empty dir w/o -force} \
- {notRoot} {
- catch {file delete -force -- tfa tfad}
- file mkdir tfa [file join tfad tfa]
- set r1 [catch {file copy tfa tfad}]
- set result [expr $r1 && [file isdir tfa]]
- file delete -force tfa tfad
- set result
-} {1}
-
-test fCmd-21.11 {TclFileCopyCmd: copy dir on top of a dir w/o -force} {notRoot} {
- catch {file delete -force -- tfa tfad}
- file mkdir tfa [file join tfad tfa file]
- set r1 [catch {file copy tfa tfad}]
- set result [expr $r1 && [file isdir tfa] && [file isdir [file join tfad tfa file]]]
- file delete -force tfa tfad
- set result
-} {1}
-
-test fCmd-21.12 {TclFileCopyCmd: copy dir on top of a non-empty dir w/ -force} \
- {notRoot} {
- catch {file delete -force -- tfa tfad}
- file mkdir tfa [file join tfad tfa file]
- set r1 [catch {file copy -force tfa tfad}]
- set result [expr $r1 && [file isdir tfa] && [file isdir [file join tfad tfa file]]]
- file delete -force tfa tfad
- set result
-} {1}
-
-#
-# Coverage testing for TclpRenameFile
-#
-test fCmd-22.1 {TclpRenameFile: rename and overwrite in a single dir} {notRoot} {
- catch {file delete -force -- tfa1 tfa2}
- set s [createfile tfa1]
- set s2 [createfile tfa2 q]
-
- set r1 [catch {rename tfa1 tfa2}]
- file rename -force tfa1 tfa2
- set result [expr $r1 && [checkcontent tfa2 $s]]
- file delete [glob tfa1 tfa2]
- set result
-} {1}
-
-test fCmd-22.2 {TclpRenameFile: attempt to overwrite itself} {macOrUnix notRoot} {
- catch {file delete -force -- tfa1}
- set s [createfile tfa1]
- file rename -force tfa1 tfa1
- set result [checkcontent tfa1 $s]
- file delete tfa1
- set result
-} {1}
-
-test fCmd-22.3 { TclpRenameFile : rename dir to existing dir } {notRoot} {
- catch {file delete -force -- d1 tfad}
- file mkdir d1 [file join tfad d1]
- set r1 [catch {file rename d1 tfad}]
- set result [expr $r1 && [file isdir d1] && [file isdir [file join tfad d1]]]
- file delete -force d1 tfad
- set result
-} {1}
-
-test fCmd-22.4 {TclpRenameFile: rename dir to dir several levels deep} {notRoot} {
- catch {file delete -force -- d1 tfad}
- file mkdir d1 [file join tfad a b c]
- file rename d1 [file join tfad a b c d1]
- set result [expr ![file isdir d1] && [file isdir [file join tfad a b c d1]]]
- file delete -force [glob d1 tfad]
- set result
-} {1}
-
-
-#
-# TclMacCopyFile needs to be redone.
-#
-test fCmd-22.5 {TclMacCopyFile: copy and overwrite in a single dir} {notRoot} {
- catch {file delete -force -- tfa1 tfa2}
- set s [createfile tfa1]
- set s2 [createfile tfa2 q]
-
- set r1 [catch {file copy tfa1 tfa2}]
- file copy -force tfa1 tfa2
- set result [expr $r1 && [checkcontent tfa2 $s] && [checkcontent tfa1 $s]]
- file delete tfa1 tfa2
- set result
-} {1}
-
-#
-# TclMacMkdir - basic cases are covered elsewhere.
-# Error cases are not covered.
-#
-
-#
-# TclMacRmdir
-# Error cases are not covered.
-#
-
-test fCmd-23.1 {TclMacRmdir: trying to remove a nonempty directory} {notRoot} {
- catch {file delete -force -- tfad}
-
- file mkdir [file join tfad dir]
-
- set result [catch {file delete tfad}]
- file delete -force tfad
- set result
-} {1}
-
-#
-# TclMacDeleteFile
-# Error cases are not covered.
-#
-test fCmd-24.1 {TclMacDeleteFile: deleting a normal file} {notRoot} {
- catch {file delete -force -- tfa1}
-
- createfile tfa1
- file delete tfa1
- file exists tfa1
-} {0}
-
-#
-# TclMacCopyDirectory
-# Error cases are not covered.
-#
-test fCmd-25.1 { TclMacCopyDirectory : copying a normal directory} \
- {notRoot notFileSharing} {
- catch {file delete -force -- tfad1 tfad2}
-
- file mkdir [file join tfad1 a b c]
- file copy tfad1 tfad2
- set result [expr [file isdir [file join tfad1 a b c]] && [file isdir [file join tfad2 a b c]]]
- file delete -force tfad1 tfad2
- set result
-} {1}
-
-test fCmd-25.2 { TclMacCopyDirectory : copying a short path normal directory} \
- {notRoot notFileSharing} {
- catch {file delete -force -- tfad1 tfad2}
-
- file mkdir tfad1
- file copy tfad1 tfad2
- set result [expr [file isdir tfad1] && [file isdir tfad2]]
- file delete tfad1 tfad2
- set result
-} {1}
-
-test fCmd-25.3 { TclMacCopyDirectory : copying dirs between different dirs} \
- {notRoot notFileSharing} {
- catch {file delete -force -- tfad1 tfad2}
-
- file mkdir [file join tfad1 x y z]
- file mkdir [file join tfad2 dir]
- file copy tfad1 [file join tfad2 dir]
- set result [expr [file isdir [file join tfad1 x y z]] && [file isdir [file join tfad2 dir tfad1 x y z]]]
- file delete -force tfad1 tfad2
- set result
-} {1}
-
-#
-# Functionality tests for TclDeleteFilesCmd
-#
-
-test fCmd-26.1 { TclDeleteFilesCmd : delete symlink} {unixOnly notRoot} {
- catch {file delete -force -- tfad1 tfad2}
-
- file mkdir tfad1
- exec ln -s tfad1 tfalink
- file delete tfalink
-
- set r1 [file isdir tfad1]
- set r2 [file exists tfalink]
-
- set result [expr $r1 && !$r2]
- file delete tfad1
- set result
-} {1}
-
-test fCmd-26.2 { TclDeleteFilesCmd : delete dir with symlink} {unixOnly notRoot} {
- catch {file delete -force -- tfad1 tfad2}
-
- file mkdir tfad1
- file mkdir tfad2
- exec ln -s tfad1 [file join tfad2 link]
- file delete -force tfad2
-
- set r1 [file isdir tfad1]
- set r2 [file exists tfad2]
-
- set result [expr $r1 && !$r2]
- file delete tfad1
- set result
-} {1}
-
-test fCmd-26.3 { TclDeleteFilesCmd : delete dangling symlink} {unixOnly notRoot} {
- catch {file delete -force -- tfad1 tfad2}
-
- file mkdir tfad1
- exec ln -s tfad1 tfad2
- file delete tfad1
- file delete tfad2
-
- set r1 [file exists tfad1]
- set r2 [file exists tfad2]
-
- set result [expr !$r1 && !$r2]
- set result
-} {1}
-
-test fCmd-27.2 {TclFileAttrsCmd - Tcl_TranslateFileName fails} {
- testsetplatform unix
- list [catch {file attributes ~_bad_user} msg] $msg [testsetplatform $platform]
-} {1 {user "_bad_user" doesn't exist} {}}
-test fCmd-27.3 {TclFileAttrsCmd - all attributes} {
- catch {file delete -force -- foo.tmp}
- createfile foo.tmp
- list [catch {file attributes foo.tmp} msg] [expr {[llength $msg] > 0}] [file delete -force -- foo.tmp]
-} {0 1 {}}
-test fCmd-27.4 {TclFileAttrsCmd - getting one option} {
- catch {file delete -force -- foo.tmp}
- createfile foo.tmp
- set attrs [file attributes foo.tmp]
- list [catch {eval file attributes foo.tmp [lindex $attrs 0]}] [file delete -force -- foo.tmp]
-} {0 {}}
-
-# Find a group that exists on this Unix system, or else skip tests that
-# require Unix groups.
-if {$tcl_platform(platform) == "unix"} {
- set ::tcltest::testConfig(foundGroup) 0
- catch {
- set groupList [exec groups]
- set group [lindex $groupList 0]
- set ::tcltest::testConfig(foundGroup) 1
- }
-} else {
- set ::tcltest::testConfig(foundGroup) 1
-}
-
-test fCmd-27.5 {TclFileAttrsCmd - setting one option} {foundGroup} {
- catch {file delete -force -- foo.tmp}
- createfile foo.tmp
- set attrs [file attributes foo.tmp]
- list [catch {eval file attributes foo.tmp [lrange $attrs 0 1]} msg] $msg [file delete -force -- foo.tmp]
-} {0 {} {}}
-test fCmd-27.6 {TclFileAttrsCmd - setting more than one option} {foundGroup} {
- catch {file delete -force -- foo.tmp}
- createfile foo.tmp
- set attrs [file attributes foo.tmp]
- list [catch {eval file attributes foo.tmp [lrange $attrs 0 3]} msg] $msg [file delete -force -- foo.tmp]
-} {0 {} {}}
-
-# cleanup
-cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/fileName.test b/tests/fileName.test
deleted file mode 100644
index 426fd10..0000000
--- a/tests/fileName.test
+++ /dev/null
@@ -1,1429 +0,0 @@
-# This file tests the filename manipulation routines.
-#
-# 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) 1995-1996 Sun Microsystems, Inc.
-# Copyright (c) 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: fileName.test,v 1.3 1999/04/16 00:47:27 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[info commands testsetplatform] == {}} {
- puts "This application hasn't been compiled with the \"testsetplatform\""
- puts "command, so I can't test the filename conversion procedures."
- ::tcltest::cleanupTests
- return
-}
-
-global env
-set platform [testgetplatform]
-
-test filename-1.1 {Tcl_GetPathType: unix} {
- testsetplatform unix
- file pathtype /
-} absolute
-test filename-1.2 {Tcl_GetPathType: unix} {
- testsetplatform unix
- file pathtype /foo
-} absolute
-test filename-1.3 {Tcl_GetPathType: unix} {
- testsetplatform unix
- file pathtype foo
-} relative
-test filename-1.4 {Tcl_GetPathType: unix} {
- testsetplatform unix
- file pathtype c:/foo
-} relative
-test filename-1.5 {Tcl_GetPathType: unix} {
- testsetplatform unix
- file pathtype ~
-} absolute
-test filename-1.6 {Tcl_GetPathType: unix} {
- testsetplatform unix
- file pathtype ~/foo
-} absolute
-test filename-1.7 {Tcl_GetPathType: unix} {
- testsetplatform unix
- file pathtype ~foo
-} absolute
-test filename-1.8 {Tcl_GetPathType: unix} {
- testsetplatform unix
- file pathtype ./~foo
-} relative
-
-test filename-2.1 {Tcl_GetPathType: mac, denerate names} {
- testsetplatform mac
- file pathtype /
-} relative
-test filename-2.2 {Tcl_GetPathType: mac, denerate names} {
- testsetplatform mac
- file pathtype /.
-} relative
-test filename-2.3 {Tcl_GetPathType: mac, denerate names} {
- testsetplatform mac
- file pathtype /..
-} relative
-test filename-2.4 {Tcl_GetPathType: mac, denerate names} {
- testsetplatform mac
- file pathtype //.//
-} relative
-test filename-2.5 {Tcl_GetPathType: mac, denerate names} {
- testsetplatform mac
- file pathtype //.//../.
-} relative
-test filename-2.6 {Tcl_GetPathType: mac, tilde names} {
- testsetplatform mac
- file pathtype ~
-} absolute
-test filename-2.7 {Tcl_GetPathType: mac, tilde names} {
- testsetplatform mac
- file pathtype ~:
-} absolute
-test filename-2.8 {Tcl_GetPathType: mac, tilde names} {
- testsetplatform mac
- file pathtype ~:foo
-} absolute
-test filename-2.9 {Tcl_GetPathType: mac, tilde names} {
- testsetplatform mac
- file pathtype ~/
-} absolute
-test filename-2.10 {Tcl_GetPathType: mac, tilde names} {
- testsetplatform mac
- file pathtype ~/foo
-} absolute
-test filename-2.11 {Tcl_GetPathType: mac, unix-style names} {
- testsetplatform mac
- file pathtype /foo
-} absolute
-test filename-2.12 {Tcl_GetPathType: mac, unix-style names} {
- testsetplatform mac
- file pathtype /./foo
-} absolute
-test filename-2.13 {Tcl_GetPathType: mac, unix-style names} {
- testsetplatform mac
- file pathtype /..//./foo
-} absolute
-test filename-2.14 {Tcl_GetPathType: mac, unix-style names} {
- testsetplatform mac
- file pathtype /foo/bar
-} absolute
-test filename-2.15 {Tcl_GetPathType: mac, unix-style names} {
- testsetplatform mac
- file pathtype foo/bar
-} relative
-test filename-2.16 {Tcl_GetPathType: mac, mac-style names} {
- testsetplatform mac
- file pathtype :
-} relative
-test filename-2.17 {Tcl_GetPathType: mac, mac-style names} {
- testsetplatform mac
- file pathtype :foo
-} relative
-test filename-2.18 {Tcl_GetPathType: mac, mac-style names} {
- testsetplatform mac
- file pathtype foo:
-} absolute
-test filename-2.19 {Tcl_GetPathType: mac, mac-style names} {
- testsetplatform mac
- file pathtype foo:bar
-} absolute
-test filename-2.20 {Tcl_GetPathType: mac, mac-style names} {
- testsetplatform mac
- file pathtype :foo:bar
-} relative
-test filename-2.21 {Tcl_GetPathType: mac, mac-style names} {
- testsetplatform mac
- file pathtype ::foo:bar
-} relative
-test filename-2.22 {Tcl_GetPathType: mac, mac-style names} {
- testsetplatform mac
- file pathtype ~foo
-} absolute
-test filename-2.23 {Tcl_GetPathType: mac, mac-style names} {
- testsetplatform mac
- file pathtype :~foo
-} relative
-test filename-2.24 {Tcl_GetPathType: mac, mac-style names} {
- testsetplatform mac
- file pathtype ~foo:
-} absolute
-test filename-2.25 {Tcl_GetPathType: mac, mac-style names} {
- testsetplatform mac
- file pathtype foo/bar:
-} absolute
-test filename-2.26 {Tcl_GetPathType: mac, mac-style names} {
- testsetplatform mac
- file pathtype /foo:
-} absolute
-test filename-2.27 {Tcl_GetPathType: mac, mac-style names} {
- testsetplatform mac
- file pathtype foo
-} relative
-
-test filename-3.1 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype /
-} volumerelative
-test filename-3.2 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype \\
-} volumerelative
-test filename-3.3 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype /foo
-} volumerelative
-test filename-3.4 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype \\foo
-} volumerelative
-test filename-3.5 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype c:/
-} absolute
-test filename-3.6 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype c:\\
-} absolute
-test filename-3.7 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype c:/foo
-} absolute
-test filename-3.8 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype c:\\foo
-} absolute
-test filename-3.9 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype c:
-} volumerelative
-test filename-3.10 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype c:foo
-} volumerelative
-test filename-3.11 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype foo
-} relative
-test filename-3.12 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype //foo/bar
-} absolute
-test filename-3.13 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype ~foo
-} absolute
-test filename-3.14 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype ~
-} absolute
-test filename-3.15 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype ~/foo
-} absolute
-test filename-3.16 {Tcl_GetPathType: windows} {
- testsetplatform windows
- file pathtype ./~foo
-} relative
-
-test filename-4.1 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split /
-} {/}
-test filename-4.2 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split /foo
-} {/ foo}
-test filename-4.3 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split /foo/bar
-} {/ foo bar}
-test filename-4.4 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split /foo/bar/baz
-} {/ foo bar baz}
-test filename-4.5 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split foo/bar
-} {foo bar}
-test filename-4.6 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split ./foo/bar
-} {. foo bar}
-test filename-4.7 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split /foo/../././foo/bar
-} {/ foo .. . . foo bar}
-test filename-4.8 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split ../foo/bar
-} {.. foo bar}
-test filename-4.9 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split {}
-} {}
-test filename-4.10 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split .
-} {.}
-test filename-4.11 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split ../
-} {..}
-test filename-4.12 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split ../..
-} {.. ..}
-test filename-4.13 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split //foo
-} {/ foo}
-test filename-4.14 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split foo//bar
-} {foo bar}
-test filename-4.15 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split ~foo
-} {~foo}
-test filename-4.16 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split ~foo/~bar
-} {~foo ./~bar}
-test filename-4.17 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split ~foo/~bar/~baz
-} {~foo ./~bar ./~baz}
-test filename-4.18 {Tcl_SplitPath: unix} {
- testsetplatform unix
- file split foo/bar~/baz
-} {foo bar~ baz}
-
-test filename-5.1 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split a:b
-} {a: b}
-test filename-5.2 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split a:b:c
-} {a: b c}
-test filename-5.3 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split a:b:c:
-} {a: b c}
-test filename-5.4 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split a:
-} {a:}
-test filename-5.5 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split a::
-} {a: ::}
-test filename-5.6 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split a:::
-} {a: :: ::}
-test filename-5.7 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split :a
-} {a}
-test filename-5.8 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split :a::
-} {a ::}
-test filename-5.9 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split :
-} {:}
-test filename-5.10 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ::
-} {::}
-test filename-5.11 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split :::
-} {:: ::}
-test filename-5.12 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split a:::b
-} {a: :: :: b}
-test filename-5.13 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split /a:b
-} {/a: b}
-test filename-5.14 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ~:
-} {~:}
-test filename-5.15 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ~/:
-} {~/:}
-test filename-5.16 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ~:foo
-} {~: foo}
-test filename-5.17 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ~/foo
-} {~: foo}
-test filename-5.18 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ~foo:
-} {~foo:}
-test filename-5.19 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split a:~foo
-} {a: :~foo}
-test filename-5.20 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split /
-} {:/}
-test filename-5.21 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split a:b/c
-} {a: :b/c}
-test filename-5.22 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split /foo
-} {foo:}
-test filename-5.23 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split /a/b
-} {a: b}
-test filename-5.24 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split /a/b/foo
-} {a: b foo}
-test filename-5.25 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split a/b
-} {a b}
-test filename-5.26 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ./foo/bar
-} {: foo bar}
-test filename-5.27 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ../foo/bar
-} {:: foo bar}
-test filename-5.28 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split {}
-} {}
-test filename-5.29 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split .
-} {:}
-test filename-5.30 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ././
-} {: :}
-test filename-5.31 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ././.
-} {: : :}
-test filename-5.32 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ../
-} {::}
-test filename-5.33 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ..
-} {::}
-test filename-5.34 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ../..
-} {:: ::}
-test filename-5.35 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split //foo
-} {foo:}
-test filename-5.36 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split foo//bar
-} {foo bar}
-test filename-5.37 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ~foo
-} {~foo:}
-test filename-5.38 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ~
-} {~:}
-test filename-5.39 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split foo
-} {foo}
-test filename-5.40 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ~/
-} {~:}
-test filename-5.41 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ~foo/~bar
-} {~foo: :~bar}
-test filename-5.42 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split ~foo/~bar/~baz
-} {~foo: :~bar :~baz}
-test filename-5.43 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split foo/bar~/baz
-} {foo bar~ baz}
-test filename-5.44 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split a/../b
-} {a :: b}
-test filename-5.45 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split a/../../b
-} {a :: :: b}
-test filename-5.46 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split a/.././../b
-} {a :: : :: b}
-test filename-5.47 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split /../bar
-} {bar:}
-test filename-5.48 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split /./bar
-} {bar:}
-test filename-5.49 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split //.//.././bar
-} {bar:}
-test filename-5.50 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split /..
-} {:/..}
-test filename-5.51 {Tcl_SplitPath: mac} {
- testsetplatform mac
- file split //.//.././
-} {://.//.././}
-
-test filename-6.1 {Tcl_SplitPath: win} {
- testsetplatform win
- file split /
-} {/}
-test filename-6.2 {Tcl_SplitPath: win} {
- testsetplatform win
- file split /foo
-} {/ foo}
-test filename-6.3 {Tcl_SplitPath: win} {
- testsetplatform win
- file split /foo/bar
-} {/ foo bar}
-test filename-6.4 {Tcl_SplitPath: win} {
- testsetplatform win
- file split /foo/bar/baz
-} {/ foo bar baz}
-test filename-6.5 {Tcl_SplitPath: win} {
- testsetplatform win
- file split foo/bar
-} {foo bar}
-test filename-6.6 {Tcl_SplitPath: win} {
- testsetplatform win
- file split ./foo/bar
-} {. foo bar}
-test filename-6.7 {Tcl_SplitPath: win} {
- testsetplatform win
- file split /foo/../././foo/bar
-} {/ foo .. . . foo bar}
-test filename-6.8 {Tcl_SplitPath: win} {
- testsetplatform win
- file split ../foo/bar
-} {.. foo bar}
-test filename-6.9 {Tcl_SplitPath: win} {
- testsetplatform win
- file split {}
-} {}
-test filename-6.10 {Tcl_SplitPath: win} {
- testsetplatform win
- file split .
-} {.}
-test filename-6.11 {Tcl_SplitPath: win} {
- testsetplatform win
- file split ../
-} {..}
-test filename-6.12 {Tcl_SplitPath: win} {
- testsetplatform win
- file split ../..
-} {.. ..}
-test filename-6.13 {Tcl_SplitPath: win} {
- testsetplatform win
- file split //foo
-} {/ foo}
-test filename-6.14 {Tcl_SplitPath: win} {
- testsetplatform win
- file split foo//bar
-} {foo bar}
-test filename-6.15 {Tcl_SplitPath: win} {
- testsetplatform win
- file split /\\/foo//bar
-} {//foo/bar}
-test filename-6.16 {Tcl_SplitPath: win} {
- testsetplatform win
- file split /\\/foo//bar
-} {//foo/bar}
-test filename-6.17 {Tcl_SplitPath: win} {
- testsetplatform win
- file split /\\/foo//bar
-} {//foo/bar}
-test filename-6.18 {Tcl_SplitPath: win} {
- testsetplatform win
- file split \\\\foo\\bar
-} {//foo/bar}
-test filename-6.19 {Tcl_SplitPath: win} {
- testsetplatform win
- file split \\\\foo\\bar/baz
-} {//foo/bar baz}
-test filename-6.20 {Tcl_SplitPath: win} {
- testsetplatform win
- file split c:/foo
-} {c:/ foo}
-test filename-6.21 {Tcl_SplitPath: win} {
- testsetplatform win
- file split c:foo
-} {c: foo}
-test filename-6.22 {Tcl_SplitPath: win} {
- testsetplatform win
- file split c:
-} {c:}
-test filename-6.23 {Tcl_SplitPath: win} {
- testsetplatform win
- file split c:\\
-} {c:/}
-test filename-6.24 {Tcl_SplitPath: win} {
- testsetplatform win
- file split c:/
-} {c:/}
-test filename-6.25 {Tcl_SplitPath: win} {
- testsetplatform win
- file split c:/./..
-} {c:/ . ..}
-test filename-6.26 {Tcl_SplitPath: win} {
- testsetplatform win
- file split ~foo
-} {~foo}
-test filename-6.27 {Tcl_SplitPath: win} {
- testsetplatform win
- file split ~foo/~bar
-} {~foo ./~bar}
-test filename-6.28 {Tcl_SplitPath: win} {
- testsetplatform win
- file split ~foo/~bar/~baz
-} {~foo ./~bar ./~baz}
-test filename-6.29 {Tcl_SplitPath: win} {
- testsetplatform win
- file split foo/bar~/baz
-} {foo bar~ baz}
-test filename-6.30 {Tcl_SplitPath: win} {
- testsetplatform win
- file split c:~foo
-} {c: ./~foo}
-
-test filename-7.1 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join / a
-} {/a}
-test filename-7.2 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join a b
-} {a/b}
-test filename-7.3 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join /a c /b d
-} {/b/d}
-test filename-7.4 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join /
-} {/}
-test filename-7.5 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join a
-} {a}
-test filename-7.6 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join {}
-} {}
-test filename-7.7 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join /a/ b
-} {/a/b}
-test filename-7.8 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join /a// b
-} {/a/b}
-test filename-7.9 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join /a/./../. b
-} {/a/./.././b}
-test filename-7.10 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join ~ a
-} {~/a}
-test filename-7.11 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join ~a ~b
-} {~b}
-test filename-7.12 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join ./~a b
-} {./~a/b}
-test filename-7.13 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join ./~a ~b
-} {~b}
-test filename-7.14 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join ./~a ./~b
-} {./~a/~b}
-test filename-7.15 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join a . b
-} {a/./b}
-test filename-7.16 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join a . ./~b
-} {a/./~b}
-test filename-7.17 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join //a b
-} {/a/b}
-test filename-7.18 {Tcl_JoinPath: unix} {
- testsetplatform unix
- file join /// a b
-} {/a/b}
-
-test filename-8.1 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join a b
-} {:a:b}
-test filename-8.2 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join :a b
-} {:a:b}
-test filename-8.3 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join a b:
-} {b:}
-test filename-8.4 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join a: :b
-} {a:b}
-test filename-8.5 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join a: :b:
-} {a:b}
-test filename-8.6 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join a :: b
-} {:a::b}
-test filename-8.7 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join a :: :: b
-} {:a:::b}
-test filename-8.8 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join a ::: b
-} {:a:::b}
-test filename-8.9 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join a: b:
-} {b:}
-test filename-8.10 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join /a/b
-} {a:b}
-test filename-8.11 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join /a/b c/d
-} {a:b:c:d}
-test filename-8.12 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join /a/b :c:d
-} {a:b:c:d}
-test filename-8.13 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join ~ foo
-} {~:foo}
-test filename-8.14 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join :: ::
-} {:::}
-test filename-8.15 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join a: ::
-} {a::}
-test filename-8.16 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join a {} b
-} {:a:b}
-test filename-8.17 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join a::: b
-} {a:::b}
-test filename-8.18 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join a : : :
-} {:a}
-test filename-8.19 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join :
-} {:}
-test filename-8.20 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join : a
-} {:a}
-test filename-8.21 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join a: :b/c
-} {a:b/c}
-test filename-8.22 {Tcl_JoinPath: mac} {
- testsetplatform mac
- file join :a :b/c
-} {:a:b/c}
-
-test filename-9.1 {Tcl_JoinPath: win} {
- testsetplatform win
- file join a b
-} {a/b}
-test filename-9.2 {Tcl_JoinPath: win} {
- testsetplatform win
- file join /a b
-} {/a/b}
-test filename-9.3 {Tcl_JoinPath: win} {
- testsetplatform win
- file join /a /b
-} {/b}
-test filename-9.4 {Tcl_JoinPath: win} {
- testsetplatform win
- file join c: foo
-} {c:foo}
-test filename-9.5 {Tcl_JoinPath: win} {
- testsetplatform win
- file join c:/ foo
-} {c:/foo}
-test filename-9.6 {Tcl_JoinPath: win} {
- testsetplatform win
- file join c:\\bar foo
-} {c:/bar/foo}
-test filename-9.7 {Tcl_JoinPath: win} {
- testsetplatform win
- file join /foo c:bar
-} {c:bar}
-test filename-9.8 {Tcl_JoinPath: win} {
- testsetplatform win
- file join ///host//share dir
-} {//host/share/dir}
-test filename-9.9 {Tcl_JoinPath: win} {
- testsetplatform win
- file join ~ foo
-} {~/foo}
-test filename-9.10 {Tcl_JoinPath: win} {
- testsetplatform win
- file join ~/~foo
-} {~/~foo}
-test filename-9.11 {Tcl_JoinPath: win} {
- testsetplatform win
- file join ~ ./~foo
-} {~/~foo}
-test filename-9.12 {Tcl_JoinPath: win} {
- testsetplatform win
- file join / ~foo
-} {~foo}
-test filename-9.13 {Tcl_JoinPath: win} {
- testsetplatform win
- file join ./a/ b c
-} {./a/b/c}
-test filename-9.14 {Tcl_JoinPath: win} {
- testsetplatform win
- file join ./~a/ b c
-} {./~a/b/c}
-test filename-9.15 {Tcl_JoinPath: win} {
- testsetplatform win
- file join // host share path
-} {/host/share/path}
-test filename-9.16 {Tcl_JoinPath: win} {
- testsetplatform win
- file join foo . bar
-} {foo/./bar}
-test filename-9.17 {Tcl_JoinPath: win} {
- testsetplatform win
- file join foo .. bar
-} {foo/../bar}
-test filename-9.18 {Tcl_JoinPath: win} {
- testsetplatform win
- file join foo/./bar
-} {foo/./bar}
-
-test filename-10.1 {Tcl_TranslateFileName} {
- testsetplatform unix
- list [catch {testtranslatefilename foo} msg] $msg
-} {0 foo}
-test filename-10.2 {Tcl_TranslateFileName} {
- testsetplatform windows
- list [catch {testtranslatefilename {c:/foo}} msg] $msg
-} {0 {c:\foo}}
-test filename-10.3 {Tcl_TranslateFileName} {
- testsetplatform windows
- list [catch {testtranslatefilename {c:/\\foo/}} msg] $msg
-} {0 {c:\foo}}
-test filename-10.4 {Tcl_TranslateFileName} {
- testsetplatform mac
- list [catch {testtranslatefilename foo} msg] $msg
-} {0 :foo}
-test filename-10.5 {Tcl_TranslateFileName} {
- testsetplatform mac
- list [catch {testtranslatefilename :~foo} msg] $msg
-} {0 :~foo}
-test filename-10.6 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- set env(HOME) "/home/test"
- testsetplatform unix
- set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 /home/test/foo}
-test filename-10.7 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- unset env(HOME)
- testsetplatform unix
- set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
- set env(HOME) $temp
- set result
-} {1 {couldn't find HOME environment variable to expand path}}
-test filename-10.8 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- set env(HOME) "/home/test"
- testsetplatform unix
- set result [list [catch {testtranslatefilename ~} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 /home/test}
-test filename-10.9 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- set env(HOME) "/home/test/"
- testsetplatform unix
- set result [list [catch {testtranslatefilename ~} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 /home/test}
-test filename-10.10 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- set env(HOME) "/home/test/"
- testsetplatform unix
- set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 /home/test/foo}
-test filename-10.11 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- set env(HOME) "Root:"
- testsetplatform mac
- set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 Root:foo}
-test filename-10.12 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- set env(HOME) "Root:home"
- testsetplatform mac
- set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 Root:home:foo}
-test filename-10.13 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- set env(HOME) "Root:home"
- testsetplatform mac
- set result [list [catch {testtranslatefilename ~::foo} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 Root:home::foo}
-test filename-10.14 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- set env(HOME) "Root:home"
- testsetplatform mac
- set result [list [catch {testtranslatefilename ~} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 Root:home}
-test filename-10.15 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- set env(HOME) "Root:home:"
- testsetplatform mac
- set result [list [catch {testtranslatefilename ~::foo} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 Root:home::foo}
-test filename-10.16 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- set env(HOME) "Root:home::"
- testsetplatform mac
- set result [list [catch {testtranslatefilename ~::foo} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 Root:home:::foo}
-test filename-10.17 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- set env(HOME) "\\home\\"
- testsetplatform windows
- set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 {\home\foo}}
-test filename-10.18 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- set env(HOME) "\\home\\"
- testsetplatform windows
- set result [list [catch {testtranslatefilename ~/foo\\bar} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 {\home\foo\bar}}
-test filename-10.19 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- set env(HOME) "c:"
- testsetplatform windows
- set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 c:foo}
-test filename-10.20 {Tcl_TranslateFileName} {
- list [catch {testtranslatefilename ~blorp/foo} msg] $msg
-} {1 {user "blorp" doesn't exist}}
-test filename-10.21 {Tcl_TranslateFileName} {
- global env
- set temp $env(HOME)
- set env(HOME) "c:\\"
- testsetplatform windows
- set result [list [catch {testtranslatefilename ~/foo} msg] $msg]
- set env(HOME) $temp
- set result
-} {0 {c:\foo}}
-test filename-10.22 {Tcl_TranslateFileName} {
- testsetplatform windows
- list [catch {testtranslatefilename foo//bar} msg] $msg
-} {0 {foo\bar}}
-
-testsetplatform $platform
-
-test filename-10.23 {Tcl_TranslateFileName} {unixOnly nonPortable} {
- # this test fails if ~ouster is not /home/ouster
- list [catch {testtranslatefilename ~ouster} msg] $msg
-} {0 /home/ouster}
-test filename-10.24 {Tcl_TranslateFileName} {unixOnly nonPortable} {
- # this test fails if ~ouster is not /home/ouster
- list [catch {testtranslatefilename ~ouster/foo} msg] $msg
-} {0 /home/ouster/foo}
-
-
-test filename-11.1 {Tcl_GlobCmd} {
- list [catch {glob} msg] $msg
-} {1 {wrong # args: should be "glob ?switches? name ?name ...?"}}
-test filename-11.2 {Tcl_GlobCmd} {
- list [catch {glob -gorp} msg] $msg
-} {1 {bad switch "-gorp": must be -nocomplain or --}}
-test filename-11.3 {Tcl_GlobCmd} {
- list [catch {glob -nocomplai} msg] $msg
-} {1 {bad switch "-nocomplai": must be -nocomplain or --}}
-test filename-11.4 {Tcl_GlobCmd} {
- list [catch {glob -nocomplain} msg] $msg
-} {1 {wrong # args: should be "glob ?switches? name ?name ...?"}}
-test filename-11.5 {Tcl_GlobCmd} {
- list [catch {glob -nocomplain ~xyqrszzz} msg] $msg
-} {0 {}}
-test filename-11.6 {Tcl_GlobCmd} {
- list [catch {glob ~xyqrszzz} msg] $msg
-} {1 {user "xyqrszzz" doesn't exist}}
-test filename-11.7 {Tcl_GlobCmd} {
- list [catch {glob -- -nocomplain} msg] $msg
-} {1 {no files matched glob patterns "-nocomplain"}}
-test filename-11.8 {Tcl_GlobCmd} {
- list [catch {glob -nocomplain -- -nocomplain} msg] $msg
-} {0 {}}
-test filename-11.9 {Tcl_GlobCmd} {
- testsetplatform unix
- list [catch {glob ~\\xyqrszzz/bar} msg] $msg
-} {1 {globbing characters not supported in user names}}
-test filename-11.10 {Tcl_GlobCmd} {
- testsetplatform unix
- list [catch {glob -nocomplain ~\\xyqrszzz/bar} msg] $msg
-} {0 {}}
-test filename-11.11 {Tcl_GlobCmd} {
- testsetplatform unix
- list [catch {glob ~xyqrszzz\\/\\bar} msg] $msg
-} {1 {user "xyqrszzz" doesn't exist}}
-test filename-11.12 {Tcl_GlobCmd} {
- testsetplatform unix
- set home $env(HOME)
- unset env(HOME)
- set x [list [catch {glob ~/*} msg] $msg]
- set env(HOME) $home
- set x
-} {1 {couldn't find HOME environment variable to expand path}}
-
-testsetplatform $platform
-
-test filename-11.13 {Tcl_GlobCmd} {
- list [catch {file join [lindex [glob ~] 0]} msg] $msg
-} [list 0 [file join $env(HOME)]]
-
-set oldhome $env(HOME)
-set env(HOME) [pwd]
-file delete -force globTest
-file mkdir globTest/a1/b1
-file mkdir globTest/a1/b2
-file mkdir globTest/a2/b3
-file mkdir globTest/a3
-close [open globTest/x1.c w]
-close [open globTest/y1.c w]
-close [open globTest/z1.c w]
-close [open "globTest/weird name.c" w]
-close [open globTest/a1/b1/x2.c w]
-close [open globTest/a1/b2/y2.c w]
-
-catch {close [open globTest/.1 w]}
-catch {close [open globTest/x,z1.c w]}
-
-test filename-11.14 {Tcl_GlobCmd} {
- list [catch {glob ~/globTest} msg] $msg
-} [list 0 [list [file join $env(HOME) globTest]]]
-test filename-11.15 {Tcl_GlobCmd} {
- list [catch {glob ~\\/globTest} msg] $msg
-} [list 0 [list [file join $env(HOME) globTest]]]
-test filename-11.16 {Tcl_GlobCmd} {
- list [catch {glob globTest} msg] $msg
-} {0 globTest}
-
-test filename-12.1 {simple globbing} {unixOrPc} {
- list [catch {glob {}} msg] $msg
-} {0 .}
-test filename-12.2 {simple globbing} {macOnly} {
- list [catch {glob {}} msg] $msg
-} {0 :}
-test filename-12.3 {simple globbing} {
- list [catch {glob -nocomplain \{a1,a2\}} msg] $msg
-} {0 {}}
-
-if {$tcl_platform(platform) == "macintosh"} {
- set globPreResult :globTest:
-} else {
- set globPreResult globTest/
-}
-set x1 x1.c
-set y1 y1.c
-test filename-12.4 {simple globbing} {unixOrPc} {
- lsort [glob globTest/x1.c globTest/y1.c globTest/foo]
-} "$globPreResult$x1 $globPreResult$y1"
-test filename-12.5 {simple globbing} {
- list [catch {glob globTest\\/x1.c} msg] $msg
-} "0 $globPreResult$x1"
-test filename-12.6 {simple globbing} {
- list [catch {glob globTest\\/\\x1.c} msg] $msg
-} "0 $globPreResult$x1"
-
-test filename-13.1 {globbing with brace substitution} {
- list [catch {glob globTest/\{\}} msg] $msg
-} "0 $globPreResult"
-test filename-13.2 {globbing with brace substitution} {
- list [catch {glob globTest/\{} msg] $msg
-} {1 {unmatched open-brace in file name}}
-test filename-13.3 {globbing with brace substitution} {
- list [catch {glob globTest/\{\\\}} msg] $msg
-} {1 {unmatched open-brace in file name}}
-test filename-13.4 {globbing with brace substitution} {
- list [catch {glob globTest/\{\\} msg] $msg
-} {1 {unmatched open-brace in file name}}
-test filename-13.5 {globbing with brace substitution} {
- list [catch {glob globTest/\}} msg] $msg
-} {1 {unmatched close-brace in file name}}
-test filename-13.6 {globbing with brace substitution} {
- list [catch {glob globTest/\{\}x1.c} msg] $msg
-} "0 $globPreResult$x1"
-test filename-13.7 {globbing with brace substitution} {
- list [catch {glob globTest/\{x\}1.c} msg] $msg
-} "0 $globPreResult$x1"
-test filename-13.8 {globbing with brace substitution} {
- list [catch {glob globTest/\{x\{\}\}1.c} msg] $msg
-} "0 $globPreResult$x1"
-test filename-13.9 {globbing with brace substitution} {
- list [lsort [catch {glob globTest/\{x,y\}1.c} msg]] $msg
-} [list 0 [list $globPreResult$x1 $globPreResult$y1]]
-test filename-13.10 {globbing with brace substitution} {
- list [lsort [catch {glob globTest/\{x,,y\}1.c} msg]] $msg
-} [list 0 [list $globPreResult$x1 $globPreResult$y1]]
-test filename-13.11 {globbing with brace substitution} {unixOrPc} {
- list [lsort [catch {glob globTest/\{x,x\\,z,z\}1.c} msg]] $msg
-} {0 {globTest/x1.c globTest/x,z1.c globTest/z1.c}}
-test filename-13.12 {globbing with brace substitution} {macOnly} {
- list [lsort [catch {glob globTest/\{x,x\\,z,z\}1.c} msg]] $msg
-} {0 {:globTest:x1.c :globTest:x,z1.c :globTest:z1.c}}
-test filename-13.13 {globbing with brace substitution} {
- lsort [glob globTest/{a,b,x,y}1.c]
-} [list $globPreResult$x1 $globPreResult$y1]
-test filename-13.14 {globbing with brace substitution} {unixOrPc} {
- lsort [glob {globTest/{x1,y2,weird name}.c}]
-} {{globTest/weird name.c} globTest/x1.c}
-test filename-13.15 {globbing with brace substitution} {macOnly} {
- lsort [glob {globTest/{x1,y2,weird name}.c}]
-} {{:globTest:weird name.c} :globTest:x1.c}
-test filename-13.16 {globbing with brace substitution} {unixOrPc} {
- lsort [glob globTest/{x1.c,a1/*}]
-} {globTest/a1/b1 globTest/a1/b2 globTest/x1.c}
-test filename-13.17 {globbing with brace substitution} {macOnly} {
- lsort [glob globTest/{x1.c,a1/*}]
-} {:globTest:a1:b1 :globTest:a1:b2 :globTest:x1.c}
-test filename-13.18 {globbing with brace substitution} {unixOrPc} {
- lsort [glob globTest/{x1.c,{a},a1/*}]
-} {globTest/a1/b1 globTest/a1/b2 globTest/x1.c}
-test filename-13.19 {globbing with brace substitution} {macOnly} {
- lsort [glob globTest/{x1.c,{a},a1/*}]
-} {:globTest:a1:b1 :globTest:a1:b2 :globTest:x1.c}
-test filename-13.20 {globbing with brace substitution} {unixOrPc} {
- lsort [glob globTest/{a,x}1/*/{x,y}*]
-} {globTest/a1/b1/x2.c globTest/a1/b2/y2.c}
-test filename-13.21 {globbing with brace substitution} {macOnly} {
- lsort [glob globTest/{a,x}1/*/{x,y}*]
-} {:globTest:a1:b1:x2.c :globTest:a1:b2:y2.c}
-test filename-13.22 {globbing with brace substitution} {
- list [catch {glob globTest/\{a,x\}1/*/\{} msg] $msg
-} {1 {unmatched open-brace in file name}}
-
-test filename-14.1 {asterisks, question marks, and brackets} {unixOrPc} {
- lsort [glob g*/*.c]
-} {{globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c}
-test filename-14.2 {asterisks, question marks, and brackets} {macOnly} {
- lsort [glob g*/*.c]
-} {{:globTest:weird name.c} :globTest:x,z1.c :globTest:x1.c :globTest:y1.c :globTest:z1.c}
-test filename-14.3 {asterisks, question marks, and brackets} {unixOrPc} {
- lsort [glob globTest/?1.c]
-} {globTest/x1.c globTest/y1.c globTest/z1.c}
-test filename-14.4 {asterisks, question marks, and brackets} {macOnly} {
- lsort [glob globTest/?1.c]
-} {:globTest:x1.c :globTest:y1.c :globTest:z1.c}
-test filename-14.5 {asterisks, question marks, and brackets} {unixOrPc} {
- lsort [glob */*/*/*.c]
-} {globTest/a1/b1/x2.c globTest/a1/b2/y2.c}
-test filename-14.6 {asterisks, question marks, and brackets} {macOnly} {
- lsort [glob */*/*/*.c]
-} {:globTest:a1:b1:x2.c :globTest:a1:b2:y2.c}
-test filename-14.7 {asterisks, question marks, and brackets} {unixOrPc} {
- lsort [glob globTest/*]
-} {globTest/a1 globTest/a2 globTest/a3 {globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c}
-test filename-14.8 {asterisks, question marks, and brackets} {macOnly} {
- lsort [glob globTest/*]
-} {:globTest:.1 :globTest:a1 :globTest:a2 :globTest:a3 {:globTest:weird name.c} :globTest:x,z1.c :globTest:x1.c :globTest:y1.c :globTest:z1.c}
-test filename-14.9 {asterisks, question marks, and brackets} {unixOrPc} {
- lsort [glob globTest/.*]
-} {globTest/. globTest/.. globTest/.1}
-test filename-14.10 {asterisks, question marks, and brackets} {macOnly} {
- lsort [glob globTest/.*]
-} {:globTest:.1}
-test filename-14.11 {asterisks, question marks, and brackets} {unixOrPc} {
- lsort [glob globTest/*/*]
-} {globTest/a1/b1 globTest/a1/b2 globTest/a2/b3}
-test filename-14.12 {asterisks, question marks, and brackets} {macOnly} {
- lsort [glob globTest/*/*]
-} {:globTest:a1:b1 :globTest:a1:b2 :globTest:a2:b3}
-test filename-14.13 {asterisks, question marks, and brackets} {unixOrPc} {
- lsort [glob {globTest/[xyab]1.*}]
-} {globTest/x1.c globTest/y1.c}
-test filename-14.14 {asterisks, question marks, and brackets} {macOnly} {
- lsort [glob {globTest/[xyab]1.*}]
-} {:globTest:x1.c :globTest:y1.c}
-test filename-14.15 {asterisks, question marks, and brackets} {unixOrPc} {
- lsort [glob globTest/*/]
-} {globTest/a1/ globTest/a2/ globTest/a3/}
-test filename-14.16 {asterisks, question marks, and brackets} {macOnly} {
- lsort [glob globTest/*/]
-} {:globTest:a1: :globTest:a2: :globTest:a3:}
-test filename-14.17 {asterisks, question marks, and brackets} {
- global env
- set temp $env(HOME)
- set env(HOME) [file join $env(HOME) globTest]
- set result [list [catch {glob ~/z*} msg] $msg]
- set env(HOME) $temp
- set result
-} [list 0 [list [file join $env(HOME) globTest z1.c]]]
-test filename-14.18 {asterisks, question marks, and brackets} {unixOrPc} {
- list [catch {lsort [glob globTest/*.c goo/*]} msg] $msg
-} {0 {{globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c}}
-test filename-14.19 {asterisks, question marks, and brackets} {macOnly} {
- list [catch {lsort [glob globTest/*.c goo/*]} msg] $msg
-} {0 {{:globTest:weird name.c} :globTest:x,z1.c :globTest:x1.c :globTest:y1.c :globTest:z1.c}}
-test filename-14.20 {asterisks, question marks, and brackets} {
- list [catch {glob -nocomplain goo/*} msg] $msg
-} {0 {}}
-test filename-14.21 {asterisks, question marks, and brackets} {
- list [catch {glob globTest/*/gorp} msg] $msg
-} {1 {no files matched glob pattern "globTest/*/gorp"}}
-test filename-14.22 {asterisks, question marks, and brackets} {
- list [catch {glob goo/* x*z foo?q} msg] $msg
-} {1 {no files matched glob patterns "goo/* x*z foo?q"}}
-test filename-14.23 {slash globbing} {unixOrPc} {
- glob /
-} /
-test filename-14.24 {slash globbing} {pcOnly} {
- glob {\\}
-} /
-
-# The following tests are only valid for Unix systems.
-# On some systems, like AFS, "000" protection doesn't prevent
-# access by owner, so the following test is not portable.
-
-catch {exec chmod 000 globTest/a1}
-test filename-15.1 {unix specific globbing} {unixOnly nonPortable} {
- string tolower [list [catch {glob globTest/a1/*} msg] $msg $errorCode]
-} {1 {couldn't read directory "globtest/a1": permission denied} {posix eacces {permission denied}}}
-test filename-15.2 {unix specific no complain: no errors} {unixOnly nonPortable} {
- glob -nocomplain globTest/a1/*
-} {}
-test filename-15.3 {unix specific no complain: no errors, good result} \
- {unixOnly nonPortable knownBug} {
- # test fails because if an error occur , the interp's result
- # is reset...
- glob -nocomplain globTest/a2 globTest/a1/* globTest/a3
-} {globTest/a2 globTest/a3}
-
-catch {exec chmod 755 globTest/a1}
-test filename-15.4 {unix specific no complain: no errors, good result} \
- {unixOnly nonPortable knownBug} {
- # test fails because if an error occurs, the interp's result
- # is reset... or you don't run at scriptics where the
- # outser and welch users exists
- glob -nocomplain ~ouster ~foo ~welch
-} {/home/ouster /home/welch}
-test filename-15.5 {unix specific globbing} {unixOnly nonPortable} {
- glob ~ouster/.csh*
-} "/home/ouster/.cshrc"
-catch {close [open globTest/odd\\\[\]*?\{\}name w]}
-test filename-15.6 {unix specific globbing} {unixOnly} {
- global env
- set temp $env(HOME)
- set env(HOME) $env(HOME)/globTest/odd\\\[\]*?\{\}name
- set result [list [catch {glob ~} msg] $msg]
- set env(HOME) $temp
- set result
-} [list 0 [list [glob ~]/globTest/odd\\\[\]*?\{\}name]]
-catch {exec rm -f globTest/odd\\\[\]*?\{\}name}
-
-
-# The following tests are only valid for Windows systems.
-set temp [pwd]
-catch {cd c:/}
-catch {
- cd c:/
- removeDirectory globTest
- makeDirectory globTest
- close [open globTest/x1.BAT w]
- close [open globTest/y1.Bat w]
- close [open globTest/z1.bat w]
-}
-
-test filename-16.1 {windows specific globbing} {pcOnly} {
- lsort [glob globTest/*.bat]
-} {globTest/x1.BAT globTest/y1.Bat globTest/z1.bat}
-test filename-16.2 {windows specific globbing} {pcOnly} {
- glob c:
-} c:
-test filename-16.3 {windows specific globbing} {pcOnly} {
- glob c:\\\\
-} c:/
-test filename-16.4 {windows specific globbing} {pcOnly} {
- glob c:/
-} c:/
-test filename-16.5 {windows specific globbing} {pcOnly} {
- glob c:*Test
-} c:globTest
-test filename-16.6 {windows specific globbing} {pcOnly} {
- glob c:\\\\*Test
-} c:/globTest
-test filename-16.7 {windows specific globbing} {pcOnly} {
- glob c:/*Test
-} c:/globTest
-test filename-16.8 {windows specific globbing} {pcOnly} {
- lsort [glob c:globTest/*.bat]
-} {c:globTest/x1.BAT c:globTest/y1.Bat c:globTest/z1.bat}
-test filename-16.9 {windows specific globbing} {pcOnly} {
- lsort [glob c:/globTest/*.bat]
-} {c:/globTest/x1.BAT c:/globTest/y1.Bat c:/globTest/z1.bat}
-test filename-16.10 {windows specific globbing} {pcOnly} {
- lsort [glob c:globTest\\\\*.bat]
-} {c:globTest/x1.BAT c:globTest/y1.Bat c:globTest/z1.bat}
-test filename-16.11 {windows specific globbing} {pcOnly} {
- lsort [glob c:\\\\globTest\\\\*.bat]
-} {c:/globTest/x1.BAT c:/globTest/y1.Bat c:/globTest/z1.bat}
-
-# some tests require a shared C drive
-
-if {[catch {cd //[info hostname]/c}]} {
- set ::tcltest::testConfig(sharedCdrive) 0
-} else {
- set ::tcltest::testConfig(sharedCdrive) 1
-}
-
-test filename-16.12 {windows specific globbing} {pcOnly sharedCdrive} {
- cd //[info hostname]/c
- removeDirectory globTest
- makeDirectory globTest
- close [open globTest/x1.BAT w]
- close [open globTest/y1.Bat w]
- close [open globTest/z1.bat w]
- glob //[info hostname]/c/*Test
-} //[info hostname]/c/globTest
-test filename-16.13 {windows specific globbing} {pcOnly sharedCdrive} {
- cd //[info hostname]/c
- removeDirectory globTest
- makeDirectory globTest
- close [open globTest/x1.BAT w]
- close [open globTest/y1.Bat w]
- close [open globTest/z1.bat w]
- glob "\\\\\\\\[info hostname]\\\\c\\\\*Test"
-} //[info hostname]/c/globTest
-
-# cleanup
-file delete -force //[info hostname]/c/globTest
-cd $temp
-file delete -force globTest
-set env(HOME) $oldhome
-testsetplatform $platform
-catch {unset oldhome platform temp result}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/for-old.test b/tests/for-old.test
deleted file mode 100644
index b2e2d39..0000000
--- a/tests/for-old.test
+++ /dev/null
@@ -1,84 +0,0 @@
-# Commands covered: for, continue, break
-#
-# This file contains the original set of tests for Tcl's for command.
-# Since the for command is now compiled, a new set of tests covering
-# the new implementation is in the file "for.test". Sourcing this file
-# into Tcl runs the tests and generates output for errors.
-# No output means no errors were found.
-#
-# Copyright (c) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-1996 Sun Microsystems, Inc.
-#
-# See the file "license.terms" for information on usage and redistribution
-# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-#
-# RCS: @(#) $Id: for-old.test,v 1.3 1999/04/16 00:47:27 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Check "for" and its use of continue and break.
-
-catch {unset a i}
-test for-old-1.1 {for tests} {
- set a {}
- for {set i 1} {$i<6} {set i [expr $i+1]} {
- set a [concat $a $i]
- }
- set a
-} {1 2 3 4 5}
-test for-old-1.2 {for tests} {
- set a {}
- for {set i 1} {$i<6} {set i [expr $i+1]} {
- if $i==4 continue
- set a [concat $a $i]
- }
- set a
-} {1 2 3 5}
-test for-old-1.3 {for tests} {
- set a {}
- for {set i 1} {$i<6} {set i [expr $i+1]} {
- if $i==4 break
- set a [concat $a $i]
- }
- set a
-} {1 2 3}
-test for-old-1.4 {for tests} {catch {for 1 2 3} msg} 1
-test for-old-1.5 {for tests} {
- catch {for 1 2 3} msg
- set msg
-} {wrong # args: should be "for start test next command"}
-test for-old-1.6 {for tests} {catch {for 1 2 3 4 5} msg} 1
-test for-old-1.7 {for tests} {
- catch {for 1 2 3 4 5} msg
- set msg
-} {wrong # args: should be "for start test next command"}
-test for-old-1.8 {for tests} {
- set a {xyz}
- for {set i 1} {$i<6} {set i [expr $i+1]} {}
- set a
-} xyz
-test for-old-1.9 {for tests} {
- set a {}
- for {set i 1} {$i<6} {set i [expr $i+1]; if $i==4 break} {
- set a [concat $a $i]
- }
- set a
-} {1 2 3}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/for.test b/tests/for.test
deleted file mode 100644
index 4503c0b..0000000
--- a/tests/for.test
+++ /dev/null
@@ -1,752 +0,0 @@
-# Commands covered: for, continue, break
-#
-# 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) 1996 Sun Microsystems, Inc.
-#
-# See the file "license.terms" for information on usage and redistribution
-# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-#
-# RCS: @(#) $Id: for.test,v 1.3 1999/04/16 00:47:27 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Basic "for" operation.
-
-test for-1.1 {TclCompileForCmd: missing initial command} {
- list [catch {for} msg] $msg
-} {1 {wrong # args: should be "for start test next command"}}
-test for-1.2 {TclCompileForCmd: error in initial command} {
- list [catch {for {set}} msg] $msg $errorInfo
-} {1 {wrong # args: should be "for start test next command"} {wrong # args: should be "for start test next command"
- while compiling
-"for {set}"}}
-catch {unset i}
-test for-1.3 {TclCompileForCmd: missing test expression} {
- catch {for {set i 0}} msg
- set msg
-} {wrong # args: should be "for start test next command"}
-test for-1.4 {TclCompileForCmd: error in test expression} {
- catch {for {set i 0} {$i<}} msg
- set errorInfo
-} {wrong # args: should be "for start test next command"
- while compiling
-"for {set i 0} {$i<}"}
-test for-1.5 {TclCompileForCmd: test expression is enclosed in quotes} {
- set i 0
- for {} "$i > 5" {incr i} {}
-} {}
-test for-1.6 {TclCompileForCmd: missing "next" command} {
- catch {for {set i 0} {$i < 5}} msg
- set msg
-} {wrong # args: should be "for start test next command"}
-test for-1.7 {TclCompileForCmd: missing command body} {
- catch {for {set i 0} {$i < 5} {incr i}} msg
- set msg
-} {wrong # args: should be "for start test next command"}
-test for-1.8 {TclCompileForCmd: error compiling command body} {
- catch {for {set i 0} {$i < 5} {incr i} {set}} msg
- set errorInfo
-} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- ("for" body line 1)
- while compiling
-"for {set i 0} {$i < 5} {incr i} {set}"}
-catch {unset a}
-test for-1.9 {TclCompileForCmd: simple command body} {
- set a {}
- for {set i 1} {$i<6} {set i [expr $i+1]} {
- if $i==4 break
- set a [concat $a $i]
- }
- set a
-} {1 2 3}
-test for-1.10 {TclCompileForCmd: command body in quotes} {
- set a {}
- for {set i 1} {$i<6} {set i [expr $i+1]} "append a x"
- set a
-} {xxxxx}
-test for-1.11 {TclCompileForCmd: computed command body} {
- catch {unset x1}
- catch {unset bb}
- catch {unset x2}
- set x1 {append a x1; }
- set bb {break}
- set x2 {; append a x2}
- set a {}
- for {set i 1} {$i<6} {set i [expr $i+1]} $x1$bb$x2
- set a
-} {x1}
-test for-1.12 {TclCompileForCmd: error in "next" command} {
- catch {for {set i 0} {$i < 5} {set} {puts $i}} msg
- set errorInfo
-} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- ("for" loop-end command)
- while compiling
-"for {set i 0} {$i < 5} {set} {puts $i}"}
-test for-1.13 {TclCompileForCmd: long command body} {
- set a {}
- for {set i 1} {$i<6} {set i [expr $i+1]} {
- if $i==4 break
- if $i>5 continue
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- set a [concat $a $i]
- }
- set a
-} {1 2 3}
-test for-1.14 {TclCompileForCmd: for command result} {
- set a [for {set i 0} {$i < 5} {incr i} {}]
- set a
-} {}
-test for-1.15 {TclCompileForCmd: for command result} {
- set a [for {set i 0} {$i < 5} {incr i} {if $i==3 break}]
- set a
-} {}
-
-# Check "for" and "continue".
-
-test for-2.1 {TclCompileContinueCmd: arguments after "continue"} {
- catch {continue foo} msg
- set msg
-} {wrong # args: should be "continue"}
-test for-2.2 {TclCompileContinueCmd: continue result} {
- catch continue
-} 4
-test for-2.3 {continue tests} {
- set a {}
- for {set i 1} {$i <= 4} {set i [expr $i+1]} {
- if {$i == 2} continue
- set a [concat $a $i]
- }
- set a
-} {1 3 4}
-test for-2.4 {continue tests} {
- set a {}
- for {set i 1} {$i <= 4} {set i [expr $i+1]} {
- if {$i != 2} continue
- set a [concat $a $i]
- }
- set a
-} {2}
-test for-2.5 {continue tests, nested loops} {
- set msg {}
- for {set i 1} {$i <= 4} {incr i} {
- for {set a 1} {$a <= 2} {incr a} {
- if {$i>=2 && $a>=2} continue
- set msg [concat $msg "$i.$a"]
- }
- }
- set msg
-} {1.1 1.2 2.1 3.1 4.1}
-test for-2.6 {continue tests, long command body} {
- set a {}
- for {set i 1} {$i<6} {set i [expr $i+1]} {
- if $i==2 continue
- if $i==4 break
- if $i>5 continue
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- set a [concat $a $i]
- }
- set a
-} {1 3}
-
-# Check "for" and "break".
-
-test for-3.1 {TclCompileBreakCmd: arguments after "break"} {
- catch {break foo} msg
- set msg
-} {wrong # args: should be "break"}
-test for-3.2 {TclCompileBreakCmd: break result} {
- catch break
-} 3
-test for-3.3 {break tests} {
- set a {}
- for {set i 1} {$i <= 4} {incr i} {
- if {$i == 3} break
- set a [concat $a $i]
- }
- set a
-} {1 2}
-test for-3.4 {break tests, nested loops} {
- set msg {}
- for {set i 1} {$i <= 4} {incr i} {
- for {set a 1} {$a <= 2} {incr a} {
- if {$i>=2 && $a>=2} break
- set msg [concat $msg "$i.$a"]
- }
- }
- set msg
-} {1.1 1.2 2.1 3.1 4.1}
-test for-3.5 {break tests, long command body} {
- set a {}
- for {set i 1} {$i<6} {set i [expr $i+1]} {
- if $i==2 continue
- if $i==5 break
- if $i>5 continue
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if $i==4 break
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- set a [concat $a $i]
- }
- set a
-} {1 3}
-# A simplified version of exmh's mail formatting routine to stress "for",
-# "break", "while", and "if".
-proc formatMail {} {
- array set lines {
- 0 {Return-path: george@tcl} \
- 1 {Return-path: <george@tcl>} \
- 2 {Received: from tcl by tcl.Somewhere.COM (SMI-8.6/SMI-SVR4)} \
- 3 { id LAA10027; Wed, 11 Sep 1996 11:14:53 -0700} \
- 4 {Message-id: <199609111814.LAA10027@tcl.Somewhere.COM>} \
- 5 {X-mailer: exmh version 1.6.9 8/22/96} \
- 6 {Mime-version: 1.0} \
- 7 {Content-type: text/plain; charset=iso-8859-1} \
- 8 {Content-transfer-encoding: quoted-printable} \
- 9 {Content-length: 2162} \
- 10 {To: fred} \
- 11 {Subject: tcl7.6} \
- 12 {Date: Wed, 11 Sep 1996 11:14:53 -0700} \
- 13 {From: George <george@tcl>} \
- 14 {The Tcl 7.6 and Tk 4.2 releases} \
- 15 {} \
- 16 {This page contains information about Tcl 7.6 and Tk4.2, which are the most recent} \
- 17 {releases of the Tcl scripting language and the Tk toolkit. The first beta versions of these} \
- 18 {releases were released on August 30, 1996. These releases contain only minor changes,} \
- 19 {so we hope to have only a single beta release and to go final in early October, 1996. } \
- 20 {} \
- 21 {} \
- 22 {What's new } \
- 23 {} \
- 24 {The most important changes in the releases are summarized below. See the README} \
- 25 {and changes files in the distributions for more complete information on what has} \
- 26 {changed, including both feature changes and bug fixes. } \
- 27 {} \
- 28 { There are new options to the file command for copying files (file copy),} \
- 29 { deleting files and directories (file delete), creating directories (file} \
- 30 { mkdir), and renaming files (file rename). } \
- 31 { The implementation of exec has been improved greatly for Windows 95 and} \
- 32 { Windows NT. } \
- 33 { There is a new memory allocator for the Macintosh version, which should be} \
- 34 { more efficient than the old one. } \
- 35 { Tk's grid geometry manager has been completely rewritten. The layout} \
- 36 { algorithm produces much better layouts than before, especially where rows or} \
- 37 { columns were stretchable. } \
- 38 { There are new commands for creating common dialog boxes:} \
- 39 { tk_chooseColor, tk_getOpenFile, tk_getSaveFile and} \
- 40 { tk_messageBox. These use native dialog boxes if they are available. } \
- 41 { There is a new virtual event mechanism for handling events in a more portable} \
- 42 { way. See the new command event. It also allows events (both physical and} \
- 43 { virtual) to be generated dynamically. } \
- 44 {} \
- 45 {Tcl 7.6 and Tk 4.2 are backwards-compatible with Tcl 7.5 and Tk 4.1 except for} \
- 46 {changes in the C APIs for custom channel drivers. Scripts written for earlier releases} \
- 47 {should work on these new releases as well. } \
- 48 {} \
- 49 {Obtaining The Releases} \
- 50 {} \
- 51 {Binary Releases} \
- 52 {} \
- 53 {Pre-compiled releases are available for the following platforms: } \
- 54 {} \
- 55 { Windows 3.1, Windows 95, and Windows NT: Fetch} \
- 56 { ftp://ftp.sunlabs.com/pub/tcl/win42b1.exe, then execute it. The file is a} \
- 57 { self-extracting executable. It will install the Tcl and Tk libraries, the wish and} \
- 58 { tclsh programs, and documentation. } \
- 59 { Macintosh (both 68K and PowerPC): Fetch} \
- 60 { ftp://ftp.sunlabs.com/pub/tcl/mactk4.2b1.sea.hqx. The file is in binhex format,} \
- 61 { which is understood by Fetch, StuffIt, and many other Mac utilities. The} \
- 62 { unpacked file is a self-installing executable: double-click on it and it will create a} \
- 63 { folder containing all that you need to run Tcl and Tk. } \
- 64 { UNIX (Solaris 2.* and SunOS, other systems soon to follow). Easy to install} \
- 65 { binary packages are now for sale at the Sun Labs Tcl/Tk Shop. Check it out!} \
- }
-
- set result ""
- set NL "
-"
- set tag {level= type=text/plain part=0 sel Charset}
- set ix [lsearch -regexp $tag text/enriched]
- if {$ix < 0} {
- set ranges {}
- set quote 0
- }
- set breakrange {6.42 78.0}
- set F1 [lindex $breakrange 0]
- set F2 [lindex $breakrange 1]
- set breakrange [lrange $breakrange 2 end]
- if {[string length $F1] == 0} {
- set F1 -1
- set break 0
- } else {
- set break 1
- }
-
- set xmailer 0
- set inheaders 1
- set last [array size lines]
- set plen 2
- for {set L 1} {$L < $last} {incr L} {
- set line $lines($L)
- if {$inheaders} {
- # Blank or empty line terminates headers
- # Leading --- terminates headers
- if {[regexp {^[ ]*$} $line] || [regexp {^--+} $line]} {
- set inheaders 0
- }
- if {[regexp -nocase {^x-mailer:} $line]} {
- continue
- }
- }
- if $inheaders {
- set limit 55
- } else {
- set limit 55
-
- # Decide whether or not to break the body line
-
- if {$plen > 0} {
- if {[string first {> } $line] == 0} {
- # This is quoted text from previous message, don't reformat
- append result $line $NL
- if {$quote && !$inheaders} {
- # Fix from <sarr@umich.edu> to handle text/enriched
- if {$L > $L1 && $L < $L2 && $line != {}} {
- # enriched requires two newlines for each one.
- append result $NL
- } elseif {$L > $L2} {
- set L1 [lindex $ranges 0]
- set L2 [lindex $ranges 1]
- set ranges [lrange $ranges 2 end]
- set quote [llength $L1]
- }
- }
- continue
- }
- }
- if {$F1 < 0} {
- # Nothing left to format
- append result $line $NL
- continue
- } elseif {$L < $F1} {
- # Not yet to formatted block
- append result $line $NL
- continue
- } elseif {$L > $F2} {
- # Past formatted block
- set F1 [lindex $breakrange 0]
- set F2 [lindex $breakrange 1]
- set breakrange [lrange $breakrange 2 end]
- append result $line $NL
- if {[string length $F1] == 0} {
- set F1 -1
- }
- continue
- }
- }
- set climit [expr $limit-1]
- set cutoff 50
- set continuation 0
-
- while {[string length $line] > $limit} {
- for {set c [expr $limit-1]} {$c >= $cutoff} {incr c -1} {
- set char [string index $line $c]
- if {$char == " " || $char == "\t"} {
- break
- }
- if {$char == ">"} { ;# Hack for enriched formatting
- break
- }
- }
- if {$c < $cutoff} {
- if {! $inheaders} {
- set c [expr $limit-1]
- } else {
- set c [string length $line]
- }
- }
- set newline [string range $line 0 $c]
- if {! $continuation} {
- append result $newline $NL
- } else {
- append result \ $newline $NL
- }
- incr c
- set line [string trimright [string range $line $c end]]
- if {$inheaders} {
- set continuation 1
- set limit $climit
- }
- }
- if {$continuation} {
- if {[string length $line] != 0} {
- append result \ $line $NL
- }
- } else {
- append result $line $NL
- if {$quote && !$inheaders} {
- if {$L > $L1 && $L < $L2 && $line != {}} {
- # enriched requires two newlines for each one.
- append result "" $NL
- } elseif {$L > $L2} {
- set L1 [lindex $ranges 0]
- set L2 [lindex $ranges 1]
- set ranges [lrange $ranges 2 end]
- set quote [llength $L1]
- }
- }
- }
- }
- return $result
-}
-test for-3.6 {break tests} {
- formatMail
-} {Return-path: <george@tcl>
-Received: from tcl by tcl.Somewhere.COM (SMI-8.6/SMI-SVR4)
- id LAA10027; Wed, 11 Sep 1996 11:14:53 -0700
-Message-id: <199609111814.LAA10027@tcl.Somewhere.COM>
-Mime-version: 1.0
-Content-type: text/plain; charset=iso-8859-1
-Content-transfer-encoding: quoted-printable
-Content-length: 2162
-To: fred
-Subject: tcl7.6
-Date: Wed, 11 Sep 1996 11:14:53 -0700
-From: George <george@tcl>
-The Tcl 7.6 and Tk 4.2 releases
-
-This page contains information about Tcl 7.6 and Tk4.2,
- which are the most recent
-releases of the Tcl scripting language and the Tk toolk
-it. The first beta versions of these
-releases were released on August 30, 1996. These releas
-es contain only minor changes,
-so we hope to have only a single beta release and to
-go final in early October, 1996.
-
-
-What's new
-
-The most important changes in the releases are summariz
-ed below. See the README
-and changes files in the distributions for more complet
-e information on what has
-changed, including both feature changes and bug fixes.
-
- There are new options to the file command for
-copying files (file copy),
- deleting files and directories (file delete),
-creating directories (file
- mkdir), and renaming files (file rename).
- The implementation of exec has been improved great
-ly for Windows 95 and
- Windows NT.
- There is a new memory allocator for the Macintosh
-version, which should be
- more efficient than the old one.
- Tk's grid geometry manager has been completely
-rewritten. The layout
- algorithm produces much better layouts than before
-, especially where rows or
- columns were stretchable.
- There are new commands for creating common dialog
-boxes:
- tk_chooseColor, tk_getOpenFile, tk_getSaveFile and
- tk_messageBox. These use native dialog boxes if
-they are available.
- There is a new virtual event mechanism for handlin
-g events in a more portable
- way. See the new command event. It also allows
-events (both physical and
- virtual) to be generated dynamically.
-
-Tcl 7.6 and Tk 4.2 are backwards-compatible with Tcl
-7.5 and Tk 4.1 except for
-changes in the C APIs for custom channel drivers. Scrip
-ts written for earlier releases
-should work on these new releases as well.
-
-Obtaining The Releases
-
-Binary Releases
-
-Pre-compiled releases are available for the following
-platforms:
-
- Windows 3.1, Windows 95, and Windows NT: Fetch
- ftp://ftp.sunlabs.com/pub/tcl/win42b1.exe, then
-execute it. The file is a
- self-extracting executable. It will install the
-Tcl and Tk libraries, the wish and
- tclsh programs, and documentation.
- Macintosh (both 68K and PowerPC): Fetch
- ftp://ftp.sunlabs.com/pub/tcl/mactk4.2b1.sea.hqx.
-The file is in binhex format,
- which is understood by Fetch, StuffIt, and many
-other Mac utilities. The
- unpacked file is a self-installing executable:
-double-click on it and it will create a
- folder containing all that you need to run Tcl
-and Tk.
- UNIX (Solaris 2.* and SunOS, other systems
-soon to follow). Easy to install
- binary packages are now for sale at the Sun Labs
-Tcl/Tk Shop. Check it out!
-}
-
-# Check that "break" resets the interpreter's result
-
-test for-4.1 {break must reset the interp result} {
- catch {
- set z GLOBTESTDIR/dir2/file2.c
- if [string match GLOBTESTDIR/dir2/* $z] {
- break
- }
- } j
- set j
-} {}
-
-# Basic "for" operation with computed command names.
-test for-5.1 {for cmd with computed command names: missing initial command} {
- set z for
- list [catch {$z} msg] $msg
-} {1 {wrong # args: should be "for start test next command"}}
-test for-5.2 {for cmd with computed command names: error in initial command} {
- set z for
- list [catch {$z {set}} msg] $msg $errorInfo
-} {1 {wrong # args: should be "for start test next command"} {wrong # args: should be "for start test next command"
- while executing
-"$z {set}"}}
-test for-5.3 {for cmd with computed command names: missing test expression} {
- set z for
- catch {$z {set i 0}} msg
- set msg
-} {wrong # args: should be "for start test next command"}
-test for-5.4 {for cmd with computed command names: error in test expression} {
- set z for
- catch {$z {set i 0} {$i<}} msg
- set errorInfo
-} {wrong # args: should be "for start test next command"
- while executing
-"$z {set i 0} {$i<}"}
-test for-5.5 {for cmd with computed command names: test expression is enclosed in quotes} {
- set z for
- set i 0
- $z {} "$i > 5" {incr i} {}
-} {}
-test for-5.6 {for cmd with computed command names: missing "next" command} {
- set z for
- catch {$z {set i 0} {$i < 5}} msg
- set msg
-} {wrong # args: should be "for start test next command"}
-test for-5.7 {for cmd with computed command names: missing command body} {
- set z for
- catch {$z {set i 0} {$i < 5} {incr i}} msg
- set msg
-} {wrong # args: should be "for start test next command"}
-test for-5.8 {for cmd with computed command names: error executing command body} {
- set z for
- catch {$z {set i 0} {$i < 5} {incr i} {set}} msg
- set errorInfo
-} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- ("for" body line 1)
- invoked from within
-"$z {set i 0} {$i < 5} {incr i} {set}"}
-test for-5.9 {for cmd with computed command names: simple command body} {
- set z for
- set a {}
- $z {set i 1} {$i<6} {set i [expr $i+1]} {
- if $i==4 break
- set a [concat $a $i]
- }
- set a
-} {1 2 3}
-test for-5.10 {for cmd with computed command names: command body in quotes} {
- set z for
- set a {}
- $z {set i 1} {$i<6} {set i [expr $i+1]} "append a x"
- set a
-} {xxxxx}
-test for-5.11 {for cmd with computed command names: computed command body} {
- set z for
- catch {unset x1}
- catch {unset bb}
- catch {unset x2}
- set x1 {append a x1; }
- set bb {break}
- set x2 {; append a x2}
- set a {}
- $z {set i 1} {$i<6} {set i [expr $i+1]} $x1$bb$x2
- set a
-} {x1}
-test for-5.12 {for cmd with computed command names: error in "next" command} {
- set z for
- catch {$z {set i 0} {$i < 5} {set} {set j 4}} msg
- set errorInfo
-} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- ("for" loop-end command)
- invoked from within
-"$z {set i 0} {$i < 5} {set} {set j 4}"}
-test for-5.13 {for cmd with computed command names: long command body} {
- set z for
- set a {}
- $z {set i 1} {$i<6} {set i [expr $i+1]} {
- if $i==4 break
- if $i>5 continue
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- set a [concat $a $i]
- }
- set a
-} {1 2 3}
-test for-5.14 {for cmd with computed command names: for command result} {
- set z for
- set a [$z {set i 0} {$i < 5} {incr i} {}]
- set a
-} {}
-test for-5.15 {for cmd with computed command names: for command result} {
- set z for
- set a [$z {set i 0} {$i < 5} {incr i} {if $i==3 break}]
- set a
-} {}
-
-# Test for incorrect "double evaluation" semantics
-
-test for-6.1 {possible delayed substitution of increment command} {knownBug} {
- # Increment should be 5, and lappend should always append 5
- catch {unset a}
- catch {unset i}
- set a 5
- set i {}
- for {set a 1} {$a < 12} "incr a $a" {lappend i $a}
- set i
-} {1 6 11}
-
-test for-6.2 {possible delayed substitution of body command} {knownBug} {
- # Increment should be 5, and lappend should always append 5
- set a 5
- set i {}
- for {set a 1} {$a < 12} {incr a $a} "lappend i $a"
- set i
-} {5 5 5 5}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/foreach.test b/tests/foreach.test
deleted file mode 100644
index 66e626e..0000000
--- a/tests/foreach.test
+++ /dev/null
@@ -1,242 +0,0 @@
-# Commands covered: foreach, continue, break
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-1997 Sun Microsystems, Inc.
-#
-# See the file "license.terms" for information on usage and redistribution
-# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-#
-# RCS: @(#) $Id: foreach.test,v 1.3 1999/04/16 00:47:27 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-catch {unset a}
-catch {unset x}
-
-# Basic "foreach" operation.
-
-test foreach-1.1 {basic foreach tests} {
- set a {}
- foreach i {a b c d} {
- set a [concat $a $i]
- }
- set a
-} {a b c d}
-test foreach-1.2 {basic foreach tests} {
- set a {}
- foreach i {a b {{c d} e} {123 {{x}}}} {
- set a [concat $a $i]
- }
- set a
-} {a b {c d} e 123 {{x}}}
-test foreach-1.3 {basic foreach tests} {catch {foreach} msg} 1
-test foreach-1.4 {basic foreach tests} {
- catch {foreach} msg
- set msg
-} {wrong # args: should be "foreach varList list ?varList list ...? command"}
-test foreach-1.5 {basic foreach tests} {catch {foreach i} msg} 1
-test foreach-1.6 {basic foreach tests} {
- catch {foreach i} msg
- set msg
-} {wrong # args: should be "foreach varList list ?varList list ...? command"}
-test foreach-1.7 {basic foreach tests} {catch {foreach i j} msg} 1
-test foreach-1.8 {basic foreach tests} {
- catch {foreach i j} msg
- set msg
-} {wrong # args: should be "foreach varList list ?varList list ...? command"}
-test foreach-1.9 {basic foreach tests} {catch {foreach i j k l} msg} 1
-test foreach-1.10 {basic foreach tests} {
- catch {foreach i j k l} msg
- set msg
-} {wrong # args: should be "foreach varList list ?varList list ...? command"}
-test foreach-1.11 {basic foreach tests} {
- set a {}
- foreach i {} {
- set a [concat $a $i]
- }
- set a
-} {}
-test foreach-1.12 {foreach errors} {
- list [catch {foreach {{a}{b}} {1 2 3} {}} msg] $msg
-} {1 {list element in braces followed by "{b}" instead of space}}
-test foreach-1.13 {foreach errors} {
- list [catch {foreach a {{1 2}3} {}} msg] $msg
-} {1 {list element in braces followed by "3" instead of space}}
-catch {unset a}
-test foreach-1.14 {foreach errors} {
- catch {unset a}
- set a(0) 44
- list [catch {foreach a {1 2 3} {}} msg] $msg
-} {1 {couldn't set loop variable: "a"}}
-test foreach-1.15 {foreach errors} {
- list [catch {foreach {} {} {}} msg] $msg
-} {1 {foreach varlist is empty}}
-catch {unset a}
-
-test foreach-2.1 {parallel foreach tests} {
- set x {}
- foreach {a b} {1 2 3 4} {
- append x $b $a
- }
- set x
-} {2143}
-test foreach-2.2 {parallel foreach tests} {
- set x {}
- foreach {a b} {1 2 3 4 5} {
- append x $b $a
- }
- set x
-} {21435}
-test foreach-2.3 {parallel foreach tests} {
- set x {}
- foreach a {1 2 3} b {4 5 6} {
- append x $b $a
- }
- set x
-} {415263}
-test foreach-2.4 {parallel foreach tests} {
- set x {}
- foreach a {1 2 3} b {4 5 6 7 8} {
- append x $b $a
- }
- set x
-} {41526378}
-test foreach-2.5 {parallel foreach tests} {
- set x {}
- foreach {a b} {a b A B aa bb} c {c C cc CC} {
- append x $a $b $c
- }
- set x
-} {abcABCaabbccCC}
-test foreach-2.6 {parallel foreach tests} {
- set x {}
- foreach a {1 2 3} b {1 2 3} c {1 2 3} d {1 2 3} e {1 2 3} {
- append x $a $b $c $d $e
- }
- set x
-} {111112222233333}
-test foreach-2.7 {parallel foreach tests} {
- set x {}
- foreach a {} b {1 2 3} c {1 2} d {1 2 3 4} e {{1 2}} {
- append x $a $b $c $d $e
- }
- set x
-} {1111 2222334}
-test foreach-2.8 {foreach only sets vars if repeating loop} {
- proc foo {} {
- set rgb {65535 0 0}
- foreach {r g b} [set rgb] {}
- return "r=$r, g=$g, b=$b"
- }
- foo
-} {r=65535, g=0, b=0}
-test foreach-2.9 {foreach only supports local scalar variables} {
- proc foo {} {
- set x {}
- foreach {a(3)} {1 2 3 4} {lappend x [set {a(3)}]}
- set x
- }
- foo
-} {1 2 3 4}
-
-test foreach-3.1 {compiled foreach backward jump works correctly} {
- catch {unset x}
- proc foo {arrayName} {
- upvar 1 $arrayName a
- set l {}
- foreach member [array names a] {
- lappend l [list $member [set a($member)]]
- }
- return $l
- }
- array set x {0 zero 1 one 2 two 3 three}
- foo x
-} {{0 zero} {1 one} {2 two} {3 three}}
-
-test foreach-4.1 {noncompiled foreach and shared variable or value list objects that are converted to another type} {
- catch {unset x}
- foreach {12.0} {a b c} {
- set x 12.0
- set x [expr $x + 1]
- }
- set x
-} 13.0
-
-# Check "continue".
-
-test foreach-4.1 {continue tests} {catch continue} 4
-test foreach-4.2 {continue tests} {
- set a {}
- foreach i {a b c d} {
- if {[string compare $i "b"] == 0} continue
- set a [concat $a $i]
- }
- set a
-} {a c d}
-test foreach-4.3 {continue tests} {
- set a {}
- foreach i {a b c d} {
- if {[string compare $i "b"] != 0} continue
- set a [concat $a $i]
- }
- set a
-} {b}
-test foreach-4.4 {continue tests} {catch {continue foo} msg} 1
-test foreach-4.5 {continue tests} {
- catch {continue foo} msg
- set msg
-} {wrong # args: should be "continue"}
-
-# Check "break".
-
-test foreach-5.1 {break tests} {catch break} 3
-test foreach-5.2 {break tests} {
- set a {}
- foreach i {a b c d} {
- if {[string compare $i "c"] == 0} break
- set a [concat $a $i]
- }
- set a
-} {a b}
-test foreach-5.3 {break tests} {catch {break foo} msg} 1
-test foreach-5.4 {break tests} {
- catch {break foo} msg
- set msg
-} {wrong # args: should be "break"}
-
-# Test for incorrect "double evaluation" semantics
-
-test foreach-6.1 {delayed substitution of body} {knownBug} {
- proc foo {} {
- set a 0
- foreach a [list 1 2 3] "
- set x $a
- "
- set x
- }
- foo
-} {0}
-
-# cleanup
-catch {unset a}
-catch {unset x}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/format.test b/tests/format.test
deleted file mode 100644
index 2b52187..0000000
--- a/tests/format.test
+++ /dev/null
@@ -1,499 +0,0 @@
-# Commands covered: format
-#
-# 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) 1991-1994 The Regents of the University of California.
-# Copyright (c) 1994-1998 Sun Microsystems, Inc.
-#
-# See the file "license.terms" for information on usage and redistribution
-# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-#
-# RCS: @(#) $Id: format.test,v 1.4 1999/04/16 00:47:28 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# The following code is needed because some versions of SCO Unix have
-# a round-off error in sprintf which would cause some of the tests to
-# fail. Someday I hope this code shouldn't be necessary (code added
-# 9/9/91).
-
-set roundOffBug 0
-if {"[format %7.1e 68.514]" == "6.8e+01"} {
- puts stdout "Note: this system has a sprintf round-off bug, some tests skipped\n"
- set roundOffBug 1
-}
-
-test format-1.1 {integer formatting} {
- format "%*d %d %d %d" 6 34 16923 -12 -1
-} { 34 16923 -12 -1}
-test format-1.2 {integer formatting} {nonPortable} {
- format "%4d %4d %4d %4d %d %#x %#X" 6 34 16923 -12 -1 14 12
-} { 6 34 16923 -12 -1 0xe 0XC}
-
-# %u output depends on word length, so this test is not portable.
-
-test format-1.3 {integer formatting} {nonPortable} {
- format "%4u %4u %4u %4u %d %#o" 6 34 16923 -12 -1 0
-} { 6 34 16923 4294967284 -1 0}
-test format-1.4 {integer formatting} {
- format "%-4d %-4i %-4d %-4ld" 6 34 16923 -12 -1
-} {6 34 16923 -12 }
-test format-1.5 {integer formatting} {
- format "%04d %04d %04d %04i" 6 34 16923 -12 -1
-} {0006 0034 16923 -012}
-test format-1.6 {integer formatting} {
- format "%00*d" 6 34
-} {000034}
-
-# Printing negative numbers in hex or octal format depends on word
-# length, so these tests are not portable.
-
-test format-1.7 {integer formatting} {nonPortable} {
- format "%4x %4x %4x %4x" 6 34 16923 -12 -1
-} { 6 22 421b fffffff4}
-test format-1.8 {integer formatting} {nonPortable} {
- format "%#x %#X %#X %#x" 6 34 16923 -12 -1
-} {0x6 0X22 0X421B 0xfffffff4}
-test format-1.9 {integer formatting} {nonPortable} {
- format "%#20x %#20x %#20x %#20x" 6 34 16923 -12 -1
-} { 0x6 0x22 0x421b 0xfffffff4}
-test format-1.10 {integer formatting} {nonPortable} {
- format "%-#20x %-#20x %-#20x %-#20x" 6 34 16923 -12 -1
-} {0x6 0x22 0x421b 0xfffffff4 }
-test format-1.11 {integer formatting} {nonPortable} {
- format "%-#20o %#-20o %#-20o %#-20o" 6 34 16923 -12 -1
-} {06 042 041033 037777777764 }
-
-test format-2.1 {string formatting} {
- format "%s %s %c %s" abcd {This is a very long test string.} 120 x
-} {abcd This is a very long test string. x x}
-test format-2.2 {string formatting} {
- format "%20s %20s %20c %20s" abcd {This is a very long test string.} 120 x
-} { abcd This is a very long test string. x x}
-test format-2.3 {string formatting} {
- format "%.10s %.10s %c %.10s" abcd {This is a very long test string.} 120 x
-} {abcd This is a x x}
-test format-2.4 {string formatting} {
- format "%s %s %% %c %s" abcd {This is a very long test string.} 120 x
-} {abcd This is a very long test string. % x x}
-test format-2.5 {string formatting, embedded nulls} {
- format "%10s" abc\0def
-} " abc\0def"
-test format-2.6 {string formatting, international chars} {
- format "%10s" abc\ufeffdef
-} " abc\ufeffdef"
-test format-2.6 {string formatting, international chars} {
- format "%.5s" abc\ufeffdef
-} "abc\ufeffd"
-test format-2.7 {string formatting, international chars} {
- format "foo\ufeffbar%s" baz
-} "foo\ufeffbarbaz"
-test format-2.8 {string formatting, width} {
- format "a%5sa" f
-} "a fa"
-test format-2.8 {string formatting, width} {
- format "a%-5sa" f
-} "af a"
-test format-2.8 {string formatting, width} {
- format "a%2sa" foo
-} "afooa"
-test format-2.8 {string formatting, width} {
- format "a%0sa" foo
-} "afooa"
-test format-2.8 {string formatting, precision} {
- format "a%.2sa" foobarbaz
-} "afoa"
-test format-2.8 {string formatting, precision} {
- format "a%.sa" foobarbaz
-} "aa"
-test format-2.8 {string formatting, precision} {
- list [catch {format "a%.-2sa" foobarbaz} msg] $msg
-} {1 {bad field specifier "-"}}
-test format-2.8 {string formatting, width and precision} {
- format "a%5.2sa" foobarbaz
-} "a foa"
-test format-2.8 {string formatting, width and precision} {
- format "a%5.7sa" foobarbaz
-} "afoobarba"
-
-test format-3.1 {Tcl_FormatObjCmd: character formatting} {
- format "|%c|%0c|%-1c|%1c|%-6c|%6c|%*c|%*c|" 65 65 65 65 65 65 3 65 -4 65
-} "|A|A|A|A|A | A| A|A |"
-test format-3.2 {Tcl_FormatObjCmd: international character formatting} {
- format "|%c|%0c|%-1c|%1c|%-6c|%6c|%*c|%*c|" 0xa2 0x4e4e 0x25a 0xc3 0xff08 0 3 0x6575 -4 0x4e4f
-} "|\ua2|\u4e4e|\u25a|\uc3|\uff08 | \0| \u6575|\u4e4f |"
-
-test format-4.1 {e and f formats} {eformat} {
- format "%e %e %e %e" 34.2e12 68.514 -.125 -16000. .000053
-} {3.420000e+13 6.851400e+01 -1.250000e-01 -1.600000e+04}
-test format-4.2 {e and f formats} {eformat} {
- format "%20e %20e %20e %20e" 34.2e12 68.514 -.125 -16000. .000053
-} { 3.420000e+13 6.851400e+01 -1.250000e-01 -1.600000e+04}
-if {!$roundOffBug} {
- test format-4.3 {e and f formats} {eformat} {
- format "%.1e %.1e %.1e %.1e" 34.2e12 68.514 -.126 -16000. .000053
- } {3.4e+13 6.9e+01 -1.3e-01 -1.6e+04}
- test format-4.4 {e and f formats} {eformat} {
- format "%020e %020e %020e %020e" 34.2e12 68.514 -.126 -16000. .000053
- } {000000003.420000e+13 000000006.851400e+01 -00000001.260000e-01 -00000001.600000e+04}
- test format-4.5 {e and f formats} {eformat} {
- format "%7.1e %7.1e %7.1e %7.1e" 34.2e12 68.514 -.126 -16000. .000053
- } {3.4e+13 6.9e+01 -1.3e-01 -1.6e+04}
- test format-4.6 {e and f formats} {
- format "%f %f %f %f" 34.2e12 68.514 -.125 -16000. .000053
- } {34200000000000.000000 68.514000 -0.125000 -16000.000000}
-}
-test format-4.7 {e and f formats} {nonPortable} {
- format "%.4f %.4f %.4f %.4f %.4f" 34.2e12 68.514 -.125 -16000. .000053
-} {34200000000000.0000 68.5140 -0.1250 -16000.0000 0.0001}
-test format-4.8 {e and f formats} {eformat} {
- format "%.4e %.5e %.6e" -9.99996 -9.99996 9.99996
-} {-1.0000e+01 -9.99996e+00 9.999960e+00}
-test format-4.9 {e and f formats} {
- format "%.4f %.5f %.6f" -9.99996 -9.99996 9.99996
-} {-10.0000 -9.99996 9.999960}
-test format-4.10 {e and f formats} {
- format "%20f %-20f %020f" -9.99996 -9.99996 9.99996
-} { -9.999960 -9.999960 0000000000009.999960}
-test format-4.11 {e and f formats} {
- format "%-020f %020f" -9.99996 -9.99996 9.99996
-} {-9.999960 -000000000009.999960}
-test format-4.12 {e and f formats} {eformat} {
- format "%.0e %#.0e" -9.99996 -9.99996 9.99996
-} {-1e+01 -1.e+01}
-test format-4.13 {e and f formats} {
- format "%.0f %#.0f" -9.99996 -9.99996 9.99996
-} {-10 -10.}
-test format-4.14 {e and f formats} {
- format "%.4f %.5f %.6f" -9.99996 -9.99996 9.99996
-} {-10.0000 -9.99996 9.999960}
-test format-4.15 {e and f formats} {
- format "%3.0f %3.0f %3.0f %3.0f" 1.0 1.1 1.01 1.001
-} { 1 1 1 1}
-test format-4.16 {e and f formats} {
- format "%3.1f %3.1f %3.1f %3.1f" 0.0 0.1 0.01 0.001
-} {0.0 0.1 0.0 0.0}
-
-test format-5.1 {g-format} {eformat} {
- format "%.3g" 12341.0
-} {1.23e+04}
-test format-5.2 {g-format} {eformat} {
- format "%.3G" 1234.12345
-} {1.23E+03}
-test format-5.3 {g-format} {
- format "%.3g" 123.412345
-} {123}
-test format-5.4 {g-format} {
- format "%.3g" 12.3412345
-} {12.3}
-test format-5.5 {g-format} {
- format "%.3g" 1.23412345
-} {1.23}
-test format-5.6 {g-format} {
- format "%.3g" 1.23412345
-} {1.23}
-test format-5.7 {g-format} {
- format "%.3g" .123412345
-} {0.123}
-test format-5.8 {g-format} {
- format "%.3g" .012341
-} {0.0123}
-test format-5.9 {g-format} {
- format "%.3g" .0012341
-} {0.00123}
-test format-5.10 {g-format} {
- format "%.3g" .00012341
-} {0.000123}
-test format-5.11 {g-format} {eformat} {
- format "%.3g" .00001234
-} {1.23e-05}
-test format-5.12 {g-format} {eformat} {
- format "%.4g" 9999.6
-} {1e+04}
-test format-5.13 {g-format} {
- format "%.4g" 999.96
-} {1000}
-test format-5.14 {g-format} {
- format "%.3g" 1.0
-} {1}
-test format-5.15 {g-format} {
- format "%.3g" .1
-} {0.1}
-test format-5.16 {g-format} {
- format "%.3g" .01
-} {0.01}
-test format-5.17 {g-format} {
- format "%.3g" .001
-} {0.001}
-test format-5.18 {g-format} {eformat} {
- format "%.3g" .00001
-} {1e-05}
-test format-5.19 {g-format} {eformat} {
- format "%#.3g" 1234.0
-} {1.23e+03}
-test format-5.20 {g-format} {eformat} {
- format "%#.3G" 9999.5
-} {1.00E+04}
-
-test format-6.1 {floating-point zeroes} {eformat} {
- format "%e %f %g" 0.0 0.0 0.0 0.0
-} {0.000000e+00 0.000000 0}
-test format-6.2 {floating-point zeroes} {eformat} {
- format "%.4e %.4f %.4g" 0.0 0.0 0.0 0.0
-} {0.0000e+00 0.0000 0}
-test format-6.3 {floating-point zeroes} {eformat} {
- format "%#.4e %#.4f %#.4g" 0.0 0.0 0.0 0.0
-} {0.0000e+00 0.0000 0.000}
-test format-6.4 {floating-point zeroes} {eformat} {
- format "%.0e %.0f %.0g" 0.0 0.0 0.0 0.0
-} {0e+00 0 0}
-test format-6.5 {floating-point zeroes} {eformat} {
- format "%#.0e %#.0f %#.0g" 0.0 0.0 0.0 0.0
-} {0.e+00 0. 0.}
-test format-6.6 {floating-point zeroes} {
- format "%3.0f %3.0f %3.0f %3.0f" 0.0 0.0 0.0 0.0
-} { 0 0 0 0}
-test format-6.7 {floating-point zeroes} {
- format "%3.0f %3.0f %3.0f %3.0f" 1.0 1.1 1.01 1.001
-} { 1 1 1 1}
-test format-6.8 {floating-point zeroes} {
- format "%3.1f %3.1f %3.1f %3.1f" 0.0 0.1 0.01 0.001
-} {0.0 0.1 0.0 0.0}
-
-test format-7.1 {various syntax features} {
- format "%*.*f" 12 3 12.345678901
-} { 12.346}
-test format-7.2 {various syntax features} {
- format "%0*.*f" 12 3 12.345678901
-} {00000012.346}
-test format-7.3 {various syntax features} {
- format "\*\t\\n"
-} {* \n}
-
-test format-8.1 {error conditions} {
- catch format
-} 1
-test format-8.2 {error conditions} {
- catch format msg
- set msg
-} {wrong # args: should be "format formatString ?arg arg ...?"}
-test format-8.3 {error conditions} {
- catch {format %*d}
-} 1
-test format-8.4 {error conditions} {
- catch {format %*d} msg
- set msg
-} {not enough arguments for all format specifiers}
-test format-8.5 {error conditions} {
- catch {format %*.*f 12}
-} 1
-test format-8.6 {error conditions} {
- catch {format %*.*f 12} msg
- set msg
-} {not enough arguments for all format specifiers}
-test format-8.7 {error conditions} {
- catch {format %*.*f 12 3}
-} 1
-test format-8.8 {error conditions} {
- catch {format %*.*f 12 3} msg
- set msg
-} {not enough arguments for all format specifiers}
-test format-8.9 {error conditions} {
- list [catch {format %*d x 3} msg] $msg
-} {1 {expected integer but got "x"}}
-test format-8.10 {error conditions} {
- list [catch {format %*.*f 2 xyz 3} msg] $msg
-} {1 {expected integer but got "xyz"}}
-test format-8.11 {error conditions} {
- catch {format %d 2a}
-} 1
-test format-8.12 {error conditions} {
- catch {format %d 2a} msg
- set msg
-} {expected integer but got "2a"}
-test format-8.13 {error conditions} {
- catch {format %c 2x}
-} 1
-test format-8.14 {error conditions} {
- catch {format %c 2x} msg
- set msg
-} {expected integer but got "2x"}
-test format-8.15 {error conditions} {
- catch {format %f 2.1z}
-} 1
-test format-8.16 {error conditions} {
- catch {format %f 2.1z} msg
- set msg
-} {expected floating-point number but got "2.1z"}
-test format-8.17 {error conditions} {
- catch {format ab%}
-} 1
-test format-8.18 {error conditions} {
- catch {format ab% 12} msg
- set msg
-} {format string ended in middle of field specifier}
-test format-8.19 {error conditions} {
- catch {format %q x}
-} 1
-test format-8.20 {error conditions} {
- catch {format %q x} msg
- set msg
-} {bad field specifier "q"}
-test format-8.21 {error conditions} {
- catch {format %d}
-} 1
-test format-8.22 {error conditions} {
- catch {format %d} msg
- set msg
-} {not enough arguments for all format specifiers}
-test format-8.23 {error conditions} {
- catch {format "%d %d" 24 xyz} msg
- set msg
-} {expected integer but got "xyz"}
-
-test format-9.1 {long result} {
- set a {1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}
- format {1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG %s %s} $a $a
-} {1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG 1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}
-
-test format-10.1 {"h" format specifier} {nonPortable} {
- format %hd 0xffff
-} -1
-test format-10.2 {"h" format specifier} {nonPortable} {
- format %hx 0x10fff
-} fff
-test format-10.3 {"h" format specifier} {nonPortable} {
- format %hd 0x10000
-} 0
-
-test format-11.1 {XPG3 %$n specifiers} {
- format {%2$d %1$d} 4 5
-} {5 4}
-test format-11.2 {XPG3 %$n specifiers} {
- format {%2$d %1$d %1$d %3$d} 4 5 6
-} {5 4 4 6}
-test format-11.3 {XPG3 %$n specifiers} {
- list [catch {format {%2$d %3$d} 4 5} msg] $msg
-} {1 {"%n$" argument index out of range}}
-test format-11.4 {XPG3 %$n specifiers} {
- list [catch {format {%2$d %0$d} 4 5 6} msg] $msg
-} {1 {"%n$" argument index out of range}}
-test format-11.5 {XPG3 %$n specifiers} {
- list [catch {format {%d %1$d} 4 5 6} msg] $msg
-} {1 {cannot mix "%" and "%n$" conversion specifiers}}
-test format-11.6 {XPG3 %$n specifiers} {
- list [catch {format {%2$d %d} 4 5 6} msg] $msg
-} {1 {cannot mix "%" and "%n$" conversion specifiers}}
-test format-11.7 {XPG3 %$n specifiers} {
- list [catch {format {%2$d %3d} 4 5 6} msg] $msg
-} {1 {cannot mix "%" and "%n$" conversion specifiers}}
-test format-11.8 {XPG3 %$n specifiers} {
- format {%2$*d %3$d} 1 10 4
-} { 4 4}
-test format-11.9 {XPG3 %$n specifiers} {
- format {%2$.*s %4$d} 1 5 abcdefghijklmnop 44
-} {abcde 44}
-test format-11.10 {XPG3 %$n specifiers} {
- list [catch {format {%2$*d} 4} msg] $msg
-} {1 {"%n$" argument index out of range}}
-test format-11.11 {XPG3 %$n specifiers} {
- list [catch {format {%2$*d} 4 5} msg] $msg
-} {1 {"%n$" argument index out of range}}
-test format-11.12 {XPG3 %$n specifiers} {
- list [catch {format {%2$*d} 4 5 6} msg] $msg
-} {0 { 6}}
-
-test format-12.1 {negative width specifiers} {
- format "%*d" -47 25
-} {25 }
-test format-13.1 {tcl_precision fuzzy comparison} {
- catch {unset a}
- catch {unset b}
- catch {unset c}
- catch {unset d}
- set a 0.0000000000001
- set b 0.00000000000001
- set c 0.00000000000000001
- set d [expr $a + $b + $c]
- format {%0.10f %0.12f %0.15f %0.17f} $d $d $d $d
-} {0.0000000000 0.000000000000 0.000000000000110 0.00000000000011001}
-test format-13.2 {tcl_precision fuzzy comparison} {
- catch {unset a}
- catch {unset b}
- catch {unset c}
- catch {unset d}
- set a 0.000000000001
- set b 0.000000000000005
- set c 0.0000000000000008
- set d [expr $a + $b + $c]
- format {%0.10f %0.12f %0.15f %0.17f} $d $d $d $d
-} {0.0000000000 0.000000000001 0.000000000001006 0.00000000000100580}
-test format-13.3 {tcl_precision fuzzy comparison} {
- catch {unset a}
- catch {unset b}
- catch {unset c}
- set a 0.00000000000099
- set b 0.000000000000011
- set c [expr $a + $b]
- format {%0.10f %0.12f %0.15f %0.17f} $c $c $c $c
-} {0.0000000000 0.000000000001 0.000000000001001 0.00000000000100100}
-test format-13.4 {tcl_precision fuzzy comparison} {
- catch {unset a}
- catch {unset b}
- catch {unset c}
- set a 0.444444444444
- set b 0.33333333333333
- set c [expr $a + $b]
- format {%0.10f %0.12f %0.15f %0.16f} $c $c $c $c
-} {0.7777777778 0.777777777777 0.777777777777330 0.7777777777773300}
-test format-13.5 {tcl_precision fuzzy comparison} {
- catch {unset a}
- catch {unset b}
- catch {unset c}
- set a 0.444444444444
- set b 0.99999999999999
- set c [expr $a + $b]
- format {%0.10f %0.12f %0.15f} $c $c $c
-} {1.4444444444 1.444444444444 1.444444444443990}
-test format-14.1 {testing MAX_FLOAT_SIZE for 0 and 1} {
- format {%s} ""
-} {}
-test format-14.2 {testing MAX_FLOAT_SIZE for 0 and 1} {
- format {%s} "a"
-} {a}
-
-set a "0123456789"
-set b ""
-for {set i 0} {$i < 290} {incr i} {
- append b $a
-}
-for {set i 290} {$i < 400} {incr i} {
- test format-15.[expr $i -290] {testing MAX_FLOAT_SIZE} {
- format {%s} $b
- } $b
- append b "x"
-}
-
-# cleanup
-catch {unset a}
-catch {unset b}
-catch {unset c}
-catch {unset d}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/get.test b/tests/get.test
deleted file mode 100644
index 261cf19..0000000
--- a/tests/get.test
+++ /dev/null
@@ -1,110 +0,0 @@
-# Commands covered: none
-#
-# This file contains a collection of tests for the procedures in the
-# file tclGet.c. Sourcing this file into Tcl runs the tests and
-# 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: get.test,v 1.3 1999/04/16 00:47:28 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test get-1.1 {Tcl_GetInt procedure} {
- set x 44
- incr x { 22}
-} {66}
-test get-1.2 {Tcl_GetInt procedure} {
- set x 44
- incr x -3
-} {41}
-test get-1.3 {Tcl_GetInt procedure} {
- set x 44
- incr x +8
-} {52}
-test get-1.4 {Tcl_GetInt procedure} {
- set x 44
- list [catch {incr x foo} msg] $msg
-} {1 {expected integer but got "foo"}}
-test get-1.5 {Tcl_GetInt procedure} {
- set x 44
- list [catch {incr x {16 }} msg] $msg
-} {0 60}
-test get-1.6 {Tcl_GetInt procedure} {
- set x 44
- list [catch {incr x {16 x}} msg] $msg
-} {1 {expected integer but got "16 x"}}
-
-# The following tests are non-portable because they depend on
-# word size.
-
-if {0x80000000 > 0} {
- test get-1.7 {Tcl_GetInt procedure} {
- set x 44
- list [catch {incr x 18446744073709551616} msg] $msg $errorCode
- } {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
- test get-1.8 {Tcl_GetInt procedure} {
- set x 0
- list [catch {incr x 18446744073709551614} msg] $msg
- } {0 -2}
- test get-1.9 {Tcl_GetInt procedure} {
- set x 0
- list [catch {incr x +18446744073709551614} msg] $msg
- } {0 -2}
- test get-1.10 {Tcl_GetInt procedure} {
- set x 0
- list [catch {incr x -18446744073709551614} msg] $msg
- } {0 2}
-} else {
- test get-1.7 {Tcl_GetInt procedure} {
- set x 44
- list [catch {incr x 4294967296} msg] $msg $errorCode
- } {1 {integer value too large to represent} {ARITH IOVERFLOW {integer value too large to represent}}}
- test get-1.8 {Tcl_GetInt procedure} {
- set x 0
- list [catch {incr x 4294967294} msg] $msg
- } {0 -2}
- test get-1.9 {Tcl_GetInt procedure} {
- set x 0
- list [catch {incr x +4294967294} msg] $msg
- } {0 -2}
- test get-1.10 {Tcl_GetInt procedure} {
- set x 0
- list [catch {incr x -4294967294} msg] $msg
- } {0 2}
-}
-
-test get-2.1 {Tcl_GetInt procedure} {
- format %g 1.23
-} {1.23}
-test get-2.2 {Tcl_GetInt procedure} {
- format %g { 1.23 }
-} {1.23}
-test get-2.3 {Tcl_GetInt procedure} {
- list [catch {format %g clip} msg] $msg
-} {1 {expected floating-point number but got "clip"}}
-test get-2.4 {Tcl_GetInt procedure} {nonPortable} {
- list [catch {format %g .000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001} msg] $msg $errorCode
-} {1 {floating-point value too small to represent} {ARITH UNDERFLOW {floating-point value too small to represent}}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/history.test b/tests/history.test
deleted file mode 100644
index c7f7d20..0000000
--- a/tests/history.test
+++ /dev/null
@@ -1,230 +0,0 @@
-# Commands covered: history
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: history.test,v 1.3 1999/04/16 00:47:28 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[catch {history}]} {
- puts stdout "This version of Tcl was built without the history command;\n"
- puts stdout "history tests will be skipped.\n"
- ::tcltest::cleanupTests
- return
-}
-
-set num [history nextid]
-history keep 3
-history add {set a 12345}
-history add {set b [format {A test %s} string]}
-history add {Another test}
-
-# "history event"
-
-test history-1.1 {event option} {history event -1} \
- {set b [format {A test %s} string]}
-test history-1.2 {event option} {history event $num} \
- {set a 12345}
-test history-1.3 {event option} {history event [expr $num+2]} \
- {Another test}
-test history-1.4 {event option} {history event set} \
- {set b [format {A test %s} string]}
-test history-1.5 {event option} {history e "* a*"} \
- {set a 12345}
-test history-1.6 {event option} {catch {history event *gorp} msg} 1
-test history-1.7 {event option} {
- catch {history event *gorp} msg
- set msg
-} {no event matches "*gorp"}
-test history-1.8 {event option} {history event} \
- {set b [format {A test %s} string]}
-test history-1.9 {event option} {catch {history event 123 456} msg} 1
-test history-1.10 {event option} {
- catch {history event 123 456} msg
- set msg
-} {wrong # args: should be "history event ?event?"}
-
-# "history redo"
-
-set a 0
-history redo -2
-test history-2.1 {redo option} {set a} 12345
-set b 0
-history redo
-test history-2.2 {redo option} {set b} {A test string}
-test history-2.3 {redo option} {catch {history redo -3 -4}} 1
-test history-2.4 {redo option} {
- catch {history redo -3 -4} msg
- set msg
-} {wrong # args: should be "history redo ?event?"}
-
-# "history add"
-
-history add "set a 444" exec
-test history-3.1 {add option} {set a} 444
-test history-3.2 {add option} {catch {history add "set a 444" execGorp}} 1
-test history-3.3 {add option} {
- catch {history add "set a 444" execGorp} msg
- set msg
-} {bad argument "execGorp": should be "exec"}
-test history-3.4 {add option} {catch {history add "set a 444" a} msg} 1
-test history-3.5 {add option} {
- catch {history add "set a 444" a} msg
- set msg
-} {bad argument "a": should be "exec"}
-history add "set a 555" e
-test history-3.6 {add option} {set a} 555
-history add "set a 666"
-test history-3.7 {add option} {set a} 555
-test history-3.8 {add option} {catch {history add "set a 666" e f} msg} 1
-test history-3.9 {add option} {
- catch {history add "set a 666" e f} msg
- set msg
-} {wrong # args: should be "history add event ?exec?"}
-
-# "history change"
-
-history change "A test value"
-test history-4.1 {change option} {history event [expr {[history n]-1}]} \
- "A test value"
-history ch "Another test" -1
-test history-4.2 {change option} {history e} "Another test"
-test history-4.3 {change option} {history event [expr {[history n]-1}]} \
- "A test value"
-test history-4.4 {change option} {catch {history change Foo 4 10}} 1
-test history-4.5 {change option} {
- catch {history change Foo 4 10} msg
- set msg
-} {wrong # args: should be "history change newValue ?event?"}
-test history-4.6 {change option} {
- catch {history change Foo [expr {[history n]-4}]}
-} 1
-set num [expr {[history n]-4}]
-test history-4.7 {change option} {
- catch {history change Foo $num} msg
- set msg
-} "event \"$num\" is too far in the past"
-
-# "history info"
-
-set num [history n]
-history add set\ a\ {b\nc\ d\ e}
-history add {set b 1234}
-history add set\ c\ {a\nb\nc}
-test history-5.1 {info option} {history info} [format {%6d set a {b
- c d e}
-%6d set b 1234
-%6d set c {a
- b
- c}} $num [expr $num+1] [expr $num+2]]
-test history-5.2 {info option} {history i 2} [format {%6d set b 1234
-%6d set c {a
- b
- c}} [expr $num+1] [expr $num+2]]
-test history-5.3 {info option} {catch {history i 2 3}} 1
-test history-5.4 {info option} {
- catch {history i 2 3} msg
- set msg
-} {wrong # args: should be "history info ?count?"}
-test history-5.5 {info option} {history} [format {%6d set a {b
- c d e}
-%6d set b 1234
-%6d set c {a
- b
- c}} $num [expr $num+1] [expr $num+2]]
-
-# "history keep"
-
-history add "foo1"
-history add "foo2"
-history add "foo3"
-history keep 2
-test history-6.1 {keep option} {history event [expr [history n]-1]} foo3
-test history-6.2 {keep option} {history event -1} foo2
-test history-6.3 {keep option} {catch {history event -3}} 1
-test history-6.4 {keep option} {
- catch {history event -3} msg
- set msg
-} {event "-3" is too far in the past}
-history k 5
-test history-6.5 {keep option} {history event -1} foo2
-test history-6.6 {keep option} {history event -2} {}
-test history-6.7 {keep option} {history event -3} {}
-test history-6.8 {keep option} {history event -4} {}
-test history-6.9 {keep option} {catch {history event -5}} 1
-test history-6.10 {keep option} {catch {history keep 4 6}} 1
-test history-6.11 {keep option} {
- catch {history keep 4 6} msg
- set msg
-} {wrong # args: should be "history keep ?count?"}
-test history-6.12 {keep option} {catch {history keep}} 0
-test history-6.13 {keep option} {
- history keep
-} {5}
-test history-6.14 {keep option} {catch {history keep -3}} 1
-test history-6.15 {keep option} {
- catch {history keep -3} msg
- set msg
-} {illegal keep count "-3"}
-test history-6.16 {keep option} {
- catch {history keep butter} msg
- set msg
-} {illegal keep count "butter"}
-
-# "history nextid"
-
-set num [history n]
-history add "Testing"
-history add "Testing2"
-test history-7.1 {nextid option} {history event} "Testing"
-test history-7.2 {nextid option} {history next} [expr $num+2]
-test history-7.3 {nextid option} {catch {history nextid garbage}} 1
-test history-7.4 {nextid option} {
- catch {history nextid garbage} msg
- set msg
-} {wrong # args: should be "history nextid"}
-
-# "history clear"
-
-set num [history n]
-history add "Testing"
-history add "Testing2"
-test history-8.1 {clear option} {catch {history clear junk}} 1
-test history-8.2 {clear option} {history clear} {}
-history add "Testing"
-test history-8.3 {clear option} {history} { 1 Testing}
-
-# miscellaneous
-
-test history-9.1 {miscellaneous} {catch {history gorp} msg} 1
-test history-9.2 {miscellaneous} {
- catch {history gorp} msg
- set msg
-} {bad option "gorp": must be add, change, clear, event, info, keep, nextid, or redo}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/http.test b/tests/http.test
deleted file mode 100644
index 752e3a2..0000000
--- a/tests/http.test
+++ /dev/null
@@ -1,315 +0,0 @@
-# Commands covered: http::config, http::geturl, http::wait, http::reset
-#
-# This file contains a collection of tests for the http script library.
-# Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-#
-# Copyright (c) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-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: http.test,v 1.4 1999/04/16 00:47:28 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[catch {package require http 2.0}]} {
- if {[info exist http2]} {
- catch {puts "Cannot load http 2.0 package"}
- return
- } else {
- catch {puts "Running http 2.0 tests in slave interp"}
- set interp [interp create http2]
- $interp eval [list set http2 "running"]
- $interp eval [list source [info script]]
- interp delete $interp
- return
- }
-}
-
-
-set port 8010
-set bindata "This is binary data\x0d\x0amore\x0dmore\x0amore\x00null"
-
-set httpdFile [file join $::tcltest::testsDir httpd]
-if {[info commands testthread] == "testthread" && [file exists $httpdFile]} {
- set httpthread [testthread create "
- source $httpdFile
- testthread wait
- "]
- testthread send $httpthread [list set port $port]
- testthread send $httpthread [list set bindata $bindata]
- testthread send $httpthread {httpd_init $port}
- puts "Running httpd in thread $httpthread"
-} else {
- if ![file exists $httpdFile] {
- puts "Cannot read $httpdFile script, http test skipped"
- unset port
- return
- }
- source $httpdFile
- if [catch {httpd_init $port} listen] {
- puts "Cannot start http server, http test skipped"
- unset port
- return
- }
-}
-
-
-test http-1.1 {http::config} {
- http::config
-} {-accept */* -proxyfilter http::ProxyRequired -proxyhost {} -proxyport {} -useragent {Tcl http client package 2.0}}
-
-test http-1.2 {http::config} {
- http::config -proxyfilter
-} http::ProxyRequired
-
-test http-1.3 {http::config} {
- catch {http::config -junk}
-} 1
-
-test http-1.4 {http::config} {
- set savedconf [http::config]
- http::config -proxyhost nowhere.come -proxyport 8080 -proxyfilter myFilter -useragent "Tcl Test Suite"
- set x [http::config]
- eval http::config $savedconf
- set x
-} {-accept */* -proxyfilter myFilter -proxyhost nowhere.come -proxyport 8080 -useragent {Tcl Test Suite}}
-
-test http-1.5 {http::config} {
- catch {http::config -proxyhost {} -junk 8080}
-} 1
-
-test http-2.1 {http::reset} {
- catch {http::reset http#1}
-} 0
-
-test http-3.1 {http::geturl} {
- catch {http::geturl -bogus flag}
-} 1
-test http-3.2 {http::geturl} {
- catch {http::geturl http:junk} err
- set err
-} {Unsupported URL: http:junk}
-
-set url [info hostname]:$port
-test http-3.3 {http::geturl} {
- set token [http::geturl $url]
- http::data $token
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>GET /</h2>
-</body></html>"
-
-set tail /a/b/c
-set url [info hostname]:$port/a/b/c
-set binurl [info hostname]:$port/binary
-
-test http-3.4 {http::geturl} {
- set token [http::geturl $url]
- http::data $token
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>GET $tail</h2>
-</body></html>"
-
-proc selfproxy {host} {
- global port
- return [list [info hostname] $port]
-}
-test http-3.5 {http::geturl} {
- http::config -proxyfilter selfproxy
- set token [http::geturl $url]
- http::config -proxyfilter http::ProxyRequired
- http::data $token
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>GET http://$url</h2>
-</body></html>"
-
-test http-3.6 {http::geturl} {
- http::config -proxyfilter bogus
- set token [http::geturl $url]
- http::config -proxyfilter http::ProxyRequired
- http::data $token
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>GET $tail</h2>
-</body></html>"
-
-test http-3.7 {http::geturl} {
- set token [http::geturl $url -headers {Pragma no-cache}]
- http::data $token
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>GET $tail</h2>
-</body></html>"
-
-test http-3.8 {http::geturl} {
- set token [http::geturl $url -query Name=Value&Foo=Bar]
- http::data $token
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>POST $tail</h2>
-<h2>Query</h2>
-<dl>
-<dt>Name<dd>Value
-<dt>Foo<dd>Bar
-</dl>
-</body></html>"
-
-test http-3.9 {http::geturl} {
- set token [http::geturl $url -validate 1]
- http::code $token
-} "HTTP/1.0 200 OK"
-
-
-test http-4.1 {http::Event} {
- set token [http::geturl $url]
- upvar #0 $token data
- array set meta $data(meta)
- expr ($data(totalsize) == $meta(Content-Length))
-} 1
-
-test http-4.2 {http::Event} {
- set token [http::geturl $url]
- upvar #0 $token data
- array set meta $data(meta)
- string compare $data(type) [string trim $meta(Content-Type)]
-} 0
-
-test http-4.3 {http::Event} {
- set token [http::geturl $url]
- http::code $token
-} {HTTP/1.0 200 Data follows}
-
-test http-4.4 {http::Event} {
- set out [open testfile w]
- set token [http::geturl $url -channel $out]
- close $out
- set in [open testfile]
- set x [read $in]
- close $in
- file delete testfile
- set x
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>GET $tail</h2>
-</body></html>"
-
-test http-4.5 {http::Event} {
- set out [open testfile w]
- set token [http::geturl $url -channel $out]
- close $out
- upvar #0 $token data
- file delete testfile
- expr $data(currentsize) == $data(totalsize)
-} 1
-
-test http-4.6 {http::Event} {
- set out [open testfile w]
- set token [http::geturl $binurl -channel $out]
- close $out
- set in [open testfile]
- fconfigure $in -translation binary
- set x [read $in]
- close $in
- file delete testfile
- set x
-} "$bindata$binurl"
-
-proc myProgress {token total current} {
- global progress httpLog
- if {[info exists httpLog] && $httpLog} {
- puts "progress $total $current"
- }
- set progress [list $total $current]
-}
-if 0 {
- # This test hangs on Windows95 because the client never gets EOF
- set httpLog 1
- test http-4.6 {http::Event} {
- set token [http::geturl $url -blocksize 50 -progress myProgress]
- set progress
- } {111 111}
-}
-test http-4.7 {http::Event} {
- set token [http::geturl $url -progress myProgress]
- set progress
-} {111 111}
-test http-4.8 {http::Event} {
- set token [http::geturl $url]
- http::status $token
-} {ok}
-test http-4.9 {http::Event} {
- set token [http::geturl $url -progress myProgress]
- http::code $token
-} {HTTP/1.0 200 Data follows}
-test http-4.10 {http::Event} {
- set token [http::geturl $url -progress myProgress]
- http::size $token
-} {111}
-test http-4.11 {http::Event} {
- set token [http::geturl $url -timeout 1 -command {#}]
- http::reset $token
- http::status $token
-} {reset}
-test http-4.12 {http::Event} {
- set token [http::geturl $url?timeout=10 -timeout 1 -command {#}]
- http::wait $token
- http::status $token
-} {timeout}
-
-test http-5.1 {http::formatQuery} {
- http::formatQuery name1 value1 name2 "value two"
-} {name1=value1&name2=value+two}
-
-test http-5.2 {http::formatQuery} {
- http::formatQuery name1 ~bwelch name2 \xa1\xa2\xa2
-} {name1=%7ebwelch&name2=%a1%a2%a2}
-
-test http-5.3 {http::formatQuery} {
- http::formatQuery lines "line1\nline2\nline3"
-} {lines=line1%0d%0aline2%0d%0aline3}
-
-test http-6.1 {http::ProxyRequired} {
- http::config -proxyhost [info hostname] -proxyport $port
- set token [http::geturl $url]
- http::wait $token
- http::config -proxyhost {} -proxyport {}
- upvar #0 $token data
- set data(body)
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>GET http://$url</h2>
-</body></html>"
-
-# cleanup
-unset url
-unset port
-if {[info exists httpthread]} {
- testthread send -async $httpthread {
- testthread exit
- }
-} else {
- close $listen
-}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/httpd b/tests/httpd
deleted file mode 100644
index 1531964..0000000
--- a/tests/httpd
+++ /dev/null
@@ -1,148 +0,0 @@
-#
-# The httpd_ procedures implement a stub http server.
-#
-# Copyright (c) 1997-1998 Sun Microsystems, Inc.
-#
-# See the file "license.terms" for information on usage and redistribution
-# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-#
-# SCCS: @(#) httpd 1.2 98/02/20 14:51:59
-
-proc httpd_init {{port 8015}} {
- socket -server httpdAccept $port
-}
-proc httpd_log {args} {
- global httpLog
- if {[info exists httpLog] && $httpLog} {
- puts stderr "httpd: [join $args { }]"
- }
-}
-array set httpdErrors {
- 204 {No Content}
- 400 {Bad Request}
- 404 {Not Found}
- 503 {Service Unavailable}
- 504 {Service Temporarily Unavailable}
- }
-
-proc httpdError {sock code args} {
- global httpdErrors
- puts $sock "$code $httpdErrors($code)"
- httpd_log "error: [join $args { }]"
-}
-proc httpdAccept {newsock ipaddr port} {
- global httpd
- upvar #0 httpd$newsock data
-
- fconfigure $newsock -blocking 0 -translation {auto crlf}
- httpd_log $newsock Connect $ipaddr $port
- set data(ipaddr) $ipaddr
- fileevent $newsock readable [list httpdRead $newsock]
-}
-
-# read data from a client request
-
-proc httpdRead { sock } {
- upvar #0 httpd$sock data
-
- set readCount [gets $sock line]
- if {![info exists data(state)]} {
- if [regexp {(POST|GET|HEAD) ([^?]+)\??([^ ]*) HTTP/1.0} \
- $line x data(proto) data(url) data(query)] {
- set data(state) mime
- httpd_log $sock Query $line
- } else {
- httpdError $sock 400
- httpd_log $sock Error "bad first line:$line"
- httpdSockDone $sock
- }
- return
- }
-
- # string compare $readCount 0 maps -1 to -1, 0 to 0, and > 0 to 1
-
- set state [string compare $readCount 0],$data(state),$data(proto)
- httpd_log $sock $state
- switch -- $state {
- -1,mime,HEAD -
- -1,mime,GET -
- -1,mime,POST {
- # gets would block
- return
- }
- 0,mime,HEAD -
- 0,mime,GET -
- 0,query,POST { httpdRespond $sock }
- 0,mime,POST { set data(state) query }
- 1,mime,HEAD -
- 1,mime,POST -
- 1,mime,GET {
- if [regexp {([^:]+):[ ]*(.*)} $line dummy key value] {
- set data(mime,[string tolower $key]) $value
- }
- }
- 1,query,POST {
- append data(query) $line
- httpdRespond $sock
- }
- default {
- if [eof $sock] {
- httpd_log $sock Error "unexpected eof on <$data(url)> request"
- } else {
- httpd_log $sock Error "unhandled state <$state> fetching <$data(url)>"
- }
- httpdError $sock 404
- httpdSockDone $sock
- }
- }
-}
-proc httpdSockDone { sock } {
-upvar #0 httpd$sock data
- unset data
- close $sock
-}
-
-# Respond to the query.
-
-proc httpdRespond { sock } {
- global httpd bindata port
- upvar #0 httpd$sock data
-
- if {[string match *binary* $data(url)]} {
- set html "$bindata[info hostname]:$port$data(url)"
- set type application/octet-stream
- } else {
- set type text/html
-
- set html "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>$data(proto) $data(url)</h2>
-"
- if {[info exists data(query)] && [string length $data(query)]} {
- append html "<h2>Query</h2>\n<dl>\n"
- foreach {key value} [split $data(query) &=] {
- append html "<dt>$key<dd>$value\n"
- }
- append html </dl>\n
- }
- append html </body></html>
- }
-
- if {$data(proto) == "HEAD"} {
- puts $sock "HTTP/1.0 200 OK"
- } else {
- puts $sock "HTTP/1.0 200 Data follows"
- }
- puts $sock "Date: [clock format [clock clicks]]"
- puts $sock "Content-Type: $type"
- puts $sock "Content-Length: [string length $html]"
- puts $sock ""
- if {$data(proto) != "HEAD"} {
- fconfigure $sock -translation binary
- puts -nonewline $sock $html
- }
- httpd_log $sock Done ""
- httpdSockDone $sock
-}
-
-
diff --git a/tests/httpold.test b/tests/httpold.test
deleted file mode 100644
index 5d874f6..0000000
--- a/tests/httpold.test
+++ /dev/null
@@ -1,441 +0,0 @@
-# Commands covered: http_config, http_get, http_wait, http_reset
-#
-# This file contains a collection of tests for the http script library.
-# Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-#
-# Copyright (c) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-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: httpold.test,v 1.3 1999/04/16 00:47:28 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[catch {package require http 1.0}]} {
- if {[info exist httpold]} {
- catch {puts "Cannot load http 1.0 package"}
- ::tcltest::cleanupTests
- return
- } else {
- catch {puts "Running http 1.0 tests in slave interp"}
- set interp [interp create httpold]
- $interp eval [list set httpold "running"]
- $interp eval [list source [info script]]
- interp delete $interp
- ::tcltest::cleanupTests
- return
- }
-}
-
-############### The httpd_ procedures implement a stub http server. ########
-proc httpd_init {{port 8015}} {
- socket -server httpdAccept $port
-}
-proc httpd_log {args} {
- global httpLog
- if {[info exists httpLog] && $httpLog} {
- puts "httpd: [join $args { }]"
- }
-}
-array set httpdErrors {
- 204 {No Content}
- 400 {Bad Request}
- 404 {Not Found}
- 503 {Service Unavailable}
- 504 {Service Temporarily Unavailable}
- }
-
-proc httpdError {sock code args} {
- global httpdErrors
- puts $sock "$code $httpdErrors($code)"
- httpd_log "error: [join $args { }]"
-}
-proc httpdAccept {newsock ipaddr port} {
- global httpd
- upvar #0 httpd$newsock data
-
- fconfigure $newsock -blocking 0 -translation {auto crlf}
- httpd_log $newsock Connect $ipaddr $port
- set data(ipaddr) $ipaddr
- fileevent $newsock readable [list httpdRead $newsock]
-}
-
-# read data from a client request
-
-proc httpdRead { sock } {
- upvar #0 httpd$sock data
-
- set readCount [gets $sock line]
- if {![info exists data(state)]} {
- if [regexp {(POST|GET|HEAD) ([^?]+)\??([^ ]*) HTTP/1.0} \
- $line x data(proto) data(url) data(query)] {
- set data(state) mime
- httpd_log $sock Query $line
- } else {
- httpdError $sock 400
- httpd_log $sock Error "bad first line:$line"
- httpdSockDone $sock
- }
- return
- }
-
- # string compare $readCount 0 maps -1 to -1, 0 to 0, and > 0 to 1
-
- set state [string compare $readCount 0],$data(state),$data(proto)
- httpd_log $sock $state
- switch -- $state {
- -1,mime,HEAD -
- -1,mime,GET -
- -1,mime,POST {
- # gets would block
- return
- }
- 0,mime,HEAD -
- 0,mime,GET -
- 0,query,POST { httpdRespond $sock }
- 0,mime,POST { set data(state) query }
- 1,mime,HEAD -
- 1,mime,POST -
- 1,mime,GET {
- if [regexp {([^:]+):[ ]*(.*)} $line dummy key value] {
- set data(mime,[string tolower $key]) $value
- }
- }
- 1,query,POST {
- append data(query) $line
- httpdRespond $sock
- }
- default {
- if [eof $sock] {
- httpd_log $sock Error "unexpected eof on <$data(url)> request"
- } else {
- httpd_log $sock Error "unhandled state <$state> fetching <$data(url)>"
- }
- httpdError $sock 404
- httpdSockDone $sock
- }
- }
-}
-proc httpdSockDone { sock } {
-upvar #0 httpd$sock data
- unset data
- catch {close $sock}
-}
-
-# Respond to the query.
-
-set bindata "This is binary data\x0d\x0amore\x0dmore\x0amore\x00null"
-proc httpdRespond { sock } {
- global httpd bindata port
- upvar #0 httpd$sock data
-
- if {[string match *binary* $data(url)]} {
- set html "$bindata[info hostname]:$port$data(url)"
- set type application/octet-stream
- } else {
- set type text/html
-
- set html "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>$data(proto) $data(url)</h2>
-"
- if {[info exists data(query)] && [string length $data(query)]} {
- append html "<h2>Query</h2>\n<dl>\n"
- foreach {key value} [split $data(query) &=] {
- append html "<dt>$key<dd>$value\n"
- if {[string compare $key timeout] == 0} {
- # Simulate a timeout by not responding,
- # but clean up our socket later.
-
- after 50 [list httpdSockDone $sock]
- httpd_log $sock Noresponse ""
- return
- }
- }
- append html </dl>\n
- }
- append html </body></html>
- }
-
- if {$data(proto) == "HEAD"} {
- puts $sock "HTTP/1.0 200 OK"
- } else {
- puts $sock "HTTP/1.0 200 Data follows"
- }
- puts $sock "Date: [clock format [clock clicks]]"
- puts $sock "Content-Type: $type"
- puts $sock "Content-Length: [string length $html]"
- puts $sock ""
- if {$data(proto) != "HEAD"} {
- fconfigure $sock -translation binary
- puts -nonewline $sock $html
- }
- httpd_log $sock Done ""
- httpdSockDone $sock
-}
-##################### end server ###########################
-
-set port 8010
-if [catch {httpd_init $port} listen] {
- puts "Cannot start http server, http test skipped"
- unset port
- ::tcltest::cleanupTests
- return
-}
-
-test http-1.1 {http_config} {
- http_config
-} {-accept */* -proxyfilter httpProxyRequired -proxyhost {} -proxyport {} -useragent {Tcl http client package 1.0}}
-
-test http-1.2 {http_config} {
- http_config -proxyfilter
-} httpProxyRequired
-
-test http-1.3 {http_config} {
- catch {http_config -junk}
-} 1
-
-test http-1.4 {http_config} {
- http_config -proxyhost nowhere.come -proxyport 8080 -proxyfilter myFilter -useragent "Tcl Test Suite"
- set x [http_config]
- http_config -proxyhost {} -proxyport {} -proxyfilter httpProxyRequired \
- -useragent "Tcl http client package 1.0"
- set x
-} {-accept */* -proxyfilter myFilter -proxyhost nowhere.come -proxyport 8080 -useragent {Tcl Test Suite}}
-
-test http-1.5 {http_config} {
- catch {http_config -proxyhost {} -junk 8080}
-} 1
-
-test http-2.1 {http_reset} {
- catch {http_reset http#1}
-} 0
-
-test http-3.1 {http_get} {
- catch {http_get -bogus flag}
-} 1
-test http-3.2 {http_get} {
- catch {http_get http:junk} err
- set err
-} {Unsupported URL: http:junk}
-
-set url [info hostname]:$port
-test http-3.3 {http_get} {
- set token [http_get $url]
- http_data $token
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>GET /</h2>
-</body></html>"
-
-set tail /a/b/c
-set url [info hostname]:$port/a/b/c
-set binurl [info hostname]:$port/binary
-
-test http-3.4 {http_get} {
- set token [http_get $url]
- http_data $token
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>GET $tail</h2>
-</body></html>"
-
-proc selfproxy {host} {
- global port
- return [list [info hostname] $port]
-}
-test http-3.5 {http_get} {
- http_config -proxyfilter selfproxy
- set token [http_get $url]
- http_config -proxyfilter httpProxyRequired
- http_data $token
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>GET http://$url</h2>
-</body></html>"
-
-test http-3.6 {http_get} {
- http_config -proxyfilter bogus
- set token [http_get $url]
- http_config -proxyfilter httpProxyRequired
- http_data $token
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>GET $tail</h2>
-</body></html>"
-
-test http-3.7 {http_get} {
- set token [http_get $url -headers {Pragma no-cache}]
- http_data $token
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>GET $tail</h2>
-</body></html>"
-
-test http-3.8 {http_get} {
- set token [http_get $url -query Name=Value&Foo=Bar]
- http_data $token
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>POST $tail</h2>
-<h2>Query</h2>
-<dl>
-<dt>Name<dd>Value
-<dt>Foo<dd>Bar
-</dl>
-</body></html>"
-
-test http-3.9 {http_get} {
- set token [http_get $url -validate 1]
- http_code $token
-} "HTTP/1.0 200 OK"
-
-
-test http-4.1 {httpEvent} {
- set token [http_get $url]
- upvar #0 $token data
- array set meta $data(meta)
- expr ($data(totalsize) == $meta(Content-Length))
-} 1
-
-test http-4.2 {httpEvent} {
- set token [http_get $url]
- upvar #0 $token data
- array set meta $data(meta)
- string compare $data(type) [string trim $meta(Content-Type)]
-} 0
-
-test http-4.3 {httpEvent} {
- set token [http_get $url]
- http_code $token
-} {HTTP/1.0 200 Data follows}
-
-test http-4.4 {httpEvent} {
- set out [open testfile w]
- set token [http_get $url -channel $out]
- close $out
- set in [open testfile]
- set x [read $in]
- close $in
- file delete testfile
- set x
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>GET $tail</h2>
-</body></html>"
-
-test http-4.5 {httpEvent} {
- set out [open testfile w]
- set token [http_get $url -channel $out]
- close $out
- upvar #0 $token data
- file delete testfile
- expr $data(currentsize) == $data(totalsize)
-} 1
-
-test http-4.6 {httpEvent} {
- set out [open testfile w]
- set token [http_get $binurl -channel $out]
- close $out
- set in [open testfile]
- fconfigure $in -translation binary
- set x [read $in]
- close $in
- file delete testfile
- set x
-} "$bindata$binurl"
-
-proc myProgress {token total current} {
- global progress httpLog
- if {[info exists httpLog] && $httpLog} {
- puts "progress $total $current"
- }
- set progress [list $total $current]
-}
-if 0 {
- # This test hangs on Windows95 because the client never gets EOF
- set httpLog 1
- test http-4.6 {httpEvent} {
- set token [http_get $url -blocksize 50 -progress myProgress]
- set progress
- } {111 111}
-}
-test http-4.7 {httpEvent} {
- set token [http_get $url -progress myProgress]
- set progress
-} {111 111}
-test http-4.8 {httpEvent} {
- set token [http_get $url]
- http_status $token
-} {ok}
-test http-4.9 {httpEvent} {
- set token [http_get $url -progress myProgress]
- http_code $token
-} {HTTP/1.0 200 Data follows}
-test http-4.10 {httpEvent} {
- set token [http_get $url -progress myProgress]
- http_size $token
-} {111}
-test http-4.11 {httpEvent} {
- set token [http_get $url -timeout 1 -command {#}]
- http_reset $token
- http_status $token
-} {reset}
-test http-4.12 {httpEvent} {
- update
- set x {}
- after 500 {lappend x ok}
- set token [http_get $url -timeout 1 -command {lappend x fail}]
- vwait x
- list [http_status $token] $x
-} {timeout ok}
-
-test http-5.1 {http_formatQuery} {
- http_formatQuery name1 value1 name2 "value two"
-} {name1=value1&name2=value+two}
-
-test http-5.2 {http_formatQuery} {
- http_formatQuery name1 ~bwelch name2 \xa1\xa2\xa2
-} {name1=%7ebwelch&name2=%a1%a2%a2}
-
-test http-5.3 {http_formatQuery} {
- http_formatQuery lines "line1\nline2\nline3"
-} {lines=line1%0d%0aline2%0d%0aline3}
-
-test http-6.1 {httpProxyRequired} {
- update
- http_config -proxyhost [info hostname] -proxyport $port
- set token [http_get $url]
- http_wait $token
- http_config -proxyhost {} -proxyport {}
- upvar #0 $token data
- set data(body)
-} "<html><head><title>HTTP/1.0 TEST</title></head><body>
-<h1>Hello, World!</h1>
-<h2>GET http://$url</h2>
-</body></html>"
-
-# cleanup
-unset url
-unset port
-close $listen
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/if-old.test b/tests/if-old.test
deleted file mode 100644
index d21b568..0000000
--- a/tests/if-old.test
+++ /dev/null
@@ -1,175 +0,0 @@
-# Commands covered: if
-#
-# This file contains the original set of tests for Tcl's if command.
-# Since the if command is now compiled, a new set of tests covering
-# the new implementation is in the file "if.test". Sourcing this file
-# into Tcl runs the tests and generates output for errors.
-# No output means no errors were found.
-#
-# Copyright (c) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-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-old.test,v 1.3 1999/04/16 00:47:28 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test if-old-1.1 {taking proper branch} {
- set a {}
- if 0 {set a 1} else {set a 2}
- set a
-} 2
-test if-old-1.2 {taking proper branch} {
- set a {}
- if 1 {set a 1} else {set a 2}
- set a
-} 1
-test if-old-1.3 {taking proper branch} {
- set a {}
- if 1<2 {set a 1}
- set a
-} 1
-test if-old-1.4 {taking proper branch} {
- set a {}
- if 1>2 {set a 1}
- set a
-} {}
-test if-old-1.5 {taking proper branch} {
- set a {}
- if 0 {set a 1} else {}
- set a
-} {}
-test if-old-1.5 {taking proper branch} {
- set a {}
- if 0 {set a 1} elseif 1 {set a 2} elseif 1 {set a 3} else {set a 4}
- set a
-} {2}
-test if-old-1.6 {taking proper branch} {
- set a {}
- if 0 {set a 1} elseif 0 {set a 2} elseif 1 {set a 3} else {set a 4}
- set a
-} {3}
-test if-old-1.7 {taking proper branch} {
- set a {}
- if 0 {set a 1} elseif 0 {set a 2} elseif 0 {set a 3} else {set a 4}
- set a
-} {4}
-test if-old-1.8 {taking proper branch, multiline test expr} {
- set a {}
- if {($tcl_platform(platform) != "foobar1") && \
- ($tcl_platform(platform) != "foobar2")} {set a 3} else {set a 4}
- set a
-} {3}
-
-
-test if-old-2.1 {optional then-else args} {
- set a 44
- if 0 then {set a 1} elseif 0 then {set a 3} else {set a 2}
- set a
-} 2
-test if-old-2.2 {optional then-else args} {
- set a 44
- if 1 then {set a 1} else {set a 2}
- set a
-} 1
-test if-old-2.3 {optional then-else args} {
- set a 44
- if 0 {set a 1} else {set a 2}
- set a
-} 2
-test if-old-2.4 {optional then-else args} {
- set a 44
- if 1 {set a 1} else {set a 2}
- set a
-} 1
-test if-old-2.5 {optional then-else args} {
- set a 44
- if 0 then {set a 1} {set a 2}
- set a
-} 2
-test if-old-2.6 {optional then-else args} {
- set a 44
- if 1 then {set a 1} {set a 2}
- set a
-} 1
-test if-old-2.7 {optional then-else args} {
- set a 44
- if 0 then {set a 1} else {set a 2}
- set a
-} 2
-test if-old-2.8 {optional then-else args} {
- set a 44
- if 0 then {set a 1} elseif 0 {set a 2} elseif 0 {set a 3} {set a 4}
- set a
-} 4
-
-test if-old-3.1 {return value} {
- if 1 then {set a 22; concat abc}
-} abc
-test if-old-3.2 {return value} {
- if 0 then {set a 22; concat abc} elseif 1 {concat def} {concat ghi}
-} def
-test if-old-3.3 {return value} {
- if 0 then {set a 22; concat abc} else {concat def}
-} def
-test if-old-3.4 {return value} {
- if 0 then {set a 22; concat abc}
-} {}
-test if-old-3.5 {return value} {
- if 0 then {set a 22; concat abc} elseif 0 {concat def}
-} {}
-
-test if-old-4.1 {error conditions} {
- list [catch {if} msg] $msg
-} {1 {wrong # args: no expression after "if" argument}}
-test if-old-4.2 {error conditions} {
- list [catch {if {[error "error in condition"]} foo} msg] $msg
-} {1 {error in condition}}
-test if-old-4.3 {error conditions} {
- list [catch {if 2} msg] $msg
-} {1 {wrong # args: no script following "2" argument}}
-test if-old-4.4 {error conditions} {
- list [catch {if 2 then} msg] $msg
-} {1 {wrong # args: no script following "then" argument}}
-test if-old-4.5 {error conditions} {
- list [catch {if 2 the} msg] $msg
-} {1 {invalid command name "the"}}
-test if-old-4.6 {error conditions} {
- list [catch {if 2 then {[error "error in then clause"]}} msg] $msg
-} {1 {error in then clause}}
-test if-old-4.7 {error conditions} {
- list [catch {if 0 then foo elseif} msg] $msg
-} {1 {wrong # args: no expression after "elseif" argument}}
-test if-old-4.8 {error conditions} {
- list [catch {if 0 then foo elsei} msg] $msg
-} {1 {invalid command name "elsei"}}
-test if-old-4.9 {error conditions} {
- list [catch {if 0 then foo elseif 0 bar else} msg] $msg
-} {1 {wrong # args: no script following "else" argument}}
-test if-old-4.10 {error conditions} {
- list [catch {if 0 then foo elseif 0 bar els} msg] $msg
-} {1 {invalid command name "els"}}
-test if-old-4.11 {error conditions} {
- list [catch {if 0 then foo elseif 0 bar else {[error "error in else clause"]}} msg] $msg
-} {1 {error in else clause}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/if.test b/tests/if.test
deleted file mode 100644
index 99e7c37..0000000
--- a/tests/if.test
+++ /dev/null
@@ -1,1091 +0,0 @@
-# Commands covered: if
-#
-# 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) 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.test,v 1.3 1999/04/16 00:47:28 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Basic "if" operation.
-
-catch {unset a}
-test if-1.1 {TclCompileIfCmd: missing if/elseif test} {
- list [catch {if} msg] $msg
-} {1 {wrong # args: no expression after "if" argument}}
-test if-1.2 {TclCompileIfCmd: error in if/elseif test} {
- list [catch {if {[error "error in condition"]} foo} msg] $msg
-} {1 {error in condition}}
-test if-1.3 {TclCompileIfCmd: error in if/elseif test} {
- list [catch {if {1+}} msg] $msg $errorInfo
-} {1 {syntax error in expression "1+"} {syntax error in expression "1+"
- ("if" test expression)
- while compiling
-"if {1+}"}}
-test if-1.4 {TclCompileIfCmd: if/elseif test in braces} {
- set a {}
- if {1<2} {set a 1}
- set a
-} {1}
-test if-1.5 {TclCompileIfCmd: if/elseif test not in braces} {
- set a {}
- if 1<2 {set a 1}
- set a
-} {1}
-test if-1.6 {TclCompileIfCmd: multiline test expr} {
- set a {}
- if {($tcl_platform(platform) != "foobar1") && \
- ($tcl_platform(platform) != "foobar2")} {set a 3} else {set a 4}
- set a
-} 3
-test if-1.7 {TclCompileIfCmd: "then" after if/elseif test} {
- set a {}
- if 4>3 then {set a 1}
- set a
-} {1}
-test if-1.8 {TclCompileIfCmd: keyword other than "then" after if/elseif test} {
- set a {}
- catch {if 1<2 therefore {set a 1}} msg
- set msg
-} {invalid command name "therefore"}
-test if-1.9 {TclCompileIfCmd: missing "then" body} {
- set a {}
- catch {if 1<2 then} msg
- set msg
-} {wrong # args: no script following "then" argument}
-test if-1.10 {TclCompileIfCmd: error in "then" body} {
- set a {}
- list [catch {if {$a!="xxx"} then {set}} msg] $msg $errorInfo
-} {1 {wrong # args: should be "set varName ?newValue?"} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- ("if" then script line 1)
- while compiling
-"if {$a!="xxx"} then {set}"}}
-test if-1.11 {TclCompileIfCmd: error in "then" body} {
- list [catch {if 2 then {[error "error in then clause"]}} msg] $msg
-} {1 {error in then clause}}
-test if-1.12 {TclCompileIfCmd: "then" body in quotes} {
- set a {}
- if 27>17 "append a x"
- set a
-} {x}
-test if-1.13 {TclCompileIfCmd: computed "then" body} {
- catch {unset x1}
- catch {unset x2}
- set a {}
- set x1 {append a x1}
- set x2 {; append a x2}
- set a {}
- if 1 $x1$x2
- set a
-} {x1x2}
-test if-1.14 {TclCompileIfCmd: taking proper branch} {
- set a {}
- if 1<2 {set a 1}
- set a
-} 1
-test if-1.15 {TclCompileIfCmd: taking proper branch} {
- set a {}
- if 1>2 {set a 1}
- set a
-} {}
-test if-1.16 {TclCompileIfCmd: test jumpFalse instruction replacement after long "then" body} {
- catch {unset i}
- set a {}
- if 1<2 {
- set a 1
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 2
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 3
- }
- set a
-} 3
-test if-1.17 {TclCompileIfCmd: if/elseif test in quotes} {
- set a {}
- list [catch {if {"0 < 3"} {set a 1}} msg] $msg
-} {1 {expected boolean value but got "0 < 3"}}
-
-
-test if-2.1 {TclCompileIfCmd: "elseif" after if/elseif test} {
- set a {}
- if 3>4 {set a 1} elseif 1 {set a 2}
- set a
-} {2}
-# Since "else" is optional, the "elwood" below is treated as a command.
-# But then there shouldn't be any additional argument words for the "if".
-test if-2.2 {TclCompileIfCmd: keyword other than "elseif"} {
- set a {}
- catch {if 1<2 {set a 1} elwood {set a 2}} msg
- set msg
-} {wrong # args: extra words after "else" clause in "if" command}
-test if-2.3 {TclCompileIfCmd: missing expression after "elseif"} {
- set a {}
- catch {if 1<2 {set a 1} elseif} msg
- set msg
-} {wrong # args: no expression after "elseif" argument}
-test if-2.4 {TclCompileIfCmd: error in expression after "elseif"} {
- set a {}
- list [catch {if 3>4 {set a 1} elseif {1>}} msg] $msg $errorInfo
-} {1 {syntax error in expression "1>"} {syntax error in expression "1>"
- ("if" test expression)
- while compiling
-"if 3>4 {set a 1} elseif {1>}"}}
-test if-2.5 {TclCompileIfCmd: test jumpFalse instruction replacement after long "elseif" body} {
- catch {unset i}
- set a {}
- if 1>2 {
- set a 1
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 2
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 3
- } elseif 1<2 then { #; this if arm should be taken
- set a 4
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 5
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 6
- }
- set a
-} 6
-
-test if-3.1 {TclCompileIfCmd: "else" clause} {
- set a {}
- if 3>4 {set a 1} elseif {$a == "foo"} {set a 2} else {set a 3}
- set a
-} 3
-# Since "else" is optional, the "elsex" below is treated as a command.
-# But then there shouldn't be any additional argument words for the "if".
-test if-3.2 {TclCompileIfCmd: keyword other than "else"} {
- set a {}
- catch {if 1<2 then {set a 1} elsex {set a 2}} msg
- set msg
-} {wrong # args: extra words after "else" clause in "if" command}
-test if-3.3 {TclCompileIfCmd: missing body after "else"} {
- set a {}
- catch {if 2<1 {set a 1} else} msg
- set msg
-} {wrong # args: no script following "else" argument}
-test if-3.4 {TclCompileIfCmd: error compiling body after "else"} {
- set a {}
- catch {if 2<1 {set a 1} else {set}} msg
- set errorInfo
-} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- ("if" else script line 1)
- while compiling
-"if 2<1 {set a 1} else {set}"}
-test if-3.5 {TclCompileIfCmd: extra arguments after "else" argument} {
- set a {}
- catch {if 2<1 {set a 1} else {set a 2} or something} msg
- set msg
-} {wrong # args: extra words after "else" clause in "if" command}
-# The following test also checks whether contained loops and other
-# commands are properly relocated because a short jump must be replaced
-# by a "long distance" one.
-test if-3.6 {TclCompileIfCmd: test jumpFalse instruction replacement after long "else" clause} {
- catch {unset i}
- set a {}
- if 1>2 {
- set a 1
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 2
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 3
- } elseif 1==2 then { #; this if arm should be taken
- set a 4
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 5
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 6
- } else {
- set a 7
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 8
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- if {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 9
- }
- set a
-} 9
-
-test if-4.1 {TclCompileIfCmd: "if" command result} {
- set a {}
- set a [if 3<4 {set i 27}]
- set a
-} 27
-test if-4.2 {TclCompileIfCmd: "if" command result} {
- set a {}
- set a [if 3>4 {set i 27}]
- set a
-} {}
-test if-4.3 {TclCompileIfCmd: "if" command result} {
- set a {}
- set a [if 0 {set i 1} elseif 1 {set i 2}]
- set a
-} 2
-test if-4.4 {TclCompileIfCmd: "if" command result} {
- set a {}
- set a [if 0 {set i 1} elseif 0 {set i 2} elseif 2>5 {set i 3} else {set i 4}]
- set a
-} 4
-test if-4.5 {TclCompileIfCmd: return value} {
- if 0 then {set a 22; concat abc} elseif 1 {concat def} {concat ghi}
-} def
-
-# Check "if" and computed command names.
-
-catch {unset a}
-test if-5.1 {if cmd with computed command names: missing if/elseif test} {
- set z if
- list [catch {$z} msg] $msg
-} {1 {wrong # args: no expression after "if" argument}}
-
-test if-5.2 {if cmd with computed command names: error in if/elseif test} {
- set z if
- list [catch {$z {[error "error in condition"]} foo} msg] $msg
-} {1 {error in condition}}
-test if-5.3 {if cmd with computed command names: error in if/elseif test} {
- set z if
- list [catch {$z {1+}} msg] $msg $errorInfo
-} {1 {syntax error in expression "1+"} {syntax error in expression "1+"
- while executing
-"$z {1+}"}}
-test if-5.4 {if cmd with computed command names: if/elseif test in braces} {
- set z if
- set a {}
- $z {1<2} {set a 1}
- set a
-} {1}
-test if-5.5 {if cmd with computed command names: if/elseif test not in braces} {
- set z if
- set a {}
- $z 1<2 {set a 1}
- set a
-} {1}
-test if-5.6 {if cmd with computed command names: multiline test expr} {
- set z if
- set a {}
- $z {($tcl_platform(platform) != "foobar1") && \
- ($tcl_platform(platform) != "foobar2")} {set a 3} else {set a 4}
- set a
-} 3
-test if-5.7 {if cmd with computed command names: "then" after if/elseif test} {
- set z if
- set a {}
- $z 4>3 then {set a 1}
- set a
-} {1}
-test if-5.8 {if cmd with computed command names: keyword other than "then" after if/elseif test} {
- set z if
- set a {}
- catch {$z 1<2 therefore {set a 1}} msg
- set msg
-} {invalid command name "therefore"}
-test if-5.9 {if cmd with computed command names: missing "then" body} {
- set z if
- set a {}
- catch {$z 1<2 then} msg
- set msg
-} {wrong # args: no script following "then" argument}
-test if-5.10 {if cmd with computed command names: error in "then" body} {
- set z if
- set a {}
- list [catch {$z {$a!="xxx"} then {set}} msg] $msg $errorInfo
-} {1 {wrong # args: should be "set varName ?newValue?"} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- invoked from within
-"$z {$a!="xxx"} then {set}"}}
-test if-5.11 {if cmd with computed command names: error in "then" body} {
- set z if
- list [catch {$z 2 then {[error "error in then clause"]}} msg] $msg
-} {1 {error in then clause}}
-test if-5.12 {if cmd with computed command names: "then" body in quotes} {
- set z if
- set a {}
- $z 27>17 "append a x"
- set a
-} {x}
-test if-5.13 {if cmd with computed command names: computed "then" body} {
- set z if
- catch {unset x1}
- catch {unset x2}
- set a {}
- set x1 {append a x1}
- set x2 {; append a x2}
- set a {}
- $z 1 $x1$x2
- set a
-} {x1x2}
-test if-5.14 {if cmd with computed command names: taking proper branch} {
- set z if
- set a {}
- $z 1<2 {set a 1}
- set a
-} 1
-test if-5.15 {if cmd with computed command names: taking proper branch} {
- set z if
- set a {}
- $z 1>2 {set a 1}
- set a
-} {}
-test if-5.16 {if cmd with computed command names: test jumpFalse instruction replacement after long "then" body} {
- set z if
- catch {unset i}
- set a {}
- $z 1<2 {
- set a 1
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 2
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 3
- }
- set a
-} 3
-test if-5.17 {if cmd with computed command names: if/elseif test in quotes} {
- set z if
- set a {}
- list [catch {$z {"0 < 3"} {set a 1}} msg] $msg
-} {1 {expected boolean value but got "0 < 3"}}
-
-
-test if-6.1 {if cmd with computed command names: "elseif" after if/elseif test} {
- set z if
- set a {}
- $z 3>4 {set a 1} elseif 1 {set a 2}
- set a
-} {2}
-# Since "else" is optional, the "elwood" below is treated as a command.
-# But then there shouldn't be any additional argument words for the "if".
-test if-6.2 {if cmd with computed command names: keyword other than "elseif"} {
- set z if
- set a {}
- catch {$z 1<2 {set a 1} elwood {set a 2}} msg
- set msg
-} {wrong # args: extra words after "else" clause in "if" command}
-test if-6.3 {if cmd with computed command names: missing expression after "elseif"} {
- set z if
- set a {}
- catch {$z 1<2 {set a 1} elseif} msg
- set msg
-} {wrong # args: no expression after "elseif" argument}
-test if-6.4 {if cmd with computed command names: error in expression after "elseif"} {
- set z if
- set a {}
- list [catch {$z 3>4 {set a 1} elseif {1>}} msg] $msg $errorInfo
-} {1 {syntax error in expression "1>"} {syntax error in expression "1>"
- while executing
-"$z 3>4 {set a 1} elseif {1>}"}}
-test if-6.5 {if cmd with computed command names: test jumpFalse instruction replacement after long "elseif" body} {
- set z if
- catch {unset i}
- set a {}
- $z 1>2 {
- set a 1
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 2
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 3
- } elseif 1<2 then { #; this if arm should be taken
- set a 4
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 5
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 6
- }
- set a
-} 6
-
-test if-7.1 {if cmd with computed command names: "else" clause} {
- set z if
- set a {}
- $z 3>4 {set a 1} elseif {$a == "foo"} {set a 2} else {set a 3}
- set a
-} 3
-# Since "else" is optional, the "elsex" below is treated as a command.
-# But then there shouldn't be any additional argument words for the "if".
-test if-7.2 {if cmd with computed command names: keyword other than "else"} {
- set z if
- set a {}
- catch {$z 1<2 then {set a 1} elsex {set a 2}} msg
- set msg
-} {wrong # args: extra words after "else" clause in "if" command}
-test if-7.3 {if cmd with computed command names: missing body after "else"} {
- set z if
- set a {}
- catch {$z 2<1 {set a 1} else} msg
- set msg
-} {wrong # args: no script following "else" argument}
-test if-7.4 {if cmd with computed command names: error compiling body after "else"} {
- set z if
- set a {}
- catch {$z 2<1 {set a 1} else {set}} msg
- set errorInfo
-} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- invoked from within
-"$z 2<1 {set a 1} else {set}"}
-test if-7.5 {if cmd with computed command names: extra arguments after "else" argument} {
- set z if
- set a {}
- catch {$z 2<1 {set a 1} else {set a 2} or something} msg
- set msg
-} {wrong # args: extra words after "else" clause in "if" command}
-# The following test also checks whether contained loops and other
-# commands are properly relocated because a short jump must be replaced
-# by a "long distance" one.
-test if-7.6 {if cmd with computed command names: test jumpFalse instruction replacement after long "else" clause} {
- set z if
- catch {unset i}
- set a {}
- $z 1>2 {
- set a 1
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 2
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 3
- } elseif 1==2 then { #; this if arm should be taken
- set a 4
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 5
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 6
- } else {
- set a 7
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 8
- while {$a != "xxx"} {
- break;
- while {$i >= 0} {
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- $z {[string compare $a "bar"] < 0} {
- set i $i
- set i [lindex $s $i]
- }
- set i [expr $i-1]
- }
- }
- set a 9
- }
- set a
-} 9
-
-test if-8.1 {if cmd with computed command names: "if" command result} {
- set z if
- set a {}
- set a [$z 3<4 {set i 27}]
- set a
-} 27
-test if-8.2 {if cmd with computed command names: "if" command result} {
- set z if
- set a {}
- set a [$z 3>4 {set i 27}]
- set a
-} {}
-test if-8.3 {if cmd with computed command names: "if" command result} {
- set z if
- set a {}
- set a [$z 0 {set i 1} elseif 1 {set i 2}]
- set a
-} 2
-test if-8.4 {if cmd with computed command names: "if" command result} {
- set z if
- set a {}
- set a [$z 0 {set i 1} elseif 0 {set i 2} elseif 2>5 {set i 3} else {set i 4}]
- set a
-} 4
-test if-8.5 {if cmd with computed command names: return value} {
- set z if
- $z 0 then {set a 22; concat abc} elseif 1 {concat def} {concat ghi}
-} def
-
-test if-9.1 {if cmd with namespace qualifiers} {
- ::if {1} {set x 4}
-} 4
-
-# Test for incorrect "double evaluation semantics"
-
-test if-10.1 {delayed substitution of then body} {knownBug} {
- set j 0
- if {[incr j] == 1} "
- set result $j
- "
- set result
-} {0}
-test if-10.2 {delayed substitution of elseif expression} {knownBug} {
- set j 0
- if {[incr j] == 0} {
- set result badthen
- } elseif "$j == 1" {
- set result badelseif
- } else {
- set result ok
- }
- set result
-} {ok}
-test if-10.3 {delayed substitution of elseif body} {knownBug} {
- set j 0
- if {[incr j] == 0} {
- set result badthen
- } elseif {1} "
- set result $j
- "
- set result
-} {0}
-test if-10.4 {delayed substitution of else body} {knownBug} {
- set j 0
- if {[incr j] == 0} {
- set result badthen
- } else "
- set result $j
- "
- set result
-} {0}
-test if-10.5 {substituted control words} {knownBug} {
- set then then; proc then {} {return badthen}
- set else else; proc else {} {return badelse}
- set elseif elseif; proc elseif {} {return badelseif}
- list [catch {if 1 $then {if 0 {} $elseif 1 {if 0 {} $else {list ok}}}} a] $a
-} {0 ok}
-test if-10.6 {double invocation of variable traces} {knownBug} {
- set iftracecounter 0
- proc iftraceproc {args} {
- upvar #0 iftracecounter counter
- set argc [llength $args]
- set extraargs [lrange $args 0 [expr {$argc - 4}]]
- set name [lindex $args [expr {$argc - 3}]]
- upvar 1 $name var
- if {[incr counter] % 2 == 1} {
- set var "$counter oops [concat $extraargs]"
- } else {
- set var "$counter + [concat $extraargs]"
- }
- }
- trace variable iftracevar r [list iftraceproc 10]
- list [catch {if "$iftracevar + 20" {}} a] $a \
- [catch {if "$iftracevar + 20" {}} b] $b \
- [unset iftracevar iftracecounter]
-} {1 {syntax error in expression "1 oops 10 + 20"} 0 {} {}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/incr-old.test b/tests/incr-old.test
deleted file mode 100644
index 64b2012..0000000
--- a/tests/incr-old.test
+++ /dev/null
@@ -1,106 +0,0 @@
-# Commands covered: incr
-#
-# This file contains the original set of tests for Tcl's incr command.
-# Since the incr command is now compiled, a new set of tests covering
-# the new implementation is in the file "incr.test". Sourcing this file
-# into Tcl runs the tests and generates output for errors.
-# No output means no errors were found.
-#
-# Copyright (c) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-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: incr-old.test,v 1.3 1999/04/16 00:47:28 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-catch {unset x}
-
-test incr-old-1.1 {basic incr operation} {
- set x 23
- list [incr x] $x
-} {24 24}
-test incr-old-1.2 {basic incr operation} {
- set x 106
- list [incr x -5] $x
-} {101 101}
-test incr-old-1.3 {basic incr operation} {
- set x " -106"
- list [incr x 1] $x
-} {-105 -105}
-test incr-old-1.3 {basic incr operation} {
- set x " +106"
- list [incr x 1] $x
-} {107 107}
-
-test incr-old-2.1 {incr errors} {
- list [catch incr msg] $msg
-} {1 {wrong # args: should be "incr varName ?increment?"}}
-test incr-old-2.2 {incr errors} {
- list [catch {incr a b c} msg] $msg
-} {1 {wrong # args: should be "incr varName ?increment?"}}
-test incr-old-2.3 {incr errors} {
- catch {unset x}
- list [catch {incr x} msg] $msg $errorInfo
-} {1 {can't read "x": no such variable} {can't read "x": no such variable
- (reading value of variable to increment)
- invoked from within
-"incr x"}}
-test incr-old-2.4 {incr errors} {
- set x abc
- list [catch {incr x} msg] $msg $errorInfo
-} {1 {expected integer but got "abc"} {expected integer but got "abc"
- while executing
-"incr x"}}
-test incr-old-2.5 {incr errors} {
- set x 123
- list [catch {incr x 1a} msg] $msg $errorInfo
-} {1 {expected integer but got "1a"} {expected integer but got "1a"
- while executing
-"incr x 1a"}}
-test incr-old-2.6 {incr errors} {
- proc readonly args {error "variable is read-only"}
- set x 123
- trace var x w readonly
- list [catch {incr x 1} msg] $msg $errorInfo
-} {1 {can't set "x": variable is read-only} {can't set "x": variable is read-only
- while executing
-"incr x 1"}}
-catch {unset x}
-test incr-old-2.7 {incr errors} {
- set x -
- list [catch {incr x 1} msg] $msg
-} {1 {expected integer but got "-"}}
-test incr-old-2.8 {incr errors} {
- set x { - }
- list [catch {incr x 1} msg] $msg
-} {1 {expected integer but got " - "}}
-test incr-old-2.9 {incr errors} {
- set x +
- list [catch {incr x 1} msg] $msg
-} {1 {expected integer but got "+"}}
-test incr-old-2.10 {incr errors} {
- set x {20 x}
- list [catch {incr x 1} msg] $msg
-} {1 {expected integer but got "20 x"}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/incr.test b/tests/incr.test
deleted file mode 100644
index 02ccf37..0000000
--- a/tests/incr.test
+++ /dev/null
@@ -1,513 +0,0 @@
-# Commands covered: incr
-#
-# 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) 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: incr.test,v 1.3 1999/04/16 00:47:28 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Basic "incr" operation.
-
-catch {unset x}
-catch {unset i}
-
-test incr-1.1 {TclCompileIncrCmd: missing variable name} {
- list [catch {incr} msg] $msg
-} {1 {wrong # args: should be "incr varName ?increment?"}}
-test incr-1.2 {TclCompileIncrCmd: simple variable name} {
- set i 10
- list [incr i] $i
-} {11 11}
-test incr-1.3 {TclCompileIncrCmd: error compiling variable name} {
- set i 10
- catch {incr "i"xxx} msg
- set msg
-} {extra characters after close-quote}
-test incr-1.4 {TclCompileIncrCmd: simple variable name in quotes} {
- set i 17
- list [incr "i"] $i
-} {18 18}
-test incr-1.5 {TclCompileIncrCmd: simple variable name in braces} {
- catch {unset {a simple var}}
- set {a simple var} 27
- list [incr {a simple var}] ${a simple var}
-} {28 28}
-test incr-1.6 {TclCompileIncrCmd: simple array variable name} {
- catch {unset a}
- set a(foo) 37
- list [incr a(foo)] $a(foo)
-} {38 38}
-test incr-1.7 {TclCompileIncrCmd: non-simple (computed) variable name} {
- set x "i"
- set i 77
- list [incr $x 2] $i
-} {79 79}
-test incr-1.8 {TclCompileIncrCmd: non-simple (computed) variable name} {
- set x "i"
- set i 77
- list [incr [set x] +2] $i
-} {79 79}
-
-test incr-1.9 {TclCompileIncrCmd: increment given} {
- set i 10
- list [incr i +07] $i
-} {17 17}
-test incr-1.10 {TclCompileIncrCmd: no increment given} {
- set i 10
- list [incr i] $i
-} {11 11}
-
-test incr-1.11 {TclCompileIncrCmd: simple global name} {
- proc p {} {
- global i
- set i 54
- incr i
- }
- p
-} {55}
-test incr-1.12 {TclCompileIncrCmd: simple local name} {
- proc p {} {
- set foo 100
- incr foo
- }
- p
-} {101}
-test incr-1.13 {TclCompileIncrCmd: simple but new (unknown) local name} {
- proc p {} {
- incr bar
- }
- catch {p} msg
- set msg
-} {can't read "bar": no such variable}
-test incr-1.14 {TclCompileIncrCmd: simple local name, >255 locals} {
- proc 260locals {} {
- # create 260 locals
- set a0 0; set a1 0; set a2 0; set a3 0; set a4 0
- set a5 0; set a6 0; set a7 0; set a8 0; set a9 0
- set b0 0; set b1 0; set b2 0; set b3 0; set b4 0
- set b5 0; set b6 0; set b7 0; set b8 0; set b9 0
- set c0 0; set c1 0; set c2 0; set c3 0; set c4 0
- set c5 0; set c6 0; set c7 0; set c8 0; set c9 0
- set d0 0; set d1 0; set d2 0; set d3 0; set d4 0
- set d5 0; set d6 0; set d7 0; set d8 0; set d9 0
- set e0 0; set e1 0; set e2 0; set e3 0; set e4 0
- set e5 0; set e6 0; set e7 0; set e8 0; set e9 0
- set f0 0; set f1 0; set f2 0; set f3 0; set f4 0
- set f5 0; set f6 0; set f7 0; set f8 0; set f9 0
- set g0 0; set g1 0; set g2 0; set g3 0; set g4 0
- set g5 0; set g6 0; set g7 0; set g8 0; set g9 0
- set h0 0; set h1 0; set h2 0; set h3 0; set h4 0
- set h5 0; set h6 0; set h7 0; set h8 0; set h9 0
- set i0 0; set i1 0; set i2 0; set i3 0; set i4 0
- set i5 0; set i6 0; set i7 0; set i8 0; set i9 0
- set j0 0; set j1 0; set j2 0; set j3 0; set j4 0
- set j5 0; set j6 0; set j7 0; set j8 0; set j9 0
- set k0 0; set k1 0; set k2 0; set k3 0; set k4 0
- set k5 0; set k6 0; set k7 0; set k8 0; set k9 0
- set l0 0; set l1 0; set l2 0; set l3 0; set l4 0
- set l5 0; set l6 0; set l7 0; set l8 0; set l9 0
- set m0 0; set m1 0; set m2 0; set m3 0; set m4 0
- set m5 0; set m6 0; set m7 0; set m8 0; set m9 0
- set n0 0; set n1 0; set n2 0; set n3 0; set n4 0
- set n5 0; set n6 0; set n7 0; set n8 0; set n9 0
- set o0 0; set o1 0; set o2 0; set o3 0; set o4 0
- set o5 0; set o6 0; set o7 0; set o8 0; set o9 0
- set p0 0; set p1 0; set p2 0; set p3 0; set p4 0
- set p5 0; set p6 0; set p7 0; set p8 0; set p9 0
- set q0 0; set q1 0; set q2 0; set q3 0; set q4 0
- set q5 0; set q6 0; set q7 0; set q8 0; set q9 0
- set r0 0; set r1 0; set r2 0; set r3 0; set r4 0
- set r5 0; set r6 0; set r7 0; set r8 0; set r9 0
- set s0 0; set s1 0; set s2 0; set s3 0; set s4 0
- set s5 0; set s6 0; set s7 0; set s8 0; set s9 0
- set t0 0; set t1 0; set t2 0; set t3 0; set t4 0
- set t5 0; set t6 0; set t7 0; set t8 0; set t9 0
- set u0 0; set u1 0; set u2 0; set u3 0; set u4 0
- set u5 0; set u6 0; set u7 0; set u8 0; set u9 0
- set v0 0; set v1 0; set v2 0; set v3 0; set v4 0
- set v5 0; set v6 0; set v7 0; set v8 0; set v9 0
- set w0 0; set w1 0; set w2 0; set w3 0; set w4 0
- set w5 0; set w6 0; set w7 0; set w8 0; set w9 0
- set x0 0; set x1 0; set x2 0; set x3 0; set x4 0
- set x5 0; set x6 0; set x7 0; set x8 0; set x9 0
- set y0 0; set y1 0; set y2 0; set y3 0; set y4 0
- set y5 0; set y6 0; set y7 0; set y8 0; set y9 0
- set z0 0; set z1 0; set z2 0; set z3 0; set z4 0
- set z5 0; set z6 0; set z7 0; set z8 0; set z9 0
- # now increment the last one (local var index > 255)
- incr z9
- }
- 260locals
-} {1}
-test incr-1.15 {TclCompileIncrCmd: variable is array} {
- catch {unset a}
- set a(foo) 27
- set x [incr a(foo) 11]
- catch {unset a}
- set x
-} 38
-test incr-1.16 {TclCompileIncrCmd: variable is array, elem substitutions} {
- catch {unset a}
- set i 5
- set a(foo5) 27
- set x [incr a(foo$i) 11]
- catch {unset a}
- set x
-} 38
-
-test incr-1.17 {TclCompileIncrCmd: increment given, simple int} {
- set i 5
- incr i 123
-} 128
-test incr-1.18 {TclCompileIncrCmd: increment given, simple int} {
- set i 5
- incr i -100
-} -95
-test incr-1.19 {TclCompileIncrCmd: increment given, but erroneous} {
- set i 5
- catch {incr i [set]} msg
- set errorInfo
-} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- (increment expression)
- while compiling
-"incr i [set]"}
-test incr-1.20 {TclCompileIncrCmd: increment given, in quotes} {
- set i 25
- incr i "-100"
-} -75
-test incr-1.21 {TclCompileIncrCmd: increment given, in braces} {
- set i 24
- incr i {126}
-} 150
-test incr-1.22 {TclCompileIncrCmd: increment given, large int} {
- set i 5
- incr i 200000
-} 200005
-test incr-1.23 {TclCompileIncrCmd: increment given, formatted int != int} {
- set i 25
- incr i 000012345 ;# an octal literal
-} 5374
-test incr-1.24 {TclCompileIncrCmd: increment given, formatted int != int} {
- set i 25
- catch {incr i 1a} msg
- set msg
-} {expected integer but got "1a"}
-
-test incr-1.25 {TclCompileIncrCmd: too many arguments} {
- set i 10
- catch {incr i 10 20} msg
- set msg
-} {wrong # args: should be "incr varName ?increment?"}
-
-
-test incr-1.26 {TclCompileIncrCmd: runtime error, bad variable name} {
- list [catch {incr {"foo}} msg] $msg $errorInfo
-} {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable
- (reading value of variable to increment)
- invoked from within
-"incr {"foo}"}}
-test incr-1.27 {TclCompileIncrCmd: runtime error, bad variable name} {
- list [catch {incr [set]} msg] $msg $errorInfo
-} {1 {wrong # args: should be "set varName ?newValue?"} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- while compiling
-"incr [set]"}}
-test incr-1.28 {TclCompileIncrCmd: runtime error, readonly variable} {
- proc readonly args {error "variable is read-only"}
- set x 123
- trace var x w readonly
- list [catch {incr x 1} msg] $msg $errorInfo
-} {1 {can't set "x": variable is read-only} {can't set "x": variable is read-only
- while executing
-"incr x 1"}}
-catch {unset x}
-test incr-1.29 {TclCompileIncrCmd: runtime error, bad variable value} {
- set x " - "
- list [catch {incr x 1} msg] $msg
-} {1 {expected integer but got " - "}}
-
-# Check "incr" and computed command names.
-
-test incr-2.0 {incr and computed command names} {
- set i 5
- set z incr
- $z i -1
- set i
-} 4
-catch {unset x}
-catch {unset i}
-
-test incr-2.1 {incr command (not compiled): missing variable name} {
- set z incr
- list [catch {$z} msg] $msg
-} {1 {wrong # args: should be "incr varName ?increment?"}}
-test incr-2.2 {incr command (not compiled): simple variable name} {
- set z incr
- set i 10
- list [$z i] $i
-} {11 11}
-test incr-2.3 {incr command (not compiled): error compiling variable name} {
- set z incr
- set i 10
- catch {$z "i"xxx} msg
- set msg
-} {extra characters after close-quote}
-test incr-2.4 {incr command (not compiled): simple variable name in quotes} {
- set z incr
- set i 17
- list [$z "i"] $i
-} {18 18}
-test incr-2.5 {incr command (not compiled): simple variable name in braces} {
- set z incr
- catch {unset {a simple var}}
- set {a simple var} 27
- list [$z {a simple var}] ${a simple var}
-} {28 28}
-test incr-2.6 {incr command (not compiled): simple array variable name} {
- set z incr
- catch {unset a}
- set a(foo) 37
- list [$z a(foo)] $a(foo)
-} {38 38}
-test incr-2.7 {incr command (not compiled): non-simple (computed) variable name} {
- set z incr
- set x "i"
- set i 77
- list [$z $x 2] $i
-} {79 79}
-test incr-2.8 {incr command (not compiled): non-simple (computed) variable name} {
- set z incr
- set x "i"
- set i 77
- list [$z [set x] +2] $i
-} {79 79}
-
-test incr-2.9 {incr command (not compiled): increment given} {
- set z incr
- set i 10
- list [$z i +07] $i
-} {17 17}
-test incr-2.10 {incr command (not compiled): no increment given} {
- set z incr
- set i 10
- list [$z i] $i
-} {11 11}
-
-test incr-2.11 {incr command (not compiled): simple global name} {
- proc p {} {
- set z incr
- global i
- set i 54
- $z i
- }
- p
-} {55}
-test incr-2.12 {incr command (not compiled): simple local name} {
- proc p {} {
- set z incr
- set foo 100
- $z foo
- }
- p
-} {101}
-test incr-2.13 {incr command (not compiled): simple but new (unknown) local name} {
- proc p {} {
- set z incr
- $z bar
- }
- catch {p} msg
- set msg
-} {can't read "bar": no such variable}
-test incr-2.14 {incr command (not compiled): simple local name, >255 locals} {
- proc 260locals {} {
- set z incr
- # create 260 locals
- set a0 0; set a1 0; set a2 0; set a3 0; set a4 0
- set a5 0; set a6 0; set a7 0; set a8 0; set a9 0
- set b0 0; set b1 0; set b2 0; set b3 0; set b4 0
- set b5 0; set b6 0; set b7 0; set b8 0; set b9 0
- set c0 0; set c1 0; set c2 0; set c3 0; set c4 0
- set c5 0; set c6 0; set c7 0; set c8 0; set c9 0
- set d0 0; set d1 0; set d2 0; set d3 0; set d4 0
- set d5 0; set d6 0; set d7 0; set d8 0; set d9 0
- set e0 0; set e1 0; set e2 0; set e3 0; set e4 0
- set e5 0; set e6 0; set e7 0; set e8 0; set e9 0
- set f0 0; set f1 0; set f2 0; set f3 0; set f4 0
- set f5 0; set f6 0; set f7 0; set f8 0; set f9 0
- set g0 0; set g1 0; set g2 0; set g3 0; set g4 0
- set g5 0; set g6 0; set g7 0; set g8 0; set g9 0
- set h0 0; set h1 0; set h2 0; set h3 0; set h4 0
- set h5 0; set h6 0; set h7 0; set h8 0; set h9 0
- set i0 0; set i1 0; set i2 0; set i3 0; set i4 0
- set i5 0; set i6 0; set i7 0; set i8 0; set i9 0
- set j0 0; set j1 0; set j2 0; set j3 0; set j4 0
- set j5 0; set j6 0; set j7 0; set j8 0; set j9 0
- set k0 0; set k1 0; set k2 0; set k3 0; set k4 0
- set k5 0; set k6 0; set k7 0; set k8 0; set k9 0
- set l0 0; set l1 0; set l2 0; set l3 0; set l4 0
- set l5 0; set l6 0; set l7 0; set l8 0; set l9 0
- set m0 0; set m1 0; set m2 0; set m3 0; set m4 0
- set m5 0; set m6 0; set m7 0; set m8 0; set m9 0
- set n0 0; set n1 0; set n2 0; set n3 0; set n4 0
- set n5 0; set n6 0; set n7 0; set n8 0; set n9 0
- set o0 0; set o1 0; set o2 0; set o3 0; set o4 0
- set o5 0; set o6 0; set o7 0; set o8 0; set o9 0
- set p0 0; set p1 0; set p2 0; set p3 0; set p4 0
- set p5 0; set p6 0; set p7 0; set p8 0; set p9 0
- set q0 0; set q1 0; set q2 0; set q3 0; set q4 0
- set q5 0; set q6 0; set q7 0; set q8 0; set q9 0
- set r0 0; set r1 0; set r2 0; set r3 0; set r4 0
- set r5 0; set r6 0; set r7 0; set r8 0; set r9 0
- set s0 0; set s1 0; set s2 0; set s3 0; set s4 0
- set s5 0; set s6 0; set s7 0; set s8 0; set s9 0
- set t0 0; set t1 0; set t2 0; set t3 0; set t4 0
- set t5 0; set t6 0; set t7 0; set t8 0; set t9 0
- set u0 0; set u1 0; set u2 0; set u3 0; set u4 0
- set u5 0; set u6 0; set u7 0; set u8 0; set u9 0
- set v0 0; set v1 0; set v2 0; set v3 0; set v4 0
- set v5 0; set v6 0; set v7 0; set v8 0; set v9 0
- set w0 0; set w1 0; set w2 0; set w3 0; set w4 0
- set w5 0; set w6 0; set w7 0; set w8 0; set w9 0
- set x0 0; set x1 0; set x2 0; set x3 0; set x4 0
- set x5 0; set x6 0; set x7 0; set x8 0; set x9 0
- set y0 0; set y1 0; set y2 0; set y3 0; set y4 0
- set y5 0; set y6 0; set y7 0; set y8 0; set y9 0
- set z0 0; set z1 0; set z2 0; set z3 0; set z4 0
- set z5 0; set z6 0; set z7 0; set z8 0; set z9 0
- # now increment the last one (local var index > 255)
- $z z9
- }
- 260locals
-} {1}
-test incr-2.15 {incr command (not compiled): variable is array} {
- set z incr
- catch {unset a}
- set a(foo) 27
- set x [$z a(foo) 11]
- catch {unset a}
- set x
-} 38
-test incr-2.16 {incr command (not compiled): variable is array, elem substitutions} {
- set z incr
- catch {unset a}
- set i 5
- set a(foo5) 27
- set x [$z a(foo$i) 11]
- catch {unset a}
- set x
-} 38
-
-test incr-2.17 {incr command (not compiled): increment given, simple int} {
- set z incr
- set i 5
- $z i 123
-} 128
-test incr-2.18 {incr command (not compiled): increment given, simple int} {
- set z incr
- set i 5
- $z i -100
-} -95
-test incr-2.19 {incr command (not compiled): increment given, but erroneous} {
- set z incr
- set i 5
- catch {$z i [set]} msg
- set errorInfo
-} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- while compiling
-"$z i [set]"}
-test incr-2.20 {incr command (not compiled): increment given, in quotes} {
- set z incr
- set i 25
- $z i "-100"
-} -75
-test incr-2.21 {incr command (not compiled): increment given, in braces} {
- set z incr
- set i 24
- $z i {126}
-} 150
-test incr-2.22 {incr command (not compiled): increment given, large int} {
- set z incr
- set i 5
- $z i 200000
-} 200005
-test incr-2.23 {incr command (not compiled): increment given, formatted int != int} {
- set z incr
- set i 25
- $z i 000012345 ;# an octal literal
-} 5374
-test incr-2.24 {incr command (not compiled): increment given, formatted int != int} {
- set z incr
- set i 25
- catch {$z i 1a} msg
- set msg
-} {expected integer but got "1a"}
-
-test incr-2.25 {incr command (not compiled): too many arguments} {
- set z incr
- set i 10
- catch {$z i 10 20} msg
- set msg
-} {wrong # args: should be "incr varName ?increment?"}
-
-
-test incr-2.26 {incr command (not compiled): runtime error, bad variable name} {
- set z incr
- list [catch {$z {"foo}} msg] $msg $errorInfo
-} {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable
- (reading value of variable to increment)
- invoked from within
-"$z {"foo}"}}
-test incr-2.27 {incr command (not compiled): runtime error, bad variable name} {
- set z incr
- list [catch {$z [set]} msg] $msg $errorInfo
-} {1 {wrong # args: should be "set varName ?newValue?"} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- while compiling
-"$z [set]"}}
-test incr-2.28 {incr command (not compiled): runtime error, readonly variable} {
- set z incr
- proc readonly args {error "variable is read-only"}
- set x 123
- trace var x w readonly
- list [catch {$z x 1} msg] $msg $errorInfo
-} {1 {can't set "x": variable is read-only} {can't set "x": variable is read-only
- while executing
-"$z x 1"}}
-catch {unset x}
-test incr-2.29 {incr command (not compiled): runtime error, bad variable value} {
- set z incr
- set x " - "
- list [catch {$z x 1} msg] $msg
-} {1 {expected integer but got " - "}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/indexObj.test b/tests/indexObj.test
deleted file mode 100644
index 979e5a8..0000000
--- a/tests/indexObj.test
+++ /dev/null
@@ -1,86 +0,0 @@
-# This file is a Tcl script to test out the the procedures in file
-# tkIndexObj.c, which implement indexed table lookups. The tests here
-# are organized in the standard fashion for Tcl tests.
-#
-# Copyright (c) 1997 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: indexObj.test,v 1.3 1999/04/16 00:47:29 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[info commands testindexobj] == {}} {
- puts "This application hasn't been compiled with the \"testindexobj\""
- puts "command, so I can't test Tcl_GetIndexFromObj etc."
- ::tcltest::cleanupTests
- return
-}
-
-test indexObj-1.1 {exact match} {
- testindexobj 1 1 xyz abc def xyz alm
-} {2}
-test indexObj-1.2 {exact match} {
- testindexobj 1 1 abc abc def xyz alm
-} {0}
-test indexObj-1.3 {exact match} {
- testindexobj 1 1 alm abc def xyz alm
-} {3}
-test indexObj-1.4 {unique abbreviation} {
- testindexobj 1 1 xy abc def xalb xyz alm
-} {3}
-test indexObj-1.5 {multiple abbreviations and exact match} {
- testindexobj 1 1 x abc def xalb xyz alm x
-} {5}
-test indexObj-1.6 {forced exact match} {
- testindexobj 1 0 xy abc def xalb xy alm
-} {3}
-test indexObj-1.7 {forced exact match} {
- testindexobj 1 0 x abc def xalb xyz alm x
-} {5}
-
-test indexObj-2.1 {no match} {
- list [catch {testindexobj 1 1 dddd abc def xalb xyz alm x} msg] $msg
-} {1 {bad token "dddd": must be abc, def, xalb, xyz, alm, or x}}
-test indexObj-2.2 {no match} {
- list [catch {testindexobj 1 1 dddd abc} msg] $msg
-} {1 {bad token "dddd": must be abc}}
-test indexObj-2.3 {no match: no abbreviations} {
- list [catch {testindexobj 1 0 xy abc def xalb xyz alm} msg] $msg
-} {1 {bad token "xy": must be abc, def, xalb, xyz, or alm}}
-test indexObj-2.4 {ambiguous value} {
- list [catch {testindexobj 1 1 d dumb daughter a c} msg] $msg
-} {1 {ambiguous token "d": must be dumb, daughter, a, or c}}
-test indexObj-2.5 {omit error message} {
- list [catch {testindexobj 0 1 d x} msg] $msg
-} {1 {}}
-
-test indexObj-3.1 {cache result to skip next lookup} {
- testindexobj check 42
-} {42}
-
-test indexObj-4.1 {free old internal representation} {
- set x {a b}
- lindex $x 1
- testindexobj 1 1 $x abc def {a b} zzz
-} {2}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/info.test b/tests/info.test
deleted file mode 100644
index 4522520..0000000
--- a/tests/info.test
+++ /dev/null
@@ -1,517 +0,0 @@
-# Commands covered: info
-#
-# 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) 1991-1994 The Regents of the University of California.
-# Copyright (c) 1994-1997 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: info.test,v 1.6 1999/04/16 00:47:29 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Set up namespaces needed to test operation of "info args", "info body",
-# "info default", and "info procs" with imported procedures.
-
-catch {namespace delete test_ns_info1 test_ns_info2}
-
-namespace eval test_ns_info1 {
- namespace export *
- proc p {x} {return "x=$x"}
- proc q {{y 27} z} {return "y=$y"}
-}
-
-
-test info-1.1 {info args option} {
- proc t1 {a bbb c} {return foo}
- info args t1
-} {a bbb c}
-test info-1.2 {info args option} {
- proc t1 {{a default1} {bbb default2} {c default3} args} {return foo}
- info a t1
-} {a bbb c args}
-test info-1.3 {info args option} {
- proc t1 "" {return foo}
- info args t1
-} {}
-test info-1.4 {info args option} {
- catch {rename t1 {}}
- list [catch {info args t1} msg] $msg
-} {1 {"t1" isn't a procedure}}
-test info-1.5 {info args option} {
- list [catch {info args set} msg] $msg
-} {1 {"set" isn't a procedure}}
-test info-1.6 {info args option} {
- proc t1 {a b} {set c 123; set d $c}
- t1 1 2
- info args t1
-} {a b}
-test info-1.7 {info args option} {
- catch {namespace delete test_ns_info2}
- namespace eval test_ns_info2 {
- namespace import ::test_ns_info1::*
- list [info args p] [info args q]
- }
-} {x {y z}}
-
-test info-2.1 {info body option} {
- proc t1 {} {body of t1}
- info body t1
-} {body of t1}
-test info-2.2 {info body option} {
- list [catch {info body set} msg] $msg
-} {1 {"set" isn't a procedure}}
-test info-2.3 {info body option} {
- list [catch {info args set 1} msg] $msg
-} {1 {wrong # args: should be "info args procname"}}
-test info-2.4 {info body option} {
- catch {namespace delete test_ns_info2}
- namespace eval test_ns_info2 {
- namespace import ::test_ns_info1::*
- list [info body p] [info body q]
- }
-} {{return "x=$x"} {return "y=$y"}}
-
-# "info cmdcount" is no longer accurate for compiled commands! The expected
-# result for info-3.1 used to be "3" and is now "1" since the "set"s have
-# been compiled away.
-test info-3.1 {info cmdcount option} {
- set x [info cmdcount]
- set y 12345
- set z [info cm]
- expr $z-$x
-} 1
-test info-3.2 {info cmdcount option} {
- list [catch {info cmdcount 1} msg] $msg
-} {1 {wrong # args: should be "info cmdcount"}}
-
-test info-4.1 {info commands option} {
- proc t1 {} {}
- proc t2 {} {}
- set x " [info commands] "
- list [string match {* t1 *} $x] [string match {* t2 *} $x] \
- [string match {* set *} $x] [string match {* list *} $x]
-} {1 1 1 1}
-test info-4.2 {info commands option} {
- proc t1 {} {}
- rename t1 {}
- set x [info comm]
- string match {* t1 *} $x
-} 0
-test info-4.3 {info commands option} {
- proc _t1_ {} {}
- proc _t2_ {} {}
- info commands _t1_
-} _t1_
-test info-4.4 {info commands option} {
- proc _t1_ {} {}
- proc _t2_ {} {}
- lsort [info commands _t*]
-} {_t1_ _t2_}
-catch {rename _t1_ {}}
-catch {rename _t2_ {}}
-test info-4.5 {info commands option} {
- list [catch {info commands a b} msg] $msg
-} {1 {wrong # args: should be "info commands ?pattern?"}}
-
-test info-5.1 {info complete option} {
- list [catch {info complete} msg] $msg
-} {1 {wrong # args: should be "info complete command"}}
-test info-5.2 {info complete option} {
- info complete abc
-} 1
-test info-5.2 {info complete option} {
- info complete "\{abcd "
-} 0
-test info-5.3 {info complete option} {
- info complete {# Comment should be complete command}
-} 1
-
-test info-6.1 {info default option} {
- proc t1 {a b {c d} {e "long default value"}} {}
- info default t1 a value
-} 0
-test info-6.2 {info default option} {
- proc t1 {a b {c d} {e "long default value"}} {}
- set value 12345
- info d t1 a value
- set value
-} {}
-test info-6.3 {info default option} {
- proc t1 {a b {c d} {e "long default value"}} {}
- info default t1 c value
-} 1
-test info-6.4 {info default option} {
- proc t1 {a b {c d} {e "long default value"}} {}
- set value 12345
- info default t1 c value
- set value
-} d
-test info-6.5 {info default option} {
- proc t1 {a b {c d} {e "long default value"}} {}
- set value 12345
- set x [info default t1 e value]
- list $x $value
-} {1 {long default value}}
-test info-6.6 {info default option} {
- list [catch {info default a b} msg] $msg
-} {1 {wrong # args: should be "info default procname arg varname"}}
-test info-6.7 {info default option} {
- list [catch {info default _nonexistent_ a b} msg] $msg
-} {1 {"_nonexistent_" isn't a procedure}}
-test info-6.8 {info default option} {
- proc t1 {a b} {}
- list [catch {info default t1 x value} msg] $msg
-} {1 {procedure "t1" doesn't have an argument "x"}}
-test info-6.9 {info default option} {
- catch {unset a}
- set a(0) 88
- proc t1 {a b} {}
- list [catch {info default t1 a a} msg] $msg
-} {1 {couldn't store default value in variable "a"}}
-test info-6.10 {info default option} {
- catch {unset a}
- set a(0) 88
- proc t1 {{a 18} b} {}
- list [catch {info default t1 a a} msg] $msg
-} {1 {couldn't store default value in variable "a"}}
-test info-6.11 {info default option} {
- catch {namespace delete test_ns_info2}
- namespace eval test_ns_info2 {
- namespace import ::test_ns_info1::*
- list [info default p x foo] $foo [info default q y bar] $bar
- }
-} {0 {} 1 27}
-catch {unset a}
-
-test info-7.1 {info exists option} {
- set value foo
- info exists value
-} 1
-catch {unset _nonexistent_}
-test info-7.2 {info exists option} {
- info exists _nonexistent_
-} 0
-test info-7.3 {info exists option} {
- proc t1 {x} {return [info exists x]}
- t1 2
-} 1
-test info-7.4 {info exists option} {
- proc t1 {x} {
- global _nonexistent_
- return [info exists _nonexistent_]
- }
- t1 2
-} 0
-test info-7.5 {info exists option} {
- proc t1 {x} {
- set y 47
- return [info exists y]
- }
- t1 2
-} 1
-test info-7.6 {info exists option} {
- proc t1 {x} {return [info exists value]}
- t1 2
-} 0
-test info-7.7 {info exists option} {
- catch {unset x}
- set x(2) 44
- list [info exists x] [info exists x(1)] [info exists x(2)]
-} {1 0 1}
-catch {unset x}
-test info-7.8 {info exists option} {
- list [catch {info exists} msg] $msg
-} {1 {wrong # args: should be "info exists varName"}}
-test info-7.9 {info exists option} {
- list [catch {info exists 1 2} msg] $msg
-} {1 {wrong # args: should be "info exists varName"}}
-
-test info-8.1 {info globals option} {
- set x 1
- set y 2
- set value 23
- set a " [info globals] "
- list [string match {* x *} $a] [string match {* y *} $a] \
- [string match {* value *} $a] [string match {* _foobar_ *} $a]
-} {1 1 1 0}
-test info-8.2 {info globals option} {
- set _xxx1 1
- set _xxx2 2
- lsort [info g _xxx*]
-} {_xxx1 _xxx2}
-test info-8.3 {info globals option} {
- list [catch {info globals 1 2} msg] $msg
-} {1 {wrong # args: should be "info globals ?pattern?"}}
-
-test info-9.1 {info level option} {
- info level
-} 0
-test info-9.2 {info level option} {
- proc t1 {a b} {
- set x [info le]
- set y [info level 1]
- list $x $y
- }
- t1 146 testString
-} {1 {t1 146 testString}}
-test info-9.3 {info level option} {
- proc t1 {a b} {
- t2 [expr $a*2] $b
- }
- proc t2 {x y} {
- list [info level] [info level 1] [info level 2] [info level -1] \
- [info level 0]
- }
- t1 146 {a {b c} {{{c}}}}
-} {2 {t1 146 {a {b c} {{{c}}}}} {t2 292 {a {b c} {{{c}}}}} {t1 146 {a {b c} {{{c}}}}} {t2 292 {a {b c} {{{c}}}}}}
-test info-9.4 {info level option} {
- proc t1 {} {
- set x [info level]
- set y [info level 1]
- list $x $y
- }
- t1
-} {1 t1}
-test info-9.5 {info level option} {
- list [catch {info level 1 2} msg] $msg
-} {1 {wrong # args: should be "info level ?number?"}}
-test info-9.6 {info level option} {
- list [catch {info level 123a} msg] $msg
-} {1 {expected integer but got "123a"}}
-test info-9.7 {info level option} {
- list [catch {info level 0} msg] $msg
-} {1 {bad level "0"}}
-test info-9.8 {info level option} {
- proc t1 {} {info level -1}
- list [catch {t1} msg] $msg
-} {1 {bad level "-1"}}
-test info-9.9 {info level option} {
- proc t1 {x} {info level $x}
- list [catch {t1 -3} msg] $msg
-} {1 {bad level "-3"}}
-
-set savedLibrary $tcl_library
-test info-10.1 {info library option} {
- list [catch {info library x} msg] $msg
-} {1 {wrong # args: should be "info library"}}
-test info-10.2 {info library option} {
- set tcl_library 12345
- info library
-} {12345}
-test info-10.3 {info library option} {
- unset tcl_library
- list [catch {info library} msg] $msg
-} {1 {no library has been specified for Tcl}}
-set tcl_library $savedLibrary
-
-test info-11.1 {info loaded option} {
- list [catch {info loaded a b} msg] $msg
-} {1 {wrong # args: should be "info loaded ?interp?"}}
-test info-11.2 {info loaded option} {
- list [catch {info loaded {}}] [catch {info loaded gorp} msg] $msg
-} {0 1 {could not find interpreter "gorp"}}
-
-test info-12.1 {info locals option} {
- set a 22
- proc t1 {x y} {
- set b 13
- set c testing
- global a
- return [info locals]
- }
- lsort [t1 23 24]
-} {b c x y}
-test info-12.2 {info locals option} {
- proc t1 {x y} {
- set xx1 2
- set xx2 3
- set y 4
- return [info loc x*]
- }
- lsort [t1 2 3]
-} {x xx1 xx2}
-test info-12.3 {info locals option} {
- list [catch {info locals 1 2} msg] $msg
-} {1 {wrong # args: should be "info locals ?pattern?"}}
-test info-12.4 {info locals option} {
- info locals
-} {}
-test info-12.5 {info locals option} {
- proc t1 {} {return [info locals]}
- t1
-} {}
-test info-12.6 {info locals vs unset compiled locals} {
- proc t1 {lst} {
- foreach $lst $lst {}
- unset lst
- return [info locals]
- }
- lsort [t1 {a b c c d e f}]
-} {a b c d e f}
-test info-12.7 {info locals with temporary variables} {
- proc t1 {} {
- foreach a {b c} {}
- info locals
- }
- t1
-} {a}
-
-test info-13.1 {info nameofexecutable option} {
- list [catch {info nameofexecutable foo} msg] $msg
-} {1 {wrong # args: should be "info nameofexecutable"}}
-
-test info-14.1 {info patchlevel option} {
- set a [info patchlevel]
- regexp {[0-9]+\.[0-9]+([p[0-9]+)?} $a
-} 1
-test info-14.2 {info patchlevel option} {
- list [catch {info patchlevel a} msg] $msg
-} {1 {wrong # args: should be "info patchlevel"}}
-test info-14.3 {info patchlevel option} {
- set t $tcl_patchLevel
- unset tcl_patchLevel
- set result [list [catch {info patchlevel} msg] $msg]
- set tcl_patchLevel $t
- set result
-} {1 {can't read "tcl_patchLevel": no such variable}}
-
-test info-15.1 {info procs option} {
- proc t1 {} {}
- proc t2 {} {}
- set x " [info procs] "
- list [string match {* t1 *} $x] [string match {* t2 *} $x] \
- [string match {* _undefined_ *} $x]
-} {1 1 0}
-test info-15.2 {info procs option} {
- proc _tt1 {} {}
- proc _tt2 {} {}
- lsort [info pr _tt*]
-} {_tt1 _tt2}
-catch {rename _tt1 {}}
-catch {rename _tt2 {}}
-test info-15.3 {info procs option} {
- list [catch {info procs 2 3} msg] $msg
-} {1 {wrong # args: should be "info procs ?pattern?"}}
-test info-15.4 {info procs option} {
- catch {namespace delete test_ns_info2}
- namespace eval test_ns_info2 {
- namespace import ::test_ns_info1::*
- proc r {} {}
- list [info procs] [info procs p*]
- }
-} {{p q r} p}
-
-test info-16.1 {info script option} {
- list [catch {info script x} msg] $msg
-} {1 {wrong # args: should be "info script"}}
-test info-16.2 {info script option} {
- file tail [info sc]
-} "info.test"
-removeFile gorp.info
-makeFile "info script\n" gorp.info
-test info-16.3 {info script option} {
- list [source gorp.info] [file tail [info script]]
-} [list gorp.info info.test]
-test info-16.4 {resetting "info script" after errors} {
- catch {source ~_nobody_/foo}
- file tail [info script]
-} "info.test"
-test info-16.5 {resetting "info script" after errors} {
- catch {source _nonexistent_}
- file tail [info script]
-} "info.test"
-removeFile gorp.info
-
-test info-17.1 {info sharedlibextension option} {
- list [catch {info sharedlibextension foo} msg] $msg
-} {1 {wrong # args: should be "info sharedlibextension"}}
-
-test info-18.1 {info tclversion option} {
- set x [info tclversion]
- scan $x "%d.%d%c" a b c
-} 2
-test info-18.2 {info tclversion option} {
- list [catch {info t 2} msg] $msg
-} {1 {wrong # args: should be "info tclversion"}}
-test info-18.3 {info tclversion option} {
- set t $tcl_version
- unset tcl_version
- set result [list [catch {info tclversion} msg] $msg]
- set tcl_version $t
- set result
-} {1 {can't read "tcl_version": no such variable}}
-
-test info-19.1 {info vars option} {
- set a 1
- set b 2
- proc t1 {x y} {
- global a b
- set c 33
- return [info vars]
- }
- lsort [t1 18 19]
-} {a b c x y}
-test info-19.2 {info vars option} {
- set xxx1 1
- set xxx2 2
- proc t1 {xxa y} {
- global xxx1 xxx2
- set c 33
- return [info vars x*]
- }
- lsort [t1 18 19]
-} {xxa xxx1 xxx2}
-test info-19.3 {info vars option} {
- lsort [info vars]
-} [lsort [info globals]]
-test info-19.4 {info vars option} {
- list [catch {info vars a b} msg] $msg
-} {1 {wrong # args: should be "info vars ?pattern?"}}
-test info-19.5 {info vars with temporary variables} {
- proc t1 {} {
- foreach a {b c} {}
- info vars
- }
- t1
-} {a}
-
-test info-20.1 {miscellaneous error conditions} {
- list [catch {info} msg] $msg
-} {1 {wrong # args: should be "info option ?arg arg ...?"}}
-test info-20.2 {miscellaneous error conditions} {
- list [catch {info gorp} msg] $msg
-} {1 {bad option "gorp": must be args, body, cmdcount, commands, complete, default, exists, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
-test info-20.3 {miscellaneous error conditions} {
- list [catch {info c} msg] $msg
-} {1 {ambiguous option "c": must be args, body, cmdcount, commands, complete, default, exists, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
-test info-20.4 {miscellaneous error conditions} {
- list [catch {info l} msg] $msg
-} {1 {ambiguous option "l": must be args, body, cmdcount, commands, complete, default, exists, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
-test info-20.5 {miscellaneous error conditions} {
- list [catch {info s} msg] $msg
-} {1 {ambiguous option "s": must be args, body, cmdcount, commands, complete, default, exists, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
-
-# cleanup
-catch {namespace delete test_ns_info1 test_ns_info2}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/init.test b/tests/init.test
deleted file mode 100644
index 4172606..0000000
--- a/tests/init.test
+++ /dev/null
@@ -1,167 +0,0 @@
-# Functionality covered: this file contains a collection of tests for the
-# auto loading and namespaces.
-#
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 1997 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: init.test,v 1.3 1999/04/16 00:47:29 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Clear out any namespaces called test_ns_*
-catch {eval namespace delete [namespace children :: test_ns_*]}
-
-# Six cases - white box testing
-
-test init-1.1 {auto_qualify - absolute cmd - namespace} {
- auto_qualify ::foo::bar ::blue
-} ::foo::bar
-
-test init-1.2 {auto_qualify - absolute cmd - global} {
- auto_qualify ::global ::sub
-} global
-
-test init-1.3 {auto_qualify - no colons cmd - global} {
- auto_qualify nocolons ::
-} nocolons
-
-test init-1.4 {auto_qualify - no colons cmd - namespace} {
- auto_qualify nocolons ::sub
-} {::sub::nocolons nocolons}
-
-test init-1.5 {auto_qualify - colons in cmd - global} {
- auto_qualify foo::bar ::
-} ::foo::bar
-
-test init-1.6 {auto_qualify - colons in cmd - namespace} {
- auto_qualify foo::bar ::sub
-} {::sub::foo::bar ::foo::bar}
-
-# Some additional tests
-
-test init-1.7 {auto_qualify - multiples colons 1} {
- auto_qualify :::foo::::bar ::blue
-} ::foo::bar
-
-test init-1.8 {auto_qualify - multiple colons 2} {
- auto_qualify :::foo ::bar
-} foo
-
-
-# we use a sub interp and auto_reset and double the tests because there is 2
-# places where auto_loading occur (before loading the indexes files and after)
-
-set testInterp [interp create]
-interp eval $testInterp [list set argv $argv]
-interp eval $testInterp [list source [file join $::tcltest::testsDir defs.tcl]]
-
-interp eval $testInterp {
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-auto_reset
-catch {rename parray {}}
-
-test init-2.0 {load parray - stage 1} {
- set ret [catch {namespace eval ::tcltest {parray}} error]
- rename parray {} ; # remove it, for the next test - that should not fail.
- list $ret $error
-} {1 {no value given for parameter "a" to "parray"}}
-
-
-test init-2.1 {load parray - stage 2} {
- set ret [catch {namespace eval ::tcltest {parray}} error]
- list $ret $error
-} {1 {no value given for parameter "a" to "parray"}}
-
-
-auto_reset
-catch {rename ::safe::setLogCmd {}}
-#unset auto_index(::safe::setLogCmd)
-#unset auto_oldpath
-
-test init-2.2 {load ::safe::setLogCmd - stage 1} {
- ::safe::setLogCmd
- rename ::safe::setLogCmd {} ; # should not fail
-} {}
-
-test init-2.3 {load ::safe::setLogCmd - stage 2} {
- ::safe::setLogCmd
- rename ::safe::setLogCmd {} ; # should not fail
-} {}
-
-auto_reset
-catch {rename ::safe::setLogCmd {}}
-
-test init-2.4 {load safe:::setLogCmd - stage 1} {
- safe:::setLogCmd ; # intentionally 3 :
- rename ::safe::setLogCmd {} ; # should not fail
-} {}
-
-test init-2.5 {load safe:::setLogCmd - stage 2} {
- safe:::setLogCmd ; # intentionally 3 :
- rename ::safe::setLogCmd {} ; # should not fail
-} {}
-
-auto_reset
-catch {rename ::safe::setLogCmd {}}
-
-test init-2.6 {load setLogCmd from safe:: - stage 1} {
- namespace eval safe setLogCmd
- rename ::safe::setLogCmd {} ; # should not fail
-} {}
-
-test init-2.7 {oad setLogCmd from safe:: - stage 2} {
- namespace eval safe setLogCmd
- rename ::safe::setLogCmd {} ; # should not fail
-} {}
-
-
-auto_reset
-package require http 2.0
-catch {rename ::http::geturl {}}
-
-test init-2.8 {load http::geturl (package)} {
- # 3 ':' on purpose
- set ret [catch {namespace eval ::tcltest {http:::geturl}} error]
- # removing it, for the next test. should not fail.
- rename ::http::geturl {} ;
- list $ret $error
-} {1 {no value given for parameter "url" to "http:::geturl"}}
-
-
-test init-3.0 {random stuff in the auto_index, should still work} {
- set auto_index(foo:::bar::blah) {
- namespace eval foo {namespace eval bar {proc blah {} {return 1}}}
- }
- foo:::bar::blah
-} 1
-
-}
-
-# cleanup
-interp delete $testInterp
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/interp.test b/tests/interp.test
deleted file mode 100644
index 817ef99..0000000
--- a/tests/interp.test
+++ /dev/null
@@ -1,2360 +0,0 @@
-# This file tests the multiple interpreter facility of Tcl
-#
-# 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) 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: interp.test,v 1.7 1999/04/16 00:47:29 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# The set of hidden commands is platform dependent:
-
-if {"$tcl_platform(platform)" == "macintosh"} {
- set hidden_cmds {beep cd echo encoding exit fconfigure file glob load ls open pwd socket source}
-} else {
- set hidden_cmds {cd encoding exec exit fconfigure file glob load open pwd socket source}
-}
-
-foreach i [interp slaves] {
- interp delete $i
-}
-
-proc equiv {x} {return $x}
-
-# Part 0: Check out options for interp command
-test interp-1.1 {options for interp command} {
- list [catch {interp} msg] $msg
-} {1 {wrong # args: should be "interp cmd ?arg ...?"}}
-test interp-1.2 {options for interp command} {
- list [catch {interp frobox} msg] $msg
-} {1 {bad option "frobox": must be alias, aliases, create, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, marktrusted, slaves, share, target, or transfer}}
-test interp-1.3 {options for interp command} {
- interp delete
-} ""
-test interp-1.4 {options for interp command} {
- list [catch {interp delete foo bar} msg] $msg
-} {1 {could not find interpreter "foo"}}
-test interp-1.5 {options for interp command} {
- list [catch {interp exists foo bar} msg] $msg
-} {1 {wrong # args: should be "interp exists ?path?"}}
-#
-# test interp-0.6 was removed
-#
-test interp-1.6 {options for interp command} {
- list [catch {interp slaves foo bar zop} msg] $msg
-} {1 {wrong # args: should be "interp slaves ?path?"}}
-test interp-1.7 {options for interp command} {
- list [catch {interp hello} msg] $msg
-} {1 {bad option "hello": must be alias, aliases, create, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, marktrusted, slaves, share, target, or transfer}}
-test interp-1.8 {options for interp command} {
- list [catch {interp -froboz} msg] $msg
-} {1 {bad option "-froboz": must be alias, aliases, create, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, marktrusted, slaves, share, target, or transfer}}
-test interp-1.9 {options for interp command} {
- list [catch {interp -froboz -safe} msg] $msg
-} {1 {bad option "-froboz": must be alias, aliases, create, delete, eval, exists, expose, hide, hidden, issafe, invokehidden, marktrusted, slaves, share, target, or transfer}}
-test interp-1.10 {options for interp command} {
- list [catch {interp target} msg] $msg
-} {1 {wrong # args: should be "interp target path alias"}}
-
-# Part 1: Basic interpreter creation tests:
-test interp-2.1 {basic interpreter creation} {
- interp create a
-} a
-test interp-2.2 {basic interpreter creation} {
- catch {interp create}
-} 0
-test interp-2.3 {basic interpreter creation} {
- catch {interp create -safe}
-} 0
-test interp-2.4 {basic interpreter creation} {
- list [catch {interp create a} msg] $msg
-} {1 {interpreter named "a" already exists, cannot create}}
-test interp-2.5 {basic interpreter creation} {
- interp create b -safe
-} b
-test interp-2.6 {basic interpreter creation} {
- interp create d -safe
-} d
-test interp-2.7 {basic interpreter creation} {
- list [catch {interp create -froboz} msg] $msg
-} {1 {bad option "-froboz": must be -safe or --}}
-test interp-2.8 {basic interpreter creation} {
- interp create -- -froboz
-} -froboz
-test interp-2.9 {basic interpreter creation} {
- interp create -safe -- -froboz1
-} -froboz1
-test interp-2.10 {basic interpreter creation} {
- interp create {a x1}
- interp create {a x2}
- interp create {a x3} -safe
-} {a x3}
-test interp-2.11 {anonymous interps vs existing procs} {
- set x [interp create]
- regexp "interp(\[0-9]+)" $x dummy thenum
- interp delete $x
- proc interp$thenum {} {}
- set x [interp create]
- regexp "interp(\[0-9]+)" $x dummy anothernum
- expr $anothernum > $thenum
-} 1
-test interp-2.12 {anonymous interps vs existing procs} {
- set x [interp create -safe]
- regexp "interp(\[0-9]+)" $x dummy thenum
- interp delete $x
- proc interp$thenum {} {}
- set x [interp create -safe]
- regexp "interp(\[0-9]+)" $x dummy anothernum
- expr $anothernum - $thenum
-} 1
-
-foreach i [interp slaves] {
- interp delete $i
-}
-
-# Part 2: Testing "interp slaves" and "interp exists"
-test interp-3.1 {testing interp exists and interp slaves} {
- interp slaves
-} ""
-test interp-3.2 {testing interp exists and interp slaves} {
- interp create a
- interp exists a
-} 1
-test interp-3.3 {testing interp exists and interp slaves} {
- interp exists nonexistent
-} 0
-test interp-3.4 {testing interp exists and interp slaves} {
- list [catch {interp slaves a b c} msg] $msg
-} {1 {wrong # args: should be "interp slaves ?path?"}}
-test interp-3.5 {testing interp exists and interp slaves} {
- list [catch {interp exists a b c} msg] $msg
-} {1 {wrong # args: should be "interp exists ?path?"}}
-test interp-3.6 {testing interp exists and interp slaves} {
- interp exists
-} 1
-test interp-3.7 {testing interp exists and interp slaves} {
- interp slaves
-} a
-test interp-3.8 {testing interp exists and interp slaves} {
- list [catch {interp slaves a b c} msg] $msg
-} {1 {wrong # args: should be "interp slaves ?path?"}}
-test interp-3.9 {testing interp exists and interp slaves} {
- interp create {a a2} -safe
- expr {[lsearch [interp slaves a] a2] >= 0}
-} 1
-test interp-3.10 {testing interp exists and interp slaves} {
- interp exists {a a2}
-} 1
-
-# Part 3: Testing "interp delete"
-test interp-3.11 {testing interp delete} {
- interp delete
-} ""
-test interp-4.1 {testing interp delete} {
- catch {interp create a}
- interp delete a
-} ""
-test interp-4.2 {testing interp delete} {
- list [catch {interp delete nonexistent} msg] $msg
-} {1 {could not find interpreter "nonexistent"}}
-test interp-4.3 {testing interp delete} {
- list [catch {interp delete x y z} msg] $msg
-} {1 {could not find interpreter "x"}}
-test interp-4.4 {testing interp delete} {
- interp delete
-} ""
-test interp-4.5 {testing interp delete} {
- interp create a
- interp create {a x1}
- interp delete {a x1}
- expr {[lsearch [interp slaves a] x1] >= 0}
-} 0
-test interp-4.6 {testing interp delete} {
- interp create c1
- interp create c2
- interp create c3
- interp delete c1 c2 c3
-} ""
-test interp-4.7 {testing interp delete} {
- interp create c1
- interp create c2
- list [catch {interp delete c1 c2 c3} msg] $msg
-} {1 {could not find interpreter "c3"}}
-test interp-4.8 {testing interp delete} {
- list [catch {interp delete {}} msg] $msg
-} {1 {cannot delete the current interpreter}}
-
-foreach i [interp slaves] {
- interp delete $i
-}
-
-# Part 4: Consistency checking - all nondeleted interpreters should be
-# there:
-test interp-5.1 {testing consistency} {
- interp slaves
-} ""
-test interp-5.2 {testing consistency} {
- interp exists a
-} 0
-test interp-5.3 {testing consistency} {
- interp exists nonexistent
-} 0
-
-# Recreate interpreter "a"
-interp create a
-
-# Part 5: Testing eval in interpreter object command and with interp command
-test interp-6.1 {testing eval} {
- a eval expr 3 + 5
-} 8
-test interp-6.2 {testing eval} {
- list [catch {a eval foo} msg] $msg
-} {1 {invalid command name "foo"}}
-test interp-6.3 {testing eval} {
- a eval {proc foo {} {expr 3 + 5}}
- a eval foo
-} 8
-test interp-6.4 {testing eval} {
- interp eval a foo
-} 8
-
-test interp-6.5 {testing eval} {
- interp create {a x2}
- interp eval {a x2} {proc frob {} {expr 4 * 9}}
- interp eval {a x2} frob
-} 36
-test interp-6.6 {testing eval} {
- list [catch {interp eval {a x2} foo} msg] $msg
-} {1 {invalid command name "foo"}}
-
-# UTILITY PROCEDURE RUNNING IN MASTER INTERPRETER:
-proc in_master {args} {
- return [list seen in master: $args]
-}
-
-# Part 6: Testing basic alias creation
-test interp-7.1 {testing basic alias creation} {
- a alias foo in_master
-} foo
-test interp-7.2 {testing basic alias creation} {
- a alias bar in_master a1 a2 a3
-} bar
-# Test 6.3 has been deleted.
-test interp-7.3 {testing basic alias creation} {
- a alias foo
-} in_master
-test interp-7.4 {testing basic alias creation} {
- a alias bar
-} {in_master a1 a2 a3}
-test interp-7.5 {testing basic alias creation} {
- a aliases
-} {foo bar}
-
-# Part 7: testing basic alias invocation
-test interp-8.1 {testing basic alias invocation} {
- catch {interp create a}
- a alias foo in_master
- a eval foo s1 s2 s3
-} {seen in master: {s1 s2 s3}}
-test interp-8.2 {testing basic alias invocation} {
- catch {interp create a}
- a alias bar in_master a1 a2 a3
- a eval bar s1 s2 s3
-} {seen in master: {a1 a2 a3 s1 s2 s3}}
-
-# Part 8: Testing aliases for non-existent targets
-test interp-9.1 {testing aliases for non-existent targets} {
- catch {interp create a}
- a alias zop nonexistent-command-in-master
- list [catch {a eval zop} msg] $msg
-} {1 {invalid command name "nonexistent-command-in-master"}}
-test interp-9.2 {testing aliases for non-existent targets} {
- catch {interp create a}
- a alias zop nonexistent-command-in-master
- proc nonexistent-command-in-master {} {return i_exist!}
- a eval zop
-} i_exist!
-
-if {[info command nonexistent-command-in-master] != ""} {
- rename nonexistent-command-in-master {}
-}
-
-# Part 9: Aliasing between interpreters
-test interp-10.1 {testing aliasing between interpreters} {
- catch {interp delete a}
- catch {interp delete b}
- interp create a
- interp create b
- interp alias a a_alias b b_alias 1 2 3
-} a_alias
-test interp-10.2 {testing aliasing between interpreters} {
- catch {interp delete a}
- catch {interp delete b}
- interp create a
- interp create b
- b eval {proc b_alias {args} {return [list got $args]}}
- interp alias a a_alias b b_alias 1 2 3
- a eval a_alias a b c
-} {got {1 2 3 a b c}}
-test interp-10.3 {testing aliasing between interpreters} {
- catch {interp delete a}
- catch {interp delete b}
- interp create a
- interp create b
- interp alias a a_alias b b_alias 1 2 3
- list [catch {a eval a_alias a b c} msg] $msg
-} {1 {invalid command name "b_alias"}}
-test interp-10.4 {testing aliasing between interpreters} {
- catch {interp delete a}
- interp create a
- a alias a_alias puts
- a aliases
-} a_alias
-test interp-10.5 {testing aliasing between interpreters} {
- catch {interp delete a}
- catch {interp delete b}
- interp create a
- interp create b
- a alias a_alias puts
- interp alias a a_del b b_del
- interp delete b
- a aliases
-} a_alias
-test interp-10.6 {testing aliasing between interpreters} {
- catch {interp delete a}
- catch {interp delete b}
- interp create a
- interp create b
- interp alias a a_command b b_command a1 a2 a3
- b alias b_command in_master b1 b2 b3
- a eval a_command m1 m2 m3
-} {seen in master: {b1 b2 b3 a1 a2 a3 m1 m2 m3}}
-test interp-10.7 {testing aliases between interpreters} {
- catch {interp delete a}
- interp create a
- interp alias "" foo a zoppo
- a eval {proc zoppo {x} {list $x $x $x}}
- set x [foo 33]
- a eval {rename zoppo {}}
- interp alias "" foo a {}
- equiv $x
-} {33 33 33}
-
-# Part 10: Testing "interp target"
-test interp-11.1 {testing interp target} {
- list [catch {interp target} msg] $msg
-} {1 {wrong # args: should be "interp target path alias"}}
-test interp-11.2 {testing interp target} {
- list [catch {interp target nosuchinterpreter foo} msg] $msg
-} {1 {could not find interpreter "nosuchinterpreter"}}
-test interp-11.3 {testing interp target} {
- catch {interp delete a}
- interp create a
- a alias boo no_command
- interp target a boo
-} ""
-test interp-11.4 {testing interp target} {
- catch {interp delete x1}
- interp create x1
- x1 eval interp create x2
- x1 eval x2 eval interp create x3
- catch {interp delete y1}
- interp create y1
- y1 eval interp create y2
- y1 eval y2 eval interp create y3
- interp alias {x1 x2 x3} xcommand {y1 y2 y3} ycommand
- interp target {x1 x2 x3} xcommand
-} {y1 y2 y3}
-test interp-11.5 {testing interp target} {
- catch {interp delete x1}
- interp create x1
- interp create {x1 x2}
- interp create {x1 x2 x3}
- catch {interp delete y1}
- interp create y1
- interp create {y1 y2}
- interp create {y1 y2 y3}
- interp alias {x1 x2 x3} xcommand {y1 y2 y3} ycommand
- list [catch {x1 eval {interp target {x2 x3} xcommand}} msg] $msg
-} {1 {target interpreter for alias "xcommand" in path "x2 x3" is not my descendant}}
-test interp-11.6 {testing interp target} {
- foreach a [interp aliases] {
- rename $a {}
- }
- list [catch {interp target {} foo} msg] $msg
-} {1 {alias "foo" in path "" not found}}
-test interp-11.7 {testing interp target} {
- catch {interp delete a}
- interp create a
- list [catch {interp target a foo} msg] $msg
-} {1 {alias "foo" in path "a" not found}}
-
-# Part 11: testing "interp issafe"
-test interp-12.1 {testing interp issafe} {
- interp issafe
-} 0
-test interp-12.2 {testing interp issafe} {
- catch {interp delete a}
- interp create a
- interp issafe a
-} 0
-test interp-12.3 {testing interp issafe} {
- catch {interp delete a}
- interp create a
- interp create {a x3} -safe
- interp issafe {a x3}
-} 1
-test interp-12.4 {testing interp issafe} {
- catch {interp delete a}
- interp create a
- interp create {a x3} -safe
- interp create {a x3 foo}
- interp issafe {a x3 foo}
-} 1
-
-# Part 12: testing interpreter object command "issafe" sub-command
-test interp-13.1 {testing foo issafe} {
- catch {interp delete a}
- interp create a
- a issafe
-} 0
-test interp-13.2 {testing foo issafe} {
- catch {interp delete a}
- interp create a
- interp create {a x3} -safe
- a eval x3 issafe
-} 1
-test interp-13.3 {testing foo issafe} {
- catch {interp delete a}
- interp create a
- interp create {a x3} -safe
- interp create {a x3 foo}
- a eval x3 eval foo issafe
-} 1
-
-# part 14: testing interp aliases
-test interp-14.1 {testing interp aliases} {
- interp aliases
-} ""
-test interp-14.2 {testing interp aliases} {
- catch {interp delete a}
- interp create a
- a alias a1 puts
- a alias a2 puts
- a alias a3 puts
- lsort [interp aliases a]
-} {a1 a2 a3}
-test interp-14.3 {testing interp aliases} {
- catch {interp delete a}
- interp create a
- interp create {a x3}
- interp alias {a x3} froboz "" puts
- interp aliases {a x3}
-} froboz
-
-# part 15: testing file sharing
-test interp-15.1 {testing file sharing} {
- catch {interp delete z}
- interp create z
- z eval close stdout
- list [catch {z eval puts hello} msg] $msg
-} {1 {can not find channel named "stdout"}}
-catch {removeFile file-15.2}
-test interp-15.2 {testing file sharing} {
- catch {interp delete z}
- interp create z
- set f [open file-15.2 w]
- interp share "" $f z
- z eval puts $f hello
- z eval close $f
- close $f
-} ""
-catch {removeFile file-15.2}
-test interp-15.3 {testing file sharing} {
- catch {interp delete xsafe}
- interp create xsafe -safe
- list [catch {xsafe eval puts hello} msg] $msg
-} {1 {can not find channel named "stdout"}}
-catch {removeFile file-15.4}
-test interp-15.4 {testing file sharing} {
- catch {interp delete xsafe}
- interp create xsafe -safe
- set f [open file-15.4 w]
- interp share "" $f xsafe
- xsafe eval puts $f hello
- xsafe eval close $f
- close $f
-} ""
-catch {removeFile file-15.4}
-test interp-15.5 {testing file sharing} {
- catch {interp delete xsafe}
- interp create xsafe -safe
- interp share "" stdout xsafe
- list [catch {xsafe eval gets stdout} msg] $msg
-} {1 {channel "stdout" wasn't opened for reading}}
-catch {removeFile file-15.6}
-test interp-15.6 {testing file sharing} {
- catch {interp delete xsafe}
- interp create xsafe -safe
- set f [open file-15.6 w]
- interp share "" $f xsafe
- set x [list [catch [list xsafe eval gets $f] msg] $msg]
- xsafe eval close $f
- close $f
- string compare [string tolower $x] \
- [list 1 [format "channel \"%s\" wasn't opened for reading" $f]]
-} 0
-catch {removeFile file-15.6}
-catch {removeFile file-15.7}
-test interp-15.7 {testing file transferring} {
- catch {interp delete xsafe}
- interp create xsafe -safe
- set f [open file-15.7 w]
- interp transfer "" $f xsafe
- xsafe eval puts $f hello
- xsafe eval close $f
-} ""
-catch {removeFile file-15.7}
-catch {removeFile file-15.8}
-test interp-15.8 {testing file transferring} {
- catch {interp delete xsafe}
- interp create xsafe -safe
- set f [open file-15.8 w]
- interp transfer "" $f xsafe
- xsafe eval close $f
- set x [list [catch {close $f} msg] $msg]
- string compare [string tolower $x] \
- [list 1 [format "can not find channel named \"%s\"" $f]]
-} 0
-catch {removeFile file-15.8}
-
-#
-# Torture tests for interpreter deletion order
-#
-proc kill {} {interp delete xxx}
-
-test interp-15.9 {testing deletion order} {
- catch {interp delete xxx}
- interp create xxx
- xxx alias kill kill
- list [catch {xxx eval kill} msg] $msg
-} {0 {}}
-test interp-16.1 {testing deletion order} {
- catch {interp delete xxx}
- interp create xxx
- interp create {xxx yyy}
- interp alias {xxx yyy} kill "" kill
- list [catch {interp eval {xxx yyy} kill} msg] $msg
-} {0 {}}
-test interp-16.2 {testing deletion order} {
- catch {interp delete xxx}
- interp create xxx
- interp create {xxx yyy}
- interp alias {xxx yyy} kill "" kill
- list [catch {xxx eval yyy eval kill} msg] $msg
-} {0 {}}
-test interp-16.3 {testing deletion order} {
- catch {interp delete xxx}
- interp create xxx
- interp create ddd
- xxx alias kill kill
- interp alias ddd kill xxx kill
- set x [ddd eval kill]
- interp delete ddd
- set x
-} ""
-test interp-16.4 {testing deletion order} {
- catch {interp delete xxx}
- interp create xxx
- interp create {xxx yyy}
- interp alias {xxx yyy} kill "" kill
- interp create ddd
- interp alias ddd kill {xxx yyy} kill
- set x [ddd eval kill]
- interp delete ddd
- set x
-} ""
-test interp-16.5 {testing deletion order, bgerror} {
- catch {interp delete xxx}
- interp create xxx
- xxx eval {proc bgerror {args} {exit}}
- xxx alias exit kill xxx
- proc kill {i} {interp delete $i}
- xxx eval after 100 expr a + b
- after 200
- update
- interp exists xxx
-} 0
-
-#
-# Alias loop prevention testing.
-#
-
-test interp-17.1 {alias loop prevention} {
- list [catch {interp alias {} a {} a} msg] $msg
-} {1 {cannot define or rename alias "a": would create a loop}}
-test interp-17.2 {alias loop prevention} {
- catch {interp delete x}
- interp create x
- x alias a loop
- list [catch {interp alias {} loop x a} msg] $msg
-} {1 {cannot define or rename alias "loop": would create a loop}}
-test interp-17.3 {alias loop prevention} {
- catch {interp delete x}
- interp create x
- interp alias x a x b
- list [catch {interp alias x b x a} msg] $msg
-} {1 {cannot define or rename alias "b": would create a loop}}
-test interp-17.4 {alias loop prevention} {
- catch {interp delete x}
- interp create x
- interp alias x b x a
- list [catch {x eval rename b a} msg] $msg
-} {1 {cannot define or rename alias "b": would create a loop}}
-test interp-17.5 {alias loop prevention} {
- catch {interp delete x}
- interp create x
- x alias z l1
- interp alias {} l2 x z
- list [catch {rename l2 l1} msg] $msg
-} {1 {cannot define or rename alias "l2": would create a loop}}
-
-#
-# Test robustness of Tcl_DeleteInterp when applied to a slave interpreter.
-# If there are bugs in the implementation these tests are likely to expose
-# the bugs as a core dump.
-#
-
-if {[info commands testinterpdelete] != ""} {
- test interp-18.1 {testing Tcl_DeleteInterp vs slaves} {
- list [catch {testinterpdelete} msg] $msg
- } {1 {wrong # args: should be "testinterpdelete path"}}
- test interp-18.2 {testing Tcl_DeleteInterp vs slaves} {
- catch {interp delete a}
- interp create a
- testinterpdelete a
- } ""
- test interp-18.3 {testing Tcl_DeleteInterp vs slaves} {
- catch {interp delete a}
- interp create a
- interp create {a b}
- testinterpdelete {a b}
- } ""
- test interp-18.4 {testing Tcl_DeleteInterp vs slaves} {
- catch {interp delete a}
- interp create a
- interp create {a b}
- testinterpdelete a
- } ""
- test interp-18.5 {testing Tcl_DeleteInterp vs slaves} {
- catch {interp delete a}
- interp create a
- interp create {a b}
- interp alias {a b} dodel {} dodel
- proc dodel {x} {testinterpdelete $x}
- list [catch {interp eval {a b} {dodel {a b}}} msg] $msg
- } {0 {}}
- test interp-18.6 {testing Tcl_DeleteInterp vs slaves} {
- catch {interp delete a}
- interp create a
- interp create {a b}
- interp alias {a b} dodel {} dodel
- proc dodel {x} {testinterpdelete $x}
- list [catch {interp eval {a b} {dodel a}} msg] $msg
- } {0 {}}
- test interp-18.7 {eval in deleted interp} {
- catch {interp delete a}
- interp create a
- a eval {
- proc dodel {} {
- delme
- dosomething else
- }
- proc dosomething args {
- puts "I should not have been called!!"
- }
- }
- a alias delme dela
- proc dela {} {interp delete a}
- list [catch {a eval dodel} msg] $msg
- } {1 {attempt to call eval in deleted interpreter}}
- test interp-18.8 {eval in deleted interp} {
- catch {interp delete a}
- interp create a
- a eval {
- interp create b
- b eval {
- proc dodel {} {
- dela
- }
- }
- proc foo {} {
- b eval dela
- dosomething else
- }
- proc dosomething args {
- puts "I should not have been called!!"
- }
- }
- interp alias {a b} dela {} dela
- proc dela {} {interp delete a}
- list [catch {a eval foo} msg] $msg
- } {1 {attempt to call eval in deleted interpreter}}
-}
-
-# Test alias deletion
-
-test interp-19.1 {alias deletion} {
- catch {interp delete a}
- interp create a
- interp alias a foo a bar
- set s [interp alias a foo {}]
- interp delete a
- set s
-} {}
-test interp-19.2 {alias deletion} {
- catch {interp delete a}
- interp create a
- catch {interp alias a foo {}} msg
- interp delete a
- set msg
-} {alias "foo" not found}
-test interp-19.3 {alias deletion} {
- catch {interp delete a}
- interp create a
- interp alias a foo a bar
- interp eval a {rename foo zop}
- interp alias a foo a zop
- catch {interp eval a foo} msg
- interp delete a
- set msg
-} {invalid command name "zop"}
-test interp-19.4 {alias deletion} {
- catch {interp delete a}
- interp create a
- interp alias a foo a bar
- interp eval a {rename foo zop}
- catch {interp eval a foo} msg
- interp delete a
- set msg
-} {invalid command name "foo"}
-test interp-19.5 {alias deletion} {
- catch {interp delete a}
- interp create a
- interp eval a {proc bar {} {return 1}}
- interp alias a foo a bar
- interp eval a {rename foo zop}
- catch {interp eval a zop} msg
- interp delete a
- set msg
-} 1
-test interp-19.6 {alias deletion} {
- catch {interp delete a}
- interp create a
- interp alias a foo a bar
- interp eval a {rename foo zop}
- interp alias a foo a zop
- set s [interp aliases a]
- interp delete a
- set s
-} foo
-test interp-19.7 {alias deletion, renaming} {
- catch {interp delete a}
- interp create a
- interp alias a foo a bar
- interp eval a rename foo blotz
- interp alias a foo {}
- set s [interp aliases a]
- interp delete a
- set s
-} {}
-test interp-19.8 {alias deletion, renaming} {
- catch {interp delete a}
- interp create a
- interp alias a foo a bar
- interp eval a rename foo blotz
- set l ""
- lappend l [interp aliases a]
- interp alias a foo {}
- lappend l [interp aliases a]
- interp delete a
- set l
-} {foo {}}
-test interp-19.9 {alias deletion, renaming} {
- catch {interp delete a}
- interp create a
- interp alias a foo a bar
- interp eval a rename foo blotz
- interp eval a {proc foo {} {expr 34 * 34}}
- interp alias a foo {}
- set l [interp eval a foo]
- interp delete a
- set l
-} 1156
-
-test interp-20.1 {interp hide, interp expose and interp invokehidden} {
- catch {interp delete a}
- interp create a
- a eval {proc unknown {x args} {error "invalid command name \"$x\""}}
- a eval {proc foo {} {}}
- a hide foo
- catch {a eval foo something} msg
- interp delete a
- set msg
-} {invalid command name "foo"}
-test interp-20.2 {interp hide, interp expose and interp invokehidden} {
- catch {interp delete a}
- interp create a
- a eval {proc unknown {x args} {error "invalid command name \"$x\""}}
- a hide list
- set l ""
- lappend l [catch {a eval {list 1 2 3}} msg]
- lappend l $msg
- a expose list
- lappend l [catch {a eval {list 1 2 3}} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {invalid command name "list"} 0 {1 2 3}}
-test interp-20.3 {interp hide, interp expose and interp invokehidden} {
- catch {interp delete a}
- interp create a
- a eval {proc unknown {x args} {error "invalid command name \"$x\""}}
- a hide list
- set l ""
- lappend l [catch {a eval {list 1 2 3}} msg]
- lappend l $msg
- lappend l [catch {a invokehidden list 1 2 3} msg]
- lappend l $msg
- a expose list
- lappend l [catch {a eval {list 1 2 3}} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {invalid command name "list"} 0 {1 2 3} 0 {1 2 3}}
-test interp-20.4 {interp hide, interp expose and interp invokehidden -- passing {}} {
- catch {interp delete a}
- interp create a
- a eval {proc unknown {x args} {error "invalid command name \"$x\""}}
- a hide list
- set l ""
- lappend l [catch {a eval {list 1 2 3}} msg]
- lappend l $msg
- lappend l [catch {a invokehidden list {"" 1 2 3}} msg]
- lappend l $msg
- a expose list
- lappend l [catch {a eval {list 1 2 3}} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {invalid command name "list"} 0 {{"" 1 2 3}} 0 {1 2 3}}
-test interp-20.5 {interp hide, interp expose and interp invokehidden -- passing {}} {
- catch {interp delete a}
- interp create a
- a eval {proc unknown {x args} {error "invalid command name \"$x\""}}
- a hide list
- set l ""
- lappend l [catch {a eval {list 1 2 3}} msg]
- lappend l $msg
- lappend l [catch {a invokehidden list {{} 1 2 3}} msg]
- lappend l $msg
- a expose list
- lappend l [catch {a eval {list 1 2 3}} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {invalid command name "list"} 0 {{{} 1 2 3}} 0 {1 2 3}}
-test interp-20.6 {interp invokehidden -- eval args} {
- catch {interp delete a}
- interp create a
- a hide list
- set l ""
- set z 45
- lappend l [catch {a invokehidden list $z 1 2 3} msg]
- lappend l $msg
- a expose list
- lappend l [catch {a eval list $z 1 2 3} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {45 1 2 3} 0 {45 1 2 3}}
-test interp-20.7 {interp invokehidden vs variable eval} {
- catch {interp delete a}
- interp create a
- a hide list
- set z 45
- set l ""
- lappend l [catch {a invokehidden list {$z a b c}} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {{$z a b c}}}
-test interp-20.8 {interp invokehidden vs variable eval} {
- catch {interp delete a}
- interp create a
- a hide list
- a eval set z 89
- set z 45
- set l ""
- lappend l [catch {a invokehidden list {$z a b c}} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {{$z a b c}}}
-test interp-20.9 {interp invokehidden vs variable eval} {
- catch {interp delete a}
- interp create a
- a hide list
- a eval set z 89
- set z 45
- set l ""
- lappend l [catch {a invokehidden list $z {$z a b c}} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {45 {$z a b c}}}
-test interp-20.10 {interp hide, interp expose and interp invokehidden} {
- catch {interp delete a}
- interp create a
- a eval {proc unknown {x args} {error "invalid command name \"$x\""}}
- a eval {proc foo {} {}}
- interp hide a foo
- catch {interp eval a foo something} msg
- interp delete a
- set msg
-} {invalid command name "foo"}
-test interp-20.11 {interp hide, interp expose and interp invokehidden} {
- catch {interp delete a}
- interp create a
- a eval {proc unknown {x args} {error "invalid command name \"$x\""}}
- interp hide a list
- set l ""
- lappend l [catch {interp eval a {list 1 2 3}} msg]
- lappend l $msg
- interp expose a list
- lappend l [catch {interp eval a {list 1 2 3}} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {invalid command name "list"} 0 {1 2 3}}
-test interp-20.12 {interp hide, interp expose and interp invokehidden} {
- catch {interp delete a}
- interp create a
- a eval {proc unknown {x args} {error "invalid command name \"$x\""}}
- interp hide a list
- set l ""
- lappend l [catch {interp eval a {list 1 2 3}} msg]
- lappend l $msg
- lappend l [catch {interp invokehidden a list 1 2 3} msg]
- lappend l $msg
- interp expose a list
- lappend l [catch {interp eval a {list 1 2 3}} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {invalid command name "list"} 0 {1 2 3} 0 {1 2 3}}
-test interp-20.13 {interp hide, interp expose, interp invokehidden -- passing {}} {
- catch {interp delete a}
- interp create a
- a eval {proc unknown {x args} {error "invalid command name \"$x\""}}
- interp hide a list
- set l ""
- lappend l [catch {interp eval a {list 1 2 3}} msg]
- lappend l $msg
- lappend l [catch {interp invokehidden a list {"" 1 2 3}} msg]
- lappend l $msg
- interp expose a list
- lappend l [catch {interp eval a {list 1 2 3}} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {invalid command name "list"} 0 {{"" 1 2 3}} 0 {1 2 3}}
-test interp-20.14 {interp hide, interp expose, interp invokehidden -- passing {}} {
- catch {interp delete a}
- interp create a
- a eval {proc unknown {x args} {error "invalid command name \"$x\""}}
- interp hide a list
- set l ""
- lappend l [catch {interp eval a {list 1 2 3}} msg]
- lappend l $msg
- lappend l [catch {interp invokehidden a list {{} 1 2 3}} msg]
- lappend l $msg
- interp expose a list
- lappend l [catch {a eval {list 1 2 3}} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {invalid command name "list"} 0 {{{} 1 2 3}} 0 {1 2 3}}
-test interp-20.15 {interp invokehidden -- eval args} {
- catch {interp delete a}
- interp create a
- interp hide a list
- set l ""
- set z 45
- lappend l [catch {interp invokehidden a list $z 1 2 3} msg]
- lappend l $msg
- a expose list
- lappend l [catch {interp eval a list $z 1 2 3} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {45 1 2 3} 0 {45 1 2 3}}
-test interp-20.16 {interp invokehidden vs variable eval} {
- catch {interp delete a}
- interp create a
- interp hide a list
- set z 45
- set l ""
- lappend l [catch {interp invokehidden a list {$z a b c}} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {{$z a b c}}}
-test interp-20.17 {interp invokehidden vs variable eval} {
- catch {interp delete a}
- interp create a
- interp hide a list
- a eval set z 89
- set z 45
- set l ""
- lappend l [catch {interp invokehidden a list {$z a b c}} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {{$z a b c}}}
-test interp-20.18 {interp invokehidden vs variable eval} {
- catch {interp delete a}
- interp create a
- interp hide a list
- a eval set z 89
- set z 45
- set l ""
- lappend l [catch {interp invokehidden a list $z {$z a b c}} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {45 {$z a b c}}}
-test interp-20.19 {interp invokehidden vs nested commands} {
- catch {interp delete a}
- interp create a
- a hide list
- set l [a invokehidden list {[list x y z] f g h} z]
- interp delete a
- set l
-} {{[list x y z] f g h} z}
-test interp-20.20 {interp invokehidden vs nested commands} {
- catch {interp delete a}
- interp create a
- a hide list
- set l [interp invokehidden a list {[list x y z] f g h} z]
- interp delete a
- set l
-} {{[list x y z] f g h} z}
-test interp-20.21 {interp hide vs safety} {
- catch {interp delete a}
- interp create a -safe
- set l ""
- lappend l [catch {a hide list} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {}}
-test interp-20.22 {interp hide vs safety} {
- catch {interp delete a}
- interp create a -safe
- set l ""
- lappend l [catch {interp hide a list} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {}}
-test interp-20.23 {interp hide vs safety} {
- catch {interp delete a}
- interp create a -safe
- set l ""
- lappend l [catch {a eval {interp hide {} list}} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {permission denied: safe interpreter cannot hide commands}}
-test interp-20.24 {interp hide vs safety} {
- catch {interp delete a}
- interp create a -safe
- interp create {a b}
- set l ""
- lappend l [catch {a eval {interp hide b list}} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {permission denied: safe interpreter cannot hide commands}}
-test interp-20.25 {interp hide vs safety} {
- catch {interp delete a}
- interp create a -safe
- interp create {a b}
- set l ""
- lappend l [catch {interp hide {a b} list} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {}}
-test interp-20.26 {interp expoose vs safety} {
- catch {interp delete a}
- interp create a -safe
- set l ""
- lappend l [catch {a hide list} msg]
- lappend l $msg
- lappend l [catch {a expose list} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {} 0 {}}
-test interp-20.27 {interp expose vs safety} {
- catch {interp delete a}
- interp create a -safe
- set l ""
- lappend l [catch {interp hide a list} msg]
- lappend l $msg
- lappend l [catch {interp expose a list} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {} 0 {}}
-test interp-20.28 {interp expose vs safety} {
- catch {interp delete a}
- interp create a -safe
- set l ""
- lappend l [catch {a hide list} msg]
- lappend l $msg
- lappend l [catch {a eval {interp expose {} list}} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {} 1 {permission denied: safe interpreter cannot expose commands}}
-test interp-20.29 {interp expose vs safety} {
- catch {interp delete a}
- interp create a -safe
- set l ""
- lappend l [catch {interp hide a list} msg]
- lappend l $msg
- lappend l [catch {a eval {interp expose {} list}} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {} 1 {permission denied: safe interpreter cannot expose commands}}
-test interp-20.30 {interp expose vs safety} {
- catch {interp delete a}
- interp create a -safe
- interp create {a b}
- set l ""
- lappend l [catch {interp hide {a b} list} msg]
- lappend l $msg
- lappend l [catch {a eval {interp expose b list}} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {} 1 {permission denied: safe interpreter cannot expose commands}}
-test interp-20.31 {interp expose vs safety} {
- catch {interp delete a}
- interp create a -safe
- interp create {a b}
- set l ""
- lappend l [catch {interp hide {a b} list} msg]
- lappend l $msg
- lappend l [catch {interp expose {a b} list} msg]
- lappend l $msg
- interp delete a
- set l
-} {0 {} 0 {}}
-test interp-20.32 {interp invokehidden vs safety} {
- catch {interp delete a}
- interp create a -safe
- interp hide a list
- set l ""
- lappend l [catch {a eval {interp invokehidden {} list a b c}} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {not allowed to invoke hidden commands from safe interpreter}}
-test interp-20.33 {interp invokehidden vs safety} {
- catch {interp delete a}
- interp create a -safe
- interp hide a list
- set l ""
- lappend l [catch {a eval {interp invokehidden {} list a b c}} msg]
- lappend l $msg
- lappend l [catch {a invokehidden list a b c} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {not allowed to invoke hidden commands from safe interpreter}\
-0 {a b c}}
-test interp-20.34 {interp invokehidden vs safety} {
- catch {interp delete a}
- interp create a -safe
- interp create {a b}
- interp hide {a b} list
- set l ""
- lappend l [catch {a eval {interp invokehidden b list a b c}} msg]
- lappend l $msg
- lappend l [catch {interp invokehidden {a b} list a b c} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {not allowed to invoke hidden commands from safe interpreter}\
-0 {a b c}}
-test interp-20.35 {invokehidden at local level} {
- catch {interp delete a}
- interp create a
- a eval {
- proc p1 {} {
- set z 90
- a1
- set z
- }
- proc h1 {} {
- upvar z z
- set z 91
- }
- }
- a hide h1
- a alias a1 a1
- proc a1 {} {
- interp invokehidden a h1
- }
- set r [interp eval a p1]
- interp delete a
- set r
-} 91
-test interp-20.36 {invokehidden at local level} {
- catch {interp delete a}
- interp create a
- a eval {
- set z 90
- proc p1 {} {
- global z
- a1
- set z
- }
- proc h1 {} {
- upvar z z
- set z 91
- }
- }
- a hide h1
- a alias a1 a1
- proc a1 {} {
- interp invokehidden a h1
- }
- set r [interp eval a p1]
- interp delete a
- set r
-} 91
-test interp-20.37 {invokehidden at local level} {
- catch {interp delete a}
- interp create a
- a eval {
- proc p1 {} {
- a1
- set z
- }
- proc h1 {} {
- upvar z z
- set z 91
- }
- }
- a hide h1
- a alias a1 a1
- proc a1 {} {
- interp invokehidden a h1
- }
- set r [interp eval a p1]
- interp delete a
- set r
-} 91
-test interp-20.38 {invokehidden at global level} {
- catch {interp delete a}
- interp create a
- a eval {
- proc p1 {} {
- a1
- set z
- }
- proc h1 {} {
- upvar z z
- set z 91
- }
- }
- a hide h1
- a alias a1 a1
- proc a1 {} {
- interp invokehidden a -global h1
- }
- set r [catch {interp eval a p1} msg]
- interp delete a
- list $r $msg
-} {1 {can't read "z": no such variable}}
-test interp-20.39 {invokehidden at global level} {
- catch {interp delete a}
- interp create a
- a eval {
- proc p1 {} {
- global z
- a1
- set z
- }
- proc h1 {} {
- upvar z z
- set z 91
- }
- }
- a hide h1
- a alias a1 a1
- proc a1 {} {
- interp invokehidden a -global h1
- }
- set r [catch {interp eval a p1} msg]
- interp delete a
- list $r $msg
-} {0 91}
-test interp-20.40 {safe, invokehidden at local level} {
- catch {interp delete a}
- interp create a -safe
- a eval {
- proc p1 {} {
- set z 90
- a1
- set z
- }
- proc h1 {} {
- upvar z z
- set z 91
- }
- }
- a hide h1
- a alias a1 a1
- proc a1 {} {
- interp invokehidden a h1
- }
- set r [interp eval a p1]
- interp delete a
- set r
-} 91
-test interp-20.41 {safe, invokehidden at local level} {
- catch {interp delete a}
- interp create a -safe
- a eval {
- set z 90
- proc p1 {} {
- global z
- a1
- set z
- }
- proc h1 {} {
- upvar z z
- set z 91
- }
- }
- a hide h1
- a alias a1 a1
- proc a1 {} {
- interp invokehidden a h1
- }
- set r [interp eval a p1]
- interp delete a
- set r
-} 91
-test interp-20.42 {safe, invokehidden at local level} {
- catch {interp delete a}
- interp create a -safe
- a eval {
- proc p1 {} {
- a1
- set z
- }
- proc h1 {} {
- upvar z z
- set z 91
- }
- }
- a hide h1
- a alias a1 a1
- proc a1 {} {
- interp invokehidden a h1
- }
- set r [interp eval a p1]
- interp delete a
- set r
-} 91
-test interp-20.43 {invokehidden at global level} {
- catch {interp delete a}
- interp create a
- a eval {
- proc p1 {} {
- a1
- set z
- }
- proc h1 {} {
- upvar z z
- set z 91
- }
- }
- a hide h1
- a alias a1 a1
- proc a1 {} {
- interp invokehidden a -global h1
- }
- set r [catch {interp eval a p1} msg]
- interp delete a
- list $r $msg
-} {1 {can't read "z": no such variable}}
-test interp-20.44 {invokehidden at global level} {
- catch {interp delete a}
- interp create a
- a eval {
- proc p1 {} {
- global z
- a1
- set z
- }
- proc h1 {} {
- upvar z z
- set z 91
- }
- }
- a hide h1
- a alias a1 a1
- proc a1 {} {
- interp invokehidden a -global h1
- }
- set r [catch {interp eval a p1} msg]
- interp delete a
- list $r $msg
-} {0 91}
-test interp-20.45 {interp hide vs namespaces} {
- catch {interp delete a}
- interp create a
- a eval {
- namespace eval foo {}
- proc foo::x {} {}
- }
- set l [list [catch {interp hide a foo::x} msg] $msg]
- interp delete a
- set l
-} {1 {cannot use namespace qualifiers as hidden commandtoken (rename)}}
-test interp-20.46 {interp hide vs namespaces} {
- catch {interp delete a}
- interp create a
- a eval {
- namespace eval foo {}
- proc foo::x {} {}
- }
- set l [list [catch {interp hide a foo::x x} msg] $msg]
- interp delete a
- set l
-} {1 {can only hide global namespace commands (use rename then hide)}}
-test interp-20.47 {interp hide vs namespaces} {
- catch {interp delete a}
- interp create a
- a eval {
- proc x {} {}
- }
- set l [list [catch {interp hide a x foo::x} msg] $msg]
- interp delete a
- set l
-} {1 {cannot use namespace qualifiers as hidden commandtoken (rename)}}
-test interp-20.48 {interp hide vs namespaces} {
- catch {interp delete a}
- interp create a
- a eval {
- namespace eval foo {}
- proc foo::x {} {}
- }
- set l [list [catch {interp hide a foo::x bar::x} msg] $msg]
- interp delete a
- set l
-} {1 {cannot use namespace qualifiers as hidden commandtoken (rename)}}
-
-test interp-21.1 {interp hidden} {
- interp hidden {}
-} ""
-test interp-21.2 {interp hidden} {
- interp hidden
-} ""
-test interp-21.3 {interp hidden vs interp hide, interp expose} {
- set l ""
- lappend l [interp hidden]
- interp hide {} pwd
- lappend l [interp hidden]
- interp expose {} pwd
- lappend l [interp hidden]
- set l
-} {{} pwd {}}
-test interp-21.4 {interp hidden} {
- catch {interp delete a}
- interp create a
- set l [interp hidden a]
- interp delete a
- set l
-} ""
-test interp-21.5 {interp hidden} {
- catch {interp delete a}
- interp create -safe a
- set l [lsort [interp hidden a]]
- interp delete a
- set l
-} $hidden_cmds
-test interp-21.6 {interp hidden vs interp hide, interp expose} {
- catch {interp delete a}
- interp create a
- set l ""
- lappend l [interp hidden a]
- interp hide a pwd
- lappend l [interp hidden a]
- interp expose a pwd
- lappend l [interp hidden a]
- interp delete a
- set l
-} {{} pwd {}}
-test interp-21.7 {interp hidden} {
- catch {interp delete a}
- interp create a
- set l [a hidden]
- interp delete a
- set l
-} ""
-test interp-21.8 {interp hidden} {
- catch {interp delete a}
- interp create a -safe
- set l [lsort [a hidden]]
- interp delete a
- set l
-} $hidden_cmds
-test interp-21.9 {interp hidden vs interp hide, interp expose} {
- catch {interp delete a}
- interp create a
- set l ""
- lappend l [a hidden]
- a hide pwd
- lappend l [a hidden]
- a expose pwd
- lappend l [a hidden]
- interp delete a
- set l
-} {{} pwd {}}
-
-test interp-22.1 {testing interp marktrusted} {
- catch {interp delete a}
- interp create a
- set l ""
- lappend l [a issafe]
- lappend l [a marktrusted]
- lappend l [a issafe]
- interp delete a
- set l
-} {0 {} 0}
-test interp-22.2 {testing interp marktrusted} {
- catch {interp delete a}
- interp create a
- set l ""
- lappend l [interp issafe a]
- lappend l [interp marktrusted a]
- lappend l [interp issafe a]
- interp delete a
- set l
-} {0 {} 0}
-test interp-22.3 {testing interp marktrusted} {
- catch {interp delete a}
- interp create a -safe
- set l ""
- lappend l [a issafe]
- lappend l [a marktrusted]
- lappend l [a issafe]
- interp delete a
- set l
-} {1 {} 0}
-test interp-22.4 {testing interp marktrusted} {
- catch {interp delete a}
- interp create a -safe
- set l ""
- lappend l [interp issafe a]
- lappend l [interp marktrusted a]
- lappend l [interp issafe a]
- interp delete a
- set l
-} {1 {} 0}
-test interp-22.5 {testing interp marktrusted} {
- catch {interp delete a}
- interp create a -safe
- interp create {a b}
- catch {a eval {interp marktrusted b}} msg
- interp delete a
- set msg
-} {permission denied: safe interpreter cannot mark trusted}
-test interp-22.6 {testing interp marktrusted} {
- catch {interp delete a}
- interp create a -safe
- interp create {a b}
- catch {a eval {b marktrusted}} msg
- interp delete a
- set msg
-} {permission denied: safe interpreter cannot mark trusted}
-test interp-22.7 {testing interp marktrusted} {
- catch {interp delete a}
- interp create a -safe
- set l ""
- lappend l [interp issafe a]
- interp marktrusted a
- interp create {a b}
- lappend l [interp issafe a]
- lappend l [interp issafe {a b}]
- interp delete a
- set l
-} {1 0 0}
-test interp-22.8 {testing interp marktrusted} {
- catch {interp delete a}
- interp create a -safe
- set l ""
- lappend l [interp issafe a]
- interp create {a b}
- lappend l [interp issafe {a b}]
- interp marktrusted a
- interp create {a c}
- lappend l [interp issafe a]
- lappend l [interp issafe {a c}]
- interp delete a
- set l
-} {1 1 0 0}
-test interp-22.9 {testing interp marktrusted} {
- catch {interp delete a}
- interp create a -safe
- set l ""
- lappend l [interp issafe a]
- interp create {a b}
- lappend l [interp issafe {a b}]
- interp marktrusted {a b}
- lappend l [interp issafe a]
- lappend l [interp issafe {a b}]
- interp create {a b c}
- lappend l [interp issafe {a b c}]
- interp delete a
- set l
-} {1 1 1 0 0}
-
-test interp-23.1 {testing hiding vs aliases} {
- catch {interp delete a}
- interp create a
- set l ""
- lappend l [interp hidden a]
- a alias bar bar
- lappend l [interp aliases a]
- lappend l [interp hidden a]
- a hide bar
- lappend l [interp aliases a]
- lappend l [interp hidden a]
- a alias bar {}
- lappend l [interp aliases a]
- lappend l [interp hidden a]
- interp delete a
- set l
-} {{} bar {} bar bar {} {}}
-test interp-23.2 {testing hiding vs aliases} {unixOrPc} {
- catch {interp delete a}
- interp create a -safe
- set l ""
- lappend l [lsort [interp hidden a]]
- a alias bar bar
- lappend l [interp aliases a]
- lappend l [lsort [interp hidden a]]
- a hide bar
- lappend l [interp aliases a]
- lappend l [lsort [interp hidden a]]
- a alias bar {}
- lappend l [interp aliases a]
- lappend l [lsort [interp hidden a]]
- interp delete a
- set l
-} {{cd encoding exec exit fconfigure file glob load open pwd socket source} bar {cd encoding exec exit fconfigure file glob load open pwd socket source} bar {bar cd encoding exec exit fconfigure file glob load open pwd socket source} {} {cd encoding exec exit fconfigure file glob load open pwd socket source}}
-
-test interp-23.3 {testing hiding vs aliases} {macOnly} {
- catch {interp delete a}
- interp create a -safe
- set l ""
- lappend l [lsort [interp hidden a]]
- a alias bar bar
- lappend l [interp aliases a]
- lappend l [lsort [interp hidden a]]
- a hide bar
- lappend l [interp aliases a]
- lappend l [lsort [interp hidden a]]
- a alias bar {}
- lappend l [interp aliases a]
- lappend l [lsort [interp hidden a]]
- interp delete a
- set l
-} {{beep cd echo exit fconfigure file glob load ls open pwd socket source} bar {beep cd echo exit fconfigure file glob load ls open pwd socket source} bar {bar beep cd echo exit fconfigure file glob load ls open pwd socket source} {} {beep cd echo exit fconfigure file glob load ls open pwd socket source}}
-
-test interp-24.1 {result resetting on error} {
- catch {interp delete a}
- interp create a
- proc foo args {error $args}
- interp alias a foo {} foo
- set l [interp eval a {
- set l {}
- lappend l [catch {foo 1 2 3} msg]
- lappend l $msg
- lappend l [catch {foo 3 4 5} msg]
- lappend l $msg
- set l
- }]
- interp delete a
- set l
-} {1 {1 2 3} 1 {3 4 5}}
-test interp-24.2 {result resetting on error} {
- catch {interp delete a}
- interp create a -safe
- proc foo args {error $args}
- interp alias a foo {} foo
- set l [interp eval a {
- set l {}
- lappend l [catch {foo 1 2 3} msg]
- lappend l $msg
- lappend l [catch {foo 3 4 5} msg]
- lappend l $msg
- set l
- }]
- interp delete a
- set l
-} {1 {1 2 3} 1 {3 4 5}}
-test interp-24.3 {result resetting on error} {
- catch {interp delete a}
- interp create a
- interp create {a b}
- interp eval a {
- proc foo args {error $args}
- }
- interp alias {a b} foo a foo
- set l [interp eval {a b} {
- set l {}
- lappend l [catch {foo 1 2 3} msg]
- lappend l $msg
- lappend l [catch {foo 3 4 5} msg]
- lappend l $msg
- set l
- }]
- interp delete a
- set l
-} {1 {1 2 3} 1 {3 4 5}}
-test interp-24.4 {result resetting on error} {
- catch {interp delete a}
- interp create a -safe
- interp create {a b}
- interp eval a {
- proc foo args {error $args}
- }
- interp alias {a b} foo a foo
- set l [interp eval {a b} {
- set l {}
- lappend l [catch {foo 1 2 3} msg]
- lappend l $msg
- lappend l [catch {foo 3 4 5} msg]
- lappend l $msg
- set l
- }]
- interp delete a
- set l
-} {1 {1 2 3} 1 {3 4 5}}
-test interp-24.5 {result resetting on error} {
- catch {interp delete a}
- catch {interp delete b}
- interp create a
- interp create b
- interp eval a {
- proc foo args {error $args}
- }
- interp alias b foo a foo
- set l [interp eval b {
- set l {}
- lappend l [catch {foo 1 2 3} msg]
- lappend l $msg
- lappend l [catch {foo 3 4 5} msg]
- lappend l $msg
- set l
- }]
- interp delete a
- set l
-} {1 {1 2 3} 1 {3 4 5}}
-test interp-24.6 {result resetting on error} {
- catch {interp delete a}
- catch {interp delete b}
- interp create a -safe
- interp create b -safe
- interp eval a {
- proc foo args {error $args}
- }
- interp alias b foo a foo
- set l [interp eval b {
- set l {}
- lappend l [catch {foo 1 2 3} msg]
- lappend l $msg
- lappend l [catch {foo 3 4 5} msg]
- lappend l $msg
- set l
- }]
- interp delete a
- set l
-} {1 {1 2 3} 1 {3 4 5}}
-test interp-24.7 {result resetting on error} {
- catch {interp delete a}
- interp create a
- interp eval a {
- proc foo args {error $args}
- }
- set l {}
- lappend l [catch {interp eval a foo 1 2 3} msg]
- lappend l $msg
- lappend l [catch {interp eval a foo 3 4 5} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {1 2 3} 1 {3 4 5}}
-test interp-24.8 {result resetting on error} {
- catch {interp delete a}
- interp create a -safe
- interp eval a {
- proc foo args {error $args}
- }
- set l {}
- lappend l [catch {interp eval a foo 1 2 3} msg]
- lappend l $msg
- lappend l [catch {interp eval a foo 3 4 5} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {1 2 3} 1 {3 4 5}}
-test interp-24.9 {result resetting on error} {
- catch {interp delete a}
- interp create a
- interp create {a b}
- interp eval {a b} {
- proc foo args {error $args}
- }
- interp eval a {
- proc foo args {
- eval interp eval b foo $args
- }
- }
- set l {}
- lappend l [catch {interp eval a foo 1 2 3} msg]
- lappend l $msg
- lappend l [catch {interp eval a foo 3 4 5} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {1 2 3} 1 {3 4 5}}
-test interp-24.10 {result resetting on error} {
- catch {interp delete a}
- interp create a -safe
- interp create {a b}
- interp eval {a b} {
- proc foo args {error $args}
- }
- interp eval a {
- proc foo args {
- eval interp eval b foo $args
- }
- }
- set l {}
- lappend l [catch {interp eval a foo 1 2 3} msg]
- lappend l $msg
- lappend l [catch {interp eval a foo 3 4 5} msg]
- lappend l $msg
- interp delete a
- set l
-} {1 {1 2 3} 1 {3 4 5}}
-test interp-24.11 {result resetting on error} {
- catch {interp delete a}
- interp create a
- interp create {a b}
- interp eval {a b} {
- proc foo args {error $args}
- }
- interp eval a {
- proc foo args {
- set l {}
- lappend l [catch {eval interp eval b foo $args} msg]
- lappend l $msg
- lappend l [catch {eval interp eval b foo $args} msg]
- lappend l $msg
- set l
- }
- }
- set l [interp eval a foo 1 2 3]
- interp delete a
- set l
-} {1 {1 2 3} 1 {1 2 3}}
-test interp-24.12 {result resetting on error} {
- catch {interp delete a}
- interp create a -safe
- interp create {a b}
- interp eval {a b} {
- proc foo args {error $args}
- }
- interp eval a {
- proc foo args {
- set l {}
- lappend l [catch {eval interp eval b foo $args} msg]
- lappend l $msg
- lappend l [catch {eval interp eval b foo $args} msg]
- lappend l $msg
- set l
- }
- }
- set l [interp eval a foo 1 2 3]
- interp delete a
- set l
-} {1 {1 2 3} 1 {1 2 3}}
-
-unset hidden_cmds
-
-test interp-25.1 {testing aliasing of string commands} {
- catch {interp delete a}
- interp create a
- a alias exec foo ;# Relies on exec being a string command!
- interp delete a
-} ""
-
-
-#
-# Interps result transmission
-#
-
-test interp-26.1 {result code transmission : interp eval direct} {
- # Test that all the possibles error codes from Tcl get passed up
- # from the slave interp's context to the master, even though the
- # slave nominally thinks the command is running at the root level.
-
- catch {interp delete a}
- interp create a
- set res {}
- # use a for so if a return -code break 'escapes' we would notice
- for {set code -1} {$code<=5} {incr code} {
- lappend res [catch {interp eval a return -code $code} msg]
- }
- interp delete a
- set res
-} {-1 0 1 2 3 4 5}
-
-
-test interp-26.2 {result code transmission : interp eval indirect} {
- # retcode == 2 == return is special
- catch {interp delete a}
- interp create a
- interp eval a {proc retcode {code} {return -code $code ret$code}}
- set res {}
- # use a for so if a return -code break 'escapes' we would notice
- for {set code -1} {$code<=5} {incr code} {
- lappend res [catch {interp eval a retcode $code} msg] $msg
- }
- interp delete a
- set res
-} {-1 ret-1 0 ret0 1 ret1 0 ret2 3 ret3 4 ret4 5 ret5}
-
-test interp-26.3 {result code transmission : aliases} {
- # Test that all the possibles error codes from Tcl get passed up
- # from the slave interp's context to the master, even though the
- # slave nominally thinks the command is running at the root level.
-
- catch {interp delete a}
- interp create a
- set res {}
- proc MyTestAlias {code} {
- return -code $code ret$code
- }
- interp alias a Test {} MyTestAlias
- for {set code -1} {$code<=5} {incr code} {
- lappend res [interp eval a [list catch [list Test $code] msg]]
- }
- interp delete a
- set res
-} {-1 0 1 2 3 4 5}
-
-test interp-26.4 {result code transmission: invoke hidden direct--bug 1637} \
- {knownBug} {
- # The known bug is that code 2 is returned, not the -code argument
- catch {interp delete a}
- interp create a
- set res {}
- interp hide a return
- for {set code -1} {$code<=5} {incr code} {
- lappend res [catch {interp invokehidden a return -code $code ret$code}]
- }
- interp delete a
- set res
-} {-1 0 1 2 3 4 5}
-
-test interp-26.5 {result code transmission: invoke hidden indirect--bug 1637} \
- {knownBug} {
- # The known bug is that the break and continue should raise errors
- # that they are used outside a loop.
- catch {interp delete a}
- interp create a
- set res {}
- interp eval a {proc retcode {code} {return -code $code ret$code}}
- interp hide a retcode
- for {set code -1} {$code<=5} {incr code} {
- lappend res [catch {interp invokehidden a retcode $code} msg] $msg
- }
- interp delete a
- set res
-} {-1 ret-1 0 ret0 1 ret1 0 ret2 3 ret3 4 ret4 5 ret5}
-
-test interp-26.6 {result code transmission: all combined--bug 1637} \
- {knownBug} {
- # Test that all the possibles error codes from Tcl get passed
- # In both directions. This doesn't work.
- set interp [interp create];
- proc MyTestAlias {interp args} {
- global aliasTrace;
- lappend aliasTrace $args;
- eval interp invokehidden [list $interp] $args
- }
- foreach c {return} {
- interp hide $interp $c;
- interp alias $interp $c {} MyTestAlias $interp $c;
- }
- interp eval $interp {proc ret {code} {return -code $code ret$code}}
- set res {}
- set aliasTrace {}
- for {set code -1} {$code<=5} {incr code} {
- lappend res [catch {interp eval $interp ret $code} msg] $msg
- }
- interp delete $interp;
- set res
-} {-1 ret-1 0 ret0 1 ret1 0 ret2 3 ret3 4 ret4 5 ret5}
-
-# Some tests might need to be added to check for difference between
-# toplevel and non toplevel evals.
-
-# End of return code transmission section
-
-test interp-26.7 {errorInfo transmission: regular interps} {
- set interp [interp create];
- proc MyError {secret} {
- return -code error "msg"
- }
- proc MyTestAlias {interp args} {
- MyError "some secret"
- }
- interp alias $interp test {} MyTestAlias $interp;
- set res [interp eval $interp {catch test;set errorInfo}]
- interp delete $interp;
- set res
-} {msg
- while executing
-"MyError "some secret""
- (procedure "MyTestAlias" line 2)
- invoked from within
-"test"}
-
-test interp-26.8 {errorInfo transmission: safe interps--bug 1637} {knownBug} {
- # this test fails because the errorInfo is fully transmitted
- # whether the interp is safe or not. The errorInfo should never
- # report data from the master interpreter because it could
- # contain sensitive information.
- set interp [interp create -safe];
- proc MyError {secret} {
- return -code error "msg"
- }
- proc MyTestAlias {interp args} {
- MyError "some secret"
- }
- interp alias $interp test {} MyTestAlias $interp;
- set res [interp eval $interp {catch test;set errorInfo}]
- interp delete $interp;
- set res
-} {msg
- while executing
-"test"}
-
-# Interps & Namespaces
-test interp-27.1 {interp aliases & namespaces} {
- set i [interp create];
- set aliasTrace {};
- proc tstAlias {args} {
- global aliasTrace;
- lappend aliasTrace [list [namespace current] $args];
- }
- $i alias foo::bar tstAlias foo::bar;
- $i eval foo::bar test
- interp delete $i
- set aliasTrace;
-} {{:: {foo::bar test}}}
-
-test interp-27.2 {interp aliases & namespaces} {
- set i [interp create];
- set aliasTrace {};
- proc tstAlias {args} {
- global aliasTrace;
- lappend aliasTrace [list [namespace current] $args];
- }
- $i alias foo::bar tstAlias foo::bar;
- $i eval namespace eval foo {bar test}
- interp delete $i
- set aliasTrace;
-} {{:: {foo::bar test}}}
-
-test interp-27.3 {interp aliases & namespaces} {
- set i [interp create];
- set aliasTrace {};
- proc tstAlias {args} {
- global aliasTrace;
- lappend aliasTrace [list [namespace current] $args];
- }
- interp eval $i {namespace eval foo {proc bar {} {error "bar called"}}}
- interp alias $i foo::bar {} tstAlias foo::bar;
- interp eval $i {namespace eval foo {bar test}}
- interp delete $i
- set aliasTrace;
-} {{:: {foo::bar test}}}
-
-test interp-27.4 {interp aliases & namespaces} {
- set i [interp create];
- namespace eval foo2 {
- variable aliasTrace {};
- proc bar {args} {
- variable aliasTrace;
- lappend aliasTrace [list [namespace current] $args];
- }
- }
- $i alias foo::bar foo2::bar foo::bar;
- $i eval namespace eval foo {bar test}
- set r $foo2::aliasTrace;
- namespace delete foo2;
- set r
-} {{::foo2 {foo::bar test}}}
-
-# the following tests are commented out while we don't support
-# hiding in namespaces
-
-# test interp-27.5 {interp hidden & namespaces} {
-# set i [interp create];
-# interp eval $i {
-# namespace eval foo {
-# proc bar {args} {
-# return "bar called ([namespace current]) ($args)"
-# }
-# }
-# }
-# set res [list [interp eval $i {namespace eval foo {bar test1}}]]
-# interp hide $i foo::bar;
-# lappend res [list [catch {interp eval $i {namespace eval foo {bar test2}}} msg] $msg]
-# interp delete $i;
-# set res;
-#} {{bar called (::foo) (test1)} {1 {invalid command name "bar"}}}
-
-# test interp-27.6 {interp hidden & aliases & namespaces} {
-# set i [interp create];
-# set v root-master;
-# namespace eval foo {
-# variable v foo-master;
-# proc bar {interp args} {
-# variable v;
-# list "master bar called ($v) ([namespace current]) ($args)"\
-# [interp invokehidden $interp foo::bar $args];
-# }
-# }
-# interp eval $i {
-# namespace eval foo {
-# namespace export *
-# variable v foo-slave;
-# proc bar {args} {
-# variable v;
-# return "slave bar called ($v) ([namespace current]) ($args)"
-# }
-# }
-# }
-# set res [list [interp eval $i {namespace eval foo {bar test1}}]]
-# $i hide foo::bar;
-# $i alias foo::bar foo::bar $i;
-# set res [concat $res [interp eval $i {
-# set v root-slave;
-# namespace eval test {
-# variable v foo-test;
-# namespace import ::foo::*;
-# bar test2
-# }
-# }]]
-# namespace delete foo;
-# interp delete $i;
-# set res
-# } {{slave bar called (foo-slave) (::foo) (test1)} {master bar called (foo-master) (::foo) (test2)} {slave bar called (foo-slave) (::foo) (test2)}}
-
-
-# test interp-27.7 {interp hidden & aliases & imports & namespaces} {
-# set i [interp create];
-# set v root-master;
-# namespace eval mfoo {
-# variable v foo-master;
-# proc bar {interp args} {
-# variable v;
-# list "master bar called ($v) ([namespace current]) ($args)"\
-# [interp invokehidden $interp test::bar $args];
-# }
-# }
-# interp eval $i {
-# namespace eval foo {
-# namespace export *
-# variable v foo-slave;
-# proc bar {args} {
-# variable v;
-# return "slave bar called ($v) ([info level 0]) ([uplevel namespace current]) ([namespace current]) ($args)"
-# }
-# }
-# set v root-slave;
-# namespace eval test {
-# variable v foo-test;
-# namespace import ::foo::*;
-# }
-# }
-# set res [list [interp eval $i {namespace eval test {bar test1}}]]
-# $i hide test::bar;
-# $i alias test::bar mfoo::bar $i;
-# set res [concat $res [interp eval $i {test::bar test2}]];
-# namespace delete mfoo;
-# interp delete $i;
-# set res
-# } {{slave bar called (foo-slave) (bar test1) (::tcltest) (::foo) (test1)} {master bar called (foo-master) (::mfoo) (test2)} {slave bar called (foo-slave) (test::bar test2) (::) (::foo) (test2)}}
-
-#test interp-27.8 {hiding, namespaces and integrity} {
-# namespace eval foo {
-# variable v 3;
-# proc bar {} {variable v; set v}
-# # next command would currently generate an unknown command "bar" error.
-# interp hide {} bar;
-# }
-# namespace delete foo;
-# list [catch {interp invokehidden {} foo} msg] $msg;
-#} {1 {invalid hidden command name "foo"}}
-
-
-test interp-28.1 {getting fooled by slave's namespace ?} {
- set i [interp create -safe];
- proc master {interp args} {interp hide $interp list}
- $i alias master master $i;
- set r [interp eval $i {
- namespace eval foo {
- proc list {args} {
- return "dummy foo::list";
- }
- master;
- }
- info commands list
- }]
- interp delete $i;
- set r
-} {}
-
-# Tests of recursionlimit
-# We need testsetrecursionlimit so we need Tcltest package
-if {[catch {package require Tcltest} msg]} {
- puts "This application hasn't been compiled with Tcltest"
- puts "skipping remining interp tests that relies on it."
-} else {
- #
-test interp-29.1 {recursion limit} {
- set i [interp create]
- load {} Tcltest $i
- set r [interp eval $i {
- testsetrecursionlimit 50
- proc p {} {incr ::i; p}
- set i 0
- catch p
- set i
- }]
- interp delete $i
- set r
-} 49
-
-test interp-29.2 {recursion limit inheritance} {
- set i [interp create]
- load {} Tcltest $i
- set ii [interp eval $i {
- testsetrecursionlimit 50
- interp create
- }]
- set r [interp eval [list $i $ii] {
- proc p {} {incr ::i; p}
- set i 0
- catch p
- set i
- }]
- interp delete $i
- set r
-} 49
-
-# # Deep recursion (into interps when the regular one fails):
-# # still crashes...
-# proc p {} {
-# if {[catch p ret]} {
-# catch {
-# set i [interp create]
-# interp eval $i [list proc p {} [info body p]]
-# interp eval $i p
-# }
-# interp delete $i
-# return ok
-# }
-# return $ret
-# }
-# p
-
-# more tests needed...
-
-# Interp & stack
-#test interp-29.1 {interp and stack (info level)} {
-#} {}
-
-# End of stack-recursion tests
-}
-
-# This test dumps core in Tcl 8.0.3!
-test interp-30.1 {deletion of aliases inside namespaces} {
- set i [interp create]
- $i alias ns::cmd list
- $i alias ns::cmd {}
-} {}
-
-test interp-31.1 {alias invocation scope} {
- proc mySet {varName value} {
- upvar 1 $varName localVar
- set localVar $value
- }
-
- interp alias {} myNewSet {} mySet
- proc testMyNewSet {value} {
- myNewSet a $value
- return $a
- }
- catch {unset a}
- set result [testMyNewSet "ok"]
- rename testMyNewSet {}
- rename mySet {}
- rename myNewSet {}
- set result
-} ok
-
-# cleanup
-foreach i [interp slaves] {
- interp delete $i
-}
-::tcltest::cleanupTests
-return
diff --git a/tests/io.test b/tests/io.test
deleted file mode 100644
index 620bc48..0000000
--- a/tests/io.test
+++ /dev/null
@@ -1,6809 +0,0 @@
-# Functionality covered: operation of all IO commands, and all procedures
-# defined in generic/tclIO.c.
-#
-# 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) 1991-1994 The Regents of the University of California.
-# Copyright (c) 1994-1997 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: io.test,v 1.7 1999/04/16 00:47:29 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {"[info commands testchannel]" != "testchannel"} {
- puts "Skipping io tests. This application does not seem to have the"
- puts "testchannel command that is needed to run these tests."
- return
-}
-
-::tcltest::saveState
-
-removeFile test1
-removeFile pipe
-
-# set up a long data file for some of the following tests
-
-set f [open longfile w]
-fconfigure $f -eofchar {} -translation lf
-for { set i 0 } { $i < 100 } { incr i} {
- puts $f "#123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
-\#123456789abcdef01
-\#"
- }
-close $f
-
-makeFile {
- set f stdin
- if {$argv != ""} {
- set f [open $argv]
- }
- fconfigure $f -encoding binary -translation lf -blocking 0 -eofchar \x1a
- fconfigure stdout -encoding binary -translation lf -buffering none
- fileevent $f readable "foo $f"
- proc foo {f} {
- set x [read $f]
- catch {puts -nonewline $x}
- if {[eof $f]} {
- close $f
- exit 0
- }
- }
- vwait forever
-} cat
-
-set thisScript [file join [pwd] [info script]]
-
-# These tests are disabled until we decide what to do with "unsupported0".
-#
-test io-1.1 {unsupported0 command} {knownBug} {
- removeFile test1
- set f1 [open iocmd.test]
- set f2 [open test1 w]
- unsupported0 $f1 $f2
- close $f1
- catch {close $f2}
- set s1 [file size $thisScript]
- set s2 [file size test1]
- set x ok
- if {"$s1" != "$s2"} {
- set x broken
- }
- set x
-} ok
-test io-1.2 {unsupported0 command} {knownBug} {
- removeFile test1
- set f1 [open $thisScript]
- set f2 [open test1 w]
- unsupported0 $f1 $f2 40
- close $f1
- close $f2
- file size test1
-} 40
-test io-1.3 {unsupported0 command} {knownBug} {
- removeFile test1
- set f1 [open $thisScript]
- set f2 [open test1 w]
- unsupported0 $f1 $f2 -1
- close $f1
- close $f2
- set x ok
- set s1 [file size $thisScript]
- set s2 [file size test1]
- if {$s1 != $s2} {
- set x broken
- }
- set x
-} ok
-test io-1.4 {unsupported0 command} {knownBug unixOrPc} {
- removeFile pipe
- removeFile test1
- set f1 [open pipe w]
- puts $f1 {puts ready}
- puts $f1 {gets stdin}
- puts $f1 {set f1 [open $thisScript r]}
- puts $f1 {puts [read $f1 100]}
- puts $f1 {close $f1}
- close $f1
- set f1 [open "|[list $tcltest pipe]" r+]
- gets $f1
- puts $f1 ready
- flush $f1
- set f2 [open test1 w]
- set c [unsupported0 $f1 $f2 40]
- catch {close $f1}
- close $f2
- set s1 [file size test1]
- set x ok
- if {$s1 != "40"} {
- set x broken
- }
- list $c $x
-} {40 ok}
-
-proc contents {file} {
- set f [open $file]
- fconfigure $f -translation binary
- set a [read $f]
- close $f
- return $a
-}
-
-test io-1.5 {Tcl_WriteChars: CheckChannelErrors} {emptyTest} {
- # no test, need to cause an async error.
-} {}
-test io-1.6 {Tcl_WriteChars: WriteBytes} {
- set f [open test1 w]
- fconfigure $f -encoding binary
- puts -nonewline $f "a\u4e4d\0"
- close $f
- contents test1
-} "a\x4d\x00"
-test io-1.7 {Tcl_WriteChars: WriteChars} {
- set f [open test1 w]
- fconfigure $f -encoding shiftjis
- puts -nonewline $f "a\u4e4d\0"
- close $f
- contents test1
-} "a\x93\xe1\x00"
-
-test io-2.1 {WriteBytes} {
- # loop until all bytes are written
-
- set f [open test1 w]
- fconfigure $f -encoding binary -buffersize 16 -translation crlf
- puts $f "abcdefghijklmnopqrstuvwxyz"
- close $f
- contents test1
-} "abcdefghijklmnopqrstuvwxyz\r\n"
-test io-2.2 {WriteBytes: savedLF > 0} {
- # After flushing buffer, there was a \n left over from the last
- # \n -> \r\n expansion. It gets stuck at beginning of this buffer.
-
- set f [open test1 w]
- fconfigure $f -encoding binary -buffersize 16 -translation crlf
- puts -nonewline $f "123456789012345\n12"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "123456789012345\r" "123456789012345\r\n12"]
-test io-2.3 {WriteBytes: flush on line} {
- # Tcl "line" buffering has weird behavior: if current buffer contains
- # a \n, entire buffer gets flushed. Logical behavior would be to flush
- # only up to the \n.
-
- set f [open test1 w]
- fconfigure $f -encoding binary -buffering line -translation crlf
- puts -nonewline $f "\n12"
- set x [contents test1]
- close $f
- set x
-} "\r\n12"
-test io-2.4 {WriteBytes: reset sawLF after each buffer} {
- set f [open test1 w]
- fconfigure $f -encoding binary -buffering line -translation lf \
- -buffersize 16
- puts -nonewline $f "abcdefg\nhijklmnopqrstuvwxyz"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "abcdefg\nhijklmno" "abcdefg\nhijklmnopqrstuvwxyz"]
-
-test io-3.1 {WriteChars: compatibility with WriteBytes} {
- # loop until all bytes are written
-
- set f [open test1 w]
- fconfigure $f -encoding ascii -buffersize 16 -translation crlf
- puts $f "abcdefghijklmnopqrstuvwxyz"
- close $f
- contents test1
-} "abcdefghijklmnopqrstuvwxyz\r\n"
-test io-3.2 {WriteChars: compatibility with WriteBytes: savedLF > 0} {
- # After flushing buffer, there was a \n left over from the last
- # \n -> \r\n expansion. It gets stuck at beginning of this buffer.
-
- set f [open test1 w]
- fconfigure $f -encoding ascii -buffersize 16 -translation crlf
- puts -nonewline $f "123456789012345\n12"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "123456789012345\r" "123456789012345\r\n12"]
-test io-3.3 {WriteChars: compatibility with WriteBytes: flush on line} {
- # Tcl "line" buffering has weird behavior: if current buffer contains
- # a \n, entire buffer gets flushed. Logical behavior would be to flush
- # only up to the \n.
-
- set f [open test1 w]
- fconfigure $f -encoding ascii -buffering line -translation crlf
- puts -nonewline $f "\n12"
- set x [contents test1]
- close $f
- set x
-} "\r\n12"
-test io-3.4 {WriteChars: loop over stage buffer} {
- # stage buffer maps to more than can be queued at once.
-
- set f [open test1 w]
- fconfigure $f -encoding jis0208 -buffersize 16
- puts -nonewline $f "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "!)!)!)!)!)!)!)!)" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
-test io-3.5 {WriteChars: saved != 0} {
- # Bytes produced by UtfToExternal from end of last channel buffer
- # had to be moved to beginning of next channel buffer to preserve
- # requested buffersize.
-
- set f [open test1 w]
- fconfigure $f -encoding jis0208 -buffersize 17
- puts -nonewline $f "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
-test io-3.6 {WriteChars: (stageRead + dstWrote == 0)} {
- # One incomplete UTF-8 character at end of staging buffer. Backup
- # in src to the beginning of that UTF-8 character and try again.
- #
- # Translate the first 16 bytes, produce 14 bytes of output, 2 left over
- # (first two bytes of \uff21 in UTF-8). Given those two bytes try
- # translating them again, find that no bytes are read produced, and break
- # to outer loop where those two bytes will have the remaining 4 bytes
- # (the last byte of \uff21 plus the all of \uff22) appended.
-
- set f [open test1 w]
- fconfigure $f -encoding shiftjis -buffersize 16
- puts -nonewline $f "12345678901234\uff21\uff22"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "12345678901234\x82\x60" "12345678901234\x82\x60\x82\x61"]
-test io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} {
- # When translating UTF-8 to external, the produced bytes went past end
- # of the channel buffer. This is done purpose -- we then truncate the
- # bytes at the end of the partial character to preserve the requested
- # blocksize on flush. The truncated bytes are moved to the beginning
- # of the next channel buffer.
-
- set f [open test1 w]
- fconfigure $f -encoding jis0208 -buffersize 17
- puts -nonewline $f "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "!)!)!)!)!)!)!)!)!" "!)!)!)!)!)!)!)!)!)!)!)!)!)!)!)"]
-test io-3.8 {WriteChars: reset sawLF after each buffer} {
- set f [open test1 w]
- fconfigure $f -encoding ascii -buffering line -translation lf \
- -buffersize 16
- puts -nonewline $f "abcdefg\nhijklmnopqrstuvwxyz"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "abcdefg\nhijklmno" "abcdefg\nhijklmnopqrstuvwxyz"]
-
-test io-4.1 {TranslateOutputEOL: lf} {
- # search for \n
-
- set f [open test1 w]
- fconfigure $f -buffering line -translation lf
- puts $f "abcde"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "abcde\n" "abcde\n"]
-test io-4.2 {TranslateOutputEOL: cr} {
- # search for \n, replace with \r
-
- set f [open test1 w]
- fconfigure $f -buffering line -translation cr
- puts $f "abcde"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "abcde\r" "abcde\r"]
-test io-4.3 {TranslateOutputEOL: crlf} {
- # simple case: search for \n, replace with \r
-
- set f [open test1 w]
- fconfigure $f -buffering line -translation crlf
- puts $f "abcde"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "abcde\r\n" "abcde\r\n"]
-test io-4.4 {TranslateOutputEOL: crlf} {
- # keep storing more bytes in output buffer until output buffer is full.
- # We have 13 bytes initially that would turn into 18 bytes. Fill
- # dest buffer while (dstEnd < dstMax).
-
- set f [open test1 w]
- fconfigure $f -translation crlf -buffersize 16
- puts -nonewline $f "1234567\n\n\n\n\nA"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "1234567\r\n\r\n\r\n\r\n\r" "1234567\r\n\r\n\r\n\r\n\r\nA"]
-test io-4.5 {TranslateOutputEOL: crlf} {
- # Check for overflow of the destination buffer
-
- set f [open test1 w]
- fconfigure $f -translation crlf -buffersize 12
- puts -nonewline $f "12345678901\n456789012345678901234"
- close $f
- set x [contents test1]
-} "12345678901\r\n456789012345678901234"
-
-test io-5.1 {CheckFlush: not full} {
- set f [open test1 w]
- fconfigure $f
- puts -nonewline $f "12345678901234567890"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "" "12345678901234567890"]
-test io-5.2 {CheckFlush: full} {
- set f [open test1 w]
- fconfigure $f -buffersize 16
- puts -nonewline $f "12345678901234567890"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "1234567890123456" "12345678901234567890"]
-test io-5.3 {CheckFlush: not line} {
- set f [open test1 w]
- fconfigure $f -buffering line
- puts -nonewline $f "12345678901234567890"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "" "12345678901234567890"]
-test io-5.4 {CheckFlush: line} {
- set f [open test1 w]
- fconfigure $f -buffering line -translation lf -encoding ascii
- puts -nonewline $f "1234567890\n1234567890"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "1234567890\n1234567890" "1234567890\n1234567890"]
-test io-5.5 {CheckFlush: none} {
- set f [open test1 w]
- fconfigure $f -buffering none
- puts -nonewline $f "1234567890"
- set x [list [contents test1]]
- close $f
- lappend x [contents test1]
-} [list "1234567890" "1234567890"]
-
-test io-6.1 {Tcl_GetsObj: working} {
- set f [open test1 w]
- puts $f "foo\nboo"
- close $f
- set f [open test1]
- set x [gets $f]
- close $f
- set x
-} {foo}
-test io-6.2 {Tcl_GetsObj: CheckChannelErrors() != 0} {
- # no test, need to cause an async error.
-} {}
-test io-6.3 {Tcl_GetsObj: how many have we used?} {
- # if (bufPtr != NULL) {oldRemoved = bufPtr->nextRemoved}
-
- set f [open test1 w]
- fconfigure $f -translation crlf
- puts $f "abc\ndefg"
- close $f
- set f [open test1]
- set x [list [tell $f] [gets $f line] [tell $f] [gets $f line] $line]
- close $f
- set x
-} {0 3 5 4 defg}
-test io-6.4 {Tcl_GetsObj: encoding == NULL} {
- set f [open test1 w]
- fconfigure $f -translation binary
- puts $f "\x81\u1234\0"
- close $f
- set f [open test1]
- fconfigure $f -translation binary
- set x [list [gets $f line] $line]
- close $f
- set x
-} [list 3 "\x81\x34\x00"]
-test io-6.5 {Tcl_GetsObj: encoding != NULL} {
- set f [open test1 w]
- fconfigure $f -translation binary
- puts $f "\x88\xea\x92\x9a"
- close $f
- set f [open test1]
- fconfigure $f -encoding shiftjis
- set x [list [gets $f line] $line]
- close $f
- set x
-} [list 2 "\u4e00\u4e01"]
-set a "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-append a $a
-append a $a
-test io-6.6 {Tcl_GetsObj: loop test} {
- # if (dst >= dstEnd)
-
- set f [open test1 w]
- puts $f $a
- puts $f hi
- close $f
- set f [open test1]
- set x [list [gets $f line] $line]
- close $f
- set x
-} [list 256 $a]
-test io-6.7 {Tcl_GetsObj: error in input} {stdio} {
- # if (FilterInputBytes(chanPtr, &gs) != 0)
-
- set f [open "|[list $tcltest cat]" w+]
- puts -nonewline $f "hi\nwould"
- flush $f
- gets $f
- fconfigure $f -blocking 0
- set x [gets $f line]
- close $f
- set x
-} {-1}
-test io-6.8 {Tcl_GetsObj: remember if EOF is seen} {
- set f [open test1 w]
- puts $f "abcdef\x1aghijk\nwombat"
- close $f
- set f [open test1]
- fconfigure $f -eofchar \x1a
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} {6 abcdef -1 {}}
-test io-6.9 {Tcl_GetsObj: remember if EOF is seen} {
- set f [open test1 w]
- puts $f "abcdefghijk\nwom\u001abat"
- close $f
- set f [open test1]
- fconfigure $f -eofchar \x1a
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} {11 abcdefghijk 3 wom}
-
-# Comprehensive tests
-
-test io-6.10 {Tcl_GetsObj: lf mode: no chars} {
- set f [open test1 w]
- close $f
- set f [open test1]
- fconfigure $f -translation lf
- set x [list [gets $f line] $line]
- close $f
- set x
-} {-1 {}}
-test io-6.11 {Tcl_GetsObj: lf mode: lone \n} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "\n"
- close $f
- set f [open test1]
- fconfigure $f -translation lf
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} {0 {} -1 {}}
-test io-6.12 {Tcl_GetsObj: lf mode: lone \r} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "\r"
- close $f
- set f [open test1]
- fconfigure $f -translation lf
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} [list 1 "\r" -1 ""]
-test io-6.13 {Tcl_GetsObj: lf mode: 1 char} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f a
- close $f
- set f [open test1]
- fconfigure $f -translation lf
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} {1 a -1 {}}
-test io-6.14 {Tcl_GetsObj: lf mode: 1 char followed by EOL} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "a\n"
- close $f
- set f [open test1]
- fconfigure $f -translation lf
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} {1 a -1 {}}
-test io-6.15 {Tcl_GetsObj: lf mode: several chars} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "abcd\nefgh\rijkl\r\nmnop"
- close $f
- set f [open test1]
- fconfigure $f -translation lf
- set x [list [gets $f line] $line [gets $f line] $line [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} [list 4 "abcd" 10 "efgh\rijkl\r" 4 "mnop" -1 ""]
-test io-6.16 {Tcl_GetsObj: cr mode: no chars} {
- set f [open test1 w]
- close $f
- set f [open test1]
- fconfigure $f -translation cr
- set x [list [gets $f line] $line]
- close $f
- set x
-} {-1 {}}
-test io-6.17 {Tcl_GetsObj: cr mode: lone \n} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "\n"
- close $f
- set f [open test1]
- fconfigure $f -translation cr
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} [list 1 "\n" -1 ""]
-test io-6.18 {Tcl_GetsObj: cr mode: lone \r} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "\r"
- close $f
- set f [open test1]
- fconfigure $f -translation cr
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} {0 {} -1 {}}
-test io-6.19 {Tcl_GetsObj: cr mode: 1 char} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f a
- close $f
- set f [open test1]
- fconfigure $f -translation cr
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} {1 a -1 {}}
-test io-6.20 {Tcl_GetsObj: cr mode: 1 char followed by EOL} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "a\r"
- close $f
- set f [open test1]
- fconfigure $f -translation cr
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} {1 a -1 {}}
-test io-6.21 {Tcl_GetsObj: cr mode: several chars} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "abcd\nefgh\rijkl\r\nmnop"
- close $f
- set f [open test1]
- fconfigure $f -translation cr
- set x [list [gets $f line] $line [gets $f line] $line [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} [list 9 "abcd\nefgh" 4 "ijkl" 5 "\nmnop" -1 ""]
-test io-6.22 {Tcl_GetsObj: crlf mode: no chars} {
- set f [open test1 w]
- close $f
- set f [open test1]
- fconfigure $f -translation crlf
- set x [list [gets $f line] $line]
- close $f
- set x
-} {-1 {}}
-test io-6.23 {Tcl_GetsObj: crlf mode: lone \n} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "\n"
- close $f
- set f [open test1]
- fconfigure $f -translation crlf
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} [list 1 "\n" -1 ""]
-test io-6.24 {Tcl_GetsObj: crlf mode: lone \r} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "\r"
- close $f
- set f [open test1]
- fconfigure $f -translation crlf
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} [list 1 "\r" -1 ""]
-test io-6.25 {Tcl_GetsObj: crlf mode: \r\r} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "\r\r"
- close $f
- set f [open test1]
- fconfigure $f -translation crlf
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} [list 2 "\r\r" -1 ""]
-test io-6.26 {Tcl_GetsObj: crlf mode: \r\n} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "\r\n"
- close $f
- set f [open test1]
- fconfigure $f -translation crlf
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} [list 0 "" -1 ""]
-test io-6.27 {Tcl_GetsObj: crlf mode: 1 char} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f a
- close $f
- set f [open test1]
- fconfigure $f -translation crlf
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} {1 a -1 {}}
-test io-6.28 {Tcl_GetsObj: crlf mode: 1 char followed by EOL} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "a\r\n"
- close $f
- set f [open test1]
- fconfigure $f -translation crlf
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} {1 a -1 {}}
-test io-6.29 {Tcl_GetsObj: crlf mode: several chars} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "abcd\nefgh\rijkl\r\nmnop"
- close $f
- set f [open test1]
- fconfigure $f -translation crlf
- set x [list [gets $f line] $line [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} [list 14 "abcd\nefgh\rijkl" 4 "mnop" -1 ""]
-test io-6.30 {Tcl_GetsObj: crlf mode: buffer exhausted} {
- # if (eol >= dstEnd)
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "123456789012345\r\nabcdefghijklmnoprstuvwxyz"
- close $f
- set f [open test1]
- fconfigure $f -translation crlf -buffersize 16
- set x [list [gets $f line] $line [testchannel inputbuffered $f]]
- close $f
- set x
-} [list 15 "123456789012345" 15]
-test io-6.31 {Tcl_GetsObj: crlf mode: buffer exhausted, blocked} {stdio} {
- # (FilterInputBytes() != 0)
-
- set f [open "|[list $tcltest cat]" w+]
- fconfigure $f -translation {crlf lf} -buffering none
- puts -nonewline $f "bbbbbbbbbbbbbb\r\n123456789012345\r"
- fconfigure $f -buffersize 16
- set x [gets $f]
- fconfigure $f -blocking 0
- lappend x [gets $f line] $line [fblocked $f] [testchannel inputbuffered $f]
- close $f
- set x
-} [list "bbbbbbbbbbbbbb" -1 "" 1 16]
-test io-6.32 {Tcl_GetsObj: crlf mode: buffer exhausted, more data} {
- # not (FilterInputBytes() != 0)
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "123456789012345\r\n123"
- close $f
- set f [open test1]
- fconfigure $f -translation crlf -buffersize 16
- set x [list [gets $f line] $line [tell $f] [testchannel inputbuffered $f]]
- close $f
- set x
-} [list 15 "123456789012345" 17 3]
-test io-6.33 {Tcl_GetsObj: crlf mode: buffer exhausted, at eof} {
- # eol still equals dstEnd
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "123456789012345\r"
- close $f
- set f [open test1]
- fconfigure $f -translation crlf -buffersize 16
- set x [list [gets $f line] $line [eof $f]]
- close $f
- set x
-} [list 16 "123456789012345\r" 1]
-test io-6.34 {Tcl_GetsObj: crlf mode: buffer exhausted, not followed by \n} {
- # not (*eol == '\n')
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "123456789012345\rabcd\r\nefg"
- close $f
- set f [open test1]
- fconfigure $f -translation crlf -buffersize 16
- set x [list [gets $f line] $line [tell $f]]
- close $f
- set x
-} [list 20 "123456789012345\rabcd" 22]
-test io-6.35 {Tcl_GetsObj: auto mode: no chars} {
- set f [open test1 w]
- close $f
- set f [open test1]
- fconfigure $f -translation auto
- set x [list [gets $f line] $line]
- close $f
- set x
-} {-1 {}}
-test io-6.36 {Tcl_GetsObj: auto mode: lone \n} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "\n"
- close $f
- set f [open test1]
- fconfigure $f -translation auto
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} [list 0 "" -1 ""]
-test io-6.37 {Tcl_GetsObj: auto mode: lone \r} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "\r"
- close $f
- set f [open test1]
- fconfigure $f -translation auto
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} [list 0 "" -1 ""]
-test io-6.38 {Tcl_GetsObj: auto mode: \r\r} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "\r\r"
- close $f
- set f [open test1]
- fconfigure $f -translation auto
- set x [list [gets $f line] $line [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} [list 0 "" 0 "" -1 ""]
-test io-6.39 {Tcl_GetsObj: auto mode: \r\n} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "\r\n"
- close $f
- set f [open test1]
- fconfigure $f -translation auto
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} [list 0 "" -1 ""]
-test io-6.40 {Tcl_GetsObj: auto mode: 1 char} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f a
- close $f
- set f [open test1]
- fconfigure $f -translation auto
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} {1 a -1 {}}
-test io-6.41 {Tcl_GetsObj: auto mode: 1 char followed by EOL} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "a\r\n"
- close $f
- set f [open test1]
- fconfigure $f -translation auto
- set x [list [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} {1 a -1 {}}
-test io-6.42 {Tcl_GetsObj: auto mode: several chars} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "abcd\nefgh\rijkl\r\nmnop"
- close $f
- set f [open test1]
- fconfigure $f -translation auto
- set x [list [gets $f line] $line [gets $f line] $line]
- lappend x [gets $f line] $line [gets $f line] $line [gets $f line] $line
- close $f
- set x
-} [list 4 "abcd" 4 "efgh" 4 "ijkl" 4 "mnop" -1 ""]
-test io-6.43 {Tcl_GetsObj: input saw cr} {stdio} {
- # if (chanPtr->flags & INPUT_SAW_CR)
-
- set f [open "|[list $tcltest cat]" w+]
- fconfigure $f -translation {auto lf} -buffering none
- puts -nonewline $f "bbbbbbbbbbbbbbb\n123456789abcdef\r"
- fconfigure $f -buffersize 16
- set x [list [gets $f]]
- fconfigure $f -blocking 0
- lappend x [gets $f line] $line [testchannel queuedcr $f]
- fconfigure $f -blocking 1
- puts -nonewline $f "\nabcd\refg\x1a"
- lappend x [gets $f line] $line [testchannel queuedcr $f]
- lappend x [gets $f line] $line
- close $f
- set x
-} [list "bbbbbbbbbbbbbbb" 15 "123456789abcdef" 1 4 "abcd" 0 3 "efg"]
-test io-6.44 {Tcl_GetsObj: input saw cr, not followed by cr} {stdio} {
- # not (*eol == '\n')
-
- set f [open "|[list $tcltest cat]" w+]
- fconfigure $f -translation {auto lf} -buffering none
- puts -nonewline $f "bbbbbbbbbbbbbbb\n123456789abcdef\r"
- fconfigure $f -buffersize 16
- set x [list [gets $f]]
- fconfigure $f -blocking 0
- lappend x [gets $f line] $line [testchannel queuedcr $f]
- fconfigure $f -blocking 1
- puts -nonewline $f "abcd\refg\x1a"
- lappend x [gets $f line] $line [testchannel queuedcr $f]
- lappend x [gets $f line] $line
- close $f
- set x
-} [list "bbbbbbbbbbbbbbb" 15 "123456789abcdef" 1 4 "abcd" 0 3 "efg"]
-test io-6.45 {Tcl_GetsObj: input saw cr, skip right number of bytes} {stdio} {
- # Tcl_ExternalToUtf()
-
- set f [open "|[list $tcltest cat]" w+]
- fconfigure $f -translation {auto lf} -buffering none
- fconfigure $f -encoding unicode
- puts -nonewline $f "bbbbbbbbbbbbbbb\n123456789abcdef\r"
- fconfigure $f -buffersize 16
- gets $f
- fconfigure $f -blocking 0
- set x [list [gets $f line] $line [testchannel queuedcr $f]]
- fconfigure $f -blocking 1
- puts -nonewline $f "\nabcd\refg"
- lappend x [gets $f line] $line [testchannel queuedcr $f]
- close $f
- set x
-} [list 15 "123456789abcdef" 1 4 "abcd" 0]
-test io-6.46 {Tcl_GetsObj: input saw cr, followed by just \n should give eof} {stdio} {
- # memmove()
-
- set f [open "|[list $tcltest cat]" w+]
- fconfigure $f -translation {auto lf} -buffering none
- puts -nonewline $f "bbbbbbbbbbbbbbb\n123456789abcdef\r"
- fconfigure $f -buffersize 16
- gets $f
- fconfigure $f -blocking 0
- set x [list [gets $f line] $line [testchannel queuedcr $f]]
- fconfigure $f -blocking 1
- puts -nonewline $f "\n\x1a"
- lappend x [gets $f line] $line [testchannel queuedcr $f]
- close $f
- set x
-} [list 15 "123456789abcdef" 1 -1 "" 0]
-test io-6.47 {Tcl_GetsObj: auto mode: \r at end of buffer, peek for \n} {
- # (eol == dstEnd)
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "123456789012345\r\nabcdefghijklmnopq"
- close $f
- set f [open test1]
- fconfigure $f -translation auto -buffersize 16
- set x [list [gets $f] [testchannel inputbuffered $f]]
- close $f
- set x
-} [list "123456789012345" 15]
-test io-6.48 {Tcl_GetsObj: auto mode: \r at end of buffer, no more avail} {
- # PeekAhead() did not get any, so (eol >= dstEnd)
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "123456789012345\r"
- close $f
- set f [open test1]
- fconfigure $f -translation auto -buffersize 16
- set x [list [gets $f] [testchannel queuedcr $f]]
- close $f
- set x
-} [list "123456789012345" 1]
-test io-6.49 {Tcl_GetsObj: auto mode: \r followed by \n} {
- # if (*eol == '\n') {skip++}
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "123456\r\n78901"
- close $f
- set f [open test1]
- set x [list [gets $f] [testchannel queuedcr $f] [tell $f] [gets $f]]
- close $f
- set x
-} [list "123456" 0 8 "78901"]
-test io-6.50 {Tcl_GetsObj: auto mode: \r not followed by \n} {
- # not (*eol == '\n')
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "123456\r78901"
- close $f
- set f [open test1]
- set x [list [gets $f] [testchannel queuedcr $f] [tell $f] [gets $f]]
- close $f
- set x
-} [list "123456" 0 7 "78901"]
-test io-6.51 {Tcl_GetsObj: auto mode: \n} {
- # else if (*eol == '\n') {goto gotoeol;}
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "123456\n78901"
- close $f
- set f [open test1]
- set x [list [gets $f] [tell $f] [gets $f]]
- close $f
- set x
-} [list "123456" 7 "78901"]
-test io-6.52 {Tcl_GetsObj: saw EOF character} {
- # if (eof != NULL)
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "123456\x1ak9012345\r"
- close $f
- set f [open test1]
- fconfigure $f -eofchar \x1a
- set x [list [gets $f] [testchannel queuedcr $f] [tell $f] [gets $f]]
- close $f
- set x
-} [list "123456" 0 6 ""]
-test io-6.53 {Tcl_GetsObj: device EOF} {
- # didn't produce any bytes
-
- set f [open test1 w]
- close $f
- set f [open test1]
- set x [list [gets $f line] $line [eof $f]]
- close $f
- set x
-} {-1 {} 1}
-test io-6.54 {Tcl_GetsObj: device EOF} {
- # got some bytes before EOF.
-
- set f [open test1 w]
- puts -nonewline $f abc
- close $f
- set f [open test1]
- set x [list [gets $f line] $line [eof $f]]
- close $f
- set x
-} {3 abc 1}
-test io-6.55 {Tcl_GetsObj: overconverted} {
- # Tcl_ExternalToUtf(), make sure state updated
-
- set f [open test1 w]
- fconfigure $f -encoding iso2022-jp
- puts $f "there\u4e00ok\n\u4e01more bytes\nhere"
- close $f
- set f [open test1]
- fconfigure $f -encoding iso2022-jp
- set x [list [gets $f line] $line [gets $f line] $line [gets $f line] $line]
- close $f
- set x
-} [list 8 "there\u4e00ok" 11 "\u4e01more bytes" 4 "here"]
-test io-6.56 {Tcl_GetsObj: incomplete lines should disable file events} {stdio} {
- update
- set f [open "|[list $tcltest cat]" w+]
- fconfigure $f -buffering none
- puts -nonewline $f "foobar"
- fconfigure $f -blocking 0
- set x {}
- after 500 { lappend x timeout }
- fileevent $f readable { lappend x [gets $f] }
- vwait x
- vwait x
- fconfigure $f -blocking 1
- puts -nonewline $f "baz\n"
- after 500 { lappend x timeout }
- fconfigure $f -blocking 0
- vwait x
- vwait x
- close $f
- set x
-} {{} timeout foobarbaz timeout}
-
-test io-7.1 {FilterInputBytes: split up character at end of buffer} {
- # (result == TCL_CONVERT_MULTIBYTE)
-
- set f [open test1 w]
- fconfigure $f -encoding shiftjis
- puts $f "1234567890123\uff10\uff11\uff12\uff13\uff14\nend"
- close $f
- set f [open test1]
- fconfigure $f -encoding shiftjis -buffersize 16
- set x [gets $f]
- close $f
- set x
-} "1234567890123\uff10\uff11\uff12\uff13\uff14"
-test io-7.2 {FilterInputBytes: split up character in middle of buffer} {
- # (bufPtr->nextAdded < bufPtr->bufLength)
-
- set f [open test1 w]
- fconfigure $f -encoding binary
- puts -nonewline $f "1234567890\n123\x82\x4f\x82\x50\x82"
- close $f
- set f [open test1]
- fconfigure $f -encoding shiftjis
- set x [list [gets $f line] $line [eof $f]]
- close $f
- set x
-} [list 10 "1234567890" 0]
-test io-7.3 {FilterInputBytes: split up character at EOF} {
- set f [open test1 w]
- fconfigure $f -encoding binary
- puts -nonewline $f "1234567890123\x82\x4f\x82\x50\x82"
- close $f
- set f [open test1]
- fconfigure $f -encoding shiftjis
- set x [list [gets $f line] $line]
- lappend x [tell $f] [testchannel inputbuffered $f] [eof $f]
- lappend x [gets $f line] $line
- close $f
- set x
-} [list 15 "1234567890123\uff10\uff11" 18 0 1 -1 ""]
-test io-7.4 {FilterInputBytes: recover from split up character} {stdio} {
- set f [open "|[list $tcltest cat]" w+]
- fconfigure $f -encoding binary -buffering none
- puts -nonewline $f "1234567890123\x82\x4f\x82\x50\x82"
- fconfigure $f -encoding shiftjis -blocking 0
- fileevent $f read "ready $f"
- set x {}
- proc ready {f} {
- lappend ::x [gets $f line] $line [fblocked $f]
- }
- vwait x
- fconfigure $f -encoding binary -blocking 1
- puts $f "\x51\x82\x52"
- fconfigure $f -encoding shiftjis
- vwait x
- close $f
- set x
-} [list -1 "" 1 17 "1234567890123\uff10\uff11\uff12\uff13" 0]
-
-test io-8.1 {PeekAhead: only go to device if no more cached data} {
- # (bufPtr->nextPtr == NULL)
-
- set f [open "test1" w]
- fconfigure $f -encoding ascii -translation lf
- puts -nonewline $f "123456789012345\r\n2345678"
- close $f
- set f [open "test1"]
- fconfigure $f -encoding ascii -translation auto -buffersize 16
- # here
- gets $f
- set x [testchannel inputbuffered $f]
- close $f
- set x
-} "7"
-test io-8.2 {PeekAhead: only go to device if no more cached data} {stdio} {
- # not (bufPtr->nextPtr == NULL)
-
- set f [open "|[list $tcltest cat]" w+]
- fconfigure $f -translation lf -encoding ascii -buffering none
- puts -nonewline $f "123456789012345\r\nbcdefghijklmnopqrstuvwxyz"
- set x {}
- fileevent $f read "ready $f"
- proc ready {f} {
- lappend ::x [gets $f line] $line [testchannel inputbuffered $f]
- }
- fconfigure $f -encoding unicode -buffersize 16 -blocking 0
- vwait x
- fconfigure $f -translation auto -encoding ascii -blocking 1
- # here
- vwait x
- close $f
- set x
-} [list -1 "" 42 15 "123456789012345" 25]
-test io-8.3 {PeekAhead: no cached data available} {stdio} {
- # (bytesLeft == 0)
-
- set f [open "|[list $tcltest cat]" w+]
- fconfigure $f -translation {auto binary}
- puts -nonewline $f "abcdefghijklmno\r"
- flush $f
- set x [list [gets $f line] $line [testchannel queuedcr $f]]
- close $f
- set x
-} [list 15 "abcdefghijklmno" 1]
-set a "123456789012345678901234567890"
-append a "123456789012345678901234567890"
-append a "1234567890123456789012345678901"
-test io-8.4 {PeekAhead: cached data available in this buffer} {
- # not (bytesLeft == 0)
-
- set f [open test1 w+]
- fconfigure $f -translation binary
- puts $f "${a}\r\nabcdef"
- close $f
- set f [open test1]
- fconfigure $f -encoding binary -translation auto
-
- # "${a}\r" was converted in one operation (because ENCODING_LINESIZE
- # is 30). To check if "\n" follows, calls PeekAhead and determines
- # that cached data is available in buffer w/o having to call driver.
-
- set x [gets $f]
- close $f
- set x
-} $a
-unset a
-test io-8.5 {PeekAhead: don't peek if last read was short} {stdio} {
- # (bufPtr->nextAdded < bufPtr->length)
-
- set f [open "|[list $tcltest cat]" w+]
- fconfigure $f -translation {auto binary}
- puts -nonewline $f "abcdefghijklmno\r"
- flush $f
- # here
- set x [list [gets $f line] $line [testchannel queuedcr $f]]
- close $f
- set x
-} {15 abcdefghijklmno 1}
-test io-8.6 {PeekAhead: change to non-blocking mode} {stdio} {
- # ((chanPtr->flags & CHANNEL_NONBLOCKING) == 0)
-
- set f [open "|[list $tcltest cat]" w+]
- fconfigure $f -translation {auto binary} -buffersize 16
- puts -nonewline $f "abcdefghijklmno\r"
- flush $f
- # here
- set x [list [gets $f line] $line [testchannel queuedcr $f]]
- close $f
- set x
-} {15 abcdefghijklmno 1}
-test io-8.7 {PeekAhead: cleanup} {stdio} {
- # Make sure bytes are removed from buffer.
-
- set f [open "|[list $tcltest cat]" w+]
- fconfigure $f -translation {auto binary} -buffering none
- puts -nonewline $f "abcdefghijklmno\r"
- # here
- set x [list [gets $f line] $line [testchannel queuedcr $f]]
- puts -nonewline $f "\x1a"
- lappend x [gets $f line] $line
- close $f
- set x
-} {15 abcdefghijklmno 1 -1 {}}
-
-
-test io-9.1 {CommonGetsCleanup} {
-} {}
-
-test io-10.1 {Tcl_ReadChars: CheckChannelErrors} {
- # no test, need to cause an async error.
-} {}
-test io-10.2 {Tcl_ReadChars: loop until enough copied} {
- # one time
- # for (copied = 0; (unsigned) toRead > 0; )
-
- set f [open "test1" w]
- puts $f abcdefghijklmnop
- close $f
-
- set f [open "test1"]
- set x [read $f 5]
- close $f
- set x
-} {abcde}
-test io-10.3 {Tcl_ReadChars: loop until enough copied} {
- # multiple times
- # for (copied = 0; (unsigned) toRead > 0; )
-
- set f [open "test1" w]
- puts $f abcdefghijklmnopqrstuvwxyz
- close $f
-
- set f [open "test1"]
- fconfigure $f -buffersize 16
- # here
- set x [read $f 19]
- close $f
- set x
-} {abcdefghijklmnopqrs}
-test io-10.4 {Tcl_ReadChars: no more in channel buffer} {
- # (copiedNow < 0)
-
- set f [open "test1" w]
- puts -nonewline $f abcdefghijkl
- close $f
-
- set f [open "test1"]
- # here
- set x [read $f 1000]
- close $f
- set x
-} {abcdefghijkl}
-test io-10.5 {Tcl_ReadChars: stop on EOF} {
- # (chanPtr->flags & CHANNEL_EOF)
-
- set f [open "test1" w]
- puts -nonewline $f abcdefghijkl
- close $f
-
- set f [open "test1"]
- # here
- set x [read $f 1000]
- close $f
- set x
-} {abcdefghijkl}
-
-test io-11.1 {ReadBytes: want to read a lot} {
- # ((unsigned) toRead > (unsigned) srcLen)
-
- set f [open "test1" w]
- puts -nonewline $f abcdefghijkl
- close $f
- set f [open "test1"]
- fconfigure $f -encoding binary
- # here
- set x [read $f 1000]
- close $f
- set x
-} {abcdefghijkl}
-test io-11.2 {ReadBytes: want to read all} {
- # ((unsigned) toRead > (unsigned) srcLen)
-
- set f [open "test1" w]
- puts -nonewline $f abcdefghijkl
- close $f
- set f [open "test1"]
- fconfigure $f -encoding binary
- # here
- set x [read $f]
- close $f
- set x
-} {abcdefghijkl}
-test io-11.3 {ReadBytes: allocate more space} {
- # (toRead > length - offset - 1)
-
- set f [open "test1" w]
- puts -nonewline $f abcdefghijklmnopqrstuvwxyz
- close $f
- set f [open "test1"]
- fconfigure $f -buffersize 16 -encoding binary
- # here
- set x [read $f]
- close $f
- set x
-} {abcdefghijklmnopqrstuvwxyz}
-test io-11.4 {ReadBytes: EOF char found} {
- # (TranslateInputEOL() != 0)
-
- set f [open "test1" w]
- puts $f abcdefghijklmnopqrstuvwxyz
- close $f
- set f [open "test1"]
- fconfigure $f -eofchar m -encoding binary
- # here
- set x [list [read $f] [eof $f] [read $f] [eof $f]]
- close $f
- set x
-} [list "abcdefghijkl" 1 "" 1]
-
-test io-12.1 {ReadChars: want to read a lot} {
- # ((unsigned) toRead > (unsigned) srcLen)
-
- set f [open "test1" w]
- puts -nonewline $f abcdefghijkl
- close $f
- set f [open "test1"]
- # here
- set x [read $f 1000]
- close $f
- set x
-} {abcdefghijkl}
-test io-12.2 {ReadChars: want to read all} {
- # ((unsigned) toRead > (unsigned) srcLen)
-
- set f [open "test1" w]
- puts -nonewline $f abcdefghijkl
- close $f
- set f [open "test1"]
- # here
- set x [read $f]
- close $f
- set x
-} {abcdefghijkl}
-test io-12.3 {ReadChars: allocate more space} {
- # (toRead > length - offset - 1)
-
- set f [open "test1" w]
- puts -nonewline $f abcdefghijklmnopqrstuvwxyz
- close $f
- set f [open "test1"]
- fconfigure $f -buffersize 16
- # here
- set x [read $f]
- close $f
- set x
-} {abcdefghijklmnopqrstuvwxyz}
-test io-12.4 {ReadChars: split-up char} {stdio} {
- # (srcRead == 0)
-
- set f [open "|[list $tcltest cat]" w+]
- fconfigure $f -encoding binary -buffering none -buffersize 16
- puts -nonewline $f "123456789012345\x96"
- fconfigure $f -encoding shiftjis -blocking 0
-
- fileevent $f read "ready $f"
- proc ready {f} {
- lappend ::x [read $f] [testchannel inputbuffered $f]
- }
- set x {}
-
- fconfigure $f -encoding shiftjis
- vwait x
- fconfigure $f -encoding binary -blocking 1
- puts -nonewline $f "\x7b"
- after 500 ;# Give the cat process time to catch up
- fconfigure $f -encoding shiftjis -blocking 0
- vwait x
- close $f
- set x
-} [list "123456789012345" 1 "\u672c" 0]
-test io-12.5 {ReadChars: fileevents on partial characters} {stdio} {
- makeFile {
- fconfigure stdout -encoding binary -buffering none
- gets stdin; puts -nonewline "\xe7"
- gets stdin; puts -nonewline "\x89"
- gets stdin; puts -nonewline "\xa6"
- } test1
- set f [open "|[list $tcltest test1]" r+]
- fileevent $f readable {
- lappend x [read $f]
- if {[eof $f]} {
- lappend x eof
- }
- }
- puts $f "go1"
- flush $f
- fconfigure $f -blocking 0 -encoding utf-8
- set x {}
- vwait x
- after 500 { lappend x timeout }
- vwait x
- puts $f "go2"
- flush $f
- vwait x
- after 500 { lappend x timeout }
- vwait x
- puts $f "go3"
- flush $f
- vwait x
- vwait x
- lappend x [catch {close $f} msg] $msg
- set x
-} "{} timeout {} timeout \u7266 {} eof 0 {}"
-
-test io-13.1 {TranslateInputEOL: cr mode} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "abcd\rdef\r"
- close $f
- set f [open test1]
- fconfigure $f -translation cr
- set x [read $f]
- close $f
- set x
-} "abcd\ndef\n"
-test io-13.2 {TranslateInputEOL: crlf mode} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "abcd\r\ndef\r\n"
- close $f
- set f [open test1]
- fconfigure $f -translation crlf
- set x [read $f]
- close $f
- set x
-} "abcd\ndef\n"
-test io-13.3 {TranslateInputEOL: crlf mode: naked cr} {
- # (src >= srcMax)
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "abcd\r\ndef\r"
- close $f
- set f [open test1]
- fconfigure $f -translation crlf
- set x [read $f]
- close $f
- set x
-} "abcd\ndef\r"
-test io-13.4 {TranslateInputEOL: crlf mode: cr followed by not \n} {
- # (src >= srcMax)
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "abcd\r\ndef\rfgh"
- close $f
- set f [open test1]
- fconfigure $f -translation crlf
- set x [read $f]
- close $f
- set x
-} "abcd\ndef\rfgh"
-test io-13.5 {TranslateInputEOL: crlf mode: naked lf} {
- # (src >= srcMax)
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "abcd\r\ndef\nfgh"
- close $f
- set f [open test1]
- fconfigure $f -translation crlf
- set x [read $f]
- close $f
- set x
-} "abcd\ndef\nfgh"
-test io-13.6 {TranslateInputEOL: auto mode: saw cr in last segment} {stdio} {
- # (chanPtr->flags & INPUT_SAW_CR)
- # This test may fail on slower machines.
-
- set f [open "|[list $tcltest cat]" w+]
- fconfigure $f -blocking 0 -buffering none -translation {auto lf}
-
- fileevent $f read "ready $f"
- proc ready {f} {
- lappend ::x [read $f] [testchannel queuedcr $f]
- }
- set x {}
-
- puts -nonewline $f "abcdefghj\r"
- after 500 {set y ok}
- vwait y
-
- puts -nonewline $f "\n01234"
- after 500 {set y ok}
- vwait y
-
- close $f
- set x
-} [list "abcdefghj\n" 1 "01234" 0]
-test io-13.7 {TranslateInputEOL: auto mode: naked \r} {
- # (src >= srcMax)
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "abcd\r"
- close $f
- set f [open test1]
- fconfigure $f -translation auto
- set x [list [read $f] [testchannel queuedcr $f]]
- close $f
- set x
-} [list "abcd\n" 1]
-test io-13.8 {TranslateInputEOL: auto mode: \r\n} {
- # (*src == '\n')
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "abcd\r\ndef"
- close $f
- set f [open test1]
- fconfigure $f -translation auto
- set x [read $f]
- close $f
- set x
-} "abcd\ndef"
-test io-13.9 {TranslateInputEOL: auto mode: \r followed by not \n} {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "abcd\rdef"
- close $f
- set f [open test1]
- fconfigure $f -translation auto
- set x [read $f]
- close $f
- set x
-} "abcd\ndef"
-test io-13.10 {TranslateInputEOL: auto mode: \n} {
- # not (*src == '\r')
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "abcd\ndef"
- close $f
- set f [open test1]
- fconfigure $f -translation auto
- set x [read $f]
- close $f
- set x
-} "abcd\ndef"
-test io-13.11 {TranslateInputEOL: EOF char} {
- # (*chanPtr->inEofChar != '\0')
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "abcd\ndefgh"
- close $f
- set f [open test1]
- fconfigure $f -translation auto -eofchar e
- set x [read $f]
- close $f
- set x
-} "abcd\nd"
-test io-13.12 {TranslateInputEOL: find EOF char in src} {
- # (*chanPtr->inEofChar != '\0')
-
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "\r\n\r\n\r\nab\r\n\r\ndef\r\n\r\n\r\n"
- close $f
- set f [open test1]
- fconfigure $f -translation auto -eofchar e
- set x [read $f]
- close $f
- set x
-} "\n\n\nab\n\nd"
-
-# Test standard handle management. The functions tested are
-# Tcl_SetStdChannel and Tcl_GetStdChannel. Incidentally we are
-# also testing channel table management.
-
-if {$tcl_platform(platform) == "macintosh"} {
- set consoleFileNames [list console0 console1 console2]
-} else {
- set consoleFileNames [lsort [testchannel open]]
-}
-test io-14.1 {Tcl_SetStdChannel and Tcl_GetStdChannel} {
- set l ""
- lappend l [fconfigure stdin -buffering]
- lappend l [fconfigure stdout -buffering]
- lappend l [fconfigure stderr -buffering]
- lappend l [lsort [testchannel open]]
- set l
-} [list line line none $consoleFileNames]
-test io-14.2 {Tcl_SetStdChannel and Tcl_GetStdChannel} {
- interp create x
- set l ""
- lappend l [x eval {fconfigure stdin -buffering}]
- lappend l [x eval {fconfigure stdout -buffering}]
- lappend l [x eval {fconfigure stderr -buffering}]
- interp delete x
- set l
-} {line line none}
-test io-14.3 {Tcl_SetStdChannel & Tcl_GetStdChannel} {stdio} {
- set f [open test1 w]
- puts $f {
- close stdin
- close stdout
- close stderr
- set f [open test1 r]
- set f2 [open test2 w]
- set f3 [open test3 w]
- puts stdout [gets stdin]
- puts stdout out
- puts stderr err
- close $f
- close $f2
- close $f3
- }
- close $f
- set result [exec $tcltest test1]
- set f [open test2 r]
- set f2 [open test3 r]
- lappend result [read $f] [read $f2]
- close $f
- close $f2
- set result
-} {{
-out
-} {err
-}}
-# This test relies on the fact that the smallest available fd is used first.
-test io-14.4 {Tcl_SetStdChannel & Tcl_GetStdChannel} {unixOnly} {
- set f [open test1 w]
- puts $f { close stdin
- close stdout
- close stderr
- set f [open test1 r]
- set f2 [open test2 w]
- set f3 [open test3 w]
- puts stdout [gets stdin]
- puts stdout $f2
- puts stderr $f3
- close $f
- close $f2
- close $f3
- }
- close $f
- set result [exec $tcltest test1]
- set f [open test2 r]
- set f2 [open test3 r]
- lappend result [read $f] [read $f2]
- close $f
- close $f2
- set result
-} {{ close stdin
-file1
-} {file2
-}}
-catch {interp delete z}
-test io-14.5 {Tcl_GetChannel: stdio name translation} {
- interp create z
- eof stdin
- catch {z eval flush stdin} msg1
- catch {z eval close stdin} msg2
- catch {z eval flush stdin} msg3
- set result [list $msg1 $msg2 $msg3]
- interp delete z
- set result
-} {{channel "stdin" wasn't opened for writing} {} {can not find channel named "stdin"}}
-test io-14.6 {Tcl_GetChannel: stdio name translation} {
- interp create z
- eof stdout
- catch {z eval flush stdout} msg1
- catch {z eval close stdout} msg2
- catch {z eval flush stdout} msg3
- set result [list $msg1 $msg2 $msg3]
- interp delete z
- set result
-} {{} {} {can not find channel named "stdout"}}
-test io-14.7 {Tcl_GetChannel: stdio name translation} {
- interp create z
- eof stderr
- catch {z eval flush stderr} msg1
- catch {z eval close stderr} msg2
- catch {z eval flush stderr} msg3
- set result [list $msg1 $msg2 $msg3]
- interp delete z
- set result
-} {{} {} {can not find channel named "stderr"}}
-test io-14.8 {reuse of stdio special channels} {stdio} {
- removeFile script
- removeFile test1
- set f [open script w]
- puts $f {
- close stderr
- set f [open test1 w]
- puts stderr hello
- close $f
- set f [open test1 r]
- puts [gets $f]
- }
- close $f
- set f [open "|[list $tcltest script]" r]
- set c [gets $f]
- close $f
- set c
-} hello
-test io-14.9 {reuse of stdio special channels} {stdio} {
- removeFile script
- removeFile test1
- set f [open script w]
- puts $f {
- set f [open test1 w]
- puts $f hello
- close $f
- close stderr
- set f [open "|[list [info nameofexecutable] cat test1]" r]
- puts [gets $f]
- }
- close $f
- set f [open "|[list $tcltest script]" r]
- set c [gets $f]
- close $f
- set c
-} hello
-
-test io-15.1 {Tcl_CreateCloseHandler} {
-} {}
-
-test io-16.1 {Tcl_DeleteCloseHandler} {
-} {}
-
-# Test channel table management. The functions tested are
-# GetChannelTable, DeleteChannelTable, Tcl_RegisterChannel,
-# Tcl_UnregisterChannel, Tcl_GetChannel and Tcl_CreateChannel.
-#
-# These functions use "eof stdin" to ensure that the standard
-# channels are added to the channel table of the interpreter.
-
-test io-17.1 {GetChannelTable, DeleteChannelTable on std handles} {
- set l1 [testchannel refcount stdin]
- eof stdin
- interp create x
- set l ""
- lappend l [expr [testchannel refcount stdin] - $l1]
- x eval {eof stdin}
- lappend l [expr [testchannel refcount stdin] - $l1]
- interp delete x
- lappend l [expr [testchannel refcount stdin] - $l1]
- set l
-} {0 1 0}
-test io-17.2 {GetChannelTable, DeleteChannelTable on std handles} {
- set l1 [testchannel refcount stdout]
- eof stdin
- interp create x
- set l ""
- lappend l [expr [testchannel refcount stdout] - $l1]
- x eval {eof stdout}
- lappend l [expr [testchannel refcount stdout] - $l1]
- interp delete x
- lappend l [expr [testchannel refcount stdout] - $l1]
- set l
-} {0 1 0}
-test io-17.3 {GetChannelTable, DeleteChannelTable on std handles} {
- set l1 [testchannel refcount stderr]
- eof stdin
- interp create x
- set l ""
- lappend l [expr [testchannel refcount stderr] - $l1]
- x eval {eof stderr}
- lappend l [expr [testchannel refcount stderr] - $l1]
- interp delete x
- lappend l [expr [testchannel refcount stderr] - $l1]
- set l
-} {0 1 0}
-
-test io-18.1 {Tcl_RegisterChannel, Tcl_UnregisterChannel} {
- removeFile test1
- set l ""
- set f [open test1 w]
- lappend l [lindex [testchannel info $f] 15]
- close $f
- if {[catch {lindex [testchannel info $f] 15} msg]} {
- lappend l $msg
- } else {
- lappend l "very broken: $f found after being closed"
- }
- string compare [string tolower $l] \
- [list 1 [format "can not find channel named \"%s\"" $f]]
-} 0
-test io-18.2 {Tcl_RegisterChannel, Tcl_UnregisterChannel} {
- removeFile test1
- set l ""
- set f [open test1 w]
- lappend l [lindex [testchannel info $f] 15]
- interp create x
- interp share "" $f x
- lappend l [lindex [testchannel info $f] 15]
- x eval close $f
- lappend l [lindex [testchannel info $f] 15]
- interp delete x
- lappend l [lindex [testchannel info $f] 15]
- close $f
- if {[catch {lindex [testchannel info $f] 15} msg]} {
- lappend l $msg
- } else {
- lappend l "very broken: $f found after being closed"
- }
- string compare [string tolower $l] \
- [list 1 2 1 1 [format "can not find channel named \"%s\"" $f]]
-} 0
-test io-18.3 {Tcl_RegisterChannel, Tcl_UnregisterChannel} {
- removeFile test1
- set l ""
- set f [open test1 w]
- lappend l [lindex [testchannel info $f] 15]
- interp create x
- interp share "" $f x
- lappend l [lindex [testchannel info $f] 15]
- interp delete x
- lappend l [lindex [testchannel info $f] 15]
- close $f
- if {[catch {lindex [testchannel info $f] 15} msg]} {
- lappend l $msg
- } else {
- lappend l "very broken: $f found after being closed"
- }
- string compare [string tolower $l] \
- [list 1 2 1 [format "can not find channel named \"%s\"" $f]]
-} 0
-
-test io-19.1 {Tcl_GetChannel->Tcl_GetStdChannel, standard handles} {
- eof stdin
-} 0
-test io-19.2 {testing Tcl_GetChannel, user opened handle} {
- removeFile test1
- set f [open test1 w]
- set x [eof $f]
- close $f
- set x
-} 0
-test io-19.3 {Tcl_GetChannel, channel not found} {
- list [catch {eof file34} msg] $msg
-} {1 {can not find channel named "file34"}}
-test io-19.4 {Tcl_CreateChannel, insertion into channel table} {
- removeFile test1
- set f [open test1 w]
- set l ""
- lappend l [eof $f]
- close $f
- if {[catch {lindex [testchannel info $f] 15} msg]} {
- lappend l $msg
- } else {
- lappend l "very broken: $f found after being closed"
- }
- string compare [string tolower $l] \
- [list 0 [format "can not find channel named \"%s\"" $f]]
-} 0
-
-test io-20.1 {Tcl_CreateChannel: initial settings} {
- set a [open test2 w]
- set old [encoding system]
- encoding system ascii
- set f [open test1 w]
- set x [fconfigure $f -encoding]
- close $f
- encoding system $old
- close $a
- set x
-} {ascii}
-test io-20.2 {Tcl_CreateChannel: initial settings} {pcOnly} {
- set f [open test1 w+]
- set x [list [fconfigure $f -eofchar] [fconfigure $f -translation]]
- close $f
- set x
-} [list [list \x1a ""] {auto crlf}]
-test io-20.3 {Tcl_CreateChannel: initial settings} {unixOnly} {
- set f [open test1 w+]
- set x [list [fconfigure $f -eofchar] [fconfigure $f -translation]]
- close $f
- set x
-} {{{} {}} {auto lf}}
-test io-20.4 {Tcl_CreateChannel: initial settings} {macOnly} {
- set f [open test1 w+]
- set x [list [fconfigure $f -eofchar] [fconfigure $f -translation]]
- close $f
- set x
-} {{{} {}} {auto cr}}
-test io-20.5 {Tcl_CreateChannel: install channel in empty slot} {stdio} {
- set f [open script w]
- puts $f {
- close stdout
- set f1 [open stdout w]
- fconfigure $f1 -buffersize 777
- puts stderr [fconfigure stdout -buffersize]
- }
- close $f
- set f [open "|[list $tcltest script]"]
- catch {close $f} msg
- set msg
-} {777}
-
-test io-21.1 {CloseChannelsOnExit} {
-} {}
-
-# Test management of attributes associated with a channel, such as
-# its default translation, its name and type, etc. The functions
-# tested in this group are Tcl_GetChannelName,
-# Tcl_GetChannelType and Tcl_GetChannelFile. Tcl_GetChannelInstanceData
-# not tested because files do not use the instance data.
-
-test io-22.1 {Tcl_GetChannelMode} {
- # Not used anywhere in Tcl.
-} {}
-
-test io-23.1 {Tcl_GetChannelName} {
- removeFile test1
- set f [open test1 w]
- set n [testchannel name $f]
- close $f
- string compare $n $f
-} 0
-
-test io-24.1 {Tcl_GetChannelType} {
- removeFile test1
- set f [open test1 w]
- set t [testchannel type $f]
- close $f
- string compare $t file
-} 0
-
-test io-25.1 {Tcl_GetChannelHandle, input} {
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar {}
- puts $f "1234567890\n098765432"
- close $f
- set f [open test1 r]
- gets $f
- set l ""
- lappend l [testchannel inputbuffered $f]
- lappend l [tell $f]
- close $f
- set l
-} {10 11}
-test io-25.2 {Tcl_GetChannelHandle, output} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts $f hello
- set l ""
- lappend l [testchannel outputbuffered $f]
- lappend l [tell $f]
- flush $f
- lappend l [testchannel outputbuffered $f]
- lappend l [tell $f]
- close $f
- removeFile test1
- set l
-} {6 6 0 6}
-
-test io-26.1 {Tcl_GetChannelInstanceData} {stdio} {
- # "pid" command uses Tcl_GetChannelInstanceData
- # Don't care what pid is (but must be a number), just want to exercise it.
-
- set f [open "|[list $tcltest << exit]"]
- expr [pid $f]
- close $f
-} {}
-
-# Test flushing. The functions tested here are FlushChannel.
-
-test io-27.1 {FlushChannel, no output buffered} {
- removeFile test1
- set f [open test1 w]
- flush $f
- set s [file size test1]
- close $f
- set s
-} 0
-test io-27.2 {FlushChannel, some output buffered} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar {}
- set l ""
- puts $f hello
- lappend l [file size test1]
- flush $f
- lappend l [file size test1]
- close $f
- lappend l [file size test1]
- set l
-} {0 6 6}
-test io-27.3 {FlushChannel, implicit flush on close} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar {}
- set l ""
- puts $f hello
- lappend l [file size test1]
- close $f
- lappend l [file size test1]
- set l
-} {0 6}
-test io-27.4 {FlushChannel, implicit flush when buffer fills} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar {}
- fconfigure $f -buffersize 60
- set l ""
- lappend l [file size test1]
- for {set i 0} {$i < 12} {incr i} {
- puts $f hello
- }
- lappend l [file size test1]
- flush $f
- lappend l [file size test1]
- close $f
- set l
-} {0 60 72}
-test io-27.5 {FlushChannel, implicit flush when buffer fills and on close} \
- {unixOrPc} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -buffersize 60 -eofchar {}
- set l ""
- lappend l [file size test1]
- for {set i 0} {$i < 12} {incr i} {
- puts $f hello
- }
- lappend l [file size test1]
- close $f
- lappend l [file size test1]
- set l
-} {0 60 72}
-test io-27.6 {FlushChannel, async flushing, async close} \
- {stdio asyncPipeClose} {
- removeFile pipe
- removeFile output
- set f [open pipe w]
- puts $f {
- set f [open output w]
- fconfigure $f -translation lf -buffering none -eofchar {}
- while {![eof stdin]} {
- after 20
- puts -nonewline $f [read stdin 1024]
- }
- close $f
- }
- close $f
- set x 01234567890123456789012345678901
- for {set i 0} {$i < 11} {incr i} {
- set x "$x$x"
- }
- set f [open output w]
- close $f
- set f [open "|[list $tcltest pipe]" w]
- fconfigure $f -blocking off
- puts -nonewline $f $x
- close $f
- set counter 0
- while {([file size output] < 65536) && ($counter < 1000)} {
- incr counter
- after 20
- update
- }
- if {$counter == 1000} {
- set result "file size only [file size output]"
- } else {
- set result ok
- }
-} ok
-
-# Tests closing a channel. The functions tested are CloseChannel and Tcl_Close.
-
-test io-28.1 {CloseChannel called when all references are dropped} {
- removeFile test1
- set f [open test1 w]
- interp create x
- interp share "" $f x
- set l ""
- lappend l [testchannel refcount $f]
- x eval close $f
- interp delete x
- lappend l [testchannel refcount $f]
- close $f
- set l
-} {2 1}
-test io-28.2 {CloseChannel called when all references are dropped} {
- removeFile test1
- set f [open test1 w]
- interp create x
- interp share "" $f x
- puts -nonewline $f abc
- close $f
- x eval puts $f def
- x eval close $f
- interp delete x
- set f [open test1 r]
- set l [gets $f]
- close $f
- set l
-} abcdef
-test io-28.3 {CloseChannel, not called before output queue is empty} \
- {stdio asyncPipeClose nonPortable} {
- removeFile pipe
- removeFile output
- set f [open pipe w]
- puts $f {
-
- # Need to not have eof char appended on close, because the other
- # side of the pipe already closed, so that writing would cause an
- # error "invalid file".
-
- fconfigure stdout -eofchar {}
- fconfigure stderr -eofchar {}
-
- set f [open output w]
- fconfigure $f -translation lf -buffering none
- for {set x 0} {$x < 20} {incr x} {
- after 20
- puts -nonewline $f [read stdin 1024]
- }
- close $f
- }
- close $f
- set x 01234567890123456789012345678901
- for {set i 0} {$i < 11} {incr i} {
- set x "$x$x"
- }
- set f [open output w]
- close $f
- set f [open "|[list $tcltest pipe]" r+]
- fconfigure $f -blocking off -eofchar {}
-
- puts -nonewline $f $x
- close $f
- set counter 0
- while {([file size output] < 20480) && ($counter < 1000)} {
- incr counter
- after 20
- update
- }
- if {$counter == 1000} {
- set result probably_broken
- } else {
- set result ok
- }
-} ok
-test io-28.4 {Tcl_Close} {
- removeFile test1
- set l ""
- lappend l [lsort [testchannel open]]
- set f [open test1 w]
- lappend l [lsort [testchannel open]]
- close $f
- lappend l [lsort [testchannel open]]
- set x [list $consoleFileNames \
- [lsort [eval list $consoleFileNames $f]] \
- $consoleFileNames]
- string compare $l $x
-} 0
-test io-28.5 {Tcl_Close vs standard handles} {stdio unixOnly} {
- removeFile script
- set f [open script w]
- puts $f {
- close stdin
- puts [testchannel open]
- }
- close $f
- set f [open "|[list $tcltest script]" r]
- set l [gets $f]
- close $f
- set l
-} {file1 file2}
-
-test io-29.1 {Tcl_WriteChars, channel not writable} {
- list [catch {puts stdin hello} msg] $msg
-} {1 {channel "stdin" wasn't opened for writing}}
-test io-29.2 {Tcl_WriteChars, empty string} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -eofchar {}
- puts -nonewline $f ""
- close $f
- file size test1
-} 0
-test io-29.3 {Tcl_WriteChars, nonempty string} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -eofchar {}
- puts -nonewline $f hello
- close $f
- file size test1
-} 5
-test io-29.4 {Tcl_WriteChars, buffering in full buffering mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -buffering full -eofchar {}
- puts $f hello
- set l ""
- lappend l [testchannel outputbuffered $f]
- lappend l [file size test1]
- flush $f
- lappend l [testchannel outputbuffered $f]
- lappend l [file size test1]
- close $f
- set l
-} {6 0 0 6}
-test io-29.5 {Tcl_WriteChars, buffering in line buffering mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -buffering line -eofchar {}
- puts -nonewline $f hello
- set l ""
- lappend l [testchannel outputbuffered $f]
- lappend l [file size test1]
- puts $f hello
- lappend l [testchannel outputbuffered $f]
- lappend l [file size test1]
- close $f
- set l
-} {5 0 0 11}
-test io-29.6 {Tcl_WriteChars, buffering in no buffering mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -buffering none -eofchar {}
- puts -nonewline $f hello
- set l ""
- lappend l [testchannel outputbuffered $f]
- lappend l [file size test1]
- puts $f hello
- lappend l [testchannel outputbuffered $f]
- lappend l [file size test1]
- close $f
- set l
-} {0 5 0 11}
-
-test io-29.7 {Tcl_Flush, full buffering} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -buffering full -eofchar {}
- puts -nonewline $f hello
- set l ""
- lappend l [testchannel outputbuffered $f]
- lappend l [file size test1]
- puts $f hello
- lappend l [testchannel outputbuffered $f]
- lappend l [file size test1]
- flush $f
- lappend l [testchannel outputbuffered $f]
- lappend l [file size test1]
- close $f
- set l
-} {5 0 11 0 0 11}
-test io-29.8 {Tcl_Flush, full buffering} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -buffering line
- puts -nonewline $f hello
- set l ""
- lappend l [testchannel outputbuffered $f]
- lappend l [file size test1]
- flush $f
- lappend l [testchannel outputbuffered $f]
- lappend l [file size test1]
- puts $f hello
- lappend l [testchannel outputbuffered $f]
- lappend l [file size test1]
- flush $f
- lappend l [testchannel outputbuffered $f]
- lappend l [file size test1]
- close $f
- set l
-} {5 0 0 5 0 11 0 11}
-test io-29.9 {Tcl_Flush, channel not writable} {
- list [catch {flush stdin} msg] $msg
-} {1 {channel "stdin" wasn't opened for writing}}
-test io-29.10 {Tcl_WriteChars, looping and buffering} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf -eofchar {}
- set f2 [open longfile r]
- for {set x 0} {$x < 10} {incr x} {
- puts $f1 [gets $f2]
- }
- close $f2
- close $f1
- file size test1
-} 387
-test io-29.11 {Tcl_WriteChars, no newline, implicit flush} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -eofchar {}
- set f2 [open longfile r]
- for {set x 0} {$x < 10} {incr x} {
- puts -nonewline $f1 [gets $f2]
- }
- close $f1
- close $f2
- file size test1
-} 377
-test io-29.12 {Tcl_WriteChars on a pipe} {stdio} {
- removeFile test1
- removeFile pipe
- set f1 [open pipe w]
- puts $f1 {
- set f1 [open longfile r]
- for {set x 0} {$x < 10} {incr x} {
- puts [gets $f1]
- }
- }
- close $f1
- set f1 [open "|[list $tcltest pipe]" r]
- set f2 [open longfile r]
- set y ok
- for {set x 0} {$x < 10} {incr x} {
- set l1 [gets $f1]
- set l2 [gets $f2]
- if {"$l1" != "$l2"} {
- set y broken
- }
- }
- close $f1
- close $f2
- set y
-} ok
-test io-29.13 {Tcl_WriteChars to a pipe, line buffered} {stdio} {
- removeFile test1
- removeFile pipe
- set f1 [open pipe w]
- puts $f1 {
- puts [gets stdin]
- puts [gets stdin]
- }
- close $f1
- set y ok
- set f1 [open "|[list $tcltest pipe]" r+]
- fconfigure $f1 -buffering line
- set f2 [open longfile r]
- set line [gets $f2]
- puts $f1 $line
- set backline [gets $f1]
- if {"$line" != "$backline"} {
- set y broken
- }
- set line [gets $f2]
- puts $f1 $line
- set backline [gets $f1]
- if {"$line" != "$backline"} {
- set y broken
- }
- close $f1
- close $f2
- set y
-} ok
-test io-29.14 {Tcl_WriteChars, buffering and implicit flush at close} {
- removeFile test3
- set f [open test3 w]
- puts -nonewline $f "Text1"
- puts -nonewline $f " Text 2"
- puts $f " Text 3"
- close $f
- set f [open test3 r]
- set x [gets $f]
- close $f
- set x
-} {Text1 Text 2 Text 3}
-test io-29.15 {Tcl_Flush, channel not open for writing} {
- removeFile test1
- set fd [open test1 w]
- close $fd
- set fd [open test1 r]
- set x [list [catch {flush $fd} msg] $msg]
- close $fd
- string compare $x \
- [list 1 "channel \"$fd\" wasn't opened for writing"]
-} 0
-test io-29.16 {Tcl_Flush on pipe opened only for reading} {stdio} {
- set fd [open "|[list $tcltest cat longfile]" r]
- set x [list [catch {flush $fd} msg] $msg]
- catch {close $fd}
- string compare $x \
- [list 1 "channel \"$fd\" wasn't opened for writing"]
-} 0
-test io-29.17 {Tcl_WriteChars buffers, then Tcl_Flush flushes} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf
- puts $f1 hello
- puts $f1 hello
- puts $f1 hello
- flush $f1
- set x [file size test1]
- close $f1
- set x
-} 18
-test io-29.18 {Tcl_WriteChars and Tcl_Flush intermixed} {
- removeFile test1
- set x ""
- set f1 [open test1 w]
- fconfigure $f1 -translation lf
- puts $f1 hello
- puts $f1 hello
- puts $f1 hello
- flush $f1
- lappend x [file size test1]
- puts $f1 hello
- flush $f1
- lappend x [file size test1]
- puts $f1 hello
- flush $f1
- lappend x [file size test1]
- close $f1
- set x
-} {18 24 30}
-test io-29.19 {Explicit and implicit flushes} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf -eofchar {}
- set x ""
- puts $f1 hello
- puts $f1 hello
- puts $f1 hello
- flush $f1
- lappend x [file size test1]
- puts $f1 hello
- flush $f1
- lappend x [file size test1]
- puts $f1 hello
- close $f1
- lappend x [file size test1]
- set x
-} {18 24 30}
-test io-29.20 {Implicit flush when buffer is full} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf -eofchar {}
- set line "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
- for {set x 0} {$x < 100} {incr x} {
- puts $f1 $line
- }
- set z ""
- lappend z [file size test1]
- for {set x 0} {$x < 100} {incr x} {
- puts $f1 $line
- }
- lappend z [file size test1]
- close $f1
- lappend z [file size test1]
- set z
-} {4096 12288 12600}
-test io-29.21 {Tcl_Flush to pipe} {stdio} {
- removeFile pipe
- set f1 [open pipe w]
- puts $f1 {set x [read stdin 6]}
- puts $f1 {set cnt [string length $x]}
- puts $f1 {puts "read $cnt characters"}
- close $f1
- set f1 [open "|[list $tcltest pipe]" r+]
- puts $f1 hello
- flush $f1
- set x [gets $f1]
- catch {close $f1}
- set x
-} "read 6 characters"
-test io-29.22 {Tcl_Flush called at other end of pipe} {stdio} {
- removeFile pipe
- set f1 [open pipe w]
- puts $f1 {
- fconfigure stdout -buffering full
- puts hello
- puts hello
- flush stdout
- gets stdin
- puts bye
- flush stdout
- }
- close $f1
- set f1 [open "|[list $tcltest pipe]" r+]
- set x ""
- lappend x [gets $f1]
- lappend x [gets $f1]
- puts $f1 hello
- flush $f1
- lappend x [gets $f1]
- close $f1
- set x
-} {hello hello bye}
-test io-29.23 {Tcl_Flush and line buffering at end of pipe} {stdio} {
- removeFile pipe
- set f1 [open pipe w]
- puts $f1 {
- puts hello
- puts hello
- gets stdin
- puts bye
- }
- close $f1
- set f1 [open "|[list $tcltest pipe]" r+]
- set x ""
- lappend x [gets $f1]
- lappend x [gets $f1]
- puts $f1 hello
- flush $f1
- lappend x [gets $f1]
- close $f1
- set x
-} {hello hello bye}
-test io-29.24 {Tcl_WriteChars and Tcl_Flush move end of file} {
- set f [open test3 w]
- puts $f "Line 1"
- puts $f "Line 2"
- set f2 [open test3]
- set x {}
- lappend x [read -nonewline $f2]
- close $f2
- flush $f
- set f2 [open test3]
- lappend x [read -nonewline $f2]
- close $f2
- close $f
- set x
-} "{} {Line 1\nLine 2}"
-test io-29.25 {Implicit flush with Tcl_Flush to command pipelines} {stdio} {
- removeFile test3
- set f [open "|[list $tcltest cat | $tcltest cat > test3]" w]
- puts $f "Line 1"
- puts $f "Line 2"
- close $f
- after 100
- set f [open test3 r]
- set x [read $f]
- close $f
- set x
-} "Line 1\nLine 2\n"
-test io-29.26 {Tcl_Flush, Tcl_Write on bidirectional pipelines} {stdio unixExecs} {
- set f [open "|[list cat -u]" r+]
- puts $f "Line1"
- flush $f
- set x [gets $f]
- close $f
- set x
-} {Line1}
-test io-29.27 {Tcl_Flush on closed pipeline} {stdio} {
- removeFile pipe
- set f [open pipe w]
- puts $f {exit}
- close $f
- set f [open "|[list $tcltest pipe]" r+]
- gets $f
- puts $f output
- after 50
- #
- # The flush below will get a SIGPIPE. This is an expected part of
- # test and indicates that the test operates correctly. If you run
- # this test under a debugger, the signal will by intercepted unless
- # you disable the debugger's signal interception.
- #
- if {[catch {flush $f} msg]} {
- set x [list 1 $msg $errorCode]
- catch {close $f}
- } else {
- if {[catch {close $f} msg]} {
- set x [list 1 $msg $errorCode]
- } else {
- set x {this was supposed to fail and did not}
- }
- }
- regsub {".*":} $x {"":} x
- string tolower $x
-} {1 {error flushing "": broken pipe} {posix epipe {broken pipe}}}
-test io-29.28 {Tcl_WriteChars, lf mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar {}
- puts $f hello\nthere\nand\nhere
- flush $f
- set s [file size test1]
- close $f
- set s
-} 21
-test io-29.29 {Tcl_WriteChars, cr mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr -eofchar {}
- puts $f hello\nthere\nand\nhere
- close $f
- file size test1
-} 21
-test io-29.30 {Tcl_WriteChars, crlf mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf -eofchar {}
- puts $f hello\nthere\nand\nhere
- close $f
- file size test1
-} 25
-test io-29.31 {Tcl_WriteChars, background flush} {stdio} {
- removeFile pipe
- removeFile output
- set f [open pipe w]
- puts $f {set f [open output w]}
- puts $f {fconfigure $f -translation lf}
- set x [list while {![eof stdin]}]
- set x "$x {"
- puts $f $x
- puts $f { puts -nonewline $f [read stdin 4096]}
- puts $f { flush $f}
- puts $f "}"
- puts $f {close $f}
- close $f
- set x 01234567890123456789012345678901
- for {set i 0} {$i < 11} {incr i} {
- set x "$x$x"
- }
- set f [open output w]
- close $f
- set f [open "|[list $tcltest pipe]" r+]
- fconfigure $f -blocking off
- puts -nonewline $f $x
- close $f
- set counter 0
- while {([file size output] < 65536) && ($counter < 1000)} {
- incr counter
- after 5
- update
- }
- if {$counter == 1000} {
- set result "file size only [file size output]"
- } else {
- set result ok
- }
-} ok
-test io-29.32 {Tcl_WriteChars, background flush to slow reader} \
- {stdio asyncPipeClose} {
- removeFile pipe
- removeFile output
- set f [open pipe w]
- puts $f {set f [open output w]}
- puts $f {fconfigure $f -translation lf}
- set x [list while {![eof stdin]}]
- set x "$x {"
- puts $f $x
- puts $f { after 20}
- puts $f { puts -nonewline $f [read stdin 1024]}
- puts $f { flush $f}
- puts $f "}"
- puts $f {close $f}
- close $f
- set x 01234567890123456789012345678901
- for {set i 0} {$i < 11} {incr i} {
- set x "$x$x"
- }
- set f [open output w]
- close $f
- set f [open "|[list $tcltest pipe]" r+]
- fconfigure $f -blocking off
- puts -nonewline $f $x
- close $f
- set counter 0
- while {([file size output] < 65536) && ($counter < 1000)} {
- incr counter
- after 20
- update
- }
- if {$counter == 1000} {
- set result "file size only [file size output]"
- } else {
- set result ok
- }
-} ok
-test io-29.33 {Tcl_Flush, implicit flush on exit} {stdio} {
- set f [open script w]
- puts $f {
- set f [open test1 w]
- fconfigure $f -translation lf
- puts $f hello
- puts $f bye
- puts $f strange
- }
- close $f
- exec $tcltest script
- set f [open test1 r]
- set r [read $f]
- close $f
- set r
-} "hello\nbye\nstrange\n"
-test io-29.34 {Tcl_Close, async flush on close, using sockets} {socket tempNotMac} {
- set c 0
- set x running
- set l abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
- proc writelots {s l} {
- for {set i 0} {$i < 2000} {incr i} {
- puts $s $l
- }
- }
- proc accept {s a p} {
- global x
- fileevent $s readable [list readit $s]
- fconfigure $s -blocking off
- set x accepted
- }
- proc readit {s} {
- global c x
- set l [gets $s]
-
- if {[eof $s]} {
- close $s
- set x done
- } elseif {([string length $l] > 0) || ![fblocked $s]} {
- incr c
- }
- }
- set ss [socket -server accept 2828]
- set cs [socket [info hostname] 2828]
- vwait x
- fconfigure $cs -blocking off
- writelots $cs $l
- close $cs
- close $ss
- vwait x
- set c
-} 2000
-test io-29.35 {Tcl_Close vs fileevent vs multiple interpreters} {socket tempNotMac} {
- # On Mac, this test screws up sockets such that subsequent tests using port 2828
- # either cause errors or panic().
-
- catch {interp delete x}
- catch {interp delete y}
- interp create x
- interp create y
- set s [socket -server accept 2828]
- proc accept {s a p} {
- puts $s hello
- close $s
- }
- set c [socket [info hostname] 2828]
- interp share {} $c x
- interp share {} $c y
- close $c
- x eval {
- proc readit {s} {
- gets $s
- if {[eof $s]} {
- close $s
- }
- }
- }
- y eval {
- proc readit {s} {
- gets $s
- if {[eof $s]} {
- close $s
- }
- }
- }
- x eval "fileevent $c readable \{readit $c\}"
- y eval "fileevent $c readable \{readit $c\}"
- y eval [list close $c]
- update
- close $s
- interp delete x
- interp delete y
-} ""
-
-# Test end of line translations. Procedures tested are Tcl_Write, Tcl_Read.
-
-test io-30.1 {Tcl_Write lf, Tcl_Read lf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation lf
- set x [read $f]
- close $f
- set x
-} "hello\nthere\nand\nhere\n"
-test io-30.2 {Tcl_Write lf, Tcl_Read cr} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation cr
- set x [read $f]
- close $f
- set x
-} "hello\nthere\nand\nhere\n"
-test io-30.3 {Tcl_Write lf, Tcl_Read crlf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation crlf
- set x [read $f]
- close $f
- set x
-} "hello\nthere\nand\nhere\n"
-test io-30.4 {Tcl_Write cr, Tcl_Read cr} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation cr
- set x [read $f]
- close $f
- set x
-} "hello\nthere\nand\nhere\n"
-test io-30.5 {Tcl_Write cr, Tcl_Read lf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation lf
- set x [read $f]
- close $f
- set x
-} "hello\rthere\rand\rhere\r"
-test io-30.6 {Tcl_Write cr, Tcl_Read crlf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation crlf
- set x [read $f]
- close $f
- set x
-} "hello\rthere\rand\rhere\r"
-test io-30.7 {Tcl_Write crlf, Tcl_Read crlf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation crlf
- set x [read $f]
- close $f
- set x
-} "hello\nthere\nand\nhere\n"
-test io-30.8 {Tcl_Write crlf, Tcl_Read lf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation lf
- set x [read $f]
- close $f
- set x
-} "hello\r\nthere\r\nand\r\nhere\r\n"
-test io-30.9 {Tcl_Write crlf, Tcl_Read cr} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation cr
- set x [read $f]
- close $f
- set x
-} "hello\n\nthere\n\nand\n\nhere\n\n"
-test io-30.10 {Tcl_Write lf, Tcl_Read auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- set c [read $f]
- set x [fconfigure $f -translation]
- close $f
- list $c $x
-} {{hello
-there
-and
-here
-} auto}
-test io-30.11 {Tcl_Write cr, Tcl_Read auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- set c [read $f]
- set x [fconfigure $f -translation]
- close $f
- list $c $x
-} {{hello
-there
-and
-here
-} auto}
-test io-30.12 {Tcl_Write crlf, Tcl_Read auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- set c [read $f]
- set x [fconfigure $f -translation]
- close $f
- list $c $x
-} {{hello
-there
-and
-here
-} auto}
-
-test io-30.13 {Tcl_Write crlf on block boundary, Tcl_Read auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- set line "123456789ABCDE" ;# 14 char plus crlf
- puts -nonewline $f x ;# shift crlf across block boundary
- for {set i 0} {$i < 700} {incr i} {
- puts $f $line
- }
- close $f
- set f [open test1 r]
- fconfigure $f -translation auto
- set c [read $f]
- close $f
- string length $c
-} [expr 700*15+1]
-
-test io-30.14 {Tcl_Write crlf on block boundary, Tcl_Read crlf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- set line "123456789ABCDE" ;# 14 char plus crlf
- puts -nonewline $f x ;# shift crlf across block boundary
- for {set i 0} {$i < 700} {incr i} {
- puts $f $line
- }
- close $f
- set f [open test1 r]
- fconfigure $f -translation crlf
- set c [read $f]
- close $f
- string length $c
-} [expr 700*15+1]
-
-test io-30.15 {Tcl_Write mixed, Tcl_Read auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts $f hello\nthere\nand\rhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation auto
- set c [read $f]
- close $f
- set c
-} {hello
-there
-and
-here
-}
-test io-30.16 {Tcl_Write ^Z at end, Tcl_Read auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f hello\nthere\nand\rhere\n\x1a
- close $f
- set f [open test1 r]
- fconfigure $f -eofchar \x1a -translation auto
- set c [read $f]
- close $f
- set c
-} {hello
-there
-and
-here
-}
-test io-30.17 {Tcl_Write, implicit ^Z at end, Tcl_Read auto} {pcOnly} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -eofchar \x1a -translation lf
- puts $f hello\nthere\nand\rhere
- close $f
- set f [open test1 r]
- fconfigure $f -eofchar \x1a -translation auto
- set c [read $f]
- close $f
- set c
-} {hello
-there
-and
-here
-}
-test io-30.18 {Tcl_Write, ^Z in middle, Tcl_Read auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- set s [format "abc\ndef\n%cghi\nqrs" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -eofchar \x1a -translation auto
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {abc def 0 {} 1 {} 1}
-test io-30.19 {Tcl_Write, ^Z no newline in middle, Tcl_Read auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- set s [format "abc\ndef\n%cghi\nqrs" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -eofchar \x1a -translation auto
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {abc def 0 {} 1 {} 1}
-test io-30.20 {Tcl_Write, ^Z in middle ignored, Tcl_Read lf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar {}
- set s [format "abc\ndef\n%cghi\nqrs" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -translation lf -eofchar {}
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} "abc def 0 \x1aghi 0 qrs 0 {} 1"
-test io-30.21 {Tcl_Write, ^Z in middle ignored, Tcl_Read cr} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar {}
- set s [format "abc\ndef\n%cghi\nqrs" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -translation cr -eofchar {}
- set l ""
- set x [gets $f]
- lappend l [string compare $x "abc\ndef\n\x1aghi\nqrs\n"]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {0 1 {} 1}
-test io-30.22 {Tcl_Write, ^Z in middle ignored, Tcl_Read crlf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar {}
- set s [format "abc\ndef\n%cghi\nqrs" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -translation crlf -eofchar {}
- set l ""
- set x [gets $f]
- lappend l [string compare $x "abc\ndef\n\x1aghi\nqrs\n"]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {0 1 {} 1}
-test io-30.23 {Tcl_Write lf, ^Z in middle, Tcl_Read auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- set c [format abc\ndef\n%cqrs\ntuv 26]
- puts $f $c
- close $f
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- set c [string length [read $f]]
- set e [eof $f]
- close $f
- list $c $e
-} {8 1}
-test io-30.24 {Tcl_Write lf, ^Z in middle, Tcl_Read lf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- set c [format abc\ndef\n%cqrs\ntuv 26]
- puts $f $c
- close $f
- set f [open test1 r]
- fconfigure $f -translation lf -eofchar \x1a
- set c [string length [read $f]]
- set e [eof $f]
- close $f
- list $c $e
-} {8 1}
-test io-30.25 {Tcl_Write cr, ^Z in middle, Tcl_Read auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr
- set c [format abc\ndef\n%cqrs\ntuv 26]
- puts $f $c
- close $f
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- set c [string length [read $f]]
- set e [eof $f]
- close $f
- list $c $e
-} {8 1}
-test io-30.26 {Tcl_Write cr, ^Z in middle, Tcl_Read cr} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr
- set c [format abc\ndef\n%cqrs\ntuv 26]
- puts $f $c
- close $f
- set f [open test1 r]
- fconfigure $f -translation cr -eofchar \x1a
- set c [string length [read $f]]
- set e [eof $f]
- close $f
- list $c $e
-} {8 1}
-test io-30.27 {Tcl_Write crlf, ^Z in middle, Tcl_Read auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- set c [format abc\ndef\n%cqrs\ntuv 26]
- puts $f $c
- close $f
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- set c [string length [read $f]]
- set e [eof $f]
- close $f
- list $c $e
-} {8 1}
-test io-30.28 {Tcl_Write crlf, ^Z in middle, Tcl_Read crlf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- set c [format abc\ndef\n%cqrs\ntuv 26]
- puts $f $c
- close $f
- set f [open test1 r]
- fconfigure $f -translation crlf -eofchar \x1a
- set c [string length [read $f]]
- set e [eof $f]
- close $f
- list $c $e
-} {8 1}
-
-# Test end of line translations. Functions tested are Tcl_Write and Tcl_Gets.
-
-test io-31.1 {Tcl_Write lf, Tcl_Gets auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- set l ""
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- close $f
- set l
-} {hello 6 auto there 12 auto}
-test io-31.2 {Tcl_Write cr, Tcl_Gets auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- set l ""
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- close $f
- set l
-} {hello 6 auto there 12 auto}
-test io-31.3 {Tcl_Write crlf, Tcl_Gets auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- set l ""
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- close $f
- set l
-} {hello 7 auto there 14 auto}
-test io-31.4 {Tcl_Write lf, Tcl_Gets lf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation lf
- set l ""
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- close $f
- set l
-} {hello 6 lf there 12 lf}
-test io-31.5 {Tcl_Write lf, Tcl_Gets cr} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation cr
- set l ""
- lappend l [string length [gets $f]]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- close $f
- set l
-} {21 21 cr 1 {} 21 cr 1}
-test io-31.6 {Tcl_Write lf, Tcl_Gets crlf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation crlf
- set l ""
- lappend l [string length [gets $f]]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- close $f
- set l
-} {21 21 crlf 1 {} 21 crlf 1}
-test io-31.7 {Tcl_Write cr, Tcl_Gets cr} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation cr
- set l ""
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- close $f
- set l
-} {hello 6 cr 0 there 12 cr 0}
-test io-31.8 {Tcl_Write cr, Tcl_Gets lf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation lf
- set l ""
- lappend l [string length [gets $f]]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- close $f
- set l
-} {21 21 lf 1 {} 21 lf 1}
-test io-31.9 {Tcl_Write cr, Tcl_Gets crlf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation crlf
- set l ""
- lappend l [string length [gets $f]]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- close $f
- set l
-} {21 21 crlf 1 {} 21 crlf 1}
-test io-31.10 {Tcl_Write crlf, Tcl_Gets crlf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation crlf
- set l ""
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- close $f
- set l
-} {hello 7 crlf 0 there 14 crlf 0}
-test io-31.11 {Tcl_Write crlf, Tcl_Gets cr} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation cr
- set l ""
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- lappend l [string length [gets $f]]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- close $f
- set l
-} {hello 6 cr 0 6 13 cr 0}
-test io-31.12 {Tcl_Write crlf, Tcl_Gets lf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- puts $f hello\nthere\nand\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation lf
- set l ""
- lappend l [string length [gets $f]]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- lappend l [string length [gets $f]]
- lappend l [tell $f]
- lappend l [fconfigure $f -translation]
- lappend l [eof $f]
- close $f
- set l
-} {6 7 lf 0 6 14 lf 0}
-test io-31.13 {binary mode is synonym of lf mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation binary
- set x [fconfigure $f -translation]
- close $f
- set x
-} lf
-#
-# Test io-9.14 has been removed because "auto" output translation mode is
-# not supoprted.
-#
-test io-31.14 {Tcl_Write mixed, Tcl_Gets auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts $f hello\nthere\rand\r\nhere
- close $f
- set f [open test1 r]
- fconfigure $f -translation auto
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {hello there and here 0 {} 1}
-test io-31.15 {Tcl_Write mixed, Tcl_Gets auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f hello\nthere\rand\r\nhere\r
- close $f
- set f [open test1 r]
- fconfigure $f -translation auto
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {hello there and here 0 {} 1}
-test io-31.16 {Tcl_Write mixed, Tcl_Gets auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f hello\nthere\rand\r\nhere\n
- close $f
- set f [open test1 r]
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {hello there and here 0 {} 1}
-test io-31.17 {Tcl_Write mixed, Tcl_Gets auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f hello\nthere\rand\r\nhere\r\n
- close $f
- set f [open test1 r]
- fconfigure $f -translation auto
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {hello there and here 0 {} 1}
-test io-31.18 {Tcl_Write ^Z at end, Tcl_Gets auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- set s [format "hello\nthere\nand\rhere\n\%c" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -eofchar \x1a -translation auto
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {hello there and here 0 {} 1}
-test io-31.19 {Tcl_Write, implicit ^Z at end, Tcl_Gets auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -eofchar \x1a -translation lf
- puts $f hello\nthere\nand\rhere
- close $f
- set f [open test1 r]
- fconfigure $f -eofchar \x1a -translation auto
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {hello there and here 0 {} 1}
-test io-31.20 {Tcl_Write, ^Z in middle, Tcl_Gets auto, eofChar} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- set s [format "abc\ndef\n%cqrs\ntuv" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -eofchar \x1a
- fconfigure $f -translation auto
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {abc def 0 {} 1}
-test io-31.21 {Tcl_Write, no newline ^Z in middle, Tcl_Gets auto, eofChar} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- set s [format "abc\ndef\n%cqrs\ntuv" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -eofchar \x1a -translation auto
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {abc def 0 {} 1}
-test io-31.22 {Tcl_Write, ^Z in middle ignored, Tcl_Gets lf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar {}
- set s [format "abc\ndef\n%cqrs\ntuv" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -translation lf -eofchar {}
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} "abc def 0 \x1aqrs 0 tuv 0 {} 1"
-test io-31.23 {Tcl_Write, ^Z in middle ignored, Tcl_Gets cr} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr -eofchar {}
- set s [format "abc\ndef\n%cqrs\ntuv" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -translation cr -eofchar {}
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} "abc def 0 \x1aqrs 0 tuv 0 {} 1"
-test io-31.24 {Tcl_Write, ^Z in middle ignored, Tcl_Gets crlf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf -eofchar {}
- set s [format "abc\ndef\n%cqrs\ntuv" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -translation crlf -eofchar {}
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} "abc def 0 \x1aqrs 0 tuv 0 {} 1"
-test io-31.25 {Tcl_Write lf, ^Z in middle, Tcl_Gets auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- set s [format "abc\ndef\n%cqrs\ntuv" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {abc def 0 {} 1}
-test io-31.26 {Tcl_Write lf, ^Z in middle, Tcl_Gets lf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- set s [format "abc\ndef\n%cqrs\ntuv" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -translation lf -eofchar \x1a
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {abc def 0 {} 1}
-test io-31.27 {Tcl_Write cr, ^Z in middle, Tcl_Gets auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr -eofchar {}
- set s [format "abc\ndef\n%cqrs\ntuv" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {abc def 0 {} 1}
-test io-31.28 {Tcl_Write cr, ^Z in middle, Tcl_Gets cr} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr -eofchar {}
- set s [format "abc\ndef\n%cqrs\ntuv" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -translation cr -eofchar \x1a
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {abc def 0 {} 1}
-test io-31.29 {Tcl_Write crlf, ^Z in middle, Tcl_Gets auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf -eofchar {}
- set s [format "abc\ndef\n%cqrs\ntuv" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {abc def 0 {} 1}
-test io-31.30 {Tcl_Write crlf, ^Z in middle, Tcl_Gets crlf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf -eofchar {}
- set s [format "abc\ndef\n%cqrs\ntuv" 26]
- puts $f $s
- close $f
- set f [open test1 r]
- fconfigure $f -translation crlf -eofchar \x1a
- set l ""
- lappend l [gets $f]
- lappend l [gets $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {abc def 0 {} 1}
-test io-31.31 {Tcl_Write crlf on block boundary, Tcl_Gets crlf} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- set line "123456789ABCDE" ;# 14 char plus crlf
- puts -nonewline $f x ;# shift crlf across block boundary
- for {set i 0} {$i < 700} {incr i} {
- puts $f $line
- }
- close $f
- set f [open test1 r]
- fconfigure $f -translation crlf
- set c ""
- while {[gets $f line] >= 0} {
- append c $line\n
- }
- close $f
- string length $c
-} [expr 700*15+1]
-test io-31.32 {Tcl_Write crlf on block boundary, Tcl_Gets auto} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- set line "123456789ABCDE" ;# 14 char plus crlf
- puts -nonewline $f x ;# shift crlf across block boundary
- for {set i 0} {$i < 700} {incr i} {
- puts $f $line
- }
- close $f
- set f [open test1 r]
- fconfigure $f -translation auto
- set c ""
- while {[gets $f line] >= 0} {
- append c $line\n
- }
- close $f
- string length $c
-} [expr 700*15+1]
-
-
-# Test Tcl_Read and buffering.
-
-test io-32.1 {Tcl_Read, channel not readable} {
- list [catch {read stdout} msg] $msg
-} {1 {channel "stdout" wasn't opened for reading}}
-test io-32.2 {Tcl_Read, zero byte count} {
- read stdin 0
-} ""
-test io-32.3 {Tcl_Read, negative byte count} {
- set f [open longfile r]
- set l [list [catch {read $f -1} msg] $msg]
- close $f
- set l
-} {1 {bad argument "-1": should be "nonewline"}}
-test io-32.4 {Tcl_Read, positive byte count} {
- set f [open longfile r]
- set x [read $f 1024]
- set s [string length $x]
- unset x
- close $f
- set s
-} 1024
-test io-32.5 {Tcl_Read, multiple buffers} {
- set f [open longfile r]
- fconfigure $f -buffersize 100
- set x [read $f 1024]
- set s [string length $x]
- unset x
- close $f
- set s
-} 1024
-test io-32.6 {Tcl_Read, very large read} {
- set f1 [open longfile r]
- set z [read $f1 1000000]
- close $f1
- set l [string length $z]
- set x ok
- set z [file size longfile]
- if {$z != $l} {
- set x broken
- }
- set x
-} ok
-test io-32.7 {Tcl_Read, nonblocking, file} {nonBlockFiles} {
- set f1 [open longfile r]
- fconfigure $f1 -blocking off
- set z [read $f1 20]
- close $f1
- set l [string length $z]
- set x ok
- if {$l != 20} {
- set x broken
- }
- set x
-} ok
-test io-32.8 {Tcl_Read, nonblocking, file} {nonBlockFiles} {
- set f1 [open longfile r]
- fconfigure $f1 -blocking off
- set z [read $f1 1000000]
- close $f1
- set x ok
- set l [string length $z]]
- set z [file size longfile]]
- if {$z != $l} {
- set x broken
- }
- set x
-} ok
-test io-32.9 {Tcl_Read, read to end of file} {
- set f1 [open longfile r]
- set z [read $f1]
- close $f1
- set l [string length $z]
- set x ok
- set z [file size longfile]
- if {$z != $l} {
- set x broken
- }
- set x
-} ok
-test io-32.10 {Tcl_Read from a pipe} {stdio} {
- removeFile pipe
- set f1 [open pipe w]
- puts $f1 {puts [gets stdin]}
- close $f1
- set f1 [open "|[list $tcltest pipe]" r+]
- puts $f1 hello
- flush $f1
- set x [read $f1]
- close $f1
- set x
-} "hello\n"
-test io-32.11 {Tcl_Read from a pipe} {stdio} {
- removeFile pipe
- set f1 [open pipe w]
- puts $f1 {puts [gets stdin]}
- puts $f1 {puts [gets stdin]}
- close $f1
- set f1 [open "|[list $tcltest pipe]" r+]
- puts $f1 hello
- flush $f1
- set x ""
- lappend x [read $f1 6]
- puts $f1 hello
- flush $f1
- lappend x [read $f1]
- close $f1
- set x
-} {{hello
-} {hello
-}}
-test io-32.12 {Tcl_Read, -nonewline} {
- removeFile test1
- set f1 [open test1 w]
- puts $f1 hello
- puts $f1 bye
- close $f1
- set f1 [open test1 r]
- set c [read -nonewline $f1]
- close $f1
- set c
-} {hello
-bye}
-test io-32.13 {Tcl_Read, -nonewline} {
- removeFile test1
- set f1 [open test1 w]
- puts $f1 hello
- puts $f1 bye
- close $f1
- set f1 [open test1 r]
- set c [read -nonewline $f1]
- close $f1
- list [string length $c] $c
-} {9 {hello
-bye}}
-test io-32.14 {Tcl_Read, reading in small chunks} {
- removeFile test1
- set f [open test1 w]
- puts $f "Two lines: this one"
- puts $f "and this one"
- close $f
- set f [open test1]
- set x [list [read $f 1] [read $f 2] [read $f]]
- close $f
- set x
-} {T wo { lines: this one
-and this one
-}}
-test io-32.15 {Tcl_Read, asking for more input than available} {
- removeFile test1
- set f [open test1 w]
- puts $f "Two lines: this one"
- puts $f "and this one"
- close $f
- set f [open test1]
- set x [read $f 100]
- close $f
- set x
-} {Two lines: this one
-and this one
-}
-test io-32.16 {Tcl_Read, read to end of file with -nonewline} {
- removeFile test1
- set f [open test1 w]
- puts $f "Two lines: this one"
- puts $f "and this one"
- close $f
- set f [open test1]
- set x [read -nonewline $f]
- close $f
- set x
-} {Two lines: this one
-and this one}
-
-# Test Tcl_Gets.
-
-test io-33.1 {Tcl_Gets, reading what was written} {
- removeFile test1
- set f1 [open test1 w]
- set y "first line"
- puts $f1 $y
- close $f1
- set f1 [open test1 r]
- set x [gets $f1]
- set z ok
- if {"$x" != "$y"} {
- set z broken
- }
- close $f1
- set z
-} ok
-test io-33.2 {Tcl_Gets into variable} {
- set f1 [open longfile r]
- set c [gets $f1 x]
- set l [string length x]
- set z ok
- if {$l != $l} {
- set z broken
- }
- close $f1
- set z
-} ok
-test io-33.3 {Tcl_Gets from pipe} {stdio} {
- removeFile pipe
- set f1 [open pipe w]
- puts $f1 {puts [gets stdin]}
- close $f1
- set f1 [open "|[list $tcltest pipe]" r+]
- puts $f1 hello
- flush $f1
- set x [gets $f1]
- close $f1
- set z ok
- if {"$x" != "hello"} {
- set z broken
- }
- set z
-} ok
-test io-33.4 {Tcl_Gets with long line} {
- removeFile test3
- set f [open test3 w]
- puts -nonewline $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- puts -nonewline $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- puts -nonewline $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- puts -nonewline $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- puts $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- close $f
- set f [open test3]
- set x [gets $f]
- close $f
- set x
-} {abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ}
-test io-33.5 {Tcl_Gets with long line} {
- set f [open test3]
- set x [gets $f y]
- close $f
- list $x $y
-} {260 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ}
-test io-33.6 {Tcl_Gets and end of file} {
- removeFile test3
- set f [open test3 w]
- puts -nonewline $f "Test1\nTest2"
- close $f
- set f [open test3]
- set x {}
- set y {}
- lappend x [gets $f y] $y
- set y {}
- lappend x [gets $f y] $y
- set y {}
- lappend x [gets $f y] $y
- close $f
- set x
-} {5 Test1 5 Test2 -1 {}}
-test io-33.7 {Tcl_Gets and bad variable} {
- set f [open test3 w]
- puts $f "Line 1"
- puts $f "Line 2"
- close $f
- catch {unset x}
- set x 24
- set f [open test3 r]
- set result [list [catch {gets $f x(0)} msg] $msg]
- close $f
- set result
-} {1 {can't set "x(0)": variable isn't array}}
-test io-33.8 {Tcl_Gets, exercising double buffering} {
- set f [open test3 w]
- fconfigure $f -translation lf -eofchar {}
- set x ""
- for {set y 0} {$y < 99} {incr y} {set x "a$x"}
- for {set y 0} {$y < 100} {incr y} {puts $f $x}
- close $f
- set f [open test3 r]
- fconfigure $f -translation lf
- for {set y 0} {$y < 100} {incr y} {gets $f}
- close $f
- set y
-} 100
-test io-33.9 {Tcl_Gets, exercising double buffering} {
- set f [open test3 w]
- fconfigure $f -translation lf -eofchar {}
- set x ""
- for {set y 0} {$y < 99} {incr y} {set x "a$x"}
- for {set y 0} {$y < 200} {incr y} {puts $f $x}
- close $f
- set f [open test3 r]
- fconfigure $f -translation lf
- for {set y 0} {$y < 200} {incr y} {gets $f}
- close $f
- set y
-} 200
-test io-33.10 {Tcl_Gets, exercising double buffering} {
- set f [open test3 w]
- fconfigure $f -translation lf -eofchar {}
- set x ""
- for {set y 0} {$y < 99} {incr y} {set x "a$x"}
- for {set y 0} {$y < 300} {incr y} {puts $f $x}
- close $f
- set f [open test3 r]
- fconfigure $f -translation lf
- for {set y 0} {$y < 300} {incr y} {gets $f}
- close $f
- set y
-} 300
-
-# Test Tcl_Seek and Tcl_Tell.
-
-test io-34.1 {Tcl_Seek to current position at start of file} {
- set f1 [open longfile r]
- seek $f1 0 current
- set c [tell $f1]
- close $f1
- set c
-} 0
-test io-34.2 {Tcl_Seek to offset from start} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf -eofchar {}
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- close $f1
- set f1 [open test1 r]
- seek $f1 10 start
- set c [tell $f1]
- close $f1
- set c
-} 10
-test io-34.3 {Tcl_Seek to end of file} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf -eofchar {}
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- close $f1
- set f1 [open test1 r]
- seek $f1 0 end
- set c [tell $f1]
- close $f1
- set c
-} 54
-test io-34.4 {Tcl_Seek to offset from end of file} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf -eofchar {}
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- close $f1
- set f1 [open test1 r]
- seek $f1 -10 end
- set c [tell $f1]
- close $f1
- set c
-} 44
-test io-34.5 {Tcl_Seek to offset from current position} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf -eofchar {}
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- close $f1
- set f1 [open test1 r]
- seek $f1 10 current
- seek $f1 10 current
- set c [tell $f1]
- close $f1
- set c
-} 20
-test io-34.6 {Tcl_Seek to offset from end of file} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf -eofchar {}
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- close $f1
- set f1 [open test1 r]
- seek $f1 -10 end
- set c [tell $f1]
- set r [read $f1]
- close $f1
- list $c $r
-} {44 {rstuvwxyz
-}}
-test io-34.7 {Tcl_Seek to offset from end of file, then to current position} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf -eofchar {}
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- close $f1
- set f1 [open test1 r]
- seek $f1 -10 end
- set c1 [tell $f1]
- set r1 [read $f1 5]
- seek $f1 0 current
- set c2 [tell $f1]
- close $f1
- list $c1 $r1 $c2
-} {44 rstuv 49}
-test io-34.8 {Tcl_Seek on pipes: not supported} {stdio} {
- set f1 [open "|[list $tcltest]" r+]
- set x [list [catch {seek $f1 0 current} msg] $msg]
- close $f1
- regsub {".*":} $x {"":} x
- string tolower $x
-} {1 {error during seek on "": invalid argument}}
-test io-34.9 {Tcl_Seek, testing buffered input flushing} {
- removeFile test3
- set f [open test3 w]
- fconfigure $f -eofchar {}
- puts -nonewline $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- close $f
- set f [open test3 RDWR]
- set x [read $f 1]
- seek $f 3
- lappend x [read $f 1]
- seek $f 0 start
- lappend x [read $f 1]
- seek $f 10 current
- lappend x [read $f 1]
- seek $f -2 end
- lappend x [read $f 1]
- seek $f 50 end
- lappend x [read $f 1]
- seek $f 1
- lappend x [read $f 1]
- close $f
- set x
-} {a d a l Y {} b}
-test io-34.10 {Tcl_Seek testing flushing of buffered input} {
- set f [open test3 w]
- fconfigure $f -translation lf
- puts $f xyz\n123
- close $f
- set f [open test3 r+]
- fconfigure $f -translation lf
- set x [gets $f]
- seek $f 0 current
- puts $f 456
- close $f
- list $x [viewFile test3]
-} "xyz {xyz
-456}"
-test io-34.11 {Tcl_Seek testing flushing of buffered output} {
- set f [open test3 w]
- puts $f xyz\n123
- close $f
- set f [open test3 w+]
- puts $f xyzzy
- seek $f 2
- set x [gets $f]
- close $f
- list $x [viewFile test3]
-} "zzy xyzzy"
-test io-34.12 {Tcl_Seek testing combination of write, seek back and read} {
- set f [open test3 w]
- fconfigure $f -translation lf -eofchar {}
- puts $f xyz\n123
- close $f
- set f [open test3 a+]
- fconfigure $f -translation lf -eofchar {}
- puts $f xyzzy
- flush $f
- set x [tell $f]
- seek $f -4 cur
- set y [gets $f]
- close $f
- list $x [viewFile test3] $y
-} {14 {xyz
-123
-xyzzy} zzy}
-test io-34.13 {Tcl_Tell at start of file} {
- removeFile test1
- set f1 [open test1 w]
- set p [tell $f1]
- close $f1
- set p
-} 0
-test io-34.14 {Tcl_Tell after seek to end of file} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf -eofchar {}
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- close $f1
- set f1 [open test1 r]
- seek $f1 0 end
- set c1 [tell $f1]
- close $f1
- set c1
-} 54
-test io-34.15 {Tcl_Tell combined with seeking} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf -eofchar {}
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- puts $f1 "abcdefghijklmnopqrstuvwxyz"
- close $f1
- set f1 [open test1 r]
- seek $f1 10 start
- set c1 [tell $f1]
- seek $f1 10 current
- set c2 [tell $f1]
- close $f1
- list $c1 $c2
-} {10 20}
-test io-34.16 {Tcl_tell on pipe: always -1} {stdio} {
- set f1 [open "|[list $tcltest]" r+]
- set c [tell $f1]
- close $f1
- set c
-} -1
-test io-34.17 {Tcl_Tell on pipe: always -1} {stdio} {
- set f1 [open "|[list $tcltest]" r+]
- puts $f1 {puts hello}
- flush $f1
- set c [tell $f1]
- gets $f1
- close $f1
- set c
-} -1
-test io-34.18 {Tcl_Tell combined with seeking and reading} {
- removeFile test2
- set f [open test2 w]
- fconfigure $f -translation lf -eofchar {}
- puts -nonewline $f "line1\nline2\nline3\nline4\nline5\n"
- close $f
- set f [open test2]
- fconfigure $f -translation lf
- set x [tell $f]
- read $f 3
- lappend x [tell $f]
- seek $f 2
- lappend x [tell $f]
- seek $f 10 current
- lappend x [tell $f]
- seek $f 0 end
- lappend x [tell $f]
- close $f
- set x
-} {0 3 2 12 30}
-test io-34.19 {Tcl_Tell combined with opening in append mode} {
- set f [open test3 w]
- fconfigure $f -translation lf -eofchar {}
- puts $f "abcdefghijklmnopqrstuvwxyz"
- puts $f "abcdefghijklmnopqrstuvwxyz"
- close $f
- set f [open test3 a]
- set c [tell $f]
- close $f
- set c
-} 54
-test io-34.20 {Tcl_Tell combined with writing} {
- set f [open test3 w]
- set l ""
- seek $f 29 start
- lappend l [tell $f]
- puts -nonewline $f a
- seek $f 39 start
- lappend l [tell $f]
- puts -nonewline $f a
- lappend l [tell $f]
- seek $f 407 end
- lappend l [tell $f]
- close $f
- set l
-} {29 39 40 447}
-
-# Test Tcl_Eof
-
-test io-35.1 {Tcl_Eof} {
- removeFile test1
- set f [open test1 w]
- puts $f hello
- puts $f hello
- close $f
- set f [open test1]
- set x [eof $f]
- lappend x [eof $f]
- gets $f
- lappend x [eof $f]
- gets $f
- lappend x [eof $f]
- gets $f
- lappend x [eof $f]
- lappend x [eof $f]
- close $f
- set x
-} {0 0 0 0 1 1}
-test io-35.2 {Tcl_Eof with pipe} {stdio} {
- removeFile pipe
- set f1 [open pipe w]
- puts $f1 {gets stdin}
- puts $f1 {puts hello}
- close $f1
- set f1 [open "|[list $tcltest pipe]" r+]
- puts $f1 hello
- set x [eof $f1]
- flush $f1
- lappend x [eof $f1]
- gets $f1
- lappend x [eof $f1]
- gets $f1
- lappend x [eof $f1]
- close $f1
- set x
-} {0 0 0 1}
-test io-35.3 {Tcl_Eof with pipe} {stdio} {
- removeFile pipe
- set f1 [open pipe w]
- puts $f1 {gets stdin}
- puts $f1 {puts hello}
- close $f1
- set f1 [open "|[list $tcltest pipe]" r+]
- puts $f1 hello
- set x [eof $f1]
- flush $f1
- lappend x [eof $f1]
- gets $f1
- lappend x [eof $f1]
- gets $f1
- lappend x [eof $f1]
- gets $f1
- lappend x [eof $f1]
- gets $f1
- lappend x [eof $f1]
- close $f1
- set x
-} {0 0 0 1 1 1}
-test io-35.4 {Tcl_Eof, eof detection on nonblocking file} {nonBlockFiles} {
- removeFile test1
- set f [open test1 w]
- close $f
- set f [open test1 r]
- fconfigure $f -blocking off
- set l ""
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {{} 1}
-test io-35.5 {Tcl_Eof, eof detection on nonblocking pipe} {stdio} {
- removeFile pipe
- set f [open pipe w]
- puts $f {
- exit
- }
- close $f
- set f [open "|[list $tcltest pipe]" r]
- set l ""
- lappend l [gets $f]
- lappend l [eof $f]
- close $f
- set l
-} {{} 1}
-test io-35.6 {Tcl_Eof, eof char, lf write, auto read} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar \x1a
- puts $f abc\ndef
- close $f
- set s [file size test1]
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- set l [string length [read $f]]
- set e [eof $f]
- close $f
- list $s $l $e
-} {9 8 1}
-test io-35.7 {Tcl_Eof, eof char, lf write, lf read} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar \x1a
- puts $f abc\ndef
- close $f
- set s [file size test1]
- set f [open test1 r]
- fconfigure $f -translation lf -eofchar \x1a
- set l [string length [read $f]]
- set e [eof $f]
- close $f
- list $s $l $e
-} {9 8 1}
-test io-35.8 {Tcl_Eof, eof char, cr write, auto read} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr -eofchar \x1a
- puts $f abc\ndef
- close $f
- set s [file size test1]
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- set l [string length [read $f]]
- set e [eof $f]
- close $f
- list $s $l $e
-} {9 8 1}
-test io-35.9 {Tcl_Eof, eof char, cr write, cr read} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr -eofchar \x1a
- puts $f abc\ndef
- close $f
- set s [file size test1]
- set f [open test1 r]
- fconfigure $f -translation cr -eofchar \x1a
- set l [string length [read $f]]
- set e [eof $f]
- close $f
- list $s $l $e
-} {9 8 1}
-test io-35.10 {Tcl_Eof, eof char, crlf write, auto read} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf -eofchar \x1a
- puts $f abc\ndef
- close $f
- set s [file size test1]
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- set l [string length [read $f]]
- set e [eof $f]
- close $f
- list $s $l $e
-} {11 8 1}
-test io-35.11 {Tcl_Eof, eof char, crlf write, crlf read} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf -eofchar \x1a
- puts $f abc\ndef
- close $f
- set s [file size test1]
- set f [open test1 r]
- fconfigure $f -translation crlf -eofchar \x1a
- set l [string length [read $f]]
- set e [eof $f]
- close $f
- list $s $l $e
-} {11 8 1}
-test io-35.12 {Tcl_Eof, eof char in middle, lf write, auto read} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar {}
- set i [format abc\ndef\n%cqrs\nuvw 26]
- puts $f $i
- close $f
- set c [file size test1]
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- set l [string length [read $f]]
- set e [eof $f]
- close $f
- list $c $l $e
-} {17 8 1}
-test io-35.13 {Tcl_Eof, eof char in middle, lf write, lf read} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar {}
- set i [format abc\ndef\n%cqrs\nuvw 26]
- puts $f $i
- close $f
- set c [file size test1]
- set f [open test1 r]
- fconfigure $f -translation lf -eofchar \x1a
- set l [string length [read $f]]
- set e [eof $f]
- close $f
- list $c $l $e
-} {17 8 1}
-test io-35.14 {Tcl_Eof, eof char in middle, cr write, auto read} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr -eofchar {}
- set i [format abc\ndef\n%cqrs\nuvw 26]
- puts $f $i
- close $f
- set c [file size test1]
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- set l [string length [read $f]]
- set e [eof $f]
- close $f
- list $c $l $e
-} {17 8 1}
-test io-35.15 {Tcl_Eof, eof char in middle, cr write, cr read} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr -eofchar {}
- set i [format abc\ndef\n%cqrs\nuvw 26]
- puts $f $i
- close $f
- set c [file size test1]
- set f [open test1 r]
- fconfigure $f -translation cr -eofchar \x1a
- set l [string length [read $f]]
- set e [eof $f]
- close $f
- list $c $l $e
-} {17 8 1}
-test io-35.16 {Tcl_Eof, eof char in middle, crlf write, auto read} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf -eofchar {}
- set i [format abc\ndef\n%cqrs\nuvw 26]
- puts $f $i
- close $f
- set c [file size test1]
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- set l [string length [read $f]]
- set e [eof $f]
- close $f
- list $c $l $e
-} {21 8 1}
-test io-35.17 {Tcl_Eof, eof char in middle, crlf write, crlf read} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf -eofchar {}
- set i [format abc\ndef\n%cqrs\nuvw 26]
- puts $f $i
- close $f
- set c [file size test1]
- set f [open test1 r]
- fconfigure $f -translation crlf -eofchar \x1a
- set l [string length [read $f]]
- set e [eof $f]
- close $f
- list $c $l $e
-} {21 8 1}
-
-# Test Tcl_InputBlocked
-
-test io-36.1 {Tcl_InputBlocked on nonblocking pipe} {stdio} {
- set f1 [open "|[list $tcltest]" r+]
- puts $f1 {puts hello_from_pipe}
- flush $f1
- gets $f1
- fconfigure $f1 -blocking off -buffering full
- puts $f1 {puts hello}
- set x ""
- lappend x [gets $f1]
- lappend x [fblocked $f1]
- flush $f1
- after 200
- lappend x [gets $f1]
- lappend x [fblocked $f1]
- lappend x [gets $f1]
- lappend x [fblocked $f1]
- close $f1
- set x
-} {{} 1 hello 0 {} 1}
-test io-36.2 {Tcl_InputBlocked on blocking pipe} {stdio} {
- set f1 [open "|[list $tcltest]" r+]
- fconfigure $f1 -buffering line
- puts $f1 {puts hello_from_pipe}
- set x ""
- lappend x [gets $f1]
- lappend x [fblocked $f1]
- puts $f1 {exit}
- lappend x [gets $f1]
- lappend x [fblocked $f1]
- lappend x [eof $f1]
- close $f1
- set x
-} {hello_from_pipe 0 {} 0 1}
-test io-36.3 {Tcl_InputBlocked vs files, short read} {
- removeFile test1
- set f [open test1 w]
- puts $f abcdefghijklmnop
- close $f
- set f [open test1 r]
- set l ""
- lappend l [fblocked $f]
- lappend l [read $f 3]
- lappend l [fblocked $f]
- lappend l [read -nonewline $f]
- lappend l [fblocked $f]
- lappend l [eof $f]
- close $f
- set l
-} {0 abc 0 defghijklmnop 0 1}
-test io-36.4 {Tcl_InputBlocked vs files, event driven read} {
- proc in {f} {
- global l x
- lappend l [read $f 3]
- if {[eof $f]} {lappend l eof; close $f; set x done}
- }
- removeFile test1
- set f [open test1 w]
- puts $f abcdefghijklmnop
- close $f
- set f [open test1 r]
- set l ""
- fileevent $f readable [list in $f]
- vwait x
- set l
-} {abc def ghi jkl mno {p
-} eof}
-test io-36.5 {Tcl_InputBlocked vs files, short read, nonblocking} {nonBlockFiles} {
- removeFile test1
- set f [open test1 w]
- puts $f abcdefghijklmnop
- close $f
- set f [open test1 r]
- fconfigure $f -blocking off
- set l ""
- lappend l [fblocked $f]
- lappend l [read $f 3]
- lappend l [fblocked $f]
- lappend l [read -nonewline $f]
- lappend l [fblocked $f]
- lappend l [eof $f]
- close $f
- set l
-} {0 abc 0 defghijklmnop 0 1}
-test io-36.6 {Tcl_InputBlocked vs files, event driven read} {nonBlockFiles} {
- proc in {f} {
- global l x
- lappend l [read $f 3]
- if {[eof $f]} {lappend l eof; close $f; set x done}
- }
- removeFile test1
- set f [open test1 w]
- puts $f abcdefghijklmnop
- close $f
- set f [open test1 r]
- fconfigure $f -blocking off
- set l ""
- fileevent $f readable [list in $f]
- vwait x
- set l
-} {abc def ghi jkl mno {p
-} eof}
-
-# Test Tcl_InputBuffered
-
-test io-37.1 {Tcl_InputBuffered} {
- set f [open longfile r]
- fconfigure $f -buffersize 4096
- read $f 3
- set l ""
- lappend l [testchannel inputbuffered $f]
- lappend l [tell $f]
- close $f
- set l
-} {4093 3}
-test io-37.2 {Tcl_InputBuffered, test input flushing on seek} {
- set f [open longfile r]
- fconfigure $f -buffersize 4096
- read $f 3
- set l ""
- lappend l [testchannel inputbuffered $f]
- lappend l [tell $f]
- seek $f 0 current
- lappend l [testchannel inputbuffered $f]
- lappend l [tell $f]
- close $f
- set l
-} {4093 3 0 3}
-
-# Test Tcl_SetChannelBufferSize, Tcl_GetChannelBufferSize
-
-test io-38.1 {Tcl_GetChannelBufferSize, default buffer size} {
- set f [open longfile r]
- set s [fconfigure $f -buffersize]
- close $f
- set s
-} 4096
-test io-38.2 {Tcl_SetChannelBufferSize, Tcl_GetChannelBufferSize} {
- set f [open longfile r]
- set l ""
- lappend l [fconfigure $f -buffersize]
- fconfigure $f -buffersize 10000
- lappend l [fconfigure $f -buffersize]
- fconfigure $f -buffersize 1
- lappend l [fconfigure $f -buffersize]
- fconfigure $f -buffersize -1
- lappend l [fconfigure $f -buffersize]
- fconfigure $f -buffersize 0
- lappend l [fconfigure $f -buffersize]
- fconfigure $f -buffersize 100000
- lappend l [fconfigure $f -buffersize]
- fconfigure $f -buffersize 10000000
- lappend l [fconfigure $f -buffersize]
- close $f
- set l
-} {4096 10000 4096 4096 4096 100000 4096}
-
-# Test Tcl_SetChannelOption, Tcl_GetChannelOption
-
-test io-39.1 {Tcl_GetChannelOption} {
- removeFile test1
- set f1 [open test1 w]
- set x [fconfigure $f1 -blocking]
- close $f1
- set x
-} 1
-#
-# Test 17.2 was removed.
-#
-test io-39.2 {Tcl_GetChannelOption} {
- removeFile test1
- set f1 [open test1 w]
- set x [fconfigure $f1 -buffering]
- close $f1
- set x
-} full
-test io-39.3 {Tcl_GetChannelOption} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -buffering line
- set x [fconfigure $f1 -buffering]
- close $f1
- set x
-} line
-test io-39.4 {Tcl_GetChannelOption, Tcl_SetChannelOption} {
- removeFile test1
- set f1 [open test1 w]
- set l ""
- lappend l [fconfigure $f1 -buffering]
- fconfigure $f1 -buffering line
- lappend l [fconfigure $f1 -buffering]
- fconfigure $f1 -buffering none
- lappend l [fconfigure $f1 -buffering]
- fconfigure $f1 -buffering line
- lappend l [fconfigure $f1 -buffering]
- fconfigure $f1 -buffering full
- lappend l [fconfigure $f1 -buffering]
- close $f1
- set l
-} {full line none line full}
-test io-39.5 {Tcl_GetChannelOption, invariance} {
- removeFile test1
- set f1 [open test1 w]
- set l ""
- lappend l [fconfigure $f1 -buffering]
- lappend l [list [catch {fconfigure $f1 -buffering green} msg] $msg]
- lappend l [fconfigure $f1 -buffering]
- close $f1
- set l
-} {full {1 {bad value for -buffering: must be one of full, line, or none}} full}
-test io-39.6 {Tcl_SetChannelOption, multiple options} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf -buffering line
- puts $f1 hello
- puts $f1 bye
- set x [file size test1]
- close $f1
- set x
-} 10
-test io-39.7 {Tcl_SetChannelOption, buffering, translation} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf
- puts $f1 hello
- puts $f1 bye
- set x ""
- fconfigure $f1 -buffering line
- lappend x [file size test1]
- puts $f1 really_bye
- lappend x [file size test1]
- close $f1
- set x
-} {0 21}
-test io-39.8 {Tcl_SetChannelOption, different buffering options} {
- removeFile test1
- set f1 [open test1 w]
- set l ""
- fconfigure $f1 -translation lf -buffering none -eofchar {}
- puts -nonewline $f1 hello
- lappend l [file size test1]
- puts -nonewline $f1 hello
- lappend l [file size test1]
- fconfigure $f1 -buffering full
- puts -nonewline $f1 hello
- lappend l [file size test1]
- fconfigure $f1 -buffering none
- lappend l [file size test1]
- puts -nonewline $f1 hello
- lappend l [file size test1]
- close $f1
- lappend l [file size test1]
- set l
-} {5 10 10 10 20 20}
-test io-39.9 {Tcl_SetChannelOption, blocking mode} {nonBlockFiles} {
- removeFile test1
- set f1 [open test1 w]
- close $f1
- set f1 [open test1 r]
- set x ""
- lappend x [fconfigure $f1 -blocking]
- fconfigure $f1 -blocking off
- lappend x [fconfigure $f1 -blocking]
- lappend x [gets $f1]
- lappend x [read $f1 1000]
- lappend x [fblocked $f1]
- lappend x [eof $f1]
- close $f1
- set x
-} {1 0 {} {} 0 1}
-test io-39.10 {Tcl_SetChannelOption, blocking mode} {stdio} {
- removeFile pipe
- set f1 [open pipe w]
- puts $f1 {
- gets stdin
- after 100
- puts hi
- gets stdin
- }
- close $f1
- set x ""
- set f1 [open "|[list $tcltest pipe]" r+]
- fconfigure $f1 -blocking off -buffering line
- lappend x [fconfigure $f1 -blocking]
- lappend x [gets $f1]
- lappend x [fblocked $f1]
- fconfigure $f1 -blocking on
- puts $f1 hello
- fconfigure $f1 -blocking off
- lappend x [gets $f1]
- lappend x [fblocked $f1]
- fconfigure $f1 -blocking on
- puts $f1 bye
- fconfigure $f1 -blocking off
- lappend x [gets $f1]
- lappend x [fblocked $f1]
- fconfigure $f1 -blocking on
- lappend x [fconfigure $f1 -blocking]
- lappend x [gets $f1]
- lappend x [fblocked $f1]
- lappend x [eof $f1]
- lappend x [gets $f1]
- lappend x [eof $f1]
- close $f1
- set x
-} {0 {} 1 {} 1 {} 1 1 hi 0 0 {} 1}
-test io-39.11 {Tcl_SetChannelOption, Tcl_GetChannelOption, buffer size} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -buffersize -10
- set x [fconfigure $f -buffersize]
- close $f
- set x
-} 4096
-test io-39.12 {Tcl_SetChannelOption, Tcl_GetChannelOption buffer size} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -buffersize 10000000
- set x [fconfigure $f -buffersize]
- close $f
- set x
-} 4096
-test io-39.13 {Tcl_SetChannelOption, Tcl_GetChannelOption, buffer size} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -buffersize 40000
- set x [fconfigure $f -buffersize]
- close $f
- set x
-} 40000
-test io-39.14 {Tcl_SetChannelOption: -encoding, binary & utf-8} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -encoding {}
- puts -nonewline $f \xe7\x89\xa6
- close $f
- set f [open test1 r]
- fconfigure $f -encoding utf-8
- set x [read $f]
- close $f
- set x
-} \u7266
-test io-39.15 {Tcl_SetChannelOption: -encoding, binary & utf-8} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -encoding binary
- puts -nonewline $f \xe7\x89\xa6
- close $f
- set f [open test1 r]
- fconfigure $f -encoding utf-8
- set x [read $f]
- close $f
- set x
-} \u7266
-test io-39.16 {Tcl_SetChannelOption: -encoding, errors} {
- removeFile test1
- set f [open test1 w]
- set result [list [catch {fconfigure $f -encoding foobar} msg] $msg]
- close $f
- set result
-} {1 {unknown encoding "foobar"}}
-test io-39.17 {Tcl_SetChannelOption: -encoding, clearing CHANNEL_NEED_MORE_DATA} {stdio} {
- set f [open "|[list $tcltest cat]" r+]
- fconfigure $f -encoding binary
- puts -nonewline $f "\xe7"
- flush $f
- fconfigure $f -encoding utf-8 -blocking 0
- set x {}
- fileevent $f readable { lappend x [read $f] }
- vwait x
- after 300 { lappend x timeout }
- vwait x
- fconfigure $f -encoding utf-8
- vwait x
- after 300 { lappend x timeout }
- vwait x
- fconfigure $f -encoding binary
- vwait x
- after 300 { lappend x timeout }
- vwait x
- close $f
- set x
-} "{} timeout {} timeout \xe7 timeout"
-
-test io-39.18 {Tcl_SetChannelOption, setting read mode independently} \
- {socket} {
- proc accept {s a p} {close $s}
- set s1 [socket -server accept 0]
- set port [lindex [fconfigure $s1 -sockname] 2]
- set s2 [socket 127.0.0.1 $port]
- update
- fconfigure $s2 -translation {auto lf}
- set modes [fconfigure $s2 -translation]
- close $s1
- close $s2
- set modes
-} {auto lf}
-test io-39.19 {Tcl_SetChannelOption, setting read mode independently} \
- {socket} {
- proc accept {s a p} {close $s}
- set s1 [socket -server accept 0]
- set port [lindex [fconfigure $s1 -sockname] 2]
- set s2 [socket 127.0.0.1 $port]
- update
- fconfigure $s2 -translation {auto crlf}
- set modes [fconfigure $s2 -translation]
- close $s1
- close $s2
- set modes
-} {auto crlf}
-test io-39.20 {Tcl_SetChannelOption, setting read mode independently} \
- {socket} {
- proc accept {s a p} {close $s}
- set s1 [socket -server accept 0]
- set port [lindex [fconfigure $s1 -sockname] 2]
- set s2 [socket 127.0.0.1 $port]
- update
- fconfigure $s2 -translation {auto cr}
- set modes [fconfigure $s2 -translation]
- close $s1
- close $s2
- set modes
-} {auto cr}
-test io-39.21 {Tcl_SetChannelOption, setting read mode independently} \
- {socket} {
- proc accept {s a p} {close $s}
- set s1 [socket -server accept 0]
- set port [lindex [fconfigure $s1 -sockname] 2]
- set s2 [socket 127.0.0.1 $port]
- update
- fconfigure $s2 -translation {auto auto}
- set modes [fconfigure $s2 -translation]
- close $s1
- close $s2
- set modes
-} {auto crlf}
-
-test io-40.1 {POSIX open access modes: RDWR} {
- removeFile test3
- set f [open test3 w]
- puts $f xyzzy
- close $f
- set f [open test3 RDWR]
- puts -nonewline $f "ab"
- seek $f 0 current
- set x [gets $f]
- close $f
- set f [open test3 r]
- lappend x [gets $f]
- close $f
- set x
-} {zzy abzzy}
-test io-40.2 {POSIX open access modes: CREAT} {unixOnly} {
- removeFile test3
- set f [open test3 {WRONLY CREAT} 0600]
- file stat test3 stats
- set x [format "0%o" [expr $stats(mode)&0777]]
- puts $f "line 1"
- close $f
- set f [open test3 r]
- lappend x [gets $f]
- close $f
- set x
-} {0600 {line 1}}
-
-# some tests can only be run is umask is 2
-# if "umask" cannot be run, the tests will be skipped.
-catch {set ::tcltest::testConfig(umask2) [expr {[exec umask] == 2}]}
-
-test io-40.3 {POSIX open access modes: CREAT} {unixOnly umask2} {
- # This test only works if your umask is 2, like ouster's.
- removeFile test3
- set f [open test3 {WRONLY CREAT}]
- close $f
- file stat test3 stats
- format "0%o" [expr $stats(mode)&0777]
-} 0664
-test io-40.4 {POSIX open access modes: CREAT} {
- removeFile test3
- set f [open test3 w]
- fconfigure $f -eofchar {}
- puts $f xyzzy
- close $f
- set f [open test3 {WRONLY CREAT}]
- fconfigure $f -eofchar {}
- puts -nonewline $f "ab"
- close $f
- set f [open test3 r]
- set x [gets $f]
- close $f
- set x
-} abzzy
-test io-40.5 {POSIX open access modes: APPEND} {
- removeFile test3
- set f [open test3 w]
- fconfigure $f -translation lf -eofchar {}
- puts $f xyzzy
- close $f
- set f [open test3 {WRONLY APPEND}]
- fconfigure $f -translation lf
- puts $f "new line"
- seek $f 0
- puts $f "abc"
- close $f
- set f [open test3 r]
- fconfigure $f -translation lf
- set x ""
- seek $f 6 current
- lappend x [gets $f]
- lappend x [gets $f]
- close $f
- set x
-} {{new line} abc}
-test io-40.6 {POSIX open access modes: EXCL} {
- removeFile test3
- set f [open test3 w]
- puts $f xyzzy
- close $f
- set msg [list [catch {open test3 {WRONLY CREAT EXCL}} msg] $msg]
- regsub " already " $msg " " msg
- string tolower $msg
-} {1 {couldn't open "test3": file exists}}
-test io-40.7 {POSIX open access modes: EXCL} {
- removeFile test3
- set f [open test3 {WRONLY CREAT EXCL}]
- fconfigure $f -eofchar {}
- puts $f "A test line"
- close $f
- viewFile test3
-} {A test line}
-test io-40.8 {POSIX open access modes: TRUNC} {
- removeFile test3
- set f [open test3 w]
- puts $f xyzzy
- close $f
- set f [open test3 {WRONLY TRUNC}]
- puts $f abc
- close $f
- set f [open test3 r]
- set x [gets $f]
- close $f
- set x
-} abc
-test io-40.9 {POSIX open access modes: NONBLOCK} {nonPortable macOrUnix} {
- removeFile test3
- set f [open test3 {WRONLY NONBLOCK CREAT}]
- puts $f "NONBLOCK test"
- close $f
- set f [open test3 r]
- set x [gets $f]
- close $f
- set x
-} {NONBLOCK test}
-test io-40.10 {POSIX open access modes: RDONLY} {
- set f [open test1 w]
- puts $f "two lines: this one"
- puts $f "and this"
- close $f
- set f [open test1 RDONLY]
- set x [list [gets $f] [catch {puts $f Test} msg] $msg]
- close $f
- string compare [string tolower $x] \
- [list {two lines: this one} 1 \
- [format "channel \"%s\" wasn't opened for writing" $f]]
-} 0
-test io-40.11 {POSIX open access modes: RDONLY} {
- removeFile test3
- string tolower [list [catch {open test3 RDONLY} msg] $msg]
-} {1 {couldn't open "test3": no such file or directory}}
-test io-40.12 {POSIX open access modes: WRONLY} {
- removeFile test3
- string tolower [list [catch {open test3 WRONLY} msg] $msg]
-} {1 {couldn't open "test3": no such file or directory}}
-test io-40.13 {POSIX open access modes: WRONLY} {
- makeFile xyzzy test3
- set f [open test3 WRONLY]
- fconfigure $f -eofchar {}
- puts -nonewline $f "ab"
- seek $f 0 current
- set x [list [catch {gets $f} msg] $msg]
- close $f
- lappend x [viewFile test3]
- string compare [string tolower $x] \
- [list 1 "channel \"$f\" wasn't opened for reading" abzzy]
-} 0
-test io-40.14 {POSIX open access modes: RDWR} {
- removeFile test3
- string tolower [list [catch {open test3 RDWR} msg] $msg]
-} {1 {couldn't open "test3": no such file or directory}}
-test io-40.15 {POSIX open access modes: RDWR} {
- makeFile xyzzy test3
- set f [open test3 RDWR]
- puts -nonewline $f "ab"
- seek $f 0 current
- set x [gets $f]
- close $f
- lappend x [viewFile test3]
-} {zzy abzzy}
-if {![file exists ~/_test_] && [file writable ~]} {
- test io-40.16 {tilde substitution in open} {
- set f [open ~/_test_ w]
- puts $f "Some text"
- close $f
- set x [file exists [file join $env(HOME) _test_]]
- removeFile [file join $env(HOME) _test_]
- set x
- } 1
-}
-test io-40.17 {tilde substitution in open} {
- set home $env(HOME)
- unset env(HOME)
- set x [list [catch {open ~/foo} msg] $msg]
- set env(HOME) $home
- set x
-} {1 {couldn't find HOME environment variable to expand path}}
-
-test io-41.1 {Tcl_FileeventCmd: errors} {
- list [catch {fileevent foo} msg] $msg
-} {1 {wrong # args: should be "fileevent channelId event ?script?"}}
-test io-41.2 {Tcl_FileeventCmd: errors} {
- list [catch {fileevent foo bar baz q} msg] $msg
-} {1 {wrong # args: should be "fileevent channelId event ?script?"}}
-test io-41.3 {Tcl_FileeventCmd: errors} {
- list [catch {fileevent gorp readable} msg] $msg
-} {1 {can not find channel named "gorp"}}
-test io-41.4 {Tcl_FileeventCmd: errors} {
- list [catch {fileevent gorp writable} msg] $msg
-} {1 {can not find channel named "gorp"}}
-test io-41.5 {Tcl_FileeventCmd: errors} {
- list [catch {fileevent gorp who-knows} msg] $msg
-} {1 {bad event name "who-knows": must be readable or writable}}
-
-#
-# Test fileevent on a file
-#
-
-set f [open foo w+]
-
-test io-42.1 {Tcl_FileeventCmd: creating, deleting, querying} {
- list [fileevent $f readable] [fileevent $f writable]
-} {{} {}}
-test io-42.2 {Tcl_FileeventCmd: replacing} {
- set result {}
- fileevent $f r "first script"
- lappend result [fileevent $f readable]
- fileevent $f r "new script"
- lappend result [fileevent $f readable]
- fileevent $f r "yet another"
- lappend result [fileevent $f readable]
- fileevent $f r ""
- lappend result [fileevent $f readable]
-} {{first script} {new script} {yet another} {}}
-test io-42.3 {Tcl_FileeventCmd: replacing, with NULL chars in script} {
- set result {}
- fileevent $f r "first scr\0ipt"
- lappend result [string length [fileevent $f readable]]
- fileevent $f r "new scr\0ipt"
- lappend result [string length [fileevent $f readable]]
- fileevent $f r "yet ano\0ther"
- lappend result [string length [fileevent $f readable]]
- fileevent $f r ""
- lappend result [fileevent $f readable]
-} {13 11 12 {}}
-
-#
-# Test fileevent on a pipe
-#
-
-catch {set f2 [open "|[list cat -u]" r+]}
-catch {set f3 [open "|[list cat -u]" r+]}
-
-test io-43.1 {Tcl_FileeventCmd: creating, deleting, querying} {stdio unixExecs} {
- set result {}
- fileevent $f readable "script 1"
- lappend result [fileevent $f readable] [fileevent $f writable]
- fileevent $f writable "write script"
- lappend result [fileevent $f readable] [fileevent $f writable]
- fileevent $f readable {}
- lappend result [fileevent $f readable] [fileevent $f writable]
- fileevent $f writable {}
- lappend result [fileevent $f readable] [fileevent $f writable]
-} {{script 1} {} {script 1} {write script} {} {write script} {} {}}
-test io-43.2 {Tcl_FileeventCmd: deleting when many present} {stdio unixExecs} {
- set result {}
- lappend result [fileevent $f r] [fileevent $f2 r] [fileevent $f3 r]
- fileevent $f r "read f"
- fileevent $f2 r "read f2"
- fileevent $f3 r "read f3"
- lappend result [fileevent $f r] [fileevent $f2 r] [fileevent $f3 r]
- fileevent $f2 r {}
- lappend result [fileevent $f r] [fileevent $f2 r] [fileevent $f3 r]
- fileevent $f3 r {}
- lappend result [fileevent $f r] [fileevent $f2 r] [fileevent $f3 r]
- fileevent $f r {}
- lappend result [fileevent $f r] [fileevent $f2 r] [fileevent $f3 r]
-} {{} {} {} {read f} {read f2} {read f3} {read f} {} {read f3} {read f} {} {} {} {} {}}
-
-test io-44.1 {FileEventProc procedure: normal read event} {stdio unixExecs} {
- fileevent $f2 readable {
- set x [gets $f2]; fileevent $f2 readable {}
- }
- puts $f2 text; flush $f2
- set x initial
- vwait x
- set x
-} {text}
-test io-44.2 {FileEventProc procedure: error in read event} {stdio unixExecs} {
- proc bgerror args {
- global x
- set x $args
- }
- fileevent $f2 readable {error bogus}
- puts $f2 text; flush $f2
- set x initial
- vwait x
- rename bgerror {}
- list $x [fileevent $f2 readable]
-} {bogus {}}
-test io-44.3 {FileEventProc procedure: normal write event} {stdio unixExecs} {
- fileevent $f2 writable {
- lappend x "triggered"
- incr count -1
- if {$count <= 0} {
- fileevent $f2 writable {}
- }
- }
- set x initial
- set count 3
- vwait x
- vwait x
- vwait x
- set x
-} {initial triggered triggered triggered}
-test io-44.4 {FileEventProc procedure: eror in write event} {stdio unixExecs} {
- proc bgerror args {
- global x
- set x $args
- }
- fileevent $f2 writable {error bad-write}
- set x initial
- vwait x
- rename bgerror {}
- list $x [fileevent $f2 writable]
-} {bad-write {}}
-test io-44.5 {FileEventProc procedure: end of file} {stdio unixExecs} {
- set f4 [open "|[list $tcltest cat << foo]" r]
- fileevent $f4 readable {
- if {[gets $f4 line] < 0} {
- lappend x eof
- fileevent $f4 readable {}
- } else {
- lappend x $line
- }
- }
- set x initial
- vwait x
- vwait x
- close $f4
- set x
-} {initial foo eof}
-
-catch {close $f2}
-catch {close $f3}
-
-
-close $f
-makeFile "foo bar" foo
-test io-45.1 {DeleteFileEvent, cleanup on close} {
- set f [open foo r]
- fileevent $f readable {
- lappend x "binding triggered: \"[gets $f]\""
- fileevent $f readable {}
- }
- close $f
- set x initial
- after 100 { set y done }
- vwait y
- set x
-} {initial}
-test io-45.2 {DeleteFileEvent, cleanup on close} {
- set f [open foo r]
- set f2 [open foo r]
- fileevent $f readable {
- lappend x "f triggered: \"[gets $f]\""
- fileevent $f readable {}
- }
- fileevent $f2 readable {
- lappend x "f2 triggered: \"[gets $f2]\""
- fileevent $f2 readable {}
- }
- close $f
- set x initial
- vwait x
- close $f2
- set x
-} {initial {f2 triggered: "foo bar"}}
-test io-45.3 {DeleteFileEvent, cleanup on close} {
- set f [open foo r]
- set f2 [open foo r]
- set f3 [open foo r]
- fileevent $f readable {f script}
- fileevent $f2 readable {f2 script}
- fileevent $f3 readable {f3 script}
- set x {}
- close $f2
- lappend x [catch {fileevent $f readable} msg] $msg \
- [catch {fileevent $f2 readable}] \
- [catch {fileevent $f3 readable} msg] $msg
- close $f3
- lappend x [catch {fileevent $f readable} msg] $msg \
- [catch {fileevent $f2 readable}] \
- [catch {fileevent $f3 readable}]
- close $f
- lappend x [catch {fileevent $f readable}] \
- [catch {fileevent $f2 readable}] \
- [catch {fileevent $f3 readable}]
-} {0 {f script} 1 0 {f3 script} 0 {f script} 1 1 1 1 1}
-
-# Execute these tests only if the "testfevent" command is present.
-
-if {[info commands testfevent] == "testfevent"} {
-
-test io-46.1 {Tcl event loop vs multiple interpreters} {
- testfevent create
- testfevent cmd {
- set f [open foo r]
- set x "no event"
- fileevent $f readable {
- set x "f triggered: [gets $f]"
- fileevent $f readable {}
- }
- }
- after 1 ;# We must delay because Windows takes a little time to notice
- update
- testfevent cmd {close $f}
- list [testfevent cmd {set x}] [testfevent cmd {info commands after}]
-} {{f triggered: foo bar} after}
-test io-46.2 {Tcl event loop vs multiple interpreters} {
- testfevent create
- testfevent cmd {
- set x 0
- after 100 {set x triggered}
- vwait x
- set x
- }
-} {triggered}
-test io-46.3 {Tcl event loop vs multiple interpreters} {
- testfevent create
- testfevent cmd {
- set x 0
- after 10 {lappend x timer}
- after 30
- set result $x
- update idletasks
- lappend result $x
- update
- lappend result $x
- }
-} {0 0 {0 timer}}
-
-test io-47.1 {fileevent vs multiple interpreters} {
- set f [open foo r]
- set f2 [open foo r]
- set f3 [open foo r]
- fileevent $f readable {script 1}
- testfevent create
- testfevent share $f2
- testfevent cmd "fileevent $f2 readable {script 2}"
- fileevent $f3 readable {sript 3}
- set x {}
- lappend x [fileevent $f2 readable]
- testfevent delete
- lappend x [fileevent $f readable] [fileevent $f2 readable] \
- [fileevent $f3 readable]
- close $f
- close $f2
- close $f3
- set x
-} {{} {script 1} {} {sript 3}}
-test io-47.2 {deleting fileevent on interpreter delete} {
- set f [open foo r]
- set f2 [open foo r]
- set f3 [open foo r]
- set f4 [open foo r]
- fileevent $f readable {script 1}
- testfevent create
- testfevent share $f2
- testfevent share $f3
- testfevent cmd "fileevent $f2 readable {script 2}
- fileevent $f3 readable {script 3}"
- fileevent $f4 readable {script 4}
- testfevent delete
- set x [list [fileevent $f readable] [fileevent $f2 readable] \
- [fileevent $f3 readable] [fileevent $f4 readable]]
- close $f
- close $f2
- close $f3
- close $f4
- set x
-} {{script 1} {} {} {script 4}}
-test io-47.3 {deleting fileevent on interpreter delete} {
- set f [open foo r]
- set f2 [open foo r]
- set f3 [open foo r]
- set f4 [open foo r]
- testfevent create
- testfevent share $f3
- testfevent share $f4
- fileevent $f readable {script 1}
- fileevent $f2 readable {script 2}
- testfevent cmd "fileevent $f3 readable {script 3}
- fileevent $f4 readable {script 4}"
- testfevent delete
- set x [list [fileevent $f readable] [fileevent $f2 readable] \
- [fileevent $f3 readable] [fileevent $f4 readable]]
- close $f
- close $f2
- close $f3
- close $f4
- set x
-} {{script 1} {script 2} {} {}}
-test io-47.4 {file events on shared files and multiple interpreters} {
- set f [open foo r]
- set f2 [open foo r]
- testfevent create
- testfevent share $f
- testfevent cmd "fileevent $f readable {script 1}"
- fileevent $f readable {script 2}
- fileevent $f2 readable {script 3}
- set x [list [fileevent $f2 readable] \
- [testfevent cmd "fileevent $f readable"] \
- [fileevent $f readable]]
- testfevent delete
- close $f
- close $f2
- set x
-} {{script 3} {script 1} {script 2}}
-test io-47.5 {file events on shared files, deleting file events} {
- set f [open foo r]
- testfevent create
- testfevent share $f
- testfevent cmd "fileevent $f readable {script 1}"
- fileevent $f readable {script 2}
- testfevent cmd "fileevent $f readable {}"
- set x [list [testfevent cmd "fileevent $f readable"] \
- [fileevent $f readable]]
- testfevent delete
- close $f
- set x
-} {{} {script 2}}
-test io-47.6 {file events on shared files, deleting file events} {
- set f [open foo r]
- testfevent create
- testfevent share $f
- testfevent cmd "fileevent $f readable {script 1}"
- fileevent $f readable {script 2}
- fileevent $f readable {}
- set x [list [testfevent cmd "fileevent $f readable"] \
- [fileevent $f readable]]
- testfevent delete
- close $f
- set x
-} {{script 1} {}}
-
-}
-
-# The above curly closes the test for presence of the "testfevent" command.
-
-test io-48.1 {testing readability conditions} {
- set f [open bar w]
- puts $f abcdefg
- puts $f abcdefg
- puts $f abcdefg
- puts $f abcdefg
- puts $f abcdefg
- close $f
- set f [open bar r]
- fileevent $f readable [list consume $f]
- proc consume {f} {
- global x l
- lappend l called
- if {[eof $f]} {
- close $f
- set x done
- } else {
- gets $f
- }
- }
- set l ""
- set x not_done
- vwait x
- list $x $l
-} {done {called called called called called called called}}
-test io-48.2 {testing readability conditions} {nonBlockFiles} {
- set f [open bar w]
- puts $f abcdefg
- puts $f abcdefg
- puts $f abcdefg
- puts $f abcdefg
- puts $f abcdefg
- close $f
- set f [open bar r]
- fileevent $f readable [list consume $f]
- fconfigure $f -blocking off
- proc consume {f} {
- global x l
- lappend l called
- if {[eof $f]} {
- close $f
- set x done
- } else {
- gets $f
- }
- }
- set l ""
- set x not_done
- vwait x
- list $x $l
-} {done {called called called called called called called}}
-test io-48.3 {testing readability conditions} {unixOnly nonBlockFiles} {
- set f [open bar w]
- puts $f abcdefg
- puts $f abcdefg
- puts $f abcdefg
- puts $f abcdefg
- puts $f abcdefg
- close $f
- set f [open my_script w]
- puts $f {
- proc copy_slowly {f} {
- while {![eof $f]} {
- puts [gets $f]
- after 200
- }
- close $f
- }
- }
- close $f
- set f [open "|[list $tcltest]" r+]
- fileevent $f readable [list consume $f]
- fconfigure $f -buffering line
- fconfigure $f -blocking off
- proc consume {f} {
- global x l
- if {[eof $f]} {
- set x done
- } else {
- gets $f
- lappend l [fblocked $f]
- gets $f
- lappend l [fblocked $f]
- }
- }
- set l ""
- set x not_done
- puts $f {source my_script}
- puts $f {set f [open bar r]}
- puts $f {copy_slowly $f}
- puts $f {exit}
- vwait x
- close $f
- list $x $l
-} {done {0 1 0 1 0 1 0 1 0 1 0 1 0 0}}
-test io-48.4 {lf write, testing readability, ^Z termination, auto read mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- set c [format "abc\ndef\n%c" 26]
- puts -nonewline $f $c
- close $f
- proc consume {f} {
- global c x l
- if {[eof $f]} {
- set x done
- close $f
- } else {
- lappend l [gets $f]
- incr c
- }
- }
- set c 0
- set l ""
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- fileevent $f readable [list consume $f]
- vwait x
- list $c $l
-} {3 {abc def {}}}
-test io-48.5 {lf write, testing readability, ^Z in middle, auto read mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- set c [format "abc\ndef\n%cfoo\nbar\n" 26]
- puts -nonewline $f $c
- close $f
- proc consume {f} {
- global c x l
- if {[eof $f]} {
- set x done
- close $f
- } else {
- lappend l [gets $f]
- incr c
- }
- }
- set c 0
- set l ""
- set f [open test1 r]
- fconfigure $f -eofchar \x1a -translation auto
- fileevent $f readable [list consume $f]
- vwait x
- list $c $l
-} {3 {abc def {}}}
-test io-48.6 {cr write, testing readability, ^Z termination, auto read mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr
- set c [format "abc\ndef\n%c" 26]
- puts -nonewline $f $c
- close $f
- proc consume {f} {
- global c x l
- if {[eof $f]} {
- set x done
- close $f
- } else {
- lappend l [gets $f]
- incr c
- }
- }
- set c 0
- set l ""
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- fileevent $f readable [list consume $f]
- vwait x
- list $c $l
-} {3 {abc def {}}}
-test io-48.7 {cr write, testing readability, ^Z in middle, auto read mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr
- set c [format "abc\ndef\n%cfoo\nbar\n" 26]
- puts -nonewline $f $c
- close $f
- proc consume {f} {
- global c x l
- if {[eof $f]} {
- set x done
- close $f
- } else {
- lappend l [gets $f]
- incr c
- }
- }
- set c 0
- set l ""
- set f [open test1 r]
- fconfigure $f -eofchar \x1a -translation auto
- fileevent $f readable [list consume $f]
- vwait x
- list $c $l
-} {3 {abc def {}}}
-test io-48.8 {crlf write, testing readability, ^Z termination, auto read mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- set c [format "abc\ndef\n%c" 26]
- puts -nonewline $f $c
- close $f
- proc consume {f} {
- global c x l
- if {[eof $f]} {
- set x done
- close $f
- } else {
- lappend l [gets $f]
- incr c
- }
- }
- set c 0
- set l ""
- set f [open test1 r]
- fconfigure $f -translation auto -eofchar \x1a
- fileevent $f readable [list consume $f]
- vwait x
- list $c $l
-} {3 {abc def {}}}
-test io-48.9 {crlf write, testing readability, ^Z in middle, auto read mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- set c [format "abc\ndef\n%cfoo\nbar\n" 26]
- puts -nonewline $f $c
- close $f
- proc consume {f} {
- global c x l
- if {[eof $f]} {
- set x done
- close $f
- } else {
- lappend l [gets $f]
- incr c
- }
- }
- set c 0
- set l ""
- set f [open test1 r]
- fconfigure $f -eofchar \x1a -translation auto
- fileevent $f readable [list consume $f]
- vwait x
- list $c $l
-} {3 {abc def {}}}
-test io-48.10 {lf write, testing readability, ^Z in middle, lf read mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- set c [format "abc\ndef\n%cfoo\nbar\n" 26]
- puts -nonewline $f $c
- close $f
- proc consume {f} {
- global c x l
- if {[eof $f]} {
- set x done
- close $f
- } else {
- lappend l [gets $f]
- incr c
- }
- }
- set c 0
- set l ""
- set f [open test1 r]
- fconfigure $f -eofchar \x1a -translation lf
- fileevent $f readable [list consume $f]
- vwait x
- list $c $l
-} {3 {abc def {}}}
-test io-48.11 {lf write, testing readability, ^Z termination, lf read mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- set c [format "abc\ndef\n%c" 26]
- puts -nonewline $f $c
- close $f
- proc consume {f} {
- global c x l
- if {[eof $f]} {
- set x done
- close $f
- } else {
- lappend l [gets $f]
- incr c
- }
- }
- set c 0
- set l ""
- set f [open test1 r]
- fconfigure $f -translation lf -eofchar \x1a
- fileevent $f readable [list consume $f]
- vwait x
- list $c $l
-} {3 {abc def {}}}
-test io-48.12 {cr write, testing readability, ^Z in middle, cr read mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr
- set c [format "abc\ndef\n%cfoo\nbar\n" 26]
- puts -nonewline $f $c
- close $f
- proc consume {f} {
- global c x l
- if {[eof $f]} {
- set x done
- close $f
- } else {
- lappend l [gets $f]
- incr c
- }
- }
- set c 0
- set l ""
- set f [open test1 r]
- fconfigure $f -eofchar \x1a -translation cr
- fileevent $f readable [list consume $f]
- vwait x
- list $c $l
-} {3 {abc def {}}}
-test io-48.13 {cr write, testing readability, ^Z termination, cr read mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation cr
- set c [format "abc\ndef\n%c" 26]
- puts -nonewline $f $c
- close $f
- proc consume {f} {
- global c x l
- if {[eof $f]} {
- set x done
- close $f
- } else {
- lappend l [gets $f]
- incr c
- }
- }
- set c 0
- set l ""
- set f [open test1 r]
- fconfigure $f -translation cr -eofchar \x1a
- fileevent $f readable [list consume $f]
- vwait x
- list $c $l
-} {3 {abc def {}}}
-test io-48.14 {crlf write, testing readability, ^Z in middle, crlf read mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- set c [format "abc\ndef\n%cfoo\nbar\n" 26]
- puts -nonewline $f $c
- close $f
- proc consume {f} {
- global c x l
- if {[eof $f]} {
- set x done
- close $f
- } else {
- lappend l [gets $f]
- incr c
- }
- }
- set c 0
- set l ""
- set f [open test1 r]
- fconfigure $f -eofchar \x1a -translation crlf
- fileevent $f readable [list consume $f]
- vwait x
- list $c $l
-} {3 {abc def {}}}
-test io-48.15 {crlf write, testing readability, ^Z termi, crlf read mode} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation crlf
- set c [format "abc\ndef\n%c" 26]
- puts -nonewline $f $c
- close $f
- proc consume {f} {
- global c x l
- if {[eof $f]} {
- set x done
- close $f
- } else {
- lappend l [gets $f]
- incr c
- }
- }
- set c 0
- set l ""
- set f [open test1 r]
- fconfigure $f -translation crlf -eofchar \x1a
- fileevent $f readable [list consume $f]
- vwait x
- list $c $l
-} {3 {abc def {}}}
-
-test io-49.1 {testing crlf reading, leftover cr disgorgment} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "a\rb\rc\r\n"
- close $f
- set f [open test1 r]
- set l ""
- lappend l [file size test1]
- fconfigure $f -translation crlf
- lappend l [read $f 1]
- lappend l [tell $f]
- lappend l [read $f 1]
- lappend l [tell $f]
- lappend l [read $f 1]
- lappend l [tell $f]
- lappend l [read $f 1]
- lappend l [tell $f]
- lappend l [read $f 1]
- lappend l [tell $f]
- lappend l [read $f 1]
- lappend l [tell $f]
- lappend l [eof $f]
- lappend l [read $f 1]
- lappend l [eof $f]
- close $f
- set l
-} "7 a 1 [list \r] 2 b 3 [list \r] 4 c 5 {
-} 7 0 {} 1"
-test io-49.2 {testing crlf reading, leftover cr disgorgment} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "a\rb\rc\r\n"
- close $f
- set f [open test1 r]
- set l ""
- lappend l [file size test1]
- fconfigure $f -translation crlf
- lappend l [read $f 2]
- lappend l [tell $f]
- lappend l [read $f 2]
- lappend l [tell $f]
- lappend l [read $f 2]
- lappend l [tell $f]
- lappend l [eof $f]
- lappend l [read $f 2]
- lappend l [tell $f]
- lappend l [eof $f]
- close $f
- set l
-} "7 [list a\r] 2 [list b\r] 4 [list c\n] 7 0 {} 7 1"
-test io-49.3 {testing crlf reading, leftover cr disgorgment} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "a\rb\rc\r\n"
- close $f
- set f [open test1 r]
- set l ""
- lappend l [file size test1]
- fconfigure $f -translation crlf
- lappend l [read $f 3]
- lappend l [tell $f]
- lappend l [read $f 3]
- lappend l [tell $f]
- lappend l [eof $f]
- lappend l [read $f 3]
- lappend l [tell $f]
- lappend l [eof $f]
- close $f
- set l
-} "7 [list a\rb] 3 [list \rc\n] 7 0 {} 7 1"
-test io-49.4 {testing crlf reading, leftover cr disgorgment} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "a\rb\rc\r\n"
- close $f
- set f [open test1 r]
- set l ""
- lappend l [file size test1]
- fconfigure $f -translation crlf
- lappend l [read $f 3]
- lappend l [tell $f]
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [eof $f]
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [eof $f]
- close $f
- set l
-} "7 [list a\rb] 3 [list \rc] 7 0 {} 7 1"
-test io-49.5 {testing crlf reading, leftover cr disgorgment} {
- removeFile test1
- set f [open test1 w]
- fconfigure $f -translation lf
- puts -nonewline $f "a\rb\rc\r\n"
- close $f
- set f [open test1 r]
- set l ""
- lappend l [file size test1]
- fconfigure $f -translation crlf
- lappend l [set x [gets $f]]
- lappend l [tell $f]
- lappend l [gets $f]
- lappend l [tell $f]
- lappend l [eof $f]
- close $f
- set l
-} [list 7 a\rb\rc 7 {} 7 1]
-
-test io-50.1 {testing handler deletion} {
- removeFile test1
- set f [open test1 w]
- close $f
- set f [open test1 r]
- testchannelevent $f add readable [list delhandler $f]
- proc delhandler {f} {
- global z
- set z called
- testchannelevent $f delete 0
- }
- set z not_called
- update
- close $f
- set z
-} called
-test io-50.2 {testing handler deletion with multiple handlers} {
- removeFile test1
- set f [open test1 w]
- close $f
- set f [open test1 r]
- testchannelevent $f add readable [list delhandler $f 1]
- testchannelevent $f add readable [list delhandler $f 0]
- proc delhandler {f i} {
- global z
- lappend z "called delhandler $f $i"
- testchannelevent $f delete 0
- }
- set z ""
- update
- close $f
- string compare [string tolower $z] \
- [list [list called delhandler $f 0] [list called delhandler $f 1]]
-} 0
-test io-50.3 {testing handler deletion with multiple handlers} {
- removeFile test1
- set f [open test1 w]
- close $f
- set f [open test1 r]
- testchannelevent $f add readable [list notcalled $f 1]
- testchannelevent $f add readable [list delhandler $f 0]
- set z ""
- proc notcalled {f i} {
- global z
- lappend z "notcalled was called!! $f $i"
- }
- proc delhandler {f i} {
- global z
- testchannelevent $f delete 1
- lappend z "delhandler $f $i called"
- testchannelevent $f delete 0
- lappend z "delhandler $f $i deleted myself"
- }
- set z ""
- update
- close $f
- string compare [string tolower $z] \
- [list [list delhandler $f 0 called] \
- [list delhandler $f 0 deleted myself]]
-} 0
-test io-50.4 {testing handler deletion vs reentrant calls} {
- removeFile test1
- set f [open test1 w]
- close $f
- set f [open test1 r]
- testchannelevent $f add readable [list delrecursive $f]
- proc delrecursive {f} {
- global z u
- if {"$u" == "recursive"} {
- testchannelevent $f delete 0
- lappend z "delrecursive deleting recursive"
- } else {
- lappend z "delrecursive calling recursive"
- set u recursive
- update
- }
- }
- set u toplevel
- set z ""
- update
- close $f
- string compare [string tolower $z] \
- {{delrecursive calling recursive} {delrecursive deleting recursive}}
-} 0
-test io-50.5 {testing handler deletion vs reentrant calls} {
- removeFile test1
- set f [open test1 w]
- close $f
- set f [open test1 r]
- testchannelevent $f add readable [list notcalled $f]
- testchannelevent $f add readable [list del $f]
- proc notcalled {f} {
- global z
- lappend z "notcalled was called!! $f"
- }
- proc del {f} {
- global z u
- if {"$u" == "recursive"} {
- testchannelevent $f delete 1
- testchannelevent $f delete 0
- lappend z "del deleted notcalled"
- lappend z "del deleted myself"
- } else {
- set u recursive
- lappend z "del calling recursive"
- update
- lappend z "del after update"
- }
- }
- set z ""
- set u toplevel
- update
- close $f
- string compare [string tolower $z] \
- [list {del calling recursive} {del deleted notcalled} \
- {del deleted myself} {del after update}]
-} 0
-test io-50.6 {testing handler deletion vs reentrant calls} {
- removeFile test1
- set f [open test1 w]
- close $f
- set f [open test1 r]
- testchannelevent $f add readable [list second $f]
- testchannelevent $f add readable [list first $f]
- proc first {f} {
- global u z
- if {"$u" == "toplevel"} {
- lappend z "first called"
- set u first
- update
- lappend z "first after update"
- } else {
- lappend z "first called not toplevel"
- }
- }
- proc second {f} {
- global u z
- if {"$u" == "first"} {
- lappend z "second called, first time"
- set u second
- testchannelevent $f delete 0
- } elseif {"$u" == "second"} {
- lappend z "second called, second time"
- testchannelevent $f delete 0
- } else {
- lappend z "second called, cannot happen!"
- testchannelevent $f removeall
- }
- }
- set z ""
- set u toplevel
- update
- close $f
- string compare [string tolower $z] \
- [list {first called} {first called not toplevel} \
- {second called, first time} {second called, second time} \
- {first after update}]
-} 0
-
-test io-51.1 {Test old socket deletion on Macintosh} {socket} {
- set x 0
- set result ""
- proc accept {s a p} {
- global x wait
- fconfigure $s -blocking off
- puts $s "sock[incr x]"
- close $s
- set wait done
- }
- set ss [socket -server accept 2831]
- set wait ""
- set cs [socket [info hostname] 2831]
- vwait wait
- lappend result [gets $cs]
- close $cs
-
- set wait ""
- set cs [socket [info hostname] 2831]
- vwait wait
- lappend result [gets $cs]
- close $cs
-
- set wait ""
- set cs [socket [info hostname] 2831]
- vwait wait
- lappend result [gets $cs]
- close $cs
-
- set wait ""
- set cs [socket [info hostname] 2831]
- vwait wait
- lappend result [gets $cs]
- close $cs
- close $ss
- set result
-} {sock1 sock2 sock3 sock4}
-
-test io-52.1 {TclCopyChannel} {
- removeFile test1
- set f1 [open $thisScript]
- set f2 [open test1 w]
- fcopy $f1 $f2 -command { # }
- catch { fcopy $f1 $f2 } msg
- close $f1
- close $f2
- string compare $msg "channel \"$f1\" is busy"
-} {0}
-test io-52.2 {TclCopyChannel} {
- removeFile test1
- set f1 [open $thisScript]
- set f2 [open test1 w]
- set f3 [open $thisScript]
- fcopy $f1 $f2 -command { # }
- catch { fcopy $f3 $f2 } msg
- close $f1
- close $f2
- close $f3
- string compare $msg "channel \"$f2\" is busy"
-} {0}
-test io-52.3 {TclCopyChannel} {
- removeFile test1
- set f1 [open $thisScript]
- set f2 [open test1 w]
- fconfigure $f1 -translation lf -blocking 0
- fconfigure $f2 -translation cr -blocking 0
- set s0 [fcopy $f1 $f2]
- set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]]
- close $f1
- close $f2
- set s1 [file size $thisScript]
- set s2 [file size test1]
- if {("$s1" == "$s2") && ($s0 == $s1)} {
- lappend result ok
- }
- set result
-} {0 0 ok}
-test io-52.4 {TclCopyChannel} {
- removeFile test1
- set f1 [open $thisScript]
- set f2 [open test1 w]
- fconfigure $f1 -translation lf -blocking 0
- fconfigure $f2 -translation cr -blocking 0
- fcopy $f1 $f2 -size 40
- set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]]
- close $f1
- close $f2
- lappend result [file size test1]
-} {0 0 40}
-test io-52.5 {TclCopyChannel} {
- removeFile test1
- set f1 [open $thisScript]
- set f2 [open test1 w]
- fconfigure $f1 -translation lf -blocking 0
- fconfigure $f2 -translation lf -blocking 0
- fcopy $f1 $f2 -size -1
- set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]]
- close $f1
- close $f2
- set s1 [file size $thisScript]
- set s2 [file size test1]
- if {"$s1" == "$s2"} {
- lappend result ok
- }
- set result
-} {0 0 ok}
-test io-52.6 {TclCopyChannel} {
- removeFile test1
- set f1 [open $thisScript]
- set f2 [open test1 w]
- fconfigure $f1 -translation lf -blocking 0
- fconfigure $f2 -translation lf -blocking 0
- set s0 [fcopy $f1 $f2 -size [expr [file size $thisScript] + 5]]
- set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]]
- close $f1
- close $f2
- set s1 [file size $thisScript]
- set s2 [file size test1]
- if {("$s1" == "$s2") && ($s0 == $s1)} {
- lappend result ok
- }
- set result
-} {0 0 ok}
-test io-52.7 {TclCopyChannel} {
- removeFile test1
- set f1 [open $thisScript]
- set f2 [open test1 w]
- fconfigure $f1 -translation lf -blocking 0
- fconfigure $f2 -translation lf -blocking 0
- fcopy $f1 $f2
- set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]]
- set s1 [file size $thisScript]
- set s2 [file size test1]
- close $f1
- close $f2
- if {"$s1" == "$s2"} {
- lappend result ok
- }
- set result
-} {0 0 ok}
-test io-52.8 {TclCopyChannel} {stdio} {
- removeFile test1
- removeFile pipe
- set f1 [open pipe w]
- fconfigure $f1 -translation lf
- puts $f1 "
- puts ready
- gets stdin
- set f1 \[open [list $thisScript] r\]
- fconfigure \$f1 -translation lf
- puts \[read \$f1 100\]
- close \$f1
- "
- close $f1
- set f1 [open "|[list $tcltest pipe]" r+]
- fconfigure $f1 -translation lf
- gets $f1
- puts $f1 ready
- flush $f1
- set f2 [open test1 w]
- fconfigure $f2 -translation lf
- set s0 [fcopy $f1 $f2 -size 40]
- catch {close $f1}
- close $f2
- list $s0 [file size test1]
-} {40 40}
-
-test io-53.1 {CopyData} {
- removeFile test1
- set f1 [open $thisScript]
- set f2 [open test1 w]
- fconfigure $f1 -translation lf -blocking 0
- fconfigure $f2 -translation cr -blocking 0
- fcopy $f1 $f2 -size 0
- set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]]
- close $f1
- close $f2
- lappend result [file size test1]
-} {0 0 0}
-test io-53.2 {CopyData} {
- removeFile test1
- set f1 [open $thisScript]
- set f2 [open test1 w]
- fconfigure $f1 -translation lf -blocking 0
- fconfigure $f2 -translation cr -blocking 0
- fcopy $f1 $f2 -command {set s0}
- set result [list [fconfigure $f1 -blocking] [fconfigure $f2 -blocking]]
- vwait s0
- close $f1
- close $f2
- set s1 [file size $thisScript]
- set s2 [file size test1]
- if {("$s1" == "$s2") && ($s0 == $s1)} {
- lappend result ok
- }
- set result
-} {0 0 ok}
-test io-53.3 {CopyData: background read underflow} {unixOnly} {
- removeFile test1
- removeFile pipe
- set f1 [open pipe w]
- puts $f1 {
- puts ready
- flush stdout ;# Don't assume line buffered!
- fcopy stdin stdout -command { set x }
- vwait x
- set f [open test1 w]
- fconfigure $f -translation lf
- puts $f "done"
- close $f
- }
- close $f1
- set f1 [open "|[list $tcltest pipe]" r+]
- set result [gets $f1]
- puts $f1 line1
- flush $f1
- lappend result [gets $f1]
- puts $f1 line2
- flush $f1
- lappend result [gets $f1]
- close $f1
- after 500
- set f [open test1]
- lappend result [read $f]
- close $f
- set result
-} "ready line1 line2 {done\n}"
-test io-53.4 {CopyData: background write overflow} {unixOnly} {
- set big bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n
- for {set x 0} {$x < 12} {incr x} {
- append big $big
- }
- removeFile test1
- removeFile pipe
- set f1 [open pipe w]
- puts $f1 {
- puts ready
- fcopy stdin stdout -command { set x }
- vwait x
- set f [open test1 w]
- fconfigure $f -translation lf
- puts $f "done"
- close $f
- }
- close $f1
- set f1 [open "|[list $tcltest pipe]" r+]
- set result [gets $f1]
- fconfigure $f1 -blocking 0
- puts $f1 $big
- flush $f1
- after 500
- set result ""
- fileevent $f1 read {
- append result [read $f1 1024]
- if {[string length $result] >= [string length $big]} {
- set x done
- }
- }
- vwait x
- close $f1
- set big {}
- set x
-} done
-set result {}
-
-proc FcopyTestAccept {sock args} {
- after 1000 "close $sock"
-}
-proc FcopyTestDone {bytes {error {}}} {
- global fcopyTestDone
- if {[string length $error]} {
- set fcopyTestDone 1
- } else {
- set fcopyTestDone 0
- }
-}
-
-test io-53.5 {CopyData: error during fcopy} {socket} {
- set listen [socket -server FcopyTestAccept 2828]
- set in [open $thisScript] ;# 126 K
- set out [socket 127.0.0.1 2828]
- catch {unset fcopyTestDone}
- close $listen ;# This means the socket open never really succeeds
- fcopy $in $out -command FcopyTestDone
- if ![info exists fcopyTestDone] {
- vwait fcopyTestDone ;# The error occurs here in the b.g.
- }
- close $in
- close $out
- set fcopyTestDone ;# 1 for error condition
-} 1
-test io-53.6 {CopyData: error during fcopy} {stdio} {
- removeFile pipe
- removeFile test1
- catch {unset fcopyTestDone}
- set f1 [open pipe w]
- puts $f1 "exit 1"
- close $f1
- set in [open "|[list $tcltest pipe]" r+]
- set out [open test1 w]
- fcopy $in $out -command [list FcopyTestDone]
- if ![info exists fcopyTestDone] {
- vwait fcopyTestDone
- }
- catch {close $in}
- close $out
- set fcopyTestDone ;# 0 for plain end of file
-} {0}
-
-test io-54.1 {Recursive channel events} {socket} {
- # This test checks to see if file events are delivered during recursive
- # event loops when there is buffered data on the channel.
-
- proc accept {s a p} {
- global as
- fconfigure $s -translation lf
- puts $s "line 1\nline2\nline3"
- flush $s
- set as $s
- }
- proc readit {s next} {
- global result x
- lappend result $next
- if {$next == 1} {
- fileevent $s readable [list readit $s 2]
- vwait x
- }
- incr x
- }
- set ss [socket -server accept 2828]
-
- # We need to delay on some systems until the creation of the
- # server socket completes.
-
- set done 0
- for {set i 0} {$i < 10} {incr i} {
- if {![catch {set cs [socket [info hostname] 2828]}]} {
- set done 1
- break
- }
- after 100
- }
- if {$done == 0} {
- close $ss
- error "failed to connect to server"
- }
- set result {}
- set x 0
- vwait as
- fconfigure $cs -translation lf
- lappend result [gets $cs]
- fconfigure $cs -blocking off
- fileevent $cs readable [list readit $cs 1]
- set a [after 2000 { set x failure }]
- vwait x
- after cancel $a
- close $as
- close $ss
- close $cs
- list $result $x
-} {{{line 1} 1 2} 2}
-test io-54.2 {Testing for busy-wait in recursive channel events} {socket} {
- set accept {}
- set after {}
- set s [socket -server accept 3939]
- proc accept {s a p} {
- global counter accept
-
- set accept $s
- set counter 0
- fconfigure $s -blocking off -buffering line -translation lf
- fileevent $s readable "doit $s"
- }
- proc doit {s} {
- global counter after
-
- incr counter
- set l [gets $s]
- if {"$l" == ""} {
- fileevent $s readable "doit1 $s"
- set after [after 1000 newline]
- }
- }
- proc doit1 {s} {
- global counter accept
-
- incr counter
- set l [gets $s]
- close $s
- set accept {}
- }
- proc producer {} {
- global writer
-
- set writer [socket 127.0.0.1 3939]
- fconfigure $writer -buffering line
- puts -nonewline $writer hello
- flush $writer
- }
- proc newline {} {
- global writer done
-
- puts $writer hello
- flush $writer
- set done 1
- }
- producer
- vwait done
- close $writer
- close $s
- after cancel $after
- if {$accept != {}} {close $accept}
- set counter
-} 1
-
-test io-55.1 {ChannelEventScriptInvoker: deletion} {
- proc eventScript {fd} {
- close $fd
- error "planned error"
- set ::x whoops
- }
- proc bgerror {args} {
- set ::x got_error
- }
- set f [open fooBar w]
- fileevent $f writable [list eventScript $f]
- set x not_done
- vwait x
- set x
-} {got_error}
-
-test io-56.1 {ChannelTimerProc} {
- set f [open fooBar w]
- puts $f "this is a test"
- close $f
- set f [open fooBar r]
- testchannelevent $f add readable {
- read $f 1
- incr x
- }
- set x 0
- vwait x
- vwait x
- set result $x
- testchannelevent $f set 0 none
- after idle {set y done}
- vwait y
- close $f
- lappend result $y
-} {2 done}
-
-test io-57.1 {buffered data and file events, gets} {
- proc accept {sock args} {
- set ::s2 $sock
- }
- set server [socket -server accept 4040]
- set s [socket 127.0.0.1 4040]
- vwait s2
- update
- fileevent $s2 readable {lappend result readable}
- puts $s "12\n34567890"
- flush $s
- set result [gets $s2]
- after 1000 {lappend result timer}
- vwait result
- lappend result [gets $s2]
- vwait result
- close $s
- close $s2
- close $server
- set result
-} {12 readable 34567890 timer}
-test io-57.2 {buffered data and file events, read} {
- proc accept {sock args} {
- set ::s2 $sock
- }
- set server [socket -server accept 4041]
- set s [socket 127.0.0.1 4041]
- vwait s2
- update
- fileevent $s2 readable {lappend result readable}
- puts -nonewline $s "1234567890"
- flush $s
- set result [read $s2 1]
- after 1000 {lappend result timer}
- vwait result
- lappend result [read $s2 9]
- vwait result
- close $s
- close $s2
- close $server
- set result
-} {1 readable 234567890 timer}
-
-test io-58.1 {Tcl_NotifyChannel and error when closing} {unixOrPc} {
- set out [open script w]
- puts $out {
- puts "normal message from pipe"
- puts stderr "error message from pipe"
- exit 1
- }
- proc readit {pipe} {
- global x result
- if {[eof $pipe]} {
- set x [catch {close $pipe} line]
- lappend result catch $line
- } else {
- gets $pipe line
- lappend result gets $line
- }
- }
- close $out
- set pipe [open "|[list $tcltest] script" r]
- fileevent $pipe readable [list readit $pipe]
- set x ""
- set result ""
- vwait x
- list $x $result
-} {1 {gets {normal message from pipe} gets {} catch {error message from pipe}}}
-
-# cleanup
-foreach file [list fooBar longfile script output test1 pipe my_script foo \
- bar test2 test3 cat stdout] {
- ::tcltest::removeFile $file
-}
-restoreState
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/ioCmd.test b/tests/ioCmd.test
deleted file mode 100644
index 1937c5d..0000000
--- a/tests/ioCmd.test
+++ /dev/null
@@ -1,528 +0,0 @@
-# Commands covered: open, close, gets, read, puts, seek, tell, eof, flush,
-# fblocked, fconfigure, open, channel, fcopy
-#
-# 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) 1991-1994 The Regents of the University of California.
-# Copyright (c) 1994-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: ioCmd.test,v 1.3 1999/04/16 00:47:29 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-removeFile test1
-removeFile pipe
-
-set executable [list [info nameofexecutable]]
-
-test iocmd-1.1 {puts command} {
- list [catch {puts} msg] $msg
-} {1 {wrong # args: should be "puts ?-nonewline? ?channelId? string"}}
-test iocmd-1.2 {puts command} {
- list [catch {puts a b c d e f g} msg] $msg
-} {1 {wrong # args: should be "puts ?-nonewline? ?channelId? string"}}
-test iocmd-1.3 {puts command} {
- list [catch {puts froboz -nonewline kablooie} msg] $msg
-} {1 {bad argument "kablooie": should be "nonewline"}}
-test iocmd-1.4 {puts command} {
- list [catch {puts froboz hello} msg] $msg
-} {1 {can not find channel named "froboz"}}
-test iocmd-1.5 {puts command} {
- list [catch {puts stdin hello} msg] $msg
-} {1 {channel "stdin" wasn't opened for writing}}
-test iocmd-1.6 {puts command} {
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar {}
- puts -nonewline $f foobar
- close $f
- file size test1
-} 6
-test iocmd-1.7 {puts command} {
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar {}
- puts $f foobar
- close $f
- file size test1
-} 7
-test iocmd-1.8 {puts command} {
- set f [open test1 w]
- fconfigure $f -translation lf -eofchar {}
- puts -nonewline $f [binary format a4a5 foo bar]
- close $f
- file size test1
-} 9
-
-
-test iocmd-2.1 {flush command} {
- list [catch {flush} msg] $msg
-} {1 {wrong # args: should be "flush channelId"}}
-test iocmd-2.2 {flush command} {
- list [catch {flush a b c d e} msg] $msg
-} {1 {wrong # args: should be "flush channelId"}}
-test iocmd-2.3 {flush command} {
- list [catch {flush foo} msg] $msg
-} {1 {can not find channel named "foo"}}
-test iocmd-2.4 {flush command} {
- list [catch {flush stdin} msg] $msg
-} {1 {channel "stdin" wasn't opened for writing}}
-
-test iocmd-3.1 {gets command} {
- list [catch {gets} msg] $msg
-} {1 {wrong # args: should be "gets channelId ?varName?"}}
-test iocmd-3.2 {gets command} {
- list [catch {gets a b c d e f g} msg] $msg
-} {1 {wrong # args: should be "gets channelId ?varName?"}}
-test iocmd-3.3 {gets command} {
- list [catch {gets aaa} msg] $msg
-} {1 {can not find channel named "aaa"}}
-test iocmd-3.4 {gets command} {
- list [catch {gets stdout} msg] $msg
-} {1 {channel "stdout" wasn't opened for reading}}
-test iocmd-3.5 {gets command} {
- set f [open test1 w]
- puts $f [binary format a4a5 foo bar]
- close $f
- set f [open test1 r]
- set result [gets $f]
- close $f
- set x foo\x00
- set x "${x}bar\x00\x00"
- string compare $x $result
-} 0
-
-test iocmd-4.1 {read command} {
- list [catch {read} msg] $msg
-} {1 {wrong # args: should be "read channelId ?numBytes?" or "read ?-nonewline? channelId"}}
-test iocmd-4.2 {read command} {
- list [catch {read a b c d e f g h} msg] $msg
-} {1 {wrong # args: should be "read channelId ?numBytes?" or "read ?-nonewline? channelId"}}
-test iocmd-4.3 {read command} {
- list [catch {read aaa} msg] $msg
-} {1 {can not find channel named "aaa"}}
-test iocmd-4.4 {read command} {
- list [catch {read -nonewline} msg] $msg
-} {1 {wrong # args: should be "read channelId ?numBytes?" or "read ?-nonewline? channelId"}}
-test iocmd-4.5 {read command} {
- list [catch {read -nonew file4} msg] $msg $errorCode
-} {1 {can not find channel named "-nonew"} NONE}
-test iocmd-4.6 {read command} {
- list [catch {read stdout} msg] $msg
-} {1 {channel "stdout" wasn't opened for reading}}
-test iocmd-4.7 {read command} {
- list [catch {read -nonewline stdout} msg] $msg
-} {1 {channel "stdout" wasn't opened for reading}}
-test iocmd-4.8 {read command with incorrect combination of arguments} {
- removeFile test1
- set f [open test1 w]
- puts $f "Two lines: this one"
- puts $f "and this one"
- close $f
- set f [open test1]
- set x [list [catch {read -nonewline $f 20 z} msg] $msg $errorCode]
- close $f
- set x
-} {1 {wrong # args: should be "read channelId ?numBytes?" or "read ?-nonewline? channelId"} NONE}
-test iocmd-4.9 {read command} {
- list [catch {read stdin foo} msg] $msg $errorCode
-} {1 {bad argument "foo": should be "nonewline"} NONE}
-test iocmd-4.10 {read command} {
- list [catch {read file107} msg] $msg $errorCode
-} {1 {can not find channel named "file107"} NONE}
-test iocmd-4.11 {read command} {
- set f [open test3 w]
- set x [list [catch {read $f} msg] $msg $errorCode]
- close $f
- string compare [string tolower $x] \
- [list 1 [format "channel \"%s\" wasn't opened for reading" $f] none]
-} 0
-test iocmd-4.12 {read command} {
- set f [open test1]
- set x [list [catch {read $f 12z} msg] $msg $errorCode]
- close $f
- set x
-} {1 {expected integer but got "12z"} NONE}
-
-test iocmd-5.1 {seek command} {
- list [catch {seek} msg] $msg
-} {1 {wrong # args: should be "seek channelId offset ?origin?"}}
-test iocmd-5.2 {seek command} {
- list [catch {seek a b c d e f g} msg] $msg
-} {1 {wrong # args: should be "seek channelId offset ?origin?"}}
-test iocmd-5.3 {seek command} {
- list [catch {seek stdin gugu} msg] $msg
-} {1 {expected integer but got "gugu"}}
-test iocmd-5.4 {seek command} {
- list [catch {seek stdin 100 gugu} msg] $msg
-} {1 {bad origin "gugu": must be start, current, or end}}
-
-test iocmd-6.1 {tell command} {
- list [catch {tell} msg] $msg
-} {1 {wrong # args: should be "tell channelId"}}
-test iocmd-6.2 {tell command} {
- list [catch {tell a b c d e} msg] $msg
-} {1 {wrong # args: should be "tell channelId"}}
-test iocmd-6.3 {tell command} {
- list [catch {tell aaa} msg] $msg
-} {1 {can not find channel named "aaa"}}
-
-test iocmd-7.1 {close command} {
- list [catch {close} msg] $msg
-} {1 {wrong # args: should be "close channelId"}}
-test iocmd-7.2 {close command} {
- list [catch {close a b c d e} msg] $msg
-} {1 {wrong # args: should be "close channelId"}}
-test iocmd-7.3 {close command} {
- list [catch {close aaa} msg] $msg
-} {1 {can not find channel named "aaa"}}
-
-test iocmd-8.1 {fconfigure command} {
- list [catch {fconfigure} msg] $msg
-} {1 {wrong # args: should be "fconfigure channelId ?optionName? ?value? ?optionName value?..."}}
-test iocmd-8.2 {fconfigure command} {
- list [catch {fconfigure a b c d e f} msg] $msg
-} {1 {wrong # args: should be "fconfigure channelId ?optionName? ?value? ?optionName value?..."}}
-test iocmd-8.3 {fconfigure command} {
- list [catch {fconfigure a b} msg] $msg
-} {1 {can not find channel named "a"}}
-test iocmd-8.4 {fconfigure command} {
- removeFile test1
- set f1 [open test1 w]
- set x [list [catch {fconfigure $f1 froboz} msg] $msg]
- close $f1
- set x
-} {1 {bad option "froboz": should be one of -blocking, -buffering, -buffersize, -eofchar, or -translation}}
-test iocmd-8.5 {fconfigure command} {
- list [catch {fconfigure stdin -buffering froboz} msg] $msg
-} {1 {bad value for -buffering: must be one of full, line, or none}}
-test iocmd-8.6 {fconfigure command} {
- list [catch {fconfigure stdin -translation froboz} msg] $msg
-} {1 {bad value for -translation: must be one of auto, binary, cr, lf, crlf, or platform}}
-test iocmd-8.7 {fconfigure command} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf -eofchar {} -encoding unicode
- set x [fconfigure $f1]
- close $f1
- set x
-} {-blocking 1 -buffering full -buffersize 4096 -encoding unicode -eofchar {} -translation lf}
-test iocmd-8.8 {fconfigure command} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation lf -buffering line -buffersize 3030 \
- -eofchar {} -encoding unicode
- set x ""
- lappend x [fconfigure $f1 -buffering]
- lappend x [fconfigure $f1]
- close $f1
- set x
-} {line {-blocking 1 -buffering line -buffersize 3030 -encoding unicode -eofchar {} -translation lf}}
-test iocmd-8.9 {fconfigure command} {
- removeFile test1
- set f1 [open test1 w]
- fconfigure $f1 -translation binary -buffering none -buffersize 4040 \
- -eofchar {} -encoding binary
- set x [fconfigure $f1]
- close $f1
- set x
-} {-blocking 1 -buffering none -buffersize 4040 -encoding binary -eofchar {} -translation lf}
-test iocmd-8.10 {fconfigure command} {
- list [catch {fconfigure a b} msg] $msg
-} {1 {can not find channel named "a"}}
-test iocmd-8.11 {fconfigure command} {
- list [catch {fconfigure stdout -froboz blarfo} msg] $msg
-} {1 {bad option "-froboz": should be one of -blocking, -buffering, -buffersize, -eofchar, or -translation}}
-test iocmd-8.12 {fconfigure command} {
- list [catch {fconfigure stdout -b blarfo} msg] $msg
-} {1 {bad option "-b": should be one of -blocking, -buffering, -buffersize, -eofchar, or -translation}}
-test iocmd-8.13 {fconfigure command} {
- list [catch {fconfigure stdout -buffer blarfo} msg] $msg
-} {1 {bad option "-buffer": should be one of -blocking, -buffering, -buffersize, -eofchar, or -translation}}
-test iocmd-8.14 {fconfigure command} {
- fconfigure stdin -buffers
-} 4096
-proc iocmdSSETUP {} {
- uplevel {
- set srv [socket -server iocmdSRV 0];
- set port [lindex [fconfigure $srv -sockname] 2];
- proc iocmdSRV {sock ip port} {close $sock}
- set cli [socket 127.0.0.1 $port];
- }
-}
-proc iocmdSSHTDWN {} {
- uplevel {
- close $cli;
- close $srv;
- unset cli srv port
- rename iocmdSRV {}
- }
-}
-
-test iocmd-8.15 {fconfigure command / tcp channel} {socket} {
- iocmdSSETUP
- set r [list [catch {fconfigure $cli -blah} msg] $msg];
- iocmdSSHTDWN
- set r;
-} {1 {bad option "-blah": should be one of -blocking, -buffering, -buffersize, -eofchar, -translation, -peername, or -sockname}}
-test iocmd-8.16 {fconfigure command / tcp channel} {socket} {
- iocmdSSETUP
- set r [expr [lindex [fconfigure $cli -peername] 2]==$port];
- iocmdSSHTDWN
- set r
-} 1
-test iocmd-8.17 {fconfigure command / tcp channel} {nonPortable} {
- # It is possible that you don't get the connection reset by peer
- # error but rather a valid answer. depends of the tcp implementation
- iocmdSSETUP
- update;
- puts $cli "blah"; flush $cli; # that flush could/should fail too
- update;
- set r [catch {fconfigure $cli -peername} msg]
- iocmdSSHTDWN
- regsub -all {can([^:])+: } $r {} r;
- set r
-} 1
-test iocmd-8.18 {fconfigure command / unix tty channel} {nonPortable unixOnly} {
- # might fail if /dev/ttya is unavailable
- set tty [open /dev/ttya]
- set r [list [catch {fconfigure $tty -blah blih} msg] $msg];
- close $tty;
- set r;
-} {1 {bad option "-blah": should be one of -blocking, -buffering, -buffersize, -eofchar, -translation, or -mode}}
-test iocmd-8.19 {fconfigure command / win tty channel} {nonPortable pcOnly} {
- # might fail if com1 is unavailable
- set tty [open com1]
- set r [list [catch {fconfigure $tty -blah blih} msg] $msg];
- close $tty;
- set r;
-} {1 {bad option "-blah": should be one of -blocking, -buffering, -buffersize, -eofchar, -translation, or -mode}}
-
-test iocmd-9.1 {eof command} {
- list [catch {eof} msg] $msg $errorCode
-} {1 {wrong # args: should be "eof channelId"} NONE}
-test iocmd-9.2 {eof command} {
- list [catch {eof a b} msg] $msg $errorCode
-} {1 {wrong # args: should be "eof channelId"} NONE}
-test iocmd-9.3 {eof command} {
- catch {close file100}
- list [catch {eof file100} msg] $msg $errorCode
-} {1 {can not find channel named "file100"} NONE}
-
-# The tests for Tcl_ExecObjCmd are in exec.test
-
-test iocmd-10.1 {fblocked command} {
- list [catch {fblocked} msg] $msg
-} {1 {wrong # args: should be "fblocked channelId"}}
-test iocmd-10.2 {fblocked command} {
- list [catch {fblocked a b c d e f g} msg] $msg
-} {1 {wrong # args: should be "fblocked channelId"}}
-test iocmd-10.3 {fblocked command} {
- list [catch {fblocked file1000} msg] $msg
-} {1 {can not find channel named "file1000"}}
-test iocmd-10.4 {fblocked command} {
- list [catch {fblocked stdout} msg] $msg
-} {1 {channel "stdout" wasn't opened for reading}}
-test iocmd-10.5 {fblocked command} {
- fblocked stdin
-} 0
-
-removeFile test5
-test iocmd-11.1 {I/O to command pipelines} {unixOrPc unixExecs} {
- set f [open test4 w]
- close $f
- list [catch {open "| cat < test4 > test5" w} msg] $msg $errorCode
-} {1 {can't write input to command: standard input was redirected} NONE}
-test iocmd-11.2 {I/O to command pipelines} {unixOrPc unixExecs} {
- list [catch {open "| echo > test5" r} msg] $msg $errorCode
-} {1 {can't read output from command: standard output was redirected} NONE}
-test iocmd-11.3 {I/O to command pipelines} {unixOrPc unixExecs} {
- list [catch {open "| echo > test5" r+} msg] $msg $errorCode
-} {1 {can't read output from command: standard output was redirected} NONE}
-
-test iocmd-12.1 {POSIX open access modes: RDONLY} {
- removeFile test1
- set f [open test1 w]
- puts $f "Two lines: this one"
- puts $f "and this one"
- close $f
- set f [open test1 RDONLY]
- set x [list [gets $f] [catch {puts $f Test} msg] $msg]
- close $f
- string compare $x \
- "{Two lines: this one} 1 [list [format "channel \"%s\" wasn't opened for writing" $f]]"
-} 0
-test iocmd-12.2 {POSIX open access modes: RDONLY} {
- removeFile test3
- string tolower [list [catch {open test3 RDONLY} msg] $msg]
-} {1 {couldn't open "test3": no such file or directory}}
-test iocmd-12.3 {POSIX open access modes: WRONLY} {
- removeFile test3
- string tolower [list [catch {open test3 WRONLY} msg] $msg]
-} {1 {couldn't open "test3": no such file or directory}}
-#
-# Test 13.4 relies on assigning the same channel name twice.
-#
-test iocmd-12.4 {POSIX open access modes: WRONLY} {unixOnly} {
- removeFile test3
- set f [open test3 w]
- fconfigure $f -eofchar {}
- puts $f xyzzy
- close $f
- set f [open test3 WRONLY]
- fconfigure $f -eofchar {}
- puts -nonewline $f "ab"
- seek $f 0 current
- set x [list [catch {gets $f} msg] $msg]
- close $f
- set f [open test3 r]
- fconfigure $f -eofchar {}
- lappend x [gets $f]
- close $f
- set y [list 1 [format "channel \"%s\" wasn't opened for reading" $f] abzzy]
- string compare $x $y
-} 0
-test iocmd-12.5 {POSIX open access modes: RDWR} {
- removeFile test3
- string tolower [list [catch {open test3 RDWR} msg] $msg]
-} {1 {couldn't open "test3": no such file or directory}}
-test iocmd-12.6 {POSIX open access modes: errors} {
- concat [catch {open test3 "FOO \{BAR BAZ"} msg] $msg\n$errorInfo
-} "1 unmatched open brace in list
-unmatched open brace in list
- while processing open access modes \"FOO {BAR BAZ\"
- invoked from within
-\"open test3 \"FOO \\{BAR BAZ\"\""
-test iocmd-12.7 {POSIX open access modes: errors} {
- list [catch {open test3 {FOO BAR BAZ}} msg] $msg
-} {1 {invalid access mode "FOO": must be RDONLY, WRONLY, RDWR, APPEND, CREAT EXCL, NOCTTY, NONBLOCK, or TRUNC}}
-test iocmd-12.8 {POSIX open access modes: errors} {
- list [catch {open test3 {TRUNC CREAT}} msg] $msg
-} {1 {access mode must include either RDONLY, WRONLY, or RDWR}}
-
-test iocmd-13.1 {errors in open command} {
- list [catch {open} msg] $msg
-} {1 {wrong # args: should be "open fileName ?access? ?permissions?"}}
-test iocmd-13.2 {errors in open command} {
- list [catch {open a b c d} msg] $msg
-} {1 {wrong # args: should be "open fileName ?access? ?permissions?"}}
-test iocmd-13.3 {errors in open command} {
- list [catch {open test1 x} msg] $msg
-} {1 {illegal access mode "x"}}
-test iocmd-13.4 {errors in open command} {
- list [catch {open test1 rw} msg] $msg
-} {1 {illegal access mode "rw"}}
-test iocmd-13.5 {errors in open command} {
- list [catch {open test1 r+1} msg] $msg
-} {1 {illegal access mode "r+1"}}
-test iocmd-13.6 {errors in open command} {
- string tolower [list [catch {open _non_existent_} msg] $msg $errorCode]
-} {1 {couldn't open "_non_existent_": no such file or directory} {posix enoent {no such file or directory}}}
-
-test iocmd-14.1 {file id parsing errors} {
- list [catch {eof gorp} msg] $msg $errorCode
-} {1 {can not find channel named "gorp"} NONE}
-test iocmd-14.2 {file id parsing errors} {
- list [catch {eof filex} msg] $msg
-} {1 {can not find channel named "filex"}}
-test iocmd-14.3 {file id parsing errors} {
- list [catch {eof file12a} msg] $msg
-} {1 {can not find channel named "file12a"}}
-test iocmd-14.4 {file id parsing errors} {
- list [catch {eof file123} msg] $msg
-} {1 {can not find channel named "file123"}}
-test iocmd-14.5 {file id parsing errors} {
- list [catch {eof stdout} msg] $msg
-} {0 0}
-test iocmd-14.6 {file id parsing errors} {
- list [catch {eof stdin} msg] $msg
-} {0 0}
-test iocmd-14.7 {file id parsing errors} {
- list [catch {eof stdout} msg] $msg
-} {0 0}
-test iocmd-14.8 {file id parsing errors} {
- list [catch {eof stderr} msg] $msg
-} {0 0}
-test iocmd-14.9 {file id parsing errors} {
- list [catch {eof stderr1} msg] $msg
-} {1 {can not find channel named "stderr1"}}
-set f [open test1 w]
-close $f
-set expect "1 {can not find channel named \"$f\"}"
-test iocmd-14.10 {file id parsing errors} {
- list [catch {eof $f} msg] $msg
-} $expect
-
-test iocmd-15.1 {Tcl_FcopyObjCmd} {
- list [catch {fcopy} msg] $msg
-} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}
-test iocmd-15.2 {Tcl_FcopyObjCmd} {
- list [catch {fcopy 1} msg] $msg
-} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}
-test iocmd-15.3 {Tcl_FcopyObjCmd} {
- list [catch {fcopy 1 2 3 4 5 6 7} msg] $msg
-} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}
-test iocmd-15.4 {Tcl_FcopyObjCmd} {
- list [catch {fcopy 1 2 3} msg] $msg
-} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}
-test iocmd-15.5 {Tcl_FcopyObjCmd} {
- list [catch {fcopy 1 2 3 4 5} msg] $msg
-} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}
-set f [open test1 w]
-close $f
-set rfile [open test1 r]
-set wfile [open test2 w]
-test iocmd-15.6 {Tcl_FcopyObjCmd} {
- list [catch {fcopy foo $wfile} msg] $msg
-} {1 {can not find channel named "foo"}}
-test iocmd-15.7 {Tcl_FcopyObjCmd} {
- list [catch {fcopy $rfile foo} msg] $msg
-} {1 {can not find channel named "foo"}}
-test iocmd-15.8 {Tcl_FcopyObjCmd} {
- list [catch {fcopy $wfile $wfile} msg] $msg
-} "1 {channel \"$wfile\" wasn't opened for reading}"
-test iocmd-15.9 {Tcl_FcopyObjCmd} {
- list [catch {fcopy $rfile $rfile} msg] $msg
-} "1 {channel \"$rfile\" wasn't opened for writing}"
-test iocmd-15.10 {Tcl_FcopyObjCmd} {
- list [catch {fcopy $rfile $wfile foo bar} msg] $msg
-} {1 {bad switch "foo": must be -size or -command}}
-test iocmd-15.11 {Tcl_FcopyObjCmd} {
- list [catch {fcopy $rfile $wfile -size foo} msg] $msg
-} {1 {expected integer but got "foo"}}
-test iocmd-15.12 {Tcl_FcopyObjCmd} {
- list [catch {fcopy $rfile $wfile -command bar -size foo} msg] $msg
-} {1 {expected integer but got "foo"}}
-
-close $rfile
-close $wfile
-
-# cleanup
-foreach file [list test1 test2 test3 test4] {
- ::tcltest::removeFile $file
-}
-# delay long enough for background processes to finish
-after 500
-foreach file [list test5 pipe output] {
- ::tcltest::removeFile $file
-}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/ioUtil.test b/tests/ioUtil.test
deleted file mode 100644
index 5bb8c35..0000000
--- a/tests/ioUtil.test
+++ /dev/null
@@ -1,318 +0,0 @@
-# This file (ioUtil.test) tests the hookable TclStat(), TclAccess(),
-# and Tcl_OpenFileChannel, routines in the file generic/tclIOUtils.c.
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# 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: ioUtil.test,v 1.6 1999/04/16 00:47:29 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-set unsetScript {
- catch {unset testStat1(size)}
- catch {unset testStat2(size)}
- catch {unset testStat3(size)}
-}
-
-test ioUtil-1.1 {TclStat: Check that none of the test procs are there.} {knownBug} {
- catch {file stat testStat1%.fil testStat1} err1
- catch {file stat testStat2%.fil testStat2} err2
- catch {file stat testStat3%.fil testStat3} err3
- list $err1 $err2 $err3
-} {{couldn't stat "testStat1%.fil": no such file or directory} {couldn't stat "testStat2%.fil": no such file or directory} {couldn't stat "testStat3%.fil": no such file or directory}}
-
-if {[info commands teststatproc] == {}} {
- puts "This application hasn't been compiled with the \"teststatproc\""
- puts "command, so I can't test Tcl_Stat_* etc."
-} else {
-test ioUtil-1.2 {TclStatInsertProc: Insert the 3 test TclStat_ procedures.} {
- catch {teststatproc insert TclpStat} err1
- teststatproc insert TestStatProc1
- teststatproc insert TestStatProc2
- teststatproc insert TestStatProc3
- set err1
-} {bad arg "insert": must be TestStatProc1, TestStatProc2, or TestStatProc3}
-
-test ioUtil-1.3 {TclStat: Use "file stat ?" to invoke each procedure.} {knownBug} {
- file stat testStat2%.fil testStat2
- file stat testStat1%.fil testStat1
- file stat testStat3%.fil testStat3
-
- list $testStat2(size) $testStat1(size) $testStat3(size)
-} {2345 1234 3456}
-
-eval $unsetScript
-
-test ioUtil-1.4 {TclStatDeleteProc: "TclpStat" function should not be deletedable.} {
- catch {teststatproc delete TclpStat} err2
- set err2
-} {"TclpStat": could not be deleteed}
-
-test ioUtil-1.5 {TclStatDeleteProc: Delete the 2nd TclStat procedure.} {knownBug} {
- # Delete the 2nd procedure and test that it longer exists but that
- # the others do actually return a result.
-
- teststatproc delete TestStatProc2
- file stat testStat1%.fil testStat1
- catch {file stat testStat2%.fil testStat2} err3
- file stat testStat3%.fil testStat3
-
- list $testStat1(size) $err3 $testStat3(size)
-} {1234 {couldn't stat "testStat2%.fil": no such file or directory} 3456}
-
-eval $unsetScript
-
-test ioUtil-1.6 {TclStatDeleteProc: Delete the 1st TclStat procedure.} {knownBug} {
- # Next delete the 1st procedure and test that only the 3rd procedure
- # is the only one that exists.
-
- teststatproc delete TestStatProc1
- catch {file stat testStat1%.fil testStat1} err4
- catch {file stat testStat2%.fil testStat2} err5
- file stat testStat3%.fil testStat3
-
- list $err4 $err5 $testStat3(size)
-} {{couldn't stat "testStat1%.fil": no such file or directory} {couldn't stat "testStat2%.fil": no such file or directory} 3456}
-
-eval $unsetScript
-
-test ioUtil-1.7 {TclStatDeleteProc: Delete the 3rd procedure & verify all are gone.} {knownBug} {
- # Finally delete the 3rd procedure and check that none of the
- # procedures exist.
-
- teststatproc delete TestStatProc3
- catch {file stat testStat1%.fil testStat1} err6
- catch {file stat testStat2%.fil testStat2} err7
- catch {file stat testStat3%.fil testStat3} err8
-
- list $err6 $err7 $err8
-} {{couldn't stat "testStat1%.fil": no such file or directory} {couldn't stat "testStat2%.fil": no such file or directory} {couldn't stat "testStat3%.fil": no such file or directory}}
-
-eval $unsetScript
-
-test ioUtil-1.8 {TclStatDeleteProc: Verify that all procs have been deleted.} {knownBug} {
- # Attempt to delete all the Stat procs. again to ensure they no longer
- # exist and an error is returned.
-
- catch {teststatproc delete TestStatProc1} err9
- catch {teststatproc delete TestStatProc2} err10
- catch {teststatproc delete TestStatProc3} err11
-
- list $err9 $err10 $err11
-} {{"TestStatProc1": could not be deleteed} {"TestStatProc2": could not be deleteed} {"TestStatProc3": could not be deleteed}}
-}
-
-eval $unsetScript
-
-
-test access-1.1 {TclAccess: Check that none of the test procs are there.} {
- catch {file exists testAccess1%.fil} err1
- catch {file exists testAccess2%.fil} err2
- catch {file exists testAccess3%.fil} err3
- list $err1 $err2 $err3
-} {0 0 0}
-
-if {[info commands testaccessproc] == {}} {
- puts "This application hasn't been compiled with the \"testaccessproc\""
- puts "command, so I can't test Tcl_Access_* etc."
-} else {
-test ioUtil-1.2 {TclAccessInsertProc: Insert the 3 test TclAccess_ procedures.} {
- catch {testaccessproc insert TclpAccess} err1
- testaccessproc insert TestAccessProc1
- testaccessproc insert TestAccessProc2
- testaccessproc insert TestAccessProc3
- set err1
-} {bad arg "insert": must be TestAccessProc1, TestAccessProc2, or TestAccessProc3}
-
-test ioUtil-2.3 {TclAccess: Use "file access ?" to invoke each procedure.} {
- list \
- [file exists testAccess2%.fil] \
- [file exists testAccess1%.fil] \
- [file exists testAccess3%.fil]
-} {1 1 1}
-
-test ioUtil-2.4 {TclAccessDeleteProc: "TclpAccess" function should not be deletedable.} {
- catch {testaccessproc delete TclpAccess} err2
- set err2
-} {"TclpAccess": could not be deleteed}
-
-test accesst-1.5 {TclAccessDeleteProc: Delete the 2nd TclAccess procedure.} {
- # Delete the 2nd procedure and test that it longer exists but that
- # the others do actually return a result.
-
- testaccessproc delete TestAccessProc2
- set res1 [file exists testAccess1%.fil]
- catch {file exists testAccess2%.fil} err3
- set res2 [file exists testAccess3%.fil]
-
- list $res1 $err3 $res2
-} {1 0 1}
-
-test ioUtil-2.6 {TclAccessDeleteProc: Delete the 1st TclAccess procedure.} {
- # Next delete the 1st procedure and test that only the 3rd procedure
- # is the only one that exists.
-
- testaccessproc delete TestAccessProc1
- catch {file exists testAccess1%.fil} err4
- catch {file exists testAccess2%.fil} err5
- set res3 [file exists testAccess3%.fil]
-
- list $err4 $err5 $res3
-} {0 0 1}
-
-test ioUtil-2.7 {TclAccessDeleteProc: Delete the 3rd procedure & verify all are gone.} {
- # Finally delete the 3rd procedure and check that none of the
- # procedures exist.
-
- testaccessproc delete TestAccessProc3
- catch {file exists testAccess1%.fil} err6
- catch {file exists testAccess2%.fil} err7
- catch {file exists testAccess3%.fil} err8
-
- list $err6 $err7 $err8
-} {0 0 0}
-
-test ioUtil-2.8 {TclAccessDeleteProc: Verify that all procs have been deleted.} {
- # Attempt to delete all the Access procs. again to ensure they no longer
- # exist and an error is returned.
-
- catch {testaccessproc delete TestAccessProc1} err9
- catch {testaccessproc delete TestAccessProc2} err10
- catch {testaccessproc delete TestAccessProc3} err11
-
- list $err9 $err10 $err11
-} {{"TestAccessProc1": could not be deleteed} {"TestAccessProc2": could not be deleteed} {"TestAccessProc3": could not be deleteed}}
-}
-
-test ioUtil-3.1 {TclOpenFileChannel: Check that none of the test procs are there.} {
- catch {file exists __testOpenFileChannel1%__.fil} err1
- catch {file exists __testOpenFileChannel2%__.fil} err2
- catch {file exists __testOpenFileChannel3%__.fil} err3
- catch {file exists __testOpenFileChannel1%__.fil} err4
- catch {file exists __testOpenFileChannel2%__.fil} err5
- catch {file exists __testOpenFileChannel3%__.fil} err6
- list $err1 $err2 $err3 $err4 $err5 $err6
-} {0 0 0 0 0 0}
-
-if {[info commands testopenfilechannelproc] == {}} {
- puts "This application hasn't been compiled with the \"testopenfilechannelproc\""
- puts "command, so I can't test Tcl_OpenFileChannelInsert"
-} else {
-test ioUtil-3.2 {TclOpenFileChannelInsertProc: Insert the 3 test TclOpenFileChannel_ procedures.} {
- catch {testopenfilechannelproc insert TclpOpenFileChannel} err1
- testopenfilechannelproc insert TestOpenFileChannelProc1
- testopenfilechannelproc insert TestOpenFileChannelProc2
- testopenfilechannelproc insert TestOpenFileChannelProc3
- set err1
-} {bad arg "insert": must be TestOpenFileChannelProc1, TestOpenFileChannelProc2, or TestOpenFileChannelProc3}
-
-test ioUtil-3.3 {TclOpenFileChannel: Use "file openfilechannel ?" to invoke each procedure.} {
- close [open __testOpenFileChannel1%__.fil w]
- close [open __testOpenFileChannel2%__.fil w]
- close [open __testOpenFileChannel3%__.fil w]
-
- catch {
- close [open testOpenFileChannel1%.fil r]
- close [open testOpenFileChannel2%.fil r]
- close [open testOpenFileChannel3%.fil r]
- } err
-
- file delete __testOpenFileChannel1%__.fil
- file delete __testOpenFileChannel2%__.fil
- file delete __testOpenFileChannel3%__.fil
-
- set err
-} {}
-
-test ioUtil-3.4 {TclOpenFileChannelDeleteProc: "TclpOpenFileChannel" function should not be deletedable.} {
- catch {testopenfilechannelproc delete TclpOpenFileChannel} err2
- set err2
-} {"TclpOpenFileChannel": could not be deleteed}
-
-test openfilechannelt-1.5 {TclOpenFileChannelDeleteProc: Delete the 2nd TclOpenFileChannel procedure.} {
- # Delete the 2nd procedure and test that it longer exists but that
- # the others do actually return a result.
-
- testopenfilechannelproc delete TestOpenFileChannelProc2
-
- close [open __testOpenFileChannel1%__.fil w]
- close [open __testOpenFileChannel3%__.fil w]
-
- catch {
- close [open testOpenFileChannel1%.fil r]
- catch {close [open testOpenFileChannel2%.fil r]}
- close [open testOpenFileChannel3%.fil r]
- } err3
-
- file delete __testOpenFileChannel1%__.fil
- file delete __testOpenFileChannel3%__.fil
-
- set err3
-} {}
-
-test ioUtil-3.6 {TclOpenFileChannelDeleteProc: Delete the 1st TclOpenFileChannel procedure.} {
- # Next delete the 1st procedure and test that only the 3rd procedure
- # is the only one that exists.
-
- testopenfilechannelproc delete TestOpenFileChannelProc1
-
- close [open __testOpenFileChannel3%__.fil w]
-
- catch {
- catch {close [open testOpenFileChannel1%.fil r]}
- catch {close [open testOpenFileChannel2%.fil r]}
- close [open testOpenFileChannel3%.fil r]
- } err4
-
- file delete __testOpenFileChannel3%__.fil
-
- set err4
-} {}
-
-test ioUtil-3.7 {TclOpenFileChannelDeleteProc: Delete the 3rd procedure & verify all are gone.} {
- # Finally delete the 3rd procedure and check that none of the
- # procedures exist.
-
- testopenfilechannelproc delete TestOpenFileChannelProc3
- catch {
- catch [open testOpenFileChannel1%.fil r]
- catch [open testOpenFileChannel2%.fil r]
- catch [open testOpenFileChannel3%.fil r]
- } err5
-
- set err5
-} {1}
-
-test ioUtil-3.8 {TclOpenFileChannelDeleteProc: Verify that all procs have been deleted.} {
- # Attempt to delete all the OpenFileChannel procs. again to ensure they no longer
- # exist and an error is returned.
-
- catch {testopenfilechannelproc delete TestOpenFileChannelProc1} err9
- catch {testopenfilechannelproc delete TestOpenFileChannelProc2} err10
- catch {testopenfilechannelproc delete TestOpenFileChannelProc3} err11
-
- list $err9 $err10 $err11
-} {{"TestOpenFileChannelProc1": could not be deleteed} {"TestOpenFileChannelProc2": could not be deleteed} {"TestOpenFileChannelProc3": could not be deleteed}}
-}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/join.test b/tests/join.test
deleted file mode 100644
index 6194c7d..0000000
--- a/tests/join.test
+++ /dev/null
@@ -1,65 +0,0 @@
-# Commands covered: join
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: join.test,v 1.3 1999/04/16 00:47:29 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test join-1.1 {basic join commands} {
- join {a b c} xyz
-} axyzbxyzc
-test join-1.2 {basic join commands} {
- join {a b c} {}
-} abc
-test join-1.3 {basic join commands} {
- join {} xyz
-} {}
-test join-1.4 {basic join commands} {
- join {12 34 56}
-} {12 34 56}
-
-test join-2.1 {join errors} {
- list [catch join msg] $msg $errorCode
-} {1 {wrong # args: should be "join list ?joinString?"} NONE}
-test join-2.2 {join errors} {
- list [catch {join a b c} msg] $msg $errorCode
-} {1 {wrong # args: should be "join list ?joinString?"} NONE}
-test join-2.3 {join errors} {
- list [catch {join "a \{ c" 111} msg] $msg $errorCode
-} {1 {unmatched open brace in list} NONE}
-
-test join-3.1 {joinString is binary ok} {
- string length [join {a b c} a\0b]
-} 9
-
-test join-3.2 {join is binary ok} {
- string length [join "a\0b a\0b a\0b"]
-} 11
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/lindex.test b/tests/lindex.test
deleted file mode 100644
index c7e5fb8..0000000
--- a/tests/lindex.test
+++ /dev/null
@@ -1,93 +0,0 @@
-# Commands covered: lindex
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: lindex.test,v 1.3 1999/04/16 00:47:30 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test lindex-1.1 {basic tests} {
- lindex {a b c} 0} a
-test lindex-1.2 {basic tests} {
- lindex {a {b c d} x} 1} {b c d}
-test lindex-1.3 {basic tests} {
- lindex {a b\ c\ d x} 1} {b c d}
-test lindex-1.4 {basic tests} {
- lindex {a b c} 3} {}
-test lindex-1.5 {basic tests} {
- list [catch {lindex {a b c} -1} msg] $msg
-} {0 {}}
-test lindex-1.6 {basic tests} {
- lindex {a b c d} end
-} d
-test lindex-1.7 {basic tests} {
- lindex {a b c d} 100
-} {}
-test lindex-1.8 {basic tests} {
- lindex {a} e
-} a
-test lindex-1.9 {basic tests} {
- lindex {} end
-} {}
-test lindex-1.10 {basic tests} {
- lindex {a b c d} 3
-} d
-
-test lindex-2.1 {error conditions} {
- list [catch {lindex msg} msg] $msg
-} {1 {wrong # args: should be "lindex list index"}}
-test lindex-2.2 {error conditions} {
- list [catch {lindex 1 2 3 4} msg] $msg
-} {1 {wrong # args: should be "lindex list index"}}
-test lindex-2.3 {error conditions} {
- list [catch {lindex 1 2a2} msg] $msg
-} {1 {bad index "2a2": must be integer or "end"}}
-test lindex-2.4 {error conditions} {
- list [catch {lindex "a \{" 2} msg] $msg
-} {1 {unmatched open brace in list}}
-test lindex-2.5 {error conditions} {
- list [catch {lindex {a {b c}d e} 2} msg] $msg
-} {1 {list element in braces followed by "d" instead of space}}
-test lindex-2.6 {error conditions} {
- list [catch {lindex {a "b c"def ghi} 2} msg] $msg
-} {1 {list element in quotes followed by "def" instead of space}}
-
-test lindex-3.1 {quoted elements} {
- lindex {a "b c" d} 1
-} {b c}
-test lindex-3.2 {quoted elements} {
- lindex {"{}" b c} 0
-} {{}}
-test lindex-3.3 {quoted elements} {
- lindex {ab "c d \" x" y} 1
-} {c d " x}
-test lindex-3.4 {quoted elements} {
- lindex {a b {c d "e} {f g"}} 2
-} {c d "e}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/link.test b/tests/link.test
deleted file mode 100644
index 4ea079c..0000000
--- a/tests/link.test
+++ /dev/null
@@ -1,255 +0,0 @@
-# Commands covered: none
-#
-# This file contains a collection of tests for Tcl_LinkVar and related
-# library procedures. Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-#
-# Copyright (c) 1993 The Regents of the University of California.
-# Copyright (c) 1994 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: link.test,v 1.3 1999/04/16 00:47:30 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[info commands testlink] == {}} {
- puts "This application hasn't been compiled with the \"testlink\""
- puts "command, so I can't test Tcl_LinkVar et al."
- ::tcltest::cleanupTests
- return
-}
-
-foreach i {int real bool string} {
- catch {unset $i}
-}
-test link-1.1 {reading C variables from Tcl} {
- testlink delete
- testlink set 43 1.23 4 -
- testlink create 1 1 1 1
- list $int $real $bool $string
-} {43 1.23 1 NULL}
-test link-1.2 {reading C variables from Tcl} {
- testlink delete
- testlink create 1 1 1 1
- testlink set -3 2 0 "A long string with spaces"
- list $int $real $bool $string $int $real $bool $string
-} {-3 2.0 0 {A long string with spaces} -3 2.0 0 {A long string with spaces}}
-
-test link-2.1 {writing C variables from Tcl} {
- testlink delete
- testlink set 43 1.21 4 -
- testlink create 1 1 1 1
- set int "00721"
- set real -10.5
- set bool true
- set string abcdef
- concat [testlink get] $int $real $bool $string
-} {465 -10.5 1 abcdef 00721 -10.5 true abcdef}
-test link-2.2 {writing bad values into variables} {
- testlink delete
- testlink set 43 1.23 4 -
- testlink create 1 1 1 1
- list [catch {set int 09a} msg] $msg $int
-} {1 {can't set "int": variable must have integer value} 43}
-test link-2.3 {writing bad values into variables} {
- testlink delete
- testlink set 43 1.23 4 -
- testlink create 1 1 1 1
- list [catch {set real 1.x3} msg] $msg $real
-} {1 {can't set "real": variable must have real value} 1.23}
-test link-2.4 {writing bad values into variables} {
- testlink delete
- testlink set 43 1.23 4 -
- testlink create 1 1 1 1
- list [catch {set bool gorp} msg] $msg $bool
-} {1 {can't set "bool": variable must have boolean value} 1}
-
-test link-3.1 {read-only variables} {
- testlink delete
- testlink set 43 1.23 4 -
- testlink create 0 1 1 0
- list [catch {set int 4} msg] $msg $int \
- [catch {set real 10.6} msg] $msg $real \
- [catch {set bool no} msg] $msg $bool \
- [catch {set string "new value"} msg] $msg $string
-} {1 {can't set "int": linked variable is read-only} 43 0 10.6 10.6 0 no no 1 {can't set "string": linked variable is read-only} NULL}
-test link-3.2 {read-only variables} {
- testlink delete
- testlink set 43 1.23 4 -
- testlink create 1 0 0 1
- list [catch {set int 4} msg] $msg $int \
- [catch {set real 10.6} msg] $msg $real \
- [catch {set bool no} msg] $msg $bool \
- [catch {set string "new value"} msg] $msg $string
-} {0 4 4 1 {can't set "real": linked variable is read-only} 1.23 1 {can't set "bool": linked variable is read-only} 1 0 {new value} {new value}}
-
-test link-4.1 {unsetting linked variables} {
- testlink delete
- testlink set -6 -2.5 0 stringValue
- testlink create 1 1 1 1
- unset int real bool string
- list [catch {set int} msg] $msg [catch {set real} msg] $msg \
- [catch {set bool} msg] $msg [catch {set string} msg] $msg
-} {0 -6 0 -2.5 0 0 0 stringValue}
-test link-4.2 {unsetting linked variables} {
- testlink delete
- testlink set -6 -2.1 0 stringValue
- testlink create 1 1 1 1
- unset int real bool string
- set int 102
- set real 16
- set bool true
- set string newValue
- testlink get
-} {102 16.0 1 newValue}
-
-test link-5.1 {unlinking variables} {
- testlink delete
- testlink set -6 -2.25 0 stringValue
- testlink delete
- set int xx1
- set real qrst
- set bool bogus
- set string 12345
- testlink get
-} {-6 -2.25 0 stringValue}
-test link-5.2 {unlinking variables} {
- testlink delete
- testlink set -6 -2.25 0 stringValue
- testlink create 1 1 1 1
- testlink delete
- testlink set 25 14.7 7 -
- list $int $real $bool $string
-} {-6 -2.25 0 stringValue}
-
-test link-6.1 {errors in setting up link} {
- testlink delete
- catch {unset int}
- set int(44) 1
- list [catch {testlink create 1 1 1 1} msg] $msg
-} {1 {can't set "int": variable is array}}
-catch {unset int}
-
-test link-7.1 {access to linked variables via upvar} {
- proc x {} {
- upvar int y
- unset y
- }
- testlink delete
- testlink create 1 0 0 0
- testlink set 14 {} {} {}
- x
- list [catch {set int} msg] $msg
-} {0 14}
-test link-7.2 {access to linked variables via upvar} {
- proc x {} {
- upvar int y
- return [set y]
- }
- testlink delete
- testlink create 1 0 0 0
- testlink set 0 {} {} {}
- set int
- testlink set 23 {} {} {}
- x
- list [x] $int
-} {23 23}
-test link-7.3 {access to linked variables via upvar} {
- proc x {} {
- upvar int y
- set y 44
- }
- testlink delete
- testlink create 0 0 0 0
- testlink set 11 {} {} {}
- list [catch x msg] $msg $int
-} {1 {can't set "y": linked variable is read-only} 11}
-test link-7.4 {access to linked variables via upvar} {
- proc x {} {
- upvar int y
- set y abc
- }
- testlink delete
- testlink create 1 1 1 1
- testlink set -4 {} {} {}
- list [catch x msg] $msg $int
-} {1 {can't set "y": variable must have integer value} -4}
-test link-7.5 {access to linked variables via upvar} {
- proc x {} {
- upvar real y
- set y abc
- }
- testlink delete
- testlink create 1 1 1 1
- testlink set -4 16.75 {} {}
- list [catch x msg] $msg $real
-} {1 {can't set "y": variable must have real value} 16.75}
-test link-7.6 {access to linked variables via upvar} {
- proc x {} {
- upvar bool y
- set y abc
- }
- testlink delete
- testlink create 1 1 1 1
- testlink set -4 16.3 1 {}
- list [catch x msg] $msg $bool
-} {1 {can't set "y": variable must have boolean value} 1}
-
-test link-8.1 {Tcl_UpdateLinkedVar procedure} {
- proc x args {
- global x int real bool string
- lappend x $args $int $real $bool $string
- }
- set x {}
- testlink create 1 1 1 1
- testlink set 14 -2.0 0 xyzzy
- trace var int w x
- testlink update 32 4.0 3 abcd
- trace vdelete int w x
- set x
-} {{int {} w} 32 -2.0 0 xyzzy}
-test link-8.2 {Tcl_UpdateLinkedVar procedure} {
- proc x args {
- global x int real bool string
- lappend x $args $int $real $bool $string
- }
- set x {}
- testlink create 1 1 1 1
- testlink set 14 -2.0 0 xyzzy
- testlink delete
- trace var int w x
- testlink update 32 4.0 6 abcd
- trace vdelete int w x
- set x
-} {}
-test link-8.3 {Tcl_UpdateLinkedVar procedure, read-only variable} {
- testlink create 0 0 0 0
- list [catch {testlink update 47 {} {} {}} msg] $msg $int
-} {0 {} 47}
-
-testlink set 0 0 0 -
-testlink delete
-foreach i {int real bool string} {
- catch {unset $i}
-}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/linsert.test b/tests/linsert.test
deleted file mode 100644
index 5c54d92..0000000
--- a/tests/linsert.test
+++ /dev/null
@@ -1,123 +0,0 @@
-# Commands covered: linsert
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: linsert.test,v 1.3 1999/04/16 00:47:30 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-catch {unset lis}
-catch {rename p ""}
-
-test linsert-1.1 {linsert command} {
- linsert {1 2 3 4 5} 0 a
-} {a 1 2 3 4 5}
-test linsert-1.2 {linsert command} {
- linsert {1 2 3 4 5} 1 a
-} {1 a 2 3 4 5}
-test linsert-1.3 {linsert command} {
- linsert {1 2 3 4 5} 2 a
-} {1 2 a 3 4 5}
-test linsert-1.4 {linsert command} {
- linsert {1 2 3 4 5} 3 a
-} {1 2 3 a 4 5}
-test linsert-1.5 {linsert command} {
- linsert {1 2 3 4 5} 4 a
-} {1 2 3 4 a 5}
-test linsert-1.6 {linsert command} {
- linsert {1 2 3 4 5} 5 a
-} {1 2 3 4 5 a}
-test linsert-1.7 {linsert command} {
- linsert {1 2 3 4 5} 2 one two \{three \$four
-} {1 2 one two \{three {$four} 3 4 5}
-test linsert-1.8 {linsert command} {
- linsert {\{one \$two \{three \ four \ five} 2 a b c
-} {\{one {$two} a b c \{three { four} { five}}
-test linsert-1.9 {linsert command} {
- linsert {{1 2} {3 4} {5 6} {7 8}} 2 {x y} {a b}
-} {{1 2} {3 4} {x y} {a b} {5 6} {7 8}}
-test linsert-1.10 {linsert command} {
- linsert {} 2 a b c
-} {a b c}
-test linsert-1.11 {linsert command} {
- linsert {} 2 {}
-} {{}}
-test linsert-1.12 {linsert command} {
- linsert {a b "c c" d e} 3 1
-} {a b {c c} 1 d e}
-test linsert-1.13 {linsert command} {
- linsert { a b c d} 0 1 2
-} {1 2 a b c d}
-test linsert-1.14 {linsert command} {
- linsert {a b c {d e f}} 4 1 2
-} {a b c {d e f} 1 2}
-test linsert-1.15 {linsert command} {
- linsert {a b c \{\ abc} 4 q r
-} {a b c \{\ q r abc}
-test linsert-1.16 {linsert command} {
- linsert {a b c \{ abc} 4 q r
-} {a b c \{ q r abc}
-test linsert-1.17 {linsert command} {
- linsert {a b c} end q r
-} {a b c q r}
-test linsert-1.18 {linsert command} {
- linsert {a} end q r
-} {a q r}
-test linsert-1.19 {linsert command} {
- linsert {} end q r
-} {q r}
-
-test linsert-2.1 {linsert errors} {
- list [catch linsert msg] $msg
-} {1 {wrong # args: should be "linsert list index element ?element ...?"}}
-test linsert-2.2 {linsert errors} {
- list [catch {linsert a b} msg] $msg
-} {1 {wrong # args: should be "linsert list index element ?element ...?"}}
-test linsert-2.3 {linsert errors} {
- list [catch {linsert a 12x 2} msg] $msg
-} {1 {bad index "12x": must be integer or "end"}}
-test linsert-2.4 {linsert errors} {
- list [catch {linsert \{ 12 2} msg] $msg
-} {1 {unmatched open brace in list}}
-
-test linsert-3.1 {linsert won't modify shared argument objects} {
- proc p {} {
- linsert "a b c" 1 "x y"
- return "a b c"
- }
- p
-} "a b c"
-test linsert-3.2 {linsert won't modify shared argument objects} {
- catch {unset lis}
- set lis [format "a \"%s\" c" "b"]
- linsert $lis 0 [string length $lis]
-} "7 a b c"
-
-# cleanup
-catch {unset lis}
-catch {rename p ""}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/list.test b/tests/list.test
deleted file mode 100644
index fa83038..0000000
--- a/tests/list.test
+++ /dev/null
@@ -1,126 +0,0 @@
-# Commands covered: list
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: list.test,v 1.3 1999/04/16 00:47:30 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# First, a bunch of individual tests
-
-test list-1.1 {basic tests} {list a b c} {a b c}
-test list-1.2 {basic tests} {list {a b} c} {{a b} c}
-test list-1.3 {basic tests} {list \{a b c} {\{a b c}
-test list-1.4 {basic tests} "list a{}} b{} c}" "a\\{\\}\\} b{} c\\}"
-test list-1.5 {basic tests} {list a\[ b\] } "{a\[} b\\]"
-test list-1.6 {basic tests} {list c\ d\t } "{c } {d\t}"
-test list-1.7 {basic tests} {list e\n f\$ } "{e\n} {f\$}"
-test list-1.8 {basic tests} {list g\; h\\} {{g;} h\\}
-test list-1.9 {basic tests} "list a\\\[} b\\\]} " "a\\\[\\\} b\\\]\\\}"
-test list-1.10 {basic tests} "list c\\\} d\\t} " "c\\} d\\t\\}"
-test list-1.11 {basic tests} "list e\\n} f\\$} " "e\\n\\} f\\$\\}"
-test list-1.12 {basic tests} "list g\\;} h\\\\} " "g\\;\\} {h\\}}"
-test list-1.13 {basic tests} {list a {{}} b} {a {{}} b}
-test list-1.14 {basic tests} {list a b xy\\} "a b xy\\\\"
-test list-1.15 {basic tests} "list a b\} e\\" "a b\\} e\\\\"
-test list-1.16 {basic tests} "list a b\}\\\$ e\\\$\\" "a b\\}\\\$ e\\\$\\\\"
-test list-1.17 {basic tests} {list a\f \{\f} "{a\f} \\\{\\f"
-test list-1.18 {basic tests} {list a\r \{\r} "{a\r} \\\{\\r"
-test list-1.19 {basic tests} {list a\v \{\v} "{a\v} \\\{\\v"
-test list-1.20 {basic tests} {list \"\}\{} "\\\"\\}\\{"
-test list-1.21 {basic tests} {list a b c\\\nd} "a b c\\\\\\nd"
-test list-1.22 {basic tests} {list "{ab}\\"} \\{ab\\}\\\\
-test list-1.23 {basic tests} {list \{} "\\{"
-test list-1.24 {basic tests} {list} {}
-
-# For the next round of tests create a list and then pick it apart
-# with "index" to make sure that we get back exactly what went in.
-
-test list-2.1 {placeholder} {
-} {}
-set num 1
-proc lcheck {a b c} {
- global num d
- set d [list $a $b $c]
-; test list-2.$num {what goes in must come out} {lindex $d 0} $a
- set num [expr $num+1]
-; test list-2.$num {what goes in must come out} {lindex $d 1} $b
- set num [expr $num+1]
-; test list-2.$num {what goes in must come out} {lindex $d 2} $c
- set num [expr $num+1]
-}
-lcheck a b c
-lcheck "a b" c\td e\nf
-lcheck {{a b}} {} { }
-lcheck \$ \$ab ab\$
-lcheck \; \;ab ab\;
-lcheck \[ \[ab ab\[
-lcheck \\ \\ab ab\\
-lcheck {"} {"ab} {ab"}
-lcheck {a b} { ab} {ab }
-lcheck a{ a{b \{ab
-lcheck a} a}b }ab
-lcheck a\\} {a \}b} {a \{c}
-lcheck xyz \\ 1\\\n2
-lcheck "{ab}\\" "{ab}xy" abc
-
-concat {}
-
-# Check that tclListObj.c's SetListFromAny handles possible overlarge
-# string rep lengths in the source object.
-
-proc slowsort list {
- set result {}
- set last [expr [llength $list] - 1]
- while {$last > 0} {
- set minIndex [expr [llength $list] - 1]
- set min [lindex $list $last]
- set i [expr $minIndex-1]
- while {$i >= 0} {
- if {[string compare [lindex $list $i] $min] < 0} {
- set minIndex $i
- set min [lindex $list $i]
- }
- set i [expr $i-1]
- }
- set result [concat $result [list $min]]
- if {$minIndex == 0} {
- set list [lrange $list 1 end]
- } else {
- set list [concat [lrange $list 0 [expr $minIndex-1]] \
- [lrange $list [expr $minIndex+1] end]]
- }
- set last [expr $last-1]
- }
- return [concat $result $list]
-}
-test list-3.1 {SetListFromAny and lrange/concat results} {
- slowsort {fred julie alex carol bill annie}
-} {alex annie bill carol fred julie}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/listObj.test b/tests/listObj.test
deleted file mode 100644
index 2c9e58e..0000000
--- a/tests/listObj.test
+++ /dev/null
@@ -1,199 +0,0 @@
-# Functionality covered: operation of the procedures in tclListObj.c that
-# implement the Tcl type manager for the list object type.
-#
-# 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) 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: listObj.test,v 1.3 1999/04/16 00:47:30 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[info commands testobj] == {}} {
- puts "This application hasn't been compiled with the \"testobj\""
- puts "command, so I can't test the Tcl type and object support."
- ::tcltest::cleanupTests
- return
-}
-
-catch {unset x}
-test listobj-1.1 {Tcl_GetListObjType} {
- set t [testobj types]
- set first [string first "list" $t]
- set result [expr {$first != -1}]
-} {1}
-
-test listobj-2.1 {Tcl_SetListObj, use in lappend} {
- catch {unset x}
- list [lappend x 1 abc def] [lappend x 1 ghi jkl] $x
-} {{1 abc def} {1 abc def 1 ghi jkl} {1 abc def 1 ghi jkl}}
-test listobj-2.2 {Tcl_SetListObj, use in ObjInterpProc} {
- proc return_args {args} {
- return $args
- }
- list [return_args] [return_args x] [return_args x y]
-} {{} x {x y}}
-test listobj-2.3 {Tcl_SetListObj, zero element count} {
- list
-} {}
-
-test listobj-3.1 {Tcl_ListObjAppend, list conversion} {
- catch {unset x}
- list [lappend x 1 2 abc "long string"] $x
-} {{1 2 abc {long string}} {1 2 abc {long string}}}
-test listobj-3.2 {Tcl_ListObjAppend, list conversion} {
- set x ""
- list [lappend x first second] [lappend x third fourth] $x
-} {{first second} {first second third fourth} {first second third fourth}}
-test listobj-3.3 {Tcl_ListObjAppend, list conversion} {
- set x "abc def"
- list [lappend x first second] $x
-} {{abc def first second} {abc def first second}}
-test listobj-3.4 {Tcl_ListObjAppend, error in conversion} {
- set x " \{"
- list [catch {lappend x abc def} msg] $msg
-} {1 {unmatched open brace in list}}
-test listobj-3.5 {Tcl_ListObjAppend, force internal rep array to grow} {
- set x ""
- list [lappend x 1 1] [lappend x 2 2] [lappend x 3 3] [lappend x 4 4] \
- [lappend x 5 5] [lappend x 6 6] [lappend x 7 7] [lappend x 8 8] $x
-} {{1 1} {1 1 2 2} {1 1 2 2 3 3} {1 1 2 2 3 3 4 4} {1 1 2 2 3 3 4 4 5 5} {1 1 2 2 3 3 4 4 5 5 6 6} {1 1 2 2 3 3 4 4 5 5 6 6 7 7} {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8} {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}}
-
-test listobj-4.1 {Tcl_ListObjAppendElement, list conversion} {
- catch {unset x}
- list [lappend x 1] $x
-} {1 1}
-test listobj-4.2 {Tcl_ListObjAppendElement, list conversion} {
- set x ""
- list [lappend x first] [lappend x second] $x
-} {first {first second} {first second}}
-test listobj-4.3 {Tcl_ListObjAppendElement, list conversion} {
- set x "abc def"
- list [lappend x first] $x
-} {{abc def first} {abc def first}}
-test listobj-4.4 {Tcl_ListObjAppendElement, error in conversion} {
- set x " \{"
- list [catch {lappend x abc} msg] $msg
-} {1 {unmatched open brace in list}}
-test listobj-4.5 {Tcl_ListObjAppendElement, force internal rep array to grow} {
- set x ""
- list [lappend x 1] [lappend x 2] [lappend x 3] [lappend x 4] \
- [lappend x 5] [lappend x 6] [lappend x 7] [lappend x 8] $x
-} {1 {1 2} {1 2 3} {1 2 3 4} {1 2 3 4 5} {1 2 3 4 5 6} {1 2 3 4 5 6 7} {1 2 3 4 5 6 7 8} {1 2 3 4 5 6 7 8}}
-
-test listobj-5.1 {Tcl_ListObjIndex, basic tests} {
- lindex {a b c} 0
-} a
-test listobj-5.2 {Tcl_ListObjIndex, basic tests} {
- lindex a 0
-} a
-test listobj-5.3 {Tcl_ListObjIndex, basic tests} {
- lindex {a {b c d} x} 1
-} {b c d}
-test listobj-5.4 {Tcl_ListObjIndex, basic tests} {
- lindex {a b c} 3
-} {}
-test listobj-5.5 {Tcl_ListObjIndex, basic tests} {
- lindex {a b c} 100
-} {}
-test listobj-5.6 {Tcl_ListObjIndex, basic tests} {
- lindex a 100
-} {}
-test listobj-5.7 {Tcl_ListObjIndex, basic tests} {
- lindex {} -1
-} {}
-test listobj-5.8 {Tcl_ListObjIndex, error in conversion} {
- set x " \{"
- list [catch {lindex $x 0} msg] $msg
-} {1 {unmatched open brace in list}}
-
-test listobj-6.1 {Tcl_ListObjLength} {
- llength {a b c d}
-} 4
-test listobj-6.2 {Tcl_ListObjLength} {
- llength {a b c {a b {c d}} d}
-} 5
-test listobj-6.3 {Tcl_ListObjLength} {
- llength {}
-} 0
-test listobj-6.4 {Tcl_ListObjLength, convert from non-list} {
- llength 123
-} 1
-test listobj-6.5 {Tcl_ListObjLength, error converting from non-list} {
- list [catch {llength "a b c \{"} msg] $msg
-} {1 {unmatched open brace in list}}
-test listobj-6.6 {Tcl_ListObjLength, error converting from non-list} {
- list [catch {llength "a {b}c"} msg] $msg
-} {1 {list element in braces followed by "c" instead of space}}
-
-test listobj-7.1 {Tcl_ListObjReplace, conversion from non-list} {
- lreplace 123 0 0 x
-} {x}
-test listobj-7.2 {Tcl_ListObjReplace, error converting from non-list} {
- list [catch {lreplace "a b c \{" 1 1 x} msg] $msg
-} {1 {unmatched open brace in list}}
-test listobj-7.3 {Tcl_ListObjReplace, error converting from non-list} {
- list [catch {lreplace "a {b}c" 1 2 x} msg] $msg
-} {1 {list element in braces followed by "c" instead of space}}
-test listobj-7.4 {Tcl_ListObjReplace, negative first element index} {
- lreplace {1 2 3 4 5} -1 1 a
-} {a 3 4 5}
-test listobj-7.5 {Tcl_ListObjReplace, last element index >= num elems} {
- lreplace {1 2 3 4 5} 3 7 a b c
-} {1 2 3 a b c}
-test listobj-7.6 {Tcl_ListObjReplace, first element index > last index} {
- lreplace {1 2 3 4 5} 3 1 a b c
-} {1 2 3 a b c 4 5}
-test listobj-7.7 {Tcl_ListObjReplace, no new elements} {
- lreplace {1 2 3 4 5} 1 1
-} {1 3 4 5}
-test listobj-7.8 {Tcl_ListObjReplace, shrink array in place} {
- lreplace {1 2 3 4 5 6 7} 4 5
-} {1 2 3 4 7}
-test listobj-7.9 {Tcl_ListObjReplace, grow array in place} {
- lreplace {1 2 3 4 5 6 7} 1 3 a b c d e
-} {1 a b c d e 5 6 7}
-test listobj-7.10 {Tcl_ListObjReplace, replace tail of array} {
- lreplace {1 2 3 4 5 6 7} 3 6 a
-} {1 2 3 a}
-test listobj-7.11 {Tcl_ListObjReplace, must grow internal array} {
- lreplace {1 2 3 4 5} 2 3 a b c d e f g h i j k l
-} {1 2 a b c d e f g h i j k l 5}
-test listobj-7.12 {Tcl_ListObjReplace, grow array, insert at start} {
- lreplace {1 2 3 4 5} -1 -1 a b c d e f g h i j k l
-} {a b c d e f g h i j k l 1 2 3 4 5}
-test listobj-7.13 {Tcl_ListObjReplace, grow array, insert at end} {
- lreplace {1 2 3 4 5} 4 1 a b c d e f g h i j k l
-} {1 2 3 4 a b c d e f g h i j k l 5}
-
-test listobj-8.1 {SetListFromAny} {
- lindex {0 foo\x00help 2} 1
-} "foo\x00help"
-
-test listobj-9.1 {UpdateStringOfList} {
- string length [list foo\x00help]
-} 8
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/llength.test b/tests/llength.test
deleted file mode 100644
index 40c0d73..0000000
--- a/tests/llength.test
+++ /dev/null
@@ -1,54 +0,0 @@
-# Commands covered: llength
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: llength.test,v 1.3 1999/04/16 00:47:30 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test llength-1.1 {length of list} {
- llength {a b c d}
-} 4
-test llength-1.2 {length of list} {
- llength {a b c {a b {c d}} d}
-} 5
-test llength-1.3 {length of list} {
- llength {}
-} 0
-
-test llength-2.1 {error conditions} {
- list [catch {llength} msg] $msg
-} {1 {wrong # args: should be "llength list"}}
-test llength-2.2 {error conditions} {
- list [catch {llength 123 2} msg] $msg
-} {1 {wrong # args: should be "llength list"}}
-test llength-2.3 {error conditions} {
- list [catch {llength "a b c \{"} msg] $msg
-} {1 {unmatched open brace in list}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/load.test b/tests/load.test
deleted file mode 100644
index 8bbfb98..0000000
--- a/tests/load.test
+++ /dev/null
@@ -1,194 +0,0 @@
-# Commands covered: load
-#
-# 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) 1995 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: load.test,v 1.4 1999/04/16 00:47:30 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Figure out what extension is used for shared libraries on this
-# platform.
-
-if {$tcl_platform(platform) == "macintosh"} {
- puts "can't run dynamic library tests on macintosh machines"
- ::tcltest::cleanupTests
- return
-}
-
-# Tests require the existence of one of the DLLs in the dltest directory.
-set ext [info sharedlibextension]
-set testDir [file join [file dirname [info nameofexecutable]] dltest]
-set x [file join $testDir pkga$ext]
-set dll "[file tail $x]Required"
-set ::tcltest::testConfig($dll) [file readable $x]
-
-# Tests also require that this DLL has not already been loaded.
-set loaded "[file tail $x]Loaded"
-set alreadyLoaded [info loaded]
-set ::tcltest::testConfig($loaded) \
- [expr {![string match *pkga* $alreadyLoaded]}]
-
-set alreadyTotalLoaded [info loaded]
-
-test load-1.1 {basic errors} [list $dll $loaded] {
- list [catch {load} msg] $msg
-} {1 {wrong # args: should be "load fileName ?packageName? ?interp?"}}
-test load-1.2 {basic errors} [list $dll $loaded] {
- list [catch {load a b c d} msg] $msg
-} {1 {wrong # args: should be "load fileName ?packageName? ?interp?"}}
-test load-1.3 {basic errors} [list $dll $loaded] {
- list [catch {load a b foobar} msg] $msg
-} {1 {could not find interpreter "foobar"}}
-test load-1.4 {basic errors} [list $dll $loaded] {
- list [catch {load {}} msg] $msg
-} {1 {must specify either file name or package name}}
-test load-1.5 {basic errors} [list $dll $loaded] {
- list [catch {load {} {}} msg] $msg
-} {1 {must specify either file name or package name}}
-test load-1.6 {basic errors} [list $dll $loaded] {
- list [catch {load {} Unknown} msg] $msg
-} {1 {package "Unknown" isn't loaded statically}}
-
-test load-2.1 {basic loading, with guess for package name} \
- [list $dll $loaded] {
- load [file join $testDir pkga$ext]
- list [pkga_eq abc def] [info commands pkga_*]
-} {0 {pkga_eq pkga_quote}}
-interp create -safe child
-test load-2.2 {loading into a safe interpreter, with package name conversion} \
- [list $dll $loaded] {
- load [file join $testDir pkgb$ext] pKgB child
- list [child eval pkgb_sub 44 13] [catch {child eval pkgb_unsafe} msg] $msg \
- [catch {pkgb_sub 12 10} msg2] $msg2
-} {31 1 {invalid command name "pkgb_unsafe"} 1 {invalid command name "pkgb_sub"}}
-test load-2.3 {loading with no _Init procedure} [list $dll $loaded] {
- list [catch {load [file join $testDir pkgc$ext] foo} msg] $msg
-} {1 {couldn't find procedure Foo_Init}}
-test load-2.4 {loading with no _SafeInit procedure} [list $dll $loaded] {
- list [catch {load [file join $testDir pkga$ext] {} child} msg] $msg
-} {1 {can't use package in a safe interpreter: no Pkga_SafeInit procedure}}
-
-test load-3.1 {error in _Init procedure, same interpreter} \
- [list $dll $loaded] {
- list [catch {load [file join $testDir pkge$ext] pkge} msg] \
- $msg $errorInfo $errorCode
-} {1 {couldn't open "non_existent": no such file or directory} {couldn't open "non_existent": no such file or directory
- while executing
-"open non_existent"
- invoked from within
-"if 44 {open non_existent}"
- invoked from within
-"load [file join $testDir pkge$ext] pkge"} {POSIX ENOENT {no such file or directory}}}
-test load-3.2 {error in _Init procedure, slave interpreter} \
- [list $dll $loaded] {
- catch {interp delete x}
- interp create x
- set errorCode foo
- set errorInfo bar
- set result [list [catch {load [file join $testDir pkge$ext] pkge x} msg] \
- $msg $errorInfo $errorCode]
- interp delete x
- set result
-} {1 {couldn't open "non_existent": no such file or directory} {couldn't open "non_existent": no such file or directory
- while executing
-"open non_existent"
- invoked from within
-"if 44 {open non_existent}"
- invoked from within
-"load [file join $testDir pkge$ext] pkge x"} {POSIX ENOENT {no such file or directory}}}
-
-test load-4.1 {reloading package into same interpreter} [list $dll $loaded] {
- list [catch {load [file join $testDir pkga$ext] pkga} msg] $msg
-} {0 {}}
-test load-4.2 {reloading package into same interpreter} [list $dll $loaded] {
- list [catch {load [file join $testDir pkga$ext] pkgb} msg] $msg
-} "1 {file \"[file join $testDir pkga$ext\"] is already loaded for package \"Pkga\"}"
-
-test load-5.1 {file name not specified and no static package: pick default} \
- [list $dll $loaded] {
- catch {interp delete x}
- interp create x
- load [file join $testDir pkga$ext] pkga
- load {} pkga x
- set result [info loaded x]
- interp delete x
- set result
-} "{[file join $testDir pkga$ext] Pkga}"
-
-# On some platforms, like SunOS 4.1.3, these tests can't be run because
-# they cause the process to exit.
-
-test load-6.1 {errors loading file} [list $dll $loaded nonPortable] {
- catch {load foo foo}
-} {1}
-
-if {[info command teststaticpkg] != ""} {
- test load-7.1 {Tcl_StaticPackage procedure} [list $dll $loaded] {
- set x "not loaded"
- teststaticpkg Test 1 0
- load {} Test
- load {} Test child
- list [set x] [child eval set x]
- } {loaded loaded}
- test load-7.2 {Tcl_StaticPackage procedure} [list $dll $loaded] {
- set x "not loaded"
- teststaticpkg Another 0 0
- load {} Another
- child eval {set x "not loaded"}
- list [catch {load {} Another child} msg] $msg \
- [child eval set x] [set x]
- } {1 {can't use package in a safe interpreter: no Another_SafeInit procedure} {not loaded} loaded}
- test load-7.3 {Tcl_StaticPackage procedure} [list $dll $loaded] {
- set x "not loaded"
- teststaticpkg More 0 1
- load {} More
- set x
- } {not loaded}
- test load-7.4 {Tcl_StaticPackage procedure, redundant calls} \
- [list $dll $loaded] {
- teststaticpkg Double 0 1
- teststaticpkg Double 0 1
- info loaded
- } "{{} Double} {{} More} {{} Another} {{} Test} {[file join $testDir pkge$ext] Pkge} {[file join $testDir pkgb$ext] Pkgb} {[file join $testDir pkga$ext] Pkga} $alreadyTotalLoaded"
-
- test load-8.1 {TclGetLoadedPackages procedure} [list $dll $loaded] {
- info loaded
- } "{{} Double} {{} More} {{} Another} {{} Test} {[file join $testDir pkge$ext] Pkge} {[file join $testDir pkgb$ext] Pkgb} {[file join $testDir pkga$ext] Pkga} $alreadyTotalLoaded"
- test load-8.2 {TclGetLoadedPackages procedure} [list $dll $loaded] {
- list [catch {info loaded gorp} msg] $msg
- } {1 {could not find interpreter "gorp"}}
- test load-8.3 {TclGetLoadedPackages procedure} [list $dll $loaded] {
- list [info loaded {}] [info loaded child]
- } "{{{} Double} {{} More} {{} Another} {{} Test} {[file join $testDir pkga$ext] Pkga} $alreadyLoaded} {{{} Test} {[file join $testDir pkgb$ext] Pkgb}}"
- test load-8.4 {TclGetLoadedPackages procedure} [list $dll $loaded] {
- load [file join $testDir pkgb$ext] pkgb
- list [info loaded {}] [lsort [info commands pkgb_*]]
- } "{{[file join $testDir pkgb$ext] Pkgb} {{} Double} {{} More} {{} Another} {{} Test} {[file join $testDir pkga$ext] Pkga} $alreadyLoaded} {pkgb_sub pkgb_unsafe}"
- interp delete child
-}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/lrange.test b/tests/lrange.test
deleted file mode 100644
index 4132969..0000000
--- a/tests/lrange.test
+++ /dev/null
@@ -1,102 +0,0 @@
-# Commands covered: lrange
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: lrange.test,v 1.3 1999/04/16 00:47:30 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test lrange-1.1 {range of list elements} {
- lrange {a b c d} 1 2
-} {b c}
-test lrange-1.2 {range of list elements} {
- lrange {a {bcd e {f g {}}} l14 l15 d} 1 1
-} {{bcd e {f g {}}}}
-test lrange-1.3 {range of list elements} {
- lrange {a {bcd e {f g {}}} l14 l15 d} 3 end
-} {l15 d}
-test lrange-1.4 {range of list elements} {
- lrange {a {bcd e {f g {}}} l14 l15 d} 4 10000
-} {d}
-test lrange-1.5 {range of list elements} {
- lrange {a {bcd e {f g {}}} l14 l15 d} 4 3
-} {}
-test lrange-1.6 {range of list elements} {
- lrange {a {bcd e {f g {}}} l14 l15 d} 10 11
-} {}
-test lrange-1.7 {range of list elements} {
- lrange {a b c d e} -1 2
-} {a b c}
-test lrange-1.8 {range of list elements} {
- lrange {a b c d e} -2 -1
-} {}
-test lrange-1.9 {range of list elements} {
- lrange {a b c d e} -2 e
-} {a b c d e}
-test lrange-1.10 {range of list elements} {
- lrange "a b\{c d" 1 2
-} "b\\{c d"
-test lrange-1.11 {range of list elements} {
- lrange "a b c d" end end
-} d
-test lrange-1.12 {range of list elements} {
- lrange "a b c d" end 100000
-} d
-test lrange-1.13 {range of list elements} {
- lrange "a b c d" e 3
-} d
-test lrange-1.14 {range of list elements} {
- lrange "a b c d" end 2
-} {}
-test lrange-1.15 {range of list elements} {
- concat \"[lrange {a b \{\ } 0 2]"
-} {"a b \{\ "}
-test lrange-1.16 {list element quoting} {
- lrange {[append a .b]} 0 end
-} {{[append} a .b\]}
-
-test lrange-2.1 {error conditions} {
- list [catch {lrange a b} msg] $msg
-} {1 {wrong # args: should be "lrange list first last"}}
-test lrange-2.2 {error conditions} {
- list [catch {lrange a b 6 7} msg] $msg
-} {1 {wrong # args: should be "lrange list first last"}}
-test lrange-2.3 {error conditions} {
- list [catch {lrange a b 6} msg] $msg
-} {1 {bad index "b": must be integer or "end"}}
-test lrange-2.4 {error conditions} {
- list [catch {lrange a 0 enigma} msg] $msg
-} {1 {bad index "enigma": must be integer or "end"}}
-test lrange-2.5 {error conditions} {
- list [catch {lrange "a \{b c" 3 4} msg] $msg
-} {1 {unmatched open brace in list}}
-test lrange-2.6 {error conditions} {
- list [catch {lrange "a b c \{ d e" 1 4} msg] $msg
-} {1 {unmatched open brace in list}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/lreplace.test b/tests/lreplace.test
deleted file mode 100644
index d0743eb..0000000
--- a/tests/lreplace.test
+++ /dev/null
@@ -1,149 +0,0 @@
-# Commands covered: lreplace
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: lreplace.test,v 1.3 1999/04/16 00:47:30 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test lreplace-1.1 {lreplace command} {
- lreplace {1 2 3 4 5} 0 0 a
-} {a 2 3 4 5}
-test lreplace-1.2 {lreplace command} {
- lreplace {1 2 3 4 5} 1 1 a
-} {1 a 3 4 5}
-test lreplace-1.3 {lreplace command} {
- lreplace {1 2 3 4 5} 2 2 a
-} {1 2 a 4 5}
-test lreplace-1.4 {lreplace command} {
- lreplace {1 2 3 4 5} 3 3 a
-} {1 2 3 a 5}
-test lreplace-1.5 {lreplace command} {
- lreplace {1 2 3 4 5} 4 4 a
-} {1 2 3 4 a}
-test lreplace-1.6 {lreplace command} {
- lreplace {1 2 3 4 5} 4 5 a
-} {1 2 3 4 a}
-test lreplace-1.7 {lreplace command} {
- lreplace {1 2 3 4 5} -1 -1 a
-} {a 1 2 3 4 5}
-test lreplace-1.8 {lreplace command} {
- lreplace {1 2 3 4 5} 2 end a b c d
-} {1 2 a b c d}
-test lreplace-1.9 {lreplace command} {
- lreplace {1 2 3 4 5} 0 3
-} {5}
-test lreplace-1.10 {lreplace command} {
- lreplace {1 2 3 4 5} 0 4
-} {}
-test lreplace-1.11 {lreplace command} {
- lreplace {1 2 3 4 5} 0 1
-} {3 4 5}
-test lreplace-1.12 {lreplace command} {
- lreplace {1 2 3 4 5} 2 3
-} {1 2 5}
-test lreplace-1.13 {lreplace command} {
- lreplace {1 2 3 4 5} 3 end
-} {1 2 3}
-test lreplace-1.14 {lreplace command} {
- lreplace {1 2 3 4 5} -1 4 a b c
-} {a b c}
-test lreplace-1.15 {lreplace command} {
- lreplace {a b "c c" d e f} 3 3
-} {a b {c c} e f}
-test lreplace-1.16 {lreplace command} {
- lreplace { 1 2 3 4 5} 0 0 a
-} {a 2 3 4 5}
-test lreplace-1.17 {lreplace command} {
- lreplace {1 2 3 4 "5 6"} 4 4 a
-} {1 2 3 4 a}
-test lreplace-1.18 {lreplace command} {
- lreplace {1 2 3 4 {5 6}} 4 4 a
-} {1 2 3 4 a}
-test lreplace-1.19 {lreplace command} {
- lreplace {1 2 3 4} 2 end x y z
-} {1 2 x y z}
-test lreplace-1.20 {lreplace command} {
- lreplace {1 2 3 4} end end a
-} {1 2 3 a}
-test lreplace-1.21 {lreplace command} {
- lreplace {1 2 3 4} end 3 a
-} {1 2 3 a}
-test lreplace-1.22 {lreplace command} {
- lreplace {1 2 3 4} end end
-} {1 2 3}
-test lreplace-1.23 {lreplace command} {
- lreplace {1 2 3 4} 2 -1 xy
-} {1 2 xy 3 4}
-test lreplace-1.24 {lreplace command} {
- lreplace {1 2 3 4} end -1 z
-} {1 2 3 z 4}
-test lreplace-1.25 {lreplace command} {
- concat \"[lreplace {\}\ hello} end end]\"
-} {"\}\ "}
-test lreplace-1.26 {lreplace command} {
- catch {unset foo}
- set foo {a b}
- list [set foo [lreplace $foo end end]] \
- [set foo [lreplace $foo end end]] \
- [set foo [lreplace $foo end end]]
-} {a {} {}}
-
-
-test lreplace-2.1 {lreplace errors} {
- list [catch lreplace msg] $msg
-} {1 {wrong # args: should be "lreplace list first last ?element element ...?"}}
-test lreplace-2.2 {lreplace errors} {
- list [catch {lreplace a b} msg] $msg
-} {1 {wrong # args: should be "lreplace list first last ?element element ...?"}}
-test lreplace-2.3 {lreplace errors} {
- list [catch {lreplace x a 10} msg] $msg
-} {1 {bad index "a": must be integer or "end"}}
-test lreplace-2.4 {lreplace errors} {
- list [catch {lreplace x 10 x} msg] $msg
-} {1 {bad index "x": must be integer or "end"}}
-test lreplace-2.5 {lreplace errors} {
- list [catch {lreplace x 10 1x} msg] $msg
-} {1 {bad index "1x": must be integer or "end"}}
-test lreplace-2.6 {lreplace errors} {
- list [catch {lreplace x 3 2} msg] $msg
-} {1 {list doesn't contain element 3}}
-test lreplace-2.7 {lreplace errors} {
- list [catch {lreplace x 1 1} msg] $msg
-} {1 {list doesn't contain element 1}}
-
-test lreplace-3.1 {lreplace won't modify shared argument objects} {
- proc p {} {
- lreplace "a b c" 1 1 "x y"
- return "a b c"
- }
- p
-} "a b c"
-
-# cleanup
-catch {unset foo}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/lsearch.test b/tests/lsearch.test
deleted file mode 100644
index 498607b..0000000
--- a/tests/lsearch.test
+++ /dev/null
@@ -1,105 +0,0 @@
-# Commands covered: lsearch
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: lsearch.test,v 1.3 1999/04/16 00:47:30 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-set x {abcd bbcd 123 234 345}
-test lsearch-1.1 {lsearch command} {
- lsearch $x 123
-} 2
-test lsearch-1.2 {lsearch command} {
- lsearch $x 3456
-} -1
-test lsearch-1.3 {lsearch command} {
- lsearch $x *5
-} 4
-test lsearch-1.4 {lsearch command} {
- lsearch $x *bc*
-} 0
-
-test lsearch-2.1 {search modes} {
- lsearch -exact {xyz bbcc *bc*} *bc*
-} 2
-test lsearch-2.2 {search modes} {
- lsearch -exact {b.x ^bc xy bcx} ^bc
-} 1
-test lsearch-2.3 {search modes} {
- lsearch -exact {foo bar cat} ba
-} -1
-test lsearch-2.4 {search modes} {
- lsearch -exact {foo bar cat} bart
-} -1
-test lsearch-2.5 {search modes} {
- lsearch -exact {foo bar cat} bar
-} 1
-test lsearch-2.6 {search modes} {
- list [catch {lsearch -regexp {xyz bbcc *bc*} *bc*} msg] $msg
-} {1 {couldn't compile regular expression pattern: quantifier operand invalid}}
-test lsearch-2.7 {search modes} {
- lsearch -regexp {b.x ^bc xy bcx} ^bc
-} 3
-test lsearch-2.8 {search modes} {
- lsearch -glob {xyz bbcc *bc*} *bc*
-} 1
-test lsearch-2.9 {search modes} {
- lsearch -glob {b.x ^bc xy bcx} ^bc
-} 1
-test lsearch-2.10 {search modes} {
- list [catch {lsearch -glib {b.x bx xy bcx} b.x} msg] $msg
-} {1 {bad search mode "-glib": must be -exact, -glob, or -regexp}}
-
-test lsearch-3.1 {lsearch errors} {
- list [catch lsearch msg] $msg
-} {1 {wrong # args: should be "lsearch ?mode? list pattern"}}
-test lsearch-3.2 {lsearch errors} {
- list [catch {lsearch a} msg] $msg
-} {1 {wrong # args: should be "lsearch ?mode? list pattern"}}
-test lsearch-3.3 {lsearch errors} {
- list [catch {lsearch a b c} msg] $msg
-} {1 {bad search mode "a": must be -exact, -glob, or -regexp}}
-test lsearch-3.4 {lsearch errors} {
- list [catch {lsearch a b c d} msg] $msg
-} {1 {wrong # args: should be "lsearch ?mode? list pattern"}}
-test lsearch-3.5 {lsearch errors} {
- list [catch {lsearch "\{" b} msg] $msg
-} {1 {unmatched open brace in list}}
-
-test lsearch-4.1 {binary data} {
- lsearch -exact [list foo one\000two bar] bar
-} 2
-test lsearch-4.2 {binary data} {
- set x one
- append x \x00
- append x two
- lsearch -exact [list foo one\000two bar] $x
-} 1
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/macFCmd.test b/tests/macFCmd.test
deleted file mode 100644
index bbb5df8..0000000
--- a/tests/macFCmd.test
+++ /dev/null
@@ -1,208 +0,0 @@
-# This file tests the tclfCmd.c file.
-#
-# 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) 1997 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: macFCmd.test,v 1.3 1999/04/16 00:47:30 stanton Exp $
-#
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-catch {file delete -force foo.dir}
-file mkdir foo.dir
-if {[catch {file attributes foo.dir -readonly 1}]} {
- set ::tcltest::testConfig(fileSharing) 0
- set ::tcltest::testConfig(notFileSharing) 1
-} else {
- set ::tcltest::testConfig(fileSharing) 1
- set ::tcltest::testConfig(notFileSharing) 0
-}
-file delete -force foo.dir
-
-test macFCmd-1.1 {GetFileFinderAttributes - no file} {macOnly} {
- catch {file delete -force foo.file}
- list [catch {file attributes foo.file -creator} msg] $msg
-} {1 {couldn't get attributes for file ":foo.file": no such file or directory}}
-test macFCmd-1.2 {GetFileFinderAttributes - creator} {macOnly} {
- catch {file delete -force foo.file}
- catch {close [open foo.file w]}
- list [catch {file attributes foo.file -creator} msg] $msg \
- [file delete -force foo.file]
-} {0 {MPW } {}}
-test macFCmd-1.3 {GetFileFinderAttributes - type} {macOnly} {
- catch {file delete -force foo.file}
- catch {close [open foo.file w]}
- list [catch {file attributes foo.file -type} msg] $msg \
- [file delete -force foo.file]
-} {0 TEXT {}}
-test macFCmd-1.4 {GetFileFinderAttributes - not hidden} {macOnly} {
- catch {file delete -force foo.file}
- catch {close [open foo.file w]}
- list [catch {file attributes foo.file -hidden} msg] $msg \
- [file delete -force foo.file]
-} {0 0 {}}
-test macFCmd-1.5 {GetFileFinderAttributes - hidden} {macOnly} {
- catch {file delete -force foo.file}
- catch {close [open foo.file w]}
- file attributes foo.file -hidden 1
- list [catch {file attributes foo.file -hidden} msg] $msg \
- [file delete -force foo.file]
-} {0 1 {}}
-test macFCmd-1.6 {GetFileFinderAttributes - folder creator} {macOnly} {
- catch {file delete -force foo.dir}
- file mkdir foo.dir
- list [catch {file attributes foo.dir -creator} msg] $msg \
- [file delete -force foo.dir]
-} {0 Fldr {}}
-test macFCmd-1.7 {GetFileFinderAttributes - folder type} {macOnly} {
- catch {file delete -force foo.dir}
- file mkdir foo.dir
- list [catch {file attributes foo.dir -type} msg] $msg \
- [file delete -force foo.dir]
-} {0 Fldr {}}
-test macFCmd-1.8 {GetFileFinderAttributes - folder hidden} {macOnly} {
- catch {file delete -force foo.dir}
- file mkdir foo.dir
- list [catch {file attributes foo.dir -hidden} msg] $msg \
- [file delete -force foo.dir]
-} {0 0 {}}
-
-test macFCmd-2.1 {GetFileReadOnly - bad file} {macOnly} {
- catch {file delete -force foo.file}
- list [catch {file attributes foo.file -readonly} msg] $msg
-} {1 {couldn't get attributes for file ":foo.file": no such file or directory}}
-test macFCmd-2.2 {GetFileReadOnly - file not read only} {macOnly} {
- catch {file delete -force foo.file}
- close [open foo.file w]
- list [catch {file attributes foo.file -readonly} msg] $msg \
- [file delete -force foo.file]
-} {0 0 {}}
-test macFCmd-2.3 {GetFileReadOnly - file read only} {macOnly} {
- catch {file delete -force foo.file}
- close [open foo.file w]
- file attributes foo.file -readonly 1
- list [catch {file attributes foo.file -readonly} msg] $msg \
- [file delete -force foo.file]
-} {0 1 {}}
-test macFCmd-2.4 {GetFileReadOnly - directory not read only} {macOnly} {
- catch {file delete -force foo.dir}
- file mkdir foo.dir
- list [catch {file attributes foo.dir -readonly} msg] $msg \
- [file delete -force foo.dir]
-} {0 0 {}}
-test macFCmd-2.5 {GetFileReadOnly - directory read only} {macOnly fileSharing} {
- catch {file delete -force foo.dir}
- file mkdir foo.dir
- file attributes foo.dir -readonly 1
- list [catch {file attributes foo.dir -readonly} msg] $msg \
- [file delete -force foo.dir]
-} {0 1 {}}
-
-test macFCmd-3.1 {SetFileFinderAttributes - bad file} {macOnly} {
- catch {file delete -force foo.file}
- list [catch {file attributes foo.file -creator FOOO} msg] $msg
-} {1 {couldn't set attributes for file ":foo.file": no such file or directory}}
-test macFCmd-3.2 {SetFileFinderAttributes - creator} {macOnly} {
- catch {file delete -force foo.file}
- close [open foo.file w]
- list [catch {file attributes foo.file -creator FOOO} msg] $msg \
- [file attributes foo.file -creator] [file delete -force foo.file]
-} {0 {} FOOO {}}
-test macFCmd-3.3 {SetFileFinderAttributes - bad creator} {macOnly} {
- catch {file delete -force foo.file}
- close [open foo.file w]
- list [catch {file attributes foo.file -creator 0} msg] $msg \
- [file delete -force foo.file]
-} {1 {expected Macintosh OS type but got "0"} {}}
-test macFCmd-3.4 {SetFileFinderAttributes - hidden} {macOnly} {
- catch {file delete -force foo.file}
- close [open foo.file w]
- list [catch {file attributes foo.file -hidden 1} msg] $msg \
- [file attributes foo.file -hidden] [file delete -force foo.file]
-} {0 {} 1 {}}
-test macFCmd-3.5 {SetFileFinderAttributes - type} {macOnly} {
- catch {file delete -force foo.file}
- close [open foo.file w]
- list [catch {file attributes foo.file -type FOOO} msg] $msg \
- [file attributes foo.file -type] [file delete -force foo.file]
-} {0 {} FOOO {}}
-test macFCmd-3.6 {SetFileFinderAttributes - bad type} {macOnly} {
- catch {file delete -force foo.file}
- close [open foo.file w]
- list [catch {file attributes foo.file -type 0} msg] $msg \
- [file delete -force foo.file]
-} {1 {expected Macintosh OS type but got "0"} {}}
-test macFCmd-3.7 {SetFileFinderAttributes - directory} {macOnly} {
- catch {file delete -force foo.dir}
- file mkdir foo.dir
- list [catch {file attributes foo.dir -creator FOOO} msg] \
- $msg [file delete -force foo.dir]
-} {1 {cannot set -creator: ":foo.dir" is a directory} {}}
-
-test macFCmd-4.1 {SetFileReadOnly - bad file} {macOnly} {
- catch {file delete -force foo.file}
- list [catch {file attributes foo.file -readonly 1} msg] $msg
-} {1 {couldn't set attributes for file ":foo.file": no such file or directory}}
-test macFCmd-4.2 {SetFileReadOnly - file not readonly} {macOnly} {
- catch {file delete -force foo.file}
- close [open foo.file w]
- list [catch {file attributes foo.file -readonly 0} msg] \
- $msg [file attributes foo.file -readonly] [file delete -force foo.file]
-} {0 {} 0 {}}
-test macFCmd-4.3 {SetFileReadOnly - file readonly} {macOnly} {
- catch {file delete -force foo.file}
- close [open foo.file w]
- list [catch {file attributes foo.file -readonly 1} msg] \
- $msg [file attributes foo.file -readonly] [file delete -force foo.file]
-} {0 {} 1 {}}
-test macFCmd-4.4 {SetFileReadOnly - directory not readonly} \
- {macOnly fileSharing} {
- catch {file delete -force foo.dir}
- file mkdir foo.dir
- list [catch {file attributes foo.dir -readonly 0} msg] \
- $msg [file attributes foo.dir -readonly] [file delete -force foo.dir]
-} {0 {} 0 {}}
-test macFCmd-4.5 {SetFileReadOnly - directory not readonly} \
- {macOnly notFileSharing} {
- catch {file delete -force foo.dir}
- file mkdir foo.dir
- list [catch {file attributes foo.dir -readonly 0} msg] $msg \
- [file delete -force foo.dir]
-} {1 {cannot set a directory to read-only when File Sharing is turned off} {}}
-test macFCmd-4.6 {SetFileReadOnly - directory readonly} {macOnly fileSharing} {
- catch {file delete -force foo.dir}
- file mkdir foo.dir
- list [catch {file attributes foo.dir -readonly 1} msg] $msg \
- [file attributes foo.dir -readonly] [file delete -force foo.dir]
-} {0 {} 1 {}}
-test macFCmd-4.7 {SetFileReadOnly - directory readonly} {macOnly notFileSharing} {
- catch {file delete -force foo.dir}
- file mkdir foo.dir
- list [catch {file attributes foo.dir -readonly 1} msg] $msg \
- [file delete -force foo.dir]
-} {1 {cannot set a directory to read-only when File Sharing is turned off} {}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/misc.test b/tests/misc.test
deleted file mode 100644
index 67c2216..0000000
--- a/tests/misc.test
+++ /dev/null
@@ -1,75 +0,0 @@
-# Commands covered: various
-#
-# This file contains a collection of miscellaneous Tcl tests that
-# don't fit naturally in any of the other test files. Many of these
-# tests are pathological cases that caused bugs in earlier Tcl
-# releases.
-#
-# Copyright (c) 1992-1993 The Regents of the University of California.
-# Copyright (c) 1994-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: misc.test,v 1.3 1999/04/16 00:47:30 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test misc-1.1 {error in variable ref. in command in array reference} {
- proc tstProc {} {
- global a
-
- set tst $a([winfo name $zz])
- # this is a bogus comment
- # this is a bogus comment
- # this is a bogus comment
- # this is a bogus comment
- # this is a bogus comment
- # this is a bogus comment
- # this is a bogus comment
- # this is a bogus comment
- }
- set msg {}
- list [catch tstProc msg] $msg
-} {1 {can't read "zz": no such variable}}
-test misc-1.2 {error in variable ref. in command in array reference} {
- proc tstProc {} "
- global a
-
- set tst \$a(\[winfo name \$\{zz)
- # this is a bogus comment
- # this is a bogus comment
- # this is a bogus comment
- # this is a bogus comment
- # this is a bogus comment
- # this is a bogus comment
- # this is a bogus comment
- # this is a bogus comment
- "
- set msg {}
- list [catch tstProc msg] $msg $errorInfo
-} {1 {missing close-brace for variable name} {missing close-brace for variable name
- while compiling
-"set tst $a([winfo name "
- (compiling body of proc "tstProc", line 4)
- invoked from within
-"tstProc"}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/msgcat.test b/tests/msgcat.test
deleted file mode 100644
index b9410e2..0000000
--- a/tests/msgcat.test
+++ /dev/null
@@ -1,318 +0,0 @@
-# Commands covered: ::msgcat::mc ::msgcat::mclocale
-# ::msgcat::mcpreferences ::msgcat::mcload
-# ::msgcat::mcset ::msgcat::mcunknown
-#
-# This file contains a collection of tests for the msgcat script library.
-# Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-#
-# Copyright (c) 1998 Mark Harrison.
-# 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: msgcat.test,v 1.2 1999/04/16 00:47:31 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[catch {package require msgcat 1.0}]} {
- if {[info exist msgcat1]} {
- catch {puts "Cannot load msgcat 1.0 package"}
- return
- } else {
- catch {puts "Running msgcat 1.0 tests in slave interp"}
- set interp [interp create msgcat1]
- $interp eval [list set msgcat1 "running"]
- $interp eval [list source [info script]]
- interp delete $interp
- return
- }
-}
-
-set oldlocale [::msgcat::mclocale]
-
-#
-# Test the various permutations of mclocale
-# and mcpreferences.
-#
-
-test msgcat-1.1 {::msgcat::mclocale default} {
- ::msgcat::mclocale
-} {c}
-test msgcat-1.2 {::msgcat::mcpreferences, single element} {
- ::msgcat::mcpreferences
-} {c}
-test msgcat-1.3 {::msgcat::mclocale, single element} {
- ::msgcat::mclocale en
-} {en}
-test msgcat-1.4 {::msgcat::mclocale, single element} {
- ::msgcat::mclocale
-} {en}
-test msgcat-1.5 {::msgcat::mcpreferences, single element} {
- ::msgcat::mcpreferences
-} {en}
-test msgcat-1.6 {::msgcat::mclocale, two elements} {
- ::msgcat::mclocale en_US
-} {en_us}
-test msgcat-1.7 {::msgcat::mclocale, two elements} {
- ::msgcat::mclocale en_US
- ::msgcat::mclocale
-} {en_us}
-test msgcat-1.8 {::msgcat::mcpreferences, two elements} {
- ::msgcat::mcpreferences
-} {en_us en}
-test msgcat-1.9 {::msgcat::mclocale, three elements} {
- ::msgcat::mclocale en_US_funky
-} {en_us_funky}
-test msgcat-1.10 {::msgcat::mclocale, three elements} {
- ::msgcat::mclocale
-} {en_us_funky}
-test msgcat-1.11 {::msgcat::mcpreferences, three elements} {
- ::msgcat::mcpreferences
-} {en_us_funky en_us en}
-
-#
-# Test mcset and mcc, ensuring that namespace partitioning
-# is working.
-#
-
-test msgcat-2.1 {::msgcat::mcset, global scope} {
- ::msgcat::mcset foo_BAR text1 text2
-} {text2}
-test msgcat-2.2 {::msgcat::mcset, global scope, default} {
- ::msgcat::mcset foo_BAR text3
-} {text3}
-test msgcat-2.2 {::msgcat::mcset, namespace overlap} {
- namespace eval bar {::msgcat::mcset foo_BAR con1 con1bar}
- namespace eval baz {::msgcat::mcset foo_BAR con1 con1baz}
-} {con1baz}
-test msgcat-2.3 {::msgcat::mcset, namespace overlap} {
- ::msgcat::mclocale foo_BAR
- namespace eval bar {::msgcat::mc con1}
-} {con1bar}
-test msgcat-2.4 {::msgcat::mcset, namespace overlap} {
- ::msgcat::mclocale foo_BAR
- namespace eval baz {::msgcat::mc con1}
-} {con1baz}
-
-#
-# Test mcset and mc, ensuring that more specific locales
-# (e.g. "en_UK") will search less specific locales
-# (e.g. "en") for translation strings.
-#
-# Do this for the 12 permutations of
-# locales: {foo foo_BAR foo_BAR_baz}
-# strings: {ov1 ov2 ov3 ov4}
-# locale foo defines ov1, ov2, ov3
-# locale foo_BAR defines ov2, ov3
-# locale foo_BAR_BAZ defines ov3
-# (ov4 is defined in none)
-# So,
-# ov3 should be resolved in foo, foo_BAR, foo_BAR_baz
-# ov2 should be resolved in foo, foo_BAR
-# ov2 should resolve to foo_BAR in foo_BAR_baz
-# ov1 should be resolved in foo
-# ov1 should resolve to foo in foo_BAR, foo_BAR_baz
-# ov4 should be resolved in none, and call mcunknown
-#
-
-test msgcat-3.1 {::msgcat::mcset, overlap} {
- ::msgcat::mcset foo ov1 ov1_foo
- ::msgcat::mcset foo ov2 ov2_foo
- ::msgcat::mcset foo ov3 ov3_foo
- ::msgcat::mcset foo_BAR ov2 ov2_foo_BAR
- ::msgcat::mcset foo_BAR ov3 ov3_foo_BAR
- ::msgcat::mcset foo_BAR_baz ov3 ov3_foo_BAR_baz
-} {ov3_foo_BAR_baz}
-# top level, locale foo
-test msgcat-3.2 {::msgcat::mcset, overlap} {
- ::msgcat::mclocale foo
- ::msgcat::mc ov1
-} {ov1_foo}
-test msgcat-3.3 {::msgcat::mcset, overlap} {
- ::msgcat::mclocale foo
- ::msgcat::mc ov2
-} {ov2_foo}
-test msgcat-3.4 {::msgcat::mcset, overlap} {
- ::msgcat::mclocale foo
- ::msgcat::mc ov3
-} {ov3_foo}
-test msgcat-3.5 {::msgcat::mcset, overlap} {
- ::msgcat::mclocale foo
- ::msgcat::mc ov4
-} {ov4}
-# second level, locale foo_BAR
-test msgcat-3.6 {::msgcat::mcset, overlap} {
- ::msgcat::mclocale foo_BAR
- ::msgcat::mc ov1
-} {ov1_foo}
-test msgcat-3.7 {::msgcat::mcset, overlap} {
- ::msgcat::mclocale foo_BAR
- ::msgcat::mc ov2
-} {ov2_foo_BAR}
-test msgcat-3.8 {::msgcat::mcset, overlap} {
- ::msgcat::mclocale foo_BAR
- ::msgcat::mc ov3
-} {ov3_foo_BAR}
-test msgcat-3.9 {::msgcat::mcset, overlap} {
- ::msgcat::mclocale foo_BAR
- ::msgcat::mc ov4
-} {ov4}
-# third level, locale foo_BAR_baz
-test msgcat-3.10 {::msgcat::mcset, overlap} {
- ::msgcat::mclocale foo_BAR_baz
- ::msgcat::mc ov1
-} {ov1_foo}
-test msgcat-3.11 {::msgcat::mcset, overlap} {
- ::msgcat::mclocale foo_BAR_baz
- ::msgcat::mc ov2
-} {ov2_foo_BAR}
-test msgcat-3.12 {::msgcat::mcset, overlap} {
- ::msgcat::mclocale foo_BAR_baz
- ::msgcat::mc ov3
-} {ov3_foo_BAR_baz}
-test msgcat-3.13 {::msgcat::mcset, overlap} {
- ::msgcat::mclocale foo_BAR_baz
- ::msgcat::mc ov4
-} {ov4}
-
-#
-# Test mcunknown, first the default operation
-# and then with an overridden definition.
-#
-
-test msgcat-4.1 {::msgcat::mcunknown, default} {
- ::msgcat::mcset foo unk1 "unknown 1"
-} {unknown 1}
-test msgcat-4.2 {::msgcat::mcunknown, default} {
- ::msgcat::mclocale foo
- ::msgcat::mc unk1
-} {unknown 1}
-test msgcat-4.3 {::msgcat::mcunknown, default} {
- ::msgcat::mclocale foo
- ::msgcat::mc unk2
-} {unk2}
-test msgcat-4.4 {::msgcat::mcunknown, overridden} {
- rename ::msgcat::mcunknown oldproc
- proc ::msgcat::mcunknown {dom s} {
- return "unknown:$dom:$s"
- }
- ::msgcat::mclocale foo
- set result [::msgcat::mc unk1]
- rename ::msgcat::mcunknown {}
- rename oldproc ::msgcat::mcunknown
- set result
-} {unknown 1}
-test msgcat-4.5 {::msgcat::mcunknown, overridden} {
- rename ::msgcat::mcunknown oldproc
- proc ::msgcat::mcunknown {dom s} {
- return "unknown:$dom:$s"
- }
- ::msgcat::mclocale foo
- set result [::msgcat::mc unk2]
- rename ::msgcat::mcunknown {}
- rename oldproc ::msgcat::mcunknown
- set result
-} {unknown:foo:unk2}
-test msgcat-4.6 {::msgcat::mcunknown, uplevel context} {
- rename ::msgcat::mcunknown oldproc
- proc ::msgcat::mcunknown {dom s} {
- return "unknown:$dom:$s:[info level]"
- }
- ::msgcat::mclocale foo
- set result [::msgcat::mc unk2]
- rename ::msgcat::mcunknown {}
- rename oldproc ::msgcat::mcunknown
- set result
-} {unknown:foo:unk2:1}
-
-
-#
-# Test mcload. Need to set up an environment for
-# these tests by creating a temporary directory and
-# message files.
-#
-
-set locales {en en_US en_US_funky}
-
-catch {file mkdir msgdir}
-foreach l $locales {
- set fd [open [string tolower [file join msgdir $l.msg]] w]
- puts $fd "::msgcat::mcset $l abc abc-$l"
- close $fd
-}
-
-test msgcat-5.1 {::msgcat::mcload} {
- ::msgcat::mclocale en
- ::msgcat::mcload msgdir
-} {1}
-test msgcat-5.2 {::msgcat::mcload} {
- ::msgcat::mclocale en_US
- ::msgcat::mcload msgdir
-} {2}
-test msgcat-5.3 {::msgcat::mcload} {
- ::msgcat::mclocale en_US_funky
- ::msgcat::mcload msgdir
-} {3}
-
-# Even though en_US_notexist does not exist,
-# en_US and en should be loaded.
-
-test msgcat-5.4 {::msgcat::mcload} {
- ::msgcat::mclocale en_US_notexist
- ::msgcat::mcload msgdir
-} {2}
-test msgcat-5.5 {::msgcat::mcload} {
- ::msgcat::mclocale no_FI_notexist
- ::msgcat::mcload msgdir
-} {0}
-test msgcat-5.6 {::msgcat::mcload} {
- ::msgcat::mclocale en
- ::msgcat::mc abc
-} {abc-en}
-test msgcat-5.7 {::msgcat::mcload} {
- ::msgcat::mclocale en_US
- ::msgcat::mc abc
-} {abc-en_US}
-test msgcat-5.8 {::msgcat::mcload} {
- ::msgcat::mclocale en_US_funky
- ::msgcat::mc abc
-} {abc-en_US_funky}
-test msgcat-5.9 {::msgcat::mcload} {
- rename ::msgcat::mcunknown oldproc
- proc ::msgcat::mcunknown {dom s} {
- return "unknown:$dom:$s"
- }
- ::msgcat::mclocale no_FI_notexist
- set result [::msgcat::mc abc]
- rename ::msgcat::mcunknown {}
- rename oldproc ::msgcat::mcunknown
- set result
-} {unknown:no_fi_notexist:abc}
-
-# cleanup
-foreach l $locales {
- file delete [string tolower [file join msgdir $l.msg]]
-}
-
-# Clean out the msg catalogs
-::msgcat::mclocale $oldlocale
-file delete msgdir
-
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/namespace-old.test b/tests/namespace-old.test
deleted file mode 100644
index d8a736e..0000000
--- a/tests/namespace-old.test
+++ /dev/null
@@ -1,863 +0,0 @@
-# Functionality covered: this file contains slightly modified versions of
-# the original tests written by Mike McLennan of Lucent Technologies for
-# the procedures in tclNamesp.c that implement Tcl's basic support for
-# namespaces. Other namespace-related tests appear in namespace.test
-# and variable.test.
-#
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 1997 Sun Microsystems, Inc.
-# Copyright (c) 1997 Lucent Technologies
-# 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: namespace-old.test,v 1.3 1999/04/16 00:47:31 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Clear out any namespaces called test_ns_*
-catch {eval namespace delete [namespace children :: test_ns_*]}
-
-test namespace-old-1.1 {usage for "namespace" command} {
- list [catch {namespace} msg] $msg
-} {1 {wrong # args: should be "namespace subcommand ?arg ...?"}}
-
-test namespace-old-1.2 {global namespace's name is "::" or {}} {
- list [namespace current] [namespace eval {} {namespace current}]
-} {:: ::}
-
-test namespace-old-1.3 {usage for "namespace eval"} {
- list [catch {namespace eval} msg] $msg
-} {1 {wrong # args: should be "namespace eval name arg ?arg...?"}}
-
-test namespace-old-1.4 {create new namespaces} {
- list [lsort [namespace children :: test_ns_simple*]] \
- [namespace eval test_ns_simple {}] \
- [namespace eval test_ns_simple2 {}] \
- [lsort [namespace children :: test_ns_simple*]]
-} {{} {} {} {::test_ns_simple ::test_ns_simple2}}
-
-test namespace-old-1.5 {access a new namespace} {
- namespace eval test_ns_simple { namespace current }
-} {::test_ns_simple}
-
-test namespace-old-1.6 {usage for "namespace eval"} {
- list [catch {namespace eval} msg] $msg
-} {1 {wrong # args: should be "namespace eval name arg ?arg...?"}}
-
-test namespace-old-1.7 {usage for "namespace eval"} {
- list [catch {namespace eval test_ns_xyzzy} msg] $msg
-} {1 {wrong # args: should be "namespace eval name arg ?arg...?"}}
-
-test namespace-old-1.8 {command "namespace eval" concatenates args} {
- namespace eval test_ns_simple namespace current
-} {::test_ns_simple}
-
-test namespace-old-1.9 {add elements to a namespace} {
- namespace eval test_ns_simple {
- variable test_ns_x 0
- proc test {test_ns_x} {
- return "test: $test_ns_x"
- }
- }
-} {}
-
-test namespace-old-1.10 {commands in a namespace} {
- namespace eval test_ns_simple { info commands [namespace current]::*}
-} {::test_ns_simple::test}
-
-test namespace-old-1.11 {variables in a namespace} {
- namespace eval test_ns_simple { info vars [namespace current]::* }
-} {::test_ns_simple::test_ns_x}
-
-test namespace-old-1.12 {global vars are separate from locals vars} {
- list [test_ns_simple::test 123] [set test_ns_simple::test_ns_x]
-} {{test: 123} 0}
-
-test namespace-old-1.13 {add to an existing namespace} {
- namespace eval test_ns_simple {
- variable test_ns_y 123
- proc _backdoor {cmd} {
- eval $cmd
- }
- }
-} ""
-
-test namespace-old-1.14 {commands in a namespace} {
- lsort [namespace eval test_ns_simple {info commands [namespace current]::*}]
-} {::test_ns_simple::_backdoor ::test_ns_simple::test}
-
-test namespace-old-1.15 {variables in a namespace} {
- lsort [namespace eval test_ns_simple {info vars [namespace current]::*}]
-} {::test_ns_simple::test_ns_x ::test_ns_simple::test_ns_y}
-test namespace-old-1.16 {variables in a namespace} {
- lsort [info vars test_ns_simple::*]
-} {::test_ns_simple::test_ns_x ::test_ns_simple::test_ns_y}
-
-test namespace-old-1.17 {commands in a namespace are hidden} {
- list [catch "_backdoor {return yes!}" msg] $msg
-} {1 {invalid command name "_backdoor"}}
-test namespace-old-1.18 {using namespace qualifiers} {
- list [catch "test_ns_simple::_backdoor {return yes!}" msg] $msg
-} {0 yes!}
-test namespace-old-1.19 {using absolute namespace qualifiers} {
- list [catch "::test_ns_simple::_backdoor {return yes!}" msg] $msg
-} {0 yes!}
-
-test namespace-old-1.20 {variables in a namespace are hidden} {
- list [catch "set test_ns_x" msg] $msg [catch "set test_ns_y" msg] $msg
-} {1 {can't read "test_ns_x": no such variable} 1 {can't read "test_ns_y": no such variable}}
-test namespace-old-1.21 {using namespace qualifiers} {
- list [catch "set test_ns_simple::test_ns_x" msg] $msg \
- [catch "set test_ns_simple::test_ns_y" msg] $msg
-} {0 0 0 123}
-test namespace-old-1.22 {using absolute namespace qualifiers} {
- list [catch "set ::test_ns_simple::test_ns_x" msg] $msg \
- [catch "set ::test_ns_simple::test_ns_y" msg] $msg
-} {0 0 0 123}
-test namespace-old-1.23 {variables can be accessed within a namespace} {
- test_ns_simple::_backdoor {
- variable test_ns_x
- variable test_ns_y
- return "$test_ns_x $test_ns_y"
- }
-} {0 123}
-
-test namespace-old-1.24 {setting global variables} {
- test_ns_simple::_backdoor {variable test_ns_x; set test_ns_x "new val"}
- namespace eval test_ns_simple {set test_ns_x}
-} {new val}
-
-test namespace-old-1.25 {qualified variables don't need a global declaration} {
- namespace eval test_ns_another { variable test_ns_x 456 }
- set cmd {set ::test_ns_another::test_ns_x}
- list [catch {test_ns_simple::_backdoor "$cmd some-value"} msg] $msg \
- [eval $cmd]
-} {0 some-value some-value}
-
-test namespace-old-1.26 {namespace qualifiers are okay after $'s} {
- namespace eval test_ns_simple { set test_ns_x 12; set test_ns_y 34 }
- set cmd {list $::test_ns_simple::test_ns_x $::test_ns_simple::test_ns_y}
- list [test_ns_simple::_backdoor $cmd] [eval $cmd]
-} {{12 34} {12 34}}
-
-test namespace-old-1.27 {can create commands with null names} {
- proc test_ns_simple:: {args} {return $args}
-} {}
-
-# -----------------------------------------------------------------------
-# TEST: using "info" in namespace contexts
-# -----------------------------------------------------------------------
-test namespace-old-2.1 {querying: info commands} {
- lsort [test_ns_simple::_backdoor {info commands [namespace current]::*}]
-} {::test_ns_simple:: ::test_ns_simple::_backdoor ::test_ns_simple::test}
-
-test namespace-old-2.2 {querying: info procs} {
- lsort [test_ns_simple::_backdoor {info procs}]
-} {{} _backdoor test}
-
-test namespace-old-2.3 {querying: info vars} {
- lsort [info vars test_ns_simple::*]
-} {::test_ns_simple::test_ns_x ::test_ns_simple::test_ns_y}
-
-test namespace-old-2.4 {querying: info vars} {
- lsort [test_ns_simple::_backdoor {info vars [namespace current]::*}]
-} {::test_ns_simple::test_ns_x ::test_ns_simple::test_ns_y}
-
-test namespace-old-2.5 {querying: info locals} {
- lsort [test_ns_simple::_backdoor {info locals}]
-} {cmd}
-
-test namespace-old-2.6 {querying: info exists} {
- test_ns_simple::_backdoor {info exists test_ns_x}
-} {0}
-
-test namespace-old-2.7 {querying: info exists} {
- test_ns_simple::_backdoor {info exists cmd}
-} {1}
-
-test namespace-old-2.8 {querying: info args} {
- info args test_ns_simple::_backdoor
-} {cmd}
-
-test namespace-old-2.9 {querying: info body} {
- string trim [info body test_ns_simple::test]
-} {return "test: $test_ns_x"}
-
-# -----------------------------------------------------------------------
-# TEST: namespace qualifiers, namespace tail
-# -----------------------------------------------------------------------
-test namespace-old-3.1 {usage for "namespace qualifiers"} {
- list [catch "namespace qualifiers" msg] $msg
-} {1 {wrong # args: should be "namespace qualifiers string"}}
-
-test namespace-old-3.2 {querying: namespace qualifiers} {
- list [namespace qualifiers ""] \
- [namespace qualifiers ::] \
- [namespace qualifiers x] \
- [namespace qualifiers ::x] \
- [namespace qualifiers foo::x] \
- [namespace qualifiers ::foo::bar::xyz]
-} {{} {} {} {} foo ::foo::bar}
-
-test namespace-old-3.3 {usage for "namespace tail"} {
- list [catch "namespace tail" msg] $msg
-} {1 {wrong # args: should be "namespace tail string"}}
-
-test namespace-old-3.4 {querying: namespace tail} {
- list [namespace tail ""] \
- [namespace tail ::] \
- [namespace tail x] \
- [namespace tail ::x] \
- [namespace tail foo::x] \
- [namespace tail ::foo::bar::xyz]
-} {{} {} x x x xyz}
-
-# -----------------------------------------------------------------------
-# TEST: delete commands and namespaces
-# -----------------------------------------------------------------------
-test namespace-old-4.1 {define test namespaces} {
- namespace eval test_ns_delete {
- namespace eval ns1 {
- variable var1 1
- proc cmd1 {} {return "cmd1"}
- }
- namespace eval ns2 {
- variable var2 2
- proc cmd2 {} {return "cmd2"}
- }
- namespace eval another {}
- lsort [namespace children]
- }
-} {::test_ns_delete::another ::test_ns_delete::ns1 ::test_ns_delete::ns2}
-
-test namespace-old-4.2 {it's okay to invoke "namespace delete" with no args} {
- list [catch {namespace delete} msg] $msg
-} {0 {}}
-
-test namespace-old-4.3 {command "namespace delete" doesn't support patterns} {
- set cmd {
- namespace eval test_ns_delete {namespace delete ns*}
- }
- list [catch $cmd msg] $msg
-} {1 {unknown namespace "ns*" in namespace delete command}}
-
-test namespace-old-4.4 {command "namespace delete" handles multiple args} {
- set cmd {
- namespace eval test_ns_delete {
- eval namespace delete \
- [namespace children [namespace current] ns?]
- }
- }
- list [catch $cmd msg] $msg [namespace children test_ns_delete]
-} {0 {} ::test_ns_delete::another}
-
-# -----------------------------------------------------------------------
-# TEST: namespace hierarchy
-# -----------------------------------------------------------------------
-test namespace-old-5.1 {define nested namespaces} {
- set test_ns_var_global "var in ::"
- proc test_ns_cmd_global {} {return "cmd in ::"}
-
- namespace eval test_ns_hier1 {
- set test_ns_var_hier1 "particular to hier1"
- proc test_ns_cmd_hier1 {} {return "particular to hier1"}
-
- set test_ns_level 1
- proc test_ns_show {} {return "[namespace current]: 1"}
-
- namespace eval test_ns_hier2 {
- set test_ns_var_hier2 "particular to hier2"
- proc test_ns_cmd_hier2 {} {return "particular to hier2"}
-
- set test_ns_level 2
- proc test_ns_show {} {return "[namespace current]: 2"}
-
- namespace eval test_ns_hier3a {}
- namespace eval test_ns_hier3b {}
- }
-
- namespace eval test_ns_hier2a {}
- namespace eval test_ns_hier2b {}
- }
-} {}
-
-test namespace-old-5.2 {namespaces can be nested} {
- list [namespace eval test_ns_hier1 {namespace current}] \
- [namespace eval test_ns_hier1 {
- namespace eval test_ns_hier2 {namespace current}
- }]
-} {::test_ns_hier1 ::test_ns_hier1::test_ns_hier2}
-
-test namespace-old-5.3 {namespace qualifiers work in namespace command} {
- list [namespace eval ::test_ns_hier1 {namespace current}] \
- [namespace eval test_ns_hier1::test_ns_hier2 {namespace current}] \
- [namespace eval ::test_ns_hier1::test_ns_hier2 {namespace current}]
-} {::test_ns_hier1 ::test_ns_hier1::test_ns_hier2 ::test_ns_hier1::test_ns_hier2}
-
-test namespace-old-5.4 {nested namespaces can access global namespace} {
- list [namespace eval test_ns_hier1 {set test_ns_var_global}] \
- [namespace eval test_ns_hier1 {test_ns_cmd_global}] \
- [namespace eval test_ns_hier1::test_ns_hier2 {set test_ns_var_global}] \
- [namespace eval test_ns_hier1::test_ns_hier2 {test_ns_cmd_global}]
-} {{var in ::} {cmd in ::} {var in ::} {cmd in ::}}
-
-test namespace-old-5.5 {variables in different namespaces don't conflict} {
- list [set test_ns_hier1::test_ns_level] \
- [set test_ns_hier1::test_ns_hier2::test_ns_level]
-} {1 2}
-
-test namespace-old-5.6 {commands in different namespaces don't conflict} {
- list [test_ns_hier1::test_ns_show] \
- [test_ns_hier1::test_ns_hier2::test_ns_show]
-} {{::test_ns_hier1: 1} {::test_ns_hier1::test_ns_hier2: 2}}
-
-test namespace-old-5.7 {nested namespaces don't see variables in parent} {
- set cmd {
- namespace eval test_ns_hier1::test_ns_hier2 {set test_ns_var_hier1}
- }
- list [catch $cmd msg] $msg
-} {1 {can't read "test_ns_var_hier1": no such variable}}
-
-test namespace-old-5.8 {nested namespaces don't see commands in parent} {
- set cmd {
- namespace eval test_ns_hier1::test_ns_hier2 {test_ns_cmd_hier1}
- }
- list [catch $cmd msg] $msg
-} {1 {invalid command name "test_ns_cmd_hier1"}}
-
-test namespace-old-5.9 {usage for "namespace children"} {
- list [catch {namespace children test_ns_hier1 y z} msg] $msg
-} {1 {wrong # args: should be "namespace children ?name? ?pattern?"}}
-
-test namespace-old-5.10 {command "namespace children" must get valid namespace} {
- list [catch {namespace children xyzzy} msg] $msg
-} {1 {unknown namespace "xyzzy" in namespace children command}}
-
-test namespace-old-5.11 {querying namespace children} {
- lsort [namespace children :: test_ns_hier*]
-} {::test_ns_hier1}
-
-test namespace-old-5.12 {querying namespace children} {
- lsort [namespace children test_ns_hier1]
-} {::test_ns_hier1::test_ns_hier2 ::test_ns_hier1::test_ns_hier2a ::test_ns_hier1::test_ns_hier2b}
-
-test namespace-old-5.13 {querying namespace children} {
- lsort [namespace eval test_ns_hier1 {namespace children}]
-} {::test_ns_hier1::test_ns_hier2 ::test_ns_hier1::test_ns_hier2a ::test_ns_hier1::test_ns_hier2b}
-
-test namespace-old-5.14 {querying namespace children} {
- lsort [namespace children test_ns_hier1::test_ns_hier2]
-} {::test_ns_hier1::test_ns_hier2::test_ns_hier3a ::test_ns_hier1::test_ns_hier2::test_ns_hier3b}
-
-test namespace-old-5.15 {querying namespace children} {
- lsort [namespace eval test_ns_hier1::test_ns_hier2 {namespace children}]
-} {::test_ns_hier1::test_ns_hier2::test_ns_hier3a ::test_ns_hier1::test_ns_hier2::test_ns_hier3b}
-
-test namespace-old-5.16 {querying namespace children with patterns} {
- lsort [namespace children test_ns_hier1::test_ns_hier2 test_ns_*]
-} {::test_ns_hier1::test_ns_hier2::test_ns_hier3a ::test_ns_hier1::test_ns_hier2::test_ns_hier3b}
-
-test namespace-old-5.17 {querying namespace children with patterns} {
- lsort [namespace children test_ns_hier1::test_ns_hier2 *b]
-} {::test_ns_hier1::test_ns_hier2::test_ns_hier3b}
-
-test namespace-old-5.18 {usage for "namespace parent"} {
- list [catch {namespace parent x y} msg] $msg
-} {1 {wrong # args: should be "namespace parent ?name?"}}
-
-test namespace-old-5.19 {command "namespace parent" must get valid namespace} {
- list [catch {namespace parent xyzzy} msg] $msg
-} {1 {unknown namespace "xyzzy" in namespace parent command}}
-
-test namespace-old-5.20 {querying namespace parent} {
- list [namespace eval :: {namespace parent}] \
- [namespace eval test_ns_hier1 {namespace parent}] \
- [namespace eval test_ns_hier1::test_ns_hier2 {namespace parent}] \
- [namespace eval test_ns_hier1::test_ns_hier2::test_ns_hier3a {namespace parent}] \
-} {{} :: ::test_ns_hier1 ::test_ns_hier1::test_ns_hier2}
-
-test namespace-old-5.21 {querying namespace parent for explicit namespace} {
- list [namespace parent ::] \
- [namespace parent test_ns_hier1] \
- [namespace parent test_ns_hier1::test_ns_hier2] \
- [namespace parent test_ns_hier1::test_ns_hier2::test_ns_hier3a]
-} {{} :: ::test_ns_hier1 ::test_ns_hier1::test_ns_hier2}
-
-# -----------------------------------------------------------------------
-# TEST: name resolution and caching
-# -----------------------------------------------------------------------
-test namespace-old-6.1 {relative ns names only looked up in current ns} {
- namespace eval test_ns_cache1 {}
- namespace eval test_ns_cache2 {}
- namespace eval test_ns_cache2::test_ns_cache3 {}
- set trigger {
- namespace eval test_ns_cache2 {namespace current}
- }
- set trigger2 {
- namespace eval test_ns_cache2::test_ns_cache3 {namespace current}
- }
- list [namespace eval test_ns_cache1 $trigger] \
- [namespace eval test_ns_cache1 $trigger2]
-} {::test_ns_cache1::test_ns_cache2 ::test_ns_cache1::test_ns_cache2::test_ns_cache3}
-
-test namespace-old-6.2 {relative ns names only looked up in current ns} {
- namespace eval test_ns_cache1::test_ns_cache2 {}
- list [namespace eval test_ns_cache1 $trigger] \
- [namespace eval test_ns_cache1 $trigger2]
-} {::test_ns_cache1::test_ns_cache2 ::test_ns_cache1::test_ns_cache2::test_ns_cache3}
-
-test namespace-old-6.3 {relative ns names only looked up in current ns} {
- namespace eval test_ns_cache1::test_ns_cache2::test_ns_cache3 {}
- list [namespace eval test_ns_cache1 $trigger] \
- [namespace eval test_ns_cache1 $trigger2]
-} {::test_ns_cache1::test_ns_cache2 ::test_ns_cache1::test_ns_cache2::test_ns_cache3}
-
-test namespace-old-6.4 {relative ns names only looked up in current ns} {
- namespace delete test_ns_cache1::test_ns_cache2
- list [namespace eval test_ns_cache1 $trigger] \
- [namespace eval test_ns_cache1 $trigger2]
-} {::test_ns_cache1::test_ns_cache2 ::test_ns_cache1::test_ns_cache2::test_ns_cache3}
-
-test namespace-old-6.5 {define test commands} {
- proc test_ns_cache_cmd {} {
- return "global version"
- }
- namespace eval test_ns_cache1 {
- proc trigger {} {
- test_ns_cache_cmd
- }
- }
- test_ns_cache1::trigger
-} {global version}
-
-test namespace-old-6.6 {one-level check for command shadowing} {
- proc test_ns_cache1::test_ns_cache_cmd {} {
- return "cache1 version"
- }
- test_ns_cache1::trigger
-} {cache1 version}
-
-test namespace-old-6.7 {renaming commands changes command epoch} {
- namespace eval test_ns_cache1 {
- rename test_ns_cache_cmd test_ns_new
- }
- test_ns_cache1::trigger
-} {global version}
-
-test namespace-old-6.8 {renaming back handles shadowing} {
- namespace eval test_ns_cache1 {
- rename test_ns_new test_ns_cache_cmd
- }
- test_ns_cache1::trigger
-} {cache1 version}
-
-test namespace-old-6.9 {deleting commands changes command epoch} {
- namespace eval test_ns_cache1 {
- rename test_ns_cache_cmd ""
- }
- test_ns_cache1::trigger
-} {global version}
-
-test namespace-old-6.10 {define test namespaces} {
- namespace eval test_ns_cache2 {
- proc test_ns_cache_cmd {} {
- return "global cache2 version"
- }
- }
- namespace eval test_ns_cache1 {
- proc trigger {} {
- test_ns_cache2::test_ns_cache_cmd
- }
- }
- namespace eval test_ns_cache1::test_ns_cache2 {
- proc trigger {} {
- test_ns_cache_cmd
- }
- }
- list [test_ns_cache1::trigger] [test_ns_cache1::test_ns_cache2::trigger]
-} {{global cache2 version} {global version}}
-
-test namespace-old-6.11 {commands affect all parent namespaces} {
- proc test_ns_cache1::test_ns_cache2::test_ns_cache_cmd {} {
- return "cache2 version"
- }
- list [test_ns_cache1::trigger] [test_ns_cache1::test_ns_cache2::trigger]
-} {{cache2 version} {cache2 version}}
-
-test namespace-old-6.12 {define test variables} {
- variable test_ns_cache_var "global version"
- set trigger {set test_ns_cache_var}
- namespace eval test_ns_cache1 $trigger
-} {global version}
-
-test namespace-old-6.13 {one-level check for variable shadowing} {
- namespace eval test_ns_cache1 {
- variable test_ns_cache_var "cache1 version"
- }
- namespace eval test_ns_cache1 $trigger
-} {cache1 version}
-
-test namespace-old-6.14 {deleting variables changes variable epoch} {
- namespace eval test_ns_cache1 {
- unset test_ns_cache_var
- }
- namespace eval test_ns_cache1 $trigger
-} {global version}
-
-test namespace-old-6.15 {define test namespaces} {
- namespace eval test_ns_cache2 {
- variable test_ns_cache_var "global cache2 version"
- }
- set trigger2 {set test_ns_cache2::test_ns_cache_var}
- list [namespace eval test_ns_cache1 $trigger2] \
- [namespace eval test_ns_cache1::test_ns_cache2 $trigger]
-} {{global cache2 version} {global version}}
-
-test namespace-old-6.16 {public variables affect all parent namespaces} {
- variable test_ns_cache1::test_ns_cache2::test_ns_cache_var "cache2 version"
- list [namespace eval test_ns_cache1 $trigger2] \
- [namespace eval test_ns_cache1::test_ns_cache2 $trigger]
-} {{cache2 version} {cache2 version}}
-
-test namespace-old-6.17 {usage for "namespace which"} {
- list [catch "namespace which -baz" msg] $msg
-} {1 {wrong # args: should be "namespace which ?-command? ?-variable? name"}}
-test namespace-old-6.18 {usage for "namespace which"} {
- list [catch "namespace which -command" msg] $msg
-} {1 {wrong # args: should be "namespace which ?-command? ?-variable? name"}}
-
-test namespace-old-6.19 {querying: namespace which -command} {
- proc test_ns_cache1::test_ns_cache_cmd {} {
- return "cache1 version"
- }
- list [namespace eval :: {namespace which test_ns_cache_cmd}] \
- [namespace eval test_ns_cache1 {namespace which test_ns_cache_cmd}] \
- [namespace eval :: {namespace which -command test_ns_cache_cmd}] \
- [namespace eval test_ns_cache1 {namespace which -command test_ns_cache_cmd}]
-} {::test_ns_cache_cmd ::test_ns_cache1::test_ns_cache_cmd ::test_ns_cache_cmd ::test_ns_cache1::test_ns_cache_cmd}
-
-test namespace-old-6.20 {command "namespace which" may not find commands} {
- namespace eval test_ns_cache1 {namespace which -command xyzzy}
-} {}
-
-test namespace-old-6.21 {querying: namespace which -variable} {
- namespace eval test_ns_cache1::test_ns_cache2 {
- namespace which -variable test_ns_cache_var
- }
-} {::test_ns_cache1::test_ns_cache2::test_ns_cache_var}
-
-test namespace-old-6.22 {command "namespace which" may not find variables} {
- namespace eval test_ns_cache1 {namespace which -variable xyzzy}
-} {}
-
-# -----------------------------------------------------------------------
-# TEST: uplevel/upvar across namespace boundaries
-# -----------------------------------------------------------------------
-test namespace-old-7.1 {define test namespace} {
- namespace eval test_ns_uplevel {
- variable x 0
- variable y 1
-
- proc show_vars {num} {
- return [uplevel $num {info vars}]
- }
- proc test_uplevel {num} {
- set a 0
- set b 1
- namespace eval ::test_ns_uplevel " return \[show_vars $num\] "
- }
- }
-} {}
-test namespace-old-7.2 {uplevel can access namespace call frame} {
- list [expr {[lsearch -exact [test_ns_uplevel::test_uplevel 1] x]>=0}] \
- [expr {[lsearch -exact [test_ns_uplevel::test_uplevel 1] y]>=0}]
-} {1 1}
-test namespace-old-7.3 {uplevel can go beyond namespace call frame} {
- lsort [test_ns_uplevel::test_uplevel 2]
-} {a b num}
-test namespace-old-7.4 {uplevel can go up to global context} {
- expr {[test_ns_uplevel::test_uplevel 3] == [info globals]}
-} {1}
-
-test namespace-old-7.5 {absolute call frame references work too} {
- list [expr {[lsearch -exact [test_ns_uplevel::test_uplevel #2] x]>=0}] \
- [expr {[lsearch -exact [test_ns_uplevel::test_uplevel #2] y]>=0}]
-} {1 1}
-test namespace-old-7.6 {absolute call frame references work too} {
- lsort [test_ns_uplevel::test_uplevel #1]
-} {a b num}
-test namespace-old-7.7 {absolute call frame references work too} {
- expr {[test_ns_uplevel::test_uplevel #0] == [info globals]}
-} {1}
-
-test namespace-old-7.8 {namespaces are included in the call stack} {
- namespace eval test_ns_upvar {
- variable scope "test_ns_upvar"
-
- proc show_val {var num} {
- upvar $num $var x
- return $x
- }
- proc test_upvar {num} {
- set scope "test_ns_upvar::test_upvar"
- namespace eval ::test_ns_upvar " return \[show_val scope $num\] "
- }
- }
-} {}
-test namespace-old-7.9 {upvar can access namespace call frame} {
- test_ns_upvar::test_upvar 1
-} {test_ns_upvar}
-test namespace-old-7.10 {upvar can go beyond namespace call frame} {
- test_ns_upvar::test_upvar 2
-} {test_ns_upvar::test_upvar}
-test namespace-old-7.11 {absolute call frame references work too} {
- test_ns_upvar::test_upvar #2
-} {test_ns_upvar}
-test namespace-old-7.12 {absolute call frame references work too} {
- test_ns_upvar::test_upvar #1
-} {test_ns_upvar::test_upvar}
-
-# -----------------------------------------------------------------------
-# TEST: variable traces across namespace boundaries
-# -----------------------------------------------------------------------
-test namespace-old-8.1 {traces work across namespace boundaries} {
- namespace eval test_ns_trace {
- namespace eval foo {
- variable x ""
- }
-
- variable status ""
- proc monitor {name1 name2 op} {
- variable status
- lappend status "$op: $name1"
- }
- trace variable foo::x rwu [namespace code monitor]
- }
- set test_ns_trace::foo::x "yes!"
- set test_ns_trace::foo::x
- unset test_ns_trace::foo::x
-
- namespace eval test_ns_trace { set status }
-} {{w: test_ns_trace::foo::x} {r: test_ns_trace::foo::x} {u: test_ns_trace::foo::x}}
-
-# -----------------------------------------------------------------------
-# TEST: imported commands
-# -----------------------------------------------------------------------
-test namespace-old-9.1 {empty "namespace export" list} {
- list [catch "namespace export" msg] $msg
-} {0 {}}
-test namespace-old-9.2 {usage for "namespace export" command} {
- list [catch "namespace export test_ns_trace::zzz" msg] $msg
-} {1 {invalid export pattern "test_ns_trace::zzz": pattern can't specify a namespace}}
-
-test namespace-old-9.3 {define test namespaces for import} {
- namespace eval test_ns_export {
- namespace export cmd1 cmd2 cmd3
- proc cmd1 {args} {return "cmd1: $args"}
- proc cmd2 {args} {return "cmd2: $args"}
- proc cmd3 {args} {return "cmd3: $args"}
- proc cmd4 {args} {return "cmd4: $args"}
- proc cmd5 {args} {return "cmd5: $args"}
- proc cmd6 {args} {return "cmd6: $args"}
- }
- lsort [info commands test_ns_export::*]
-} {::test_ns_export::cmd1 ::test_ns_export::cmd2 ::test_ns_export::cmd3 ::test_ns_export::cmd4 ::test_ns_export::cmd5 ::test_ns_export::cmd6}
-
-test namespace-old-9.4 {check export status} {
- set x ""
- namespace eval test_ns_import {
- namespace export cmd1 cmd2
- namespace import ::test_ns_export::*
- }
- foreach cmd [lsort [info commands test_ns_import::*]] {
- lappend x $cmd
- }
- set x
-} {::test_ns_import::cmd1 ::test_ns_import::cmd2 ::test_ns_import::cmd3}
-
-test namespace-old-9.5 {empty import list in "namespace import" command} {
- namespace import
-} {}
-
-test namespace-old-9.6 {empty import list for "namespace import" command} {
- namespace import
-} {}
-
-test namespace-old-9.7 {empty forget list for "namespace forget" command} {
- namespace forget
-} {}
-
-catch {rename cmd1 {}}
-catch {rename cmd2 {}}
-catch {rename ncmd {}}
-catch {rename ncmd1 {}}
-catch {rename ncmd2 {}}
-test namespace-old-9.8 {only exported commands are imported} {
- namespace import test_ns_import::cmd*
- set x [lsort [info commands cmd*]]
-} {cmd1 cmd2}
-
-test namespace-old-9.9 {imported commands work just the same as original} {
- list [cmd1 test 1 2 3] [test_ns_import::cmd1 test 4 5 6]
-} {{cmd1: test 1 2 3} {cmd1: test 4 5 6}}
-
-test namespace-old-9.10 {commands can be imported from many namespaces} {
- namespace eval test_ns_import2 {
- namespace export ncmd ncmd1 ncmd2
- proc ncmd {args} {return "ncmd: $args"}
- proc ncmd1 {args} {return "ncmd1: $args"}
- proc ncmd2 {args} {return "ncmd2: $args"}
- proc ncmd3 {args} {return "ncmd3: $args"}
- }
- namespace import test_ns_import2::*
- lsort [concat [info commands cmd*] [info commands ncmd*]]
-} {cmd1 cmd2 ncmd ncmd1 ncmd2}
-
-test namespace-old-9.11 {imported commands can be removed by deleting them} {
- rename cmd1 ""
- lsort [concat [info commands cmd*] [info commands ncmd*]]
-} {cmd2 ncmd ncmd1 ncmd2}
-
-test namespace-old-9.12 {command "namespace forget" checks for valid namespaces} {
- list [catch {namespace forget xyzzy::*} msg] $msg
-} {1 {unknown namespace in namespace forget pattern "xyzzy::*"}}
-
-test namespace-old-9.13 {command "namespace forget" ignores patterns that don't match} {
- list [catch {namespace forget test_ns_import::xy*zzy} msg] $msg \
- [lsort [info commands cmd?]]
-} {0 {} cmd2}
-
-test namespace-old-9.14 {imported commands can be removed} {
- namespace forget test_ns_import::cmd?
- list [lsort [info commands cmd?]] \
- [catch {cmd1 another test} msg] $msg
-} {{} 1 {invalid command name "cmd1"}}
-
-test namespace-old-9.15 {existing commands can't be overwritten} {
- proc cmd1 {x y} {
- return [expr $x+$y]
- }
- list [catch {namespace import test_ns_import::cmd?} msg] $msg \
- [cmd1 3 5]
-} {1 {can't import command "cmd1": already exists} 8}
-
-test namespace-old-9.16 {use "-force" option to override existing commands} {
- list [cmd1 3 5] \
- [namespace import -force test_ns_import::cmd?] \
- [cmd1 3 5]
-} {8 {} {cmd1: 3 5}}
-
-test namespace-old-9.17 {commands can be imported into many namespaces} {
- namespace eval test_ns_import_use {
- namespace import ::test_ns_import::* ::test_ns_import2::ncmd?
- lsort [concat [info commands ::test_ns_import_use::cmd*] \
- [info commands ::test_ns_import_use::ncmd*]]
- }
-} {::test_ns_import_use::cmd1 ::test_ns_import_use::cmd2 ::test_ns_import_use::ncmd1 ::test_ns_import_use::ncmd2}
-
-test namespace-old-9.18 {when command is deleted, imported commands go away} {
- namespace eval test_ns_import { rename cmd1 "" }
- list [info commands cmd1] \
- [namespace eval test_ns_import_use {info commands cmd1}]
-} {{} {}}
-
-test namespace-old-9.19 {when namesp is deleted, all imported commands go away} {
- namespace delete test_ns_import test_ns_import2
- list [info commands cmd*] \
- [info commands ncmd*] \
- [namespace eval test_ns_import_use {info commands cmd*}] \
- [namespace eval test_ns_import_use {info commands ncmd*}] \
-} {{} {} {} {}}
-
-# -----------------------------------------------------------------------
-# TEST: scoped values
-# -----------------------------------------------------------------------
-test namespace-old-10.1 {define namespace for scope test} {
- namespace eval test_ns_inscope {
- variable x "x-value"
- proc show {args} {
- return "show: $args"
- }
- proc do {args} {
- return [eval $args]
- }
- list [set x] [show test]
- }
-} {x-value {show: test}}
-
-test namespace-old-10.2 {command "namespace code" requires one argument} {
- list [catch {namespace code} msg] $msg
-} {1 {wrong # args: should be "namespace code arg"}}
-
-test namespace-old-10.3 {command "namespace code" requires one argument} {
- list [catch {namespace code first "second arg" third} msg] $msg
-} {1 {wrong # args: should be "namespace code arg"}}
-
-test namespace-old-10.4 {command "namespace code" gets current namesp context} {
- namespace eval test_ns_inscope {
- namespace code {"1 2 3" "4 5" 6}
- }
-} {namespace inscope ::test_ns_inscope {"1 2 3" "4 5" 6}}
-
-test namespace-old-10.5 {with one arg, first "scope" sticks} {
- set sval [namespace eval test_ns_inscope {namespace code {one two}}]
- namespace code $sval
-} {namespace inscope ::test_ns_inscope {one two}}
-
-test namespace-old-10.6 {with many args, each "scope" adds new args} {
- set sval [namespace eval test_ns_inscope {namespace code {one two}}]
- namespace code "$sval three"
-} {namespace inscope ::test_ns_inscope {one two} three}
-
-test namespace-old-10.7 {scoped commands work with eval} {
- set cref [namespace eval test_ns_inscope {namespace code show}]
- list [eval $cref "a" "b c" "d e f"]
-} {{show: a b c d e f}}
-
-test namespace-old-10.8 {scoped commands execute in namespace context} {
- set cref [namespace eval test_ns_inscope {
- namespace code {set x "some new value"}
- }]
- list [set test_ns_inscope::x] [eval $cref] [set test_ns_inscope::x]
-} {x-value {some new value} {some new value}}
-
-foreach cmd [info commands test_ns_*] {
- rename $cmd ""
-}
-catch {rename cmd {}}
-catch {rename cmd1 {}}
-catch {rename cmd2 {}}
-catch {rename ncmd {}}
-catch {rename ncmd1 {}}
-catch {rename ncmd2 {}}
-catch {unset cref}
-catch {unset trigger}
-catch {unset trigger2}
-catch {unset sval}
-catch {unset msg}
-catch {unset x}
-catch {unset test_ns_var_global}
-catch {unset cmd}
-eval namespace delete [namespace children :: test_ns_*]
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/namespace.test b/tests/namespace.test
deleted file mode 100644
index 54f1149..0000000
--- a/tests/namespace.test
+++ /dev/null
@@ -1,1115 +0,0 @@
-# Functionality covered: this file contains a collection of tests for the
-# procedures in tclNamesp.c that implement Tcl's basic support for
-# namespaces. Other namespace-related tests appear in variable.test.
-#
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 1997 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: namespace.test,v 1.4 1999/04/16 00:47:31 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Clear out any namespaces called test_ns_*
-catch {eval namespace delete [namespace children :: test_ns_*]}
-
-test namespace-1.1 {TclInitNamespaces, GetNamespaceFromObj, NamespaceChildrenCmd} {
- namespace children :: test_ns_*
-} {}
-
-catch {unset l}
-test namespace-2.1 {Tcl_GetCurrentNamespace} {
- list [namespace current] [namespace eval {} {namespace current}] \
- [namespace eval {} {namespace current}]
-} {:: :: ::}
-test namespace-2.2 {Tcl_GetCurrentNamespace} {
- set l {}
- lappend l [namespace current]
- namespace eval test_ns_1 {
- lappend l [namespace current]
- namespace eval foo {
- lappend l [namespace current]
- }
- }
- lappend l [namespace current]
- set l
-} {:: ::test_ns_1 ::test_ns_1::foo ::}
-
-test namespace-3.1 {Tcl_GetGlobalNamespace} {
- namespace eval test_ns_1 {namespace eval foo {namespace eval bar {} } }
- # namespace children uses Tcl_GetGlobalNamespace
- namespace eval test_ns_1 {namespace children foo b*}
-} {::test_ns_1::foo::bar}
-
-test namespace-4.1 {Tcl_PushCallFrame with isProcCallFrame=1} {
- namespace eval test_ns_1 {
- variable v 123
- proc p {} {
- variable v
- return $v
- }
- }
- test_ns_1::p ;# does Tcl_PushCallFrame to push p's namespace
-} {123}
-test namespace-4.2 {Tcl_PushCallFrame with isProcCallFrame=0} {
- namespace eval test_ns_1::baz {} ;# does Tcl_PushCallFrame to create baz
- proc test_ns_1::baz::p {} {
- variable v
- set v 789
- set v}
- test_ns_1::baz::p
-} {789}
-
-test namespace-5.1 {Tcl_PopCallFrame, no vars} {
- namespace eval test_ns_1::blodge {} ;# pushes then pops frame
-} {}
-test namespace-5.2 {Tcl_PopCallFrame, local vars must be deleted} {
- proc test_ns_1::r {} {
- set a 123
- }
- test_ns_1::r ;# pushes then pop's r's frame
-} {123}
-
-test namespace-6.1 {Tcl_CreateNamespace} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [lsort [namespace children :: test_ns_*]] \
- [namespace eval test_ns_1 {namespace current}] \
- [namespace eval test_ns_2 {namespace current}] \
- [namespace eval ::test_ns_3 {namespace current}] \
- [namespace eval ::test_ns_4 \
- {namespace eval foo {namespace current}}] \
- [namespace eval ::test_ns_5 \
- {namespace eval ::test_ns_6 {namespace current}}] \
- [lsort [namespace children :: test_ns_*]]
-} {{} ::test_ns_1 ::test_ns_2 ::test_ns_3 ::test_ns_4::foo ::test_ns_6 {::test_ns_1 ::test_ns_2 ::test_ns_3 ::test_ns_4 ::test_ns_5 ::test_ns_6}}
-test namespace-6.2 {Tcl_CreateNamespace, odd number of :'s in name is okay} {
- list [namespace eval :::test_ns_1::::foo {namespace current}] \
- [namespace eval test_ns_2:::::foo {namespace current}]
-} {::test_ns_1::foo ::test_ns_2::foo}
-test namespace-6.3 {Tcl_CreateNamespace, trailing ::s in ns name are ignored} {
- list [catch {namespace eval test_ns_7::: {namespace current}} msg] $msg
-} {0 ::test_ns_7}
-test namespace-6.4 {Tcl_CreateNamespace, trailing ::s in ns name are ignored} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1:: {
- namespace eval test_ns_2:: {}
- namespace eval test_ns_3:: {}
- }
- namespace children ::test_ns_1
-} {::test_ns_1::test_ns_2 ::test_ns_1::test_ns_3}
-test namespace-6.5 {Tcl_CreateNamespace, relative ns names now only looked up in current ns} {
- set trigger {
- namespace eval test_ns_2 {namespace current}
- }
- set l {}
- lappend l [namespace eval test_ns_1 $trigger]
- namespace eval test_ns_1::test_ns_2 {}
- lappend l [namespace eval test_ns_1 $trigger]
-} {::test_ns_1::test_ns_2 ::test_ns_1::test_ns_2}
-
-test namespace-7.1 {Tcl_DeleteNamespace, active call frames in ns} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1 {
- proc p {} {
- namespace delete [namespace current]
- return [namespace current]
- }
- }
- list [test_ns_1::p] [catch {test_ns_1::p} msg] $msg
-} {::test_ns_1 1 {invalid command name "test_ns_1::p"}}
-test namespace-7.2 {Tcl_DeleteNamespace, no active call frames in ns} {
- namespace eval test_ns_2 {
- proc p {} {
- return [namespace current]
- }
- }
- list [test_ns_2::p] [namespace delete test_ns_2]
-} {::test_ns_2 {}}
-
-test namespace-8.1 {TclTeardownNamespace, delete global namespace} {
- catch {interp delete test_interp}
- interp create test_interp
- interp eval test_interp {
- namespace eval test_ns_1 {
- namespace export p
- proc p {} {
- return [namespace current]
- }
- }
- namespace eval test_ns_2 {
- namespace import ::test_ns_1::p
- variable v 27
- proc q {} {
- variable v
- return "[p] $v"
- }
- }
- set x [test_ns_2::q]
- catch {set xxxx}
- }
- list [interp eval test_interp {test_ns_2::q}] \
- [interp eval test_interp {namespace delete ::}] \
- [catch {interp eval test_interp {set a 123}} msg] $msg \
- [interp delete test_interp]
-} {{::test_ns_1 27} {} 1 {invalid command name "set"} {}}
-test namespace-8.2 {TclTeardownNamespace, remove deleted ns from parent} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1::test_ns_2::test_ns_3a {proc p {} {}}
- namespace eval test_ns_1::test_ns_2::test_ns_3b {proc q {} {}}
- list [namespace children test_ns_1] \
- [namespace delete test_ns_1::test_ns_2] \
- [namespace children test_ns_1]
-} {::test_ns_1::test_ns_2 {} {}}
-test namespace-8.3 {TclTeardownNamespace, delete child namespaces} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1::test_ns_2::test_ns_3a {proc p {} {}}
- namespace eval test_ns_1::test_ns_2::test_ns_3b {proc q {} {}}
- list [namespace children test_ns_1] \
- [namespace delete test_ns_1::test_ns_2] \
- [namespace children test_ns_1] \
- [catch {namespace children test_ns_1::test_ns_2} msg] $msg \
- [info commands test_ns_1::test_ns_2::test_ns_3a::*]
-} {::test_ns_1::test_ns_2 {} {} 1 {unknown namespace "test_ns_1::test_ns_2" in namespace children command} {}}
-test namespace-8.4 {TclTeardownNamespace, cmds imported from deleted ns go away} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_export {
- namespace export cmd1 cmd2
- proc cmd1 {args} {return "cmd1: $args"}
- proc cmd2 {args} {return "cmd2: $args"}
- }
- namespace eval test_ns_import {
- namespace import ::test_ns_export::*
- proc p {} {return foo}
- }
- list [info commands test_ns_import::*] \
- [namespace delete test_ns_export] \
- [info commands test_ns_import::*]
-} {{::test_ns_import::p ::test_ns_import::cmd1 ::test_ns_import::cmd2} {} ::test_ns_import::p}
-
-test namespace-9.1 {Tcl_Import, empty import pattern} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {namespace eval test_ns_import {namespace import {}}} msg] $msg
-} {1 {empty import pattern}}
-test namespace-9.2 {Tcl_Import, unknown namespace in import pattern} {
- list [catch {namespace eval test_ns_import {namespace import fred::x}} msg] $msg
-} {1 {unknown namespace in import pattern "fred::x"}}
-test namespace-9.3 {Tcl_Import, import ns == export ns} {
- list [catch {namespace eval test_ns_import {namespace import ::test_ns_import::puts}} msg] $msg
-} {1 {import pattern "::test_ns_import::puts" tries to import from namespace "test_ns_import" into itself}}
-test namespace-9.4 {Tcl_Import, simple import} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_export {
- namespace export cmd1
- proc cmd1 {args} {return "cmd1: $args"}
- proc cmd2 {args} {return "cmd2: $args"}
- }
- namespace eval test_ns_import {
- namespace import ::test_ns_export::*
- proc p {} {return [cmd1 123]}
- }
- test_ns_import::p
-} {cmd1: 123}
-test namespace-9.5 {Tcl_Import, can't redefine cmd unless allowOverwrite!=0} {
- list [catch {namespace eval test_ns_import {namespace import ::test_ns_export::*}} msg] $msg
-} {1 {can't import command "cmd1": already exists}}
-test namespace-9.6 {Tcl_Import, cmd redefinition ok if allowOverwrite!=0} {
- namespace eval test_ns_import {
- namespace import -force ::test_ns_export::*
- cmd1 555
- }
-} {cmd1: 555}
-test namespace-9.7 {Tcl_Import, links are preserved if cmd is redefined} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_export {
- namespace export cmd1
- proc cmd1 {args} {return "cmd1: $args"}
- }
- namespace eval test_ns_import {
- namespace import -force ::test_ns_export::*
- }
- list [test_ns_import::cmd1 a b c] \
- [test_ns_export::cmd1 d e f] \
- [proc test_ns_export::cmd1 {args} {return "new1: $args"}] \
- [namespace origin test_ns_import::cmd1] \
- [namespace origin test_ns_export::cmd1] \
- [test_ns_import::cmd1 g h i] \
- [test_ns_export::cmd1 j k l]
-} {{cmd1: a b c} {cmd1: d e f} {} ::test_ns_export::cmd1 ::test_ns_export::cmd1 {new1: g h i} {new1: j k l}}
-
-test namespace-10.1 {Tcl_ForgetImport, check for valid namespaces} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {namespace forget xyzzy::*} msg] $msg
-} {1 {unknown namespace in namespace forget pattern "xyzzy::*"}}
-test namespace-10.2 {Tcl_ForgetImport, ignores patterns that don't match} {
- namespace eval test_ns_export {
- namespace export cmd1
- proc cmd1 {args} {return "cmd1: $args"}
- proc cmd2 {args} {return "cmd2: $args"}
- }
- namespace eval test_ns_import {
- namespace forget ::test_ns_export::wombat
- }
-} {}
-test namespace-10.3 {Tcl_ForgetImport, deletes matching imported cmds} {
- namespace eval test_ns_import {
- namespace import ::test_ns_export::*
- proc p {} {return [cmd1 123]}
- set l {}
- lappend l [info commands ::test_ns_import::*]
- namespace forget ::test_ns_export::cmd1
- lappend l [info commands ::test_ns_import::*]
- lappend l [catch {cmd1 777} msg] $msg
- }
-} {{::test_ns_import::p ::test_ns_import::cmd1} ::test_ns_import::p 1 {invalid command name "cmd1"}}
-
-test namespace-11.1 {TclGetOriginalCommand, check if not imported cmd} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_export {
- namespace export cmd1
- proc cmd1 {args} {return "cmd1: $args"}
- }
- list [namespace origin set] [namespace origin test_ns_export::cmd1]
-} {::set ::test_ns_export::cmd1}
-test namespace-11.2 {TclGetOriginalCommand, directly imported cmd} {
- namespace eval test_ns_import1 {
- namespace import ::test_ns_export::*
- namespace export *
- proc p {} {namespace origin cmd1}
- }
- list [test_ns_import1::p] [namespace origin test_ns_import1::cmd1]
-} {::test_ns_export::cmd1 ::test_ns_export::cmd1}
-test namespace-11.3 {TclGetOriginalCommand, indirectly imported cmd} {
- namespace eval test_ns_import2 {
- namespace import ::test_ns_import1::*
- proc q {} {return [cmd1 123]}
- }
- list [test_ns_import2::q] [namespace origin test_ns_import2::cmd1]
-} {{cmd1: 123} ::test_ns_export::cmd1}
-
-test namespace-12.1 {InvokeImportedCmd} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_export {
- namespace export cmd1
- proc cmd1 {args} {namespace current}
- }
- namespace eval test_ns_import {
- namespace import ::test_ns_export::*
- }
- list [test_ns_import::cmd1]
-} {::test_ns_export}
-
-test namespace-13.1 {DeleteImportedCmd, deletes imported cmds} {
- namespace eval test_ns_import {
- set l {}
- lappend l [info commands ::test_ns_import::*]
- namespace forget ::test_ns_export::cmd1
- lappend l [info commands ::test_ns_import::*]
- }
-} {::test_ns_import::cmd1 {}}
-
-test namespace-14.1 {TclGetNamespaceForQualName, absolute names} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- variable v 10
- namespace eval test_ns_1::test_ns_2 {
- variable v 20
- }
- namespace eval test_ns_2 {
- variable v 30
- }
- namespace eval test_ns_1 {
- list $::v $::test_ns_2::v $::test_ns_1::test_ns_2::v \
- [namespace children :: test_ns_*]
- }
-} {10 30 20 {::test_ns_1 ::test_ns_2}}
-test namespace-14.2 {TclGetNamespaceForQualName, invalid absolute names} {
- namespace eval test_ns_1 {
- list [catch {set ::test_ns_777::v} msg] $msg \
- [catch {namespace children test_ns_777} msg] $msg
- }
-} {1 {can't read "::test_ns_777::v": no such variable} 1 {unknown namespace "test_ns_777" in namespace children command}}
-test namespace-14.3 {TclGetNamespaceForQualName, relative names} {
- namespace eval test_ns_1 {
- list $v $test_ns_2::v
- }
-} {10 20}
-test namespace-14.4 {TclGetNamespaceForQualName, relative ns names looked up only in current ns} {
- namespace eval test_ns_1::test_ns_2 {
- namespace eval foo {}
- }
- namespace eval test_ns_1 {
- list [namespace children test_ns_2] \
- [catch {namespace children test_ns_1} msg] $msg
- }
-} {::test_ns_1::test_ns_2::foo 1 {unknown namespace "test_ns_1" in namespace children command}}
-test namespace-14.5 {TclGetNamespaceForQualName, relative ns names looked up only in current ns} {
- namespace eval ::test_ns_2 {
- namespace eval bar {}
- }
- namespace eval test_ns_1 {
- set l [list [catch {namespace delete test_ns_2::bar} msg] $msg]
- }
- set l
-} {1 {unknown namespace "test_ns_2::bar" in namespace delete command}}
-test namespace-14.6 {TclGetNamespaceForQualName, relative ns names looked up only in current ns} {
- namespace eval test_ns_1::test_ns_2 {
- namespace eval foo {}
- }
- namespace eval test_ns_1 {
- list [namespace children test_ns_2] \
- [catch {namespace children test_ns_1} msg] $msg
- }
-} {::test_ns_1::test_ns_2::foo 1 {unknown namespace "test_ns_1" in namespace children command}}
-test namespace-14.7 {TclGetNamespaceForQualName, ignore extra :s if ns} {
- namespace children test_ns_1:::
-} {::test_ns_1::test_ns_2}
-test namespace-14.8 {TclGetNamespaceForQualName, ignore extra :s if ns} {
- namespace children :::test_ns_1:::::test_ns_2:::
-} {::test_ns_1::test_ns_2::foo}
-test namespace-14.9 {TclGetNamespaceForQualName, extra ::s are significant for vars} {
- set l {}
- lappend l [catch {set test_ns_1::test_ns_2::} msg] $msg
- namespace eval test_ns_1::test_ns_2 {variable {} 2525}
- lappend l [set test_ns_1::test_ns_2::]
-} {1 {can't read "test_ns_1::test_ns_2::": no such variable} 2525}
-test namespace-14.10 {TclGetNamespaceForQualName, extra ::s are significant for vars} {
- catch {unset test_ns_1::test_ns_2::}
- set l {}
- lappend l [catch {set test_ns_1::test_ns_2::} msg] $msg
- set test_ns_1::test_ns_2:: 314159
- lappend l [set test_ns_1::test_ns_2::]
-} {1 {can't read "test_ns_1::test_ns_2::": no such variable} 314159}
-test namespace-14.11 {TclGetNamespaceForQualName, extra ::s are significant for commands} {
- catch {rename test_ns_1::test_ns_2:: {}}
- set l {}
- lappend l [catch {test_ns_1::test_ns_2:: hello} msg] $msg
- proc test_ns_1::test_ns_2:: {args} {return "\{\}: $args"}
- lappend l [test_ns_1::test_ns_2:: hello]
-} {1 {invalid command name "test_ns_1::test_ns_2::"} {{}: hello}}
-test namespace-14.12 {TclGetNamespaceForQualName, extra ::s are significant for vars} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1 {
- variable {}
- set test_ns_1::(x) y
- }
- set test_ns_1::(x)
-} y
-test namespace-14.13 {TclGetNamespaceForQualName, namespace other than global ns can't have empty name} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {namespace eval test_ns_1 {proc {} {} {}; namespace eval {} {}; {}}} msg] $msg
-} {1 {can't create namespace "": only global namespace can have empty name}}
-
-test namespace-15.1 {Tcl_FindNamespace, absolute name found} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_delete {
- namespace eval test_ns_delete2 {}
- proc cmd {args} {namespace current}
- }
- list [namespace delete ::test_ns_delete::test_ns_delete2] \
- [namespace children ::test_ns_delete]
-} {{} {}}
-test namespace-15.2 {Tcl_FindNamespace, absolute name not found} {
- list [catch {namespace delete ::test_ns_delete::test_ns_delete2} msg] $msg
-} {1 {unknown namespace "::test_ns_delete::test_ns_delete2" in namespace delete command}}
-test namespace-15.3 {Tcl_FindNamespace, relative name found} {
- namespace eval test_ns_delete {
- namespace eval test_ns_delete2 {}
- namespace eval test_ns_delete3 {}
- list [namespace delete test_ns_delete2] \
- [namespace children [namespace current]]
- }
-} {{} ::test_ns_delete::test_ns_delete3}
-test namespace-15.4 {Tcl_FindNamespace, relative name not found} {
- namespace eval test_ns_delete2 {}
- namespace eval test_ns_delete {
- list [catch {namespace delete test_ns_delete2} msg] $msg
- }
-} {1 {unknown namespace "test_ns_delete2" in namespace delete command}}
-
-test namespace-16.1 {Tcl_FindCommand, absolute name found} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1 {
- proc cmd {args} {return "[namespace current]::cmd: $args"}
- variable v "::test_ns_1::cmd"
- eval $v one
- }
-} {::test_ns_1::cmd: one}
-test namespace-16.2 {Tcl_FindCommand, absolute name found} {
- eval $test_ns_1::v two
-} {::test_ns_1::cmd: two}
-test namespace-16.3 {Tcl_FindCommand, absolute name not found} {
- namespace eval test_ns_1 {
- variable v2 "::test_ns_1::ladidah"
- list [catch {eval $v2} msg] $msg
- }
-} {1 {invalid command name "::test_ns_1::ladidah"}}
-
-# save the "unknown" proc, which is redefined by the following two tests
-catch {rename unknown unknown.old}
-proc unknown {args} {
- return "unknown: $args"
-}
-test namespace-16.4 {Tcl_FindCommand, absolute name and TCL_GLOBAL_ONLY} {
- ::test_ns_1::foobar x y z
-} {unknown: ::test_ns_1::foobar x y z}
-test namespace-16.5 {Tcl_FindCommand, absolute name and TCL_GLOBAL_ONLY} {
- ::foobar 1 2 3 4 5
-} {unknown: ::foobar 1 2 3 4 5}
-test namespace-16.6 {Tcl_FindCommand, relative name and TCL_GLOBAL_ONLY} {
- test_ns_1::foobar x y z
-} {unknown: test_ns_1::foobar x y z}
-test namespace-16.7 {Tcl_FindCommand, relative name and TCL_GLOBAL_ONLY} {
- foobar 1 2 3 4 5
-} {unknown: foobar 1 2 3 4 5}
-# restore the "unknown" proc saved previously
-catch {rename unknown {}}
-catch {rename unknown.old unknown}
-
-test namespace-16.8 {Tcl_FindCommand, relative name found} {
- namespace eval test_ns_1 {
- cmd a b c
- }
-} {::test_ns_1::cmd: a b c}
-test namespace-16.9 {Tcl_FindCommand, relative name found} {
- catch {rename cmd2 {}}
- proc cmd2 {args} {return "[namespace current]::cmd2: $args"}
- namespace eval test_ns_1 {
- cmd2 a b c
- }
-} {::::cmd2: a b c}
-test namespace-16.10 {Tcl_FindCommand, relative name found, only look in current then global ns} {
- namespace eval test_ns_1 {
- proc cmd2 {args} {
- return "[namespace current]::cmd2 in test_ns_1: $args"
- }
- namespace eval test_ns_12 {
- cmd2 a b c
- }
- }
-} {::::cmd2: a b c}
-test namespace-16.11 {Tcl_FindCommand, relative name not found} {
- namespace eval test_ns_1 {
- list [catch {cmd3 a b c} msg] $msg
- }
-} {1 {invalid command name "cmd3"}}
-
-catch {unset x}
-test namespace-17.1 {Tcl_FindNamespaceVar, absolute name found} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- set x 314159
- namespace eval test_ns_1 {
- set ::x
- }
-} {314159}
-test namespace-17.2 {Tcl_FindNamespaceVar, absolute name found} {
- namespace eval test_ns_1 {
- variable x 777
- set ::test_ns_1::x
- }
-} {777}
-test namespace-17.3 {Tcl_FindNamespaceVar, absolute name found} {
- namespace eval test_ns_1 {
- namespace eval test_ns_2 {
- variable x 1111
- }
- set ::test_ns_1::test_ns_2::x
- }
-} {1111}
-test namespace-17.4 {Tcl_FindNamespaceVar, absolute name not found} {
- namespace eval test_ns_1 {
- namespace eval test_ns_2 {
- variable x 1111
- }
- list [catch {set ::test_ns_1::test_ns_2::y} msg] $msg
- }
-} {1 {can't read "::test_ns_1::test_ns_2::y": no such variable}}
-test namespace-17.5 {Tcl_FindNamespaceVar, absolute name and TCL_GLOBAL_ONLY} {
- namespace eval test_ns_1 {
- namespace eval test_ns_3 {
- variable ::test_ns_1::test_ns_2::x 2222
- }
- }
- set ::test_ns_1::test_ns_2::x
-} {2222}
-test namespace-17.6 {Tcl_FindNamespaceVar, relative name found} {
- namespace eval test_ns_1 {
- set x
- }
-} {777}
-test namespace-17.7 {Tcl_FindNamespaceVar, relative name found} {
- namespace eval test_ns_1 {
- unset x
- set x ;# must be global x now
- }
-} {314159}
-test namespace-17.8 {Tcl_FindNamespaceVar, relative name not found} {
- namespace eval test_ns_1 {
- list [catch {set wuzzat} msg] $msg
- }
-} {1 {can't read "wuzzat": no such variable}}
-test namespace-17.9 {Tcl_FindNamespaceVar, relative name and TCL_GLOBAL_ONLY} {
- namespace eval test_ns_1 {
- variable a hello
- }
- set test_ns_1::a
-} {hello}
-catch {unset x}
-
-catch {unset l}
-catch {rename foo {}}
-test namespace-18.1 {TclResetShadowedCmdRefs, one-level check for command shadowing} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- proc foo {} {return "global foo"}
- namespace eval test_ns_1 {
- proc trigger {} {
- return [foo]
- }
- }
- set l ""
- lappend l [test_ns_1::trigger]
- namespace eval test_ns_1 {
- # force invalidation of cached ref to "foo" in proc trigger
- proc foo {} {return "foo in test_ns_1"}
- }
- lappend l [test_ns_1::trigger]
- set l
-} {{global foo} {foo in test_ns_1}}
-test namespace-18.2 {TclResetShadowedCmdRefs, multilevel check for command shadowing} {
- namespace eval test_ns_2 {
- proc foo {} {return "foo in ::test_ns_2"}
- }
- namespace eval test_ns_1 {
- namespace eval test_ns_2 {}
- proc trigger {} {
- return [test_ns_2::foo]
- }
- }
- set l ""
- lappend l [test_ns_1::trigger]
- namespace eval test_ns_1 {
- namespace eval test_ns_2 {
- # force invalidation of cached ref to "foo" in proc trigger
- proc foo {} {return "foo in ::test_ns_1::test_ns_2"}
- }
- }
- lappend l [test_ns_1::trigger]
- set l
-} {{foo in ::test_ns_2} {foo in ::test_ns_1::test_ns_2}}
-catch {unset l}
-catch {rename foo {}}
-
-test namespace-19.1 {GetNamespaceFromObj, global name found} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1::test_ns_2 {}
- namespace children ::test_ns_1
-} {::test_ns_1::test_ns_2}
-test namespace-19.2 {GetNamespaceFromObj, relative name found} {
- namespace eval test_ns_1 {
- namespace children test_ns_2
- }
-} {}
-test namespace-19.3 {GetNamespaceFromObj, name not found} {
- namespace eval test_ns_1 {
- list [catch {namespace children test_ns_99} msg] $msg
- }
-} {1 {unknown namespace "test_ns_99" in namespace children command}}
-test namespace-19.4 {GetNamespaceFromObj, invalidation of cached ns refs} {
- namespace eval test_ns_1 {
- proc foo {} {
- return [namespace children test_ns_2]
- }
- list [catch {namespace children test_ns_99} msg] $msg
- }
- set l {}
- lappend l [test_ns_1::foo]
- namespace delete test_ns_1::test_ns_2
- namespace eval test_ns_1::test_ns_2::test_ns_3 {}
- lappend l [test_ns_1::foo]
- set l
-} {{} ::test_ns_1::test_ns_2::test_ns_3}
-
-test namespace-20.1 {Tcl_NamespaceObjCmd, bad subcommand} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {namespace} msg] $msg
-} {1 {wrong # args: should be "namespace subcommand ?arg ...?"}}
-test namespace-20.2 {Tcl_NamespaceObjCmd, bad subcommand} {
- list [catch {namespace wombat {}} msg] $msg
-} {1 {bad option "wombat": must be children, code, current, delete, eval, export, forget, import, inscope, origin, parent, qualifiers, tail, or which}}
-test namespace-20.3 {Tcl_NamespaceObjCmd, abbreviations are okay} {
- namespace ch :: test_ns_*
-} {}
-
-test namespace-21.1 {NamespaceChildrenCmd, no args} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1::test_ns_2 {}
- expr {[string first ::test_ns_1 [namespace children]] != -1}
-} {1}
-test namespace-21.2 {NamespaceChildrenCmd, no args} {
- namespace eval test_ns_1 {
- namespace children
- }
-} {::test_ns_1::test_ns_2}
-test namespace-21.3 {NamespaceChildrenCmd, ns name given} {
- namespace children ::test_ns_1
-} {::test_ns_1::test_ns_2}
-test namespace-21.4 {NamespaceChildrenCmd, ns name given} {
- namespace eval test_ns_1 {
- namespace children test_ns_2
- }
-} {}
-test namespace-21.5 {NamespaceChildrenCmd, too many args} {
- namespace eval test_ns_1 {
- list [catch {namespace children test_ns_2 xxx yyy} msg] $msg
- }
-} {1 {wrong # args: should be "namespace children ?name? ?pattern?"}}
-test namespace-21.6 {NamespaceChildrenCmd, glob-style pattern given} {
- namespace eval test_ns_1::test_ns_foo {}
- namespace children test_ns_1 *f*
-} {::test_ns_1::test_ns_foo}
-test namespace-21.7 {NamespaceChildrenCmd, glob-style pattern given} {
- namespace eval test_ns_1::test_ns_foo {}
- namespace children test_ns_1 test*
-} {::test_ns_1::test_ns_2 ::test_ns_1::test_ns_foo}
-
-test namespace-22.1 {NamespaceCodeCmd, bad args} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {namespace code} msg] $msg \
- [catch {namespace code xxx yyy} msg] $msg
-} {1 {wrong # args: should be "namespace code arg"} 1 {wrong # args: should be "namespace code arg"}}
-test namespace-22.2 {NamespaceCodeCmd, arg is already scoped value} {
- namespace eval test_ns_1 {
- proc cmd {} {return "test_ns_1::cmd"}
- }
- namespace code {namespace inscope ::test_ns_1 cmd}
-} {namespace inscope ::test_ns_1 cmd}
-test namespace-22.3 {NamespaceCodeCmd, arg is already scoped value} {
- namespace code {namespace inscope ::test_ns_1 cmd}
-} {namespace inscope ::test_ns_1 cmd}
-test namespace-22.4 {NamespaceCodeCmd, in :: namespace} {
- namespace code unknown
-} {namespace inscope :: unknown}
-test namespace-22.5 {NamespaceCodeCmd, in other namespace} {
- namespace eval test_ns_1 {
- namespace code cmd
- }
-} {namespace inscope ::test_ns_1 cmd}
-
-test namespace-23.1 {NamespaceCurrentCmd, bad args} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {namespace current xxx} msg] $msg \
- [catch {namespace current xxx yyy} msg] $msg
-} {1 {wrong # args: should be "namespace current"} 1 {wrong # args: should be "namespace current"}}
-test namespace-23.2 {NamespaceCurrentCmd, at global level} {
- namespace current
-} {::}
-test namespace-23.3 {NamespaceCurrentCmd, in nested ns} {
- namespace eval test_ns_1::test_ns_2 {
- namespace current
- }
-} {::test_ns_1::test_ns_2}
-
-test namespace-24.1 {NamespaceDeleteCmd, no args} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace delete
-} {}
-test namespace-24.2 {NamespaceDeleteCmd, one arg} {
- namespace eval test_ns_1::test_ns_2 {}
- namespace delete ::test_ns_1
-} {}
-test namespace-24.3 {NamespaceDeleteCmd, two args} {
- namespace eval test_ns_1::test_ns_2 {}
- list [namespace delete ::test_ns_1::test_ns_2] [namespace delete ::test_ns_1]
-} {{} {}}
-test namespace-24.4 {NamespaceDeleteCmd, unknown ns} {
- list [catch {namespace delete ::test_ns_foo} msg] $msg
-} {1 {unknown namespace "::test_ns_foo" in namespace delete command}}
-
-test namespace-25.1 {NamespaceEvalCmd, bad args} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {namespace eval} msg] $msg
-} {1 {wrong # args: should be "namespace eval name arg ?arg...?"}}
-test namespace-25.2 {NamespaceEvalCmd, bad args} {
- list [catch {namespace test_ns_1} msg] $msg
-} {1 {bad option "test_ns_1": must be children, code, current, delete, eval, export, forget, import, inscope, origin, parent, qualifiers, tail, or which}}
-catch {unset v}
-test namespace-25.3 {NamespaceEvalCmd, new namespace} {
- set v 123
- namespace eval test_ns_1 {
- variable v 314159
- proc p {} {
- variable v
- return $v
- }
- }
- test_ns_1::p
-} {314159}
-test namespace-25.4 {NamespaceEvalCmd, existing namespace} {
- namespace eval test_ns_1 {
- proc q {} {return [expr {[p]+1}]}
- }
- test_ns_1::q
-} {314160}
-test namespace-25.5 {NamespaceEvalCmd, multiple args} {
- namespace eval test_ns_1 "set" "v"
-} {314159}
-test namespace-25.6 {NamespaceEvalCmd, error in eval'd script} {
- list [catch {namespace eval test_ns_1 {xxxx}} msg] $msg $errorInfo
-} {1 {invalid command name "xxxx"} {invalid command name "xxxx"
- while executing
-"xxxx"
- (in namespace eval "::test_ns_1" script line 1)
- invoked from within
-"namespace eval test_ns_1 {xxxx}"}}
-catch {unset v}
-
-test namespace-26.1 {NamespaceExportCmd, no args and new ns} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace export
-} {}
-test namespace-26.2 {NamespaceExportCmd, just -clear arg} {
- namespace export -clear
-} {}
-test namespace-26.3 {NamespaceExportCmd, pattern can't specify a namespace} {
- namespace eval test_ns_1 {
- list [catch {namespace export ::zzz} msg] $msg
- }
-} {1 {invalid export pattern "::zzz": pattern can't specify a namespace}}
-test namespace-26.4 {NamespaceExportCmd, one pattern} {
- namespace eval test_ns_1 {
- namespace export cmd1
- proc cmd1 {args} {return "cmd1: $args"}
- proc cmd2 {args} {return "cmd2: $args"}
- proc cmd3 {args} {return "cmd3: $args"}
- proc cmd4 {args} {return "cmd4: $args"}
- }
- namespace eval test_ns_2 {
- namespace import ::test_ns_1::*
- }
- list [info commands test_ns_2::*] [test_ns_2::cmd1 hello]
-} {::test_ns_2::cmd1 {cmd1: hello}}
-test namespace-26.5 {NamespaceExportCmd, sequence of patterns, patterns accumulate} {
- namespace eval test_ns_1 {
- namespace export cmd1 cmd3
- }
- namespace eval test_ns_2 {
- namespace import -force ::test_ns_1::*
- }
- list [info commands test_ns_2::*] [test_ns_2::cmd3 hello]
-} {{::test_ns_2::cmd1 ::test_ns_2::cmd3} {cmd3: hello}}
-test namespace-26.6 {NamespaceExportCmd, no patterns means return export list} {
- namespace eval test_ns_1 {
- namespace export
- }
-} {cmd1 cmd1 cmd3}
-test namespace-26.7 {NamespaceExportCmd, -clear resets export list} {
- namespace eval test_ns_1 {
- namespace export -clear cmd4
- }
- namespace eval test_ns_2 {
- namespace import ::test_ns_1::*
- }
- list [info commands test_ns_2::*] [test_ns_2::cmd4 hello]
-} {{::test_ns_2::cmd4 ::test_ns_2::cmd1 ::test_ns_2::cmd3} {cmd4: hello}}
-
-test namespace-27.1 {NamespaceForgetCmd, no args} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace forget
-} {}
-test namespace-27.2 {NamespaceForgetCmd, args must be valid namespaces} {
- list [catch {namespace forget ::test_ns_1::xxx} msg] $msg
-} {1 {unknown namespace in namespace forget pattern "::test_ns_1::xxx"}}
-test namespace-27.3 {NamespaceForgetCmd, arg is forgotten} {
- namespace eval test_ns_1 {
- namespace export cmd*
- proc cmd1 {args} {return "cmd1: $args"}
- proc cmd2 {args} {return "cmd2: $args"}
- }
- namespace eval test_ns_2 {
- namespace import ::test_ns_1::*
- namespace forget ::test_ns_1::cmd1
- }
- info commands ::test_ns_2::*
-} {::test_ns_2::cmd2}
-
-test namespace-28.1 {NamespaceImportCmd, no args} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace import
-} {}
-test namespace-28.2 {NamespaceImportCmd, no args and just "-force"} {
- namespace import -force
-} {}
-test namespace-28.3 {NamespaceImportCmd, arg is imported} {
- namespace eval test_ns_1 {
- namespace export cmd2
- proc cmd1 {args} {return "cmd1: $args"}
- proc cmd2 {args} {return "cmd2: $args"}
- }
- namespace eval test_ns_2 {
- namespace import ::test_ns_1::*
- namespace forget ::test_ns_1::cmd1
- }
- info commands test_ns_2::*
-} {::test_ns_2::cmd2}
-
-test namespace-29.1 {NamespaceInscopeCmd, bad args} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {namespace inscope} msg] $msg
-} {1 {wrong # args: should be "namespace inscope name arg ?arg...?"}}
-test namespace-29.2 {NamespaceInscopeCmd, bad args} {
- list [catch {namespace inscope ::} msg] $msg
-} {1 {wrong # args: should be "namespace inscope name arg ?arg...?"}}
-test namespace-29.3 {NamespaceInscopeCmd, specified ns must exist} {
- list [catch {namespace inscope test_ns_1 {set v}} msg] $msg
-} {1 {unknown namespace "test_ns_1" in inscope namespace command}}
-test namespace-29.4 {NamespaceInscopeCmd, simple case} {
- namespace eval test_ns_1 {
- variable v 747
- proc cmd {args} {
- variable v
- return "[namespace current]::cmd: v=$v, args=$args"
- }
- }
- namespace inscope test_ns_1 cmd
-} {::test_ns_1::cmd: v=747, args=}
-test namespace-29.5 {NamespaceInscopeCmd, has lappend semantics} {
- list [namespace inscope test_ns_1 cmd x y z] \
- [namespace eval test_ns_1 [concat cmd [list x y z]]]
-} {{::test_ns_1::cmd: v=747, args=x y z} {::test_ns_1::cmd: v=747, args=x y z}}
-
-test namespace-30.1 {NamespaceOriginCmd, bad args} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {namespace origin} msg] $msg
-} {1 {wrong # args: should be "namespace origin name"}}
-test namespace-30.2 {NamespaceOriginCmd, bad args} {
- list [catch {namespace origin x y} msg] $msg
-} {1 {wrong # args: should be "namespace origin name"}}
-test namespace-30.3 {NamespaceOriginCmd, command not found} {
- list [catch {namespace origin fred} msg] $msg
-} {1 {invalid command name "fred"}}
-test namespace-30.4 {NamespaceOriginCmd, command isn't imported} {
- namespace origin set
-} {::set}
-test namespace-30.5 {NamespaceOriginCmd, imported command} {
- namespace eval test_ns_1 {
- namespace export cmd*
- proc cmd1 {args} {return "cmd1: $args"}
- proc cmd2 {args} {return "cmd2: $args"}
- }
- namespace eval test_ns_2 {
- namespace export *
- namespace import ::test_ns_1::*
- proc p {} {}
- }
- namespace eval test_ns_3 {
- namespace import ::test_ns_2::*
- list [namespace origin foreach] \
- [namespace origin p] \
- [namespace origin cmd1] \
- [namespace origin ::test_ns_2::cmd2]
- }
-} {::foreach ::test_ns_2::p ::test_ns_1::cmd1 ::test_ns_1::cmd2}
-
-test namespace-31.1 {NamespaceParentCmd, bad args} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {namespace parent a b} msg] $msg
-} {1 {wrong # args: should be "namespace parent ?name?"}}
-test namespace-31.2 {NamespaceParentCmd, no args} {
- namespace parent
-} {}
-test namespace-31.3 {NamespaceParentCmd, namespace specified} {
- namespace eval test_ns_1 {
- namespace eval test_ns_2 {
- namespace eval test_ns_3 {}
- }
- }
- list [namespace parent ::] \
- [namespace parent test_ns_1::test_ns_2] \
- [namespace eval test_ns_1::test_ns_2::test_ns_3 {namespace parent ::test_ns_1::test_ns_2}]
-} {{} ::test_ns_1 ::test_ns_1}
-test namespace-31.4 {NamespaceParentCmd, bad namespace specified} {
- list [catch {namespace parent test_ns_1::test_ns_foo} msg] $msg
-} {1 {unknown namespace "test_ns_1::test_ns_foo" in namespace parent command}}
-
-test namespace-32.1 {NamespaceQualifiersCmd, bad args} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {namespace qualifiers} msg] $msg
-} {1 {wrong # args: should be "namespace qualifiers string"}}
-test namespace-32.2 {NamespaceQualifiersCmd, bad args} {
- list [catch {namespace qualifiers x y} msg] $msg
-} {1 {wrong # args: should be "namespace qualifiers string"}}
-test namespace-32.3 {NamespaceQualifiersCmd, simple name} {
- namespace qualifiers foo
-} {}
-test namespace-32.4 {NamespaceQualifiersCmd, leading ::} {
- namespace qualifiers ::x::y::z
-} {::x::y}
-test namespace-32.5 {NamespaceQualifiersCmd, no leading ::} {
- namespace qualifiers a::b
-} {a}
-test namespace-32.6 {NamespaceQualifiersCmd, :: argument} {
- namespace qualifiers ::
-} {}
-test namespace-32.7 {NamespaceQualifiersCmd, odd number of :s} {
- namespace qualifiers :::::
-} {}
-test namespace-32.8 {NamespaceQualifiersCmd, odd number of :s} {
- namespace qualifiers foo:::
-} {foo}
-
-test namespace-33.1 {NamespaceTailCmd, bad args} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {namespace tail} msg] $msg
-} {1 {wrong # args: should be "namespace tail string"}}
-test namespace-33.2 {NamespaceTailCmd, bad args} {
- list [catch {namespace tail x y} msg] $msg
-} {1 {wrong # args: should be "namespace tail string"}}
-test namespace-33.3 {NamespaceTailCmd, simple name} {
- namespace tail foo
-} {foo}
-test namespace-33.4 {NamespaceTailCmd, leading ::} {
- namespace tail ::x::y::z
-} {z}
-test namespace-33.5 {NamespaceTailCmd, no leading ::} {
- namespace tail a::b
-} {b}
-test namespace-33.6 {NamespaceTailCmd, :: argument} {
- namespace tail ::
-} {}
-test namespace-33.7 {NamespaceTailCmd, odd number of :s} {
- namespace tail :::::
-} {}
-test namespace-33.8 {NamespaceTailCmd, odd number of :s} {
- namespace tail foo:::
-} {}
-
-test namespace-34.1 {NamespaceWhichCmd, bad args} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {namespace which} msg] $msg
-} {1 {wrong # args: should be "namespace which ?-command? ?-variable? name"}}
-test namespace-34.2 {NamespaceWhichCmd, bad args} {
- list [catch {namespace which -fred} msg] $msg
-} {1 {wrong # args: should be "namespace which ?-command? ?-variable? name"}}
-test namespace-34.3 {NamespaceWhichCmd, bad args} {
- list [catch {namespace which -command} msg] $msg
-} {1 {wrong # args: should be "namespace which ?-command? ?-variable? name"}}
-test namespace-34.4 {NamespaceWhichCmd, bad args} {
- list [catch {namespace which a b} msg] $msg
-} {1 {wrong # args: should be "namespace which ?-command? ?-variable? name"}}
-test namespace-34.5 {NamespaceWhichCmd, command lookup} {
- namespace eval test_ns_1 {
- namespace export cmd*
- variable v1 111
- proc cmd1 {args} {return "cmd1: $args"}
- proc cmd2 {args} {return "cmd2: $args"}
- }
- namespace eval test_ns_2 {
- namespace export *
- namespace import ::test_ns_1::*
- variable v2 222
- proc p {} {}
- }
- namespace eval test_ns_3 {
- namespace import ::test_ns_2::*
- variable v3 333
- list [namespace which -command foreach] \
- [namespace which -command p] \
- [namespace which -command cmd1] \
- [namespace which -command ::test_ns_2::cmd2] \
- [catch {namespace which -command ::test_ns_2::noSuchCmd} msg] $msg
- }
-} {::foreach ::test_ns_3::p ::test_ns_3::cmd1 ::test_ns_2::cmd2 0 {}}
-test namespace-34.6 {NamespaceWhichCmd, -command is default} {
- namespace eval test_ns_3 {
- list [namespace which foreach] \
- [namespace which p] \
- [namespace which cmd1] \
- [namespace which ::test_ns_2::cmd2]
- }
-} {::foreach ::test_ns_3::p ::test_ns_3::cmd1 ::test_ns_2::cmd2}
-test namespace-34.7 {NamespaceWhichCmd, variable lookup} {
- namespace eval test_ns_3 {
- list [namespace which -variable env] \
- [namespace which -variable v3] \
- [namespace which -variable ::test_ns_2::v2] \
- [catch {namespace which -variable ::test_ns_2::noSuchVar} msg] $msg
- }
-} {::env ::test_ns_3::v3 ::test_ns_2::v2 0 {}}
-
-test namespace-35.1 {FreeNsNameInternalRep, resulting ref count > 0} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1 {
- proc p {} {
- namespace delete [namespace current]
- return [namespace current]
- }
- }
- test_ns_1::p
-} {::test_ns_1}
-test namespace-35.2 {FreeNsNameInternalRep, resulting ref count == 0} {
- namespace eval test_ns_1 {
- proc q {} {
- return [namespace current]
- }
- }
- list [test_ns_1::q] \
- [namespace delete test_ns_1] \
- [catch {test_ns_1::q} msg] $msg
-} {::test_ns_1 {} 1 {invalid command name "test_ns_1::q"}}
-
-catch {unset x}
-catch {unset y}
-test namespace-36.1 {DupNsNameInternalRep} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1 {}
- set x "::test_ns_1"
- list [namespace parent $x] [set y $x] [namespace parent $y]
-} {:: ::test_ns_1 ::}
-catch {unset x}
-catch {unset y}
-
-test namespace-37.1 {SetNsNameFromAny, ns name found} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1::test_ns_2 {}
- namespace eval test_ns_1 {
- namespace children ::test_ns_1
- }
-} {::test_ns_1::test_ns_2}
-test namespace-37.2 {SetNsNameFromAny, ns name not found} {
- namespace eval test_ns_1 {
- list [catch {namespace children ::test_ns_1::test_ns_foo} msg] $msg
- }
-} {1 {unknown namespace "::test_ns_1::test_ns_foo" in namespace children command}}
-
-test namespace-38.1 {UpdateStringOfNsName} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- ;# Tcl_NamespaceObjCmd calls UpdateStringOfNsName to get subcmd name
- list [namespace eval {} {namespace current}] \
- [namespace eval {} {namespace current}]
-} {:: ::}
-
-# cleanup
-catch {rename cmd1 {}}
-catch {unset l}
-catch {unset msg}
-catch {unset trigger}
-eval namespace delete [namespace children :: test_ns_*]
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/obj.test b/tests/obj.test
deleted file mode 100644
index ce7738d..0000000
--- a/tests/obj.test
+++ /dev/null
@@ -1,546 +0,0 @@
-# Functionality covered: this file contains a collection of tests for the
-# procedures in tclObj.c that implement Tcl's basic type support and the
-# type managers for the types boolean, double, and integer.
-#
-# Sourcing this file into Tcl runs the tests and 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: obj.test,v 1.3 1999/04/16 00:47:31 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[info commands testobj] == {}} {
- puts "This application hasn't been compiled with the \"testobj\""
- puts "command, so I can't test the Tcl type and object support."
- ::tcltest::cleanupTests
- return
-}
-
-test obj-1.1 {Tcl_AppendAllObjTypes, and InitTypeTable, Tcl_RegisterObjType} {
- set r 1
- foreach {t} {list boolean cmdName bytecode string int double} {
- set first [string first $t [testobj types]]
- set r [expr {$r && ($first != -1)}]
- }
- set result $r
-} {1}
-
-test obj-2.1 {Tcl_GetObjType error} {
- list [testintobj set 1 0] [catch {testobj convert 1 foo} msg] $msg
-} {0 1 {no type foo found}}
-test obj-2.2 {Tcl_GetObjType and Tcl_ConvertToType} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testintobj set 1 12]
- lappend result [testobj convert 1 double]
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} 12 12 double 3}
-
-test obj-3.1 {Tcl_ConvertToType error} {
- list [testdoubleobj set 1 12.34] [catch {testobj convert 1 int} msg] $msg
-} {12.34 1 {expected integer but got "12.34"}}
-test obj-3.2 {Tcl_ConvertToType error, "empty string" object} {
- list [testobj newobj 1] [catch {testobj convert 1 int} msg] $msg
-} {{} 1 {expected integer but got ""}}
-
-test obj-4.1 {Tcl_NewObj and AllocateFreeObjects} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testobj newobj 1]
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} {} string 2}
-
-test obj-5.1 {Tcl_FreeObj} {
- set result ""
- lappend result [testintobj set 1 12345]
- lappend result [testobj freeallvars]
- lappend result [catch {testintobj get 1} msg]
- lappend result $msg
-} {12345 {} 1 {variable 1 is unset (NULL)}}
-
-test obj-6.1 {Tcl_DuplicateObj, object has internal rep} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testintobj set 1 47]
- lappend result [testobj duplicate 1 2]
- lappend result [testintobj get 2]
- lappend result [testobj refcount 1]
- lappend result [testobj refcount 2]
-} {{} 47 47 47 2 3}
-test obj-6.2 {Tcl_DuplicateObj, "empty string" object} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testobj newobj 1]
- lappend result [testobj duplicate 1 2]
- lappend result [testintobj get 2]
- lappend result [testobj refcount 1]
- lappend result [testobj refcount 2]
-} {{} {} {} {} 2 3}
-
-test obj-7.1 {Tcl_GetString, return existing string rep} {
- set result ""
- lappend result [testintobj set 1 47]
- lappend result [testintobj get2 1]
-} {47 47}
-test obj-7.2 {Tcl_GetString, "empty string" object} {
- set result ""
- lappend result [testobj newobj 1]
- lappend result [teststringobj append 1 abc -1]
- lappend result [teststringobj get2 1]
-} {{} abc abc}
-test obj-7.3 {Tcl_GetString, returns string internal rep (DString)} {
- set result ""
- lappend result [teststringobj set 1 xyz]
- lappend result [teststringobj append 1 abc -1]
- lappend result [teststringobj get2 1]
-} {xyz xyzabc xyzabc}
-test obj-7.4 {Tcl_GetString, recompute string rep from internal rep} {
- set result ""
- lappend result [testintobj set 1 77]
- lappend result [testintobj mult10 1]
- lappend result [teststringobj get2 1]
-} {77 770 770}
-
-test obj-8.1 {Tcl_GetStringFromObj, return existing string rep} {
- set result ""
- lappend result [testintobj set 1 47]
- lappend result [testintobj get 1]
-} {47 47}
-test obj-8.2 {Tcl_GetStringFromObj, "empty string" object} {
- set result ""
- lappend result [testobj newobj 1]
- lappend result [teststringobj append 1 abc -1]
- lappend result [teststringobj get 1]
-} {{} abc abc}
-test obj-8.3 {Tcl_GetStringFromObj, returns string internal rep (DString)} {
- set result ""
- lappend result [teststringobj set 1 xyz]
- lappend result [teststringobj append 1 abc -1]
- lappend result [teststringobj get 1]
-} {xyz xyzabc xyzabc}
-test obj-8.4 {Tcl_GetStringFromObj, recompute string rep from internal rep} {
- set result ""
- lappend result [testintobj set 1 77]
- lappend result [testintobj mult10 1]
- lappend result [teststringobj get 1]
-} {77 770 770}
-
-test obj-9.1 {Tcl_NewBooleanObj} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testbooleanobj set 1 0]
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} 0 boolean 2}
-
-test obj-10.1 {Tcl_SetBooleanObj, existing "empty string" object} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testobj newobj 1]
- lappend result [testbooleanobj set 1 0] ;# makes existing obj boolean
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} {} 0 boolean 2}
-test obj-10.2 {Tcl_SetBooleanObj, existing non-"empty string" object} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testintobj set 1 98765]
- lappend result [testbooleanobj set 1 1] ;# makes existing obj boolean
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} 98765 1 boolean 2}
-
-test obj-11.1 {Tcl_GetBooleanFromObj, existing boolean object} {
- set result ""
- lappend result [testbooleanobj set 1 1]
- lappend result [testbooleanobj not 1] ;# gets existing boolean rep
-} {1 0}
-test obj-11.2 {Tcl_GetBooleanFromObj, convert to boolean} {
- set result ""
- lappend result [testintobj set 1 47]
- lappend result [testbooleanobj not 1] ;# must convert to bool
- lappend result [testobj type 1]
-} {47 0 boolean}
-test obj-11.3 {Tcl_GetBooleanFromObj, error converting to boolean} {
- set result ""
- lappend result [teststringobj set 1 abc]
- lappend result [catch {testbooleanobj not 1} msg]
- lappend result $msg
-} {abc 1 {expected boolean value but got "abc"}}
-test obj-11.4 {Tcl_GetBooleanFromObj, error converting from "empty string"} {
- set result ""
- lappend result [testobj newobj 1]
- lappend result [catch {testbooleanobj not 1} msg]
- lappend result $msg
-} {{} 1 {expected boolean value but got ""}}
-
-test obj-12.1 {DupBooleanInternalRep} {
- set result ""
- lappend result [testbooleanobj set 1 1]
- lappend result [testobj duplicate 1 2] ;# uses DupBooleanInternalRep
- lappend result [testbooleanobj get 2]
-} {1 1 1}
-
-test obj-13.1 {SetBooleanFromAny, int to boolean special case} {
- set result ""
- lappend result [testintobj set 1 1234]
- lappend result [testbooleanobj not 1] ;# converts with SetBooleanFromAny
- lappend result [testobj type 1]
-} {1234 0 boolean}
-test obj-13.2 {SetBooleanFromAny, double to boolean special case} {
- set result ""
- lappend result [testdoubleobj set 1 3.14159]
- lappend result [testbooleanobj not 1] ;# converts with SetBooleanFromAny
- lappend result [testobj type 1]
-} {3.14159 0 boolean}
-test obj-13.3 {SetBooleanFromAny, special case strings representing booleans} {
- set result ""
- foreach s {yes no true false on off} {
- teststringobj set 1 $s
- lappend result [testbooleanobj not 1]
- }
- lappend result [testobj type 1]
-} {0 1 0 1 0 1 boolean}
-test obj-13.4 {SetBooleanFromAny, recompute string rep then parse it} {
- set result ""
- lappend result [testintobj set 1 456]
- lappend result [testintobj div10 1]
- lappend result [testbooleanobj not 1] ;# converts with SetBooleanFromAny
- lappend result [testobj type 1]
-} {456 45 0 boolean}
-test obj-13.5 {SetBooleanFromAny, error parsing string} {
- set result ""
- lappend result [teststringobj set 1 abc]
- lappend result [catch {testbooleanobj not 1} msg]
- lappend result $msg
-} {abc 1 {expected boolean value but got "abc"}}
-test obj-13.6 {SetBooleanFromAny, error parsing string} {
- set result ""
- lappend result [teststringobj set 1 x1.0]
- lappend result [catch {testbooleanobj not 1} msg]
- lappend result $msg
-} {x1.0 1 {expected boolean value but got "x1.0"}}
-test obj-13.7 {SetBooleanFromAny, error converting from "empty string"} {
- set result ""
- lappend result [testobj newobj 1]
- lappend result [catch {testbooleanobj not 1} msg]
- lappend result $msg
-} {{} 1 {expected boolean value but got ""}}
-test obj-13.8 {SetBooleanFromAny, unicode strings} {
- set result ""
- lappend result [teststringobj set 1 1\u7777]
- lappend result [catch {testbooleanobj not 1} msg]
- lappend result $msg
-} "1\u7777 1 {expected boolean value but got \"1\u7777\"}"
-
-test obj-14.1 {UpdateStringOfBoolean} {
- set result ""
- lappend result [testbooleanobj set 1 0]
- lappend result [testbooleanobj not 1]
- lappend result [testbooleanobj get 1] ;# must update string rep
-} {0 1 1}
-
-test obj-15.1 {Tcl_NewDoubleObj} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testdoubleobj set 1 3.1459]
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} 3.1459 double 2}
-
-test obj-16.1 {Tcl_SetDoubleObj, existing "empty string" object} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testobj newobj 1]
- lappend result [testdoubleobj set 1 0.123] ;# makes existing obj boolean
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} {} 0.123 double 2}
-test obj-16.2 {Tcl_SetDoubleObj, existing non-"empty string" object} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testintobj set 1 98765]
- lappend result [testdoubleobj set 1 27.56] ;# makes existing obj double
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} 98765 27.56 double 2}
-
-test obj-17.1 {Tcl_GetDoubleFromObj, existing double object} {
- set result ""
- lappend result [testdoubleobj set 1 16.1]
- lappend result [testdoubleobj mult10 1] ;# gets existing double rep
-} {16.1 161.0}
-test obj-17.2 {Tcl_GetDoubleFromObj, convert to double} {
- set result ""
- lappend result [testintobj set 1 477]
- lappend result [testdoubleobj div10 1] ;# must convert to bool
- lappend result [testobj type 1]
-} {477 47.7 double}
-test obj-17.3 {Tcl_GetDoubleFromObj, error converting to double} {
- set result ""
- lappend result [teststringobj set 1 abc]
- lappend result [catch {testdoubleobj mult10 1} msg]
- lappend result $msg
-} {abc 1 {expected floating-point number but got "abc"}}
-test obj-17.4 {Tcl_GetDoubleFromObj, error converting from "empty string"} {
- set result ""
- lappend result [testobj newobj 1]
- lappend result [catch {testdoubleobj div10 1} msg]
- lappend result $msg
-} {{} 1 {expected floating-point number but got ""}}
-
-test obj-18.1 {DupDoubleInternalRep} {
- set result ""
- lappend result [testdoubleobj set 1 17.1]
- lappend result [testobj duplicate 1 2] ;# uses DupDoubleInternalRep
- lappend result [testdoubleobj get 2]
-} {17.1 17.1 17.1}
-
-test obj-19.1 {SetDoubleFromAny, int to double special case} {
- set result ""
- lappend result [testintobj set 1 1234]
- lappend result [testdoubleobj mult10 1] ;# converts with SetDoubleFromAny
- lappend result [testobj type 1]
-} {1234 12340.0 double}
-test obj-19.2 {SetDoubleFromAny, boolean to double special case} {
- set result ""
- lappend result [testbooleanobj set 1 1]
- lappend result [testdoubleobj mult10 1] ;# converts with SetDoubleFromAny
- lappend result [testobj type 1]
-} {1 10.0 double}
-test obj-19.3 {SetDoubleFromAny, recompute string rep then parse it} {
- set result ""
- lappend result [testintobj set 1 456]
- lappend result [testintobj div10 1]
- lappend result [testdoubleobj mult10 1] ;# converts with SetDoubleFromAny
- lappend result [testobj type 1]
-} {456 45 450.0 double}
-test obj-19.4 {SetDoubleFromAny, error parsing string} {
- set result ""
- lappend result [teststringobj set 1 abc]
- lappend result [catch {testdoubleobj mult10 1} msg]
- lappend result $msg
-} {abc 1 {expected floating-point number but got "abc"}}
-test obj-19.5 {SetDoubleFromAny, error parsing string} {
- set result ""
- lappend result [teststringobj set 1 x1.0]
- lappend result [catch {testdoubleobj mult10 1} msg]
- lappend result $msg
-} {x1.0 1 {expected floating-point number but got "x1.0"}}
-test obj-19.6 {SetDoubleFromAny, error converting from "empty string"} {
- set result ""
- lappend result [testobj newobj 1]
- lappend result [catch {testdoubleobj div10 1} msg]
- lappend result $msg
-} {{} 1 {expected floating-point number but got ""}}
-
-test obj-20.1 {UpdateStringOfDouble} {
- set result ""
- lappend result [testdoubleobj set 1 3.14159]
- lappend result [testdoubleobj mult10 1]
- lappend result [testdoubleobj get 1] ;# must update string rep
-} {3.14159 31.4159 31.4159}
-
-test obj-21.1 {Tcl_NewIntObj} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testintobj set 1 55]
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} 55 int 2}
-
-test obj-22.1 {Tcl_SetIntObj, existing "empty string" object} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testobj newobj 1]
- lappend result [testintobj set 1 77] ;# makes existing obj int
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} {} 77 int 2}
-test obj-22.2 {Tcl_SetIntObj, existing non-"empty string" object} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testdoubleobj set 1 12.34]
- lappend result [testintobj set 1 77] ;# makes existing obj int
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} 12.34 77 int 2}
-
-test obj-23.1 {Tcl_GetIntFromObj, existing int object} {
- set result ""
- lappend result [testintobj set 1 22]
- lappend result [testintobj mult10 1] ;# gets existing int rep
-} {22 220}
-test obj-23.2 {Tcl_GetIntFromObj, convert to int} {
- set result ""
- lappend result [testintobj set 1 477]
- lappend result [testintobj div10 1] ;# must convert to bool
- lappend result [testobj type 1]
-} {477 47 int}
-test obj-23.3 {Tcl_GetIntFromObj, error converting to int} {
- set result ""
- lappend result [teststringobj set 1 abc]
- lappend result [catch {testintobj mult10 1} msg]
- lappend result $msg
-} {abc 1 {expected integer but got "abc"}}
-test obj-23.4 {Tcl_GetIntFromObj, error converting from "empty string"} {
- set result ""
- lappend result [testobj newobj 1]
- lappend result [catch {testintobj div10 1} msg]
- lappend result $msg
-} {{} 1 {expected integer but got ""}}
-test obj-23.5 {Tcl_GetIntFromObj, integer too large to represent as non-long error} {nonPortable} {
- set result ""
- lappend result [testobj newobj 1]
- lappend result [testintobj inttoobigtest 1]
-} {{} 1}
-
-test obj-24.1 {DupIntInternalRep} {
- set result ""
- lappend result [testintobj set 1 23]
- lappend result [testobj duplicate 1 2] ;# uses DupIntInternalRep
- lappend result [testintobj get 2]
-} {23 23 23}
-
-test obj-25.1 {SetIntFromAny, int to int special case} {
- set result ""
- lappend result [testintobj set 1 1234]
- lappend result [testintobj mult10 1] ;# converts with SetIntFromAny
- lappend result [testobj type 1]
-} {1234 12340 int}
-test obj-25.2 {SetIntFromAny, boolean to int special case} {
- set result ""
- lappend result [testbooleanobj set 1 1]
- lappend result [testintobj mult10 1] ;# converts with SetIntFromAny
- lappend result [testobj type 1]
-} {1 10 int}
-test obj-25.3 {SetIntFromAny, recompute string rep then parse it} {
- set result ""
- lappend result [testintobj set 1 456]
- lappend result [testintobj div10 1]
- lappend result [testintobj mult10 1] ;# converts with SetIntFromAny
- lappend result [testobj type 1]
-} {456 45 450 int}
-test obj-25.4 {SetIntFromAny, error parsing string} {
- set result ""
- lappend result [teststringobj set 1 abc]
- lappend result [catch {testintobj mult10 1} msg]
- lappend result $msg
-} {abc 1 {expected integer but got "abc"}}
-test obj-25.5 {SetIntFromAny, error parsing string} {
- set result ""
- lappend result [teststringobj set 1 x17]
- lappend result [catch {testintobj mult10 1} msg]
- lappend result $msg
-} {x17 1 {expected integer but got "x17"}}
-test obj-25.6 {SetIntFromAny, integer too large} {nonPortable} {
- set result ""
- lappend result [teststringobj set 1 123456789012345678901]
- lappend result [catch {testintobj mult10 1} msg]
- lappend result $msg
-} {123456789012345678901 1 {integer value too large to represent}}
-test obj-25.7 {SetIntFromAny, error converting from "empty string"} {
- set result ""
- lappend result [testobj newobj 1]
- lappend result [catch {testintobj div10 1} msg]
- lappend result $msg
-} {{} 1 {expected integer but got ""}}
-
-test obj-26.1 {UpdateStringOfInt} {
- set result ""
- lappend result [testintobj set 1 512]
- lappend result [testintobj mult10 1]
- lappend result [testintobj get 1] ;# must update string rep
-} {512 5120 5120}
-
-test obj-27.1 {Tcl_NewLongObj} {
- set result ""
- lappend result [testobj freeallvars]
- testintobj setmaxlong 1
- lappend result [testintobj ismaxlong 1]
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} 1 int 1}
-
-test obj-28.1 {Tcl_SetLongObj, existing "empty string" object} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testobj newobj 1]
- lappend result [testintobj setlong 1 77] ;# makes existing obj long int
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} {} 77 int 2}
-test obj-28.2 {Tcl_SetLongObj, existing non-"empty string" object} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testdoubleobj set 1 12.34]
- lappend result [testintobj setlong 1 77] ;# makes existing obj long int
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} 12.34 77 int 2}
-
-test obj-29.1 {Tcl_GetLongFromObj, existing long integer object} {
- set result ""
- lappend result [testintobj setlong 1 22]
- lappend result [testintobj mult10 1] ;# gets existing long int rep
-} {22 220}
-test obj-29.2 {Tcl_GetLongFromObj, convert to long} {
- set result ""
- lappend result [testintobj setlong 1 477]
- lappend result [testintobj div10 1] ;# must convert to bool
- lappend result [testobj type 1]
-} {477 47 int}
-test obj-29.3 {Tcl_GetLongFromObj, error converting to long integer} {
- set result ""
- lappend result [teststringobj set 1 abc]
- lappend result [catch {testintobj ismaxlong 1} msg] ;# cvts to long int
- lappend result $msg
-} {abc 1 {expected integer but got "abc"}}
-test obj-29.4 {Tcl_GetLongFromObj, error converting from "empty string"} {
- set result ""
- lappend result [testobj newobj 1]
- lappend result [catch {testintobj ismaxlong 1} msg] ;# cvts to long int
- lappend result $msg
-} {{} 1 {expected integer but got ""}}
-
-test obj-30.1 {Ref counting and object deletion, simple types} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testintobj set 1 1024]
- lappend result [testobj assign 1 2] ;# vars 1 and 2 share the int obj
- lappend result [testobj type 2]
- lappend result [testobj refcount 1]
- lappend result [testobj refcount 2]
- lappend result [testbooleanobj set 2 0] ;# must copy on write, now 2 objs
- lappend result [testobj type 2]
- lappend result [testobj refcount 1]
- lappend result [testobj refcount 2]
-} {{} 1024 1024 int 4 4 0 boolean 3 2}
-
-testobj freeallvars
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/opt.test b/tests/opt.test
deleted file mode 100644
index 3ca62f2..0000000
--- a/tests/opt.test
+++ /dev/null
@@ -1,290 +0,0 @@
-# Package covered: opt1.0/optparse.tcl
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-1997 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: opt.test,v 1.4 1999/04/16 00:47:31 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# the package we are going to test
-package require opt 0.4.1
-
-# we are using implementation specifics to test the package
-
-
-#### functions tests #####
-
-set n $::tcl::OptDescN
-
-test opt-1.1 {OptKeyRegister / check that auto allocation is skipping existing keys} {
- list [::tcl::OptKeyRegister {} $n] [::tcl::OptKeyRegister {} [expr $n+1]] [::tcl::OptKeyRegister {}]
-} "$n [expr $n+1] [expr $n+2]"
-
-test opt-2.1 {OptKeyDelete} {
- list [::tcl::OptKeyRegister {} testkey] [::tcl::OptKeyDelete testkey] \
- [catch {::tcl::OptKeyDelete testkey} msg] $msg;
-} {testkey {} 1 {can't unset "OptDesc(testkey)": no such element in array}}
-
-
-test opt-3.1 {OptParse / temp key is removed} {
- set n $::tcl::OptDescN
- set prev [array names ::tcl::OptDesc]
- ::tcl::OptKeyRegister {} $n
- list [info exists ::tcl::OptDesc($n)]\
- [::tcl::OptKeyDelete $n]\
- [::tcl::OptParse {{-foo}} {}]\
- [info exists ::tcl::OptDesc($n)]\
- [expr {"[lsort $prev]"=="[lsort [array names ::tcl::OptDesc]]"}]
-} {1 {} {} 0 1}
-
-
-test opt-3.2 {OptParse / temp key is removed even on errors} {
- set n $::tcl::OptDescN
- catch {::tcl::OptKeyDelete $n}
- list [catch {::tcl::OptParse {{-foo}} {-blah}}] \
- [info exists ::tcl::OptDesc($n)]
-} {1 0}
-
-test opt-4.1 {OptProc} {
- ::tcl::OptProc optTest {} {}
- optTest ;
- ::tcl::OptKeyDelete optTest
-} {}
-
-
-test opt-5.1 {OptProcArgGiven} {
- ::tcl::OptProc optTest {{-foo}} {
- if {[::tcl::OptProcArgGiven "-foo"]} {
- return 1
- } else {
- return 0
- }
- }
- list [optTest] [optTest -f] [optTest -F] [optTest -fOO]
-} {0 1 1 1}
-
-test opt-6.1 {OptKeyParse} {
- ::tcl::OptKeyRegister {} test;
- list [catch {::tcl::OptKeyParse test {-help}} msg] $msg
-} {1 {Usage information:
- Var/FlagName Type Value Help
- ------------ ---- ----- ----
- ( -help gives this help )}}
-
-
-test opt-7.1 {OptCheckType} {
- list \
- [::tcl::OptCheckType 23 int] \
- [::tcl::OptCheckType 23 float] \
- [::tcl::OptCheckType true boolean] \
- [::tcl::OptCheckType "-blah" any] \
- [::tcl::OptCheckType {a b c} list] \
- [::tcl::OptCheckType maYbe choice {yes maYbe no}] \
- [catch {::tcl::OptCheckType "-blah" string}] \
- [catch {::tcl::OptCheckType 6 boolean}] \
- [catch {::tcl::OptCheckType x float}] \
- [catch {::tcl::OptCheckType "a \{ c" list}] \
- [catch {::tcl::OptCheckType 2.3 int}] \
- [catch {::tcl::OptCheckType foo choice {x y Foo z}}]
-} {23 23.0 1 -blah {a b c} maYbe 1 1 1 1 1 1}
-
-
-test opt-8.1 {List utilities} {
- ::tcl::Lempty {}
-} 1
-test opt-8.2 {List utilities} {
- ::tcl::Lempty {a b c}
-} 0
-test opt-8.3 {List utilities} {
- ::tcl::Lget {a {b c d} e} {1 2}
-} d
-
-test opt-8.4 {List utilities} {
- set l {a {b c d e} f}
- ::tcl::Lvarset l {1 2} D
- set l
-} {a {b c D e} f}
-
-test opt-8.5 {List utilities} {
- set l {a b c}
- ::tcl::Lvarset1 l 6 X
- set l
-} {a b c {} {} {} X}
-
-test opt-8.6 {List utilities} {
- set l {a {b c 7 e} f}
- ::tcl::Lvarincr l {1 2}
- set l
-} {a {b c 8 e} f}
-
-test opt-8.7 {List utilities} {
- set l {a {b c 7 e} f}
- ::tcl::Lvarincr l {1 2} -9
- set l
-} {a {b c -2 e} f}
-
-test opt-8.8 {List utilities} {
- set l {{b c 7 e} f}
- ::tcl::Lfirst $l
-} {b c 7 e}
-
-
-test opt-8.9 {List utilities} {
- set l {a {b c 7 e} f}
- ::tcl::Lrest $l
-} {{b c 7 e} f}
-
-test opt-8.10 {List utilities} {
- set l {a {b c 7 e} f}
- ::tcl::Lvarpop l
- set l
-} {{b c 7 e} f}
-
-test opt-8.11 {List utilities} {
- catch {unset x}
- set l {a {b c 7 e} f}
- list [::tcl::Lassign $l u v w x] \
- $u $v $w [info exists x]
-} {3 a {b c 7 e} f 0}
-
-test opt-9.1 {Misc utilities} {
- catch {unset v}
- ::tcl::SetMax v 3
- ::tcl::SetMax v 7
- ::tcl::SetMax v 6
- set v
-} 7
-
-test opt-9.2 {Misc utilities} {
- catch {unset v}
- ::tcl::SetMin v 3
- ::tcl::SetMin v -7
- ::tcl::SetMin v 1
- set v
-} -7
-
-#### behaviour tests #####
-
-test opt-10.1 {ambigous flags} {
- ::tcl::OptProc optTest {{-fla} {-other} {-flag2xyz} {-flag3xyz}} {}
- catch {optTest -fL} msg
- set msg
-} {ambigous option "-fL", choose from:
- -fla boolflag (false)
- -flag2xyz boolflag (false)
- -flag3xyz boolflag (false) }
-
-test opt-10.2 {non ambigous flags} {
- ::tcl::OptProc optTest {{-flag1xyz} {-other} {-flag2xyz} {-flag3xyz}} {
- return $flag2xyz
- }
- optTest -fLaG2
-} 1
-
-test opt-10.3 {non ambigous flags because of exact match} {
- ::tcl::OptProc optTest {{-flag1x} {-other} {-flag1} {-flag1xy}} {
- return $flag1
- }
- optTest -flAg1
-} 1
-
-test opt-10.4 {ambigous flags, not exact match} {
- ::tcl::OptProc optTest {{-flag1xy} {-other} {-flag1} {-flag1xyz}} {
- return $flag1
- }
- catch {optTest -fLag1X} msg
- set msg
-} {ambigous option "-fLag1X", choose from:
- -flag1xy boolflag (false)
- -flag1xyz boolflag (false) }
-
-
-
-# medium size overall test example: (defined once)
-::tcl::OptProc optTest {
- {cmd -choice {print save delete} "sub command to choose"}
- {-allowBoing -boolean true}
- {arg2 -string "this is help"}
- {?arg3? 7 "optional number"}
- {-moreflags}
-} {
- list $cmd $allowBoing $arg2 $arg3 $moreflags
-}
-
-test opt-10.5 {medium size overall test} {
- list [catch {optTest} msg] $msg
-} {1 {no value given for parameter "cmd" (use -help for full usage) :
- cmd choice (print save delete) sub command to choose}}
-
-
-test opt-10.6 {medium size overall test} {
- list [catch {optTest -help} msg] $msg
-} {1 {Usage information:
- Var/FlagName Type Value Help
- ------------ ---- ----- ----
- ( -help gives this help )
- cmd choice (print save delete) sub command to choose
- -allowBoing boolean (true)
- arg2 string () this is help
- ?arg3? int (7) optional number
- -moreflags boolflag (false) }}
-
-test opt-10.7 {medium size overall test} {
- optTest save tst
-} {save 1 tst 7 0}
-
-test opt-10.8 {medium size overall test} {
- optTest save -allowBoing false -- 8
-} {save 0 8 7 0}
-
-test opt-10.9 {medium size overall test} {
- optTest save tst -m --
-} {save 1 tst 7 1}
-
-test opt-10.10 {medium size overall test} {
- list [catch {optTest save tst foo} msg] [lindex [split $msg "\n"] 0]
-} {1 {too many arguments (unexpected argument(s): foo), usage:}}
-
-test opt-11.1 {too many args test 2} {
- set key [::tcl::OptKeyRegister {-foo}]
- list [catch {::tcl::OptKeyParse $key {-foo blah}} msg] $msg\
- [::tcl::OptKeyDelete $key]
-} {1 {too many arguments (unexpected argument(s): blah), usage:
- Var/FlagName Type Value Help
- ------------ ---- ----- ----
- ( -help gives this help )
- -foo boolflag (false) } {}}
-test opt-11.2 {default value for args} {
- set args {}
- set key [::tcl::OptKeyRegister {{args -list {a b c} "args..."}}]
- ::tcl::OptKeyParse $key {}
- ::tcl::OptKeyDelete $key
- set args
-} {a b c}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/osa.test b/tests/osa.test
deleted file mode 100644
index 4b061cf..0000000
--- a/tests/osa.test
+++ /dev/null
@@ -1,47 +0,0 @@
-# Commands covered: AppleScript
-#
-# 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) 1997 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: osa.test,v 1.3 1999/04/16 00:47:31 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Only run the test if we can load the AppleScript command
-set ::tcltest::testConfig(appleScript) [expr {[info commands AppleScript] != ""}]
-
-test osa-1.1 {Tcl_OSAComponentCmd} {macOnly appleScript} {
- list [catch AppleScript msg] $msg
-} {1 {wrong # args: should be "AppleScript option ?arg ...?"}}
-test osa-1.2 {Tcl_OSAComponentCmd} {macOnly appleScript} {
- list [catch {AppleScript x} msg] $msg
-} {1 {bad option "x": should be compile, decompile, delete, execute, info, load, run or store}}
-
-test osa-1.3 {TclOSACompileCmd} {macOnly appleScript} {
- list [catch {AppleScript compile} msg] $msg
-} {1 {wrong # args: should be "AppleScript compile ?options? code"}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/parse.test b/tests/parse.test
deleted file mode 100644
index 1f36063..0000000
--- a/tests/parse.test
+++ /dev/null
@@ -1,743 +0,0 @@
-# This file contains a collection of tests for the procedures in the
-# file tclParse.c. Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-#
-# Copyright (c) 1997 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: parse.test,v 1.3 1999/04/16 00:47:31 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[info commands testparser] == {}} {
- puts "This application hasn't been compiled with the \"testparser\""
- puts "command, so I can't test the Tcl parser."
- ::tcltest::cleanupTests
- return
-}
-
-test parse-1.1 {Tcl_ParseCommand procedure, computing string length} {
- testparser [bytestring "foo\0 bar"] -1
-} {- foo 1 simple foo 1 text foo 0 {}}
-test parse-1.2 {Tcl_ParseCommand procedure, computing string length} {
- testparser "foo bar" -1
-} {- {foo bar} 2 simple foo 1 text foo 0 simple bar 1 text bar 0 {}}
-test parse-1.3 {Tcl_ParseCommand procedure, leading space} {
- testparser " \n\t foo" 0
-} {- foo 1 simple foo 1 text foo 0 {}}
-test parse-1.4 {Tcl_ParseCommand procedure, leading space} {
- testparser "\f\r\vfoo" 0
-} {- foo 1 simple foo 1 text foo 0 {}}
-test parse-1.5 {Tcl_ParseCommand procedure, backslash-newline in leading space} {
- testparser " \\\n foo" 0
-} {- foo 1 simple foo 1 text foo 0 {}}
-test parse-1.6 {Tcl_ParseCommand procedure, backslash-newline in leading space} {
- testparser { \a foo} 0
-} {- {\a foo} 2 word {\a} 1 backslash {\a} 0 simple foo 1 text foo 0 {}}
-test parse-1.7 {Tcl_ParseCommand procedure, missing continuation line in leading space} {
- testparser " \\\n" 0
-} {- {} 0 {}}
-test parse-1.8 {Tcl_ParseCommand procedure, eof in leading space} {
- testparser " foo" 3
-} {- {} 0 { foo}}
-
-test parse-2.1 {Tcl_ParseCommand procedure, comments} {
- testparser "# foo bar\n foo" 0
-} {{# foo bar
-} foo 1 simple foo 1 text foo 0 {}}
-test parse-2.2 {Tcl_ParseCommand procedure, several comments} {
- testparser " # foo bar\n # another comment\n\n foo" 0
-} {{# foo bar
- # another comment
-} foo 1 simple foo 1 text foo 0 {}}
-test parse-2.3 {Tcl_ParseCommand procedure, backslash-newline in comments} {
- testparser " # foo bar\\\ncomment on continuation line\nfoo" 0
-} {#\ foo\ bar\\\ncomment\ on\ continuation\ line\n foo 1 simple foo 1 text foo 0 {}}
-test parse-2.4 {Tcl_ParseCommand procedure, missing continuation line in comment} {
- testparser "# \\\n" 0
-} {#\ \ \ \\\n {} 0 {}}
-test parse-2.5 {Tcl_ParseCommand procedure, eof in comment} {
- testparser " # foo bar\nfoo" 8
-} {{# foo b} {} 0 {ar
-foo}}
-
-test parse-3.1 {Tcl_ParseCommand procedure, parsing words, skipping space} {
- testparser "foo bar\t\tx" 0
-} {- {foo bar x} 3 simple foo 1 text foo 0 simple bar 1 text bar 0 simple x 1 text x 0 {}}
-test parse-3.2 {Tcl_ParseCommand procedure, missing continuation line in leading space} {
- testparser "abc \\\n" 0
-} {- abc\ \ \\\n 1 simple abc 1 text abc 0 {}}
-test parse-3.3 {Tcl_ParseCommand procedure, parsing words, command ends in space} {
- testparser "foo ; bar x" 0
-} {- {foo ;} 1 simple foo 1 text foo 0 { bar x}}
-test parse-3.4 {Tcl_ParseCommand procedure, parsing words, command ends in space} {
- testparser "foo " 5
-} {- {foo } 1 simple foo 1 text foo 0 { }}
-test parse-3.5 {Tcl_ParseCommand procedure, quoted words} {
- testparser {foo "a b c" d "efg";} 0
-} {- {foo "a b c" d "efg";} 4 simple foo 1 text foo 0 simple {"a b c"} 1 text {a b c} 0 simple d 1 text d 0 simple {"efg"} 1 text efg 0 {}}
-test parse-3.6 {Tcl_ParseCommand procedure, words in braces} {
- testparser {foo {a $b [concat foo]} {c d}} 0
-} {- {foo {a $b [concat foo]} {c d}} 3 simple foo 1 text foo 0 simple {{a $b [concat foo]}} 1 text {a $b [concat foo]} 0 simple {{c d}} 1 text {c d} 0 {}}
-test parse-3.7 {Tcl_ParseCommand procedure, error in unquoted word} {
- list [catch {testparser "foo \$\{abc" 0} msg] $msg $errorInfo
-} {1 {missing close-brace for variable name} missing\ close-brace\ for\ variable\ name\n\ \ \ \ (remainder\ of\ script:\ \"\{abc\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"foo\ \\\$\\\{abc\"\ 0\"}
-
-test parse-4.1 {Tcl_ParseCommand procedure, simple words} {
- testparser {foo} 0
-} {- foo 1 simple foo 1 text foo 0 {}}
-test parse-4.2 {Tcl_ParseCommand procedure, simple words} {
- testparser {{abc}} 0
-} {- {{abc}} 1 simple {{abc}} 1 text abc 0 {}}
-test parse-4.3 {Tcl_ParseCommand procedure, simple words} {
- testparser {"c d"} 0
-} {- {"c d"} 1 simple {"c d"} 1 text {c d} 0 {}}
-test parse-4.4 {Tcl_ParseCommand procedure, simple words} {
- testparser {x$d} 0
-} {- {x$d} 1 word {x$d} 3 text x 0 variable {$d} 1 text d 0 {}}
-test parse-4.5 {Tcl_ParseCommand procedure, simple words} {
- testparser {"a [foo] b"} 0
-} {- {"a [foo] b"} 1 word {"a [foo] b"} 3 text {a } 0 command {[foo]} 0 text { b} 0 {}}
-test parse-4.6 {Tcl_ParseCommand procedure, simple words} {
- testparser {$x} 0
-} {- {$x} 1 word {$x} 2 variable {$x} 1 text x 0 {}}
-
-test parse-5.1 {Tcl_ParseCommand procedure, backslash-newline terminates word} {
- testparser "{abc}\\\n" 0
-} {- \{abc\}\\\n 1 simple {{abc}} 1 text abc 0 {}}
-test parse-5.2 {Tcl_ParseCommand procedure, backslash-newline terminates word} {
- testparser "foo\\\nbar" 0
-} {- foo\\\nbar 2 simple foo 1 text foo 0 simple bar 1 text bar 0 {}}
-test parse-5.3 {Tcl_ParseCommand procedure, word terminator is command terminator} {
- testparser "foo\n bar" 0
-} {- {foo
-} 1 simple foo 1 text foo 0 { bar}}
-test parse-5.4 {Tcl_ParseCommand procedure, word terminator is command terminator} {
- testparser "foo; bar" 0
-} {- {foo;} 1 simple foo 1 text foo 0 { bar}}
-test parse-5.5 {Tcl_ParseCommand procedure, word terminator is end of string} {
- testparser "\"foo\" bar" 5
-} {- {"foo"} 1 simple {"foo"} 1 text foo 0 { bar}}
-test parse-5.6 {Tcl_ParseCommand procedure, junk after close quote} {
- list [catch {testparser {foo "bar"x} 0} msg] $msg $errorInfo
-} {1 {extra characters after close-quote} {extra characters after close-quote
- (remainder of script: "x")
- invoked from within
-"testparser {foo "bar"x} 0"}}
-test parse-5.7 {Tcl_ParseCommand procedure, backslash-newline after close quote} {
- testparser "foo \"bar\"\\\nx" 0
-} {- foo\ \"bar\"\\\nx 3 simple foo 1 text foo 0 simple {"bar"} 1 text bar 0 simple x 1 text x 0 {}}
-test parse-5.8 {Tcl_ParseCommand procedure, junk after close brace} {
- list [catch {testparser {foo {bar}x} 0} msg] $msg $errorInfo
-} {1 {extra characters after close-brace} {extra characters after close-brace
- (remainder of script: "x")
- invoked from within
-"testparser {foo {bar}x} 0"}}
-test parse-5.9 {Tcl_ParseCommand procedure, backslash-newline after close brace} {
- testparser "foo {bar}\\\nx" 0
-} {- foo\ \{bar\}\\\nx 3 simple foo 1 text foo 0 simple {{bar}} 1 text bar 0 simple x 1 text x 0 {}}
-test parse-5.10 {Tcl_ParseCommand procedure, multiple deletion of non-static buffer} {
- # This test is designed to catch bug 1681.
- list [catch {testparser "a \"\\1\\2\\3\\4\\5\\6\\7\\8\\9\\1\\2\\3\\4\\5\\6\\7\\8" 0} msg] $msg $errorInfo
-} "1 {missing \"} {missing \"
- (remainder of script: \"\"\\1\\2\\3\\4\\5\\6\\7\\8\\9\\1\\2\\3\\4\\5\\6\\7\\8\")
- invoked from within
-\"testparser \"a \\\"\\\\1\\\\2\\\\3\\\\4\\\\5\\\\6\\\\7\\\\8\\\\9\\\\1\\\\2\\\\3\\\\4\\\\5\\\\6\\\\7\\\\8\" 0\"}"
-
-test parse-6.1 {ParseTokens procedure, empty word} {
- testparser {""} 0
-} {- {""} 1 simple {""} 1 text {} 0 {}}
-test parse-6.2 {ParseTokens procedure, simple range} {
- testparser {"abc$x.e"} 0
-} {- {"abc$x.e"} 1 word {"abc$x.e"} 4 text abc 0 variable {$x} 1 text x 0 text .e 0 {}}
-test parse-6.3 {ParseTokens procedure, variable reference} {
- testparser {abc$x.e $y(z)} 0
-} {- {abc$x.e $y(z)} 2 word {abc$x.e} 4 text abc 0 variable {$x} 1 text x 0 text .e 0 word {$y(z)} 3 variable {$y(z)} 2 text y 0 text z 0 {}}
-test parse-6.4 {ParseTokens procedure, variable reference} {
- list [catch {testparser {$x([a )} 0} msg] $msg
-} {1 {missing close-bracket}}
-test parse-6.5 {ParseTokens procedure, command substitution} {
- testparser {[foo $x bar]z} 0
-} {- {[foo $x bar]z} 1 word {[foo $x bar]z} 2 command {[foo $x bar]} 0 text z 0 {}}
-test parse-6.6 {ParseTokens procedure, command substitution} {
- testparser {[foo \] [a b]]} 0
-} {- {[foo \] [a b]]} 1 word {[foo \] [a b]]} 1 command {[foo \] [a b]]} 0 {}}
-test parse-6.7 {ParseTokens procedure, error in command substitution} {
- list [catch {testparser {a [b {}c d] e} 0} msg] $msg $errorInfo
-} {1 {extra characters after close-brace} {extra characters after close-brace
- (remainder of script: "c d] e")
- invoked from within
-"testparser {a [b {}c d] e} 0"}}
-test parse-6.8 {ParseTokens procedure, error in command substitution} {
- info complete {a [b {}c d]}
-} {1}
-test parse-6.9 {ParseTokens procedure, error in command substitution} {
- info complete {a [b "c d}
-} {0}
-test parse-6.10 {ParseTokens procedure, incomplete sub-command} {
- info complete {puts [
- expr 1+1
- #this is a comment ]}
-} {0}
-test parse-6.11 {ParseTokens procedure, memory allocation for big nested command} {
- testparser {[$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b)]} 0
-} {- {[$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b)]} 1 word {[$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b)]} 1 command {[$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b)]} 0 {}}
-test parse-6.12 {ParseTokens procedure, missing close bracket} {
- list [catch {testparser {[foo $x bar} 0} msg] $msg $errorInfo
-} {1 {missing close-bracket} {missing close-bracket
- (remainder of script: "[foo $x bar")
- invoked from within
-"testparser {[foo $x bar} 0"}}
-test parse-6.13 {ParseTokens procedure, backslash-newline without continuation line} {
- list [catch {testparser "\"a b\\\n" 0} msg] $msg $errorInfo
-} {1 {missing "} missing\ \"\n\ \ \ \ (remainder\ of\ script:\ \"\"a\ b\\\n\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"\\\"a\ b\\\\\\n\"\ 0\"}
-test parse-6.14 {ParseTokens procedure, backslash-newline} {
- testparser "b\\\nc" 0
-} {- b\\\nc 2 simple b 1 text b 0 simple c 1 text c 0 {}}
-test parse-6.15 {ParseTokens procedure, backslash-newline} {
- testparser "\"b\\\nc\"" 0
-} {- \"b\\\nc\" 1 word \"b\\\nc\" 3 text b 0 backslash \\\n 0 text c 0 {}}
-test parse-6.16 {ParseTokens procedure, backslash substitution} {
- testparser {\n\a\x7f} 0
-} {- {\n\a\x7f} 1 word {\n\a\x7f} 3 backslash {\n} 0 backslash {\a} 0 backslash {\x7f} 0 {}}
-test parse-6.17 {ParseTokens procedure, null characters} {
- testparser [bytestring "foo\0zz"] 0
-} "- [bytestring foo\0zz] 1 word [bytestring foo\0zz] 3 text foo 0 text [bytestring \0] 0 text zz 0 {}"
-
-test parse-7.1 {Tcl_FreeParse and ExpandTokenArray procedures} {
- testparser {$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) } 0
-} {- {$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) } 16 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 {}}
-
-test parse-8.1 {Tcl_EvalObjv procedure} {
- testevalobjv 0 concat this is a test
-} {this is a test}
-test parse-8.2 {Tcl_EvalObjv procedure, unknown commands} {
- rename unknown unknown.old
- set x [catch {testevalobjv 10 asdf poiu} msg]
- rename unknown.old unknown
- list $x $msg
-} {1 {invalid command name "asdf"}}
-test parse-8.3 {Tcl_EvalObjv procedure, unknown commands} {
- rename unknown unknown.old
- proc unknown args {
- return "unknown $args"
- }
- set x [catch {testevalobjv 0 asdf poiu} msg]
- rename unknown {}
- rename unknown.old unknown
- list $x $msg
-} {0 {unknown asdf poiu}}
-test parse-8.4 {Tcl_EvalObjv procedure, unknown commands} {
- rename unknown unknown.old
- proc unknown args {
- error "I don't like that command"
- }
- set x [catch {testevalobjv 0 asdf poiu} msg]
- rename unknown {}
- rename unknown.old unknown
- list $x $msg
-} {1 {I don't like that command}}
-test parse-8.5 {Tcl_EvalObjv procedure, command traces} {
- testevalobjv 0 set x 123
- testcmdtrace tracetest {testevalobjv 0 set x $x}
-} {{testevalobjv 0 set x $x} {testevalobjv 0 set x 123} {set x 123} {set x 123}}
-test parse-8.7 {Tcl_EvalObjv procedure, TCL_EVAL_GLOBAL flag} {
- proc x {} {
- set y 23
- set z [testevalobjv 1 set y]
- return [list $z $y]
- }
- catch {unset y}
- set y 16
- x
-} {16 23}
-test parse-8.8 {Tcl_EvalObjv procedure, async handlers} {
- proc async1 {result code} {
- global aresult acode
- set aresult $result
- set acode $code
- return "new result"
- }
- set handler1 [testasync create async1]
- set aresult xxx
- set acode yyy
- set x [list [catch [list testevalobjv 0 testasync mark $handler1 original 0] msg] $msg $acode $aresult]
- testasync delete
- set x
-} {0 {new result} 0 original}
-test parse-8.9 {Tcl_EvalObjv procedure, exceptional return} {
- list [catch {testevalobjv 0 error message} msg] $msg
-} {1 message}
-
-test parse-9.1 {Tcl_LogCommandInfo, line numbers} {
- catch {unset x}
- list [catch {testevalex {for {} 1 {} {
-
-
- # asdf
- set x
- }}}] $errorInfo
-} {1 {can't read "x": no such variable
- while executing
-"set x"
- ("for" body line 5)
- invoked from within
-"for {} 1 {} {
-
-
- # asdf
- set x
- }"
- invoked from within
-"testevalex {for {} 1 {} {
-
-
- # asdf
- set x
- }}"}}
-test parse-9.2 {Tcl_LogCommandInfo, truncating long commands} {
- list [testevalex {catch {set a b 111111111 222222222 333333333 444444444 555555555 666666666 777777777 888888888 999999999 000000000 aaaaaaaaa bbbbbbbbb ccccccccc ddddddddd eeeeeeeee fffffffff ggggggggg}}] $errorInfo
-} {1 {wrong # args: should be "set varName ?newValue?"
- while executing
-"set a b 111111111 222222222 333333333 444444444 555555555 666666666 777777777 888888888 999999999 000000000 aaaaaaaaa bbbbbbbbb ccccccccc ddddddddd ee..."}}
-
-test parse-10.1 {Tcl_EvalTokens, simple text} {
- testevalex {concat test}
-} {test}
-test parse-10.2 {Tcl_EvalTokens, backslash sequences} {
- testevalex {concat test\063\062test}
-} {test32test}
-test parse-10.3 {Tcl_EvalTokens, nested commands} {
- testevalex {concat [expr 2 + 6]}
-} {8}
-test parse-10.4 {Tcl_EvalTokens, nested commands} {
- catch {unset a}
- list [catch {testevalex {concat xxx[expr $a]}} msg] $msg
-} {1 {can't read "a": no such variable}}
-test parse-10.5 {Tcl_EvalTokens, simple variables} {
- set a hello
- testevalex {concat $a}
-} {hello}
-test parse-10.6 {Tcl_EvalTokens, array variables} {
- catch {unset a}
- set a(12) 46
- testevalex {concat $a(12)}
-} {46}
-test parse-10.7 {Tcl_EvalTokens, array variables} {
- catch {unset a}
- set a(12) 46
- testevalex {concat $a(1[expr 3 - 1])}
-} {46}
-test parse-10.8 {Tcl_EvalTokens, array variables} {
- catch {unset a}
- list [catch {testevalex {concat $x($a)}} msg] $msg
-} {1 {can't read "a": no such variable}}
-test parse-10.9 {Tcl_EvalTokens, array variables} {
- catch {unset a}
- list [catch {testevalex {concat xyz$a(1)}} msg] $msg
-} {1 {can't read "a(1)": no such variable}}
-test parse-10.10 {Tcl_EvalTokens, object values} {
- set a 123
- testevalex {concat $a}
-} {123}
-test parse-10.11 {Tcl_EvalTokens, object values} {
- set a 123
- testevalex {concat $a$a$a}
-} {123123123}
-test parse-10.12 {Tcl_EvalTokens, object values} {
- testevalex {concat [expr 2][expr 4][expr 6]}
-} {246}
-test parse-10.13 {Tcl_EvalTokens, string values} {
- testevalex {concat {a" b"}}
-} {a" b"}
-test parse-10.14 {Tcl_EvalTokens, string values} {
- set a 111
- testevalex {concat x$a.$a.$a}
-} {x111.111.111}
-
-test parse-11.1 {Tcl_Eval2, TCL_EVAL_GLOBAL flag} {
- proc x {} {
- set y 777
- set z [testevalex "set y" global]
- return [list $z $y]
- }
- catch {unset y}
- set y 321
- x
-} {321 777}
-test parse-11.2 {Tcl_Eval2, error while parsing} {
- list [catch {testevalex {concat "abc}} msg] $msg
-} {1 {missing "}}
-test parse-11.3 {Tcl_Eval2, error while collecting words} {
- catch {unset a}
- list [catch {testevalex {concat xyz $a}} msg] $msg
-} {1 {can't read "a": no such variable}}
-test parse-11.4 {Tcl_Eval2, error in Tcl_EvalObjv call} {
- catch {unset a}
- list [catch {testevalex {_bogus_ a b c d}} msg] $msg
-} {1 {invalid command name "_bogus_"}}
-test parse-11.5 {Tcl_Eval2, exceptional return} {
- list [catch {testevalex {break}} msg] $msg
-} {3 {}}
-test parse-11.6 {Tcl_Eval2, freeing memory} {
- testevalex {concat a b c d e f g h i j k l m n o p q r s t u v w x y z}
-} {a b c d e f g h i j k l m n o p q r s t u v w x y z}
-test parse-11.7 {Tcl_Eval2, multiple commands in script} {
- list [testevalex {set a b; set c d}] $a $c
-} {d b d}
-test parse-11.8 {Tcl_Eval2, multiple commands in script} {
- list [testevalex {
- set a b
- set c d
- }] $a $c
-} {d b d}
-test parse-11.9 {Tcl_Eval2, freeing memory after error} {
- catch {unset a}
- list [catch {testevalex {concat a b c d e f g h i j k l m n o p q r s t u v w x y z $a}} msg] $msg
-} {1 {can't read "a": no such variable}}
-test parse-11.10 {Tcl_EvalTokens, empty commands} {
- testevalex {concat xyz; }
-} {xyz}
-test parse-11.11 {Tcl_EvalTokens, empty commands} {
- testevalex "concat abc; ; # this is a comment\n"
-} {abc}
-test parse-11.12 {Tcl_EvalTokens, empty commands} {
- testevalex {}
-} {}
-
-test parse-12.1 {Tcl_ParseVarName procedure, initialization} {
- list [catch {testparsevarname {$a([first second])} 8 0} msg] $msg
-} {1 {missing close-bracket}}
-test parse-12.2 {Tcl_ParseVarName procedure, initialization} {
- testparsevarname {$a([first second])} 0 0
-} {- {} 0 variable {$a([first second])} 2 text a 0 command {[first second]} 0 {}}
-test parse-12.3 {Tcl_ParseVarName procedure, initialization} {
- list [catch {testparsevarname {$abcd} 3 0} msg] $msg
-} {0 {- {} 0 variable {$ab} 1 text ab 0 cd}}
-test parse-12.4 {Tcl_ParseVarName procedure, initialization} {
- testparsevarname {$abcd} 0 0
-} {- {} 0 variable {$abcd} 1 text abcd 0 {}}
-test parse-12.5 {Tcl_ParseVarName procedure, just a dollar sign} {
- testparsevarname {$abcd} 1 0
-} {- {} 0 text {$} 0 abcd}
-test parse-12.6 {Tcl_ParseVarName procedure, braced variable name} {
- testparser {${..[]b}cd} 0
-} {- {${..[]b}cd} 1 word {${..[]b}cd} 3 variable {${..[]b}} 1 text {..[]b} 0 text cd 0 {}}
-test parse-12.7 {Tcl_ParseVarName procedure, braced variable name} {
- testparser "\$\{\{\} " 0
-} {- \$\{\{\}\ 1 word \$\{\{\} 2 variable \$\{\{\} 1 text \{ 0 {}}
-test parse-12.8 {Tcl_ParseVarName procedure, missing close brace} {
- list [catch {testparser "$\{abc" 0} msg] $msg $errorInfo
-} {1 {missing close-brace for variable name} missing\ close-brace\ for\ variable\ name\n\ \ \ \ (remainder\ of\ script:\ \"\{abc\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"\$\\\{abc\"\ 0\"}
-test parse-12.9 {Tcl_ParseVarName procedure, missing close brace} {
- list [catch {testparsevarname {${bcd}} 4 0} msg] $msg
-} {1 {missing close-brace for variable name}}
-test parse-12.10 {Tcl_ParseVarName procedure, missing close brace} {
- list [catch {testparsevarname {${bc}} 4 0} msg] $msg
-} {1 {missing close-brace for variable name}}
-test parse-12.11 {Tcl_ParseVarName procedure, simple variable name} {
- testparser {$az_AZ.} 0
-} {- {$az_AZ.} 1 word {$az_AZ.} 3 variable {$az_AZ} 1 text az_AZ 0 text . 0 {}}
-test parse-12.12 {Tcl_ParseVarName procedure, simple variable name} {
- testparser {$abcdefg} 4
-} {- {$abc} 1 word {$abc} 2 variable {$abc} 1 text abc 0 defg}
-test parse-12.13 {Tcl_ParseVarName procedure, simple variable name with ::} {
- testparser {$xyz::ab:c} 0
-} {- {$xyz::ab:c} 1 word {$xyz::ab:c} 3 variable {$xyz::ab} 1 text xyz::ab 0 text :c 0 {}}
-test parse-12.14 {Tcl_ParseVarName procedure, variable names with many colons} {
- testparser {$xyz:::::c} 0
-} {- {$xyz:::::c} 1 word {$xyz:::::c} 2 variable {$xyz:::::c} 1 text xyz:::::c 0 {}}
-test parse-12.15 {Tcl_ParseVarName procedure, : vs. ::} {
- testparsevarname {$ab:cd} 0 0
-} {- {} 0 variable {$ab} 1 text ab 0 :cd}
-test parse-12.16 {Tcl_ParseVarName procedure, eof in ::} {
- testparsevarname {$ab::cd} 4 0
-} {- {} 0 variable {$ab} 1 text ab 0 ::cd}
-test parse-12.17 {Tcl_ParseVarName procedure, eof in ::} {
- testparsevarname {$ab:::cd} 5 0
-} {- {} 0 variable {$ab::} 1 text ab:: 0 :cd}
-test parse-12.18 {Tcl_ParseVarName procedure, no variable name} {
- testparser {$$ $.} 0
-} {- {$$ $.} 2 word {$$} 2 text {$} 0 text {$} 0 word {$.} 2 text {$} 0 text . 0 {}}
-test parse-12.19 {Tcl_ParseVarName procedure, EOF before (} {
- testparsevarname {$ab(cd)} 3 0
-} {- {} 0 variable {$ab} 1 text ab 0 (cd)}
-test parse-12.20 {Tcl_ParseVarName procedure, array reference} {
- testparser {$x(abc)} 0
-} {- {$x(abc)} 1 word {$x(abc)} 3 variable {$x(abc)} 2 text x 0 text abc 0 {}}
-test parse-12.21 {Tcl_ParseVarName procedure, array reference} {
- testparser {$x(ab$cde[foo bar])} 0
-} {- {$x(ab$cde[foo bar])} 1 word {$x(ab$cde[foo bar])} 6 variable {$x(ab$cde[foo bar])} 5 text x 0 text ab 0 variable {$cde} 1 text cde 0 command {[foo bar]} 0 {}}
-test parse-12.22 {Tcl_ParseVarName procedure, array reference} {
- testparser {$x([cmd arg]zz)} 0
-} {- {$x([cmd arg]zz)} 1 word {$x([cmd arg]zz)} 4 variable {$x([cmd arg]zz)} 3 text x 0 command {[cmd arg]} 0 text zz 0 {}}
-test parse-12.23 {Tcl_ParseVarName procedure, missing close paren in array reference} {
- list [catch {testparser {$x(poiu} 0} msg] $msg $errorInfo
-} {1 {missing )} {missing )
- (remainder of script: "(poiu")
- invoked from within
-"testparser {$x(poiu} 0"}}
-test parse-12.24 {Tcl_ParseVarName procedure, missing close paren in array reference} {
- list [catch {testparsevarname {$ab(cd)} 6 0} msg] $msg $errorInfo
-} {1 {missing )} {missing )
- (remainder of script: "(cd)")
- invoked from within
-"testparsevarname {$ab(cd)} 6 0"}}
-test parse-12.25 {Tcl_ParseVarName procedure, nested array reference} {
- testparser {$x(a$y(b$z))} 0
-} {- {$x(a$y(b$z))} 1 word {$x(a$y(b$z))} 8 variable {$x(a$y(b$z))} 7 text x 0 text a 0 variable {$y(b$z)} 4 text y 0 text b 0 variable {$z} 1 text z 0 {}}
-
-test parse-13.1 {Tcl_ParseVar procedure} {
- set abc 24
- testparsevar {$abc.fg}
-} {24 .fg}
-test parse-13.2 {Tcl_ParseVar procedure, no variable name} {
- testparsevar {$}
-} {{$} {}}
-test parse-13.3 {Tcl_ParseVar procedure, no variable name} {
- testparsevar {$.123}
-} {{$} .123}
-test parse-13.4 {Tcl_ParseVar procedure, error looking up variable} {
- catch {unset abc}
- list [catch {testparsevar {$abc}} msg] $msg
-} {1 {can't read "abc": no such variable}}
-test parse-13.5 {Tcl_ParseVar procedure, error looking up variable} {
- catch {unset abc}
- list [catch {testparsevar {$abc([bogus x y z])}} msg] $msg
-} {1 {invalid command name "bogus"}}
-
-test parse-14.1 {Tcl_ParseBraces procedure, computing string length} {
- testparser [bytestring "foo\0 bar"] -1
-} {- foo 1 simple foo 1 text foo 0 {}}
-test parse-14.2 {Tcl_ParseBraces procedure, computing string length} {
- testparser "foo bar" -1
-} {- {foo bar} 2 simple foo 1 text foo 0 simple bar 1 text bar 0 {}}
-test parse-14.3 {Tcl_ParseBraces procedure, words in braces} {
- testparser {foo {a $b [concat foo]} {c d}} 0
-} {- {foo {a $b [concat foo]} {c d}} 3 simple foo 1 text foo 0 simple {{a $b [concat foo]}} 1 text {a $b [concat foo]} 0 simple {{c d}} 1 text {c d} 0 {}}
-test parse-14.4 {Tcl_ParseBraces procedure, empty nested braces} {
- testparser {foo {{}}} 0
-} {- {foo {{}}} 2 simple foo 1 text foo 0 simple {{{}}} 1 text {{}} 0 {}}
-test parse-14.5 {Tcl_ParseBraces procedure, nested braces} {
- testparser {foo {{a {b} c} {} {d e}}} 0
-} {- {foo {{a {b} c} {} {d e}}} 2 simple foo 1 text foo 0 simple {{{a {b} c} {} {d e}}} 1 text {{a {b} c} {} {d e}} 0 {}}
-test parse-14.6 {Tcl_ParseBraces procedure, backslashes in words in braces} {
- testparser "foo {a \\n\\\{}" 0
-} {- {foo {a \n\{}} 2 simple foo 1 text foo 0 simple {{a \n\{}} 1 text {a \n\{} 0 {}}
-test parse-14.7 {Tcl_ParseBraces procedure, missing continuation line in braces} {
- list [catch {testparser "\{abc\\\n" 0} msg] $msg $errorInfo
-} {1 {missing close-brace} missing\ close-brace\n\ \ \ \ (remainder\ of\ script:\ \"\{abc\\\n\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"\\\{abc\\\\\\n\"\ 0\"}
-test parse-14.8 {Tcl_ParseBraces procedure, backslash-newline in braces} {
- testparser "foo {\\\nx}" 0
-} {- foo\ \{\\\nx\} 2 simple foo 1 text foo 0 word \{\\\nx\} 2 backslash \\\n 0 text x 0 {}}
-test parse-14.9 {Tcl_ParseBraces procedure, backslash-newline in braces} {
- testparser "foo {a \\\n b}" 0
-} {- foo\ \{a\ \\\n\ \ \ b\} 2 simple foo 1 text foo 0 word \{a\ \\\n\ \ \ b\} 3 text {a } 0 backslash \\\n\ \ \ 0 text b 0 {}}
-test parse-14.10 {Tcl_ParseBraces procedure, backslash-newline in braces} {
- testparser "foo {xyz\\\n }" 0
-} {- foo\ \{xyz\\\n\ \} 2 simple foo 1 text foo 0 word \{xyz\\\n\ \} 2 text xyz 0 backslash \\\n\ 0 {}}
-test parse-14.11 {Tcl_ParseBraces procedure, empty braced string} {
- testparser {foo {}} 0
-} {- {foo {}} 2 simple foo 1 text foo 0 simple {{}} 1 text {} 0 {}}
-test parse-14.12 {Tcl_ParseBraces procedure, missing close brace} {
- list [catch {testparser "foo \{xy\\\nz" 0} msg] $msg $errorInfo
-} {1 {missing close-brace} missing\ close-brace\n\ \ \ \ (remainder\ of\ script:\ \"\{xy\\\nz\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"foo\ \\\{xy\\\\\\nz\"\ 0\"}
-
-test parse-15.1 {Tcl_ParseQuotedString procedure, computing string length} {
- testparser [bytestring "foo\0 bar"] -1
-} {- foo 1 simple foo 1 text foo 0 {}}
-test parse-15.2 {Tcl_ParseQuotedString procedure, computing string length} {
- testparser "foo bar" -1
-} {- {foo bar} 2 simple foo 1 text foo 0 simple bar 1 text bar 0 {}}
-test parse-15.3 {Tcl_ParseQuotedString procedure, word is quoted string} {
- testparser {foo "a b c" d "efg";} 0
-} {- {foo "a b c" d "efg";} 4 simple foo 1 text foo 0 simple {"a b c"} 1 text {a b c} 0 simple d 1 text d 0 simple {"efg"} 1 text efg 0 {}}
-test parse-15.4 {Tcl_ParseQuotedString procedure, garbage after quoted string} {
- list [catch {testparser {foo "a b c"d} 0} msg] $msg $errorInfo
-} {1 {extra characters after close-quote} {extra characters after close-quote
- (remainder of script: "d")
- invoked from within
-"testparser {foo "a b c"d} 0"}}
-
-test parse-15.5 {CommandComplete procedure} {
- info complete ""
-} 1
-test parse-15.6 {CommandComplete procedure} {
- info complete " \n"
-} 1
-test parse-15.7 {CommandComplete procedure} {
- info complete "abc def"
-} 1
-test parse-15.8 {CommandComplete procedure} {
- info complete "a b c d e f \t\n"
-} 1
-test parse-15.9 {CommandComplete procedure} {
- info complete {a b c"d}
-} 1
-test parse-15.10 {CommandComplete procedure} {
- info complete {a b "c d" e}
-} 1
-test parse-15.11 {CommandComplete procedure} {
- info complete {a b "c d"}
-} 1
-test parse-15.12 {CommandComplete procedure} {
- info complete {a b "c d"}
-} 1
-test parse-15.13 {CommandComplete procedure} {
- info complete {a b "c d}
-} 0
-test parse-15.14 {CommandComplete procedure} {
- info complete {a b "}
-} 0
-test parse-15.15 {CommandComplete procedure} {
- info complete {a b "cd"xyz}
-} 1
-test parse-15.16 {CommandComplete procedure} {
- info complete {a b "c $d() d"}
-} 1
-test parse-15.17 {CommandComplete procedure} {
- info complete {a b "c $dd("}
-} 0
-test parse-15.18 {CommandComplete procedure} {
- info complete {a b "c \"}
-} 0
-test parse-15.19 {CommandComplete procedure} {
- info complete {a b "c [d e f]"}
-} 1
-test parse-15.20 {CommandComplete procedure} {
- info complete {a b "c [d e f] g"}
-} 1
-test parse-15.21 {CommandComplete procedure} {
- info complete {a b "c [d e f"}
-} 0
-test parse-15.22 {CommandComplete procedure} {
- info complete {a {b c d} e}
-} 1
-test parse-15.23 {CommandComplete procedure} {
- info complete {a {b c d}}
-} 1
-test parse-15.24 {CommandComplete procedure} {
- info complete "a b\{c d"
-} 1
-test parse-15.25 {CommandComplete procedure} {
- info complete "a b \{c"
-} 0
-test parse-15.26 {CommandComplete procedure} {
- info complete "a b \{c{ }"
-} 0
-test parse-15.27 {CommandComplete procedure} {
- info complete "a b {c d e}xxx"
-} 1
-test parse-15.28 {CommandComplete procedure} {
- info complete "a b {c \\\{d e}xxx"
-} 1
-test parse-15.29 {CommandComplete procedure} {
- info complete {a b [ab cd ef]}
-} 1
-test parse-15.30 {CommandComplete procedure} {
- info complete {a b x[ab][cd][ef] gh}
-} 1
-test parse-15.31 {CommandComplete procedure} {
- info complete {a b x[ab][cd[ef] gh}
-} 0
-test parse-15.32 {CommandComplete procedure} {
- info complete {a b x[ gh}
-} 0
-test parse-15.33 {CommandComplete procedure} {
- info complete {[]]]}
-} 1
-test parse-15.34 {CommandComplete procedure} {
- info complete {abc x$yyy}
-} 1
-test parse-15.35 {CommandComplete procedure} {
- info complete "abc x\${abc\[\\d} xyz"
-} 1
-test parse-15.36 {CommandComplete procedure} {
- info complete "abc x\$\{ xyz"
-} 0
-test parse-15.37 {CommandComplete procedure} {
- info complete {word $a(xyz)}
-} 1
-test parse-15.38 {CommandComplete procedure} {
- info complete {word $a(}
-} 0
-test parse-15.39 {CommandComplete procedure} {
- info complete "set a \\\n"
-} 0
-test parse-15.40 {CommandComplete procedure} {
- info complete "set a \\\\\n"
-} 1
-test parse-15.41 {CommandComplete procedure} {
- info complete "set a \\n "
-} 1
-test parse-15.42 {CommandComplete procedure} {
- info complete "set a \\"
-} 1
-test parse-15.43 {CommandComplete procedure} {
- info complete "foo \\\n\{"
-} 0
-test parse-15.44 {CommandComplete procedure} {
- info complete "a\nb\n# \{\n# \{\nc\n"
-} 1
-test parse-15.45 {CommandComplete procedure} {
- info complete "#Incomplete comment\\\n"
-} 0
-test parse-15.46 {CommandComplete procedure} {
- info complete "#Incomplete comment\\\nBut now it's complete.\n"
-} 1
-test parse-15.47 {CommandComplete procedure} {
- info complete "# Complete comment\\\\\n"
-} 1
-test parse-15.48 {CommandComplete procedure} {
- info complete "abc\\\n def"
-} 1
-test parse-15.49 {CommandComplete procedure} {
- info complete "abc\\\n "
-} 1
-test parse-15.50 {CommandComplete procedure} {
- info complete "abc\\\n"
-} 0
-test parse-15.51 {CommandComplete procedure} "
- info complete \"\\{abc\\}\\{\"
-" 1
-test parse-15.52 {CommandComplete procedure} {
- info complete "\"abc\"("
-} 1
-test parse-15.53 {CommandComplete procedure} "
- info complete \" # {\"
-" 1
-test parse-15.54 {CommandComplete procedure} "
- info complete \"foo bar;# {\"
-" 1
-test parse-15.55 {CommandComplete procedure} {
- info complete "set x [bytestring \0]; puts hi"
-} 1
-test parse-15.56 {CommandComplete procedure} {
- info complete "set x [bytestring \0]; \{"
-} 0
-test parse-15.57 {CommandComplete procedure} {
- info complete "# Comment should be complete command"
-} 1
-
-# cleanup
-catch {unset a}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/parseExpr.test b/tests/parseExpr.test
deleted file mode 100644
index e454321..0000000
--- a/tests/parseExpr.test
+++ /dev/null
@@ -1,637 +0,0 @@
-# This file contains a collection of tests for the procedures in the
-# file tclParseExpr.c. Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-#
-# Copyright (c) 1997 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: parseExpr.test,v 1.2 1999/04/16 00:47:31 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Note that the Tcl expression parser (tclParseExpr.c) does not check
-# the semantic validity of the expressions it parses. It does not check,
-# for example, that a math function actually exists, or that the operands
-# of "<<" are integers.
-
-if {[info commands testexprparser] == {}} {
- puts "This application hasn't been compiled with the \"testexprparser\""
- puts "command, so I can't test the Tcl expression parser."
- ::tcltest::cleanupTests
- return
-}
-
-test parseExpr-1.1 {Tcl_ParseExpr procedure, computing string length} {
- testexprparser [bytestring "1+2\0 +3"] -1
-} {- {} 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-1.2 {Tcl_ParseExpr procedure, computing string length} {
- testexprparser "1 + 2" -1
-} {- {} 0 subexpr {1 + 2} 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-1.3 {Tcl_ParseExpr procedure, error getting initial lexeme} {nonPortable} {
- list [catch {testexprparser {12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-1.4 {Tcl_ParseExpr procedure, error in conditional expression} {
- list [catch {testexprparser {foo+} -1} msg] $msg
-} {1 {syntax error in expression "foo+"}}
-test parseExpr-1.5 {Tcl_ParseExpr procedure, lexemes after the expression} {
- list [catch {testexprparser {1+2 345} -1} msg] $msg
-} {1 {syntax error in expression "1+2 345"}}
-
-test parseExpr-2.1 {ParseCondExpr procedure, valid test subexpr} {
- testexprparser {2>3? 1 : 0} -1
-} {- {} 0 subexpr {2>3? 1 : 0} 11 operator ? 0 subexpr 2>3 5 operator > 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
-test parseExpr-2.2 {ParseCondExpr procedure, error in test subexpr} {
- list [catch {testexprparser {0 || foo} -1} msg] $msg
-} {1 {syntax error in expression "0 || foo"}}
-test parseExpr-2.3 {ParseCondExpr procedure, next lexeme isn't "?"} {
- testexprparser {1+2} -1
-} {- {} 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-2.4 {ParseCondExpr procedure, next lexeme is "?"} {
- testexprparser {1+2 ? 3 : 4} -1
-} {- {} 0 subexpr {1+2 ? 3 : 4} 11 operator ? 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
-test parseExpr-2.5 {ParseCondExpr procedure, bad lexeme after "?"} {nonPortable} {
- list [catch {testexprparser {1+2 ? 12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-2.6 {ParseCondExpr procedure, valid "then" subexpression} {
- testexprparser {1? 3 : 4} -1
-} {- {} 0 subexpr {1? 3 : 4} 7 operator ? 0 subexpr 1 1 text 1 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
-test parseExpr-2.7 {ParseCondExpr procedure, error in "then" subexpression} {
- list [catch {testexprparser {1? fred : martha} -1} msg] $msg
-} {1 {syntax error in expression "1? fred : martha"}}
-test parseExpr-2.8 {ParseCondExpr procedure, lexeme after "then" subexpr isn't ":"} {
- list [catch {testexprparser {1? 2 martha 3} -1} msg] $msg
-} {1 {syntax error in expression "1? 2 martha 3"}}
-test parseExpr-2.9 {ParseCondExpr procedure, valid "else" subexpression} {
- testexprparser {27||3? 3 : 4&&9} -1
-} {- {} 0 subexpr {27||3? 3 : 4&&9} 15 operator ? 0 subexpr 27||3 5 operator || 0 subexpr 27 1 text 27 0 subexpr 3 1 text 3 0 subexpr 3 1 text 3 0 subexpr 4&&9 5 operator && 0 subexpr 4 1 text 4 0 subexpr 9 1 text 9 0 {}}
-test parseExpr-2.10 {ParseCondExpr procedure, error in "else" subexpression} {
- list [catch {testexprparser {1? 2 : martha} -1} msg] $msg
-} {1 {syntax error in expression "1? 2 : martha"}}
-
-test parseExpr-3.1 {ParseLorExpr procedure, valid logical and subexpr} {
- testexprparser {1&&2 || 3} -1
-} {- {} 0 subexpr {1&&2 || 3} 9 operator || 0 subexpr 1&&2 5 operator && 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-3.2 {ParseLorExpr procedure, error in logical and subexpr} {
- list [catch {testexprparser {1&&foo || 3} -1} msg] $msg
-} {1 {syntax error in expression "1&&foo || 3"}}
-test parseExpr-3.3 {ParseLorExpr procedure, next lexeme isn't "||"} {
- testexprparser {1&&2? 1 : 0} -1
-} {- {} 0 subexpr {1&&2? 1 : 0} 11 operator ? 0 subexpr 1&&2 5 operator && 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
-test parseExpr-3.4 {ParseLorExpr procedure, next lexeme is "||"} {
- testexprparser {1&&2 || 3} -1
-} {- {} 0 subexpr {1&&2 || 3} 9 operator || 0 subexpr 1&&2 5 operator && 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-3.5 {ParseLorExpr procedure, bad lexeme after "||"} {nonPortable} {
- list [catch {testexprparser {1&&2 || 12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-3.6 {ParseLorExpr procedure, valid RHS subexpression} {
- testexprparser {1&&2 || 3 || 4} -1
-} {- {} 0 subexpr {1&&2 || 3 || 4} 13 operator || 0 subexpr {1&&2 || 3} 9 operator || 0 subexpr 1&&2 5 operator && 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
-test parseExpr-3.7 {ParseLorExpr procedure, error in RHS subexpression} {
- list [catch {testexprparser {1&&2 || 3 || martha} -1} msg] $msg
-} {1 {syntax error in expression "1&&2 || 3 || martha"}}
-
-test parseExpr-4.1 {ParseLandExpr procedure, valid LHS "|" subexpr} {
- testexprparser {1|2 && 3} -1
-} {- {} 0 subexpr {1|2 && 3} 9 operator && 0 subexpr 1|2 5 operator | 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-4.2 {ParseLandExpr procedure, error in LHS "|" subexpr} {
- list [catch {testexprparser {1&&foo && 3} -1} msg] $msg
-} {1 {syntax error in expression "1&&foo && 3"}}
-test parseExpr-4.3 {ParseLandExpr procedure, next lexeme isn't "&&"} {
- testexprparser {1|2? 1 : 0} -1
-} {- {} 0 subexpr {1|2? 1 : 0} 11 operator ? 0 subexpr 1|2 5 operator | 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
-test parseExpr-4.4 {ParseLandExpr procedure, next lexeme is "&&"} {
- testexprparser {1|2 && 3} -1
-} {- {} 0 subexpr {1|2 && 3} 9 operator && 0 subexpr 1|2 5 operator | 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-4.5 {ParseLandExpr procedure, bad lexeme after "&&"} {nonPortable} {
- list [catch {testexprparser {1|2 && 12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-4.6 {ParseLandExpr procedure, valid RHS subexpression} {
- testexprparser {1|2 && 3 && 4} -1
-} {- {} 0 subexpr {1|2 && 3 && 4} 13 operator && 0 subexpr {1|2 && 3} 9 operator && 0 subexpr 1|2 5 operator | 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
-test parseExpr-4.7 {ParseLandExpr procedure, error in RHS subexpression} {
- list [catch {testexprparser {1|2 && 3 && martha} -1} msg] $msg
-} {1 {syntax error in expression "1|2 && 3 && martha"}}
-
-test parseExpr-5.1 {ParseBitOrExpr procedure, valid LHS "^" subexpr} {
- testexprparser {1^2 | 3} -1
-} {- {} 0 subexpr {1^2 | 3} 9 operator | 0 subexpr 1^2 5 operator ^ 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-5.2 {ParseBitOrExpr procedure, error in LHS "^" subexpr} {
- list [catch {testexprparser {1|foo | 3} -1} msg] $msg
-} {1 {syntax error in expression "1|foo | 3"}}
-test parseExpr-5.3 {ParseBitOrExpr procedure, next lexeme isn't "|"} {
- testexprparser {1^2? 1 : 0} -1
-} {- {} 0 subexpr {1^2? 1 : 0} 11 operator ? 0 subexpr 1^2 5 operator ^ 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
-test parseExpr-5.4 {ParseBitOrExpr procedure, next lexeme is "|"} {
- testexprparser {1^2 | 3} -1
-} {- {} 0 subexpr {1^2 | 3} 9 operator | 0 subexpr 1^2 5 operator ^ 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-5.5 {ParseBitOrExpr procedure, bad lexeme after "|"} {nonPortable} {
- list [catch {testexprparser {1^2 | 12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-5.6 {ParseBitOrExpr procedure, valid RHS subexpression} {
- testexprparser {1^2 | 3 | 4} -1
-} {- {} 0 subexpr {1^2 | 3 | 4} 13 operator | 0 subexpr {1^2 | 3} 9 operator | 0 subexpr 1^2 5 operator ^ 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
-test parseExpr-5.7 {ParseBitOrExpr procedure, error in RHS subexpression} {
- list [catch {testexprparser {1^2 | 3 | martha} -1} msg] $msg
-} {1 {syntax error in expression "1^2 | 3 | martha"}}
-
-test parseExpr-6.1 {ParseBitXorExpr procedure, valid LHS "&" subexpr} {
- testexprparser {1&2 ^ 3} -1
-} {- {} 0 subexpr {1&2 ^ 3} 9 operator ^ 0 subexpr 1&2 5 operator & 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-6.2 {ParseBitXorExpr procedure, error in LHS "&" subexpr} {
- list [catch {testexprparser {1^foo ^ 3} -1} msg] $msg
-} {1 {syntax error in expression "1^foo ^ 3"}}
-test parseExpr-6.3 {ParseBitXorExpr procedure, next lexeme isn't "^"} {
- testexprparser {1&2? 1 : 0} -1
-} {- {} 0 subexpr {1&2? 1 : 0} 11 operator ? 0 subexpr 1&2 5 operator & 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
-test parseExpr-6.4 {ParseBitXorExpr procedure, next lexeme is "^"} {
- testexprparser {1&2 ^ 3} -1
-} {- {} 0 subexpr {1&2 ^ 3} 9 operator ^ 0 subexpr 1&2 5 operator & 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-6.5 {ParseBitXorExpr procedure, bad lexeme after "^"} {nonPortable} {
- list [catch {testexprparser {1&2 ^ 12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-6.6 {ParseBitXorExpr procedure, valid RHS subexpression} {
- testexprparser {1&2 ^ 3 ^ 4} -1
-} {- {} 0 subexpr {1&2 ^ 3 ^ 4} 13 operator ^ 0 subexpr {1&2 ^ 3} 9 operator ^ 0 subexpr 1&2 5 operator & 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
-test parseExpr-6.7 {ParseBitXorExpr procedure, error in RHS subexpression} {
- list [catch {testexprparser {1&2 ^ 3 ^ martha} -1} msg] $msg
-} {1 {syntax error in expression "1&2 ^ 3 ^ martha"}}
-
-test parseExpr-7.1 {ParseBitAndExpr procedure, valid LHS equality subexpr} {
- testexprparser {1==2 & 3} -1
-} {- {} 0 subexpr {1==2 & 3} 9 operator & 0 subexpr 1==2 5 operator == 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-7.2 {ParseBitAndExpr procedure, error in LHS equality subexpr} {
- list [catch {testexprparser {1!=foo & 3} -1} msg] $msg
-} {1 {syntax error in expression "1!=foo & 3"}}
-test parseExpr-7.3 {ParseBitAndExpr procedure, next lexeme isn't "&"} {
- testexprparser {1==2? 1 : 0} -1
-} {- {} 0 subexpr {1==2? 1 : 0} 11 operator ? 0 subexpr 1==2 5 operator == 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
-test parseExpr-7.4 {ParseBitAndExpr procedure, next lexeme is "&"} {
- testexprparser {1>2 & 3} -1
-} {- {} 0 subexpr {1>2 & 3} 9 operator & 0 subexpr 1>2 5 operator > 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-7.5 {ParseBitAndExpr procedure, bad lexeme after "&"} {nonPortable} {
- list [catch {testexprparser {1==2 & 12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-7.6 {ParseBitAndExpr procedure, valid RHS subexpression} {
- testexprparser {1<2 & 3 & 4} -1
-} {- {} 0 subexpr {1<2 & 3 & 4} 13 operator & 0 subexpr {1<2 & 3} 9 operator & 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
-test parseExpr-7.7 {ParseBitAndExpr procedure, error in RHS subexpression} {
- list [catch {testexprparser {1==2 & 3>2 & martha} -1} msg] $msg
-} {1 {syntax error in expression "1==2 & 3>2 & martha"}}
-
-test parseExpr-7.1 {ParseEqualityExpr procedure, valid LHS relational subexpr} {
- testexprparser {1<2 == 3} -1
-} {- {} 0 subexpr {1<2 == 3} 9 operator == 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-7.2 {ParseEqualityExpr procedure, error in LHS relational subexpr} {
- list [catch {testexprparser {1>=foo == 3} -1} msg] $msg
-} {1 {syntax error in expression "1>=foo == 3"}}
-test parseExpr-7.3 {ParseEqualityExpr procedure, next lexeme isn't "==" or "!="} {
- testexprparser {1<2? 1 : 0} -1
-} {- {} 0 subexpr {1<2? 1 : 0} 11 operator ? 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
-test parseExpr-7.4 {ParseEqualityExpr procedure, next lexeme is "==" or "!=} {
- testexprparser {1<2 == 3} -1
-} {- {} 0 subexpr {1<2 == 3} 9 operator == 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-7.5 {ParseEqualityExpr procedure, next lexeme is "==" or "!="} {
- testexprparser {1<2 != 3} -1
-} {- {} 0 subexpr {1<2 != 3} 9 operator != 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-7.6 {ParseEqualityExpr procedure, bad lexeme after "==" or "!="} {nonPortable} {
- list [catch {testexprparser {1<2 == 12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-7.7 {ParseEqualityExpr procedure, valid RHS subexpression} {
- testexprparser {1<2 == 3 == 4} -1
-} {- {} 0 subexpr {1<2 == 3 == 4} 13 operator == 0 subexpr {1<2 == 3} 9 operator == 0 subexpr 1<2 5 operator < 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
-test parseExpr-7.8 {ParseEqualityExpr procedure, error in RHS subexpression} {
- list [catch {testexprparser {1<2 == 3 != martha} -1} msg] $msg
-} {1 {syntax error in expression "1<2 == 3 != martha"}}
-
-test parseExpr-8.1 {ParseRelationalExpr procedure, valid LHS shift subexpr} {
- testexprparser {1<<2 < 3} -1
-} {- {} 0 subexpr {1<<2 < 3} 9 operator < 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-8.2 {ParseRelationalExpr procedure, error in LHS shift subexpr} {
- list [catch {testexprparser {1>=foo < 3} -1} msg] $msg
-} {1 {syntax error in expression "1>=foo < 3"}}
-test parseExpr-8.3 {ParseRelationalExpr procedure, next lexeme isn't relational op} {
- testexprparser {1<<2? 1 : 0} -1
-} {- {} 0 subexpr {1<<2? 1 : 0} 11 operator ? 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
-test parseExpr-8.4 {ParseRelationalExpr procedure, next lexeme is relational op} {
- testexprparser {1<<2 < 3} -1
-} {- {} 0 subexpr {1<<2 < 3} 9 operator < 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-8.5 {ParseRelationalExpr procedure, next lexeme is relational op} {
- testexprparser {1>>2 > 3} -1
-} {- {} 0 subexpr {1>>2 > 3} 9 operator > 0 subexpr 1>>2 5 operator >> 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-8.6 {ParseRelationalExpr procedure, next lexeme is relational op} {
- testexprparser {1<<2 <= 3} -1
-} {- {} 0 subexpr {1<<2 <= 3} 9 operator <= 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-8.7 {ParseRelationalExpr procedure, next lexeme is relational op} {
- testexprparser {1<<2 >= 3} -1
-} {- {} 0 subexpr {1<<2 >= 3} 9 operator >= 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-8.8 {ParseRelationalExpr procedure, bad lexeme after relational op} {nonPortable} {
- list [catch {testexprparser {1<<2 < 12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-8.9 {ParseRelationalExpr procedure, valid RHS subexpression} {
- testexprparser {1<<2 < 3 < 4} -1
-} {- {} 0 subexpr {1<<2 < 3 < 4} 13 operator < 0 subexpr {1<<2 < 3} 9 operator < 0 subexpr 1<<2 5 operator << 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
-test parseExpr-8.8 {ParseRelationalExpr procedure, error in RHS subexpression} {
- list [catch {testexprparser {1<<2 < 3 > martha} -1} msg] $msg
-} {1 {syntax error in expression "1<<2 < 3 > martha"}}
-
-test parseExpr-9.1 {ParseShiftExpr procedure, valid LHS add subexpr} {
- testexprparser {1+2 << 3} -1
-} {- {} 0 subexpr {1+2 << 3} 9 operator << 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-9.2 {ParseShiftExpr procedure, error in LHS add subexpr} {
- list [catch {testexprparser {1-foo << 3} -1} msg] $msg
-} {1 {syntax error in expression "1-foo << 3"}}
-test parseExpr-9.3 {ParseShiftExpr procedure, next lexeme isn't "<<" or ">>"} {
- testexprparser {1+2? 1 : 0} -1
-} {- {} 0 subexpr {1+2? 1 : 0} 11 operator ? 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
-test parseExpr-9.4 {ParseShiftExpr procedure, next lexeme is "<<" or ">>} {
- testexprparser {1+2 << 3} -1
-} {- {} 0 subexpr {1+2 << 3} 9 operator << 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-9.5 {ParseShiftExpr procedure, next lexeme is "<<" or ">>"} {
- testexprparser {1+2 >> 3} -1
-} {- {} 0 subexpr {1+2 >> 3} 9 operator >> 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-9.6 {ParseShiftExpr procedure, bad lexeme after "<<" or ">>"} {nonPortable} {
- list [catch {testexprparser {1+2 << 12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-9.7 {ParseShiftExpr procedure, valid RHS subexpression} {
- testexprparser {1+2 << 3 << 4} -1
-} {- {} 0 subexpr {1+2 << 3 << 4} 13 operator << 0 subexpr {1+2 << 3} 9 operator << 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
-test parseExpr-9.8 {ParseShiftExpr procedure, error in RHS subexpression} {
- list [catch {testexprparser {1+2 << 3 >> martha} -1} msg] $msg
-} {1 {syntax error in expression "1+2 << 3 >> martha"}}
-
-test parseExpr-10.1 {ParseAddExpr procedure, valid LHS multiply subexpr} {
- testexprparser {1*2 + 3} -1
-} {- {} 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-10.2 {ParseAddExpr procedure, error in LHS multiply subexpr} {
- list [catch {testexprparser {1/foo + 3} -1} msg] $msg
-} {1 {syntax error in expression "1/foo + 3"}}
-test parseExpr-10.3 {ParseAddExpr procedure, next lexeme isn't "+" or "-"} {
- testexprparser {1*2? 1 : 0} -1
-} {- {} 0 subexpr {1*2? 1 : 0} 11 operator ? 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
-test parseExpr-10.4 {ParseAddExpr procedure, next lexeme is "+" or "-} {
- testexprparser {1*2 + 3} -1
-} {- {} 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-10.5 {ParseAddExpr procedure, next lexeme is "+" or "-"} {
- testexprparser {1*2 - 3} -1
-} {- {} 0 subexpr {1*2 - 3} 9 operator - 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-10.6 {ParseAddExpr procedure, bad lexeme after "+" or "-"} {nonPortable} {
- list [catch {testexprparser {1*2 + 12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-10.7 {ParseAddExpr procedure, valid RHS subexpression} {
- testexprparser {1*2 + 3 + 4} -1
-} {- {} 0 subexpr {1*2 + 3 + 4} 13 operator + 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
-test parseExpr-10.8 {ParseAddExpr procedure, error in RHS subexpression} {
- list [catch {testexprparser {1*2 + 3 - martha} -1} msg] $msg
-} {1 {syntax error in expression "1*2 + 3 - martha"}}
-
-test parseExpr-10.1 {ParseAddExpr procedure, valid LHS multiply subexpr} {
- testexprparser {1*2 + 3} -1
-} {- {} 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-10.2 {ParseAddExpr procedure, error in LHS multiply subexpr} {
- list [catch {testexprparser {1/foo + 3} -1} msg] $msg
-} {1 {syntax error in expression "1/foo + 3"}}
-test parseExpr-10.3 {ParseAddExpr procedure, next lexeme isn't "+" or "-"} {
- testexprparser {1*2? 1 : 0} -1
-} {- {} 0 subexpr {1*2? 1 : 0} 11 operator ? 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
-test parseExpr-10.4 {ParseAddExpr procedure, next lexeme is "+" or "-} {
- testexprparser {1*2 + 3} -1
-} {- {} 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-10.5 {ParseAddExpr procedure, next lexeme is "+" or "-"} {
- testexprparser {1*2 - 3} -1
-} {- {} 0 subexpr {1*2 - 3} 9 operator - 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-10.6 {ParseAddExpr procedure, bad lexeme after "+" or "-"} {nonPortable} {
- list [catch {testexprparser {1*2 + 12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-10.7 {ParseAddExpr procedure, valid RHS subexpression} {
- testexprparser {1*2 + 3 + 4} -1
-} {- {} 0 subexpr {1*2 + 3 + 4} 13 operator + 0 subexpr {1*2 + 3} 9 operator + 0 subexpr 1*2 5 operator * 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
-test parseExpr-10.8 {ParseAddExpr procedure, error in RHS subexpression} {
- list [catch {testexprparser {1*2 + 3 - martha} -1} msg] $msg
-} {1 {syntax error in expression "1*2 + 3 - martha"}}
-
-test parseExpr-11.1 {ParseMultiplyExpr procedure, valid LHS unary subexpr} {
- testexprparser {+2 * 3} -1
-} {- {} 0 subexpr {+2 * 3} 7 operator * 0 subexpr +2 3 operator + 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-11.2 {ParseMultiplyExpr procedure, error in LHS unary subexpr} {nonPortable} {
- list [catch {testexprparser {-12345678901234567890 * 3} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-11.3 {ParseMultiplyExpr procedure, next lexeme isn't "*", "/", or "%"} {
- testexprparser {+2? 1 : 0} -1
-} {- {} 0 subexpr {+2? 1 : 0} 9 operator ? 0 subexpr +2 3 operator + 0 subexpr 2 1 text 2 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
-test parseExpr-11.4 {ParseMultiplyExpr procedure, next lexeme is "*", "/", or "%"} {
- testexprparser {-123 * 3} -1
-} {- {} 0 subexpr {-123 * 3} 7 operator * 0 subexpr -123 3 operator - 0 subexpr 123 1 text 123 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-11.5 {ParseMultiplyExpr procedure, next lexeme is "*", "/", or "%"} {
- testexprparser {+-456 / 3} -1
-} {- {} 0 subexpr {+-456 / 3} 9 operator / 0 subexpr +-456 5 operator + 0 subexpr -456 3 operator - 0 subexpr 456 1 text 456 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-11.6 {ParseMultiplyExpr procedure, next lexeme is "*", "/", or "%"} {
- testexprparser {+-456 % 3} -1
-} {- {} 0 subexpr {+-456 % 3} 9 operator % 0 subexpr +-456 5 operator + 0 subexpr -456 3 operator - 0 subexpr 456 1 text 456 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-11.7 {ParseMultiplyExpr procedure, bad lexeme after "*", "/", or "%"} {nonPortable} {
- list [catch {testexprparser {--++5 / 12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-11.8 {ParseMultiplyExpr procedure, valid RHS subexpression} {
- testexprparser {-2 / 3 % 4} -1
-} {- {} 0 subexpr {-2 / 3 % 4} 11 operator % 0 subexpr {-2 / 3} 7 operator / 0 subexpr -2 3 operator - 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 subexpr 4 1 text 4 0 {}}
-test parseExpr-11.9 {ParseMultiplyExpr procedure, error in RHS subexpression} {
- list [catch {testexprparser {++2 / 3 * martha} -1} msg] $msg
-} {1 {syntax error in expression "++2 / 3 * martha"}}
-
-test parseExpr-12.1 {ParseUnaryExpr procedure, first token is unary operator} {
- testexprparser {+2} -1
-} {- {} 0 subexpr +2 3 operator + 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-12.2 {ParseUnaryExpr procedure, first token is unary operator} {
- testexprparser {-2} -1
-} {- {} 0 subexpr -2 3 operator - 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-12.3 {ParseUnaryExpr procedure, first token is unary operator} {
- testexprparser {~2} -1
-} {- {} 0 subexpr ~2 3 operator ~ 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-12.4 {ParseUnaryExpr procedure, first token is unary operator} {
- testexprparser {!2} -1
-} {- {} 0 subexpr !2 3 operator ! 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-12.5 {ParseUnaryExpr procedure, error in lexeme after unary op} {nonPortable} {
- list [catch {testexprparser {-12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-12.6 {ParseUnaryExpr procedure, simple unary expr after unary op} {
- testexprparser {+"1234"} -1
-} {- {} 0 subexpr +\"1234\" 3 operator + 0 subexpr {"1234"} 1 text 1234 0 {}}
-test parseExpr-12.7 {ParseUnaryExpr procedure, another unary expr after unary op} {
- testexprparser {~!{fred}} -1
-} {- {} 0 subexpr ~!{fred} 5 operator ~ 0 subexpr !{fred} 3 operator ! 0 subexpr {{fred}} 1 text fred 0 {}}
-test parseExpr-12.8 {ParseUnaryExpr procedure, error in unary expr after unary op} {
- list [catch {testexprparser {+-||27} -1} msg] $msg
-} {1 {syntax error in expression "+-||27"}}
-test parseExpr-12.9 {ParseUnaryExpr procedure, error in unary expr after unary op} {
- list [catch {testexprparser {+-||27} -1} msg] $msg
-} {1 {syntax error in expression "+-||27"}}
-test parseExpr-12.10 {ParseUnaryExpr procedure, first token is not unary op} {
- testexprparser {123} -1
-} {- {} 0 subexpr 123 1 text 123 0 {}}
-test parseExpr-12.11 {ParseUnaryExpr procedure, not unary expr, complex primary expr} {
- testexprparser {(1+2)} -1
-} {- {} 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-12.12 {ParseUnaryExpr procedure, not unary expr, error in primary expr} {nonPortable} {
- list [catch {testexprparser {(12345678901234567890)} -1} msg] $msg
-} {1 {integer value too large to represent}}
-
-test parseExpr-13.1 {ParsePrimaryExpr procedure, just parenthesized subexpr} {
- testexprparser {({abc}/{def})} -1
-} {- {} 0 subexpr {{abc}/{def}} 5 operator / 0 subexpr {{abc}} 1 text abc 0 subexpr {{def}} 1 text def 0 {}}
-test parseExpr-13.2 {ParsePrimaryExpr procedure, bad lexeme after "("} {nonPortable} {
- list [catch {testexprparser {(12345678901234567890)} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-13.3 {ParsePrimaryExpr procedure, valid parenthesized subexpr} {
- testexprparser {({abc}? 2*4 : -6)} -1
-} {- {} 0 subexpr {{abc}? 2*4 : -6} 13 operator ? 0 subexpr {{abc}} 1 text abc 0 subexpr 2*4 5 operator * 0 subexpr 2 1 text 2 0 subexpr 4 1 text 4 0 subexpr -6 3 operator - 0 subexpr 6 1 text 6 0 {}}
-test parseExpr-13.4 {ParsePrimaryExpr procedure, error in parenthesized subexpr} {
- list [catch {testexprparser {(? 123 : 456)} -1} msg] $msg
-} {1 {syntax error in expression "(? 123 : 456)"}}
-test parseExpr-13.5 {ParsePrimaryExpr procedure, missing ")" after in parenthesized subexpr} {
- list [catch {testexprparser {({abc}/{def}} -1} msg] $msg
-} {1 {syntax error in expression "({abc}/{def}"}}
-test parseExpr-13.6 {ParsePrimaryExpr procedure, primary is literal} {
- testexprparser {12345} -1
-} {- {} 0 subexpr 12345 1 text 12345 0 {}}
-test parseExpr-13.7 {ParsePrimaryExpr procedure, primary is literal} {
- testexprparser {12345.6789} -1
-} {- {} 0 subexpr 12345.6789 1 text 12345.6789 0 {}}
-test parseExpr-13.8 {ParsePrimaryExpr procedure, primary is var reference} {
- testexprparser {$a} -1
-} {- {} 0 subexpr {$a} 2 variable {$a} 1 text a 0 {}}
-test parseExpr-13.9 {ParsePrimaryExpr procedure, primary is var reference} {
- testexprparser {$a(hello$there)} -1
-} {- {} 0 subexpr {$a(hello$there)} 5 variable {$a(hello$there)} 4 text a 0 text hello 0 variable {$there} 1 text there 0 {}}
-test parseExpr-13.10 {ParsePrimaryExpr procedure, primary is var reference} {
- testexprparser {$a()} -1
-} {- {} 0 subexpr {$a()} 3 variable {$a()} 2 text a 0 text {} 0 {}}
-test parseExpr-13.11 {ParsePrimaryExpr procedure, error in var reference} {
- list [catch {testexprparser {$a(} -1} msg] $msg
-} {1 {missing )}}
-test parseExpr-13.12 {ParsePrimaryExpr procedure, primary is quoted string} {
- testexprparser {"abc $xyz def"} -1
-} {- {} 0 subexpr {"abc $xyz def"} 5 word {"abc $xyz def"} 4 text {abc } 0 variable {$xyz} 1 text xyz 0 text { def} 0 {}}
-test parseExpr-13.13 {ParsePrimaryExpr procedure, error in quoted string} {
- list [catch {testexprparser {"$a(12"} -1} msg] $msg
-} {1 {missing )}}
-test parseExpr-13.14 {ParsePrimaryExpr procedure, quoted string has multiple tokens} {
- testexprparser {"abc [xyz] $def"} -1
-} {- {} 0 subexpr {"abc [xyz] $def"} 6 word {"abc [xyz] $def"} 5 text {abc } 0 command {[xyz]} 0 text { } 0 variable {$def} 1 text def 0 {}}
-test parseExpr-13.15 {ParsePrimaryExpr procedure, primary is command} {
- testexprparser {[def]} -1
-} {- {} 0 subexpr {[def]} 1 command {[def]} 0 {}}
-test parseExpr-13.16 {ParsePrimaryExpr procedure, primary is multiple commands} {
- testexprparser {[one; two; three; four;]} -1
-} {- {} 0 subexpr {[one; two; three; four;]} 1 command {[one; two; three; four;]} 0 {}}
-test parseExpr-13.17 {ParsePrimaryExpr procedure, primary is multiple commands} {
- testexprparser {[one; two; three; four;]} -1
-} {- {} 0 subexpr {[one; two; three; four;]} 1 command {[one; two; three; four;]} 0 {}}
-test parseExpr-13.18 {ParsePrimaryExpr procedure, missing close bracket} {
- list [catch {testexprparser {[one} -1} msg] $msg
-} {1 {missing close-bracket}}
-test parseExpr-13.19 {ParsePrimaryExpr procedure, primary is braced string} {
- testexprparser {{hello world}} -1
-} {- {} 0 subexpr {{hello world}} 1 text {hello world} 0 {}}
-test parseExpr-13.20 {ParsePrimaryExpr procedure, error in primary, which is braced string} {
- list [catch {testexprparser "\{abc\\\n" -1} msg] $msg
-} {1 {missing close-brace}}
-test parseExpr-13.21 {ParsePrimaryExpr procedure, primary is braced string with multiple tokens} {
- testexprparser "\{ \\
- +123 \}" -1
-} {- {} 0 subexpr \{\ \ \\\n\ +123\ \} 4 word \{\ \ \\\n\ +123\ \} 3 text { } 0 backslash \\\n\ 0 text {+123 } 0 {}}
-test parseExpr-13.22 {ParsePrimaryExpr procedure, primary is function call} {
- testexprparser {foo(123)} -1
-} {- {} 0 subexpr foo(123) 3 operator foo 0 subexpr 123 1 text 123 0 {}}
-test parseExpr-13.23 {ParsePrimaryExpr procedure, bad lexeme after function name} {nonPortable} {
- list [catch {testexprparser {foo 12345678901234567890 123)} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-13.24 {ParsePrimaryExpr procedure, lexeme after function name isn't "("} {
- list [catch {testexprparser {foo 27.4 123)} -1} msg] $msg
-} {1 {syntax error in expression "foo 27.4 123)"}}
-test parseExpr-13.25 {ParsePrimaryExpr procedure, bad lexeme after "("} {nonPortable} {
- list [catch {testexprparser {foo(12345678901234567890)} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-13.26 {ParsePrimaryExpr procedure, function call, one arg} {
- testexprparser {foo(27*4)} -1
-} {- {} 0 subexpr foo(27*4) 7 operator foo 0 subexpr 27*4 5 operator * 0 subexpr 27 1 text 27 0 subexpr 4 1 text 4 0 {}}
-test parseExpr-13.27 {ParsePrimaryExpr procedure, error in function arg} {
- list [catch {testexprparser {foo(*1-2)} -1} msg] $msg
-} {1 {syntax error in expression "foo(*1-2)"}}
-test parseExpr-13.28 {ParsePrimaryExpr procedure, error in function arg} {
- list [catch {testexprparser {foo(*1-2)} -1} msg] $msg
-} {1 {syntax error in expression "foo(*1-2)"}}
-test parseExpr-13.29 {ParsePrimaryExpr procedure, function call, comma after arg} {
- testexprparser {foo(27-2, (-2*[foo]))} -1
-} {- {} 0 subexpr {foo(27-2, (-2*[foo]))} 15 operator foo 0 subexpr 27-2 5 operator - 0 subexpr 27 1 text 27 0 subexpr 2 1 text 2 0 subexpr {-2*[foo]} 7 operator * 0 subexpr -2 3 operator - 0 subexpr 2 1 text 2 0 subexpr {[foo]} 1 command {[foo]} 0 {}}
-test parseExpr-13.30 {ParsePrimaryExpr procedure, bad lexeme after comma} {nonPortable} {
- list [catch {testexprparser {foo(123, 12345678901234567890)} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-13.31 {ParsePrimaryExpr procedure, lexeme not "," or ")" after arg} {
- list [catch {testexprparser {foo(123 [foo])} -1} msg] $msg
-} {1 {syntax error in expression "foo(123 [foo])"}}
-test parseExpr-13.32 {ParsePrimaryExpr procedure, bad lexeme after primary} {nonPortable} {
- list [catch {testexprparser {123 12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-
-test parseExpr-14.1 {GetLexeme procedure, whitespace before lexeme} {
- testexprparser { 123} -1
-} {- {} 0 subexpr 123 1 text 123 0 {}}
-test parseExpr-14.2 {GetLexeme procedure, whitespace before lexeme} {
- testexprparser { \
-456} -1
-} {- {} 0 subexpr 456 1 text 456 0 {}}
-test parseExpr-14.3 {GetLexeme procedure, no lexeme after whitespace} {
- testexprparser { 123 \
- } -1
-} {- {} 0 subexpr 123 1 text 123 0 {}}
-test parseExpr-14.4 {GetLexeme procedure, integer lexeme} {
- testexprparser {000} -1
-} {- {} 0 subexpr 000 1 text 000 0 {}}
-test parseExpr-14.5 {GetLexeme procedure, integer lexeme too big} {nonPortable} {
- list [catch {testexprparser {12345678901234567890} -1} msg] $msg
-} {1 {integer value too large to represent}}
-test parseExpr-14.6 {GetLexeme procedure, bad integer lexeme} {
- list [catch {testexprparser {0999} -1} msg] $msg
-} {1 {syntax error in expression "0999"}}
-test parseExpr-14.7 {GetLexeme procedure, double lexeme} {
- testexprparser {0.999} -1
-} {- {} 0 subexpr 0.999 1 text 0.999 0 {}}
-test parseExpr-14.8 {GetLexeme procedure, double lexeme} {
- testexprparser {.123} -1
-} {- {} 0 subexpr .123 1 text .123 0 {}}
-test parseExpr-14.9 {GetLexeme procedure, double lexeme} {nonPortable unixOnly} {
- testexprparser {nan} -1
-} {- {} 0 subexpr nan 1 text nan 0 {}}
-test parseExpr-14.10 {GetLexeme procedure, double lexeme} {nonPortable unixOnly} {
- testexprparser {NaN} -1
-} {- {} 0 subexpr NaN 1 text NaN 0 {}}
-test parseExpr-14.11 {GetLexeme procedure, bad double lexeme too big} {
- list [catch {testexprparser {123.e+99999999999999} -1} msg] $msg
-} {1 {floating-point value too large to represent}}
-test parseExpr-14.12 {GetLexeme procedure, bad double lexeme} {
- list [catch {testexprparser {123.4x56} -1} msg] $msg
-} {1 {syntax error in expression "123.4x56"}}
-test parseExpr-14.13 {GetLexeme procedure, lexeme is "["} {
- testexprparser {[foo]} -1
-} {- {} 0 subexpr {[foo]} 1 command {[foo]} 0 {}}
-test parseExpr-14.14 {GetLexeme procedure, lexeme is open brace} {
- testexprparser {{bar}} -1
-} {- {} 0 subexpr {{bar}} 1 text bar 0 {}}
-test parseExpr-14.15 {GetLexeme procedure, lexeme is "("} {
- testexprparser {(123)} -1
-} {- {} 0 subexpr 123 1 text 123 0 {}}
-test parseExpr-14.16 {GetLexeme procedure, lexeme is ")"} {
- testexprparser {(2*3)} -1
-} {- {} 0 subexpr 2*3 5 operator * 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-14.17 {GetLexeme procedure, lexeme is "$"} {
- testexprparser {$wombat} -1
-} {- {} 0 subexpr {$wombat} 2 variable {$wombat} 1 text wombat 0 {}}
-test parseExpr-14.18 {GetLexeme procedure, lexeme is '"'} {
- testexprparser {"fred"} -1
-} {- {} 0 subexpr {"fred"} 1 text fred 0 {}}
-test parseExpr-14.19 {GetLexeme procedure, lexeme is ","} {
- testexprparser {foo(1,2)} -1
-} {- {} 0 subexpr foo(1,2) 5 operator foo 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-14.20 {GetLexeme procedure, lexeme is "*"} {
- testexprparser {$a*$b} -1
-} {- {} 0 subexpr {$a*$b} 7 operator * 0 subexpr {$a} 2 variable {$a} 1 text a 0 subexpr {$b} 2 variable {$b} 1 text b 0 {}}
-test parseExpr-14.21 {GetLexeme procedure, lexeme is "/"} {
- testexprparser {5/6} -1
-} {- {} 0 subexpr 5/6 5 operator / 0 subexpr 5 1 text 5 0 subexpr 6 1 text 6 0 {}}
-test parseExpr-14.22 {GetLexeme procedure, lexeme is "%"} {
- testexprparser {5%[xxx]} -1
-} {- {} 0 subexpr {5%[xxx]} 5 operator % 0 subexpr 5 1 text 5 0 subexpr {[xxx]} 1 command {[xxx]} 0 {}}
-test parseExpr-14.23 {GetLexeme procedure, lexeme is "+"} {
- testexprparser {1+2} -1
-} {- {} 0 subexpr 1+2 5 operator + 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-14.24 {GetLexeme procedure, lexeme is "-"} {
- testexprparser {.12-0e27} -1
-} {- {} 0 subexpr .12-0e27 5 operator - 0 subexpr .12 1 text .12 0 subexpr 0e27 1 text 0e27 0 {}}
-test parseExpr-14.25 {GetLexeme procedure, lexeme is "?" or ":"} {
- testexprparser {$b? 1 : 0} -1
-} {- {} 0 subexpr {$b? 1 : 0} 8 operator ? 0 subexpr {$b} 2 variable {$b} 1 text b 0 subexpr 1 1 text 1 0 subexpr 0 1 text 0 0 {}}
-test parseExpr-14.26 {GetLexeme procedure, lexeme is "<"} {
- testexprparser {2<3} -1
-} {- {} 0 subexpr 2<3 5 operator < 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-14.27 {GetLexeme procedure, lexeme is "<<"} {
- testexprparser {2<<3} -1
-} {- {} 0 subexpr 2<<3 5 operator << 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-14.28 {GetLexeme procedure, lexeme is "<="} {
- testexprparser {2<=3} -1
-} {- {} 0 subexpr 2<=3 5 operator <= 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-14.29 {GetLexeme procedure, lexeme is ">"} {
- testexprparser {2>3} -1
-} {- {} 0 subexpr 2>3 5 operator > 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-14.30 {GetLexeme procedure, lexeme is ">>"} {
- testexprparser {2>>3} -1
-} {- {} 0 subexpr 2>>3 5 operator >> 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-14.31 {GetLexeme procedure, lexeme is ">="} {
- testexprparser {2>=3} -1
-} {- {} 0 subexpr 2>=3 5 operator >= 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-14.32 {GetLexeme procedure, lexeme is "=="} {
- testexprparser {2==3} -1
-} {- {} 0 subexpr 2==3 5 operator == 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-14.33 {GetLexeme procedure, bad lexeme starting with "="} {
- list [catch {testexprparser {2=+3} -1} msg] $msg
-} {1 {syntax error in expression "2=+3"}}
-test parseExpr-14.34 {GetLexeme procedure, lexeme is "!="} {
- testexprparser {2!=3} -1
-} {- {} 0 subexpr 2!=3 5 operator != 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-14.35 {GetLexeme procedure, lexeme is "!"} {
- testexprparser {!2} -1
-} {- {} 0 subexpr !2 3 operator ! 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-14.36 {GetLexeme procedure, lexeme is "&&"} {
- testexprparser {2&&3} -1
-} {- {} 0 subexpr 2&&3 5 operator && 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-14.37 {GetLexeme procedure, lexeme is "&"} {
- testexprparser {1&2} -1
-} {- {} 0 subexpr 1&2 5 operator & 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-14.38 {GetLexeme procedure, lexeme is "^"} {
- testexprparser {1^2} -1
-} {- {} 0 subexpr 1^2 5 operator ^ 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-14.39 {GetLexeme procedure, lexeme is "||"} {
- testexprparser {2||3} -1
-} {- {} 0 subexpr 2||3 5 operator || 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-14.40 {GetLexeme procedure, lexeme is "|"} {
- testexprparser {1|2} -1
-} {- {} 0 subexpr 1|2 5 operator | 0 subexpr 1 1 text 1 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-14.41 {GetLexeme procedure, lexeme is "~"} {
- testexprparser {~2} -1
-} {- {} 0 subexpr ~2 3 operator ~ 0 subexpr 2 1 text 2 0 {}}
-test parseExpr-14.42 {GetLexeme procedure, lexeme is func name} {
- testexprparser {george()} -1
-} {- {} 0 subexpr george() 1 operator george 0 {}}
-test parseExpr-14.43 {GetLexeme procedure, lexeme is func name} {
- testexprparser {harmonic_ratio(2,3)} -1
-} {- {} 0 subexpr harmonic_ratio(2,3) 5 operator harmonic_ratio 0 subexpr 2 1 text 2 0 subexpr 3 1 text 3 0 {}}
-test parseExpr-14.44 {GetLexeme procedure, unknown lexeme} {
- list [catch {testexprparser {@27} -1} msg] $msg
-} {1 {syntax error in expression "@27"}}
-
-test parseExpr-15.1 {PrependSubExprTokens procedure, expand token array} {
- testexprparser {[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]} -1
-} {- {} 0 subexpr {[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]} 13 operator && 0 subexpr {[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]} 9 operator && 0 subexpr {[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]} 5 operator && 0 subexpr {[string compare [format %c $i] [string index $a $i]]} 1 command {[string compare [format %c $i] [string index $a $i]]} 0 subexpr {[string compare [format %c $i] [string index $a $i]]} 1 command {[string compare [format %c $i] [string index $a $i]]} 0 subexpr {[string compare [format %c $i] [string index $a $i]]} 1 command {[string compare [format %c $i] [string index $a $i]]} 0 subexpr {[string compare [format %c $i] [string index $a $i]]} 1 command {[string compare [format %c $i] [string index $a $i]]} 0 {}}
-
-test parse-16.1 {LogSyntaxError procedure, error in expr longer than 60 chars} {
- list [catch {testexprparser {(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)/} -1} msg] $msg
-} {1 {syntax error in expression "(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+0123456)*(+012"}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/parseOld.test b/tests/parseOld.test
deleted file mode 100644
index 3f799d6..0000000
--- a/tests/parseOld.test
+++ /dev/null
@@ -1,546 +0,0 @@
-# Commands covered: set (plus basic command syntax). Also tests the
-# procedures in the file tclOldParse.c. This set of tests is an old
-# one that predates the new parser in Tcl 8.1.
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-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: parseOld.test,v 1.2 1999/04/16 00:47:32 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-proc fourArgs {a b c d} {
- global arg1 arg2 arg3 arg4
- set arg1 $a
- set arg2 $b
- set arg3 $c
- set arg4 $d
-}
-
-proc getArgs args {
- global argv
- set argv $args
-}
-
-# Basic argument parsing.
-
-test parseOld-1.1 {basic argument parsing} {
- set arg1 {}
- fourArgs a b c d
- list $arg1 $arg2 $arg3 $arg4
-} {a b c d}
-test parseOld-1.2 {basic argument parsing} {
- set arg1 {}
- eval "fourArgs 123\v4\f56\r7890"
- list $arg1 $arg2 $arg3 $arg4
-} {123 4 56 7890}
-
-# Quotes.
-
-test parseOld-2.1 {quotes and variable-substitution} {
- getArgs "a b c" d
- set argv
-} {{a b c} d}
-test parseOld-2.2 {quotes and variable-substitution} {
- set a 101
- getArgs "a$a b c"
- set argv
-} {{a101 b c}}
-test parseOld-2.3 {quotes and variable-substitution} {
- set argv "xy[format xabc]"
- set argv
-} {xyxabc}
-test parseOld-2.4 {quotes and variable-substitution} {
- set argv "xy\t"
- set argv
-} xy\t
-test parseOld-2.5 {quotes and variable-substitution} {
- set argv "a b c
-d e f"
- set argv
-} a\ b\tc\nd\ e\ f
-test parseOld-2.6 {quotes and variable-substitution} {
- set argv a"bcd"e
- set argv
-} {a"bcd"e}
-
-# Braces.
-
-test parseOld-3.1 {braces} {
- getArgs {a b c} d
- set argv
-} "{a b c} d"
-test parseOld-3.2 {braces} {
- set a 101
- set argv {a$a b c}
- set b [string index $argv 1]
- set b
-} {$}
-test parseOld-3.3 {braces} {
- set argv {a[format xyz] b}
- string length $argv
-} 15
-test parseOld-3.4 {braces} {
- set argv {a\nb\}}
- string length $argv
-} 6
-test parseOld-3.5 {braces} {
- set argv {{{{}}}}
- set argv
-} "{{{}}}"
-test parseOld-3.6 {braces} {
- set argv a{{}}b
- set argv
-} "a{{}}b"
-test parseOld-3.7 {braces} {
- set a [format "last]"]
- set a
-} {last]}
-
-# Command substitution.
-
-test parseOld-4.1 {command substitution} {
- set a [format xyz]
- set a
-} xyz
-test parseOld-4.2 {command substitution} {
- set a a[format xyz]b[format q]
- set a
-} axyzbq
-test parseOld-4.3 {command substitution} {
- set a a[
-set b 22;
-format %s $b
-
-]b
- set a
-} a22b
-test parseOld-4.4 {command substitution} {
- set a 7.7
- if [catch {expr int($a)}] {set a foo}
- set a
-} 7.7
-
-# Variable substitution.
-
-test parseOld-5.1 {variable substitution} {
- set a 123
- set b $a
- set b
-} 123
-test parseOld-5.2 {variable substitution} {
- set a 345
- set b x$a.b
- set b
-} x345.b
-test parseOld-5.3 {variable substitution} {
- set _123z xx
- set b $_123z^
- set b
-} xx^
-test parseOld-5.4 {variable substitution} {
- set a 78
- set b a${a}b
- set b
-} a78b
-test parseOld-5.5 {variable substitution} {catch {$_non_existent_} msg} 1
-test parseOld-5.6 {variable substitution} {
- catch {$_non_existent_} msg
- set msg
-} {can't read "_non_existent_": no such variable}
-test parseOld-5.7 {array variable substitution} {
- catch {unset a}
- set a(xyz) 123
- set b $a(xyz)foo
- set b
-} 123foo
-test parseOld-5.8 {array variable substitution} {
- catch {unset a}
- set "a(x y z)" 123
- set b $a(x y z)foo
- set b
-} 123foo
-test parseOld-5.9 {array variable substitution} {
- catch {unset a}; catch {unset qqq}
- set "a(x y z)" qqq
- set $a([format x]\ y [format z]) foo
- set qqq
-} foo
-test parseOld-5.10 {array variable substitution} {
- catch {unset a}
- list [catch {set b $a(22)} msg] $msg
-} {1 {can't read "a(22)": no such variable}}
-test parseOld-5.11 {array variable substitution} {
- set b a$!
- set b
-} {a$!}
-test parseOld-5.12 {array variable substitution} {
- set b a$()
- set b
-} {a$()}
-catch {unset a}
-test parseOld-5.13 {array variable substitution} {
- catch {unset a}
- set long {This is a very long variable, long enough to cause storage \
- allocation to occur in Tcl_ParseVar. If that storage isn't getting \
- freed up correctly, then a core leak will occur when this test is \
- run. This text is probably beginning to sound like drivel, but I've \
- run out of things to say and I need more characters still.}
- set a($long) 777
- set b $a($long)
- list $b [array names a]
-} {777 {{This is a very long variable, long enough to cause storage \
- allocation to occur in Tcl_ParseVar. If that storage isn't getting \
- freed up correctly, then a core leak will occur when this test is \
- run. This text is probably beginning to sound like drivel, but I've \
- run out of things to say and I need more characters still.}}}
-test parseOld-5.14 {array variable substitution} {
- catch {unset a}; catch {unset b}; catch {unset a1}
- set a1(22) foo
- set a(foo) bar
- set b $a($a1(22))
- set b
-} bar
-catch {unset a}; catch {unset a1}
-
-test parseOld-7.1 {backslash substitution} {
- set a "\a\c\n\]\}"
- string length $a
-} 5
-test parseOld-7.2 {backslash substitution} {
- set a {\a\c\n\]\}}
- string length $a
-} 10
-test parseOld-7.3 {backslash substitution} {
- set a "abc\
-def"
- set a
-} {abc def}
-test parseOld-7.4 {backslash substitution} {
- set a {abc\
-def}
- set a
-} {abc def}
-test parseOld-7.5 {backslash substitution} {
- set msg {}
- set a xxx
- set error [catch {if {24 < \
- 35} {set a 22} {set \
- a 33}} msg]
- list $error $msg $a
-} {0 22 22}
-test parseOld-7.6 {backslash substitution} {
- eval "concat abc\\"
-} "abc\\"
-test parseOld-7.7 {backslash substitution} {
- eval "concat \\\na"
-} "a"
-test parseOld-7.8 {backslash substitution} {
- eval "concat x\\\n a"
-} "x a"
-test parseOld-7.9 {backslash substitution} {
- eval "concat \\x"
-} "x"
-test parseOld-7.10 {backslash substitution} {
- eval "list a b\\\nc d"
-} {a b c d}
-test parseOld-7.11 {backslash substitution} {
- eval "list a \"b c\"\\\nd e"
-} {a {b c} d e}
-test parseOld-7.12 {backslash substitution} {
- list \ua2
-} [bytestring "\xc2\xa2"]
-test parseOld-7.13 {backslash substitution} {
- list \u4e21
-} [bytestring "\xe4\xb8\xa1"]
-test parseOld-7.14 {backslash substitution} {
- list \u4e2k
-} [bytestring "\xd3\xa2k"]
-
-# Semi-colon.
-
-test parseOld-8.1 {semi-colons} {
- set b 0
- getArgs a;set b 2
- set argv
-} a
-test parseOld-8.2 {semi-colons} {
- set b 0
- getArgs a;set b 2
- set b
-} 2
-test parseOld-8.3 {semi-colons} {
- getArgs a b ; set b 1
- set argv
-} {a b}
-test parseOld-8.4 {semi-colons} {
- getArgs a b ; set b 1
- set b
-} 1
-
-# The following checks are to ensure that the interpreter's result
-# gets re-initialized by Tcl_Eval in all the right places.
-
-test parseOld-9.1 {result initialization} {concat abc} abc
-test parseOld-9.2 {result initialization} {concat abc; proc foo {} {}} {}
-test parseOld-9.3 {result initialization} {concat abc; proc foo {} $a} {}
-test parseOld-9.4 {result initialization} {proc foo {} [concat abc]} {}
-test parseOld-9.5 {result initialization} {concat abc; } abc
-test parseOld-9.6 {result initialization} {
- eval {
- concat abc
-}} abc
-test parseOld-9.7 {result initialization} {} {}
-test parseOld-9.8 {result initialization} {concat abc; ; ;} abc
-
-# Syntax errors.
-
-test parseOld-10.1 {syntax errors} {catch "set a \{bcd" msg} 1
-test parseOld-10.2 {syntax errors} {
- catch "set a \{bcd" msg
- set msg
-} {missing close-brace}
-test parseOld-10.3 {syntax errors} {catch {set a "bcd} msg} 1
-test parseOld-10.4 {syntax errors} {
- catch {set a "bcd} msg
- set msg
-} {missing "}
-test parseOld-10.5 {syntax errors} {catch {set a "bcd"xy} msg} 1
-test parseOld-10.6 {syntax errors} {
- catch {set a "bcd"xy} msg
- set msg
-} {extra characters after close-quote}
-test parseOld-10.7 {syntax errors} {catch "set a {bcd}xy" msg} 1
-test parseOld-10.8 {syntax errors} {
- catch "set a {bcd}xy" msg
- set msg
-} {extra characters after close-brace}
-test parseOld-10.9 {syntax errors} {catch {set a [format abc} msg} 1
-test parseOld-10.10 {syntax errors} {
- catch {set a [format abc} msg
- set msg
-} {missing close-bracket}
-test parseOld-10.11 {syntax errors} {catch gorp-a-lot msg} 1
-test parseOld-10.12 {syntax errors} {
- catch gorp-a-lot msg
- set msg
-} {invalid command name "gorp-a-lot"}
-test parseOld-10.13 {syntax errors} {
- set a [concat {a}\
- {b}]
- set a
-} {a b}
-test parseOld-10.14 {syntax errors} {
- list [catch {eval \$x[format "%01000d" 0](} msg] $msg $errorInfo
-} {1 {missing )} {missing )
- while compiling
-"$x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000..."
- ("eval" body line 1)
- invoked from within
-"eval \$x[format "%01000d" 0]("}}
-test parseOld-10.15 {syntax errors, missplaced braces} {
- catch {
- proc misplaced_end_brace {} {
- set what foo
- set when [expr ${what}size - [set off$what]}]
- } msg
- set msg
-} {extra characters after close-brace}
-test parseOld-10.16 {syntax errors, missplaced braces} {
- catch {
- set a {
- set what foo
- set when [expr ${what}size - [set off$what]}]
- } msg
- set msg
-} {extra characters after close-brace}
-test parseOld-10.17 {syntax errors, unusual spacing} {
- list [catch {return [ [1]]} msg] $msg
-} {1 {invalid command name "1"}}
-# Long values (stressing storage management)
-
-set a {1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH}
-
-test parseOld-11.1 {long values} {
- string length $a
-} 214
-test parseOld-11.2 {long values} {
- llength $a
-} 43
-test parseOld-11.3 {long values} {
- set b "1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH"
- set b
-} $a
-test parseOld-11.4 {long values} {
- set b "$a"
- set b
-} $a
-test parseOld-11.5 {long values} {
- set b [set a]
- set b
-} $a
-test parseOld-11.6 {long values} {
- set b [concat 1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH]
- string length $b
-} 214
-test parseOld-11.7 {long values} {
- set b [concat 1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH]
- llength $b
-} 43
-test parseOld-11.8 {long values} {
- set b
-} $a
-test parseOld-11.9 {long values} {
- set a [concat 0000 1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH IIII JJJJ KKKK LLLL MMMM NNNN OOOO PPPP QQQQ RRRR SSSS TTTT UUUU VVVV WWWW XXXX YYYY ZZZZ]
- llength $a
-} 62
-set i 0
-foreach j [concat 0000 1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH IIII JJJJ KKKK LLLL MMMM NNNN OOOO PPPP QQQQ RRRR SSSS TTTT UUUU VVVV WWWW XXXX YYYY ZZZZ] {
- set test [string index 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ $i]
- set test $test$test$test$test
- set i [expr $i+1]
- test parseOld-11.10 {long values} {
- set j
- } $test
-}
-test parseOld-11.11 {test buffer overflow in backslashes in braces} {
- expr {"a" == {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101}}
-} 0
-
-test parseOld-12.1 {comments} {
- set a old
- eval { # set a new}
- set a
-} {old}
-test parseOld-12.2 {comments} {
- set a old
- eval " # set a new\nset a new"
- set a
-} {new}
-test parseOld-12.3 {comments} {
- set a old
- eval " # set a new\\\nset a new"
- set a
-} {old}
-test parseOld-12.4 {comments} {
- set a old
- eval " # set a new\\\\\nset a new"
- set a
-} {new}
-
-test parseOld-13.1 {comments at the end of a bracketed script} {
- set x "[
-expr 1+1
-# skip this!
-]"
-} {2}
-
-if {[info command testwordend] == "testwordend"} {
- test parseOld-14.1 {TclWordEnd procedure} {
- testwordend " \n abc"
- } {c}
- test parseOld-14.2 {TclWordEnd procedure} {
- testwordend " \\\n"
- } {}
- test parseOld-14.3 {TclWordEnd procedure} {
- testwordend " \\\n "
- } { }
- test parseOld-14.4 {TclWordEnd procedure} {
- testwordend {"abc"}
- } {"}
- test parseOld-14.5 {TclWordEnd procedure} {
- testwordend {{xyz}}
- } \}
- test parseOld-14.6 {TclWordEnd procedure} {
- testwordend {{a{}b{}\}} xyz}
- } "\} xyz"
- test parseOld-14.7 {TclWordEnd procedure} {
- testwordend {abc[this is a]def ghi}
- } {f ghi}
- test parseOld-14.8 {TclWordEnd procedure} {
- testwordend "puts\\\n\n "
- } "s\\\n\n "
- test parseOld-14.9 {TclWordEnd procedure} {
- testwordend "puts\\\n "
- } "s\\\n "
- test parseOld-14.10 {TclWordEnd procedure} {
- testwordend "puts\\\n xyz"
- } "s\\\n xyz"
- test parseOld-14.11 {TclWordEnd procedure} {
- testwordend {a$x.$y(a long index) foo}
- } ") foo"
- test parseOld-14.12 {TclWordEnd procedure} {
- testwordend {abc; def}
- } {; def}
- test parseOld-14.13 {TclWordEnd procedure} {
- testwordend {abc def}
- } {c def}
- test parseOld-14.14 {TclWordEnd procedure} {
- testwordend {abc def}
- } {c def}
- test parseOld-14.15 {TclWordEnd procedure} {
- testwordend "abc\ndef"
- } "c\ndef"
- test parseOld-14.16 {TclWordEnd procedure} {
- testwordend "abc"
- } {c}
- test parseOld-14.17 {TclWordEnd procedure} {
- testwordend "a\000bc"
- } {c}
- test parseOld-14.18 {TclWordEnd procedure} {
- testwordend \[a\000\]
- } {]}
- test parseOld-14.19 {TclWordEnd procedure} {
- testwordend \"a\000\"
- } {"}
- test parseOld-14.20 {TclWordEnd procedure} {
- testwordend a{\000}b
- } {b}
- test parseOld-14.21 {TclWordEnd procedure} {
- testwordend " \000b"
- } {b}
-}
-
-test parseOld-15.1 {TclScriptEnd procedure} {
- info complete {puts [
- expr 1+1
- #this is a comment ]}
-} {0}
-test parseOld-15.2 {TclScriptEnd procedure} {
- info complete "abc\\\n"
-} {0}
-test parseOld-15.3 {TclScriptEnd procedure} {
- info complete "abc\\\\\n"
-} {1}
-test parseOld-15.4 {TclScriptEnd procedure} {
- info complete "xyz \[abc \{abc\]"
-} {0}
-test parseOld-15.5 {TclScriptEnd procedure} {
- info complete "xyz \[abc"
-} {0}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/pid.test b/tests/pid.test
deleted file mode 100644
index 3f8275b..0000000
--- a/tests/pid.test
+++ /dev/null
@@ -1,70 +0,0 @@
-# Commands covered: pid
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-1995 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: pid.test,v 1.3 1999/04/16 00:47:32 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# If pid is not defined just return with no error
-# Some platforms may not have the pid command implemented
-if {[info commands pid] == ""} {
- puts "pid is not implemented for this machine"
- ::tcltest::cleanupTests
- return
-}
-
-catch {removeFile test1}
-
-test pid-1.1 {pid command} {
- regexp {(^[0-9]+$)|(^0x[0-9a-fA-F]+$)} [pid]
-} 1
-test pid-1.2 {pid command} {unixOrPc unixExecs} {
- set f [open {| echo foo | cat >test1} w]
- set pids [pid $f]
- close $f
- catch {removeFile test1}
- list [llength $pids] [regexp {^[0-9]+$} [lindex $pids 0]] \
- [regexp {^[0-9]+$} [lindex $pids 1]] \
- [expr {[lindex $pids 0] == [lindex $pids 1]}]
-} {2 1 1 0}
-test pid-1.3 {pid command} {
- set f [open test1 w]
- set pids [pid $f]
- close $f
- set pids
-} {}
-test pid-1.4 {pid command} {
- list [catch {pid a b} msg] $msg
-} {1 {wrong # args: should be "pid ?channelId?"}}
-test pid-1.5 {pid command} {
- list [catch {pid gorp} msg] $msg
-} {1 {can not find channel named "gorp"}}
-
-# cleanup
-catch {::tcltest::removeFile test1}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/pkg.test b/tests/pkg.test
deleted file mode 100644
index 02ffc14..0000000
--- a/tests/pkg.test
+++ /dev/null
@@ -1,652 +0,0 @@
-# Commands covered: pkg
-#
-# 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) 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: pkg.test,v 1.4 1999/04/16 00:47:32 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Do all this in a slave interp to avoid garbaging the
-# package list
-set i [interp create]
-interp eval $i [list set argv $argv]
-interp eval $i [list source [file join $::tcltest::testsDir defs.tcl]]
-interp eval $i {
-
-eval package forget [package names]
-set oldPkgUnknown [package unknown]
-package unknown {}
-set oldPath $auto_path
-set auto_path ""
-
-test pkg-1.1 {Tcl_PkgProvide procedure} {
- package forget t
- package provide t 2.3
-} {}
-test pkg-1.2 {Tcl_PkgProvide procedure} {
- package forget t
- package provide t 2.3
- list [catch {package provide t 2.2} msg] $msg
-} {1 {conflicting versions provided for package "t": 2.3, then 2.2}}
-test pkg-1.3 {Tcl_PkgProvide procedure} {
- package forget t
- package provide t 2.3
- list [catch {package provide t 2.4} msg] $msg
-} {1 {conflicting versions provided for package "t": 2.3, then 2.4}}
-test pkg-1.4 {Tcl_PkgProvide procedure} {
- package forget t
- package provide t 2.3
- list [catch {package provide t 3.3} msg] $msg
-} {1 {conflicting versions provided for package "t": 2.3, then 3.3}}
-test pkg-1.5 {Tcl_PkgProvide procedure} {
- package forget t
- package provide t 2.3
- package provide t 2.3
-} {}
-
-test pkg-2.1 {Tcl_PkgRequire procedure, picking best version} {
- package forget t
- foreach i {1.4 3.4 2.3 2.4 2.2} {
- package ifneeded t $i "set x $i; package provide t $i"
- }
- set x xxx
- package require t
- set x
-} {3.4}
-test pkg-2.2 {Tcl_PkgRequire procedure, picking best version} {
- package forget t
- foreach i {1.4 3.4 2.3 2.4 2.2 3.5 3.2} {
- package ifneeded t $i "set x $i; package provide t $i"
- }
- set x xxx
- package require t
- set x
-} {3.5}
-test pkg-2.3 {Tcl_PkgRequire procedure, picking best version} {
- package forget t
- foreach i {3.5 2.1 2.3} {
- package ifneeded t $i "set x $i; package provide t $i"
- }
- set x xxx
- package require t 2.2
- set x
-} {2.3}
-test pkg-2.4 {Tcl_PkgRequire procedure, picking best version} {
- package forget t
- foreach i {1.4 3.4 2.3 2.4 2.2} {
- package ifneeded t $i "set x $i; package provide t $i"
- }
- set x xxx
- package require -exact t 2.3
- set x
-} {2.3}
-test pkg-2.5 {Tcl_PkgRequire procedure, picking best version} {
- package forget t
- foreach i {1.4 3.4 2.3 2.4 2.2} {
- package ifneeded t $i "set x $i; package provide t $i"
- }
- set x xxx
- package require t 2.1
- set x
-} {2.4}
-test pkg-2.6 {Tcl_PkgRequire procedure, can't find suitable version} {
- package forget t
- package unknown {}
- foreach i {1.4 3.4 2.3 2.4 2.2} {
- package ifneeded t $i "set x $i"
- }
- list [catch {package require t 2.5} msg] $msg
-} {1 {can't find package t 2.5}}
-test pkg-2.7 {Tcl_PkgRequire procedure, can't find suitable version} {
- package forget t
- package unknown {}
- foreach i {1.4 3.4 2.3 2.4 2.2} {
- package ifneeded t $i "set x $i"
- }
- list [catch {package require t 4.1} msg] $msg
-} {1 {can't find package t 4.1}}
-test pkg-2.8 {Tcl_PkgRequire procedure, can't find suitable version} {
- package forget t
- package unknown {}
- foreach i {1.4 3.4 2.3 2.4 2.2} {
- package ifneeded t $i "set x $i"
- }
- list [catch {package require -exact t 1.3} msg] $msg
-} {1 {can't find package t 1.3}}
-test pkg-2.9 {Tcl_PkgRequire procedure, can't find suitable version} {
- package forget t
- package unknown {}
- list [catch {package require t} msg] $msg
-} {1 {can't find package t}}
-test pkg-2.10 {Tcl_PkgRequire procedure, error in ifneeded script} {
- package forget t
- package ifneeded t 2.1 {package provide t 2.1; error "ifneeded test"}
- list [catch {package require t 2.1} msg] $msg $errorInfo
-} {1 {ifneeded test} {ifneeded test
- while executing
-"error "ifneeded test""
- ("package ifneeded" script)
- invoked from within
-"package require t 2.1"}}
-test pkg-2.11 {Tcl_PkgRequire procedure, ifneeded script doesn't provide package} {
- package forget t
- package ifneeded t 2.1 "set x invoked"
- set x xxx
- list [catch {package require t 2.1} msg] $msg $x
-} {1 {can't find package t 2.1} invoked}
-test pkg-2.12 {Tcl_PkgRequire procedure, self-deleting script} {
- package forget t
- package ifneeded t 1.2 "package forget t; set x 1.2; package provide t 1.2"
- set x xxx
- package require t 1.2
- set x
-} {1.2}
-test pkg-2.13 {Tcl_PkgRequire procedure, "package unknown" support} {
- proc pkgUnknown args {
- global x
- set x $args
- package provide [lindex $args 0] [lindex $args 1]
- }
- package forget t
- foreach i {1.4 3.4 2.3 2.4 2.2} {
- package ifneeded t $i "set x $i"
- }
- package unknown pkgUnknown
- set x xxx
- package require -exact t 1.5
- package unknown {}
- set x
-} {t 1.5 -exact}
-test pkg-2.14 {Tcl_PkgRequire procedure, "package unknown" support} {
- proc pkgUnknown args {
- package ifneeded t 1.2 "set x loaded; package provide t 1.2"
- }
- package forget t
- package unknown pkgUnknown
- set x xxx
- set result [list [package require t] $x]
- package unknown {}
- set result
-} {1.2 loaded}
-test pkg-2.15 {Tcl_PkgRequire procedure, "package unknown" support} {
- proc pkgUnknown args {
- global x
- set x $args
- package provide [lindex $args 0] 2.0
- }
- package forget {a b}
- package unknown pkgUnknown
- set x xxx
- package require {a b}
- package unknown {}
- set x
-} {{a b} {}}
-test pkg-2.16 {Tcl_PkgRequire procedure, "package unknown" error} {
- proc pkgUnknown args {
- error "testing package unknown"
- }
- package forget t
- package unknown pkgUnknown
- set result [list [catch {package require t} msg] $msg $errorInfo]
- package unknown {}
- set result
-} {1 {testing package unknown} {testing package unknown
- while executing
-"error "testing package unknown""
- (procedure "pkgUnknown" line 2)
- invoked from within
-"pkgUnknown t {}"
- ("package unknown" script)
- invoked from within
-"package require t"}}
-test pkg-2.17 {Tcl_PkgRequire procedure, "package unknown" doesn't load package} {
- proc pkgUnknown args {
- global x
- set x $args
- }
- package forget t
- foreach i {1.4 3.4 2.3 2.4 2.2} {
- package ifneeded t $i "set x $i"
- }
- package unknown pkgUnknown
- set x xxx
- set result [list [catch {package require -exact t 1.5} msg] $msg $x]
- package unknown {}
- set result
-} {1 {can't find package t 1.5} {t 1.5 -exact}}
-test pkg-2.18 {Tcl_PkgRequire procedure, version checks} {
- package forget t
- package provide t 2.3
- package require t
-} {2.3}
-test pkg-2.19 {Tcl_PkgRequire procedure, version checks} {
- package forget t
- package provide t 2.3
- package require t 2.1
-} {2.3}
-test pkg-2.20 {Tcl_PkgRequire procedure, version checks} {
- package forget t
- package provide t 2.3
- package require t 2.3
-} {2.3}
-test pkg-2.21 {Tcl_PkgRequire procedure, version checks} {
- package forget t
- package provide t 2.3
- list [catch {package require t 2.4} msg] $msg
-} {1 {version conflict for package "t": have 2.3, need 2.4}}
-test pkg-2.22 {Tcl_PkgRequire procedure, version checks} {
- package forget t
- package provide t 2.3
- list [catch {package require t 1.2} msg] $msg
-} {1 {version conflict for package "t": have 2.3, need 1.2}}
-test pkg-2.23 {Tcl_PkgRequire procedure, version checks} {
- package forget t
- package provide t 2.3
- package require -exact t 2.3
-} {2.3}
-test pkg-2.24 {Tcl_PkgRequire procedure, version checks} {
- package forget t
- package provide t 2.3
- list [catch {package require -exact t 2.2} msg] $msg
-} {1 {version conflict for package "t": have 2.3, need 2.2}}
-
-test pkg-3.1 {Tcl_PackageCmd procedure} {
- list [catch {package} msg] $msg
-} {1 {wrong # args: should be "package option ?arg arg ...?"}}
-test pkg-3.2 {Tcl_PackageCmd procedure, "forget" option} {
- foreach i [package names] {
- package forget $i
- }
- package names
-} {}
-test pkg-3.3 {Tcl_PackageCmd procedure, "forget" option} {
- foreach i [package names] {
- package forget $i
- }
- package forget foo
-} {}
-test pkg-3.4 {Tcl_PackageCmd procedure, "forget" option} {
- foreach i [package names] {
- package forget $i
- }
- package ifneeded t 1.1 {first script}
- package ifneeded t 2.3 {second script}
- package ifneeded x 1.4 {x's script}
- set result {}
- lappend result [lsort [package names]] [package versions t]
- package forget t
- lappend result [lsort [package names]] [package versions t]
-} {{t x} {1.1 2.3} x {}}
-test pkg-3.5 {Tcl_PackageCmd procedure, "forget" option} {
- foreach i [package names] {
- package forget $i
- }
- package ifneeded a 1.1 {first script}
- package ifneeded b 2.3 {second script}
- package ifneeded c 1.4 {third script}
- package forget
- set result [list [lsort [package names]]]
- package forget a c
- lappend result [lsort [package names]]
-} {{a b c} b}
-test pkg-3.6 {Tcl_PackageCmd procedure, "ifneeded" option} {
- list [catch {package ifneeded a} msg] $msg
-} {1 {wrong # args: should be "package ifneeded package version ?script?"}}
-test pkg-3.7 {Tcl_PackageCmd procedure, "ifneeded" option} {
- list [catch {package ifneeded a b c d} msg] $msg
-} {1 {wrong # args: should be "package ifneeded package version ?script?"}}
-test pkg-3.8 {Tcl_PackageCmd procedure, "ifneeded" option} {
- list [catch {package ifneeded t xyz} msg] $msg
-} {1 {expected version number but got "xyz"}}
-test pkg-3.9 {Tcl_PackageCmd procedure, "ifneeded" option} {
- foreach i [package names] {
- package forget $i
- }
- list [package ifneeded foo 1.1] [package names]
-} {{} {}}
-test pkg-3.10 {Tcl_PackageCmd procedure, "ifneeded" option} {
- package forget t
- package ifneeded t 1.4 "script for t 1.4"
- list [package names] [package ifneeded t 1.4] [package versions t]
-} {t {script for t 1.4} 1.4}
-test pkg-3.11 {Tcl_PackageCmd procedure, "ifneeded" option} {
- package forget t
- package ifneeded t 1.4 "script for t 1.4"
- list [package ifneeded t 1.5] [package names] [package versions t]
-} {{} t 1.4}
-test pkg-3.12 {Tcl_PackageCmd procedure, "ifneeded" option} {
- package forget t
- package ifneeded t 1.4 "script for t 1.4"
- package ifneeded t 1.4 "second script for t 1.4"
- list [package ifneeded t 1.4] [package names] [package versions t]
-} {{second script for t 1.4} t 1.4}
-test pkg-3.13 {Tcl_PackageCmd procedure, "ifneeded" option} {
- package forget t
- package ifneeded t 1.4 "script for t 1.4"
- package ifneeded t 1.2 "second script"
- package ifneeded t 3.1 "last script"
- list [package ifneeded t 1.2] [package versions t]
-} {{second script} {1.4 1.2 3.1}}
-test pkg-3.14 {Tcl_PackageCmd procedure, "names" option} {
- list [catch {package names a} msg] $msg
-} {1 {wrong # args: should be "package names"}}
-test pkg-3.15 {Tcl_PackageCmd procedure, "names" option} {
- foreach i [package names] {
- package forget $i
- }
- package names
-} {}
-test pkg-3.16 {Tcl_PackageCmd procedure, "names" option} {
- foreach i [package names] {
- package forget $i
- }
- package ifneeded x 1.2 {dummy}
- package provide x 1.3
- package provide y 2.4
- catch {package require z 47.16}
- lsort [package names]
-} {x y}
-test pkg-3.17 {Tcl_PackageCmd procedure, "provide" option} {
- list [catch {package provide} msg] $msg
-} {1 {wrong # args: should be "package provide package ?version?"}}
-test pkg-3.18 {Tcl_PackageCmd procedure, "provide" option} {
- list [catch {package provide a b c} msg] $msg
-} {1 {wrong # args: should be "package provide package ?version?"}}
-test pkg-3.19 {Tcl_PackageCmd procedure, "provide" option} {
- package forget t
- package provide t
-} {}
-test pkg-3.20 {Tcl_PackageCmd procedure, "provide" option} {
- package forget t
- package provide t 2.3
- package provide t
-} {2.3}
-test pkg-3.21 {Tcl_PackageCmd procedure, "provide" option} {
- package forget t
- list [catch {package provide t a.b} msg] $msg
-} {1 {expected version number but got "a.b"}}
-test pkg-3.22 {Tcl_PackageCmd procedure, "require" option} {
- list [catch {package require} msg] $msg
-} {1 {wrong # args: should be "package require ?-exact? package ?version?"}}
-test pkg-3.23 {Tcl_PackageCmd procedure, "require" option} {
- list [catch {package require a b c} msg] $msg
-} {1 {wrong # args: should be "package require ?-exact? package ?version?"}}
-test pkg-3.24 {Tcl_PackageCmd procedure, "require" option} {
- list [catch {package require -exact a b c} msg] $msg
-} {1 {wrong # args: should be "package require ?-exact? package ?version?"}}
-test pkg-3.25 {Tcl_PackageCmd procedure, "require" option} {
- list [catch {package require -bs a b} msg] $msg
-} {1 {wrong # args: should be "package require ?-exact? package ?version?"}}
-test pkg-3.26 {Tcl_PackageCmd procedure, "require" option} {
- list [catch {package require x a.b} msg] $msg
-} {1 {expected version number but got "a.b"}}
-test pkg-3.27 {Tcl_PackageCmd procedure, "require" option} {
- list [catch {package require -exact x a.b} msg] $msg
-} {1 {expected version number but got "a.b"}}
-test pkg-3.28 {Tcl_PackageCmd procedure, "require" option} {
- list [catch {package require -exact x} msg] $msg
-} {1 {wrong # args: should be "package require ?-exact? package ?version?"}}
-test pkg-3.29 {Tcl_PackageCmd procedure, "require" option} {
- list [catch {package require -exact} msg] $msg
-} {1 {wrong # args: should be "package require ?-exact? package ?version?"}}
-test pkg-3.30 {Tcl_PackageCmd procedure, "require" option} {
- package forget t
- package provide t 2.3
- package require t 2.1
-} {2.3}
-test pkg-3.31 {Tcl_PackageCmd procedure, "require" option} {
- package forget t
- list [catch {package require t} msg] $msg
-} {1 {can't find package t}}
-test pkg-3.32 {Tcl_PackageCmd procedure, "require" option} {
- package forget t
- package ifneeded t 2.3 "error {synthetic error}"
- list [catch {package require t 2.3} msg] $msg
-} {1 {synthetic error}}
-test pkg-3.33 {Tcl_PackageCmd procedure, "unknown" option} {
- list [catch {package unknown a b} msg] $msg
-} {1 {wrong # args: should be "package unknown ?command?"}}
-test pkg-3.34 {Tcl_PackageCmd procedure, "unknown" option} {
- package unknown "test script"
- package unknown
-} {test script}
-test pkg-3.35 {Tcl_PackageCmd procedure, "unknown" option} {
- package unknown "test script"
- package unknown {}
- package unknown
-} {}
-test pkg-3.36 {Tcl_PackageCmd procedure, "vcompare" option} {
- list [catch {package vcompare a} msg] $msg
-} {1 {wrong # args: should be "package vcompare version1 version2"}}
-test pkg-3.37 {Tcl_PackageCmd procedure, "vcompare" option} {
- list [catch {package vcompare a b c} msg] $msg
-} {1 {wrong # args: should be "package vcompare version1 version2"}}
-test pkg-3.38 {Tcl_PackageCmd procedure, "vcompare" option} {
- list [catch {package vcompare x.y 3.4} msg] $msg
-} {1 {expected version number but got "x.y"}}
-test pkg-3.39 {Tcl_PackageCmd procedure, "vcompare" option} {
- list [catch {package vcompare 2.1 a.b} msg] $msg
-} {1 {expected version number but got "a.b"}}
-test pkg-3.40 {Tcl_PackageCmd procedure, "vcompare" option} {
- package vc 2.1 2.3
-} {-1}
-test pkg-3.41 {Tcl_PackageCmd procedure, "vcompare" option} {
- package vc 2.2.4 2.2.4
-} {0}
-test pkg-3.42 {Tcl_PackageCmd procedure, "versions" option} {
- list [catch {package versions} msg] $msg
-} {1 {wrong # args: should be "package versions package"}}
-test pkg-3.43 {Tcl_PackageCmd procedure, "versions" option} {
- list [catch {package versions a b} msg] $msg
-} {1 {wrong # args: should be "package versions package"}}
-test pkg-3.44 {Tcl_PackageCmd procedure, "versions" option} {
- package forget t
- package versions t
-} {}
-test pkg-3.45 {Tcl_PackageCmd procedure, "versions" option} {
- package forget t
- package provide t 2.3
- package versions t
-} {}
-test pkg-3.46 {Tcl_PackageCmd procedure, "versions" option} {
- package forget t
- package ifneeded t 2.3 x
- package ifneeded t 2.4 y
- package versions t
-} {2.3 2.4}
-test pkg-3.47 {Tcl_PackageCmd procedure, "vsatisfies" option} {
- list [catch {package vsatisfies a} msg] $msg
-} {1 {wrong # args: should be "package vsatisfies version1 version2"}}
-test pkg-3.48 {Tcl_PackageCmd procedure, "vsatisfies" option} {
- list [catch {package vsatisfies a b c} msg] $msg
-} {1 {wrong # args: should be "package vsatisfies version1 version2"}}
-test pkg-3.49 {Tcl_PackageCmd procedure, "vsatisfies" option} {
- list [catch {package vsatisfies x.y 3.4} msg] $msg
-} {1 {expected version number but got "x.y"}}
-test pkg-3.50 {Tcl_PackageCmd procedure, "vsatisfies" option} {
- list [catch {package vcompare 2.1 a.b} msg] $msg
-} {1 {expected version number but got "a.b"}}
-test pkg-3.51 {Tcl_PackageCmd procedure, "vsatisfies" option} {
- package vs 2.3 2.1
-} {1}
-test pkg-3.52 {Tcl_PackageCmd procedure, "vsatisfies" option} {
- package vs 2.3 1.2
-} {0}
-test pkg-3.53 {Tcl_PackageCmd procedure, "versions" option} {
- list [catch {package foo} msg] $msg
-} {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.
-
-test pkg-4.1 {TclFreePackageInfo procedure} {
- interp create foo
- foo eval {
- package ifneeded t 2.3 x
- package ifneeded t 2.4 y
- package ifneeded x 3.1 z
- package provide q 4.3
- package unknown "will this get freed?"
- }
- interp delete foo
-} {}
-test pkg-4.2 {TclFreePackageInfo procedure} {
- interp create foo
- foo eval {
- package ifneeded t 2.3 x
- package ifneeded t 2.4 y
- package ifneeded x 3.1 z
- package provide q 4.3
- }
- foo alias z kill
- proc kill {} {
- interp delete foo
- }
- list [catch {foo eval package require x 3.1} msg] $msg
-} {1 {can't find package x 3.1}}
-
-test pkg-5.1 {CheckVersion procedure} {
- list [catch {package vcompare 1 2.1} msg] $msg
-} {0 -1}
-test pkg-5.2 {CheckVersion procedure} {
- list [catch {package vcompare .1 2.1} msg] $msg
-} {1 {expected version number but got ".1"}}
-test pkg-5.3 {CheckVersion procedure} {
- list [catch {package vcompare 111.2a.3 2.1} msg] $msg
-} {1 {expected version number but got "111.2a.3"}}
-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-6.1 {ComparePkgVersions procedure} {
- package vcompare 1.23 1.22
-} {1}
-test pkg-6.2 {ComparePkgVersions procedure} {
- package vcompare 1.22.1.2.3 1.22.1.2.3
-} {0}
-test pkg-6.3 {ComparePkgVersions procedure} {
- package vcompare 1.21 1.22
-} {-1}
-test pkg-6.4 {ComparePkgVersions procedure} {
- package vcompare 1.21 1.21.2
-} {-1}
-test pkg-6.5 {ComparePkgVersions procedure} {
- package vcompare 1.21.1 1.21
-} {1}
-test pkg-6.6 {ComparePkgVersions procedure} {
- package vsatisfies 1.21.1 1.21
-} {1}
-test pkg-6.7 {ComparePkgVersions procedure} {
- package vsatisfies 2.22.3 1.21
-} {0}
-test pkg-6.8 {ComparePkgVersions procedure} {
- package vsatisfies 1 1
-} {1}
-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
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/pkg/circ1.tcl b/tests/pkg/circ1.tcl
deleted file mode 100644
index 3616621..0000000
--- a/tests/pkg/circ1.tcl
+++ /dev/null
@@ -1,34 +0,0 @@
-# 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
deleted file mode 100644
index 66a20a3..0000000
--- a/tests/pkg/circ2.tcl
+++ /dev/null
@@ -1,25 +0,0 @@
-# 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
deleted file mode 100644
index ddcb691..0000000
--- a/tests/pkg/circ3.tcl
+++ /dev/null
@@ -1,25 +0,0 @@
-# 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
deleted file mode 100644
index 38925c5..0000000
--- a/tests/pkg/global.tcl
+++ /dev/null
@@ -1,19 +0,0 @@
-# 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/import.tcl b/tests/pkg/import.tcl
deleted file mode 100644
index e7196f5..0000000
--- a/tests/pkg/import.tcl
+++ /dev/null
@@ -1,16 +0,0 @@
-package provide fubar 1.0
-
-namespace eval ::fubar:: {
- #
- # export only public functions.
- #
- namespace export {[a-z]*}
-}
-
-proc ::fubar::foo {bar} {
- puts "$bar"
- return true
-}
-
-namespace import ::fubar::foo
-
diff --git a/tests/pkg/pkg1.tcl b/tests/pkg/pkg1.tcl
deleted file mode 100644
index e2cf960..0000000
--- a/tests/pkg/pkg1.tcl
+++ /dev/null
@@ -1,26 +0,0 @@
-# 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
deleted file mode 100644
index 85e16c4..0000000
--- a/tests/pkg/pkg2_a.tcl
+++ /dev/null
@@ -1,22 +0,0 @@
-# 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
deleted file mode 100644
index 15fb1a8..0000000
--- a/tests/pkg/pkg2_b.tcl
+++ /dev/null
@@ -1,22 +0,0 @@
-# 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
deleted file mode 100644
index fd769c4..0000000
--- a/tests/pkg/pkg3.tcl
+++ /dev/null
@@ -1,22 +0,0 @@
-# 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
deleted file mode 100644
index ccb9291..0000000
--- a/tests/pkg/pkg4.tcl
+++ /dev/null
@@ -1,27 +0,0 @@
-# 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
deleted file mode 100644
index 5e25e6d..0000000
--- a/tests/pkg/pkg5.tcl
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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
deleted file mode 100644
index e964f51..0000000
--- a/tests/pkg/pkga.tcl
+++ /dev/null
@@ -1,15 +0,0 @@
-# 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
deleted file mode 100644
index a2cf121..0000000
--- a/tests/pkg/simple.tcl
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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
deleted file mode 100644
index 48c4048..0000000
--- a/tests/pkg/std.tcl
+++ /dev/null
@@ -1,28 +0,0 @@
-# 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
deleted file mode 100644
index cc10330..0000000
--- a/tests/pkg1/direct1.tcl
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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
deleted file mode 100644
index 5dc1d5e..0000000
--- a/tests/pkg1/pkgIndex.tcl
+++ /dev/null
@@ -1,11 +0,0 @@
-# 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/pkgMkIndex.test b/tests/pkgMkIndex.test
deleted file mode 100644
index e49cf25..0000000
--- a/tests/pkgMkIndex.test
+++ /dev/null
@@ -1,375 +0,0 @@
-# This file contains tests for the pkg_mkIndex command.
-# Note that the tests are limited to Tcl scripts only, there are no shared
-# libraries against which to test.
-#
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 1998-1999 by Scriptics Corporation.
-# All rights reserved.
-#
-# RCS: @(#) $Id: pkgMkIndex.test,v 1.6 1999/04/16 00:47:32 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# temporarily copy the pkg and pkg1 dirs from testsDir to tmpDir
-if {"$::tcltest::testsDir" != "$::tcltest::workingDir"} {
- set origPkgDir [file join $::tcltest::testsDir pkg]
- set newPkgDir [file join $::tcltest::workingDir pkg]
- if {![catch {file copy $origPkgDir $newPkgDir}]} {
- set removePkgDir 1
- }
- if {![catch {file copy "${origPkgDir}1" "${newPkgDir}1"}]} {
- set removePkg1Dir 1
- }
-}
-
-# Add the pkg1 directory to auto_path, so that its packages can be found.
-# packages in pkg1 are used to test indexing of packages in pkg.
-# Make sure that the path to pkg1 is absolute.
-
-set oldDir [pwd]
-lappend auto_path [file join $::tcltest::workingDir pkg1]
-
-namespace eval pkgtest {
- # Namespace for procs we can discard
-}
-
-# pkgtest::parseArgs --
-#
-# Parse an argument list.
-#
-# Arguments:
-# <flags> (optional) arguments starting with a dash are collected
-# as options to pkg_mkIndex and passed to pkg_mkIndex.
-# dirPath the directory to index
-# pattern0 pattern to index
-# ... pattern to index
-# patternN pattern to index
-#
-# Results:
-# Returns a three element list:
-# 0: the options
-# 1: the directory to index
-# 2: the patterns list
-
-proc pkgtest::parseArgs { args } {
- set options ""
-
- set argc [llength $args]
- for {set iarg 0} {$iarg < $argc} {incr iarg} {
- set a [lindex $args $iarg]
- if {[regexp {^-} $a]} {
- lappend options $a
- if {[string compare -load $a] == 0} {
- incr iarg
- lappend options [lindex $args $iarg]
- }
- } else {
- break
- }
- }
-
- set dirPath [lindex $args $iarg]
- incr iarg
- set patternList [lrange $args $iarg end]
-
- return [list $options $dirPath $patternList]
-}
-
-# pkgtest::parseIndex --
-#
-# Loads a pkgIndex.tcl file, records all the calls to "package ifneeded".
-#
-# Arguments:
-# filePath path to the pkgIndex.tcl file.
-#
-# Results:
-# Returns a list, in "array set/get" format, where the keys are the package
-# name and version (in the form "$name:$version"), and the values the rest
-# of the command line.
-
-proc pkgtest::parseIndex { filePath } {
- # create a slave interpreter, where we override "package ifneeded"
-
- set slave [interp create]
- if {[catch {
- $slave eval {
- rename package package_original
- proc package { args } {
- if {[string compare [lindex $args 0] ifneeded] == 0} {
- set pkg [lindex $args 1]
- set ver [lindex $args 2]
- set ::PKGS($pkg:$ver) [lindex $args 3]
- } else {
- return [eval package_original $args]
- }
- }
- array set ::PKGS {}
- }
-
- set dir [file dirname $filePath]
- $slave eval {set curdir [pwd]}
- $slave eval [list cd $dir]
- $slave eval [list set dir $dir]
- $slave eval [list source [file tail $filePath]]
- $slave eval {cd $curdir}
-
- # Create the list in sorted order, so that we don't get spurious
- # errors because the order has changed.
-
- array set P {}
- foreach {k v} [$slave eval {array get ::PKGS}] {
- set P($k) $v
- }
-
- set PKGS ""
- foreach k [lsort [array names P]] {
- lappend PKGS $k $P($k)
- }
- } err]} {
- set ei $::errorInfo
- set ec $::errorCode
-
- catch {interp delete $slave}
-
- error $ei $ec
- }
-
- interp delete $slave
-
- return $PKGS
-}
-
-# pkgtest::createIndex --
-#
-# Runs pkg_mkIndex for the given directory and set of patterns.
-# This procedure deletes any pkgIndex.tcl file in the target directory,
-# then runs pkg_mkIndex.
-#
-# Arguments:
-# <flags> (optional) arguments starting with a dash are collected
-# as options to pkg_mkIndex and passed to pkg_mkIndex.
-# dirPath the directory to index
-# pattern0 pattern to index
-# ... pattern to index
-# patternN pattern to index
-#
-# Results:
-# Returns a two element list:
-# 0: 1 if the procedure encountered an error, 0 otherwise.
-# 1: the error result if element 0 was 1
-
-proc pkgtest::createIndex { args } {
- set parsed [eval parseArgs $args]
- set options [lindex $parsed 0]
- set dirPath [lindex $parsed 1]
- set patternList [lindex $parsed 2]
-
- if {[catch {
- file delete [file join $dirPath pkgIndex.tcl]
- eval pkg_mkIndex $options $dirPath $patternList
- } err]} {
- return [list 1 $err]
- }
-
- return [list 0 {}]
-}
-
-# makePkgList --
-#
-# Takes the output of a pkgtest::parseIndex call, filters it and returns a
-# cleaned up list of packages and their actions.
-#
-# Arguments:
-# inList output from a pkgtest::parseIndex.
-#
-# Results:
-# Returns a list of two element lists:
-# 0: the name:version
-# 1: a list describing the package.
-# For tclPkgSetup packages it consists of:
-# 0: the keyword tclPkgSetup
-# 1: the first file to source, with its exported procedures
-# 2: the second file ...
-# N: the N-1st file ...
-
-proc makePkgList { inList } {
- set pkgList ""
-
- foreach {k v} $inList {
- switch [lindex $v 0] {
- tclPkgSetup {
- set l tclPkgSetup
- foreach s [lindex $v 4] {
- lappend l $s
- }
- }
-
- source {
- set l $v
- }
-
- default {
- error "can't handle $k $v"
- }
- }
-
- lappend pkgList [list $k $l]
- }
-
- return $pkgList
-}
-
-# pkgtest::runIndex --
-#
-# Runs pkg_mkIndex, parses the generated index file.
-#
-# Arguments:
-# <flags> (optional) arguments starting with a dash are collected
-# as options to pkg_mkIndex and passed to pkg_mkIndex.
-# dirPath the directory to index
-# pattern0 pattern to index
-# ... pattern to index
-# patternN pattern to index
-#
-# Results:
-# Returns a two element list:
-# 0: 1 if the procedure encountered an error, 0 otherwise.
-# 1: if no error, this is the parsed generated index file, in the format
-# returned by pkgtest::parseIndex.
-# If error, this is the error result.
-
-proc pkgtest::runIndex { args } {
- set rv [eval createIndex $args]
- if {[lindex $rv 0] == 0} {
- set parsed [eval parseArgs $args]
- set dirPath [lindex $parsed 1]
- set idxFile [file join $dirPath pkgIndex.tcl]
-
- if {[catch {
- set result [list 0 [makePkgList [parseIndex $idxFile]]]
- } err]} {
- set result [list 1 $err]
- }
- file delete $idxFile
- } else {
- set result $rv
- }
-
- return $result
-}
-
-# If there is no match to the patterns, make sure the directory hasn't
-# changed on us
-
-test pkgMkIndex-1.1 {nothing matches pattern - current dir is the same} {
- list [pkgtest::runIndex pkg nomatch.tcl] [pwd]
-} [list {1 {no files matched glob pattern "nomatch.tcl"}} [pwd]]
-cd $oldDir ;# 'cause 8.0.3 is left in the wrong place
-test pkgMkIndex-2.1 {simple package} {
- pkgtest::runIndex pkg simple.tcl
-} {0 {{simple:1.0 {tclPkgSetup {simple.tcl source {::simple::lower ::simple::upper}}}}}}
-
-test pkgMkIndex-2.2 {simple package - use -direct} {
- pkgtest::runIndex -direct pkg simple.tcl
-} "0 {{simple:1.0 {source [file join pkg simple.tcl]}}}"
-
-test pkgMkIndex-3.1 {simple package with global symbols} {
- pkgtest::runIndex pkg global.tcl
-} {0 {{global:1.0 {tclPkgSetup {global.tcl source {global_lower global_upper}}}}}}
-
-test pkgMkIndex-4.1 {split package} {
- pkgtest::runIndex pkg pkg2_a.tcl pkg2_b.tcl
-} {0 {{pkg2:1.0 {tclPkgSetup {pkg2_a.tcl source ::pkg2::p2-1} {pkg2_b.tcl source ::pkg2::p2-2}}}}}
-
-test pkgMkIndex-4.2 {split package - direct loading} {
- pkgtest::runIndex -direct pkg pkg2_a.tcl pkg2_b.tcl
-} "0 {{pkg2:1.0 {source [file join pkg pkg2_a.tcl]
-source [file join pkg pkg2_b.tcl]}}}"
-
-# This will fail, with "direct1" procedures in the list of procedures
-# provided by std.
-# It may also fail, if tclblend is in the auto_path, with an additional
-# command "loadJava" which comes from the tclblend pkgIndex.tcl file.
-# Both failures are caused by Tcl code executed in pkgIndex.tcl.
-
-test pkgMkIndex-5.1 {requires -direct package} {
- pkgtest::runIndex pkg std.tcl
-} {0 {{std:1.0 {tclPkgSetup {std.tcl source {::std::p1 ::std::p2}}}}}}
-
-test pkgMkIndex-6.1 {pkg1 requires pkg3} {
- pkgtest::runIndex pkg pkg1.tcl pkg3.tcl
-} {0 {{pkg1:1.0 {tclPkgSetup {pkg1.tcl source {::pkg1::p1-1 ::pkg1::p1-2}}}} {pkg3:1.0 {tclPkgSetup {pkg3.tcl source {::pkg3::p3-1 ::pkg3::p3-2}}}}}}
-
-test pkgMkIndex-6.2 {pkg1 requires pkg3 - use -direct} {
- pkgtest::runIndex -direct pkg pkg1.tcl pkg3.tcl
-} "0 {{pkg1:1.0 {source [file join pkg pkg1.tcl]}} {pkg3:1.0 {source [file join pkg pkg3.tcl]}}}"
-
-test pkgMkIndex-7.1 {pkg4 uses pkg3} {
- pkgtest::runIndex pkg pkg4.tcl pkg3.tcl
-} {0 {{pkg3:1.0 {tclPkgSetup {pkg3.tcl source {::pkg3::p3-1 ::pkg3::p3-2}}}} {pkg4:1.0 {tclPkgSetup {pkg4.tcl source {::pkg4::p4-1 ::pkg4::p4-2}}}}}}
-
-test pkgMkIndex-7.2 {pkg4 uses pkg3 - use -direct} {
- pkgtest::runIndex -direct pkg pkg4.tcl pkg3.tcl
-} "0 {{pkg3:1.0 {source [file join pkg pkg3.tcl]}} {pkg4:1.0 {source [file join pkg pkg4.tcl]}}}"
-
-test pkgMkIndex-8.1 {pkg5 uses pkg2} {
- pkgtest::runIndex pkg pkg5.tcl pkg2_a.tcl pkg2_b.tcl
-} {0 {{pkg2:1.0 {tclPkgSetup {pkg2_a.tcl source ::pkg2::p2-1} {pkg2_b.tcl source ::pkg2::p2-2}}} {pkg5:1.0 {tclPkgSetup {pkg5.tcl source {::pkg5::p5-1 ::pkg5::p5-2}}}}}}
-
-test pkgMkIndex-8.2 {pkg5 uses pkg2 - use -direct} {
- pkgtest::runIndex -direct pkg pkg5.tcl pkg2_a.tcl pkg2_b.tcl
-} "0 {{pkg2:1.0 {source [file join pkg pkg2_a.tcl]
-source [file join pkg pkg2_b.tcl]}} {pkg5:1.0 {source [file join pkg pkg5.tcl]}}}"
-
-test pkgMkIndex-9.1 {circular packages} {
- pkgtest::runIndex pkg circ1.tcl circ2.tcl circ3.tcl
-} {0 {{circ1:1.0 {tclPkgSetup {circ1.tcl source {::circ1::c1-1 ::circ1::c1-2 ::circ1::c1-3 ::circ1::c1-4}}}} {circ2:1.0 {tclPkgSetup {circ2.tcl source {::circ2::c2-1 ::circ2::c2-2}}}} {circ3:1.0 {tclPkgSetup {circ3.tcl source ::circ3::c3-1}}}}}
-
-# Some tests require the existence of one of the DLLs in the dltest directory
-set x [file join [file dirname [info nameofexecutable]] dltest \
- pkga[info sharedlibextension]]
-set dll "[file tail $x]Required"
-set ::tcltest::testConfig($dll) [file exists $x]
-
-test pkgMkIndex-10.1 {package in DLL and script} $dll {
- file copy -force $x pkg
- pkgtest::runIndex pkg pkga[info sharedlibextension] pkga.tcl
-} "0 {{Pkga:1.0 {tclPkgSetup {pkga[info sharedlibextension] load {pkga_eq pkga_quote}} {pkga.tcl source pkga_neq}}}}"
-test pkgMkIndex-10.2 {package in DLL hidden by -load} $dll {
- pkgtest::runIndex -load Pkg* -- pkg pkga[info sharedlibextension]
-} {0 {}}
-
-# Tolerate "namespace import" at the global scope
-
-test pkgMkIndex-11.1 {conflicting namespace imports} {
- pkgtest::runIndex pkg import.tcl
-} {0 {{fubar:1.0 {tclPkgSetup {import.tcl source ::fubar::foo}}}}}
-
-# cleanup
-namespace delete pkgtest
-cd $::tcltest::workingDir
-if {[info exists removePkgDir]} {
- # strange error deleting the pkg dir only once--needs be done twice!
- catch {file delete -force $newPkgDir}
- catch {file delete -force $newPkgDir}
-}
-if {[info exists removePkg1Dir]} {
- catch {file delete -force "${newPkgDir}1"}
-}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/platform.test b/tests/platform.test
deleted file mode 100644
index b81103c..0000000
--- a/tests/platform.test
+++ /dev/null
@@ -1,39 +0,0 @@
-# The file tests the tcl_platform variable
-#
-# 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) 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: @(#)
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test platform-1.1 {TclpSetVariables: tcl_platform} {
- interp create i
- i eval {catch {unset tcl_platform(debug)}}
- set result [i eval {lsort [array names tcl_platform]}]
- interp delete i
- set result
-} {byteOrder machine os osVersion platform user}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/proc-old.test b/tests/proc-old.test
deleted file mode 100644
index a57e147..0000000
--- a/tests/proc-old.test
+++ /dev/null
@@ -1,523 +0,0 @@
-# Commands covered: proc, return, global
-#
-# This file, proc-old.test, includes the original set of tests for Tcl's
-# proc, return, and global commands. There is now a new file proc.test
-# that contains tests for the tclProc.c source file.
-#
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-1997 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: proc-old.test,v 1.3 1999/04/16 00:47:32 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-catch {rename t1 ""}
-catch {rename foo ""}
-
-proc tproc {} {return a; return b}
-test proc-old-1.1 {simple procedure call and return} {tproc} a
-proc tproc x {
- set x [expr $x+1]
- return $x
-}
-test proc-old-1.2 {simple procedure call and return} {tproc 2} 3
-test proc-old-1.3 {simple procedure call and return} {
- proc tproc {} {return foo}
-} {}
-test proc-old-1.4 {simple procedure call and return} {
- proc tproc {} {return}
- tproc
-} {}
-proc tproc1 {a} {incr a; return $a}
-proc tproc2 {a b} {incr a; return $a}
-test proc-old-1.5 {simple procedure call and return (2 procs with same body but different parameters)} {
- list [tproc1 123] [tproc2 456 789]
-} {124 457}
-test proc-old-1.6 {simple procedure call and return (shared proc body string)} {
- set x {}
- proc tproc {} {} ;# body is shared with x
- list [tproc] [append x foo]
-} {{} foo}
-
-test proc-old-2.1 {local and global variables} {
- proc tproc x {
- set x [expr $x+1]
- return $x
- }
- set x 42
- list [tproc 6] $x
-} {7 42}
-test proc-old-2.2 {local and global variables} {
- proc tproc x {
- set y [expr $x+1]
- return $y
- }
- set y 18
- list [tproc 6] $y
-} {7 18}
-test proc-old-2.3 {local and global variables} {
- proc tproc x {
- global y
- set y [expr $x+1]
- return $y
- }
- set y 189
- list [tproc 6] $y
-} {7 7}
-test proc-old-2.4 {local and global variables} {
- proc tproc x {
- global y
- return [expr $x+$y]
- }
- set y 189
- list [tproc 6] $y
-} {195 189}
-catch {unset _undefined_}
-test proc-old-2.5 {local and global variables} {
- proc tproc x {
- global _undefined_
- return $_undefined_
- }
- list [catch {tproc xxx} msg] $msg
-} {1 {can't read "_undefined_": no such variable}}
-test proc-old-2.6 {local and global variables} {
- set a 114
- set b 115
- global a b
- list $a $b
-} {114 115}
-
-proc do {cmd} {eval $cmd}
-test proc-old-3.1 {local and global arrays} {
- catch {unset a}
- set a(0) 22
- list [catch {do {global a; set a(0)}} msg] $msg
-} {0 22}
-test proc-old-3.2 {local and global arrays} {
- catch {unset a}
- set a(x) 22
- list [catch {do {global a; set a(x) newValue}} msg] $msg $a(x)
-} {0 newValue newValue}
-test proc-old-3.3 {local and global arrays} {
- catch {unset a}
- set a(x) 22
- set a(y) 33
- list [catch {do {global a; unset a(y)}; array names a} msg] $msg
-} {0 x}
-test proc-old-3.4 {local and global arrays} {
- catch {unset a}
- set a(x) 22
- set a(y) 33
- list [catch {do {global a; unset a; info exists a}} msg] $msg \
- [info exists a]
-} {0 0 0}
-test proc-old-3.5 {local and global arrays} {
- catch {unset a}
- set a(x) 22
- set a(y) 33
- list [catch {do {global a; unset a(y); array names a}} msg] $msg
-} {0 x}
-catch {unset a}
-test proc-old-3.6 {local and global arrays} {
- catch {unset a}
- set a(x) 22
- set a(y) 33
- do {global a; do {global a; unset a}; set a(z) 22}
- list [catch {array names a} msg] $msg
-} {0 z}
-test proc-old-3.7 {local and global arrays} {
- proc t1 {args} {global info; set info 1}
- catch {unset a}
- set info {}
- do {global a; trace var a(1) w t1}
- set a(1) 44
- set info
-} 1
-test proc-old-3.8 {local and global arrays} {
- proc t1 {args} {global info; set info 1}
- catch {unset a}
- trace var a(1) w t1
- set info {}
- do {global a; trace vdelete a(1) w t1}
- set a(1) 44
- set info
-} {}
-test proc-old-3.9 {local and global arrays} {
- proc t1 {args} {global info; set info 1}
- catch {unset a}
- trace var a(1) w t1
- do {global a; trace vinfo a(1)}
-} {{w t1}}
-catch {unset a}
-
-test proc-old-3.1 {arguments and defaults} {
- proc tproc {x y z} {
- return [list $x $y $z]
- }
- tproc 11 12 13
-} {11 12 13}
-test proc-old-3.2 {arguments and defaults} {
- proc tproc {x y z} {
- return [list $x $y $z]
- }
- list [catch {tproc 11 12} msg] $msg
-} {1 {no value given for parameter "z" to "tproc"}}
-test proc-old-3.3 {arguments and defaults} {
- proc tproc {x y z} {
- return [list $x $y $z]
- }
- list [catch {tproc 11 12 13 14} msg] $msg
-} {1 {called "tproc" with too many arguments}}
-test proc-old-3.4 {arguments and defaults} {
- proc tproc {x {y y-default} {z z-default}} {
- return [list $x $y $z]
- }
- tproc 11 12 13
-} {11 12 13}
-test proc-old-3.5 {arguments and defaults} {
- proc tproc {x {y y-default} {z z-default}} {
- return [list $x $y $z]
- }
- tproc 11 12
-} {11 12 z-default}
-test proc-old-3.6 {arguments and defaults} {
- proc tproc {x {y y-default} {z z-default}} {
- return [list $x $y $z]
- }
- tproc 11
-} {11 y-default z-default}
-test proc-old-3.7 {arguments and defaults} {
- proc tproc {x {y y-default} {z z-default}} {
- return [list $x $y $z]
- }
- list [catch {tproc} msg] $msg
-} {1 {no value given for parameter "x" to "tproc"}}
-test proc-old-3.8 {arguments and defaults} {
- list [catch {
- proc tproc {x {y y-default} z} {
- return [list $x $y $z]
- }
- tproc 2 3
- } msg] $msg
-} {1 {no value given for parameter "z" to "tproc"}}
-test proc-old-3.9 {arguments and defaults} {
- proc tproc {x {y y-default} args} {
- return [list $x $y $args]
- }
- tproc 2 3 4 5
-} {2 3 {4 5}}
-test proc-old-3.10 {arguments and defaults} {
- proc tproc {x {y y-default} args} {
- return [list $x $y $args]
- }
- tproc 2 3
-} {2 3 {}}
-test proc-old-3.11 {arguments and defaults} {
- proc tproc {x {y y-default} args} {
- return [list $x $y $args]
- }
- tproc 2
-} {2 y-default {}}
-test proc-old-3.12 {arguments and defaults} {
- proc tproc {x {y y-default} args} {
- return [list $x $y $args]
- }
- list [catch {tproc} msg] $msg
-} {1 {no value given for parameter "x" to "tproc"}}
-
-test proc-old-4.1 {variable numbers of arguments} {
- proc tproc args {return $args}
- tproc
-} {}
-test proc-old-4.2 {variable numbers of arguments} {
- proc tproc args {return $args}
- tproc 1 2 3 4 5 6 7 8
-} {1 2 3 4 5 6 7 8}
-test proc-old-4.3 {variable numbers of arguments} {
- proc tproc args {return $args}
- tproc 1 {2 3} {4 {5 6} {{{7}}}} 8
-} {1 {2 3} {4 {5 6} {{{7}}}} 8}
-test proc-old-4.4 {variable numbers of arguments} {
- proc tproc {x y args} {return $args}
- tproc 1 2 3 4 5 6 7
-} {3 4 5 6 7}
-test proc-old-4.5 {variable numbers of arguments} {
- proc tproc {x y args} {return $args}
- tproc 1 2
-} {}
-test proc-old-4.6 {variable numbers of arguments} {
- proc tproc {x missing args} {return $args}
- list [catch {tproc 1} msg] $msg
-} {1 {no value given for parameter "missing" to "tproc"}}
-
-test proc-old-5.1 {error conditions} {
- list [catch {proc} msg] $msg
-} {1 {wrong # args: should be "proc name args body"}}
-test proc-old-5.2 {error conditions} {
- list [catch {proc tproc b} msg] $msg
-} {1 {wrong # args: should be "proc name args body"}}
-test proc-old-5.3 {error conditions} {
- list [catch {proc tproc b c d e} msg] $msg
-} {1 {wrong # args: should be "proc name args body"}}
-test proc-old-5.4 {error conditions} {
- list [catch {proc tproc \{xyz {return foo}} msg] $msg
-} {1 {unmatched open brace in list}}
-test proc-old-5.5 {error conditions} {
- list [catch {proc tproc {{} y} {return foo}} msg] $msg
-} {1 {procedure "tproc" has argument with no name}}
-test proc-old-5.6 {error conditions} {
- list [catch {proc tproc {{} y} {return foo}} msg] $msg
-} {1 {procedure "tproc" has argument with no name}}
-test proc-old-5.7 {error conditions} {
- list [catch {proc tproc {{x 1 2} y} {return foo}} msg] $msg
-} {1 {too many fields in argument specifier "x 1 2"}}
-test proc-old-5.8 {error conditions} {
- catch {return}
-} 2
-test proc-old-5.9 {error conditions} {
- list [catch {global} msg] $msg
-} {1 {wrong # args: should be "global varName ?varName ...?"}}
-proc tproc {} {
- set a 22
- global a
-}
-test proc-old-5.10 {error conditions} {
- list [catch {tproc} msg] $msg
-} {1 {variable "a" already exists}}
-test proc-old-5.11 {error conditions} {
- catch {rename tproc {}}
- catch {
- proc tproc {x {} z} {return foo}
- }
- list [catch {tproc 1} msg] $msg
-} {1 {invalid command name "tproc"}}
-test proc-old-5.12 {error conditions} {
- proc tproc {} {
- set a 22
- error "error in procedure"
- return
- }
- list [catch tproc msg] $msg
-} {1 {error in procedure}}
-test proc-old-5.13 {error conditions} {
- proc tproc {} {
- set a 22
- error "error in procedure"
- return
- }
- catch tproc msg
- set errorInfo
-} {error in procedure
- while executing
-"error "error in procedure""
- (procedure "tproc" line 3)
- invoked from within
-"tproc"}
-test proc-old-5.14 {error conditions} {
- proc tproc {} {
- set a 22
- break
- return
- }
- catch tproc msg
- set errorInfo
-} {invoked "break" outside of a loop
- while executing
-"tproc"}
-test proc-old-5.15 {error conditions} {
- proc tproc {} {
- set a 22
- continue
- return
- }
- catch tproc msg
- set errorInfo
-} {invoked "continue" outside of a loop
- while executing
-"tproc"}
-test proc-old-5.16 {error conditions} {
- proc foo args {
- global fooMsg
- set fooMsg "foo was called: $args"
- }
- proc tproc {} {
- set x 44
- trace var x u foo
- while {$x < 100} {
- error "Nested error"
- }
- }
- set fooMsg "foo not called"
- list [catch tproc msg] $msg $errorInfo $fooMsg
-} {1 {Nested error} {Nested error
- while executing
-"error "Nested error""
- (procedure "tproc" line 5)
- invoked from within
-"tproc"} {foo was called: x {} u}}
-
-# The tests below will really only be useful when run under Purify or
-# some other system that can detect accesses to freed memory...
-
-test proc-old-6.1 {procedure that redefines itself} {
- proc tproc {} {
- proc tproc {} {
- return 44
- }
- return 45
- }
- tproc
-} 45
-test proc-old-6.2 {procedure that deletes itself} {
- proc tproc {} {
- rename tproc {}
- return 45
- }
- tproc
-} 45
-
-proc tproc code {
- return -code $code abc
-}
-test proc-old-7.1 {return with special completion code} {
- list [catch {tproc ok} msg] $msg
-} {0 abc}
-test proc-old-7.2 {return with special completion code} {
- list [catch {tproc error} msg] $msg $errorInfo $errorCode
-} {1 abc {abc
- while executing
-"tproc error"} NONE}
-test proc-old-7.3 {return with special completion code} {
- list [catch {tproc return} msg] $msg
-} {2 abc}
-test proc-old-7.4 {return with special completion code} {
- list [catch {tproc break} msg] $msg
-} {3 abc}
-test proc-old-7.5 {return with special completion code} {
- list [catch {tproc continue} msg] $msg
-} {4 abc}
-test proc-old-7.6 {return with special completion code} {
- list [catch {tproc -14} msg] $msg
-} {-14 abc}
-test proc-old-7.7 {return with special completion code} {
- list [catch {tproc gorp} msg] $msg
-} {1 {bad completion code "gorp": must be ok, error, return, break, continue, or an integer}}
-test proc-old-7.8 {return with special completion code} {
- list [catch {tproc 10b} msg] $msg
-} {1 {bad completion code "10b": must be ok, error, return, break, continue, or an integer}}
-test proc-old-7.9 {return with special completion code} {
- proc tproc2 {} {
- tproc return
- }
- list [catch tproc2 msg] $msg
-} {0 abc}
-test proc-old-7.10 {return with special completion code} {
- proc tproc2 {} {
- return -code error
- }
- list [catch tproc2 msg] $msg
-} {1 {}}
-test proc-old-7.11 {return with special completion code} {
- proc tproc2 {} {
- global errorCode errorInfo
- catch {open _bad_file_name r} msg
- return -code error -errorinfo $errorInfo -errorcode $errorCode $msg
- }
- normalizeMsg [list [catch tproc2 msg] $msg $errorInfo $errorCode]
-} {1 {couldn't open "_bad_file_name": no such file or directory} {couldn't open "_bad_file_name": no such file or directory
- while executing
-"open _bad_file_name r"
- invoked from within
-"tproc2"} {posix enoent {no such file or directory}}}
-test proc-old-7.12 {return with special completion code} {
- proc tproc2 {} {
- global errorCode errorInfo
- catch {open _bad_file_name r} msg
- return -code error -errorcode $errorCode $msg
- }
- normalizeMsg [list [catch tproc2 msg] $msg $errorInfo $errorCode]
-} {1 {couldn't open "_bad_file_name": no such file or directory} {couldn't open "_bad_file_name": no such file or directory
- while executing
-"tproc2"} {posix enoent {no such file or directory}}}
-test proc-old-7.13 {return with special completion code} {
- proc tproc2 {} {
- global errorCode errorInfo
- catch {open _bad_file_name r} msg
- return -code error -errorinfo $errorInfo $msg
- }
- normalizeMsg [list [catch tproc2 msg] $msg $errorInfo $errorCode]
-} {1 {couldn't open "_bad_file_name": no such file or directory} {couldn't open "_bad_file_name": no such file or directory
- while executing
-"open _bad_file_name r"
- invoked from within
-"tproc2"} none}
-test proc-old-7.14 {return with special completion code} {
- proc tproc2 {} {
- global errorCode errorInfo
- catch {open _bad_file_name r} msg
- return -code error $msg
- }
- normalizeMsg [list [catch tproc2 msg] $msg $errorInfo $errorCode]
-} {1 {couldn't open "_bad_file_name": no such file or directory} {couldn't open "_bad_file_name": no such file or directory
- while executing
-"tproc2"} none}
-test proc-old-7.14 {return with special completion code} {
- list [catch {return -badOption foo message} msg] $msg
-} {1 {bad option "-badOption": must be -code, -errorcode, or -errorinfo}}
-
-test proc-old-8.1 {unset and undefined local arrays} {
- proc t1 {} {
- foreach v {xxx, yyy} {
- catch {unset $v}
- }
- set yyy(foo) bar
- }
- t1
-} bar
-
-test proc-old-9.1 {empty command name} {
- catch {rename {} ""}
- proc t1 {args} {
- return
- }
- set v [t1]
- catch {$v}
-} 1
-
-test proc-old-10.1 {ByteCode epoch change during recursive proc execution} {
- proc t1 x {
- set y 20
- rename expr expr.old
- rename expr.old expr
- if $x then {t1 0} ;# recursive call after foo's code is invalidated
- return 20
- }
- t1 1
-} 20
-
-# cleanup
-catch {rename t1 ""}
-catch {rename foo ""}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/proc.test b/tests/proc.test
deleted file mode 100644
index 60f5d8e..0000000
--- a/tests/proc.test
+++ /dev/null
@@ -1,312 +0,0 @@
-# This file contains tests for the tclProc.c source file. Tests appear in
-# the same order as the C code that they test. The set of tests is
-# currently incomplete since it includes only new tests, in particular
-# tests for code changed for the addition of Tcl namespaces. Other
-# procedure-related tests appear in other test files such as proc-old.test.
-#
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 1997 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: proc.test,v 1.4 1999/04/16 00:47:32 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-catch {eval namespace delete [namespace children :: test_ns_*]}
-catch {rename p ""}
-catch {rename {} ""}
-catch {unset msg}
-
-test proc-1.1 {Tcl_ProcObjCmd, put proc in namespace specified in name, if any} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1 {
- namespace eval baz {}
- }
- proc test_ns_1::baz::p {} {
- return "p in [namespace current]"
- }
- list [test_ns_1::baz::p] \
- [namespace eval test_ns_1 {baz::p}] \
- [info commands test_ns_1::baz::*]
-} {{p in ::test_ns_1::baz} {p in ::test_ns_1::baz} ::test_ns_1::baz::p}
-test proc-1.2 {Tcl_ProcObjCmd, namespace specified in proc name must exist} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- list [catch {proc test_ns_1::baz::p {} {}} msg] $msg
-} {1 {can't create procedure "test_ns_1::baz::p": unknown namespace}}
-test proc-1.3 {Tcl_ProcObjCmd, empty proc name} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- proc :: {} {
- return "empty called"
- }
- list [::] \
- [info body {}]
-} {{empty called} {
- return "empty called"
- }}
-test proc-1.4 {Tcl_ProcObjCmd, simple proc name and proc defined in namespace} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1 {
- namespace eval baz {
- proc p {} {
- return "p in [namespace current]"
- }
- }
- }
- list [test_ns_1::baz::p] \
- [info commands test_ns_1::baz::*]
-} {{p in ::test_ns_1::baz} ::test_ns_1::baz::p}
-test proc-1.5 {Tcl_ProcObjCmd, qualified proc name and proc defined in namespace} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1::baz {}
- namespace eval test_ns_1 {
- proc baz::p {} {
- return "p in [namespace current]"
- }
- }
- list [test_ns_1::baz::p] \
- [info commands test_ns_1::baz::*] \
- [namespace eval test_ns_1::baz {namespace which p}]
-} {{p in ::test_ns_1::baz} ::test_ns_1::baz::p ::test_ns_1::baz::p}
-test proc-1.6 {Tcl_ProcObjCmd, namespace code ignores single ":"s in middle or end of command names} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1 {
- proc q: {} {return "q:"}
- proc value:at: {} {return "value:at:"}
- }
- list [namespace eval test_ns_1 {q:}] \
- [namespace eval test_ns_1 {value:at:}] \
- [test_ns_1::q:] \
- [test_ns_1::value:at:] \
- [lsort [info commands test_ns_1::*]] \
- [namespace eval test_ns_1 {namespace which q:}] \
- [namespace eval test_ns_1 {namespace which value:at:}]
-} {q: value:at: q: value:at: {::test_ns_1::q: ::test_ns_1::value:at:} ::test_ns_1::q: ::test_ns_1::value:at:}
-test proc-1.7 {Tcl_ProcObjCmd, check that formal parameter names are not array elements} {
- catch {rename p ""}
- list [catch {proc p {a(1) a(2)} {
- set z [expr $a(1)+$a(2)]
- puts "$z=z, $a(1)=$a(1)"
- }} msg] $msg
-} {1 {procedure "p" has formal parameter "a(1)" that is an array element}}
-
-test proc-2.1 {TclFindProc, simple proc name and proc not in namespace} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {rename p ""}
- proc p {} {return "p in [namespace current]"}
- info body p
-} {return "p in [namespace current]"}
-test proc-2.2 {TclFindProc, simple proc name and proc defined in namespace} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1 {
- namespace eval baz {
- proc p {} {return "p in [namespace current]"}
- }
- }
- namespace eval test_ns_1::baz {info body p}
-} {return "p in [namespace current]"}
-test proc-2.3 {TclFindProc, qualified proc name and proc defined in namespace} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1::baz {}
- namespace eval test_ns_1 {
- proc baz::p {} {return "p in [namespace current]"}
- }
- namespace eval test_ns_1 {info body baz::p}
-} {return "p in [namespace current]"}
-test proc-2.4 {TclFindProc, global proc and executing in namespace} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {rename p ""}
- proc p {} {return "global p"}
- namespace eval test_ns_1::baz {info body p}
-} {return "global p"}
-
-test proc-3.1 {TclObjInterpProc, proc defined and executing in same namespace} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- proc p {} {return "p in [namespace current]"}
- p
-} {p in ::}
-test proc-3.2 {TclObjInterpProc, proc defined and executing in same namespace} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- namespace eval test_ns_1::baz {
- proc p {} {return "p in [namespace current]"}
- p
- }
-} {p in ::test_ns_1::baz}
-test proc-3.3 {TclObjInterpProc, proc defined and executing in different namespaces} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {rename p ""}
- proc p {} {return "p in [namespace current]"}
- namespace eval test_ns_1::baz {
- p
- }
-} {p in ::}
-test proc-3.4 {TclObjInterpProc, procs execute in the namespace in which they were defined unless renamed into new namespace} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {rename p ""}
- namespace eval test_ns_1::baz {
- proc p {} {return "p in [namespace current]"}
- rename ::test_ns_1::baz::p ::p
- list [p] [namespace which p]
- }
-} {{p in ::} ::p}
-test proc-3.5 {TclObjInterpProc, any old result is reset before appending error msg about missing arguments} {
- proc p {x} {info commands 3m}
- list [catch {p} msg] $msg
-} {1 {no value given for parameter "x" to "p"}}
-
-catch {eval namespace delete [namespace children :: test_ns_*]}
-catch {rename p ""}
-catch {rename {} ""}
-catch {unset msg}
-
-if {[catch {package require procbodytest}]} {
- puts "This application couldn't load the \"procbodytest\" package, so I"
- puts "can't test creation of procs whose bodies have type \"procbody\"."
- ::tcltest::cleanupTests
- return
-}
-
-catch {rename p ""}
-catch {rename t ""}
-
-# Note that the test require that procedures whose body is used to create
-# procbody objects must be executed before the procbodytest::proc command
-# is executed, so that the Proc struct is populated correctly (CompiledLocals
-# are added at compile time).
-
-test proc-4.1 {TclCreateProc, procbody obj} {
- catch {
- proc p x {return "$x:$x"}
- set rv [p P]
- procbodytest::proc t x p
- lappend rv [t T]
- set rv
- } result
- catch {rename p ""}
- catch {rename t ""}
- set result
-} {P:P T:T}
-
-test proc-4.2 {TclCreateProc, procbody obj, use compiled locals} {
- catch {
- proc p x {
- set y [string tolower $x]
- return "$x:$y"
- }
- set rv [p P]
- procbodytest::proc t x p
- lappend rv [t T]
- set rv
- } result
- catch {rename p ""}
- catch {rename t ""}
- set result
-} {P:p T:t}
-
-test proc-4.3 {TclCreateProc, procbody obj, too many args} {
- catch {
- proc p x {
- set y [string tolower $x]
- return "$x:$y"
- }
- set rv [p P]
- procbodytest::proc t {x x1 x2} p
- lappend rv [t T]
- set rv
- } result
- catch {rename p ""}
- catch {rename t ""}
- set result
-} {procedure "t": arg list contains 3 entries, precompiled header expects 1}
-
-test proc-4.4 {TclCreateProc, procbody obj, inconsitent arg name} {
- catch {
- proc p {x y z} {
- set v [join [list $x $y $z]]
- set w [string tolower $v]
- return "$v:$w"
- }
- set rv [p P Q R]
- procbodytest::proc t {x x1 z} p
- lappend rv [t S T U]
- set rv
- } result
- catch {rename p ""}
- catch {rename t ""}
- set result
-} {procedure "t": formal parameter 1 is inconsistent with precompiled body}
-
-test proc-4.5 {TclCreateProc, procbody obj, inconsitent arg default type} {
- catch {
- proc p {x y {z Z}} {
- set v [join [list $x $y $z]]
- set w [string tolower $v]
- return "$v:$w"
- }
- set rv [p P Q R]
- procbodytest::proc t {x y z} p
- lappend rv [t S T U]
- set rv
- } result
- catch {rename p ""}
- catch {rename t ""}
- set result
-} {procedure "t": formal parameter 2 is inconsistent with precompiled body}
-
-test proc-4.6 {TclCreateProc, procbody obj, inconsitent arg default type} {
- catch {
- proc p {x y z} {
- set v [join [list $x $y $z]]
- set w [string tolower $v]
- return "$v:$w"
- }
- set rv [p P Q R]
- procbodytest::proc t {x y {z Z}} p
- lappend rv [t S T U]
- set rv
- } result
- catch {rename p ""}
- catch {rename t ""}
- set result
-} {procedure "t": formal parameter 2 is inconsistent with precompiled body}
-
-test proc-4.7 {TclCreateProc, procbody obj, inconsitent arg default value} {
- catch {
- proc p {x y {z Z}} {
- set v [join [list $x $y $z]]
- set w [string tolower $v]
- return "$v:$w"
- }
- set rv [p P Q R]
- procbodytest::proc t {x y {z ZZ}} p
- lappend rv [t S T U]
- set rv
- } result
- catch {rename p ""}
- catch {rename t ""}
- set result
-} {procedure "t": formal parameter "z" has default value inconsistent with precompiled body}
-
-# cleanup
-catch {rename p ""}
-catch {rename t ""}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/pwd.test b/tests/pwd.test
deleted file mode 100644
index 0656b63..0000000
--- a/tests/pwd.test
+++ /dev/null
@@ -1,41 +0,0 @@
-# Commands covered: pwd
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-1997 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: pwd.test,v 1.3 1999/04/16 00:47:32 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test pwd-1.1 {simple pwd} {
- catch pwd
-} 0
-test pwd-1.2 {simple pwd} {
- expr [string length pwd]>0
-} 1
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/reg.test b/tests/reg.test
deleted file mode 100644
index de20e33..0000000
--- a/tests/reg.test
+++ /dev/null
@@ -1,905 +0,0 @@
-# reg.test --
-#
-# 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-1999 by Scriptics Corporation.
-# All rights reserved.
-#
-# RCS: @(#) $Id: reg.test,v 1.2 1999/04/16 00:47:33 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# All tests require the testregexp command, return if this
-# command doesn't exist
-
-set ::tcltest::testConfig(testregexp) \
- [expr {[info commands testregexp] != {}}]
-
-# This file uses some custom procedures, defined below, for regexp regression
-# testing. The name of the procedure indicates the general nature of the
-# test: e for compile error expected, f for match failure expected, m
-# for a successful match, and i for a successful match with -indices (used
-# in checking things like nonparticipating subexpressions). There is also
-# a "doing" procedure which sets up title and major test number for each
-# block of tests, and an "xx" procedure which ignores its arguments and
-# arranges for the next invocation of "doing" to announce that some tests
-# were bypassed (which is better than just commenting them out).
-
-# The first 3 arguments are constant: a minor number (which often gets
-# a letter or two suffixed to it internally), some flags, and the RE itself.
-# For e, the remaining argument is the name of the compile error expected,
-# less the leading "REG_". For the rest, the next argument is the string
-# to try the match against. Remaining arguments are the substring expected
-# to be matched, and any substrings expected to be matched by subexpressions.
-# (For f, these arguments are optional, and if present are ignored except
-# that they indicate how many subexpressions should be presents in the RE.)
-# It is an error for the number of subexpression arguments to be wrong.
-# Cases involving nonparticipating subexpressions, checking where empty
-# substrings are located, etc. should be done using i.
-
-# The flag characters are complex and a bit eclectic. Generally speaking,
-# lowercase letters are compile options, uppercase are expected re_info
-# bits, and nonalphabetics are match options, controls for how the test is
-# run, or testing options. The one small surprise is that AREs are the
-# default, and you must explicitly request lesser flavors of RE. The flags
-# are as follows. It is admitted that some are not very mnemonic.
-# There are some others which are purely debugging tools and are not
-# useful in this file.
-#
-# - no-op (placeholder)
-# + provide fake xy equivalence class
-# % force small state-set cache in matcher (to test cache replace)
-# ^ beginning of string is not beginning of line
-# $ end of string is not end of line
-#
-# & test as both ARE and BRE
-# b BRE
-# e ERE
-# a turn advanced-features bit on (error unless ERE already)
-# q literal string, no metacharacters at all
-#
-# i case-independent matching
-# o ("opaque") no subexpression capture
-# p newlines are half-magic, excluded from . and [^ only
-# w newlines are half-magic, significant to ^ and $ only
-# n newlines are fully magic, both effects
-# x expanded RE syntax
-#
-# A backslash-_a_lphanumeric seen
-# B ERE/ARE literal-_b_race heuristic used
-# E backslash (_e_scape) seen within []
-# H looka_h_ead constraint seen
-# I _i_mpossible to match
-# L _l_ocale-specific construct seen
-# M unportable (_m_achine-specific) construct seen
-# N RE can match empty (_n_ull) string
-# P non-_P_OSIX construct seen
-# Q {} _q_uantifier seen
-# R back _r_eference seen
-# S POSIX-un_s_pecified syntax seen
-# U saw original-POSIX botch: unmatched right paren in ERE (_u_gh)
-
-# The one area we can't easily test is memory-allocation failures (which
-# are hard to provoke on command). Embedded NULs also are not tested at
-# the moment, but this is a historical accident which should be fixed.
-
-
-
-# test procedures and related
-
-set ask "about"
-set xflags "xflags"
-set testbypassed 0
-
-# re_info abbreviation mapping table
-set infonames(A) "REG_UBSALNUM"
-set infonames(B) "REG_UBRACES"
-set infonames(E) "REG_UBBS"
-set infonames(H) "REG_ULOOKAHEAD"
-set infonames(I) "REG_UIMPOSSIBLE"
-set infonames(L) "REG_ULOCALE"
-set infonames(M) "REG_UUNPORT"
-set infonames(N) "REG_UEMPTYMATCH"
-set infonames(P) "REG_UNONPOSIX"
-set infonames(Q) "REG_UBOUNDS"
-set infonames(R) "REG_UBACKREF"
-set infonames(S) "REG_UUNSPEC"
-set infonames(U) "REG_UPBOTCH"
-set infonameorder "RHQBAUEPSMLNI" ;# must match bit order, lsb first
-
-# set major test number and description
-proc doing {major desc} {
- global prefix description testbypassed
-
- if {$testbypassed != 0} {
- puts stdout "!!! bypassed $testbypassed tests in\
- $major, `$description'"
- }
-
- set prefix reg-$major
- set description "reg $desc"
- set testbypassed 0
-}
-
-# build test number (internal)
-proc tno {testid} {
- return [lindex $testid 0]
-}
-
-# build description, with possible modifiers (internal)
-proc desc {testid} {
- global description
-
- set d $description
- if {[llength $testid] > 1} {
- set d "([lreplace $testid 0 0]) $d"
- }
- return $d
-}
-
-# build trailing options and flags argument from a flags string (internal)
-proc flags {fl} {
- global xflags
-
- set args [list]
- set flags ""
- foreach f [split $fl ""] {
- switch -exact -- $f {
- "i" { lappend args "-nocase" }
- "x" { lappend args "-expanded" }
- "n" { lappend args "-line" }
- "p" { lappend args "-linestop" }
- "w" { lappend args "-lineanchor" }
- "-" { }
- default { append flags $f }
- }
- }
- if {[string compare $flags ""] != 0} {
- lappend args -$xflags $flags
- }
- return $args
-}
-
-# build info-flags list from a flags string (internal)
-proc infoflags {fl} {
- global infonames infonameorder
-
- set ret [list]
- foreach f [split $infonameorder ""] {
- if {[string first $f $fl] >= 0} {
- lappend ret $infonames($f)
- }
- }
- return $ret
-}
-
-# compilation error expected
-proc e {testid flags re err} {
- global prefix ask errorCode
-
- # if &, test as both ARE and BRE
- set amp [string first "&" $flags]
- if {$amp >= 0} {
- set f [string range $flags 0 [expr $amp - 1]]
- append f [string range $flags [expr $amp + 1] end]
- e [linsert $testid end ARE] ${f} $re $err
- e [linsert $testid end BRE] ${f}b $re $err
- return
- }
-
- set cmd [concat [list testregexp -$ask] [flags $flags] [list $re]]
- set run "list \[catch \{$cmd\}\] \[lindex \$errorCode 1\]"
- test $prefix.[tno $testid] [desc $testid] {testregexp} $run [list 1 REG_$err]
-}
-
-# match failure expected
-proc f {testid flags re target args} {
- global prefix description ask
-
- # if &, test as both ARE and BRE
- set amp [string first "&" $flags]
- if {$amp >= 0} {
- set f [string range $flags 0 [expr $amp - 1]]
- append f [string range $flags [expr $amp + 1] end]
- eval [linsert $args 0 f [linsert $testid end ARE] ${f} $re \
- $target]
- eval [linsert $args 0 f [linsert $testid end BRE] ${f}b $re \
- $target]
- return
- }
-
- set f [flags $flags]
- set infoflags [infoflags $flags]
- set ccmd [concat [list testregexp -$ask] $f [list $re]]
- set nsub [expr [llength $args] - 1]
- if {$nsub == -1} {
- # didn't tell us number of subexps
- set ccmd "lreplace \[$ccmd\] 0 0"
- set info [list $infoflags]
- } else {
- set info [list $nsub $infoflags]
- }
- lappend testid "compile"
- test $prefix.[tno $testid] [desc $testid] {testregexp} $ccmd $info
-
- set testid [lreplace $testid end end "execute"]
- set ecmd [concat [list testregexp] $f [list $re $target]]
- test $prefix.[tno $testid] [desc $testid] {testregexp} $ecmd 0
-}
-
-# match expected, internal routine that does the work
-# parameters like the "real" routines except they don't have "opts",
-# which is a possibly-empty list of switches for the regexp match attempt
-proc matchexpected {opts testid flags re target args} {
- global prefix description ask
-
- # if &, test as both BRE and ARE
- set amp [string first "&" $flags]
- if {$amp >= 0} {
- set f [string range $flags 0 [expr $amp - 1]]
- append f [string range $flags [expr $amp + 1] end]
- eval [concat [list matchexpected $opts \
- [linsert $testid end ARE] ${f} $re $target] $args]
- eval [concat [list matchexpected $opts \
- [linsert $testid end BRE] ${f}b $re $target] $args]
- return
- }
-
- set f [flags $flags]
- set infoflags [infoflags $flags]
- set ccmd [concat [list testregexp -$ask] $f [list $re]]
- set ecmd [concat [list testregexp] $opts $f [list $re $target]]
-
- set nsub [expr [llength $args] - 1]
- set names [list]
- set refs ""
- for {set i 0} {$i <= $nsub} {incr i} {
- if {$i == 0} {
- set name match
- } else {
- set name sub$i
- }
- lappend names $name
- append refs " \$$name"
- set $name ""
- }
- if {[string first "o" $flags] >= 0} { ;# REG_NOSUB
- set nsub 0 ;# unsigned value cannot be -1
- }
- set ecmd [concat $ecmd $names]
- set erun "list \[$ecmd\] $refs"
- set result [concat [list 1] $args]
-
- set info [list $nsub $infoflags]
- lappend testid "compile"
- test $prefix.[tno $testid] [desc $testid] {testregexp} $ccmd $info
- set testid [lreplace $testid end end "execute"]
- test $prefix.[tno $testid] [desc $testid] {testregexp} $erun $result
-}
-
-# match expected (no missing, empty, or ambiguous submatches)
-# m testno flags re target mat submat ...
-proc m {args} {
- eval matchexpected [linsert $args 0 [list]]
-}
-
-# match expected (full fanciness)
-# i testno flags re target mat submat ...
-proc i {args} {
- eval matchexpected [linsert $args 0 [list "-indices"]]
-}
-
-# test temporarily unimplemented
-proc xx {args} {
- global testbypassed
-
- incr testbypassed
-}
-
-
-
-# the tests themselves
-
-
-
-# support functions and preliminary misc.
-# This is sensitive to changes in message wording, but we really have to
-# test the code->message expansion at least once.
-test regexp-0.1 "regexp error reporting" {
- list [catch {regexp (*) ign} msg] $msg
-} {1 {couldn't compile regular expression pattern: quantifier operand invalid}}
-
-
-
-doing 1 "basic sanity checks"
-m 1 & abc abc abc
-f 2 & abc def
-m 3 & abc xyabxabce abc
-
-
-
-doing 2 "invalid option combinations"
-e 1 qe a INVARG
-e 2 qa a INVARG
-e 3 qx a INVARG
-e 4 qn a INVARG
-e 5 ba a INVARG
-
-
-
-doing 3 "basic syntax"
-i 1 &NS "" a {0 -1}
-m 2 NS a| a a
-m 3 - a|b a a
-m 4 - a|b b b
-m 5 NS a||b b b
-m 6 & ab ab ab
-
-
-
-doing 4 "parentheses"
-m 1 - (a)e ae ae a
-m 2 o (a)e ae
-m 3 b {\(a\)b} ab ab a
-m 4 - a((b)c) abc abc bc b
-m 5 - a(b)(c) abc abc b c
-e 6 - a(b EPAREN
-e 7 b {a\(b} EPAREN
-# sigh, we blew it on the specs here... someday this will be fixed in POSIX,
-# but meanwhile, it's fixed in AREs
-m 8 eU a)b a)b a)b
-e 9 - a)b EPAREN
-e 10 b {a\)b} EPAREN
-m 11 P a(?:b)c abc abc
-e 12 e a(?:b)c BADRPT
-i 13 S a()b ab {0 1} {1 0}
-m 14 SP a(?:)b ab ab
-i 15 S a(|b)c ac {0 1} {1 0}
-m 16 S a(b|)c abc abc b
-
-
-
-doing 5 "simple one-char matching"
-# general case of brackets done later
-m 1 & a.b axb axb
-f 2 &n "a.b" "a\nb"
-m 3 & {a[bc]d} abd abd
-m 4 & {a[bc]d} acd acd
-f 5 & {a[bc]d} aed
-f 6 & {a[^bc]d} abd
-m 7 & {a[^bc]d} aed aed
-f 8 &p "a\[^bc]d" "a\nd"
-
-
-
-doing 6 "context-dependent syntax"
-# plus odds and ends
-e 1 - * BADRPT
-m 2 b * * *
-m 3 b {\(*\)} * * *
-e 4 - (*) BADRPT
-m 5 b ^* * *
-e 6 - ^* BADRPT
-f 7 & ^b ^b
-m 8 b x^ x^ x^
-f 9 I x^ x
-m 10 n "\n^" "x\nb" "\n"
-f 11 bS {\(^b\)} ^b
-m 12 - (^b) b b b
-m 13 & {x$} x x
-m 14 bS {\(x$\)} x x x
-m 15 - {(x$)} x x x
-m 16 b {x$y} "x\$y" "x\$y"
-f 17 I {x$y} xy
-m 18 n "x\$\n" "x\n" "x\n"
-e 19 - + BADRPT
-e 20 - ? BADRPT
-
-
-
-doing 7 "simple quantifiers"
-m 1 &N a* aa aa
-i 2 &N a* b {0 -1}
-m 3 - a+ aa aa
-m 4 - a?b ab ab
-m 5 - a?b b b
-e 6 - ** BADRPT
-m 7 bN ** *** ***
-e 8 & a** BADRPT
-e 9 & a**b BADRPT
-e 10 & *** BADRPT
-e 11 * a++ BADRPT
-e 12 * a?+ BADRPT
-e 13 * a?* BADRPT
-e 14 * a+* BADRPT
-e 15 * a*+ BADRPT
-
-
-
-doing 8 "braces"
-m 1 NQ "a{0,1}" "" ""
-m 2 NQ "a{0,1}" ac a
-e 3 - "a{1,0}" BADBR
-e 4 - "a{1,2,3}" BADBR
-e 5 - "a{257}" BADBR
-e 6 - "a{1000}" BADBR
-e 7 - "a{1" EBRACE
-e 8 - "a{1n}" BADBR
-m 9 BS "a{b" "a\{b" "a\{b"
-m 10 BS "a{" "a\{" "a\{"
-m 11 bQ {a\{0,1\}b} cb b
-e 12 b {a\{0,1} EBRACE
-e 13 - "a{0,1\\" BADBR
-m 14 Q "a{0}b" ab b
-m 15 Q "a{0,0}b" ab b
-m 16 Q "a{0,1}b" ab ab
-m 17 Q "a{0,2}b" b b
-m 18 Q "a{0,2}b" aab aab
-m 19 Q "a{0,}b" aab aab
-m 20 Q "a{1,1}b" aab ab
-m 21 Q "a{1,3}b" aaaab aaab
-f 22 Q "a{1,3}b" b
-m 23 Q "a{1,}b" aab aab
-f 24 Q "a{2,3}b" ab
-m 25 Q "a{2,3}b" aaaab aaab
-f 26 Q "a{2,}b" ab
-m 27 Q "a{2,}b" aaaab aaaab
-
-
-
-doing 9 "brackets"
-m 1 & {a[bc]} ac ac
-m 2 & {a[-]} a- a-
-m 3 & {a[[.-.]]} a- a-
-m 4 &L {a[[.zero.]]} a0 a0
-m 5 &LM {a[[.zero.]-9]} a2 a2
-m 6 &M {a[0-[.9.]]} a2 a2
-m 7 &+L {a[[=x=]]} ax ax
-m 8 &+L {a[[=x=]]} ay ay
-f 9 &+L {a[[=x=]]} az
-e 10 & {a[0-[=x=]]} ERANGE
-m 11 &L {a[[:digit:]]} a0 a0
-e 12 & {a[[:woopsie:]]} ECTYPE
-f 13 &L {a[[:digit:]]} ab
-e 14 & {a[0-[:digit:]]} ERANGE
-m 15 &LP {[[:<:]]a} a a
-m 16 &LP {a[[:>:]]} a a
-e 17 & {a[[..]]b} ECOLLATE
-e 18 & {a[[==]]b} ECOLLATE
-e 19 & {a[[::]]b} ECTYPE
-e 20 & {a[[.a} EBRACK
-e 21 & {a[[=a} EBRACK
-e 22 & {a[[:a} EBRACK
-e 23 & {a[} EBRACK
-e 24 & {a[b} EBRACK
-e 25 & {a[b-} EBRACK
-e 26 & {a[b-c} EBRACK
-m 27 &M {a[b-c]} ab ab
-m 28 & {a[b-b]} ab ab
-m 29 &M {a[1-2]} a2 a2
-e 30 & {a[c-b]} ERANGE
-e 31 & {a[a-b-c]} ERANGE
-m 32 &M {a[--?]b} a?b a?b
-m 33 & {a[---]b} a-b a-b
-m 34 & {a[]b]c} a]c a]c
-m 35 EP {a[\]]b} a]b a]b
-f 36 bE {a[\]]b} a]b
-m 37 bE {a[\]]b} "a\\]b" "a\\]b"
-m 38 eE {a[\]]b} "a\\]b" "a\\]b"
-m 39 EP {a[\\]b} "a\\b" "a\\b"
-m 40 eE {a[\\]b} "a\\b" "a\\b"
-m 41 bE {a[\\]b} "a\\b" "a\\b"
-e 42 - {a[\Z]b} EESCAPE
-m 43 & {a[[b]c} "a\[c" "a\[c"
-m 44 EMP {a[\u00fe-\u0507][\u00ff-\u0300]b} \
- "a\u0102\u02ffb" "a\u0102\u02ffb"
-
-
-
-doing 10 "anchors and newlines"
-m 1 & ^a a a
-f 2 &^ ^a a
-i 3 &N ^ a {0 -1}
-i 4 & {a$} aba {2 2}
-f 5 {&$} {a$} a
-i 6 &N {$} ab {2 1}
-m 7 &n ^a a a
-m 8 &n "^a" "b\na" "a"
-i 9 &w "^a" "a\na" {0 0}
-i 10 &n^ "^a" "a\na" {2 2}
-m 11 &n {a$} a a
-m 12 &n "a\$" "a\nb" "a"
-i 13 &n "a\$" "a\na" {0 0}
-i 14 N ^^ a {0 -1}
-m 15 b ^^ ^ ^
-i 16 N {$$} a {1 0}
-m 17 b {$$} "\$" "\$"
-m 18 &N {^$} "" ""
-f 19 &N {^$} a
-i 20 &nN "^\$" "a\n\nb" {2 1}
-m 21 N {$^} "" ""
-m 22 b {$^} "\$^" "\$^"
-m 23 P {\Aa} a a
-m 24 ^P {\Aa} a a
-f 25 ^nP {\Aa} "b\na"
-m 26 P {a\Z} a a
-m 27 {$P} {a\Z} a a
-f 28 {$nP} {a\Z} "a\nb"
-e 29 - ^* BADRPT
-e 30 - {$*} BADRPT
-e 31 - {\A*} BADRPT
-e 32 - {\Z*} BADRPT
-
-
-
-doing 11 "boundary constraints"
-m 1 &LP {[[:<:]]a} a a
-m 2 &LP {[[:<:]]a} -a a
-f 3 &LP {[[:<:]]a} ba
-m 4 &LP {a[[:>:]]} a a
-m 5 &LP {a[[:>:]]} a- a
-f 6 &LP {a[[:>:]]} ab
-m 7 bLP {\<a} a a
-f 8 bLP {\<a} ba
-m 9 bLP {a\>} a a
-f 10 bLP {a\>} ab
-m 11 LP {\ya} a a
-f 12 LP {\ya} ba
-m 13 LP {a\y} a a
-f 14 LP {a\y} ab
-m 15 LP {a\Y} ab a
-f 16 LP {a\Y} a-
-f 17 LP {a\Y} a
-f 18 LP {-\Y} -a
-m 19 LP {-\Y} -% -
-f 20 LP {\Y-} a-
-e 21 - {[[:<:]]*} BADRPT
-e 22 - {[[:>:]]*} BADRPT
-e 23 b {\<*} BADRPT
-e 24 b {\>*} BADRPT
-e 25 - {\y*} BADRPT
-e 26 - {\Y*} BADRPT
-m 27 LP {\ma} a a
-f 28 LP {\ma} ba
-m 29 LP {a\M} a a
-f 30 LP {a\M} ab
-f 31 ILP {\Ma} a
-f 32 ILP {a\m} a
-
-
-
-doing 12 "character classes"
-m 1 LP {a\db} a0b a0b
-f 2 LP {a\db} axb
-f 3 LP {a\Db} a0b
-m 4 LP {a\Db} axb axb
-m 5 LP "a\\sb" "a b" "a b"
-m 6 LP "a\\sb" "a\tb" "a\tb"
-m 7 LP "a\\sb" "a\nb" "a\nb"
-f 8 LP {a\sb} axb
-m 9 LP {a\Sb} axb axb
-f 10 LP "a\\Sb" "a b"
-m 11 LP {a\wb} axb axb
-f 12 LP {a\wb} a-b
-f 13 LP {a\Wb} axb
-m 14 LP {a\Wb} a-b a-b
-m 15 LP {\y\w+z\y} adze-guz guz
-m 16 LPE {a[\d]b} a1b a1b
-m 17 LPE "a\[\\s]b" "a b" "a b"
-m 18 LPE {a[\w]b} axb axb
-
-
-
-doing 13 "escapes"
-e 1 & "a\\" EESCAPE
-m 2 - {a\<b} a<b a<b
-m 3 e {a\<b} a<b a<b
-m 4 bAS {a\wb} awb awb
-m 5 eAS {a\wb} awb awb
-m 6 PL "a\\ab" "a\007b" "a\007b"
-m 7 P "a\\bb" "a\bb" "a\bb"
-m 8 P {a\Bb} "a\\b" "a\\b"
-m 9 MP "a\\chb" "a\bb" "a\bb"
-m 10 MP "a\\cHb" "a\bb" "a\bb"
-m 11 LMP "a\\e" "a\033" "a\033"
-m 12 P "a\\fb" "a\fb" "a\fb"
-m 13 P "a\\nb" "a\nb" "a\nb"
-m 14 P "a\\rb" "a\rb" "a\rb"
-m 15 P "a\\tb" "a\tb" "a\tb"
-m 16 P "a\\u0008x" "a\bx" "a\bx"
-e 17 - {a\u008x} EESCAPE
-m 18 P "a\\u00088x" "a\b8x" "a\b8x"
-m 19 P "a\\U00000008x" "a\bx" "a\bx"
-e 20 - {a\U0000008x} EESCAPE
-m 21 P "a\\vb" "a\vb" "a\vb"
-m 22 MP "a\\x08x" "a\bx" "a\bx"
-e 23 - {a\xq} EESCAPE
-m 24 MP "a\\x0008x" "a\bx" "a\bx"
-e 25 - {a\z} EESCAPE
-m 26 MP "a\\010b" "a\bb" "a\bb"
-
-
-
-doing 14 "back references"
-# ugh
-m 1 {R[1P} {a(b*)c\1} abbcbb abbcbb bb
-m 2 {R[1P} {a(b*)c\1} ac ac ""
-f 3 {R[1P} {a(b*)c\1} abbcb
-m 4 {R[1P} {a(b*)\1} abbcbb abb b
-m 5 {R[1P} {a(b|bb)\1} abbcbb abb b
-m 6 {R[1P} {a([bc])\1} abb abb b
-f 7 {R[1P} {a([bc])\1} abc
-m 8 {R[1P} {a([bc])\1} abcabb abb b
-f 9 {R[1P} {a([bc])*\1} abc
-f 10 {R[1P} {a([bc])\1} abB
-m 11 {iR[1P} {a([bc])\1} abB abB b
-m 12 {R[1P} {a([bc])\1+} abbb abbb b
-m 13 {QR[1P} "a(\[bc])\\1{3,4}" abbbb abbbb b
-f 14 {QR[1P} "a(\[bc])\\1{3,4}" abbb
-m 15 {R[1P} {a([bc])\1*} abbb abbb b
-m 16 {R[1P} {a([bc])\1*} ab ab b
-m 17 {R[2P} {a([bc])(\1*)} ab ab b ""
-e 18 - {a((b)\1)} ESUBREG
-e 19 - {a(b)c\2} ESUBREG
-m 20 {bR[1} {a\(b*\)c\1} abbcbb abbcbb bb
-
-
-
-doing 15 "octal escapes vs back references"
-# initial zero is always octal
-m 1 MP "a\\010b" "a\bb" "a\bb"
-m 2 MP "a\\0070b" "a\0070b" "a\0070b"
-m 3 MP "a\\07b" "a\007b" "a\007b"
-m 4 MP "a(b)(b)(b)(b)(b)(b)(b)(b)(b)(b)\\07c" "abbbbbbbbbb\007c" \
- "abbbbbbbbbb\007c" "b" "b" "b" "b" "b" "b" \
- "b" "b" "b" "b"
-# a single digit is always a backref
-e 5 - {a\7b} ESUBREG
-# otherwise it's a backref only if within range (barf!)
-m 6 MP "a\\10b" "a\bb" "a\bb"
-m 7 MP {a\101b} aAb aAb
-m 8 RP {a(b)(b)(b)(b)(b)(b)(b)(b)(b)(b)\10c} abbbbbbbbbbbc \
- abbbbbbbbbbbc b b b b b b b \
- b b b
-# but we're fussy about border cases -- guys who want octal should use the zero
-e 9 - {a((((((((((b\10))))))))))c} ESUBREG
-# BREs don't have octal, EREs don't have backrefs
-m 10 MP "a\\12b" "a\nb" "a\nb"
-e 11 b {a\12b} ESUBREG
-m 12 eAS {a\12b} a12b a12b
-
-
-
-doing 16 "expanded syntax"
-m 1 xP "a b c" "abc" "abc"
-m 2 xP "a b #oops\nc\td" "abcd" "abcd"
-m 3 x "a\\ b\\\tc" "a b\tc" "a b\tc"
-m 4 xP "a b\\#c" "ab#c" "ab#c"
-m 5 xP "a b\[c d]e" "ab e" "ab e"
-m 6 xP "a b\[c#d]e" "ab#e" "ab#e"
-m 7 xP "a b\[c#d]e" "abde" "abde"
-m 8 xSPB "ab{ d" "ab\{d" "ab\{d"
-m 9 xPQ "ab{ 1 , 2 }c" "abc" "abc"
-
-
-
-doing 17 "misc syntax"
-m 1 P a(?#comment)b ab ab
-
-
-
-doing 18 "unmatchable REs"
-f 1 I a^b ab
-
-
-
-doing 19 "case independence"
-m 1 &i ab Ab Ab
-m 2 &i {a[bc]} aC aC
-f 3 &i {a[^bc]} aB
-m 4 &iM {a[b-d]} aC aC
-f 5 &iM {a[^b-d]} aC
-
-
-
-doing 20 "directors and embedded options"
-e 1 & ***? BADPAT
-m 2 q ***? ***? ***?
-m 3 &P ***=a*b a*b a*b
-m 4 q ***=a*b ***=a*b ***=a*b
-m 5 bLP {***:\w+} ab ab
-m 6 eLP {***:\w+} ab ab
-e 7 & ***:***=a*b BADRPT
-m 8 &P ***:(?b)a+b a+b a+b
-m 9 P (?b)a+b a+b a+b
-e 10 e {(?b)\w+} BADRPT
-m 11 bAS {(?b)\w+} (?b)w+ (?b)w+
-m 12 iP (?c)a a a
-f 13 iP (?c)a A
-m 14 APS {(?e)\W+} WW WW
-m 15 P (?i)a+ Aa Aa
-f 16 P "(?m)a.b" "a\nb"
-m 17 P "(?m)^b" "a\nb" "b"
-f 18 P "(?n)a.b" "a\nb"
-m 19 P "(?n)^b" "a\nb" "b"
-f 20 P "(?p)a.b" "a\nb"
-f 21 P "(?p)^b" "a\nb"
-m 22 P (?q)a+b a+b a+b
-m 23 nP "(?s)a.b" "a\nb" "a\nb"
-m 24 xP "(?t)a b" "a b" "a b"
-m 25 P "(?w)a.b" "a\nb" "a\nb"
-m 26 P "(?w)^b" "a\nb" "b"
-m 27 P "(?x)a b" "ab" "ab"
-e 28 - (?z)ab BADOPT
-m 29 P (?ici)a+ Aa Aa
-e 30 P (?i)(?q)a+ BADRPT
-m 31 P (?q)(?i)a+ (?i)a+ (?i)a+
-m 32 P (?qe)a+ a a
-m 33 xP "(?q)a b" "a b" "a b"
-m 34 P "(?qx)a b" "a b" "a b"
-m 35 P (?qi)ab Ab Ab
-
-
-
-doing 21 "capturing"
-m 1 - a(b)c abc abc b
-m 2 P a(?:b)c xabc abc
-m 3 - a((b))c xabcy abc b b
-m 4 P a(?:(b))c abcy abc b
-m 5 P a((?:b))c abc abc b
-m 6 P a(?:(?:b))c abc abc
-i 7 Q "a(b){0}c" ac {0 1} {-1 -1}
-m 8 - a(b)c(d)e abcde abcde b d
-m 9 - (b)c(d)e bcde bcde b d
-m 10 - a(b)(d)e abde abde b d
-m 11 - a(b)c(d) abcd abcd b d
-m 12 - (ab)(cd) xabcdy abcd ab cd
-m 13 - a(b)?c xabcy abc b
-i 14 - a(b)?c xacy {1 2} {-1 -1}
-m 15 - a(b)?c(d)?e xabcdey abcde b d
-i 16 - a(b)?c(d)?e xacdey {1 4} {-1 -1} {3 3}
-i 17 - a(b)?c(d)?e xabcey {1 4} {2 2} {-1 -1}
-i 18 - a(b)?c(d)?e xacey {1 3} {-1 -1} {-1 -1}
-m 19 - a(b)*c xabcy abc b
-i 20 - a(b)*c xabbbcy {1 5} {4 4}
-i 21 - a(b)*c xacy {1 2} {-1 -1}
-m 22 - a(b*)c xabbbcy abbbc bbb
-m 23 - a(b*)c xacy ac ""
-f 24 - a(b)+c xacy
-m 25 - a(b)+c xabcy abc b
-i 26 - a(b)+c xabbbcy {1 5} {4 4}
-m 27 - a(b+)c xabbbcy abbbc bbb
-i 28 Q "a(b){2,3}c" xabbbcy {1 5} {4 4}
-i 29 Q "a(b){2,3}c" xabbcy {1 4} {3 3}
-f 30 Q "a(b){2,3}c" xabcy
-m 31 LP "\\y(\\w+)\\y" "-- abc-" "abc" "abc"
-m 32 - a((b|c)d+)+ abacdbd acdbd bd b
-m 33 N (.*).* abc abc abc
-m 34 N (a*)* bc "" ""
-
-
-
-doing 22 "multicharacter collating elements"
-# again ugh
-# currently disabled because the fake MCCE we use for testing is unavailable
-xx m 1 &+L {a[c]e} ace ace
-xx f 2 &+I {a[c]h} ach
-xx m 3 &+L {a[[.ch.]]} ach ach
-xx f 4 &+L {a[[.ch.]]} ace
-xx m 5 &+L {a[c[.ch.]]} ac ac
-xx m 6 &+L {a[c[.ch.]]} ace ac
-xx m 7 &+L {a[c[.ch.]]} ache ach
-xx f 8 &+L {a[^c]e} ace
-xx m 9 &+L {a[^c]e} abe abe
-xx m 10 &+L {a[^c]e} ache ache
-xx f 11 &+L {a[^[.ch.]]} ach
-xx m 12 &+L {a[^[.ch.]]} ace ac
-xx m 13 &+L {a[^[.ch.]]} ac ac
-xx m 14 &+L {a[^[.ch.]]} abe ab
-xx f 15 &+L {a[^c[.ch.]]} ach
-xx f 16 &+L {a[^c[.ch.]]} ace
-xx f 17 &+L {a[^c[.ch.]]} ac
-xx m 18 &+L {a[^c[.ch.]]} abe ab
-xx m 19 &+L {a[^b]} ac ac
-xx m 20 &+L {a[^b]} ace ac
-xx m 21 &+L {a[^b]} ach ach
-xx f 22 &+L {a[^b]} abe
-
-
-
-doing 23 "lookahead constraints"
-m 1 HP a(?=b)b* ab ab
-f 2 HP a(?=b)b* a
-m 3 HP a(?=b)b*(?=c)c* abc abc
-f 4 HP a(?=b)b*(?=c)c* ab
-f 5 HP a(?!b)b* ab
-m 6 HP a(?!b)b* a a
-m 7 HP (?=b)b b b
-f 8 HP (?=b)b a
-
-
-
-doing 24 "non-greedy quantifiers"
-m 1 P ab+? abb ab
-m 2 P ab+?c abbc abbc
-m 3 P ab*? abb a
-m 4 P ab*?c abbc abbc
-m 5 P ab?? ab a
-m 6 P ab??c abc abc
-m 7 PQ "ab{2,4}?" abbbb abb
-m 8 PQ "ab{2,4}?c" abbbbc abbbbc
-
-
-
-doing 25 "mixed quantifiers"
-xx to be done, actually
-xx should include |
-
-
-
-doing 26 "tricky cases"
-# attempts to trick the matcher into accepting a short match
-m 1 - (week|wee)(night|knights) weeknights weeknights \
- wee knights
-m 2 RP {a(bc*).*\1} abccbccb abccbccb b
-m 3 - {a(b.[bc]*)+} abcbd abcbd bd
-
-
-
-doing 27 "implementation misc."
-# duplicate arcs are suppressed
-m 1 P a(?:b|b)c abc abc
-# make color/subcolor relationship go back and forth
-m 2 & {[ab][ab][ab]} aba aba
-m 3 & {[ab][ab][ab][ab][ab][ab][ab]} abababa abababa
-
-
-
-doing 28 "boundary busters etc."
-# color-descriptor allocation changes at 10
-m 1 & abcdefghijkl abcdefghijkl abcdefghijkl
-# so does arc allocation
-m 2 P a(?:b|c|d|e|f|g|h|i|j|k|l|m)n agn agn
-# subexpression tracking also at 10
-m 3 - a(((((((((((((b)))))))))))))c abc abc b b b b b b b b b b b b b
-# state-set handling changes slightly at unsigned size (might be 64...)
-# (also stresses arc allocation)
-m 4 Q "ab{1,100}c" abbc abbc
-m 5 Q "ab{1,100}c" abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc \
- abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc
-m 6 Q "ab{1,100}c" \
- abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc \
- abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc
-# force small cache and bust it, several ways
-m 7 LP {\w+abcdefgh} xyzabcdefgh xyzabcdefgh
-m 8 %LP {\w+abcdefgh} xyzabcdefgh xyzabcdefgh
-m 9 %LP {\w+abcdefghijklmnopqrst} xyzabcdefghijklmnopqrst \
- xyzabcdefghijklmnopqrst
-i 10 %LP {\w+(abcdefgh)?} xyz {0 2} {-1 -1}
-i 11 %LP {\w+(abcdefgh)?} xyzabcdefg {0 9} {-1 -1}
-i 12 %LP {\w+(abcdefghijklmnopqrst)?} xyzabcdefghijklmnopqrs \
- {0 21} {-1 -1}
-
-
-
-doing 29 "misc. oddities and old bugs"
-e 1 & *** BADRPT
-m 2 N a?b* abb abb
-m 3 N a?b* bb bb
-m 4 & a*b aab aab
-m 5 & ^a*b aaaab aaaab
-m 6 &M {[0-6][1-2][0-3][0-6][1-6][0-6]} 010010 010010
-
-
-
-doing 0 "flush" ;# to flush any leftover complaints
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
diff --git a/tests/regexp.test b/tests/regexp.test
deleted file mode 100644
index 611a780..0000000
--- a/tests/regexp.test
+++ /dev/null
@@ -1,378 +0,0 @@
-# Commands covered: regexp, regsub
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1998 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: regexp.test,v 1.3 1999/04/16 00:47:33 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-catch {unset foo}
-test regexp-1.1 {basic regexp operation} {
- regexp ab*c abbbc
-} 1
-test regexp-1.2 {basic regexp operation} {
- regexp ab*c ac
-} 1
-test regexp-1.3 {basic regexp operation} {
- regexp ab*c ab
-} 0
-test regexp-1.4 {basic regexp operation} {
- regexp -- -gorp abc-gorpxxx
-} 1
-test regexp-1.5 {basic regexp operation} {
- regexp {^([^ ]*)[ ]*([^ ]*)} "" a
-} 1
-test regexp-1.6 {basic regexp operation} {
- list [catch {regexp {} abc} msg] $msg
-} {0 1}
-test regexp-1.7 {regexp utf compliance} {
- # if not UTF-8 aware, result is "0 1"
- set foo "\u4e4eb q"
- regexp "\u4e4eb q" "a\u4e4eb qw\u5e4e\x4e wq" bar
- list [string compare $foo $bar] [regexp 4 $bar]
-} {0 0}
-
-test regexp-2.1 {getting substrings back from regexp} {
- set foo {}
- list [regexp ab*c abbbbc foo] $foo
-} {1 abbbbc}
-test regexp-2.2 {getting substrings back from regexp} {
- set foo {}
- set f2 {}
- list [regexp a(b*)c abbbbc foo f2] $foo $f2
-} {1 abbbbc bbbb}
-test regexp-2.3 {getting substrings back from regexp} {
- set foo {}
- set f2 {}
- list [regexp a(b*)(c) abbbbc foo f2] $foo $f2
-} {1 abbbbc bbbb}
-test regexp-2.4 {getting substrings back from regexp} {
- set foo {}
- set f2 {}
- set f3 {}
- list [regexp a(b*)(c) abbbbc foo f2 f3] $foo $f2 $f3
-} {1 abbbbc bbbb c}
-test regexp-2.5 {getting substrings back from regexp} {
- set foo {}; set f1 {}; set f2 {}; set f3 {}; set f4 {}; set f5 {};
- set f6 {}; set f7 {}; set f8 {}; set f9 {}; set fa {}; set fb {};
- list [regexp (1*)(2*)(3*)(4*)(5*)(6*)(7*)(8*)(9*)(a*)(b*) \
- 12223345556789999aabbb \
- foo f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb] $foo $f1 $f2 $f3 $f4 $f5 \
- $f6 $f7 $f8 $f9 $fa $fb
-} {1 12223345556789999aabbb 1 222 33 4 555 6 7 8 9999 aa bbb}
-test regexp-2.6 {getting substrings back from regexp} {
- set foo 2; set f2 2; set f3 2; set f4 2
- list [regexp (a)(b)? xay foo f2 f3 f4] $foo $f2 $f3 $f4
-} {1 a a {} {}}
-test regexp-2.7 {getting substrings back from regexp} {
- set foo 1; set f2 1; set f3 1; set f4 1
- list [regexp (a)(b)?(c) xacy foo f2 f3 f4] $foo $f2 $f3 $f4
-} {1 ac a {} c}
-test regexp-2.8 {getting substrings back from regexp} {
- set match {}
- list [regexp {^a*b} aaaab match] $match
-} {1 aaaab}
-
-test regexp-3.1 {-indices option to regexp} {
- set foo {}
- list [regexp -indices ab*c abbbbc foo] $foo
-} {1 {0 5}}
-test regexp-3.2 {-indices option to regexp} {
- set foo {}
- set f2 {}
- list [regexp -indices a(b*)c abbbbc foo f2] $foo $f2
-} {1 {0 5} {1 4}}
-test regexp-3.3 {-indices option to regexp} {
- set foo {}
- set f2 {}
- list [regexp -indices a(b*)(c) abbbbc foo f2] $foo $f2
-} {1 {0 5} {1 4}}
-test regexp-3.4 {-indices option to regexp} {
- set foo {}
- set f2 {}
- set f3 {}
- list [regexp -indices a(b*)(c) abbbbc foo f2 f3] $foo $f2 $f3
-} {1 {0 5} {1 4} {5 5}}
-test regexp-3.5 {-indices option to regexp} {
- set foo {}; set f1 {}; set f2 {}; set f3 {}; set f4 {}; set f5 {};
- set f6 {}; set f7 {}; set f8 {}; set f9 {}
- list [regexp -indices (1*)(2*)(3*)(4*)(5*)(6*)(7*)(8*)(9*) \
- 12223345556789999 \
- foo f1 f2 f3 f4 f5 f6 f7 f8 f9] $foo $f1 $f2 $f3 $f4 $f5 \
- $f6 $f7 $f8 $f9
-} {1 {0 16} {0 0} {1 3} {4 5} {6 6} {7 9} {10 10} {11 11} {12 12} {13 16}}
-test regexp-3.6 {getting substrings back from regexp} {
- set foo 2; set f2 2; set f3 2; set f4 2
- list [regexp -indices (a)(b)? xay foo f2 f3 f4] $foo $f2 $f3 $f4
-} {1 {1 1} {1 1} {-1 -1} {-1 -1}}
-test regexp-3.7 {getting substrings back from regexp} {
- set foo 1; set f2 1; set f3 1; set f4 1
- list [regexp -indices (a)(b)?(c) xacy foo f2 f3 f4] $foo $f2 $f3 $f4
-} {1 {1 2} {1 1} {-1 -1} {2 2}}
-
-test regexp-4.1 {-nocase option to regexp} {
- regexp -nocase foo abcFOo
-} 1
-test regexp-4.2 {-nocase option to regexp} {
- set f1 22
- set f2 33
- set f3 44
- list [regexp -nocase {a(b*)([xy]*)z} aBbbxYXxxZ22 f1 f2 f3] $f1 $f2 $f3
-} {1 aBbbxYXxxZ Bbb xYXxx}
-test regexp-4.3 {-nocase option to regexp} {
- regexp -nocase FOo abcFOo
-} 1
-set x abcdefghijklmnopqrstuvwxyz1234567890
-set x $x$x$x$x$x$x$x$x$x$x$x$x
-test regexp-4.4 {case conversion in regexp} {
- list [regexp -nocase $x $x foo] $foo
-} "1 $x"
-catch {unset x}
-
-test regexp-5.1 {exercise cache of compiled expressions} {
- regexp .*a b
- regexp .*b c
- regexp .*c d
- regexp .*d e
- regexp .*e f
- regexp .*a bbba
-} 1
-test regexp-5.2 {exercise cache of compiled expressions} {
- regexp .*a b
- regexp .*b c
- regexp .*c d
- regexp .*d e
- regexp .*e f
- regexp .*b xxxb
-} 1
-test regexp-5.3 {exercise cache of compiled expressions} {
- regexp .*a b
- regexp .*b c
- regexp .*c d
- regexp .*d e
- regexp .*e f
- regexp .*c yyyc
-} 1
-test regexp-5.4 {exercise cache of compiled expressions} {
- regexp .*a b
- regexp .*b c
- regexp .*c d
- regexp .*d e
- regexp .*e f
- regexp .*d 1d
-} 1
-test regexp-5.5 {exercise cache of compiled expressions} {
- regexp .*a b
- regexp .*b c
- regexp .*c d
- regexp .*d e
- regexp .*e f
- regexp .*e xe
-} 1
-
-test regexp-6.1 {regexp errors} {
- list [catch {regexp a} msg] $msg
-} {1 {wrong # args: should be "regexp ?switches? exp string ?matchVar? ?subMatchVar subMatchVar ...?"}}
-test regexp-6.2 {regexp errors} {
- list [catch {regexp -nocase a} msg] $msg
-} {1 {wrong # args: should be "regexp ?switches? exp string ?matchVar? ?subMatchVar subMatchVar ...?"}}
-test regexp-6.3 {regexp errors} {
- list [catch {regexp -gorp a} msg] $msg
-} {1 {bad switch "-gorp": must be -indices, -nocase, -about, -expanded, -line, -linestop, -lineanchor, or --}}
-test regexp-6.4 {regexp errors} {
- list [catch {regexp a( b} msg] $msg
-} {1 {couldn't compile regular expression pattern: parentheses () not balanced}}
-test regexp-6.5 {regexp errors} {
- list [catch {regexp a( b} msg] $msg
-} {1 {couldn't compile regular expression pattern: parentheses () not balanced}}
-test regexp-6.6 {regexp errors} {
- list [catch {regexp a a f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1} msg] $msg
-} {0 1}
-test regexp-6.7 {regexp errors} {
- list [catch {regexp (x)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.) xyzzy} msg] $msg
-} {0 0}
-test regexp-6.8 {regexp errors} {
- catch {unset f1}
- set f1 44
- list [catch {regexp abc abc f1(f2)} msg] $msg
-} {1 {couldn't set variable "f1(f2)"}}
-
-test regexp-7.1 {basic regsub operation} {
- list [regsub aa+ xaxaaaxaa 111&222 foo] $foo
-} {1 xax111aaa222xaa}
-test regexp-7.2 {basic regsub operation} {
- list [regsub aa+ aaaxaa &111 foo] $foo
-} {1 aaa111xaa}
-test regexp-7.3 {basic regsub operation} {
- list [regsub aa+ xaxaaa 111& foo] $foo
-} {1 xax111aaa}
-test regexp-7.4 {basic regsub operation} {
- list [regsub aa+ aaa 11&2&333 foo] $foo
-} {1 11aaa2aaa333}
-test regexp-7.5 {basic regsub operation} {
- list [regsub aa+ xaxaaaxaa &2&333 foo] $foo
-} {1 xaxaaa2aaa333xaa}
-test regexp-7.6 {basic regsub operation} {
- list [regsub aa+ xaxaaaxaa 1&22& foo] $foo
-} {1 xax1aaa22aaaxaa}
-test regexp-7.7 {basic regsub operation} {
- list [regsub a(a+) xaxaaaxaa {1\122\1} foo] $foo
-} {1 xax1aa22aaxaa}
-test regexp-7.8 {basic regsub operation} {
- list [regsub a(a+) xaxaaaxaa {1\\\122\1} foo] $foo
-} "1 {xax1\\aa22aaxaa}"
-test regexp-7.9 {basic regsub operation} {
- list [regsub a(a+) xaxaaaxaa {1\\122\1} foo] $foo
-} "1 {xax1\\122aaxaa}"
-test regexp-7.10 {basic regsub operation} {
- list [regsub a(a+) xaxaaaxaa {1\\&\1} foo] $foo
-} "1 {xax1\\aaaaaxaa}"
-test regexp-7.11 {basic regsub operation} {
- list [regsub a(a+) xaxaaaxaa {1\&\1} foo] $foo
-} {1 xax1&aaxaa}
-test regexp-7.12 {basic regsub operation} {
- list [regsub a(a+) xaxaaaxaa {\1\1\1\1&&} foo] $foo
-} {1 xaxaaaaaaaaaaaaaaxaa}
-test regexp-7.13 {basic regsub operation} {
- set foo xxx
- list [regsub abc xyz 111 foo] $foo
-} {0 xyz}
-test regexp-7.14 {basic regsub operation} {
- set foo xxx
- list [regsub ^ xyz "111 " foo] $foo
-} {1 {111 xyz}}
-test regexp-7.15 {basic regsub operation} {
- set foo xxx
- list [regsub -- -foo abc-foodef "111 " foo] $foo
-} {1 {abc111 def}}
-test regexp-7.16 {basic regsub operation} {
- set foo xxx
- list [regsub x "" y foo] $foo
-} {0 {}}
-test regexp-7.17 {regsub utf compliance} {
- # if not UTF-8 aware, result is "0 1"
- set foo "xyz555ijka\u4e4ebpqr"
- regsub a\u4e4eb xyza\u4e4ebijka\u4e4ebpqr 555 bar
- list [string compare $foo $bar] [regexp 4 $bar]
-} {0 0}
-
-test regexp-8.1 {case conversion in regsub} {
- list [regsub -nocase a(a+) xaAAaAAay & foo] $foo
-} {1 xaAAaAAay}
-test regexp-8.2 {case conversion in regsub} {
- list [regsub -nocase a(a+) xaAAaAAay & foo] $foo
-} {1 xaAAaAAay}
-test regexp-8.3 {case conversion in regsub} {
- set foo 123
- list [regsub a(a+) xaAAaAAay & foo] $foo
-} {0 xaAAaAAay}
-test regexp-8.4 {case conversion in regsub} {
- set foo 123
- list [regsub -nocase a CaDE b foo] $foo
-} {1 CbDE}
-test regexp-8.5 {case conversion in regsub} {
- set foo 123
- list [regsub -nocase XYZ CxYzD b foo] $foo
-} {1 CbD}
-test regexp-8.6 {case conversion in regsub} {
- set x abcdefghijklmnopqrstuvwxyz1234567890
- set x $x$x$x$x$x$x$x$x$x$x$x$x
- set foo 123
- list [regsub -nocase $x $x b foo] $foo
-} {1 b}
-
-test regexp-9.1 {-all option to regsub} {
- set foo 86
- list [regsub -all x+ axxxbxxcxdx |&| foo] $foo
-} {4 a|xxx|b|xx|c|x|d|x|}
-test regexp-9.2 {-all option to regsub} {
- set foo 86
- list [regsub -nocase -all x+ aXxXbxxcXdx |&| foo] $foo
-} {4 a|XxX|b|xx|c|X|d|x|}
-test regexp-9.3 {-all option to regsub} {
- set foo 86
- list [regsub x+ axxxbxxcxdx |&| foo] $foo
-} {1 a|xxx|bxxcxdx}
-test regexp-9.4 {-all option to regsub} {
- set foo 86
- list [regsub -all bc axxxbxxcxdx |&| foo] $foo
-} {0 axxxbxxcxdx}
-test regexp-9.5 {-all option to regsub} {
- set foo xxx
- list [regsub -all node "node node more" yy foo] $foo
-} {2 {yy yy more}}
-test regexp-9.6 {-all option to regsub} {
- set foo xxx
- list [regsub -all ^ xxx 123 foo] $foo
-} {1 123xxx}
-
-test regexp-10.1 {regsub errors} {
- list [catch {regsub a b c} msg] $msg
-} {1 {wrong # args: should be "regsub ?switches? exp string subSpec varName"}}
-test regexp-10.2 {regsub errors} {
- list [catch {regsub -nocase a b c} msg] $msg
-} {1 {wrong # args: should be "regsub ?switches? exp string subSpec varName"}}
-test regexp-10.3 {regsub errors} {
- list [catch {regsub -nocase -all a b c} msg] $msg
-} {1 {wrong # args: should be "regsub ?switches? exp string subSpec varName"}}
-test regexp-10.4 {regsub errors} {
- list [catch {regsub a b c d e f} msg] $msg
-} {1 {wrong # args: should be "regsub ?switches? exp string subSpec varName"}}
-test regexp-10.5 {regsub errors} {
- list [catch {regsub -gorp a b c} msg] $msg
-} {1 {bad switch "-gorp": must be -all, -nocase, or --}}
-test regexp-10.6 {regsub errors} {
- list [catch {regsub -nocase a( b c d} msg] $msg
-} {1 {couldn't compile regular expression pattern: parentheses () not balanced}}
-test regexp-10.7 {regsub errors} {
- catch {unset f1}
- set f1 44
- list [catch {regsub -nocase aaa aaa xxx f1(f2)} msg] $msg
-} {1 {couldn't set variable "f1(f2)"}}
-
-test regexp-11.1 {Tcl_RegExpExec: large number of subexpressions} {
- list [regexp (.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.) abcdefghijklmnopqrstuvwxyz all a b c d e f g h i j k l m n o p q r s t u v w x y z] $all $a $b $c $d $e $f $g $h $i $j $k $l $m $n $o $p $q $r $s $t $u $v $w $x $y $z
-} {1 abcdefghijklmnopqrstuvwxyz a b c d e f g h i j k l m n o p q r s t u v w x y z}
-
-test regexp-12.1 {regsub of a very large string} {
- # This test is designed to stress the memory subsystem in order
- # to catch Bug #933. It only fails if the Tcl memory allocator
- # is in use.
-
- set line {BEGIN_TABLE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END_TABLE}
- set filedata ""
- for {set i 1} {$i<200} {incr i} {
- append filedata $line
- }
- for {set i 1} {$i<10} {incr i} {
- regsub -all "BEGIN_TABLE " $filedata "" newfiledata
- }
- set x done
-} {done}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/registry.test b/tests/registry.test
deleted file mode 100644
index 773f964..0000000
--- a/tests/registry.test
+++ /dev/null
@@ -1,601 +0,0 @@
-# registry.test --
-#
-# This file contains a collection of tests for the registry command.
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# In order for these tests to run, the registry package must be on the
-# auto_path or the registry package must have been loaded already.
-#
-# Copyright (c) 1997 by Sun Microsystems, Inc. All rights reserved.
-# Copyright (c) 1998-1999 by Scriptics Corporation.
-#
-# RCS: @(#) $Id: registry.test,v 1.5 1999/04/16 00:47:33 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {$tcl_platform(platform) == "windows"} {
- if [catch {
- set lib [lindex [glob [file join [pwd] [file dirname \
- [info nameofexecutable]] tclreg*.dll]] 0]
- load $lib registry
- }] {
- puts "Unable to find the registry package. Skipping registry tests."
- return
- }
-}
-
-# determine the current locale
-set old [testlocale all]
-if {![string compare [testlocale all ""] "English_United States.1252"]} {
- # error messages from registry package are already localized.
- set ::tcltest::testConfig(english) 1
-}
-testlocale all $old
-unset old
-
-set hostname [info hostname]
-
-test registry-1.1 {argument parsing for registry command} {pcOnly} {
- list [catch {registry} msg] $msg
-} {1 {wrong # args: should be "registry option ?arg arg ...?"}}
-test registry-1.2 {argument parsing for registry command} {pcOnly} {
- list [catch {registry foo} msg] $msg
-} {1 {bad option "foo": must be delete, get, keys, set, type, or values}}
-
-test registry-1.3 {argument parsing for registry command} {pcOnly} {
- list [catch {registry d} msg] $msg
-} {1 {wrong # args: should be "registry delete keyName ?valueName?"}}
-test registry-1.4 {argument parsing for registry command} {pcOnly} {
- list [catch {registry delete} msg] $msg
-} {1 {wrong # args: should be "registry delete keyName ?valueName?"}}
-test registry-1.5 {argument parsing for registry command} {pcOnly} {
- list [catch {registry delete foo bar baz} msg] $msg
-} {1 {wrong # args: should be "registry delete keyName ?valueName?"}}
-
-test registry-1.6 {argument parsing for registry command} {pcOnly} {
- list [catch {registry g} msg] $msg
-} {1 {wrong # args: should be "registry get keyName valueName"}}
-test registry-1.7 {argument parsing for registry command} {pcOnly} {
- list [catch {registry get} msg] $msg
-} {1 {wrong # args: should be "registry get keyName valueName"}}
-test registry-1.8 {argument parsing for registry command} {pcOnly} {
- list [catch {registry get foo} msg] $msg
-} {1 {wrong # args: should be "registry get keyName valueName"}}
-test registry-1.9 {argument parsing for registry command} {pcOnly} {
- list [catch {registry get foo bar baz} msg] $msg
-} {1 {wrong # args: should be "registry get keyName valueName"}}
-
-test registry-1.10 {argument parsing for registry command} {pcOnly} {
- list [catch {registry k} msg] $msg
-} {1 {wrong # args: should be "registry keys keyName ?pattern?"}}
-test registry-1.11 {argument parsing for registry command} {pcOnly} {
- list [catch {registry keys} msg] $msg
-} {1 {wrong # args: should be "registry keys keyName ?pattern?"}}
-test registry-1.12 {argument parsing for registry command} {pcOnly} {
- list [catch {registry keys foo bar baz} msg] $msg
-} {1 {wrong # args: should be "registry keys keyName ?pattern?"}}
-
-test registry-1.13 {argument parsing for registry command} {pcOnly} {
- list [catch {registry s} msg] $msg
-} {1 {wrong # args: should be "registry set keyName ?valueName data ?type??"}}
-test registry-1.14 {argument parsing for registry command} {pcOnly} {
- list [catch {registry set} msg] $msg
-} {1 {wrong # args: should be "registry set keyName ?valueName data ?type??"}}
-test registry-1.15 {argument parsing for registry command} {pcOnly} {
- list [catch {registry set foo bar} msg] $msg
-} {1 {wrong # args: should be "registry set keyName ?valueName data ?type??"}}
-test registry-1.16 {argument parsing for registry command} {pcOnly} {
- list [catch {registry set foo bar baz blat gorp} msg] $msg
-} {1 {wrong # args: should be "registry set keyName ?valueName data ?type??"}}
-
-test registry-1.17 {argument parsing for registry command} {pcOnly} {
- list [catch {registry t} msg] $msg
-} {1 {wrong # args: should be "registry type keyName valueName"}}
-test registry-1.18 {argument parsing for registry command} {pcOnly} {
- list [catch {registry type} msg] $msg
-} {1 {wrong # args: should be "registry type keyName valueName"}}
-test registry-1.19 {argument parsing for registry command} {pcOnly} {
- list [catch {registry type foo} msg] $msg
-} {1 {wrong # args: should be "registry type keyName valueName"}}
-test registry-1.20 {argument parsing for registry command} {pcOnly} {
- list [catch {registry type foo bar baz} msg] $msg
-} {1 {wrong # args: should be "registry type keyName valueName"}}
-
-test registry-1.21 {argument parsing for registry command} {pcOnly} {
- list [catch {registry v} msg] $msg
-} {1 {wrong # args: should be "registry values keyName ?pattern?"}}
-test registry-1.22 {argument parsing for registry command} {pcOnly} {
- list [catch {registry values} msg] $msg
-} {1 {wrong # args: should be "registry values keyName ?pattern?"}}
-test registry-1.23 {argument parsing for registry command} {pcOnly} {
- list [catch {registry values foo bar baz} msg] $msg
-} {1 {wrong # args: should be "registry values keyName ?pattern?"}}
-
-test registry-2.1 {DeleteKey: bad key} {pcOnly} {
- list [catch {registry delete foo} msg] $msg
-} {1 {bad root name "foo": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}}
-test registry-2.2 {DeleteKey: bad key} {pcOnly} {
- list [catch {registry delete HKEY_CLASSES_ROOT} msg] $msg
-} {1 {bad key: cannot delete root keys}}
-test registry-2.3 {DeleteKey: bad key} {pcOnly} {
- list [catch {registry delete HKEY_CLASSES_ROOT\\} msg] $msg
-} {1 {bad key: cannot delete root keys}}
-test registry-2.4 {DeleteKey: subkey at root level} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry keys HKEY_CLASSES_ROOT TclFoobar
-} {}
-test registry-2.5 {DeleteKey: subkey below root level} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\test
- registry delete HKEY_CLASSES_ROOT\\TclFoobar\\test
- set result [registry keys HKEY_CLASSES_ROOT TclFoobar\\test]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {}
-test registry-2.6 {DeleteKey: recursive delete} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\test1
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\test2\\test3
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result [registry keys HKEY_CLASSES_ROOT TclFoobar]
- set result
-} {}
-test registry-2.7 {DeleteKey: trailing backslashes} {pcOnly english} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz
- list [catch {registry delete HKEY_CLASSES_ROOT\\TclFoobar\\} msg] $msg
-} {1 {unable to delete key: The configuration registry key is invalid.}}
-test registry-2.8 {DeleteKey: failure} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
-} {}
-test registry-2.9 {DeleteKey: unicode} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\test\u00c7bar\\a
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\test\u00c7bar\\b
- registry delete HKEY_CLASSES_ROOT\\TclFoobar\\test\u00c7bar
- set result [registry keys HKEY_CLASSES_ROOT\\TclFoobar]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {}
-
-test registry-3.1 {DeleteValue} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz test1 blort
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz test2 blat
- registry delete HKEY_CLASSES_ROOT\\TclFoobar\\baz test1
- set result [registry values HKEY_CLASSES_ROOT\\TclFoobar\\baz]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} test2
-test registry-3.2 {DeleteValue: bad key} {pcOnly english} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- list [catch {registry delete HKEY_CLASSES_ROOT\\TclFoobar test} msg] $msg
-} {1 {unable to open key: The system cannot find the file specified.}}
-test registry-3.3 {DeleteValue: bad value} {pcOnly english} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz test2 blort
- set result [list [catch {registry delete HKEY_CLASSES_ROOT\\TclFoobar test1} msg] $msg]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {1 {unable to delete value "test1" from key "HKEY_CLASSES_ROOT\TclFoobar": The system cannot find the file specified.}}
-test registry-3.4 {DeleteValue: Unicode} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\\u00c7baz \u00c7test1 blort
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\\u00c7baz test2 blat
- registry delete HKEY_CLASSES_ROOT\\TclFoobar\\\u00c7baz \u00c7test1
- set result [registry values HKEY_CLASSES_ROOT\\TclFoobar\\\u00c7baz]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} test2
-
-test registry-4.1 {GetKeyNames: bad key} {pcOnly english} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- list [catch {registry keys HKEY_CLASSES_ROOT\\TclFoobar} msg] $msg
-} {1 {unable to open key: The system cannot find the file specified.}}
-test registry-4.2 {GetKeyNames} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz
- set result [registry keys HKEY_CLASSES_ROOT\\TclFoobar]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {baz}
-test registry-4.3 {GetKeyNames: remote key} {pcOnly nonPortable english} {
- registry set \\\\$hostname\\HKEY_CLASSES_ROOT\\TclFoobar\\baz
- set result [registry keys \\\\gaspode\\HKEY_CLASSES_ROOT\\TclFoobar]
- registry delete \\\\$hostname\\HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {baz}
-test registry-4.4 {GetKeyNames: empty key} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar
- set result [registry keys HKEY_CLASSES_ROOT\\TclFoobar]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {}
-test registry-4.5 {GetKeyNames: patterns} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\blat
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\foo
- set result [lsort [registry keys HKEY_CLASSES_ROOT\\TclFoobar b*]]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {baz blat}
-test registry-4.6 {GetKeyNames: names with spaces} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz\ bar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\blat
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\foo
- set result [lsort [registry keys HKEY_CLASSES_ROOT\\TclFoobar b*]]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {{baz bar} blat}
-test registry-4.7 {GetKeyNames: Unicode} {pcOnly english} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz\u00c7bar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\blat
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\foo
- set result [lsort [registry keys HKEY_CLASSES_ROOT\\TclFoobar b*]]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} "baz\u00c7bar blat"
-test registry-4.8 {GetKeyNames: Unicode} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz\u30b7bar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\blat
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\foo
- set result [lsort [registry keys HKEY_CLASSES_ROOT\\TclFoobar b*]]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} "baz\u30b7bar blat"
-
-test registry-5.1 {GetType} {pcOnly english} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- list [catch {registry type HKEY_CLASSES_ROOT\\TclFoobar val1} msg] $msg
-} {1 {unable to open key: The system cannot find the file specified.}}
-test registry-5.2 {GetType} {pcOnly english} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar
- list [catch {registry type HKEY_CLASSES_ROOT\\TclFoobar val1} msg] $msg
-} {1 {unable to get type of value "val1" from key "HKEY_CLASSES_ROOT\TclFoobar": The system cannot find the file specified.}}
-test registry-5.3 {GetType} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar none
- set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} none
-test registry-5.4 {GetType} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar
- set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} sz
-test registry-5.5 {GetType} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar sz
- set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} sz
-test registry-5.6 {GetType} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar expand_sz
- set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} expand_sz
-test registry-5.7 {GetType} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 binary
- set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} binary
-test registry-5.8 {GetType} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 dword
- set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} dword
-test registry-5.9 {GetType} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 dword_big_endian
- set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} dword_big_endian
-test registry-5.10 {GetType} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 link
- set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} link
-test registry-5.11 {GetType} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar multi_sz
- set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} multi_sz
-test registry-5.12 {GetType} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 resource_list
- set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} resource_list
-test registry-5.13 {GetType: unknown types} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 24
- set result [registry type HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} 24
-test registry-5.14 {GetType: Unicode} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar va\u00c7l1 1 24
- set result [registry type HKEY_CLASSES_ROOT\\TclFoobar va\u00c7l1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} 24
-
-test registry-6.1 {GetValue} {pcOnly english} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- list [catch {registry get HKEY_CLASSES_ROOT\\TclFoobar val1} msg] $msg
-} {1 {unable to open key: The system cannot find the file specified.}}
-test registry-6.2 {GetValue} {pcOnly english} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar
- list [catch {registry get HKEY_CLASSES_ROOT\\TclFoobar val1} msg] $msg
-} {1 {unable to get value "val1" from key "HKEY_CLASSES_ROOT\TclFoobar": The system cannot find the file specified.}}
-test registry-6.3 {GetValue} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar none
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} foobar
-test registry-6.4 {GetValue} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} foobar
-test registry-6.5 {GetValue} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar sz
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} foobar
-test registry-6.6 {GetValue} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar expand_sz
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} foobar
-test registry-6.7 {GetValue} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 binary
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} 1
-test registry-6.8 {GetValue} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 0x20 dword
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} 32
-test registry-6.9 {GetValue} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 0x20 dword_big_endian
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} 32
-test registry-6.10 {GetValue} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 link
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} 1
-test registry-6.11 {GetValue} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 foobar multi_sz
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} foobar
-test registry-6.12 {GetValue} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 {foo\ bar baz} multi_sz
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {{foo bar} baz}
-test registry-6.13 {GetValue} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 {} multi_sz
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {}
-test registry-6.14 {GetValue: truncation of multivalues with null elements} \
- {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 {a {} b} multi_sz
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} a
-test registry-6.15 {GetValue} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 resource_list
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} 1
-test registry-6.16 {GetValue: unknown types} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 1 24
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} 1
-test registry-6.17 {GetValue: Unicode value names} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val\u00c71 foobar multi_sz
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val\u00c71]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} foobar
-test registry-6.18 {GetValue: values with Unicode strings} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 {foo ba\u30b7r baz} multi_sz
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} "foo ba\u30b7r baz"
-test registry-6.19 {GetValue: values with Unicode strings} {pcOnly english} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 {foo ba\u00c7r baz} multi_sz
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} "foo ba\u00c7r baz"
-test registry-6.20 {GetValue: values with Unicode strings with embedded nulls} {pcOnly} {
- registry set HKEY_CLASSES_ROOT\\TclFoobar val1 {foo ba\u0000r baz} multi_sz
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar val1]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} "foo ba r baz"
-
-test registry-7.1 {GetValueNames: bad key} {pcOnly english} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- list [catch {registry values HKEY_CLASSES_ROOT\\TclFoobar} msg] $msg
-} {1 {unable to open key: The system cannot find the file specified.}}
-test registry-7.2 {GetValueNames} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar baz foobar
- set result [registry values HKEY_CLASSES_ROOT\\TclFoobar]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} baz
-test registry-7.3 {GetValueNames} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar baz foobar1
- registry set HKEY_CLASSES_ROOT\\TclFoobar blat foobar2
- registry set HKEY_CLASSES_ROOT\\TclFoobar {} foobar3
- set result [lsort [registry values HKEY_CLASSES_ROOT\\TclFoobar]]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {{} baz blat}
-test registry-7.4 {GetValueNames: remote key} {pcOnly nonPortable english} {
- registry set \\\\$hostname\\HKEY_CLASSES_ROOT\\TclFoobar baz blat
- set result [registry values \\\\$hostname\\HKEY_CLASSES_ROOT\\TclFoobar]
- registry delete \\\\$hostname\\HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} baz
-test registry-7.5 {GetValueNames: empty key} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar
- set result [registry values HKEY_CLASSES_ROOT\\TclFoobar]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {}
-test registry-7.6 {GetValueNames: patterns} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar baz foobar1
- registry set HKEY_CLASSES_ROOT\\TclFoobar blat foobar2
- registry set HKEY_CLASSES_ROOT\\TclFoobar foo foobar3
- set result [lsort [registry values HKEY_CLASSES_ROOT\\TclFoobar b*]]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {baz blat}
-test registry-7.7 {GetValueNames: names with spaces} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar baz\ bar foobar1
- registry set HKEY_CLASSES_ROOT\\TclFoobar blat foobar2
- registry set HKEY_CLASSES_ROOT\\TclFoobar foo foobar3
- set result [lsort [registry values HKEY_CLASSES_ROOT\\TclFoobar b*]]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {{baz bar} blat}
-
-test registry-8.1 {OpenSubKey} {pcOnly nonPortable english} {
- # This test will only succeed if the current user does not have registry
- # access on the specified machine.
- list [catch {registry keys {\\mom\HKEY_LOCAL_MACHINE}} msg] $msg
-} {1 {unable to open key: Access is denied.}}
-test registry-8.2 {OpenSubKey} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar
- set result [registry keys HKEY_CLASSES_ROOT TclFoobar]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} TclFoobar
-test registry-8.3 {OpenSubKey} {pcOnly english} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- list [catch {registry keys HKEY_CLASSES_ROOT\\TclFoobar} msg] $msg
-} {1 {unable to open key: The system cannot find the file specified.}}
-
-test registry-9.1 {ParseKeyName: bad keys} {pcOnly} {
- list [catch {registry values \\} msg] $msg
-} "1 {bad key \"\\\": must start with a valid root}"
-test registry-9.2 {ParseKeyName: bad keys} {pcOnly} {
- list [catch {registry values \\foobar} msg] $msg
-} {1 {bad key "\foobar": must start with a valid root}}
-test registry-9.3 {ParseKeyName: bad keys} {pcOnly} {
- list [catch {registry values \\\\} msg] $msg
-} {1 {ambiguous root name "": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}}
-test registry-9.4 {ParseKeyName: bad keys} {pcOnly} {
- list [catch {registry values \\\\\\} msg] $msg
-} {1 {ambiguous root name "": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}}
-test registry-9.5 {ParseKeyName: bad keys} {pcOnly english} {
- list [catch {registry values \\\\\\HKEY_CLASSES_ROOT} msg] $msg
-} {1 {unable to open key: The network address is invalid.}}
-test registry-9.6 {ParseKeyName: bad keys} {pcOnly} {
- list [catch {registry values \\\\gaspode} msg] $msg
-} {1 {ambiguous root name "": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}}
-test registry-9.7 {ParseKeyName: bad keys} {pcOnly} {
- list [catch {registry values foobar} msg] $msg
-} {1 {bad root name "foobar": must be HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, or HKEY_DYN_DATA}}
-test registry-9.8 {ParseKeyName: null keys} {pcOnly} {
- list [catch {registry delete HKEY_CLASSES_ROOT\\} msg] $msg
-} {1 {bad key: cannot delete root keys}}
-test registry-9.9 {ParseKeyName: null keys} {pcOnly english} {
- list [catch {registry keys HKEY_CLASSES_ROOT\\TclFoobar\\baz} msg] $msg
-} {1 {unable to open key: The system cannot find the file specified.}}
-
-test registry-10.1 {RecursiveDeleteKey} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\test1
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\test2\\test3
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result [registry keys HKEY_CLASSES_ROOT TclFoobar]
- set result
-} {}
-test registry-10.2 {RecursiveDeleteKey} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\test1
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\test2\\test3
- set result [registry delete HKEY_CLASSES_ROOT\\TclFoobar\\test2\\test4]
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- set result
-} {}
-
-test registry-11.1 {SetValue: recursive creation} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz blat foobar
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar\\baz blat]
-} foobar
-test registry-11.2 {SetValue: modification} {pcOnly} {
- registry delete HKEY_CLASSES_ROOT\\TclFoobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz blat foobar
- registry set HKEY_CLASSES_ROOT\\TclFoobar\\baz blat frob
- set result [registry get HKEY_CLASSES_ROOT\\TclFoobar\\baz blat]
-} frob
-test registry-11.3 {SetValue: failure} {pcOnly nonPortable english} {
- # This test will only succeed if the current user does not have registry
- # access on the specified machine.
- list [catch {registry set {\\mom\HKEY_CLASSES_ROOT\TclFoobar} bar foobar} msg] $msg
-} {1 {unable to open key: Access is denied.}}
-
-
-# cleanup
-unset hostname
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/remote.tcl b/tests/remote.tcl
deleted file mode 100644
index 005f2df..0000000
--- a/tests/remote.tcl
+++ /dev/null
@@ -1,172 +0,0 @@
-# This file contains Tcl code to implement a remote server that can be
-# used during testing of Tcl socket code. This server is used by some
-# of the tests in socket.test.
-#
-# Source this file in the remote server you are using to test Tcl against.
-#
-# Copyright (c) 1995-1996 Sun Microsystems, Inc.
-#
-# See the file "license.terms" for information on usage and redistribution
-# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-#
-# RCS: @(#) $Id: remote.tcl,v 1.3 1999/04/16 00:47:33 stanton Exp $
-
-# Initialize message delimitor
-
-# Initialize command array
-catch {unset command}
-set command(0) ""
-set callerSocket ""
-
-# Detect whether we should print out connection messages etc.
-if {![info exists VERBOSE]} {
- set VERBOSE 0
-}
-
-proc __doCommands__ {l s} {
- global callerSocket VERBOSE
-
- if {$VERBOSE} {
- puts "--- Server executing the following for socket $s:"
- puts $l
- puts "---"
- }
- set callerSocket $s
- if {[catch {uplevel #0 $l} msg]} {
- list error $msg
- } else {
- list success $msg
- }
-}
-
-proc __readAndExecute__ {s} {
- global command VERBOSE
-
- set l [gets $s]
- if {[string compare $l "--Marker--Marker--Marker--"] == 0} {
- if {[info exists command($s)]} {
- puts $s [list error incomplete_command]
- }
- puts $s "--Marker--Marker--Marker--"
- return
- }
- if {[string compare $l ""] == 0} {
- if {[eof $s]} {
- if {$VERBOSE} {
- puts "Server closing $s, eof from client"
- }
- close $s
- }
- return
- }
- append command($s) $l "\n"
- if {[info complete $command($s)]} {
- set cmds $command($s)
- unset command($s)
- puts $s [__doCommands__ $cmds $s]
- }
- if {[eof $s]} {
- if {$VERBOSE} {
- puts "Server closing $s, eof from client"
- }
- close $s
- }
-}
-
-proc __accept__ {s a p} {
- global VERBOSE
-
- if {$VERBOSE} {
- puts "Server accepts new connection from $a:$p on $s"
- }
- fileevent $s readable [list __readAndExecute__ $s]
- fconfigure $s -buffering line -translation crlf
-}
-
-set serverIsSilent 0
-for {set i 0} {$i < $argc} {incr i} {
- if {[string compare -serverIsSilent [lindex $argv $i]] == 0} {
- set serverIsSilent 1
- break
- }
-}
-if {![info exists serverPort]} {
- if {[info exists env(serverPort)]} {
- set serverPort $env(serverPort)
- }
-}
-if {![info exists serverPort]} {
- for {set i 0} {$i < $argc} {incr i} {
- if {[string compare -port [lindex $argv $i]] == 0} {
- if {$i < [expr $argc - 1]} {
- set serverPort [lindex $argv [expr $i + 1]]
- }
- break
- }
- }
-}
-if {![info exists serverPort]} {
- set serverPort 2048
-}
-
-if {![info exists serverAddress]} {
- if {[info exists env(serverAddress)]} {
- set serverAddress $env(serverAddress)
- }
-}
-if {![info exists serverAddress]} {
- for {set i 0} {$i < $argc} {incr i} {
- if {[string compare -address [lindex $argv $i]] == 0} {
- if {$i < [expr $argc - 1]} {
- set serverAddress [lindex $argv [expr $i + 1]]
- }
- break
- }
- }
-}
-if {![info exists serverAddress]} {
- set serverAddress 0.0.0.0
-}
-
-if {$serverIsSilent == 0} {
- set l "Remote server listening on port $serverPort, IP $serverAddress."
- puts ""
- puts $l
- for {set c [string length $l]} {$c > 0} {incr c -1} {puts -nonewline "-"}
- puts ""
- puts ""
- puts "You have set the Tcl variables serverAddress to $serverAddress and"
- puts "serverPort to $serverPort. You can set these with the -address and"
- puts "-port command line options, or as environment variables in your"
- puts "shell."
- puts ""
- puts "NOTE: The tests will not work properly if serverAddress is set to"
- puts "\"localhost\" or 127.0.0.1."
- puts ""
- puts "When you invoke tcltest to run the tests, set the variables"
- puts "remoteServerPort to $serverPort and remoteServerIP to"
- puts "[info hostname]. You can set these as environment variables"
- puts "from the shell. The tests will not work properly if you set"
- puts "remoteServerIP to \"localhost\" or 127.0.0.1."
- puts ""
- puts -nonewline "Type Ctrl-C to terminate--> "
- flush stdout
-}
-
-if {[catch {set serverSocket \
- [socket -myaddr $serverAddress -server __accept__ $serverPort]} msg]} {
- puts "Server on $serverAddress:$serverPort cannot start: $msg"
-} else {
- vwait __server_wait_variable__
-}
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/rename.test b/tests/rename.test
deleted file mode 100644
index 14cdf05..0000000
--- a/tests/rename.test
+++ /dev/null
@@ -1,186 +0,0 @@
-# Commands covered: rename
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: rename.test,v 1.3 1999/04/16 00:47:33 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Must eliminate the "unknown" command while the test is running,
-# especially if the test is being run in a program with its
-# own special-purpose unknown command.
-
-catch {rename unknown unknown.old}
-
-catch {rename r2 {}}
-proc r1 {} {return "procedure r1"}
-rename r1 r2
-test rename-1.1 {simple renaming} {
- r2
-} {procedure r1}
-test rename-1.2 {simple renaming} {
- list [catch r1 msg] $msg
-} {1 {invalid command name "r1"}}
-rename r2 {}
-test rename-1.3 {simple renaming} {
- list [catch r2 msg] $msg
-} {1 {invalid command name "r2"}}
-
-# The test below is tricky because it renames a built-in command.
-# It's possible that the test procedure uses this command, so must
-# restore the command before calling test again.
-
-rename list l.new
-set a [catch list msg1]
-set b [l.new a b c]
-rename l.new list
-set c [catch l.new msg2]
-set d [list 111 222]
-test rename-2.1 {renaming built-in command} {
- list $a $msg1 $b $c $msg2 $d
-} {1 {invalid command name "list"} {a b c} 1 {invalid command name "l.new"} {111 222}}
-
-test rename-3.1 {error conditions} {
- list [catch {rename r1} msg] $msg $errorCode
-} {1 {wrong # args: should be "rename oldName newName"} NONE}
-test rename-3.2 {error conditions} {
- list [catch {rename r1 r2 r3} msg] $msg $errorCode
-} {1 {wrong # args: should be "rename oldName newName"} NONE}
-test rename-3.3 {error conditions} {
- proc r1 {} {}
- proc r2 {} {}
- list [catch {rename r1 r2} msg] $msg
-} {1 {can't rename to "r2": command already exists}}
-test rename-3.4 {error conditions} {
- catch {rename r1 {}}
- catch {rename r2 {}}
- list [catch {rename r1 r2} msg] $msg
-} {1 {can't rename "r1": command doesn't exist}}
-test rename-3.5 {error conditions} {
- catch {rename _non_existent_command {}}
- list [catch {rename _non_existent_command {}} msg] $msg
-} {1 {can't delete "_non_existent_command": command doesn't exist}}
-
-catch {rename unknown {}}
-catch {rename unknown.old unknown}
-
-if {[info command testdel] == "testdel"} {
- test rename-4.1 {reentrancy issues with command deletion and renaming} {
- set x {}
- testdel {} foo {lappend x deleted; rename bar {}; lappend x [info command bar]}
- rename foo bar
- lappend x |
- rename bar {}
- set x
- } {| deleted {}}
- test rename-4.2 {reentrancy issues with command deletion and renaming} {
- set x {}
- testdel {} foo {lappend x deleted; rename foo bar}
- rename foo {}
- set x
- } {deleted}
- test rename-4.3 {reentrancy issues with command deletion and renaming} {
- set x {}
- testdel {} foo {lappend x deleted; testdel {} foo {lappend x deleted2}}
- rename foo {}
- lappend x |
- rename foo {}
- set x
- } {deleted | deleted2}
- test rename-4.4 {reentrancy issues with command deletion and renaming} {
- set x {}
- testdel {} foo {lappend x deleted; rename foo bar}
- rename foo {}
- lappend x | [info command bar]
- } {deleted | {}}
- test rename-4.5 {reentrancy issues with command deletion and renaming} {
- set env(value) before
- interp create foo
- testdel foo cmd {set env(value) deleted}
- interp delete foo
- set env(value)
- } {deleted}
- test rename-4.6 {reentrancy issues with command deletion and renaming} {
- proc kill args {
- interp delete foo
- }
- set env(value) before
- interp create foo
- foo alias kill kill
- testdel foo cmd {set env(value) deleted; kill}
- list [catch {foo eval {rename cmd {}}} msg] $msg $env(value)
- } {0 {} deleted}
- test rename-4.7 {reentrancy issues with command deletion and renaming} {
- proc kill args {
- interp delete foo
- }
- set env(value) before
- interp create foo
- foo alias kill kill
- testdel foo cmd {set env(value) deleted; kill}
- list [catch {interp delete foo} msg] $msg $env(value)
- } {0 {} deleted}
-}
-
-# Save the unknown procedure which is modified by the following test.
-
-catch {rename unknown unknown.old}
-
-test rename-5.1 {repeated rename deletion and redefinition of same command} {
- set SAVED_UNKNOWN "proc unknown "
- append SAVED_UNKNOWN "\{[info args unknown.old]\} "
- append SAVED_UNKNOWN "\{[info body unknown.old]\}"
-
- for {set i 0} {$i < 10} {incr i} {
- eval $SAVED_UNKNOWN
- tcl_wordBreakBefore "" 0
- rename tcl_wordBreakBefore {}
- rename unknown {}
- }
-} {}
-
-catch {rename unknown {}}
-catch {rename unknown.old unknown}
-
-
-test rename-6.1 {old code invalidated (epoch incremented) when cmd with compile proc is renamed } {
- proc x {} {
- set a 123
- set b [incr a]
- }
- x
- rename incr incr.old
- proc incr {} {puts "new incr called!"}
- catch {x} msg
- set msg
-} {called "incr" with too many arguments}
-
-# cleanup
-catch {rename incr {}}
-catch {rename incr.old incr}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/resource.test b/tests/resource.test
deleted file mode 100644
index b5f341a..0000000
--- a/tests/resource.test
+++ /dev/null
@@ -1,364 +0,0 @@
-# Commands covered: resource
-#
-# 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) 1996-1997 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: resource.test,v 1.4 1999/04/16 00:47:33 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test resource-1.1 {resource tests} {macOnly} {
- list [catch {resource} msg] $msg
-} {1 {wrong # args: should be "resource option ?arg ...?"}}
-test resource-1.2 {resource tests} {macOnly} {
- list [catch {resource _bad_} msg] $msg
-} {1 {bad option "_bad_": must be close, delete, files, list, open, read, types, or write}}
-
-# resource open & close tests
-test resource-2.1 {resource open & close tests} {macOnly} {
- list [catch {resource open} msg] $msg
-} {1 {wrong # args: should be "resource open fileName ?permissions?"}}
-test resource-2.2 {resource open & close tests} {macOnly} {
- list [catch {resource open resource.test r extraArg} msg] $msg
-} {1 {wrong # args: should be "resource open fileName ?permissions?"}}
-test resource-2.3 {resource open & close tests} {macOnly} {
- list [catch {resource open resource.test bad_perms} msg] $msg
-} {1 {illegal access mode "bad_perms"}}
-test resource-2.4 {resource open & close tests} {macOnly} {
- list [catch {resource open _bad_file_} msg] $msg
-} {1 {file does not exist}}
-test resource-2.5 {resource open & close tests} {macOnly} {
- testWriteTextResource -rsrc fileRsrcName -file rsrc.file {error "don't source me"}
- set id [resource open rsrc.file]
- resource close $id
- file delete rsrc.file
-} {}
-test resource-2.6 {resource open & close tests} {macOnly} {
- catch {file delete rsrc.file}
- testWriteTextResource -rsrc fileRsrcName -file rsrc.file {A test string}
- set id [resource open rsrc.file]
- set result [string compare [resource open rsrc.file] $id]
- lappend result [resource read TEXT fileRsrcName $id]
- resource close $id
- file delete rsrc.file
- set result
-} {0 {A test string}}
-test resource-2.7 {resource open & close tests} {macOnly} {
- catch {file delete rsrc.file}
- testWriteTextResource -rsrc fileRsrcName -file rsrc.file {error "don't source me"}
- set id [resource open rsrc.file r]
- set result [catch {resource open rsrc.file w} mssg]
- resource close $id
- file delete rsrc.file
- lappend result $mssg
- set result
-} {1 {Resource already open with different permissions.}}
-test resource-2.8 {resource open & close tests} {macOnly} {
- list [catch {resource close} msg] $msg
-} {1 {wrong # args: should be "resource close resourceRef"}}
-test resource-2.9 {resource open & close tests} {macOnly} {
- list [catch {resource close foo bar} msg] $msg
-} {1 {wrong # args: should be "resource close resourceRef"}}
-test resource-2.10 {resource open & close tests} {macOnly} {
- list [catch {resource close _bad_resource_} msg] $msg
-} {1 {invalid resource file reference "_bad_resource_"}}
-test resource-2.11 {resource open & close tests} {macOnly} {
- set result [catch {resource close System} mssg]
- lappend result $mssg
-} {1 {can't close "System" resource file}}
-test resource-2.12 {resource open & close tests} {macOnly} {
- set result [catch {resource close application} mssg]
- lappend result $mssg
-} {1 {can't close "application" resource file}}
-
-# Tests for listing resources
-test resource-3.1 {resource list tests} {macOnly} {
- list [catch {resource list} msg] $msg
-} {1 {wrong # args: should be "resource list resourceType ?resourceRef?"}}
-test resource-3.2 {resource list tests} {macOnly} {
- list [catch {resource list _bad_type_} msg] $msg
-} {1 {expected Macintosh OS type but got "_bad_type_"}}
-test resource-3.3 {resource list tests} {macOnly} {
- list [catch {resource list TEXT _bad_ref_} msg] $msg
-} {1 {invalid resource file reference "_bad_ref_"}}
-test resource-3.4 {resource list tests} {macOnly} {
- list [catch {resource list TEXT _bad_ref_ extraArg} msg] $msg
-} {1 {wrong # args: should be "resource list resourceType ?resourceRef?"}}
-test resource-3.5 {resource list tests} {macOnly} {
- catch {file delete rsrc.file}
- testWriteTextResource -rsrc fileRsrcName -file rsrc.file {error "don't source me"}
- set id [resource open rsrc.file]
- catch "resource list TEXT $id" result
- resource close $id
- set result
-} {fileRsrcName}
-test resource-3.6 {resource list tests} {macOnly} {
- # There should not be any resource of this type
- resource list XXXX
-} {}
-test resource-3.7 {resource list tests} {macOnly} {
- set resourceList [resource list STR#]
- if {[lsearch $resourceList {Tcl Environment Variables}] == -1} {
- set result {couldn't find resource that should exist}
- } else {
- set result ok
- }
-} {ok}
-
-# Tests for reading resources
-test resource-4.1 {resource read tests} {macOnly} {
- list [catch {resource read} msg] $msg
-} {1 {wrong # args: should be "resource read resourceType resourceId ?resourceRef?"}}
-test resource-4.2 {resource read tests} {macOnly} {
- list [catch {resource read TEXT} msg] $msg
-} {1 {wrong # args: should be "resource read resourceType resourceId ?resourceRef?"}}
-test resource-4.3 {resource read tests} {macOnly} {
- list [catch {resource read STR# {_non_existant_resource_}} msg] $msg
-} {1 {could not load resource}}
-test resource-4.4 {resource read tests} {macOnly} {
- # The following resource should exist and load OK without error
- catch {resource read STR# {Tcl Environment Variables}}
-} {0}
-
-# Tests for getting resource types
-test resource-5.1 {resource types tests} {macOnly} {
- list [catch {resource types _bad_ref_} msg] $msg
-} {1 {invalid resource file reference "_bad_ref_"}}
-test resource-5.2 {resource types tests} {macOnly} {
- list [catch {resource types _bad_ref_ extraArg} msg] $msg
-} {1 {wrong # args: should be "resource types ?resourceRef?"}}
-test resource-5.3 {resource types tests} {macOnly} {
- # This should never cause an error
- catch {resource types}
-} {0}
-test resource-5.4 {resource types tests} {macOnly} {
- testWriteTextResource -rsrc fileRsrcName -file rsrc.file {error "don't source me"}
- set id [resource open rsrc.file]
- set result [resource types $id]
- resource close $id
- set result
-} {TEXT}
-
-# resource write tests
-test resource-6.1 {resource write tests} {macOnly} {
- list [catch {resource write} msg] $msg
-} {1 {wrong # args: should be "resource write ?-id resourceId? ?-name resourceName? ?-file resourceRef? ?-force? resourceType data"}}
-test resource-6.2 {resource write tests} {macOnly} {
- list [catch {resource write _bad_type_ data} msg] $msg
-} {1 {expected Macintosh OS type but got "_bad_type_"}}
-test resource-6.3 {resource write tests} {macOnly} {
- catch {file delete rsrc2.file}
- set id [resource open rsrc2.file w]
- resource close $id
- set id [resource open rsrc2.file r]
- set result [catch {resource write -file $id -name Hello TEXT foo} errMsg]
- lappend result [string compare $errMsg "cannot write to resource file \"$id\", it was opened read only"]
- lappend result [lsearch [resource list TEXT $id] Hello]
- resource close $id
- file delete rsrc2.file
- set result
-} {1 0 -1}
-test resource-6.4 {resource write tests} {macOnly} {
- catch {file delete rsrc2.file}
- set id [resource open rsrc2.file w]
- resource write -file $id -name Hello TEXT {set x "our test data"}
- source -rsrc Hello rsrc2.file
- resource close $id
- file delete rsrc2.file
- set x
-} {our test data}
-test resource-6.5 {resource write tests} {macOnly} {
- catch {file delete rsrc2.file}
- set id [resource open rsrc2.file w]
- resource write -file $id -id 256 TEXT {HAHAHAHAHAHAHA}
- set result [catch {resource write -file $id -id 256 TEXT {HOHOHOHOHOHO}} mssg]
- resource close $id
- file delete rsrc2.file
- lappend result $mssg
-} {1 {the resource 256 already exists, use "-force" to overwrite it.}}
-test resource-6.6 {resource write tests} {macOnly} {
- catch {file delete rsrc2.file}
- testWriteTextResource -rsrc fileRsrcName -rsrcid 256 -file rsrc2.file -protected {error "don't tread on me"}
- set id [resource open rsrc2.file w]
- set result [catch {resource write -id 256 -force -file $id TEXT {NAHNAHNANAHNAH}} mssg]
- resource close $id
- file delete rsrc2.file
- lappend result $mssg
-} {1 {could not write resource id 256 of type TEXT, it was protected.}}
-test resource-6.7 {resource write tests} {macOnly} {
- catch {file delete rsrc2.file}
- set id [resource open rsrc2.file w]
- resource write -file $id -id 256 -name FOO TEXT {set x [list "our first test data"]}
- resource write -file $id -id 256 -name BAR -force TEXT {set x [list "our second test data"]}
- source -rsrcid 256 rsrc2.file
- lappend x [resource list TEXT $id]
- resource close $id
- file delete rsrc2.file
- set x
-} {{our second test data} BAR}
-
-#Tests for listing open resource files
-test resource-7.1 {resource file tests} {macOnly} {
- catch {resource files foo bar} mssg
- set mssg
-} {wrong # args: should be "resource files ?resourceId?"}
-test resource-7.2 {resource file tests} {macOnly} {
- catch {file delete rsrc2.file}
- set rsrcFiles [resource files]
- set id [resource open rsrc2.file w]
- set result [string compare $rsrcFiles [lrange [resource files] 1 end]]
- lappend result [string compare $id [lrange [resource files] 0 0]]
- resource close $id
- file delete rsrc2.file
- set result
-} {0 0}
-test resource-7.3 {resource file tests} {macOnly} {
- set result 0
- foreach file [resource files] {
- if {[catch {resource types $file}] != 0} {
- set result 1
- }
- }
- set result
-} {0}
-test resource-7.4 {resource file tests} {macOnly} {
- catch {resource files __NO_SUCH_RESOURCE__} mssg
- set mssg
-} {invalid resource file reference "__NO_SUCH_RESOURCE__"}
-test resource-7.5 {resource file tests} {macOnly} {
- set sys [resource files System]
- string compare $sys [file join $env(SYS_FOLDER) System]
-} {0}
-test resource-7.6 {resource file tests} {macOnly} {
- set app [resource files application]
- string compare $app [info nameofexecutable]
-} {0}
-
-#Tests for the resource delete command
-test resource-8.1 {resource delete tests} {macOnly} {
- list [catch {resource delete} msg] $msg
-} {1 {wrong # args: should be "resource delete ?-id resourceId? ?-name resourceName? ?-file resourceRef? resourceType"}}
-test resource-8.2 {resource delete tests} {macOnly} {
- list [catch {resource delete TEXT} msg] $msg
-} {1 {you must specify either "-id" or "-name" or both to "resource delete"}}
-test resource-8.3 {resource delete tests} {macOnly} {
- set result [catch {resource delete -file ffffff -id 128 TEXT} mssg]
- lappend result $mssg
-} {1 {invalid resource file reference "ffffff"}}
-test resource-8.4 {resource delete tests} {macOnly} {
- catch {file delete rsrc2.file}
- testWriteTextResource -rsrc fileRsrcName -rsrcid 128 -file rsrc2.file {Some stuff}
- set id [resource open rsrc2.file r]
- set result [catch {resource delete -id 128 -file $id TEXT} mssg]
- resource close $id
- file delete rsrc2.file
- lappend result [string compare $mssg "cannot delete from resource file \"$id\", it was opened read only"]
-} {1 0}
-test resource-8.5 {resource delete tests} {macOnly} {
- catch {file delete rsrc2.file}
- testWriteTextResource -rsrc fileRsrcName -rsrcid 128 -file rsrc2.file {Some stuff}
- set id [resource open rsrc2.file w]
- set result [catch {resource delete -id 128 -file $id _bad_type_} mssg]
- resource close $id
- file delete rsrc2.file
- lappend result $mssg
-} {1 {expected Macintosh OS type but got "_bad_type_"}}
-test resource-8.5 {resource delete tests} {macOnly} {
- catch {file delete rsrc2.file}
- set id [resource open rsrc2.file w]
- set result [catch {resource delete -id 128 -file $id TEXT} mssg]
- resource close $id
- file delete rsrc2.file
- lappend result $mssg
-} {1 {resource not found}}
-test resource-8.6 {resource delete tests} {macOnly} {
- catch {file delete rsrc2.file}
- set id [resource open rsrc2.file w]
- set result [catch {resource delete -name foo -file $id TEXT} mssg]
- resource close $id
- file delete rsrc2.file
- lappend result $mssg
-} {1 {resource not found}}
-test resource-8.7 {resource delete tests} {macOnly} {
- catch {file delete rsrc2.file}
- set id [resource open rsrc2.file w]
- resource write -file $id -name foo -id 128 TEXT {some stuff}
- resource write -file $id -name bar -id 129 TEXT {some stuff}
- set result [catch {resource delete -name foo -id 129 -file $id TEXT} mssg]
- resource close $id
- file delete rsrc2.file
- lappend result $mssg
-} {1 {"-id" and "-name" values do not point to the same resource}}
-test resource-8.8 {resource delete tests} {macOnly} {
- catch {file delete rsrc2.file}
- testWriteTextResource -rsrc fileRsrcName -rsrcid 256 -file rsrc2.file -protected {error "don't tread on me"}
- set id [resource open rsrc2.file w]
- set result [catch {resource delete -id 256 -file $id TEXT } mssg]
- resource close $id
- file delete rsrc2.file
- lappend result $mssg
-} {1 {resource cannot be deleted: it is protected.}}
-test resource-8.9 {resource delete tests} {macOnly} {
- catch {file delete rsrc2.file}
- testWriteTextResource -rsrc fileRsrcName -rsrcid 128 -file rsrc2.file {Some stuff}
- set id [resource open rsrc2.file w]
- set result [resource list TEXT $id]
- resource delete -id 128 -file $id TEXT
- lappend result [resource list TEXT $id]
- resource close $id
- file delete rsrc2.file
- set result
-} {fileRsrcName {}}
-
-# Tests for the Mac version of the source command
-catch {file delete rsrc.file}
-test resource-9.1 {source command} {macOnly} {
- testWriteTextResource -rsrc fileRsrcName -rsrcid 128 \
- -file rsrc.file {set rsrc_foo 1}
- catch {unset rsrc_foo}
- source -rsrc fileRsrcName rsrc.file
- list [catch {set rsrc_foo} msg] $msg
-} {0 1}
-test resource-9.2 {source command} {macOnly} {
- catch {unset rsrc_foo}
- list [catch {source -rsrc no_resource rsrc.file} msg] $msg
-} {1 {The resource "no_resource" could not be loaded from rsrc.file.}}
-test resource-9.3 {source command} {macOnly} {
- catch {unset rsrc_foo}
- source -rsrcid 128 rsrc.file
- list [catch {set rsrc_foo} msg] $msg
-} {0 1}
-test resource-9.4 {source command} {macOnly} {
- catch {unset rsrc_foo}
- list [catch {source -rsrcid bad_int rsrc.file} msg] $msg
-} {1 {expected integer but got "bad_int"}}
-test resource-9.5 {source command} {macOnly} {
- catch {unset rsrc_foo}
- list [catch {source -rsrcid 100 rsrc.file} msg] $msg
-} {1 {The resource "ID=100" could not be loaded from rsrc.file.}}
-
-# cleanup
-catch {file delete rsrc.file}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/result.test b/tests/result.test
deleted file mode 100644
index 3f77fdc..0000000
--- a/tests/result.test
+++ /dev/null
@@ -1,102 +0,0 @@
-# This file tests the routines in tclResult.c.
-#
-# 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) 1997 by 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.
-#
-# SCCS: @(#) result.test 1.4 97/12/08 15:07:49
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Some tests require the testsaveresult command
-
-set ::tcltest::testConfig(testsaveresult) \
- [expr {[info commands testsaveresult] != {}}]
-
-test result-1.1 {Tcl_SaveInterpResult} {testsaveresult} {
- testsaveresult small {set x 42} 0
-} {small result}
-test result-1.2 {Tcl_SaveInterpResult} {testsaveresult} {
- testsaveresult append {set x 42} 0
-} {append result}
-test result-1.3 {Tcl_SaveInterpResult} {testsaveresult} {
- testsaveresult dynamic {set x 42} 0
-} {dynamic result notCalled present}
-test result-1.4 {Tcl_SaveInterpResult} {testsaveresult} {
- testsaveresult object {set x 42} 0
-} {object result same}
-test result-1.5 {Tcl_SaveInterpResult} {testsaveresult} {
- testsaveresult small {set x 42} 1
-} {42}
-test result-1.6 {Tcl_SaveInterpResult} {testsaveresult} {
- testsaveresult append {set x 42} 1
-} {42}
-test result-1.7 {Tcl_SaveInterpResult} {testsaveresult} {
- testsaveresult dynamic {set x 42} 1
-} {42 called missing}
-test result-1.8 {Tcl_SaveInterpResult} {testsaveresult} {
- testsaveresult object {set x 42} 1
-} {42 different}
-
-
-# Tcl_RestoreInterpResult is mostly tested by the previous tests except
-# for the following case
-
-test result-2.1 {Tcl_RestoreInterpResult} {testsaveresult} {
- testsaveresult append {cd _foobar} 0
-} {append result}
-
-# Tcl_DiscardInterpResult is mostly tested by the previous tests except
-# for the following cases
-
-test result-3.1 {Tcl_DiscardInterpResult} {testsaveresult} {
- list [catch {testsaveresult append {cd _foobar} 1} msg] $msg
-} {1 {couldn't change working directory to "_foobar": no such file or directory}}
-test result-3.2 {Tcl_DiscardInterpResult} {testsaveresult} {
- testsaveresult free {set x 42} 1
-} {42}
-
-test result-4.1 {Tcl_SetObjErrorCode - one arg} {testsaveresult} {
- catch {testsetobjerrorcode 1}
- list [set errorCode]
-} {1}
-test result-4.2 {Tcl_SetObjErrorCode - two args} {testsaveresult} {
- catch {testsetobjerrorcode 1 2}
- list [set errorCode]
-} {{1 2}}
-test result-4.3 {Tcl_SetObjErrorCode - three args} {testsaveresult} {
- catch {testsetobjerrorcode 1 2 3}
- list [set errorCode]
-} {{1 2 3}}
-test result-4.4 {Tcl_SetObjErrorCode - four args} {testsaveresult} {
- catch {testsetobjerrorcode 1 2 3 4}
- list [set errorCode]
-} {{1 2 3 4}}
-test result-4.5 {Tcl_SetObjErrorCode - five args} {testsaveresult} {
- catch {testsetobjerrorcode 1 2 3 4 5}
- list [set errorCode]
-} {{1 2 3 4 5}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/safe.test b/tests/safe.test
deleted file mode 100644
index 5149c59..0000000
--- a/tests/safe.test
+++ /dev/null
@@ -1,527 +0,0 @@
-# safe.test --
-#
-# This file contains a collection of tests for safe Tcl, packages loading,
-# and using safe interpreters. Sourcing this file into tcl runs the tests
-# and 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: safe.test,v 1.5 1999/04/16 00:47:33 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-foreach i [interp slaves] {
- interp delete $i
-}
-
-# Force actual loading of the safe package
-# because we use un exported (and thus un-autoindexed) APIs
-# in this test result arguments:
-catch {safe::interpConfigure}
-
-proc equiv {x} {return $x}
-
-test safe-1.1 {safe::interpConfigure syntax} {
- list [catch {safe::interpConfigure} msg] $msg;
-} {1 {no value given for parameter "slave" (use -help for full usage) :
- slave name () name of the slave}}
-
-test safe-1.2 {safe::interpCreate syntax} {
- list [catch {safe::interpCreate -help} msg] $msg;
-} {1 {Usage information:
- Var/FlagName Type Value Help
- ------------ ---- ----- ----
- ( -help gives this help )
- ?slave? name () name of the slave (optional)
- -accessPath list () access path for the slave
- -noStatics boolflag (false) prevent loading of statically linked pkgs
- -statics boolean (true) loading of statically linked pkgs
- -nestedLoadOk boolflag (false) allow nested loading
- -nested boolean (false) nested loading
- -deleteHook script () delete hook}}
-
-test safe-1.3 {safe::interpInit syntax} {
- list [catch {safe::interpInit -noStatics} msg] $msg;
-} {1 {bad value "-noStatics" for parameter
- slave name () name of the slave}}
-
-
-test safe-2.1 {creating interpreters, should have no aliases} {
- interp aliases
-} ""
-test safe-2.2 {creating interpreters, should have no aliases} {
- catch {safe::interpDelete a}
- interp create a
- set l [a aliases]
- safe::interpDelete a
- set l
-} ""
-test safe-2.3 {creating safe interpreters, should have no aliases} {
- catch {safe::interpDelete a}
- interp create a -safe
- set l [a aliases]
- interp delete a
- set l
-} ""
-
-test safe-3.1 {calling safe::interpInit is safe} {
- catch {safe::interpDelete a}
- interp create a -safe
- safe::interpInit a
- catch {interp eval a exec ls} msg
- safe::interpDelete a
- set msg
-} {invalid command name "exec"}
-test safe-3.2 {calling safe::interpCreate on trusted interp} {
- catch {safe::interpDelete a}
- safe::interpCreate a
- set l [lsort [a aliases]]
- safe::interpDelete a
- set l
-} {encoding exit file load source}
-test safe-3.3 {calling safe::interpCreate on trusted interp} {
- catch {safe::interpDelete a}
- safe::interpCreate a
- set x [interp eval a {source [file join $tcl_library init.tcl]}]
- safe::interpDelete a
- set x
-} ""
-test safe-3.4 {calling safe::interpCreate on trusted interp} {
- catch {safe::interpDelete a}
- safe::interpCreate a
- catch {set x \
- [interp eval a {source [file join $tcl_library init.tcl]}]} msg
- safe::interpDelete a
- list $x $msg
-} {{} {}}
-
-test safe-4.1 {safe::interpDelete} {
- catch {safe::interpDelete a}
- interp create a
- safe::interpDelete a
-} ""
-test safe-4.2 {safe::interpDelete, indirectly} {
- catch {safe::interpDelete a}
- interp create a
- a alias exit safe::interpDelete a
- a eval exit
-} ""
-test safe-4.3 {safe::interpDelete, state array (not a public api)} {
- catch {safe::interpDelete a}
- namespace eval safe {set [InterpStateName a](foo) 33}
- # not an error anymore to call it if interp is already
- # deleted, to make trhings smooth if it's called twice...
- catch {safe::interpDelete a} m1
- catch {namespace eval safe {set [InterpStateName a](foo)}} m2
- list $m1 $m2
-} "{}\
- {can't read \"[safe::InterpStateName a]\": no such variable}"
-
-
-test safe-4.4 {safe::interpDelete, state array, indirectly (not a public api)} {
- catch {safe::interpDelete a}
- safe::interpCreate a
- namespace eval safe {set [InterpStateName a](foo) 33}
- a eval exit
- catch {namespace eval safe {set [InterpStateName a](foo)}} msg
-} 1
-
-test safe-4.5 {safe::interpDelete} {
- catch {safe::interpDelete a}
- safe::interpCreate a
- catch {safe::interpCreate a} msg
- set msg
-} {interpreter named "a" already exists, cannot create}
-test safe-4.6 {safe::interpDelete, indirectly} {
- catch {safe::interpDelete a}
- safe::interpCreate a
- a eval exit
-} ""
-
-# The following test checks whether the definition of tcl_endOfWord can be
-# obtained from auto_loading.
-
-test safe-5.1 {test auto-loading in safe interpreters} {
- catch {safe::interpDelete a}
- safe::interpCreate a
- set r [catch {interp eval a {tcl_endOfWord "" 0}} msg]
- safe::interpDelete a
- list $r $msg
-} {0 -1}
-
-# test safe interps 'information leak'
-proc SI {} {
- global I
- set I [interp create -safe];
-}
-proc DI {} {
- global I;
- interp delete $I;
-}
-test safe-6.1 {test safe interpreters knowledge of the world} {
- SI; set r [lsort [$I eval {info globals}]]; DI; set r
-} {tcl_interactive tcl_patchLevel tcl_platform tcl_version}
-test safe-6.2 {test safe interpreters knowledge of the world} {
- SI; set r [$I eval {info script}]; DI; set r
-} {}
-test safe-6.3 {test safe interpreters knowledge of the world} {
- SI
- set r [lsort [$I eval {array names tcl_platform}]]
- DI
- # If running a windows-debug shell, remove the "debug" element from r.
- if {$tcl_platform(platform) == "windows" && \
- [lsearch $r "debug"] != -1} {
- set r [lreplace $r 1 1]
- }
- set r
-} {byteOrder platform}
-
-# more test should be added to check that hostname, nameofexecutable,
-# aren't leaking infos, but they still do...
-
-# high level general test
-test safe-7.1 {tests that everything works at high level} {
- set i [safe::interpCreate];
- # no error shall occur:
- # (because the default access_path shall include 1st level sub dirs
- # so package require in a slave works like in the master)
- set v [interp eval $i {package require http 1}]
- # no error shall occur:
- interp eval $i {http_config};
- safe::interpDelete $i
- set v
-} 1.0
-
-test safe-7.2 {tests specific path and interpFind/AddToAccessPath} {
- set i [safe::interpCreate -nostat -nested 1 -accessPath [list [info library]]];
- # should not add anything (p0)
- set token1 [safe::interpAddToAccessPath $i [info library]]
- # should add as p1
- set token2 [safe::interpAddToAccessPath $i "/dummy/unixlike/test/path"];
- # an error shall occur (http is not anymore in the secure 0-level
- # provided deep path)
- list $token1 $token2 \
- [catch {interp eval $i {package require http 1}} msg] $msg \
- [safe::interpConfigure $i]\
- [safe::interpDelete $i]
-} "{\$p(:0:)} {\$p(:1:)} 1 {can't find package http 1} {-accessPath {[list $tcl_library /dummy/unixlike/test/path]} -statics 0 -nested 1 -deleteHook {}} {}"
-
-
-# test source control on file name
-test safe-8.1 {safe source control on file} {
- set i "a";
- catch {safe::interpDelete $i}
- safe::interpCreate $i;
- list [catch {$i eval {source}} msg] \
- $msg \
- [safe::interpDelete $i] ;
-} {1 {wrong # args: should be "source fileName"} {}}
-
-# test source control on file name
-test safe-8.2 {safe source control on file} {
- set i "a";
- catch {safe::interpDelete $i}
- safe::interpCreate $i;
- list [catch {$i eval {source}} msg] \
- $msg \
- [safe::interpDelete $i] ;
-} {1 {wrong # args: should be "source fileName"} {}}
-
-test safe-8.3 {safe source control on file} {
- set i "a";
- catch {safe::interpDelete $i}
- safe::interpCreate $i;
- set log {};
- proc safe-test-log {str} {global log; lappend log $str}
- set prevlog [safe::setLogCmd];
- safe::setLogCmd safe-test-log;
- list [catch {$i eval {source .}} msg] \
- $msg \
- $log \
- [safe::setLogCmd $prevlog; unset log] \
- [safe::interpDelete $i] ;
-} {1 {permission denied} {{ERROR for slave a : ".": is a directory}} {} {}}
-
-
-test safe-8.4 {safe source control on file} {
- set i "a";
- catch {safe::interpDelete $i}
- safe::interpCreate $i;
- set log {};
- proc safe-test-log {str} {global log; lappend log $str}
- set prevlog [safe::setLogCmd];
- safe::setLogCmd safe-test-log;
- list [catch {$i eval {source /abc/def}} msg] \
- $msg \
- $log \
- [safe::setLogCmd $prevlog; unset log] \
- [safe::interpDelete $i] ;
-} {1 {permission denied} {{ERROR for slave a : "/abc/def": not in access_path}} {} {}}
-
-
-test safe-8.5 {safe source control on file} {
- set i "a";
- catch {safe::interpDelete $i}
- safe::interpCreate $i;
- set log {};
- proc safe-test-log {str} {global log; lappend log $str}
- set prevlog [safe::setLogCmd];
- safe::setLogCmd safe-test-log;
- list [catch {$i eval {source [file join [info lib] blah]}} msg] \
- $msg \
- $log \
- [safe::setLogCmd $prevlog; unset log] \
- [safe::interpDelete $i] ;
-} "1 {blah: must be a *.tcl or tclIndex} {{ERROR for slave a : [file join [info library] blah]:blah: must be a *.tcl or tclIndex}} {} {}"
-
-
-test safe-8.6 {safe source control on file} {
- set i "a";
- catch {safe::interpDelete $i}
- safe::interpCreate $i;
- set log {};
- proc safe-test-log {str} {global log; lappend log $str}
- set prevlog [safe::setLogCmd];
- safe::setLogCmd safe-test-log;
- list [catch {$i eval {source [file join [info lib] blah.tcl]}} msg] \
- $msg \
- $log \
- [safe::setLogCmd $prevlog; unset log] \
- [safe::interpDelete $i] ;
-} "1 {no such file or directory} {{ERROR for slave a : [file join [info library] blah.tcl]:no such file or directory}} {} {}"
-
-
-test safe-8.7 {safe source control on file} {
- set i "a";
- catch {safe::interpDelete $i}
- safe::interpCreate $i;
- set log {};
- proc safe-test-log {str} {global log; lappend log $str}
- set prevlog [safe::setLogCmd];
- safe::setLogCmd safe-test-log;
- list [catch {$i eval {source [file join [info lib] xxxxxxxxxxx.tcl]}}\
- msg] \
- $msg \
- $log \
- [safe::setLogCmd $prevlog; unset log] \
- [safe::interpDelete $i] ;
-} "1 {xxxxxxxxxxx.tcl: filename too long} {{ERROR for slave a : [file join [info library] xxxxxxxxxxx.tcl]:xxxxxxxxxxx.tcl: filename too long}} {} {}"
-
-test safe-8.8 {safe source forbids -rsrc} {
- set i "a";
- catch {safe::interpDelete $i}
- safe::interpCreate $i;
- list [catch {$i eval {source -rsrc Init}} msg] \
- $msg \
- [safe::interpDelete $i] ;
-} {1 {wrong # args: should be "source fileName"} {}}
-
-
-test safe-9.1 {safe interps' deleteHook} {
- set i "a";
- catch {safe::interpDelete $i}
- set res {}
- proc testDelHook {args} {
- global res;
- # the interp still exists at that point
- interp eval a {set delete 1}
- # mark that we've been here (successfully)
- set res $args;
- }
- safe::interpCreate $i -deleteHook "testDelHook arg1 arg2";
- list [interp eval $i exit] $res
-} {{} {arg1 arg2 a}}
-
-test safe-9.2 {safe interps' error in deleteHook} {
- set i "a";
- catch {safe::interpDelete $i}
- set res {}
- proc testDelHook {args} {
- global res;
- # the interp still exists at that point
- interp eval a {set delete 1}
- # mark that we've been here (successfully)
- set res $args;
- # create an exception
- error "being catched";
- }
- set log {};
- proc safe-test-log {str} {global log; lappend log $str}
- safe::interpCreate $i -deleteHook "testDelHook arg1 arg2";
- set prevlog [safe::setLogCmd];
- safe::setLogCmd safe-test-log;
- list [safe::interpDelete $i] $res \
- $log \
- [safe::setLogCmd $prevlog; unset log];
-} {{} {arg1 arg2 a} {{NOTICE for slave a : About to delete} {ERROR for slave a : Delete hook error (being catched)} {NOTICE for slave a : Deleted}} {}}
-
-
-test safe-9.3 {dual specification of statics} {
- list [catch {safe::interpCreate -stat true -nostat} msg] $msg
-} {1 {conflicting values given for -statics and -noStatics}}
-
-test safe-9.4 {dual specification of statics} {
- # no error shall occur
- safe::interpDelete [safe::interpCreate -stat false -nostat]
-} {}
-
-test safe-9.5 {dual specification of nested} {
- list [catch {safe::interpCreate -nested 0 -nestedload} msg] $msg
-} {1 {conflicting values given for -nested and -nestedLoadOk}}
-
-test safe-9.6 {interpConfigure widget like behaviour} {
- # this test shall work, don't try to "fix it" unless
- # you *really* know what you are doing (ie you are me :p) -- dl
- list [set i [safe::interpCreate \
- -noStatics \
- -nestedLoadOk \
- -deleteHook {foo bar}];
- safe::interpConfigure $i -accessPath /foo/bar ;
- safe::interpConfigure $i]\
- [safe::interpConfigure $i -aCCess]\
- [safe::interpConfigure $i -nested]\
- [safe::interpConfigure $i -statics]\
- [safe::interpConfigure $i -DEL]\
- [safe::interpConfigure $i -accessPath /blah -statics 1;
- safe::interpConfigure $i]\
- [safe::interpConfigure $i -deleteHook toto -nosta -nested 0;
- safe::interpConfigure $i]
-} {{-accessPath /foo/bar -statics 0 -nested 1 -deleteHook {foo bar}} {-accessPath /foo/bar} {-nested 1} {-statics 0} {-deleteHook {foo bar}} {-accessPath /blah -statics 1 -nested 1 -deleteHook {foo bar}} {-accessPath /blah -statics 0 -nested 0 -deleteHook toto}}
-
-
-# testing that nested and statics do what is advertised
-# (we use a static package : Tcltest)
-
-if {[catch {package require Tcltest} msg]} {
- puts "This application hasn't been compiled with Tcltest"
- puts "skipping remining safe test that relies on it."
-} else {
-
- # we use the Tcltest package , which has no Safe_Init
-
-test safe-10.1 {testing statics loading} {
- set i [safe::interpCreate]
- list \
- [catch {interp eval $i {load {} Tcltest}} msg] \
- $msg \
- [safe::interpDelete $i];
-} {1 {can't use package in a safe interpreter: no Tcltest_SafeInit procedure} {}}
-
-test safe-10.2 {testing statics loading / -nostatics} {
- set i [safe::interpCreate -nostatics]
- list \
- [catch {interp eval $i {load {} Tcltest}} msg] \
- $msg \
- [safe::interpDelete $i];
-} {1 {permission denied (static package)} {}}
-
-
-
-test safe-10.3 {testing nested statics loading / no nested by default} {
- set i [safe::interpCreate]
- list \
- [catch {interp eval $i {interp create x; load {} Tcltest x}} msg] \
- $msg \
- [safe::interpDelete $i];
-} {1 {permission denied (nested load)} {}}
-
-
-test safe-10.4 {testing nested statics loading / -nestedloadok} {
- set i [safe::interpCreate -nestedloadok]
- list \
- [catch {interp eval $i {interp create x; load {} Tcltest x}} msg] \
- $msg \
- [safe::interpDelete $i];
-} {1 {can't use package in a safe interpreter: no Tcltest_SafeInit procedure} {}}
-
-
-}
-
-test safe-11.1 {testing safe encoding} {
- set i [safe::interpCreate]
- list \
- [catch {interp eval $i encoding} msg] \
- $msg \
- [safe::interpDelete $i];
-} {1 {wrong # args: should be "encoding option ?arg ...?"} {}}
-
-test safe-11.2 {testing safe encoding} {
- set i [safe::interpCreate]
- list \
- [catch {interp eval $i encoding system cp775} msg] \
- $msg \
- [safe::interpDelete $i];
-} {1 {wrong # args: should be "encoding system"} {}}
-
-test safe-11.3 {testing safe encoding} {
- set i [safe::interpCreate]
- set result [catch {
- string match [encoding system] [interp eval $i encoding system]
- } msg]
- list $result $msg [safe::interpDelete $i]
-} {0 1 {}}
-
-test safe-11.4 {testing safe encoding} {
- set i [safe::interpCreate]
- set result [catch {
- string match [encoding names] [interp eval $i encoding names]
- } msg]
- list $result $msg [safe::interpDelete $i]
-} {0 1 {}}
-
-test safe-11.5 {testing safe encoding} {
- set i [safe::interpCreate]
- list \
- [catch {interp eval $i encoding convertfrom cp1258 foobar} msg] \
- $msg \
- [safe::interpDelete $i];
-} {0 foobar {}}
-
-
-test safe-11.6 {testing safe encoding} {
- set i [safe::interpCreate]
- list \
- [catch {interp eval $i encoding convertto cp1258 foobar} msg] \
- $msg \
- [safe::interpDelete $i];
-} {0 foobar {}}
-
-test safe-11.7 {testing safe encoding} {
- set i [safe::interpCreate]
- list \
- [catch {interp eval $i encoding convertfrom} msg] \
- $msg \
- [safe::interpDelete $i];
-} {1 {wrong # args: should be "encoding convertfrom ?encoding? data"} {}}
-
-
-test safe-11.8 {testing safe encoding} {
- set i [safe::interpCreate]
- list \
- [catch {interp eval $i encoding convertto} msg] \
- $msg \
- [safe::interpDelete $i];
-} {1 {wrong # args: should be "encoding convertto ?encoding? data"} {}}
-
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/scan.test b/tests/scan.test
deleted file mode 100644
index aa86a4d..0000000
--- a/tests/scan.test
+++ /dev/null
@@ -1,586 +0,0 @@
-# Commands covered: scan
-#
-# 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) 1991-1994 The Regents of the University of California.
-# Copyright (c) 1994-1997 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: scan.test,v 1.4 1999/04/16 00:47:34 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test scan-1.1 {BuildCharSet, CharInSet} {
- list [scan foo {%[^o]} x] $x
-} {1 f}
-test scan-1.2 {BuildCharSet, CharInSet} {
- list [scan \]foo {%[]f]} x] $x
-} {1 \]f}
-test scan-1.3 {BuildCharSet, CharInSet} {
- list [scan abc-def {%[a-c]} x] $x
-} {1 abc}
-test scan-1.4 {BuildCharSet, CharInSet} {
- list [scan abc-def {%[a-c]} x] $x
-} {1 abc}
-test scan-1.5 {BuildCharSet, CharInSet} {
- list [scan -abc-def {%[-ac]} x] $x
-} {1 -a}
-test scan-1.6 {BuildCharSet, CharInSet} {
- list [scan -abc-def {%[ac-]} x] $x
-} {1 -a}
-test scan-1.7 {BuildCharSet, CharInSet} {
- list [scan abc-def {%[c-a]} x] $x
-} {1 abc}
-test scan-1.8 {BuildCharSet, CharInSet} {
- list [scan def-abc {%[^c-a]} x] $x
-} {1 def-}
-
-test scan-2.1 {ReleaseCharSet} {
- list [scan abcde {%[abc]} x] $x
-} {1 abc}
-test scan-2.2 {ReleaseCharSet} {
- list [scan abcde {%[a-c]} x] $x
-} {1 abc}
-
-test scan-3.1 {ValidateFormat} {
- list [catch {scan {} {%d%1$d} x} msg] $msg
-} {1 {cannot mix "%" and "%n$" conversion specifiers}}
-test scan-3.2 {ValidateFormat} {
- list [catch {scan {} {%d%1$d} x} msg] $msg
-} {1 {cannot mix "%" and "%n$" conversion specifiers}}
-test scan-3.3 {ValidateFormat} {
- list [catch {scan {} {%2$d%d} x} msg] $msg
-} {1 {"%n$" argument index out of range}}
-test scan-3.4 {ValidateFormat} {
- list [catch {scan {} %d} msg] $msg
-} {1 {different numbers of variable names and field specifiers}}
-test scan-3.5 {ValidateFormat} {
- list [catch {scan {} {%10c} a} msg] $msg
-} {1 {field width may not be specified in %c conversion}}
-test scan-3.6 {ValidateFormat} {
- list [catch {scan {} {%*1$d} a} msg] $msg
-} {1 {bad scan conversion character "$"}}
-test scan-3.7 {ValidateFormat} {
- list [catch {scan {} {%1$d%1$d} a} msg] $msg
-} {1 {variable is assigned by multiple "%n$" conversion specifiers}}
-test scan-3.8 {ValidateFormat} {
- list [catch {scan {} a x} msg] $msg
-} {1 {variable is not assigend by any conversion specifiers}}
-test scan-3.9 {ValidateFormat} {
- list [catch {scan {} {%2$s} x y} msg] $msg
-} {1 {variable is not assigend by any conversion specifiers}}
-test scan-3.10 {ValidateFormat} {
- list [catch {scan {} {%[a} x} msg] $msg
-} {1 {unmatched [ in format string}}
-test scan-3.11 {ValidateFormat} {
- list [catch {scan {} {%[^a} x} msg] $msg
-} {1 {unmatched [ in format string}}
-test scan-3.12 {ValidateFormat} {
- list [catch {scan {} {%[]a} x} msg] $msg
-} {1 {unmatched [ in format string}}
-test scan-3.13 {ValidateFormat} {
- list [catch {scan {} {%[^]a} x} msg] $msg
-} {1 {unmatched [ in format string}}
-
-test scan-4.1 {Tcl_ScanObjCmd, argument checks} {
- list [catch {scan} msg] $msg
-} {1 {wrong # args: should be "scan string format ?varName varName ...?"}}
-test scan-4.2 {Tcl_ScanObjCmd, argument checks} {
- list [catch {scan string} msg] $msg
-} {1 {wrong # args: should be "scan string format ?varName varName ...?"}}
-test scan-4.3 {Tcl_ScanObjCmd, argument checks} {
- list [catch {scan string format} msg] $msg
-} {0 0}
-test scan-4.4 {Tcl_ScanObjCmd, whitespace} {
- list [scan { abc def } {%s%s} x y] $x $y
-} {2 abc def}
-test scan-4.5 {Tcl_ScanObjCmd, whitespace} {
- list [scan { abc def } { %s %s } x y] $x $y
-} {2 abc def}
-test scan-4.6 {Tcl_ScanObjCmd, whitespace} {
- list [scan { abc def } { %s %s } x y] $x $y
-} {2 abc def}
-test scan-4.7 {Tcl_ScanObjCmd, literals} {
- scan { abc def } { abc def }
-} 0
-test scan-4.8 {Tcl_ScanObjCmd, literals} {
- set x {}
- list [scan { abcg} { abc def %1s} x] $x
-} {0 {}}
-test scan-4.9 {Tcl_ScanObjCmd, literals} {
- list [scan { abc%defghi} { abc %% def%n } x] $x
-} {1 10}
-test scan-4.10 {Tcl_ScanObjCmd, assignment suppression} {
- list [scan { abc def } { %*c%s def } x] $x
-} {1 bc}
-test scan-4.11 {Tcl_ScanObjCmd, XPG3-style} {
- list [scan { abc def } {%2$s %1$s} x y] $x $y
-} {2 def abc}
-test scan-4.12 {Tcl_ScanObjCmd, width specifiers} {
- list [scan {abc123456789012} {%3s%3d%3f%3[0-9]%s} a b c d e] $a $b $c $d $e
-} {5 abc 123 456.0 789 012}
-test scan-4.13 {Tcl_ScanObjCmd, width specifiers} {
- list [scan {abc123456789012} {%3s%3d%3f%3[0-9]%s} a b c d e] $a $b $c $d $e
-} {5 abc 123 456.0 789 012}
-test scan-4.14 {Tcl_ScanObjCmd, underflow} {
- set x {}
- list [scan {a} {a%d} x] $x
-} {-1 {}}
-test scan-4.15 {Tcl_ScanObjCmd, underflow} {
- set x {}
- list [scan {} {a%d} x] $x
-} {-1 {}}
-test scan-4.16 {Tcl_ScanObjCmd, underflow} {
- set x {}
- list [scan {ab} {a%d} x] $x
-} {0 {}}
-test scan-4.17 {Tcl_ScanObjCmd, underflow} {
- set x {}
- list [scan {a } {a%d} x] $x
-} {-1 {}}
-test scan-4.18 {Tcl_ScanObjCmd, skipping whitespace} {
- list [scan { b} {%c%s} x y] $x $y
-} {2 32 b}
-test scan-4.19 {Tcl_ScanObjCmd, skipping whitespace} {
- list [scan { b} {%[^b]%s} x y] $x $y
-} {2 { } b}
-test scan-4.20 {Tcl_ScanObjCmd, string scanning} {
- list [scan {abc def} {%s} x] $x
-} {1 abc}
-test scan-4.21 {Tcl_ScanObjCmd, string scanning} {
- list [scan {abc def} {%0s} x] $x
-} {1 abc}
-test scan-4.22 {Tcl_ScanObjCmd, string scanning} {
- list [scan {abc def} {%2s} x] $x
-} {1 ab}
-test scan-4.23 {Tcl_ScanObjCmd, string scanning} {
- list [scan {abc def} {%*s%n} x] $x
-} {1 3}
-test scan-4.24 {Tcl_ScanObjCmd, charset scanning} {
- list [scan {abcdef} {%[a-c]} x] $x
-} {1 abc}
-test scan-4.25 {Tcl_ScanObjCmd, charset scanning} {
- list [scan {abcdef} {%0[a-c]} x] $x
-} {1 abc}
-test scan-4.26 {Tcl_ScanObjCmd, charset scanning} {
- list [scan {abcdef} {%2[a-c]} x] $x
-} {1 ab}
-test scan-4.27 {Tcl_ScanObjCmd, charset scanning} {
- list [scan {abcdef} {%*[a-c]%n} x] $x
-} {1 3}
-test scan-4.28 {Tcl_ScanObjCmd, character scanning} {
- list [scan {abcdef} {%c} x] $x
-} {1 97}
-test scan-4.29 {Tcl_ScanObjCmd, character scanning} {
- list [scan {abcdef} {%*c%n} x] $x
-} {1 1}
-
-test scan-4.30 {Tcl_ScanObjCmd, base-10 integer scanning} {
- set x {}
- list [scan {1234567890a} {%3d} x] $x
-} {1 123}
-test scan-4.31 {Tcl_ScanObjCmd, base-10 integer scanning} {
- set x {}
- list [scan {1234567890a} {%d} x] $x
-} {1 1234567890}
-test scan-4.32 {Tcl_ScanObjCmd, base-10 integer scanning} {
- set x {}
- list [scan {01234567890a} {%d} x] $x
-} {1 1234567890}
-test scan-4.33 {Tcl_ScanObjCmd, base-10 integer scanning} {
- set x {}
- list [scan {+01234} {%d} x] $x
-} {1 1234}
-test scan-4.34 {Tcl_ScanObjCmd, base-10 integer scanning} {
- set x {}
- list [scan {-01234} {%d} x] $x
-} {1 -1234}
-test scan-4.35 {Tcl_ScanObjCmd, base-10 integer scanning} {
- set x {}
- list [scan {a01234} {%d} x] $x
-} {0 {}}
-test scan-4.36 {Tcl_ScanObjCmd, base-10 integer scanning} {
- set x {}
- list [scan {0x10} {%d} x] $x
-} {1 0}
-test scan-4.37 {Tcl_ScanObjCmd, base-8 integer scanning} {
- set x {}
- list [scan {012345678} {%o} x] $x
-} {1 342391}
-test scan-4.38 {Tcl_ScanObjCmd, base-8 integer scanning} {
- set x {}
- list [scan {+1238 -1239 123a} {%o%*s%o%*s%o} x y z] $x $y $z
-} {3 83 -83 83}
-test scan-4.39 {Tcl_ScanObjCmd, base-16 integer scanning} {
- set x {}
- list [scan {+1238 -123a 0123} {%x%x%x} x y z] $x $y $z
-} {3 4664 -4666 291}
-test scan-4.40 {Tcl_ScanObjCmd, base-16 integer scanning} {
- set x {}
- list [scan {aBcDeF AbCdEf 0x1} {%x%x%x} x y z] $x $y $z
-} {3 11259375 11259375 0}
-test scan-4.41 {Tcl_ScanObjCmd, base-unknown integer scanning} {
- set x {}
- list [scan {10 010 0x10} {%i%i%i} x y z] $x $y $z
-} {3 10 8 16}
-test scan-4.42 {Tcl_ScanObjCmd, base-unknown integer scanning} {
- set x {}
- list [scan {10 010 0X10} {%i%i%i} x y z] $x $y $z
-} {3 10 8 16}
-test scan-4.43 {Tcl_ScanObjCmd, integer scanning, odd cases} {
- set x {}
- list [scan {+ } {%i} x] $x
-} {0 {}}
-test scan-4.44 {Tcl_ScanObjCmd, integer scanning, odd cases} {
- set x {}
- list [scan {+} {%i} x] $x
-} {-1 {}}
-test scan-4.45 {Tcl_ScanObjCmd, integer scanning, odd cases} {
- set x {}
- list [scan {0x} {%i%s} x y] $x $y
-} {2 0 x}
-test scan-4.46 {Tcl_ScanObjCmd, integer scanning, odd cases} {
- set x {}
- list [scan {0X} {%i%s} x y] $x $y
-} {2 0 X}
-test scan-4.47 {Tcl_ScanObjCmd, integer scanning, suppressed} {
- set x {}
- list [scan {123def} {%*i%s} x] $x
-} {1 def}
-test scan-4.48 {Tcl_ScanObjCmd, float scanning} {
- list [scan {1 2 3} {%e %f %g} x y z] $x $y $z
-} {3 1.0 2.0 3.0}
-test scan-4.49 {Tcl_ScanObjCmd, float scanning} {
- list [scan {.1 0.2 3.} {%e %f %g} x y z] $x $y $z
-} {3 0.1 0.2 3.0}
-test scan-4.50 {Tcl_ScanObjCmd, float scanning} {
- list [scan {1234567890a} %f x] $x
-} {1 1234567890.0}
-test scan-4.51 {Tcl_ScanObjCmd, float scanning} {
- list [scan {+123+45} %f x] $x
-} {1 123.0}
-test scan-4.52 {Tcl_ScanObjCmd, float scanning} {
- list [scan {-123+45} %f x] $x
-} {1 -123.0}
-test scan-4.53 {Tcl_ScanObjCmd, float scanning} {
- list [scan {1.0e1} %f x] $x
-} {1 10.0}
-test scan-4.54 {Tcl_ScanObjCmd, float scanning} {
- list [scan {1.0e-1} %f x] $x
-} {1 0.1}
-test scan-4.55 {Tcl_ScanObjCmd, odd cases} {
- set x {}
- list [scan {+} %f x] $x
-} {-1 {}}
-test scan-4.56 {Tcl_ScanObjCmd, odd cases} {
- set x {}
- list [scan {1.0e} %f%s x y] $x $y
-} {2 1.0 e}
-test scan-4.57 {Tcl_ScanObjCmd, odd cases} {
- set x {}
- list [scan {1.0e+} %f%s x y] $x $y
-} {2 1.0 e+}
-test scan-4.58 {Tcl_ScanObjCmd, odd cases} {
- set x {}
- set y {}
- list [scan {e1} %f%s x y] $x $y
-} {0 {} {}}
-test scan-4.59 {Tcl_ScanObjCmd, float scanning} {
- list [scan {1.0e-1x} %*f%n x] $x
-} {1 6}
-
-test scan-4.60 {Tcl_ScanObjCmd, set errors} {
- set x {}
- set y {}
- catch {unset z}; array set z {}
- set result [list [catch {scan {abc def ghi} {%s%s%s} x z y} msg] \
- $msg $x $y]
- unset z
- set result
-} {1 {couldn't set variable "z"} abc ghi}
-test scan-4.61 {Tcl_ScanObjCmd, set errors} {
- set x {}
- catch {unset y}; array set y {}
- catch {unset z}; array set z {}
- set result [list [catch {scan {abc def ghi} {%s%s%s} x z y} msg] \
- $msg $x]
- unset y
- unset z
- set result
-} {1 {couldn't set variable "z"couldn't set variable "y"} abc}
-
-test scan-5.1 {integer scanning} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "-20 1476 \n33 0" "%d %d %d %d" a b c d] $a $b $c $d
-} {4 -20 1476 33 0}
-test scan-5.2 {integer scanning} {
- set a {}; set b {}; set c {}
- list [scan "-45 16 7890 +10" "%2d %*d %10d %d" a b c] $a $b $c
-} {3 -4 16 7890}
-test scan-5.3 {integer scanning} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "-45 16 +10 987" "%ld %d %ld %d" a b c d] $a $b $c $d
-} {4 -45 16 10 987}
-test scan-5.4 {integer scanning} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "14 1ab 62 10" "%d %x %lo %x" a b c d] $a $b $c $d
-} {4 14 427 50 16}
-test scan-5.5 {integer scanning} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "12345670 1234567890ab cdefg" "%o %o %x %lx" a b c d] \
- $a $b $c $d
-} {4 2739128 342391 561323 52719}
-test scan-5.6 {integer scanning} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "ab123-24642" "%2x %3x %3o %2o" a b c d] $a $b $c $d
-} {4 171 291 -20 52}
-test scan-5.7 {integer scanning} {
- set a {}; set b {}
- list [scan "1234567 234 567 " "%*3x %x %*o %4o" a b] $a $b
-} {2 17767 375}
-test scan-5.8 {integer scanning} {
- set a {}; set b {}
- list [scan "a 1234" "%d %d" a b] $a $b
-} {0 {} {}}
-test scan-5.9 {integer scanning} {
- set a {}; set b {}; set c {}; set d {};
- list [scan "12345678" "%2d %2d %2ld %2d" a b c d] $a $b $c $d
-} {4 12 34 56 78}
-test scan-5.10 {integer scanning} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "1 2 " "%hd %d %d %d" a b c d] $a $b $c $d
-} {2 1 2 {} {}}
-#
-# The behavior for scaning intergers larger than MAX_INT is
-# not defined by the ANSI spec. Some implementations wrap the
-# input (-16) some return MAX_INT.
-#
-test scan-5.11 {integer scanning} {nonPortable} {
- set a {}; set b {};
- list [scan "4294967280 4294967280" "%u %d" a b] $a \
- [expr {$b == -16 || $b == 0x7fffffff}]
-} {2 4294967280 1}
-
-test scan-6.1 {floating-point scanning} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "2.1 -3.0e8 .99962 a" "%f%g%e%f" a b c d] $a $b $c $d
-} {3 2.1 -300000000.0 0.99962 {}}
-test scan-6.2 {floating-point scanning} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "-1.2345 +8.2 9" "%3e %3lf %f %f" a b c d] $a $b $c $d
-} {4 -1.0 234.0 5.0 8.2}
-test scan-6.3 {floating-point scanning} {
- set a {}; set b {}; set c {}
- list [scan "1e00004 332E-4 3e+4" "%Lf %*2e %f %f" a b c] $a $c
-} {3 10000.0 30000.0}
-#
-# Some libc implementations consider 3.e- bad input. The ANSI
-# spec states that digits must follow the - sign.
-#
-test scan-6.4 {floating-point scanning} {
- set a {}; set b {}; set c {}
- list [scan "1. 47.6 2.e2 3.e-" "%f %*f %f %f" a b c] $a $b $c
-} {3 1.0 200.0 3.0}
-test scan-6.5 {floating-point scanning} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "4.6 99999.7 876.43e-1 118" "%f %f %f %e" a b c d] $a $b $c $d
-} {4 4.6 99999.7 87.643 118.0}
-test scan-6.6 {floating-point scanning} {eformat} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "1.2345 697.0e-3 124 .00005" "%f %e %f %e" a b c d] $a $b $c $d
-} {4 1.2345 0.697 124.0 5e-05}
-test scan-6.7 {floating-point scanning} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "4.6abc" "%f %f %f %f" a b c d] $a $b $c $d
-} {1 4.6 {} {} {}}
-test scan-6.8 {floating-point scanning} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "4.6 5.2" "%f %f %f %f" a b c d] $a $b $c $d
-} {2 4.6 5.2 {} {}}
-
-test scan-7.1 {string and character scanning} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "abc defghijk dum " "%s %3s %20s %s" a b c d] $a $b $c $d
-} {4 abc def ghijk dum}
-test scan-7.2 {string and character scanning} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "a bcdef" "%c%c%1s %s" a b c d] $a $b $c $d
-} {4 97 32 b cdef}
-test scan-7.3 {string and character scanning} {
- set a {}; set b {}; set c {}
- list [scan "123456 test " "%*c%*s %s %s %s" a b c] $a $b $c
-} {1 test {} {}}
-test scan-7.4 {string and character scanning} {
- set a {}; set b {}; set c {}; set d
- list [scan "ababcd01234 f 123450" {%4[abcd] %4[abcd] %[^abcdef] %[^0]} a b c d] $a $b $c $d
-} {4 abab cd {01234 } {f 12345}}
-test scan-7.5 {string and character scanning} {
- set a {}; set b {}; set c {}
- list [scan "aaaaaabc aaabcdefg + + XYZQR" {%*4[a] %s %*4[a]%s%*4[ +]%c} a b c] $a $b $c
-} {3 aabc bcdefg 43}
-test scan-7.6 {string and character scanning, unicode} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "abc d\u00c7fghijk dum " "%s %3s %20s %s" a b c d] $a $b $c $d
-} "4 abc d\u00c7f ghijk dum"
-test scan-7.7 {string and character scanning, unicode} {
- set a {}; set b {}
- list [scan "ab\u00c7cdef" "ab%c%c" a b] $a $b
-} "2 199 99"
-test scan-7.8 {string and character scanning, unicode} {
- set a {}; set b {}
- list [scan "ab\ufeffdef" "%\[ab\ufeff\]" a] $a
-} "1 ab\ufeff"
-
-test scan-8.1 {error conditions} {
- catch {scan a}
-} 1
-test scan-8.2 {error conditions} {
- catch {scan a} msg
- set msg
-} {wrong # args: should be "scan string format ?varName varName ...?"}
-test scan-8.3 {error conditions} {
- list [catch {scan a %D x} msg] $msg
-} {1 {bad scan conversion character "D"}}
-test scan-8.4 {error conditions} {
- list [catch {scan a %O x} msg] $msg
-} {1 {bad scan conversion character "O"}}
-test scan-8.5 {error conditions} {
- list [catch {scan a %X x} msg] $msg
-} {1 {bad scan conversion character "X"}}
-test scan-8.6 {error conditions} {
- list [catch {scan a %F x} msg] $msg
-} {1 {bad scan conversion character "F"}}
-test scan-8.7 {error conditions} {
- list [catch {scan a %E x} msg] $msg
-} {1 {bad scan conversion character "E"}}
-test scan-8.8 {error conditions} {
- list [catch {scan a "%d %d" a} msg] $msg
-} {1 {different numbers of variable names and field specifiers}}
-test scan-8.9 {error conditions} {
- list [catch {scan a "%d %d" a b c} msg] $msg
-} {1 {variable is not assigend by any conversion specifiers}}
-test scan-8.10 {error conditions} {
- set a {}; set b {}; set c {}; set d {}
- list [expr {[scan " a" " a %d %d %d %d" a b c d] <= 0}] $a $b $c $d
-} {1 {} {} {} {}}
-test scan-8.11 {error conditions} {
- set a {}; set b {}; set c {}; set d {}
- list [scan "1 2" "%d %d %d %d" a b c d] $a $b $c $d
-} {2 1 2 {} {}}
-test scan-8.12 {error conditions} {
- catch {unset a}
- set a(0) 44
- list [catch {scan 44 %d a} msg] $msg
-} {1 {couldn't set variable "a"}}
-test scan-8.13 {error conditions} {
- catch {unset a}
- set a(0) 44
- list [catch {scan 44 %c a} msg] $msg
-} {1 {couldn't set variable "a"}}
-test scan-8.14 {error conditions} {
- catch {unset a}
- set a(0) 44
- list [catch {scan 44 %s a} msg] $msg
-} {1 {couldn't set variable "a"}}
-test scan-8.15 {error conditions} {
- catch {unset a}
- set a(0) 44
- list [catch {scan 44 %f a} msg] $msg
-} {1 {couldn't set variable "a"}}
-test scan-8.16 {error conditions} {
- catch {unset a}
- set a(0) 44
- list [catch {scan 44 %f a} msg] $msg
-} {1 {couldn't set variable "a"}}
-catch {unset a}
-test scan-8.17 {error conditions} {
- list [catch {scan 44 %2c a} msg] $msg
-} {1 {field width may not be specified in %c conversion}}
-test scan-8.18 {error conditions} {
- list [catch {scan abc {%[} x} msg] $msg
-} {1 {unmatched [ in format string}}
-test scan-8.19 {error conditions} {
- list [catch {scan abc {%[^a} x} msg] $msg
-} {1 {unmatched [ in format string}}
-test scan-8.20 {error conditions} {
- list [catch {scan abc {%[^]a} x} msg] $msg
-} {1 {unmatched [ in format string}}
-test scan-8.21 {error conditions} {
- list [catch {scan abc {%[]a} x} msg] $msg
-} {1 {unmatched [ in format string}}
-
-test scan-9.1 {lots of arguments} {
- scan "10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200" "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d" a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20
-} 20
-test scan-9.2 {lots of arguments} {
- scan "10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200" "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d" a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20
- set a20
-} 200
-
-test scan-10.1 {miscellaneous tests} {
- set a {}
- list [scan ab16c ab%dc a] $a
-} {1 16}
-test scan-10.2 {miscellaneous tests} {
- set a {}
- list [scan ax16c ab%dc a] $a
-} {0 {}}
-test scan-10.3 {miscellaneous tests} {
- set a {}
- list [catch {scan ab%c114 ab%%c%d a} msg] $msg $a
-} {0 1 114}
-test scan-10.4 {miscellaneous tests} {
- set a {}
- list [catch {scan ab%c14 ab%%c%d a} msg] $msg $a
-} {0 1 14}
-test scan-10.5 {miscellaneous tests} {
- catch {unset arr}
- set arr(2) {}
- list [catch {scan ab%c14 ab%%c%d arr(2)} msg] $msg $arr(2)
-} {0 1 14}
-
-test scan-11.1 {alignment in results array (TCL_ALIGN)} {
- scan "123 13.6" "%s %f" a b
- set b
-} 13.6
-test scan-11.2 {alignment in results array (TCL_ALIGN)} {
- scan "1234567 13.6" "%s %f" a b
- set b
-} 13.6
-test scan-11.3 {alignment in results array (TCL_ALIGN)} {
- scan "12345678901 13.6" "%s %f" a b
- set b
-} 13.6
-test scan-11.4 {alignment in results array (TCL_ALIGN)} {
- scan "123456789012345 13.6" "%s %f" a b
- set b
-} 13.6
-test scan-11.5 {alignment in results array (TCL_ALIGN)} {
- scan "1234567890123456789 13.6" "%s %f" a b
- set b
-} 13.6
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/security.test b/tests/security.test
deleted file mode 100644
index d75696a..0000000
--- a/tests/security.test
+++ /dev/null
@@ -1,53 +0,0 @@
-# security.test --
-#
-# Functionality covered: this file contains a collection of tests for the
-# auto loading and namespaces.
-#
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 1997 Sun Microsystems, Inc.
-# Copyright (c) 1998-1999 by Scriptics Corporation.
-# All rights reserved.
-#
-# RCS: @(#) $Id: security.test,v 1.2 1999/04/16 00:47:34 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# If this proc becomes invoked, then there is a bug
-
-proc BUG {args} {
- set ::BUG 1
-}
-
-# Check and Clear the bug flag (to do before each test)
-set ::BUG 0
-
-proc CB {} {
- set ret $::BUG
- set ::BUG 0
- return $ret
-}
-
-
-test sec-1.1 {tcl_endOfPreviousWord} {
- catch {tcl_startOfPreviousWord x {[BUG]}}
- CB
-} 0
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/set-old.test b/tests/set-old.test
deleted file mode 100644
index 08e2cd1..0000000
--- a/tests/set-old.test
+++ /dev/null
@@ -1,811 +0,0 @@
-# Commands covered: set, unset, array
-#
-# This file includes the original set of tests for Tcl's set command.
-# Since the set command is now compiled, a new set of tests covering
-# the new implementation is in the file "set.test". Sourcing this file
-# into Tcl runs the tests and generates output for errors.
-# No output means no errors were found.
-#
-# Copyright (c) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-1997 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: set-old.test,v 1.4 1999/04/16 00:47:34 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-proc ignore args {}
-
-# Simple variable operations.
-
-catch {unset a}
-test set-old-1.1 {basic variable setting and unsetting} {
- set a 22
-} 22
-test set-old-1.2 {basic variable setting and unsetting} {
- set a 123
- set a
-} 123
-test set-old-1.3 {basic variable setting and unsetting} {
- set a xxx
- format %s $a
-} xxx
-test set-old-1.4 {basic variable setting and unsetting} {
- set a 44
- unset a
- list [catch {set a} msg] $msg
-} {1 {can't read "a": no such variable}}
-
-# Basic array operations.
-
-catch {unset a}
-set a(xyz) 2
-set a(44) 3
-set {a(a long name)} test
-test set-old-2.1 {basic array operations} {
- lsort [array names a]
-} {44 {a long name} xyz}
-test set-old-2.2 {basic array operations} {
- set a(44)
-} 3
-test set-old-2.3 {basic array operations} {
- set a(xyz)
-} 2
-test set-old-2.4 {basic array operations} {
- set "a(a long name)"
-} test
-test set-old-2.5 {basic array operations} {
- list [catch {set a(other)} msg] $msg
-} {1 {can't read "a(other)": no such element in array}}
-test set-old-2.6 {basic array operations} {
- list [catch {set a} msg] $msg
-} {1 {can't read "a": variable is array}}
-test set-old-2.7 {basic array operations} {
- format %s $a(44)
-} 3
-test set-old-2.8 {basic array operations} {
- format %s $a(a long name)
-} test
-unset a(44)
-test set-old-2.9 {basic array operations} {
- lsort [array names a]
-} {{a long name} xyz}
-test set-old-2.10 {basic array operations} {
- catch {unset b}
- list [catch {set b(123)} msg] $msg
-} {1 {can't read "b(123)": no such variable}}
-test set-old-2.11 {basic array operations} {
- catch {unset b}
- set b 44
- list [catch {set b(123)} msg] $msg
-} {1 {can't read "b(123)": variable isn't array}}
-test set-old-2.12 {basic array operations} {
- list [catch {set a 14} msg] $msg
-} {1 {can't set "a": variable is array}}
-unset a
-test set-old-2.13 {basic array operations} {
- list [catch {set a(xyz)} msg] $msg
-} {1 {can't read "a(xyz)": no such variable}}
-
-# Test the set commands, and exercise the corner cases of the code
-# that parses array references into two parts.
-
-test set-old-3.1 {set command} {
- list [catch {set} msg] $msg
-} {1 {wrong # args: should be "set varName ?newValue?"}}
-test set-old-3.2 {set command} {
- list [catch {set x y z} msg] $msg
-} {1 {wrong # args: should be "set varName ?newValue?"}}
-test set-old-3.3 {set command} {
- catch {unset a}
- list [catch {set a} msg] $msg
-} {1 {can't read "a": no such variable}}
-test set-old-3.4 {set command} {
- catch {unset a}
- set a(14) 83
- list [catch {set a 22} msg] $msg
-} {1 {can't set "a": variable is array}}
-
-# Test the corner-cases of parsing array names, using set and unset.
-
-test set-old-4.1 {parsing array names} {
- catch {unset a}
- set a(()) 44
- list [catch {array names a} msg] $msg
-} {0 ()}
-test set-old-4.2 {parsing array names} {
- catch {unset a a(abcd}
- set a(abcd 33
- info exists a(abcd
-} 1
-test set-old-4.3 {parsing array names} {
- catch {unset a a(abcd}
- set a(abcd 33
- list [catch {array names a} msg] $msg
-} {0 {}}
-test set-old-4.4 {parsing array names} {
- catch {unset a abcd)}
- set abcd) 33
- info exists abcd)
-} 1
-test set-old-4.5 {parsing array names} {
- set a(bcd yyy
- catch {unset a}
- list [catch {set a(bcd} msg] $msg
-} {0 yyy}
-test set-old-4.6 {parsing array names} {
- catch {unset a}
- set a 44
- list [catch {set a(bcd test} msg] $msg
-} {0 test}
-
-# Errors in reading variables
-
-test set-old-5.1 {errors in reading variables} {
- catch {unset a}
- list [catch {set a} msg] $msg
-} {1 {can't read "a": no such variable}}
-test set-old-5.2 {errors in reading variables} {
- catch {unset a}
- set a 44
- list [catch {set a(18)} msg] $msg
-} {1 {can't read "a(18)": variable isn't array}}
-test set-old-5.3 {errors in reading variables} {
- catch {unset a}
- set a(6) 44
- list [catch {set a(18)} msg] $msg
-} {1 {can't read "a(18)": no such element in array}}
-test set-old-5.4 {errors in reading variables} {
- catch {unset a}
- set a(6) 44
- list [catch {set a} msg] $msg
-} {1 {can't read "a": variable is array}}
-
-# Errors and other special cases in writing variables
-
-test set-old-6.1 {creating array during write} {
- catch {unset a}
- trace var a rwu ignore
- list [catch {set a(14) 186} msg] $msg [array names a]
-} {0 186 14}
-test set-old-6.2 {errors in writing variables} {
- catch {unset a}
- set a xxx
- list [catch {set a(14) 186} msg] $msg
-} {1 {can't set "a(14)": variable isn't array}}
-test set-old-6.3 {errors in writing variables} {
- catch {unset a}
- set a(100) yyy
- list [catch {set a 2} msg] $msg
-} {1 {can't set "a": variable is array}}
-test set-old-6.4 {expanding variable size} {
- catch {unset a}
- list [set a short] [set a "longer name"] [set a "even longer name"] \
- [set a "a much much truly longer name"]
-} {short {longer name} {even longer name} {a much much truly longer name}}
-
-# Unset command, Tcl_UnsetVar procedures
-
-test set-old-7.1 {unset command} {
- catch {unset a}; catch {unset b}; catch {unset c}; catch {unset d}
- set a 44
- set b 55
- set c 66
- set d 77
- unset a b c
- list [catch {set a(0) 0}] [catch {set b(0) 0}] [catch {set c(0) 0}] \
- [catch {set d(0) 0}]
-} {0 0 0 1}
-test set-old-7.2 {unset command} {
- list [catch {unset} msg] $msg
-} {1 {wrong # args: should be "unset varName ?varName ...?"}}
-test set-old-7.3 {unset command} {
- catch {unset a}
- list [catch {unset a} msg] $msg
-} {1 {can't unset "a": no such variable}}
-test set-old-7.4 {unset command} {
- catch {unset a}
- set a 44
- list [catch {unset a(14)} msg] $msg
-} {1 {can't unset "a(14)": variable isn't array}}
-test set-old-7.5 {unset command} {
- catch {unset a}
- set a(0) xx
- list [catch {unset a(14)} msg] $msg
-} {1 {can't unset "a(14)": no such element in array}}
-test set-old-7.6 {unset command} {
- catch {unset a}; catch {unset b}; catch {unset c}
- set a foo
- set c gorp
- list [catch {unset a a a(14)} msg] $msg [info exists c]
-} {1 {can't unset "a": no such variable} 1}
-test set-old-7.7 {unsetting globals from within procedures} {
- set y 0
- proc p1 {} {
- global y
- set z [p2]
- return [list $z [catch {set y} msg] $msg]
- }
- proc p2 {} {global y; unset y; list [catch {set y} msg] $msg}
- p1
-} {{1 {can't read "y": no such variable}} 1 {can't read "y": no such variable}}
-test set-old-7.8 {unsetting globals from within procedures} {
- set y 0
- proc p1 {} {
- global y
- p2
- return [list [catch {set y 44} msg] $msg]
- }
- proc p2 {} {global y; unset y}
- concat [p1] [list [catch {set y} msg] $msg]
-} {0 44 0 44}
-test set-old-7.9 {unsetting globals from within procedures} {
- set y 0
- proc p1 {} {
- global y
- unset y
- return [list [catch {set y 55} msg] $msg]
- }
- concat [p1] [list [catch {set y} msg] $msg]
-} {0 55 0 55}
-test set-old-7.10 {unset command} {
- catch {unset a}
- set a(14) 22
- unset a(14)
- list [catch {set a(14)} msg] $msg [catch {array names a} msg2] $msg2
-} {1 {can't read "a(14)": no such element in array} 0 {}}
-test set-old-7.11 {unset command} {
- catch {unset a}
- set a(14) 22
- unset a
- list [catch {set a(14)} msg] $msg [catch {array names a} msg2] $msg2
-} {1 {can't read "a(14)": no such variable} 0 {}}
-
-# Array command.
-
-test set-old-8.1 {array command} {
- list [catch {array} msg] $msg
-} {1 {wrong # args: should be "array option arrayName ?arg ...?"}}
-test set-old-8.2 {array command} {
- list [catch {array a} msg] $msg
-} {1 {wrong # args: should be "array option arrayName ?arg ...?"}}
-test set-old-8.3 {array command} {
- catch {unset a}
- list [catch {array anymore a b} msg] $msg
-} {1 {"a" isn't an array}}
-test set-old-8.4 {array command} {
- catch {unset a}
- set a 44
- list [catch {array anymore a b} msg] $msg
-} {1 {"a" isn't an array}}
-test set-old-8.5 {array command} {
- proc foo {} {
- set a 44
- upvar 0 a x
- list [catch {array anymore x b} msg] $msg
- }
- foo
-} {1 {"x" isn't an array}}
-test set-old-8.6 {array command} {
- catch {unset a}
- set a(22) 3
- list [catch {array gorp a} msg] $msg
-} {1 {bad option "gorp": must be anymore, donesearch, exists, get, names, nextelement, set, size, or startsearch}}
-test set-old-8.7 {array command, anymore option} {
- catch {unset a}
- list [catch {array anymore a x} msg] $msg
-} {1 {"a" isn't an array}}
-test set-old-8.8 {array command, anymore option, array doesn't exist yet but has compiler-allocated procedure slot} {
- proc foo {x} {
- if {$x==1} {
- return [array anymore a x]
- }
- set a(x) 123
- }
- list [catch {foo 1} msg] $msg
-} {1 {"a" isn't an array}}
-test set-old-8.9 {array command, donesearch option} {
- catch {unset a}
- list [catch {array donesearch a x} msg] $msg
-} {1 {"a" isn't an array}}
-test set-old-8.10 {array command, donesearch option, array doesn't exist yet but has compiler-allocated procedure slot} {
- proc foo {x} {
- if {$x==1} {
- return [array donesearch a x]
- }
- set a(x) 123
- }
- list [catch {foo 1} msg] $msg
-} {1 {"a" isn't an array}}
-test set-old-8.11 {array command, exists option} {
- list [catch {array exists a b} msg] $msg
-} {1 {wrong # args: should be "array exists arrayName"}}
-test set-old-8.12 {array command, exists option} {
- catch {unset a}
- array exists a
-} {0}
-test set-old-8.13 {array command, exists option} {
- catch {unset a}
- set a(0) 1
- array exists a
-} {1}
-test set-old-8.14 {array command, exists option, array doesn't exist yet but has compiler-allocated procedure slot} {
- proc foo {x} {
- if {$x==1} {
- return [array exists a]
- }
- set a(x) 123
- }
- list [catch {foo 1} msg] $msg
-} {0 0}
-test set-old-8.15 {array command, get option} {
- list [catch {array get} msg] $msg
-} {1 {wrong # args: should be "array option arrayName ?arg ...?"}}
-test set-old-8.16 {array command, get option} {
- list [catch {array get a b c} msg] $msg
-} {1 {wrong # args: should be "array get arrayName ?pattern?"}}
-test set-old-8.17 {array command, get option} {
- catch {unset a}
- array get a
-} {}
-test set-old-8.18 {array command, get option} {
- catch {unset a}
- set a(22) 3
- set {a(long name)} {}
- array get a
-} {22 3 {long name} {}}
-test set-old-8.19 {array command, get option (unset variable)} {
- catch {unset a}
- set a(x) 3
- trace var a(y) w ignore
- array get a
-} {x 3}
-test set-old-8.20 {array command, get option, with pattern} {
- catch {unset a}
- set a(x1) 3
- set a(x2) 4
- set a(x3) 5
- set a(b1) 24
- set a(b2) 25
- array get a x*
-} {x1 3 x2 4 x3 5}
-test set-old-8.21 {array command, get option, array doesn't exist yet but has compiler-allocated procedure slot} {
- proc foo {x} {
- if {$x==1} {
- return [array get a]
- }
- set a(x) 123
- }
- list [catch {foo 1} msg] $msg
-} {0 {}}
-test set-old-8.22 {array command, names option} {
- catch {unset a}
- set a(22) 3
- list [catch {array names a 4 5} msg] $msg
-} {1 {wrong # args: should be "array names arrayName ?pattern?"}}
-test set-old-8.19 {array command, names option} {
- catch {unset a}
- array names a
-} {}
-test set-old-8.23 {array command, names option} {
- catch {unset a}
- set a(22) 3; set a(Textual_name) 44; set "a(name with spaces)" xxx
- list [catch {lsort [array names a]} msg] $msg
-} {0 {22 Textual_name {name with spaces}}}
-test set-old-8.24 {array command, names option} {
- catch {unset a}
- set a(22) 3; set a(33) 44;
- trace var a(xxx) w ignore
- list [catch {lsort [array names a]} msg] $msg
-} {0 {22 33}}
-test set-old-8.25 {array command, names option} {
- catch {unset a}
- set a(22) 3; set a(33) 44;
- trace var a(xxx) w ignore
- set a(xxx) value
- list [catch {lsort [array names a]} msg] $msg
-} {0 {22 33 xxx}}
-test set-old-8.26 {array command, names option} {
- catch {unset a}
- set a(axy) 3
- set a(bxy) 44
- set a(no) yes
- set a(xxx) value
- list [lsort [array names a *xy]] [lsort [array names a]]
-} {{axy bxy} {axy bxy no xxx}}
-test set-old-8.27 {array command, names option, array doesn't exist yet but has compiler-allocated procedure slot} {
- proc foo {x} {
- if {$x==1} {
- return [array names a]
- }
- set a(x) 123
- }
- list [catch {foo 1} msg] $msg
-} {0 {}}
-test set-old-8.28 {array command, nextelement option} {
- list [catch {array nextelement a} msg] $msg
-} {1 {wrong # args: should be "array nextelement arrayName searchId"}}
-test set-old-8.29 {array command, nextelement option} {
- catch {unset a}
- list [catch {array nextelement a b} msg] $msg
-} {1 {"a" isn't an array}}
-test set-old-8.30 {array command, nextelement option, array doesn't exist yet but has compiler-allocated procedure slot} {
- proc foo {x} {
- if {$x==1} {
- return [array nextelement a b]
- }
- set a(x) 123
- }
- list [catch {foo 1} msg] $msg
-} {1 {"a" isn't an array}}
-test set-old-8.31 {array command, set option} {
- list [catch {array set a} msg] $msg
-} {1 {wrong # args: should be "array set arrayName list"}}
-test set-old-8.32 {array command, set option} {
- list [catch {array set a 1 2} msg] $msg
-} {1 {wrong # args: should be "array set arrayName list"}}
-test set-old-8.33 {array command, set option} {
- list [catch {array set a "a \{ c"} msg] $msg
-} {1 {unmatched open brace in list}}
-test set-old-8.34 {array command, set option} {
- catch {unset a}
- set a 44
- list [catch {array set a {a b c d}} msg] $msg
-} {1 {can't set "a(a)": variable isn't array}}
-test set-old-8.35 {array command, set option} {
- catch {unset a}
- set a(xx) yy
- array set a {b c d e}
- array get a
-} {d e xx yy b c}
-test set-old-8.36 {array command, set option, array doesn't exist yet but has compiler-allocated procedure slot} {
- proc foo {x} {
- if {$x==1} {
- return [array set a {x 0}]
- }
- set a(x)
- }
- list [catch {foo 1} msg] $msg
-} {0 {}}
-test set-old-8.37 {array command, set option} {
- catch {unset aVaRnAmE}
- array set aVaRnAmE {}
- list [info exists aVaRnAmE] [catch {set aVaRnAmE} msg] $msg
-} {1 1 {can't read "aVaRnAmE": variable is array}}
-test set-old-8.37.1 {array command, set scalar} {
- catch {unset aVaRnAmE}
- set aVaRnAmE 1
- list [catch {array set aVaRnAmE {}} msg] $msg
-} {1 {can't array set "aVaRnAmE": variable isn't array}}
-test set-old-8.37.2 {array command, set alias} {
- catch {unset aVaRnAmE}
- upvar 0 aVaRnAmE anAliAs
- array set anAliAs {}
- list [array exists aVaRnAmE] [catch {set anAliAs} msg] $msg
-} {1 1 {can't read "anAliAs": variable is array}}
-test set-old-8.37.3 {array command, set element alias} {
- catch {unset aVaRnAmE}
- list [catch {upvar 0 aVaRnAmE(elem) elemAliAs}] \
- [catch {array set elemAliAs {}} msg] $msg
-} {0 1 {can't array set "elemAliAs": variable isn't array}}
-test set-old-8.37.4 {array command, empty set with populated array} {
- catch {unset aVaRnAmE}
- array set aVaRnAmE [list e1 v1 e2 v2]
- array set aVaRnAmE {}
- array set aVaRnAmE [list e3 v3]
- list [lsort [array names aVaRnAmE]] [catch {set aVaRnAmE(e2)} msg] $msg
-} {{e1 e2 e3} 0 v2}
-test set-old-8.38 {array command, size option} {
- catch {unset a}
- array size a
-} {0}
-test set-old-8.39 {array command, size option} {
- list [catch {array size a 4} msg] $msg
-} {1 {wrong # args: should be "array size arrayName"}}
-test set-old-8.40 {array command, size option} {
- catch {unset a}
- array size a
-} {0}
-test set-old-8.41 {array command, size option} {
- catch {unset a}
- set a(22) 3; set a(Textual_name) 44; set "a(name with spaces)" xxx
- list [catch {array size a} msg] $msg
-} {0 3}
-test set-old-8.42 {array command, size option} {
- catch {unset a}
- set a(22) 3; set a(xx) 44; set a(y) xxx
- unset a(22) a(y) a(xx)
- list [catch {array size a} msg] $msg
-} {0 0}
-test set-old-8.43 {array command, size option} {
- catch {unset a}
- set a(22) 3;
- trace var a(33) rwu ignore
- list [catch {array size a} msg] $msg
-} {0 1}
-test set-old-8.44 {array command, size option, array doesn't exist yet but has compiler-allocated procedure slot} {
- proc foo {x} {
- if {$x==1} {
- return [array size a]
- }
- set a(x) 123
- }
- list [catch {foo 1} msg] $msg
-} {0 0}
-test set-old-8.45 {array command, startsearch option} {
- list [catch {array startsearch a b} msg] $msg
-} {1 {wrong # args: should be "array startsearch arrayName"}}
-test set-old-8.46 {array command, startsearch option} {
- catch {unset a}
- list [catch {array startsearch a} msg] $msg
-} {1 {"a" isn't an array}}
-test set-old-8.47 {array command, startsearch option, array doesn't exist yet but has compiler-allocated procedure slot} {
- catch {rename p ""}
- proc p {x} {
- if {$x==1} {
- return [array startsearch a]
- }
- set a(x) 123
- }
- list [catch {p 1} msg] $msg
-} {1 {"a" isn't an array}}
-
-test set-old-9.1 {ids for array enumeration} {
- catch {unset a}
- set a(a) 1
- list [array st a] [array st a] [array done a s-1-a; array st a] \
- [array done a s-2-a; array d a s-3-a; array start a]
-} {s-1-a s-2-a s-3-a s-1-a}
-test set-old-9.2 {array enumeration} {
- catch {unset a}
- set a(a) 1
- set a(b) 1
- set a(c) 1
- set x [array startsearch a]
- list [array nextelement a $x] [array ne a $x] [array next a $x] \
- [array next a $x] [array next a $x]
-} {a b c {} {}}
-test set-old-9.3 {array enumeration} {
- catch {unset a}
- set a(a) 1
- set a(b) 1
- set a(c) 1
- set x [array startsearch a]
- set y [array startsearch a]
- set z [array startsearch a]
- list [array nextelement a $x] [array ne a $x] \
- [array next a $y] [array next a $z] [array next a $y] \
- [array next a $z] [array next a $y] [array next a $z] \
- [array next a $y] [array next a $z] [array next a $x] \
- [array next a $x]
-} {a b a a b b c c {} {} c {}}
-test set-old-9.4 {array enumeration: stopping searches} {
- catch {unset a}
- set a(a) 1
- set a(b) 1
- set a(c) 1
- set x [array startsearch a]
- set y [array startsearch a]
- set z [array startsearch a]
- list [array next a $x] [array next a $x] [array next a $y] \
- [array done a $z; array next a $x] \
- [array done a $x; array next a $y] [array next a $y]
-} {a b a c b c}
-test set-old-9.5 {array enumeration: stopping searches} {
- catch {unset a}
- set a(a) 1
- set x [array startsearch a]
- array done a $x
- list [catch {array next a $x} msg] $msg
-} {1 {couldn't find search "s-1-a"}}
-test set-old-9.6 {array enumeration: searches automatically stopped} {
- catch {unset a}
- set a(a) 1
- set x [array startsearch a]
- set y [array startsearch a]
- set a(b) 1
- list [catch {array next a $x} msg] $msg \
- [catch {array next a $y} msg2] $msg2
-} {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}
-test set-old-9.7 {array enumeration: searches automatically stopped} {
- catch {unset a}
- set a(a) 1
- set x [array startsearch a]
- set y [array startsearch a]
- set a(a) 2
- list [catch {array next a $x} msg] $msg \
- [catch {array next a $y} msg2] $msg2
-} {0 a 0 a}
-test set-old-9.8 {array enumeration: searches automatically stopped} {
- catch {unset a}
- set a(a) 1
- set a(c) 2
- set x [array startsearch a]
- set y [array startsearch a]
- catch {unset a(c)}
- list [catch {array next a $x} msg] $msg \
- [catch {array next a $y} msg2] $msg2
-} {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}
-test set-old-9.9 {array enumeration: searches automatically stopped} {
- catch {unset a}
- set a(a) 1
- set x [array startsearch a]
- set y [array startsearch a]
- catch {unset a(c)}
- list [catch {array next a $x} msg] $msg \
- [catch {array next a $y} msg2] $msg2
-} {0 a 0 a}
-test set-old-9.10 {array enumeration: searches automatically stopped} {
- catch {unset a}
- set a(a) 1
- set x [array startsearch a]
- set y [array startsearch a]
- trace var a(b) r {}
- list [catch {array next a $x} msg] $msg \
- [catch {array next a $y} msg2] $msg2
-} {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}
-test set-old-9.11 {array enumeration: searches automatically stopped} {
- catch {unset a}
- set a(a) 1
- set x [array startsearch a]
- set y [array startsearch a]
- trace var a(a) r {}
- list [catch {array next a $x} msg] $msg \
- [catch {array next a $y} msg2] $msg2
-} {0 a 0 a}
-test set-old-9.12 {array enumeration with traced undefined elements} {
- catch {unset a}
- set a(a) 1
- trace var a(b) r {}
- set x [array startsearch a]
- list [array next a $x] [array next a $x]
-} {a {}}
-
-test set-old-10.1 {array enumeration errors} {
- list [catch {array start} msg] $msg
-} {1 {wrong # args: should be "array option arrayName ?arg ...?"}}
-test set-old-10.2 {array enumeration errors} {
- list [catch {array start a b} msg] $msg
-} {1 {wrong # args: should be "array startsearch arrayName"}}
-test set-old-10.3 {array enumeration errors} {
- catch {unset a}
- list [catch {array start a} msg] $msg
-} {1 {"a" isn't an array}}
-test set-old-10.4 {array enumeration errors} {
- catch {unset a}
- set a(a) 1
- set x [array startsearch a]
- list [catch {array next a} msg] $msg
-} {1 {wrong # args: should be "array nextelement arrayName searchId"}}
-test set-old-10.5 {array enumeration errors} {
- catch {unset a}
- set a(a) 1
- set x [array startsearch a]
- list [catch {array next a b c} msg] $msg
-} {1 {wrong # args: should be "array nextelement arrayName searchId"}}
-test set-old-10.6 {array enumeration errors} {
- catch {unset a}
- set a(a) 1
- set x [array startsearch a]
- list [catch {array next a a-1-a} msg] $msg
-} {1 {illegal search identifier "a-1-a"}}
-test set-old-10.7 {array enumeration errors} {
- catch {unset a}
- set a(a) 1
- set x [array startsearch a]
- list [catch {array next a sx1-a} msg] $msg
-} {1 {illegal search identifier "sx1-a"}}
-test set-old-10.8 {array enumeration errors} {
- catch {unset a}
- set a(a) 1
- set x [array startsearch a]
- list [catch {array next a s--a} msg] $msg
-} {1 {illegal search identifier "s--a"}}
-test set-old-10.9 {array enumeration errors} {
- catch {unset a}
- set a(a) 1
- set x [array startsearch a]
- list [catch {array next a s-1-b} msg] $msg
-} {1 {search identifier "s-1-b" isn't for variable "a"}}
-test set-old-10.10 {array enumeration errors} {
- catch {unset a}
- set a(a) 1
- set x [array startsearch a]
- list [catch {array next a s-1ba} msg] $msg
-} {1 {illegal search identifier "s-1ba"}}
-test set-old-10.11 {array enumeration errors} {
- catch {unset a}
- set a(a) 1
- set x [array startsearch a]
- list [catch {array next a s-2-a} msg] $msg
-} {1 {couldn't find search "s-2-a"}}
-test set-old-10.12 {array enumeration errors} {
- list [catch {array done a} msg] $msg
-} {1 {wrong # args: should be "array donesearch arrayName searchId"}}
-test set-old-10.13 {array enumeration errors} {
- list [catch {array done a b c} msg] $msg
-} {1 {wrong # args: should be "array donesearch arrayName searchId"}}
-test set-old-10.14 {array enumeration errors} {
- list [catch {array done a b} msg] $msg
-} {1 {illegal search identifier "b"}}
-test set-old-10.15 {array enumeration errors} {
- list [catch {array anymore a} msg] $msg
-} {1 {wrong # args: should be "array anymore arrayName searchId"}}
-test set-old-10.16 {array enumeration errors} {
- list [catch {array any a b c} msg] $msg
-} {1 {wrong # args: should be "array anymore arrayName searchId"}}
-test set-old-10.17 {array enumeration errors} {
- catch {unset a}
- set a(0) 44
- list [catch {array any a bogus} msg] $msg
-} {1 {illegal search identifier "bogus"}}
-
-# Array enumeration with "anymore" option
-
-test set-old-11.1 {array anymore option} {
- catch {unset a}
- set a(a) 1
- set a(b) 2
- set a(c) 3
- array startsearch a
- list [array anymore a s-1-a] [array next a s-1-a] \
- [array anymore a s-1-a] [array next a s-1-a] \
- [array anymore a s-1-a] [array next a s-1-a] \
- [array anymore a s-1-a] [array next a s-1-a]
-} {1 a 1 b 1 c 0 {}}
-test set-old-11.2 {array anymore option} {
- catch {unset a}
- set a(a) 1
- set a(b) 2
- set a(c) 3
- array startsearch a
- list [array next a s-1-a] [array next a s-1-a] \
- [array anymore a s-1-a] [array next a s-1-a] \
- [array next a s-1-a] [array anymore a s-1-a]
-} {a b 1 c {} 0}
-
-# Special check to see that the value of a variable is handled correctly
-# if it is returned as the result of a procedure (must not free the variable
-# string while deleting the call frame). Errors will only be detected if
-# a memory consistency checker such as Purify is being used.
-
-test set-old-12.1 {cleanup on procedure return} {
- proc foo {} {
- set x 12345
- }
- foo
-} 12345
-test set-old-12.2 {cleanup on procedure return} {
- proc foo {} {
- set x(1) 23456
- }
- foo
-} 23456
-
-# Must delete variables when done, since these arrays get used as
-# scalars by other tests.
-catch {unset a}
-catch {unset b}
-catch {unset c}
-catch {unset aVaRnAmE}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/set.test b/tests/set.test
deleted file mode 100644
index 7ffeb75..0000000
--- a/tests/set.test
+++ /dev/null
@@ -1,499 +0,0 @@
-# Commands covered: set
-#
-# 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) 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: set.test,v 1.3 1999/04/16 00:47:34 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-catch {unset x}
-catch {unset i}
-
-test set-1.1 {TclCompileSetCmd: missing variable name} {
- list [catch {set} msg] $msg
-} {1 {wrong # args: should be "set varName ?newValue?"}}
-test set-1.2 {TclCompileSetCmd: simple variable name} {
- set i 10
- list [set i] $i
-} {10 10}
-test set-1.3 {TclCompileSetCmd: error compiling variable name} {
- set i 10
- catch {set "i"xxx} msg
- set msg
-} {extra characters after close-quote}
-test set-1.4 {TclCompileSetCmd: simple variable name in quotes} {
- set i 17
- list [set "i"] $i
-} {17 17}
-test set-1.5 {TclCompileSetCmd: simple variable name in braces} {
- catch {unset {a simple var}}
- set {a simple var} 27
- list [set {a simple var}] ${a simple var}
-} {27 27}
-test set-1.6 {TclCompileSetCmd: simple array variable name} {
- catch {unset a}
- set a(foo) 37
- list [set a(foo)] $a(foo)
-} {37 37}
-test set-1.7 {TclCompileSetCmd: non-simple (computed) variable name} {
- set x "i"
- set i 77
- list [set $x] $i
-} {77 77}
-test set-1.8 {TclCompileSetCmd: non-simple (computed) variable name} {
- set x "i"
- set i 77
- list [set [set x] 2] $i
-} {2 2}
-
-test set-1.9 {TclCompileSetCmd: 3rd arg => assignment} {
- set i "abcdef"
- list [set i] $i
-} {abcdef abcdef}
-test set-1.10 {TclCompileSetCmd: only two args => just getting value} {
- set i {one two}
- set i
-} {one two}
-
-test set-1.11 {TclCompileSetCmd: simple global name} {
- proc p {} {
- global i
- set i 54
- set i
- }
- p
-} {54}
-test set-1.12 {TclCompileSetCmd: simple local name} {
- proc p {bar} {
- set foo $bar
- set foo
- }
- p 999
-} {999}
-test set-1.13 {TclCompileSetCmd: simple but new (unknown) local name} {
- proc p {} {
- set bar
- }
- catch {p} msg
- set msg
-} {can't read "bar": no such variable}
-test set-1.14 {TclCompileSetCmd: simple local name, >255 locals} {
- proc 260locals {} {
- # create 260 locals (the last ones with index > 255)
- set a0 0; set a1 0; set a2 0; set a3 0; set a4 0
- set a5 0; set a6 0; set a7 0; set a8 0; set a9 0
- set b0 0; set b1 0; set b2 0; set b3 0; set b4 0
- set b5 0; set b6 0; set b7 0; set b8 0; set b9 0
- set c0 0; set c1 0; set c2 0; set c3 0; set c4 0
- set c5 0; set c6 0; set c7 0; set c8 0; set c9 0
- set d0 0; set d1 0; set d2 0; set d3 0; set d4 0
- set d5 0; set d6 0; set d7 0; set d8 0; set d9 0
- set e0 0; set e1 0; set e2 0; set e3 0; set e4 0
- set e5 0; set e6 0; set e7 0; set e8 0; set e9 0
- set f0 0; set f1 0; set f2 0; set f3 0; set f4 0
- set f5 0; set f6 0; set f7 0; set f8 0; set f9 0
- set g0 0; set g1 0; set g2 0; set g3 0; set g4 0
- set g5 0; set g6 0; set g7 0; set g8 0; set g9 0
- set h0 0; set h1 0; set h2 0; set h3 0; set h4 0
- set h5 0; set h6 0; set h7 0; set h8 0; set h9 0
- set i0 0; set i1 0; set i2 0; set i3 0; set i4 0
- set i5 0; set i6 0; set i7 0; set i8 0; set i9 0
- set j0 0; set j1 0; set j2 0; set j3 0; set j4 0
- set j5 0; set j6 0; set j7 0; set j8 0; set j9 0
- set k0 0; set k1 0; set k2 0; set k3 0; set k4 0
- set k5 0; set k6 0; set k7 0; set k8 0; set k9 0
- set l0 0; set l1 0; set l2 0; set l3 0; set l4 0
- set l5 0; set l6 0; set l7 0; set l8 0; set l9 0
- set m0 0; set m1 0; set m2 0; set m3 0; set m4 0
- set m5 0; set m6 0; set m7 0; set m8 0; set m9 0
- set n0 0; set n1 0; set n2 0; set n3 0; set n4 0
- set n5 0; set n6 0; set n7 0; set n8 0; set n9 0
- set o0 0; set o1 0; set o2 0; set o3 0; set o4 0
- set o5 0; set o6 0; set o7 0; set o8 0; set o9 0
- set p0 0; set p1 0; set p2 0; set p3 0; set p4 0
- set p5 0; set p6 0; set p7 0; set p8 0; set p9 0
- set q0 0; set q1 0; set q2 0; set q3 0; set q4 0
- set q5 0; set q6 0; set q7 0; set q8 0; set q9 0
- set r0 0; set r1 0; set r2 0; set r3 0; set r4 0
- set r5 0; set r6 0; set r7 0; set r8 0; set r9 0
- set s0 0; set s1 0; set s2 0; set s3 0; set s4 0
- set s5 0; set s6 0; set s7 0; set s8 0; set s9 0
- set t0 0; set t1 0; set t2 0; set t3 0; set t4 0
- set t5 0; set t6 0; set t7 0; set t8 0; set t9 0
- set u0 0; set u1 0; set u2 0; set u3 0; set u4 0
- set u5 0; set u6 0; set u7 0; set u8 0; set u9 0
- set v0 0; set v1 0; set v2 0; set v3 0; set v4 0
- set v5 0; set v6 0; set v7 0; set v8 0; set v9 0
- set w0 0; set w1 0; set w2 0; set w3 0; set w4 0
- set w5 0; set w6 0; set w7 0; set w8 0; set w9 0
- set x0 0; set x1 0; set x2 0; set x3 0; set x4 0
- set x5 0; set x6 0; set x7 0; set x8 0; set x9 0
- set y0 0; set y1 0; set y2 0; set y3 0; set y4 0
- set y5 0; set y6 0; set y7 0; set y8 0; set y9 0
- set z0 0; set z1 0; set z2 0; set z3 0; set z4 0
- set z5 0; set z6 0; set z7 0; set z8 0; set z9 1234
- }
- 260locals
-} {1234}
-test set-1.15 {TclCompileSetCmd: variable is array} {
- catch {unset a}
- set x 27
- set x [set a(foo) 11]
- catch {unset a}
- set x
-} 11
-test set-1.16 {TclCompileSetCmd: variable is array, elem substitutions} {
- catch {unset a}
- set i 5
- set x 789
- set a(foo5) 27
- set x [set a(foo$i)]
- catch {unset a}
- set x
-} 27
-
-test set-1.17 {TclCompileSetCmd: doing assignment, simple int} {
- set i 5
- set i 123
-} 123
-test set-1.18 {TclCompileSetCmd: doing assignment, simple int} {
- set i 5
- set i -100
-} -100
-test set-1.19 {TclCompileSetCmd: doing assignment, simple but not int} {
- set i 5
- set i 0x12MNOP
- set i
-} {0x12MNOP}
-test set-1.20 {TclCompileSetCmd: doing assignment, in quotes} {
- set i 25
- set i "-100"
-} -100
-test set-1.21 {TclCompileSetCmd: doing assignment, in braces} {
- set i 24
- set i {126}
-} 126
-test set-1.22 {TclCompileSetCmd: doing assignment, large int} {
- set i 5
- set i 200000
-} 200000
-test set-1.23 {TclCompileSetCmd: doing assignment, formatted int != int} {
- set i 25
- set i 000012345 ;# an octal literal == 5349 decimal
- list $i [incr i]
-} {000012345 5350}
-
-test set-1.24 {TclCompileSetCmd: too many arguments} {
- set i 10
- catch {set i 20 30} msg
- set msg
-} {wrong # args: should be "set varName ?newValue?"}
-
-test set-2.1 {set command: runtime error, bad variable name} {
- list [catch {set {"foo}} msg] $msg $errorInfo
-} {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable
- while executing
-"set {"foo}"}}
-test set-2.2 {set command: runtime error, not array variable} {
- catch {unset b}
- set b 44
- list [catch {set b(123)} msg] $msg
-} {1 {can't read "b(123)": variable isn't array}}
-test set-2.3 {set command: runtime error, errors in reading variables} {
- catch {unset a}
- set a(6) 44
- list [catch {set a(18)} msg] $msg
-} {1 {can't read "a(18)": no such element in array}}
-test set-2.4 {set command: runtime error, readonly variable} {
- proc readonly args {error "variable is read-only"}
- set x 123
- trace var x w readonly
- list [catch {set x 1} msg] $msg $errorInfo
-} {1 {can't set "x": variable is read-only} {can't set "x": variable is read-only
- while executing
-"set x 1"}}
-test set-2.5 {set command: runtime error, basic array operations} {
- list [catch {set a(other)} msg] $msg
-} {1 {can't read "a(other)": no such element in array}}
-test set-2.6 {set command: runtime error, basic array operations} {
- list [catch {set a} msg] $msg
-} {1 {can't read "a": variable is array}}
-
-# Test the uncompiled version of set
-
-catch {unset a}
-catch {unset b}
-catch {unset i}
-catch {unset x}
-
-test set-3.1 {uncompiled set command: missing variable name} {
- set z set
- list [catch {$z} msg] $msg
-} {1 {wrong # args: should be "set varName ?newValue?"}}
-test set-3.2 {uncompiled set command: simple variable name} {
- set z set
- $z i 10
- list [$z i] $i
-} {10 10}
-test set-3.3 {uncompiled set command: error compiling variable name} {
- set z set
- $z i 10
- catch {$z "i"xxx} msg
- $z msg
-} {extra characters after close-quote}
-test set-3.4 {uncompiled set command: simple variable name in quotes} {
- set z set
- $z i 17
- list [$z "i"] $i
-} {17 17}
-test set-3.5 {uncompiled set command: simple variable name in braces} {
- set z set
- catch {unset {a simple var}}
- $z {a simple var} 27
- list [$z {a simple var}] ${a simple var}
-} {27 27}
-test set-3.6 {uncompiled set command: simple array variable name} {
- set z set
- catch {unset a}
- $z a(foo) 37
- list [$z a(foo)] $a(foo)
-} {37 37}
-test set-3.7 {uncompiled set command: non-simple (computed) variable name} {
- set z set
- $z x "i"
- $z i 77
- list [$z $x] $i
-} {77 77}
-test set-3.8 {uncompiled set command: non-simple (computed) variable name} {
- set z set
- $z x "i"
- $z i 77
- list [$z [$z x] 2] $i
-} {2 2}
-
-test set-3.9 {uncompiled set command: 3rd arg => assignment} {
- set z set
- $z i "abcdef"
- list [$z i] $i
-} {abcdef abcdef}
-test set-3.10 {uncompiled set command: only two args => just getting value} {
- set z set
- $z i {one two}
- $z i
-} {one two}
-
-test set-3.11 {uncompiled set command: simple global name} {
- proc p {} {
- set z set
- global i
- $z i 54
- $z i
- }
- p
-} {54}
-test set-3.12 {uncompiled set command: simple local name} {
- proc p {bar} {
- set z set
- $z foo $bar
- $z foo
- }
- p 999
-} {999}
-test set-3.13 {uncompiled set command: simple but new (unknown) local name} {
- set z set
- proc p {} {
- set z set
- $z bar
- }
- catch {p} msg
- $z msg
-} {can't read "bar": no such variable}
-test set-3.14 {uncompiled set command: simple local name, >255 locals} {
- proc 260locals {} {
- set z set
- # create 260 locals (the last ones with index > 255)
- $z a0 0; $z a1 0; $z a2 0; $z a3 0; $z a4 0
- $z a5 0; $z a6 0; $z a7 0; $z a8 0; $z a9 0
- $z b0 0; $z b1 0; $z b2 0; $z b3 0; $z b4 0
- $z b5 0; $z b6 0; $z b7 0; $z b8 0; $z b9 0
- $z c0 0; $z c1 0; $z c2 0; $z c3 0; $z c4 0
- $z c5 0; $z c6 0; $z c7 0; $z c8 0; $z c9 0
- $z d0 0; $z d1 0; $z d2 0; $z d3 0; $z d4 0
- $z d5 0; $z d6 0; $z d7 0; $z d8 0; $z d9 0
- $z e0 0; $z e1 0; $z e2 0; $z e3 0; $z e4 0
- $z e5 0; $z e6 0; $z e7 0; $z e8 0; $z e9 0
- $z f0 0; $z f1 0; $z f2 0; $z f3 0; $z f4 0
- $z f5 0; $z f6 0; $z f7 0; $z f8 0; $z f9 0
- $z g0 0; $z g1 0; $z g2 0; $z g3 0; $z g4 0
- $z g5 0; $z g6 0; $z g7 0; $z g8 0; $z g9 0
- $z h0 0; $z h1 0; $z h2 0; $z h3 0; $z h4 0
- $z h5 0; $z h6 0; $z h7 0; $z h8 0; $z h9 0
- $z i0 0; $z i1 0; $z i2 0; $z i3 0; $z i4 0
- $z i5 0; $z i6 0; $z i7 0; $z i8 0; $z i9 0
- $z j0 0; $z j1 0; $z j2 0; $z j3 0; $z j4 0
- $z j5 0; $z j6 0; $z j7 0; $z j8 0; $z j9 0
- $z k0 0; $z k1 0; $z k2 0; $z k3 0; $z k4 0
- $z k5 0; $z k6 0; $z k7 0; $z k8 0; $z k9 0
- $z l0 0; $z l1 0; $z l2 0; $z l3 0; $z l4 0
- $z l5 0; $z l6 0; $z l7 0; $z l8 0; $z l9 0
- $z m0 0; $z m1 0; $z m2 0; $z m3 0; $z m4 0
- $z m5 0; $z m6 0; $z m7 0; $z m8 0; $z m9 0
- $z n0 0; $z n1 0; $z n2 0; $z n3 0; $z n4 0
- $z n5 0; $z n6 0; $z n7 0; $z n8 0; $z n9 0
- $z o0 0; $z o1 0; $z o2 0; $z o3 0; $z o4 0
- $z o5 0; $z o6 0; $z o7 0; $z o8 0; $z o9 0
- $z p0 0; $z p1 0; $z p2 0; $z p3 0; $z p4 0
- $z p5 0; $z p6 0; $z p7 0; $z p8 0; $z p9 0
- $z q0 0; $z q1 0; $z q2 0; $z q3 0; $z q4 0
- $z q5 0; $z q6 0; $z q7 0; $z q8 0; $z q9 0
- $z r0 0; $z r1 0; $z r2 0; $z r3 0; $z r4 0
- $z r5 0; $z r6 0; $z r7 0; $z r8 0; $z r9 0
- $z s0 0; $z s1 0; $z s2 0; $z s3 0; $z s4 0
- $z s5 0; $z s6 0; $z s7 0; $z s8 0; $z s9 0
- $z t0 0; $z t1 0; $z t2 0; $z t3 0; $z t4 0
- $z t5 0; $z t6 0; $z t7 0; $z t8 0; $z t9 0
- $z u0 0; $z u1 0; $z u2 0; $z u3 0; $z u4 0
- $z u5 0; $z u6 0; $z u7 0; $z u8 0; $z u9 0
- $z v0 0; $z v1 0; $z v2 0; $z v3 0; $z v4 0
- $z v5 0; $z v6 0; $z v7 0; $z v8 0; $z v9 0
- $z w0 0; $z w1 0; $z w2 0; $z w3 0; $z w4 0
- $z w5 0; $z w6 0; $z w7 0; $z w8 0; $z w9 0
- $z x0 0; $z x1 0; $z x2 0; $z x3 0; $z x4 0
- $z x5 0; $z x6 0; $z x7 0; $z x8 0; $z x9 0
- $z y0 0; $z y1 0; $z y2 0; $z y3 0; $z y4 0
- $z y5 0; $z y6 0; $z y7 0; $z y8 0; $z y9 0
- $z z0 0; $z z1 0; $z z2 0; $z z3 0; $z z4 0
- $z z5 0; $z z6 0; $z z7 0; $z z8 0; $z z9 1234
- }
- 260locals
-} {1234}
-test set-3.15 {uncompiled set command: variable is array} {
- set z set
- catch {unset a}
- $z x 27
- $z x [$z a(foo) 11]
- catch {unset a}
- $z x
-} 11
-test set-3.16 {uncompiled set command: variable is array, elem substitutions} {
- set z set
- catch {unset a}
- $z i 5
- $z x 789
- $z a(foo5) 27
- $z x [$z a(foo$i)]
- catch {unset a}
- $z x
-} 27
-
-test set-3.17 {uncompiled set command: doing assignment, simple int} {
- set z set
- $z i 5
- $z i 123
-} 123
-test set-3.18 {uncompiled set command: doing assignment, simple int} {
- set z set
- $z i 5
- $z i -100
-} -100
-test set-3.19 {uncompiled set command: doing assignment, simple but not int} {
- set z set
- $z i 5
- $z i 0x12MNOP
- $z i
-} {0x12MNOP}
-test set-3.20 {uncompiled set command: doing assignment, in quotes} {
- set z set
- $z i 25
- $z i "-100"
-} -100
-test set-3.21 {uncompiled set command: doing assignment, in braces} {
- set z set
- $z i 24
- $z i {126}
-} 126
-test set-3.22 {uncompiled set command: doing assignment, large int} {
- set z set
- $z i 5
- $z i 200000
-} 200000
-test set-3.23 {uncompiled set command: doing assignment, formatted int != int} {
- set z set
- $z i 25
- $z i 000012345 ;# an octal literal == 5349 decimal
- list $i [incr i]
-} {000012345 5350}
-
-test set-3.24 {uncompiled set command: too many arguments} {
- set z set
- $z i 10
- catch {$z i 20 30} msg
- $z msg
-} {wrong # args: should be "set varName ?newValue?"}
-
-test set-4.1 {uncompiled set command: runtime error, bad variable name} {
- set z set
- list [catch {$z {"foo}} msg] $msg $errorInfo
-} {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable
- while executing
-"$z {"foo}"}}
-test set-4.2 {uncompiled set command: runtime error, not array variable} {
- set z set
- catch {unset b}
- $z b 44
- list [catch {$z b(123)} msg] $msg
-} {1 {can't read "b(123)": variable isn't array}}
-test set-4.3 {uncompiled set command: runtime error, errors in reading variables} {
- set z set
- catch {unset a}
- $z a(6) 44
- list [catch {$z a(18)} msg] $msg
-} {1 {can't read "a(18)": no such element in array}}
-test set-4.4 {uncompiled set command: runtime error, readonly variable} {
- set z set
- proc readonly args {error "variable is read-only"}
- $z x 123
- trace var x w readonly
- list [catch {$z x 1} msg] $msg $errorInfo
-} {1 {can't set "x": variable is read-only} {can't set "x": variable is read-only
- while executing
-"$z x 1"}}
-test set-4.5 {uncompiled set command: runtime error, basic array operations} {
- set z set
- list [catch {$z a(other)} msg] $msg
-} {1 {can't read "a(other)": no such element in array}}
-test set-4.6 {set command: runtime error, basic array operations} {
- set z set
- list [catch {$z a} msg] $msg
-} {1 {can't read "a": variable is array}}
-
-# cleanup
-catch {unset a}
-catch {unset b}
-catch {unset i}
-catch {unset x}
-catch {unset z}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/socket.test b/tests/socket.test
deleted file mode 100644
index 249dc5e..0000000
--- a/tests/socket.test
+++ /dev/null
@@ -1,1669 +0,0 @@
-# Commands tested in this file: socket.
-#
-# 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) 1994-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: socket.test,v 1.7 1999/04/16 00:47:34 stanton Exp $
-
-# Running socket tests with a remote server:
-# ------------------------------------------
-#
-# Some tests in socket.test depend on the existence of a remote server to
-# which they connect. The remote server must be an instance of tcltest and it
-# must run the script found in the file "remote.tcl" in this directory. You
-# can start the remote server on any machine reachable from the machine on
-# which you want to run the socket tests, by issuing:
-#
-# tcltest remote.tcl -port 2048 # Or choose another port number.
-#
-# If the machine you are running the remote server on has several IP
-# interfaces, you can choose which interface the server listens on for
-# connections by specifying the -address command line flag, so:
-#
-# tcltest remote.tcl -address your.machine.com
-#
-# These options can also be set by environment variables. On Unix, you can
-# type these commands to the shell from which the remote server is started:
-#
-# shell% setenv serverPort 2048
-# shell% setenv serverAddress your.machine.com
-#
-# and subsequently you can start the remote server with:
-#
-# tcltest remote.tcl
-#
-# to have it listen on port 2048 on the interface your.machine.com.
-#
-# When the server starts, it prints out a detailed message containing its
-# configuration information, and it will block until killed with a Ctrl-C.
-# Once the remote server exists, you can run the tests in socket.test with
-# the server by setting two Tcl variables:
-#
-# % set remoteServerIP <name or address of machine on which server runs>
-# % set remoteServerPort 2048
-#
-# These variables are also settable from the environment. On Unix, you can:
-#
-# shell% setenv remoteServerIP machine.where.server.runs
-# shell% senetv remoteServerPort 2048
-#
-# The preamble of the socket.test file checks to see if the variables are set
-# either in Tcl or in the environment; if they are, it attempts to connect to
-# the server. If the connection is successful, the tests using the remote
-# server will be performed; otherwise, it will attempt to start the remote
-# server (via exec) on platforms that support this, on the local host,
-# listening at port 2048. If all fails, a message is printed and the tests
-# using the remote server are not performed.
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Some tests require the testthread command
-
-set ::tcltest::testConfig(testthread) \
- [expr {[info commands testthread] != {}}]
-
-#
-# If remoteServerIP or remoteServerPort are not set, check in the
-# environment variables for externally set values.
-#
-
-if {![info exists remoteServerIP]} {
- if {[info exists env(remoteServerIP)]} {
- set remoteServerIP $env(remoteServerIP)
- }
-}
-if {![info exists remoteServerPort]} {
- if {[info exists env(remoteServerIP)]} {
- set remoteServerPort $env(remoteServerPort)
- } else {
- if {[info exists remoteServerIP]} {
- set remoteServerPort 2048
- }
- }
-}
-
-#
-# Check if we're supposed to do tests against the remote server
-#
-
-set doTestsWithRemoteServer 1
-if {![info exists remoteServerIP] && ($tcl_platform(platform) != "macintosh")} {
- set remoteServerIP 127.0.0.1
-}
-if {($doTestsWithRemoteServer == 1) && (![info exists remoteServerPort])} {
- set remoteServerPort 2048
-}
-
-# Attempt to connect to a remote server if one is already running. If it
-# is not running or for some other reason the connect fails, attempt to
-# start the remote server on the local host listening on port 2048. This
-# is only done on platforms that support exec (i.e. not on the Mac). On
-# platforms that do not support exec, the remote server must be started
-# by the user before running the tests.
-
-set remoteProcChan ""
-set commandSocket ""
-if {$doTestsWithRemoteServer} {
- catch {close $commandSocket}
- if {[catch {set commandSocket [socket $remoteServerIP \
- $remoteServerPort]}] != 0} {
- if {[info commands exec] == ""} {
- set noRemoteTestReason "can't exec"
- set doTestsWithRemoteServer 0
- } else {
- set remoteServerIP 127.0.0.1
- set remoteFile [file join [pwd] remote.tcl]
- if {[catch {set remoteProcChan \
- [open "|[list $tcltest $remoteFile \
- -serverIsSilent \
- -port $remoteServerPort \
- -address $remoteServerIP]" \
- w+]} \
- msg] == 0} {
- after 1000
- if {[catch {set commandSocket [socket $remoteServerIP \
- $remoteServerPort]} msg] == 0} {
- fconfigure $commandSocket -translation crlf -buffering line
- } else {
- set noRemoteTestReason $msg
- set doTestsWithRemoteServer 0
- }
- } else {
- set noRemoteTestReason "$msg $tcltest"
- set doTestsWithRemoteServer 0
- }
- }
- } else {
- fconfigure $commandSocket -translation crlf -buffering line
- }
-}
-
-# Some tests are run only if we are doing testing against a remote server.
-set ::tcltest::testConfig(doTestsWithRemoteServer) $doTestsWithRemoteServer
-if {$doTestsWithRemoteServer == 0} {
- if {[string first s $::tcltest::verbose] != -1} {
- puts "Skipping tests with remote server. See tests/socket.test for"
- puts "information on how to run remote server."
- puts "Reason for not doing remote tests: $noRemoteTestReason"
- }
-}
-
-#
-# If we do the tests, define a command to send a command to the
-# remote server.
-#
-
-if {$doTestsWithRemoteServer == 1} {
- proc sendCommand {c} {
- global commandSocket
-
- if {[eof $commandSocket]} {
- error "remote server disappeared"
- }
-
- if {[catch {puts $commandSocket $c} msg]} {
- error "remote server disappaered: $msg"
- }
- if {[catch {puts $commandSocket "--Marker--Marker--Marker--"} msg]} {
- error "remote server disappeared: $msg"
- }
-
- set resp ""
- while {1} {
- set line [gets $commandSocket]
- if {[eof $commandSocket]} {
- error "remote server disappaered"
- }
- if {[string compare $line "--Marker--Marker--Marker--"] == 0} {
- if {[string compare [lindex $resp 0] error] == 0} {
- error [lindex $resp 1]
- } else {
- return [lindex $resp 1]
- }
- } else {
- append resp $line "\n"
- }
- }
- }
-}
-
-test socket-1.1 {arg parsing for socket command} {socket} {
- list [catch {socket -server} msg] $msg
-} {1 {no argument given for -server option}}
-test socket-1.2 {arg parsing for socket command} {socket} {
- list [catch {socket -server foo} msg] $msg
-} {1 {wrong # args: should be either:
-socket ?-myaddr addr? ?-myport myport? ?-async? host port
-socket -server command ?-myaddr addr? port}}
-test socket-1.3 {arg parsing for socket command} {socket} {
- list [catch {socket -myaddr} msg] $msg
-} {1 {no argument given for -myaddr option}}
-test socket-1.4 {arg parsing for socket command} {socket} {
- list [catch {socket -myaddr 127.0.0.1} msg] $msg
-} {1 {wrong # args: should be either:
-socket ?-myaddr addr? ?-myport myport? ?-async? host port
-socket -server command ?-myaddr addr? port}}
-test socket-1.5 {arg parsing for socket command} {socket} {
- list [catch {socket -myport} msg] $msg
-} {1 {no argument given for -myport option}}
-test socket-1.6 {arg parsing for socket command} {socket} {
- list [catch {socket -myport xxxx} msg] $msg
-} {1 {expected integer but got "xxxx"}}
-test socket-1.7 {arg parsing for socket command} {socket} {
- list [catch {socket -myport 2522} msg] $msg
-} {1 {wrong # args: should be either:
-socket ?-myaddr addr? ?-myport myport? ?-async? host port
-socket -server command ?-myaddr addr? port}}
-test socket-1.8 {arg parsing for socket command} {socket} {
- list [catch {socket -froboz} msg] $msg
-} {1 {bad option "-froboz": must be -async, -myaddr, -myport, or -server}}
-test socket-1.9 {arg parsing for socket command} {socket} {
- list [catch {socket -server foo -myport 2521 3333} msg] $msg
-} {1 {Option -myport is not valid for servers}}
-test socket-1.10 {arg parsing for socket command} {socket} {
- list [catch {socket host 2528 -junk} msg] $msg
-} {1 {wrong # args: should be either:
-socket ?-myaddr addr? ?-myport myport? ?-async? host port
-socket -server command ?-myaddr addr? port}}
-test socket-1.11 {arg parsing for socket command} {socket} {
- list [catch {socket -server callback 2520 --} msg] $msg
-} {1 {wrong # args: should be either:
-socket ?-myaddr addr? ?-myport myport? ?-async? host port
-socket -server command ?-myaddr addr? port}}
-test socket-1.12 {arg parsing for socket command} {socket} {
- list [catch {socket foo badport} msg] $msg
-} {1 {expected integer but got "badport"}}
-
-test socket-2.1 {tcp connection} {socket stdio} {
- removeFile script
- set f [open script w]
- puts $f {
- set timer [after 2000 "set x timed_out"]
- set f [socket -server accept 2828]
- proc accept {file addr port} {
- global x
- set x done
- close $file
- }
- puts ready
- vwait x
- after cancel $timer
- close $f
- puts $x
- }
- close $f
- set f [open "|[list $tcltest script]" r]
- gets $f x
- if {[catch {socket 127.0.0.1 2828} msg]} {
- set x $msg
- } else {
- lappend x [gets $f]
- close $msg
- }
- lappend x [gets $f]
- close $f
- set x
-} {ready done {}}
-
-if [info exists port] {
- incr port
-} else {
- set port [expr 2048 + [pid]%1024]
-}
-test socket-2.2 {tcp connection with client port specified} {socket stdio} {
- removeFile script
- set f [open script w]
- puts $f {
- set timer [after 2000 "set x done"]
- set f [socket -server accept 2829]
- proc accept {file addr port} {
- global x
- puts "[gets $file] $port"
- close $file
- set x done
- }
- puts ready
- vwait x
- after cancel $timer
- close $f
- }
- close $f
- set f [open "|[list $tcltest script]" r]
- gets $f x
- global port
- if {[catch {socket -myport $port 127.0.0.1 2829} sock]} {
- set x $sock
- close [socket 127.0.0.1 2829]
- puts stderr $sock
- } else {
- puts $sock hello
- flush $sock
- lappend x [gets $f]
- close $sock
- }
- close $f
- set x
-} [list ready "hello $port"]
-test socket-2.3 {tcp connection with client interface specified} {socket stdio} {
- removeFile script
- set f [open script w]
- puts $f {
- set timer [after 2000 "set x done"]
- set f [socket -server accept 2830]
- proc accept {file addr port} {
- global x
- puts "[gets $file] $addr"
- close $file
- set x done
- }
- puts ready
- vwait x
- after cancel $timer
- close $f
- }
- close $f
- set f [open "|[list $tcltest script]" r]
- gets $f x
- if {[catch {socket -myaddr 127.0.0.1 127.0.0.1 2830} sock]} {
- set x $sock
- } else {
- puts $sock hello
- flush $sock
- lappend x [gets $f]
- close $sock
- }
- close $f
- set x
-} {ready {hello 127.0.0.1}}
-test socket-2.4 {tcp connection with server interface specified} {socket stdio} {
- removeFile script
- set f [open script w]
- puts $f {
- set timer [after 2000 "set x done"]
- set f [socket -server accept -myaddr [info hostname] 2831]
- proc accept {file addr port} {
- global x
- puts "[gets $file]"
- close $file
- set x done
- }
- puts ready
- vwait x
- after cancel $timer
- close $f
- }
- close $f
- set f [open "|[list $tcltest script]" r]
- gets $f x
- if {[catch {socket [info hostname] 2831} sock]} {
- set x $sock
- } else {
- puts $sock hello
- flush $sock
- lappend x [gets $f]
- close $sock
- }
- close $f
- set x
-} {ready hello}
-test socket-2.5 {tcp connection with redundant server port} {socket stdio} {
- removeFile script
- set f [open script w]
- puts $f {
- set timer [after 2000 "set x done"]
- set f [socket -server accept 2832]
- proc accept {file addr port} {
- global x
- puts "[gets $file]"
- close $file
- set x done
- }
- puts ready
- vwait x
- after cancel $timer
- close $f
- }
- close $f
- set f [open "|[list $tcltest script]" r]
- gets $f x
- if {[catch {socket 127.0.0.1 2832} sock]} {
- set x $sock
- } else {
- puts $sock hello
- flush $sock
- lappend x [gets $f]
- close $sock
- }
- close $f
- set x
-} {ready hello}
-test socket-2.6 {tcp connection} {socket} {
- set status ok
- if {![catch {set sock [socket 127.0.0.1 2833]}]} {
- if {![catch {gets $sock}]} {
- set status broken
- }
- close $sock
- }
- set status
-} ok
-test socket-2.7 {echo server, one line} {socket stdio} {
- removeFile script
- set f [open script w]
- puts $f {
- set timer [after 2000 "set x done"]
- set f [socket -server accept 2834]
- proc accept {s a p} {
- fileevent $s readable [list echo $s]
- fconfigure $s -translation lf -buffering line
- }
- proc echo {s} {
- set l [gets $s]
- if {[eof $s]} {
- global x
- close $s
- set x done
- } else {
- puts $s $l
- }
- }
- puts ready
- vwait x
- after cancel $timer
- close $f
- puts done
- }
- close $f
- set f [open "|[list $tcltest script]" r]
- gets $f
- set s [socket 127.0.0.1 2834]
- fconfigure $s -buffering line -translation lf
- puts $s "hello abcdefghijklmnop"
- after 1000
- set x [gets $s]
- close $s
- set y [gets $f]
- close $f
- list $x $y
-} {{hello abcdefghijklmnop} done}
-test socket-2.8 {echo server, loop 50 times, single connection} {socket stdio} {
- makeFile {
- set f [socket -server accept 2835]
- proc accept {s a p} {
- fileevent $s readable [list echo $s]
- fconfigure $s -buffering line
- }
- proc echo {s} {
- global i
- set l [gets $s]
- if {[eof $s]} {
- global x
- close $s
- set x done
- } else {
- incr i
- puts $s $l
- }
- }
- set i 0
- puts ready
- set timer [after 20000 "set x done"]
- vwait x
- after cancel $timer
- close $f
- puts "done $i"
- } script
- set f [open "|[list $tcltest script]" r]
- gets $f
- set s [socket 127.0.0.1 2835]
- fconfigure $s -buffering line
- catch {
- for {set x 0} {$x < 50} {incr x} {
- puts $s "hello abcdefghijklmnop"
- gets $s
- }
- }
- close $s
- catch {set x [gets $f]}
- close $f
- set x
-} {done 50}
-test socket-2.9 {socket conflict} {socket stdio} {
- set s [socket -server accept 2828]
- removeFile script
- set f [open script w]
- puts -nonewline $f {socket -server accept 2828}
- close $f
- set f [open "|[list $tcltest script]" r]
- gets $f
- after 100
- set x [list [catch {close $f} msg] $msg]
- close $s
- set x
-} {1 {couldn't open socket: address already in use
- while executing
-"socket -server accept 2828"
- (file "script" line 1)}}
-test socket-2.10 {close on accept, accepted socket lives} {socket} {
- set done 0
- set timer [after 20000 "set done timed_out"]
- set ss [socket -server accept 2830]
- proc accept {s a p} {
- global ss
- close $ss
- fileevent $s readable "readit $s"
- fconfigure $s -trans lf
- }
- proc readit {s} {
- global done
- gets $s
- close $s
- set done 1
- }
- set cs [socket [info hostname] 2830]
- puts $cs hello
- close $cs
- vwait done
- after cancel $timer
- set done
-} 1
-test socket-2.11 {detecting new data} {socket} {
- proc accept {s a p} {
- global sock
- set sock $s
- }
-
- set s [socket -server accept 2400]
- set sock ""
- set s2 [socket 127.0.0.1 2400]
- vwait sock
- puts $s2 one
- flush $s2
- after 500
- fconfigure $sock -blocking 0
- set result [gets $sock]
- lappend result [gets $sock]
- fconfigure $sock -blocking 1
- puts $s2 two
- flush $s2
- fconfigure $sock -blocking 0
- lappend result [gets $sock]
- fconfigure $sock -blocking 1
- close $s2
- close $s
- close $sock
- set result
-} {one {} two}
-
-
-test socket-3.1 {socket conflict} {socket stdio} {
- removeFile script
- set f [open script w]
- puts $f {
- set f [socket -server accept 2828]
- puts ready
- gets stdin
- close $f
- }
- close $f
- set f [open "|[list $tcltest script]" r+]
- gets $f
- set x [list [catch {socket -server accept 2828} msg] \
- $msg]
- puts $f bye
- close $f
- set x
-} {1 {couldn't open socket: address already in use}}
-test socket-3.2 {server with several clients} {socket stdio} {
- removeFile script
- set f [open script w]
- puts $f {
- set t1 [after 30000 "set x timed_out"]
- set t2 [after 31000 "set x timed_out"]
- set t3 [after 32000 "set x timed_out"]
- set counter 0
- set s [socket -server accept 2828]
- proc accept {s a p} {
- fileevent $s readable [list echo $s]
- fconfigure $s -buffering line
- }
- proc echo {s} {
- global x
- set l [gets $s]
- if {[eof $s]} {
- close $s
- set x done
- } else {
- puts $s $l
- }
- }
- puts ready
- vwait x
- after cancel $t1
- vwait x
- after cancel $t2
- vwait x
- after cancel $t3
- close $s
- puts $x
- }
- close $f
- set f [open "|[list $tcltest script]" r+]
- set x [gets $f]
- set s1 [socket 127.0.0.1 2828]
- fconfigure $s1 -buffering line
- set s2 [socket 127.0.0.1 2828]
- fconfigure $s2 -buffering line
- set s3 [socket 127.0.0.1 2828]
- fconfigure $s3 -buffering line
- for {set i 0} {$i < 100} {incr i} {
- puts $s1 hello,s1
- gets $s1
- puts $s2 hello,s2
- gets $s2
- puts $s3 hello,s3
- gets $s3
- }
- close $s1
- close $s2
- close $s3
- lappend x [gets $f]
- close $f
- set x
-} {ready done}
-
-test socket-4.1 {server with several clients} {socket stdio} {
- removeFile script
- set f [open script w]
- puts $f {
- gets stdin
- set s [socket 127.0.0.1 2828]
- fconfigure $s -buffering line
- for {set i 0} {$i < 100} {incr i} {
- puts $s hello
- gets $s
- }
- close $s
- puts bye
- gets stdin
- }
- close $f
- set p1 [open "|[list $tcltest script]" r+]
- fconfigure $p1 -buffering line
- set p2 [open "|[list $tcltest script]" r+]
- fconfigure $p2 -buffering line
- set p3 [open "|[list $tcltest script]" r+]
- fconfigure $p3 -buffering line
- proc accept {s a p} {
- fconfigure $s -buffering line
- fileevent $s readable [list echo $s]
- }
- proc echo {s} {
- global x
- set l [gets $s]
- if {[eof $s]} {
- close $s
- set x done
- } else {
- puts $s $l
- }
- }
- set t1 [after 30000 "set x timed_out"]
- set t2 [after 31000 "set x timed_out"]
- set t3 [after 32000 "set x timed_out"]
- set s [socket -server accept 2828]
- puts $p1 open
- puts $p2 open
- puts $p3 open
- vwait x
- vwait x
- vwait x
- after cancel $t1
- after cancel $t2
- after cancel $t3
- close $s
- set l ""
- lappend l [list p1 [gets $p1] $x]
- lappend l [list p2 [gets $p2] $x]
- lappend l [list p3 [gets $p3] $x]
- puts $p1 bye
- puts $p2 bye
- puts $p3 bye
- close $p1
- close $p2
- close $p3
- set l
-} {{p1 bye done} {p2 bye done} {p3 bye done}}
-test socket-4.2 {byte order problems, socket numbers, htons} {socket} {
- set x ok
- if {[catch {socket -server dodo 0x3000} msg]} {
- set x $msg
- } else {
- close $msg
- }
- set x
-} ok
-
-test socket-5.1 {byte order problems, socket numbers, htons} \
- {socket unixOnly notRoot} {
- set x {couldn't open socket: not owner}
- if {![catch {socket -server dodo 0x1} msg]} {
- set x {htons problem, should be disallowed, are you running as SU?}
- close $msg
- }
- set x
-} {couldn't open socket: not owner}
-test socket-5.2 {byte order problems, socket numbers, htons} {socket} {
- set x {couldn't open socket: port number too high}
- if {![catch {socket -server dodo 0x10000} msg]} {
- set x {port resolution problem, should be disallowed}
- close $msg
- }
- set x
-} {couldn't open socket: port number too high}
-test socket-5.3 {byte order problems, socket numbers, htons} \
- {socket unixOnly notRoot} {
- set x {couldn't open socket: not owner}
- if {![catch {socket -server dodo 21} msg]} {
- set x {htons problem, should be disallowed, are you running as SU?}
- close $msg
- }
- set x
-} {couldn't open socket: not owner}
-
-test socket-6.1 {accept callback error} {socket stdio} {
- removeFile script
- set f [open script w]
- puts $f {
- gets stdin
- socket 127.0.0.1 2848
- }
- close $f
- set f [open "|[list $tcltest script]" r+]
- proc bgerror args {
- global x
- set x $args
- }
- proc accept {s a p} {expr 10 / 0}
- set s [socket -server accept 2848]
- puts $f hello
- close $f
- set timer [after 10000 "set x timed_out"]
- vwait x
- after cancel $timer
- close $s
- rename bgerror {}
- set x
-} {{divide by zero}}
-
-test socket-7.1 {testing socket specific options} {socket stdio} {
- removeFile script
- set f [open script w]
- puts $f {
- socket -server accept 2820
- proc accept args {
- global x
- set x done
- }
- puts ready
- set timer [after 10000 "set x timed_out"]
- vwait x
- after cancel $timer
- }
- close $f
- set f [open "|[list $tcltest script]" r]
- gets $f
- set s [socket 127.0.0.1 2820]
- set p [fconfigure $s -peername]
- close $s
- close $f
- set l ""
- lappend l [string compare [lindex $p 0] 127.0.0.1]
- lappend l [string compare [lindex $p 2] 2820]
- lappend l [llength $p]
-} {0 0 3}
-test socket-7.2 {testing socket specific options} {socket stdio} {
- removeFile script
- set f [open script w]
- puts $f {
- socket -server accept 2821
- proc accept args {
- global x
- set x done
- }
- puts ready
- set timer [after 10000 "set x timed_out"]
- vwait x
- after cancel $timer
- }
- close $f
- set f [open "|[list $tcltest script]" r]
- gets $f
- set s [socket 127.0.0.1 2821]
- set p [fconfigure $s -sockname]
- close $s
- close $f
- set l ""
- lappend l [llength $p]
- lappend l [lindex $p 0]
- lappend l [expr [lindex $p 2] == 2821]
-} {3 127.0.0.1 0}
-test socket-7.3 {testing socket specific options} {socket} {
- set s [socket -server accept 2822]
- set l [fconfigure $s]
- close $s
- update
- llength $l
-} 12
-test socket-7.4 {testing socket specific options} {socket} {
- set s [socket -server accept 2823]
- proc accept {s a p} {
- global x
- set x [fconfigure $s -sockname]
- close $s
- }
- set s1 [socket [info hostname] 2823]
- set timer [after 10000 "set x timed_out"]
- vwait x
- after cancel $timer
- close $s
- close $s1
- set l ""
- lappend l [lindex $x 2] [llength $x]
-} {2823 3}
-test socket-7.5 {testing socket specific options} {socket unixOrPc} {
- set s [socket -server accept 2829]
- proc accept {s a p} {
- global x
- set x [fconfigure $s -sockname]
- close $s
- }
- set s1 [socket 127.0.0.1 2829]
- set timer [after 10000 "set x timed_out"]
- vwait x
- after cancel $timer
- close $s
- close $s1
- set l ""
- lappend l [lindex $x 0] [lindex $x 2] [llength $x]
-} {127.0.0.1 2829 3}
-
-test socket-8.1 {testing -async flag on sockets} {socket} {
- # NOTE: This test may fail on some Solaris 2.4 systems. If it does,
- # check that you have these patches installed (using showrev -p):
- #
- # 101907-05, 101925-02, 101945-14, 101959-03, 101969-05, 101973-03,
- # 101977-03, 101981-02, 101985-01, 102001-03, 102003-01, 102007-01,
- # 102011-02, 102024-01, 102039-01, 102044-01, 102048-01, 102062-03,
- # 102066-04, 102070-01, 102105-01, 102153-03, 102216-01, 102232-01,
- # 101878-03, 101879-01, 101880-03, 101933-01, 101950-01, 102030-01,
- # 102057-08, 102140-01, 101920-02, 101921-09, 101922-07, 101923-03
- #
- # If after installing these patches you are still experiencing a
- # problem, please email jyl@eng.sun.com. We have not observed this
- # failure on Solaris 2.5, so another option (instead of installing
- # these patches) is to upgrade to Solaris 2.5.
- set s [socket -server accept 2830]
- proc accept {s a p} {
- global x
- puts $s bye
- close $s
- set x done
- }
- set s1 [socket -async [info hostname] 2830]
- vwait x
- set z [gets $s1]
- close $s
- close $s1
- set z
-} bye
-
-test socket-9.1 {testing spurious events} {socket} {
- set len 0
- set spurious 0
- set done 0
- proc readlittle {s} {
- global spurious done len
- set l [read $s 1]
- if {[string length $l] == 0} {
- if {![eof $s]} {
- incr spurious
- } else {
- close $s
- set done 1
- }
- } else {
- incr len [string length $l]
- }
- }
- proc accept {s a p} {
- fconfigure $s -buffering none -blocking off
- fileevent $s readable [list readlittle $s]
- }
- set s [socket -server accept 2831]
- set c [socket [info hostname] 2831]
- puts -nonewline $c 01234567890123456789012345678901234567890123456789
- close $c
- set timer [after 10000 "set done timed_out"]
- vwait done
- after cancel $timer
- close $s
- list $spurious $len
-} {0 50}
-test socket-9.2 {testing async write, fileevents, flush on close} {socket} {
- set firstblock ""
- for {set i 0} {$i < 5} {incr i} {set firstblock "a$firstblock$firstblock"}
- set secondblock ""
- for {set i 0} {$i < 16} {incr i} {
- set secondblock "b$secondblock$secondblock"
- }
- set l [socket -server accept 2832]
- proc accept {s a p} {
- fconfigure $s -blocking 0 -translation lf -buffersize 16384 \
- -buffering line
- fileevent $s readable "readable $s"
- }
- proc readable {s} {
- set l [gets $s]
- fileevent $s readable {}
- after 1000 respond $s
- }
- proc respond {s} {
- global firstblock
- puts -nonewline $s $firstblock
- after 1000 writedata $s
- }
- proc writedata {s} {
- global secondblock
- puts -nonewline $s $secondblock
- close $s
- }
- set s [socket [info hostname] 2832]
- fconfigure $s -blocking 0 -trans lf -buffering line
- set count 0
- puts $s hello
- proc readit {s} {
- global count done
- set l [read $s]
- incr count [string length $l]
- if {[eof $s]} {
- close $s
- set done 1
- }
- }
- fileevent $s readable "readit $s"
- set timer [after 10000 "set done timed_out"]
- vwait done
- after cancel $timer
- close $l
- set count
-} 65566
-test socket-9.3 {testing EOF stickyness} {socket} {
- proc count_to_eof {s} {
- global count done timer
- set l [gets $s]
- if {[eof $s]} {
- incr count
- if {$count > 9} {
- close $s
- set done true
- set count {eof is sticky}
- after cancel $timer
- }
- }
- }
- proc timerproc {} {
- global done count c
- set done true
- set count {timer went off, eof is not sticky}
- close $c
- }
- set count 0
- set done false
- proc write_then_close {s} {
- puts $s bye
- close $s
- }
- proc accept {s a p} {
- fconfigure $s -buffering line -translation lf
- fileevent $s writable "write_then_close $s"
- }
- set s [socket -server accept 2833]
- set c [socket [info hostname] 2833]
- fconfigure $c -blocking off -buffering line -translation lf
- fileevent $c readable "count_to_eof $c"
- set timer [after 1000 timerproc]
- vwait done
- close $s
- set count
-} {eof is sticky}
-
-removeFile script
-
-test socket-10.1 {testing socket accept callback error handling} {socket} {
- set goterror 0
- proc bgerror args {global goterror; set goterror 1}
- set s [socket -server accept 2898]
- proc accept {s a p} {close $s; error}
- set c [socket 127.0.0.1 2898]
- vwait goterror
- close $s
- close $c
- set goterror
-} 1
-
-test socket-11.1 {tcp connection} {socket doTestsWithRemoteServer} {
- sendCommand {
- set socket9_1_test_server [socket -server accept 2834]
- proc accept {s a p} {
- puts $s done
- close $s
- }
- }
- set s [socket $remoteServerIP 2834]
- set r [gets $s]
- close $s
- sendCommand {close $socket9_1_test_server}
- set r
-} done
-test socket-11.2 {client specifies its port} {socket doTestsWithRemoteServer} {
- if {[info exists port]} {
- incr port
- } else {
- set port [expr 2048 + [pid]%1024]
- }
- sendCommand {
- set socket9_2_test_server [socket -server accept 2835]
- proc accept {s a p} {
- puts $s $p
- close $s
- }
- }
- set s [socket -myport $port $remoteServerIP 2835]
- set r [gets $s]
- close $s
- sendCommand {close $socket9_2_test_server}
- if {$r == $port} {
- set result ok
- } else {
- set result broken
- }
- set result
-} ok
-test socket-11.3 {trying to connect, no server} {socket doTestsWithRemoteServer} {
- set status ok
- if {![catch {set s [socket $remoteServerIp 2836]}]} {
- if {![catch {gets $s}]} {
- set status broken
- }
- close $s
- }
- set status
-} ok
-test socket-11.4 {remote echo, one line} {socket doTestsWithRemoteServer} {
- sendCommand {
- set socket10_6_test_server [socket -server accept 2836]
- proc accept {s a p} {
- fileevent $s readable [list echo $s]
- fconfigure $s -buffering line -translation crlf
- }
- proc echo {s} {
- set l [gets $s]
- if {[eof $s]} {
- close $s
- } else {
- puts $s $l
- }
- }
- }
- set f [socket $remoteServerIP 2836]
- fconfigure $f -translation crlf -buffering line
- puts $f hello
- set r [gets $f]
- close $f
- sendCommand {close $socket10_6_test_server}
- set r
-} hello
-test socket-11.5 {remote echo, 50 lines} {socket doTestsWithRemoteServer} {
- sendCommand {
- set socket10_7_test_server [socket -server accept 2836]
- proc accept {s a p} {
- fileevent $s readable [list echo $s]
- fconfigure $s -buffering line -translation crlf
- }
- proc echo {s} {
- set l [gets $s]
- if {[eof $s]} {
- close $s
- } else {
- puts $s $l
- }
- }
- }
- set f [socket $remoteServerIP 2836]
- fconfigure $f -translation crlf -buffering line
- for {set cnt 0} {$cnt < 50} {incr cnt} {
- puts $f "hello, $cnt"
- if {[string compare [gets $f] "hello, $cnt"] != 0} {
- break
- }
- }
- close $f
- sendCommand {close $socket10_7_test_server}
- set cnt
-} 50
-# Macintosh sockets can have more than one server per port
-if {$tcl_platform(platform) == "macintosh"} {
- set conflictResult {0 2836}
-} else {
- set conflictResult {1 {couldn't open socket: address already in use}}
-}
-test socket-11.6 {socket conflict} {socket doTestsWithRemoteServer} {
- set s1 [socket -server accept 2836]
- if {[catch {set s2 [socket -server accept 2836]} msg]} {
- set result [list 1 $msg]
- } else {
- set result [list 0 [lindex [fconfigure $s2 -sockname] 2]]
- close $s2
- }
- close $s1
- set result
-} $conflictResult
-test socket-11.7 {server with several clients} {socket doTestsWithRemoteServer} {
- sendCommand {
- set socket10_9_test_server [socket -server accept 2836]
- proc accept {s a p} {
- fconfigure $s -buffering line
- fileevent $s readable [list echo $s]
- }
- proc echo {s} {
- set l [gets $s]
- if {[eof $s]} {
- close $s
- } else {
- puts $s $l
- }
- }
- }
- set s1 [socket $remoteServerIP 2836]
- fconfigure $s1 -buffering line
- set s2 [socket $remoteServerIP 2836]
- fconfigure $s2 -buffering line
- set s3 [socket $remoteServerIP 2836]
- fconfigure $s3 -buffering line
- for {set i 0} {$i < 100} {incr i} {
- puts $s1 hello,s1
- gets $s1
- puts $s2 hello,s2
- gets $s2
- puts $s3 hello,s3
- gets $s3
- }
- close $s1
- close $s2
- close $s3
- sendCommand {close $socket10_9_test_server}
- set i
-} 100
-test socket-11.8 {client with several servers} {socket doTestsWithRemoteServer} {
- sendCommand {
- set s1 [socket -server "accept 4003" 4003]
- set s2 [socket -server "accept 4004" 4004]
- set s3 [socket -server "accept 4005" 4005]
- proc accept {mp s a p} {
- puts $s $mp
- close $s
- }
- }
- set s1 [socket $remoteServerIP 4003]
- set s2 [socket $remoteServerIP 4004]
- set s3 [socket $remoteServerIP 4005]
- set l ""
- lappend l [gets $s1] [gets $s1] [eof $s1] [gets $s2] [gets $s2] [eof $s2] \
- [gets $s3] [gets $s3] [eof $s3]
- close $s1
- close $s2
- close $s3
- sendCommand {
- close $s1
- close $s2
- close $s3
- }
- set l
-} {4003 {} 1 4004 {} 1 4005 {} 1}
-test socket-11.9 {accept callback error} {socket doTestsWithRemoteServer} {
- set s [socket -server accept 2836]
- proc accept {s a p} {expr 10 / 0}
- proc bgerror args {
- global x
- set x $args
- }
- if {[catch {sendCommand {
- set peername [fconfigure $callerSocket -peername]
- set s [socket [lindex $peername 0] 2836]
- close $s
- }} msg]} {
- close $s
- error $msg
- }
- set timer [after 10000 "set x timed_out"]
- vwait x
- after cancel $timer
- close $s
- rename bgerror {}
- set x
-} {{divide by zero}}
-test socket-11.10 {testing socket specific options} {socket doTestsWithRemoteServer} {
- sendCommand {
- set socket10_12_test_server [socket -server accept 2836]
- proc accept {s a p} {close $s}
- }
- set s [socket $remoteServerIP 2836]
- set p [fconfigure $s -peername]
- set n [fconfigure $s -sockname]
- set l ""
- lappend l [lindex $p 2] [llength $p] [llength $p]
- close $s
- sendCommand {close $socket10_12_test_server}
- set l
-} {2836 3 3}
-test socket-11.11 {testing spurious events} {socket doTestsWithRemoteServer} {
- sendCommand {
- set socket10_13_test_server [socket -server accept 2836]
- proc accept {s a p} {
- fconfigure $s -translation "auto lf"
- after 100 writesome $s
- }
- proc writesome {s} {
- for {set i 0} {$i < 100} {incr i} {
- puts $s "line $i from remote server"
- }
- close $s
- }
- }
- set len 0
- set spurious 0
- set done 0
- proc readlittle {s} {
- global spurious done len
- set l [read $s 1]
- if {[string length $l] == 0} {
- if {![eof $s]} {
- incr spurious
- } else {
- close $s
- set done 1
- }
- } else {
- incr len [string length $l]
- }
- }
- set c [socket $remoteServerIP 2836]
- fileevent $c readable "readlittle $c"
- set timer [after 10000 "set done timed_out"]
- vwait done
- after cancel $timer
- sendCommand {close $socket10_13_test_server}
- list $spurious $len
-} {0 2690}
-test socket-11.12 {testing EOF stickyness} {socket doTestsWithRemoteServer} {
- set counter 0
- set done 0
- proc count_up {s} {
- global counter done after_id
- set l [gets $s]
- if {[eof $s]} {
- incr counter
- if {$counter > 9} {
- set done {EOF is sticky}
- after cancel $after_id
- close $s
- }
- }
- }
- proc timed_out {} {
- global c done
- set done {timed_out, EOF is not sticky}
- close $c
- }
- sendCommand {
- set socket10_14_test_server [socket -server accept 2836]
- proc accept {s a p} {
- after 100 close $s
- }
- }
- set c [socket $remoteServerIP 2836]
- fileevent $c readable "count_up $c"
- set after_id [after 1000 timed_out]
- vwait done
- sendCommand {close $socket10_14_test_server}
- set done
-} {EOF is sticky}
-test socket-11.13 {testing async write, async flush, async close} \
- {socket doTestsWithRemoteServer} {
- proc readit {s} {
- global count done
- set l [read $s]
- incr count [string length $l]
- if {[eof $s]} {
- close $s
- set done 1
- }
- }
- sendCommand {
- set firstblock ""
- for {set i 0} {$i < 5} {incr i} {
- set firstblock "a$firstblock$firstblock"
- }
- set secondblock ""
- for {set i 0} {$i < 16} {incr i} {
- set secondblock "b$secondblock$secondblock"
- }
- set l [socket -server accept 2845]
- proc accept {s a p} {
- fconfigure $s -blocking 0 -translation lf -buffersize 16384 \
- -buffering line
- fileevent $s readable "readable $s"
- }
- proc readable {s} {
- set l [gets $s]
- fileevent $s readable {}
- after 1000 respond $s
- }
- proc respond {s} {
- global firstblock
- puts -nonewline $s $firstblock
- after 1000 writedata $s
- }
- proc writedata {s} {
- global secondblock
- puts -nonewline $s $secondblock
- close $s
- }
- }
- set s [socket $remoteServerIP 2845]
- fconfigure $s -blocking 0 -trans lf -buffering line
- set count 0
- puts $s hello
- fileevent $s readable "readit $s"
- set timer [after 10000 "set done timed_out"]
- vwait done
- after cancel $timer
- sendCommand {close $l}
- set count
-} 65566
-
-test socket-12.1 {testing inheritance of server sockets} \
- {socket doTestsWithRemoteServer} {
- removeFile script1
- removeFile script2
-
- # Script1 is just a 10 second delay. If the server socket
- # is inherited, it will be held open for 10 seconds
-
- set f [open script1 w]
- puts $f {
- after 10000 exit
- vwait forever
- }
- close $f
-
- # Script2 creates the server socket, launches script1,
- # waits a second, and exits. The server socket will now
- # be closed unless script1 inherited it.
-
- set f [open script2 w]
- puts $f [list set tcltest $tcltest]
- puts $f {
- set f [socket -server accept 2828]
- proc accept { file addr port } {
- close $file
- }
- exec $tcltest script1 &
- close $f
- after 1000 exit
- vwait forever
- }
- close $f
-
- # Launch script2 and wait 5 seconds
-
- exec $tcltest script2 &
- after 5000 { set ok_to_proceed 1 }
- vwait ok_to_proceed
-
- # If we can still connect to the server, the socket got inherited.
-
- if {[catch {socket 127.0.0.1 2828} msg]} {
- set x {server socket was not inherited}
- } else {
- close $msg
- set x {server socket was inherited}
- }
-
- removeFile script1
- removeFile script2
- set x
-} {server socket was not inherited}
-test socket-12.2 {testing inheritance of client sockets} \
- {socket doTestsWithRemoteServer} {
- removeFile script1
- removeFile script2
-
- # Script1 is just a 10 second delay. If the server socket
- # is inherited, it will be held open for 10 seconds
-
- set f [open script1 w]
- puts $f {
- after 10000 exit
- vwait forever
- }
- close $f
-
- # Script2 opens the client socket and writes to it. It then
- # launches script1 and exits. If the child process inherited the
- # client socket, the socket will still be open.
-
- set f [open script2 w]
- puts $f [list set tcltest $tcltest]
- puts $f {
- set f [socket 127.0.0.1 2829]
- exec $tcltest script1 &
- puts $f testing
- flush $f
- after 1000 exit
- vwait forever
- }
- close $f
-
- # Create the server socket
-
- set server [socket -server accept 2829]
- proc accept { file host port } {
-
- # When the client connects, establish the read handler
- global server
- close $server
- fileevent $file readable [list getdata $file]
- fconfigure $file -buffering line -blocking 0
- return
- }
- proc getdata { file } {
-
- # Read handler on the accepted socket.
- global x
- global failed
- set status [catch {read $file} data]
- if {$status != 0} {
- set x {read failed, error was $data}
- catch { close $file }
- } elseif {[string compare {} $data]} {
- } elseif {[fblocked $file]} {
- } elseif {[eof $file]} {
- if {$failed} {
- set x {client socket was inherited}
- } else {
- set x {client socket was not inherited}
- }
- catch { close $file }
- } else {
- set x {impossible case}
- catch { close $file }
- }
- return
- }
-
- # If the socket doesn't hit end-of-file in 5 seconds, the
- # script1 process must have inherited the client.
-
- set failed 0
- after 5000 [list set failed 1]
-
- # Launch the script2 process
-
- exec $tcltest script2 &
-
- vwait x
- if {!$failed} {
- vwait failed
- }
- removeFile script1
- removeFile script2
- set x
-} {client socket was not inherited}
-test socket-12.3 {testing inheritance of accepted sockets} \
- {socket doTestsWithRemoteServer} {
- removeFile script1
- removeFile script2
-
- set f [open script1 w]
- puts $f {
- after 10000 exit
- vwait forever
- }
- close $f
-
- set f [open script2 w]
- puts $f [list set tcltest $tcltest]
- puts $f {
- set server [socket -server accept 2930]
- proc accept { file host port } {
- global tcltest
- puts $file {test data on socket}
- exec $tcltest script1 &
- after 1000 exit
- }
- vwait forever
- }
- close $f
-
- # Launch the script2 process and connect to it. See how long
- # the socket stays open
-
- exec $tcltest script2 &
-
- after 1000 set ok_to_proceed 1
- vwait ok_to_proceed
-
- set f [socket 127.0.0.1 2930]
- fconfigure $f -buffering full -blocking 0
- fileevent $f readable [list getdata $f]
-
- # If the socket is still open after 5 seconds, the script1 process
- # must have inherited the accepted socket.
-
- set failed 0
- after 5000 set failed 1
-
- proc getdata { file } {
-
- # Read handler on the client socket.
- global x
- global failed
- set status [catch {read $file} data]
- if {$status != 0} {
- set x {read failed, error was $data}
- catch { close $file }
- } elseif {[string compare {} $data]} {
- } elseif {[fblocked $file]} {
- } elseif {[eof $file]} {
- if {$failed} {
- set x {accepted socket was inherited}
- } else {
- set x {accepted socket was not inherited}
- }
- catch { close $file }
- } else {
- set x {impossible case}
- catch { close $file }
- }
- return
- }
-
- vwait x
-
- removeFile script1
- removeFile script2
- set x
-} {accepted socket was not inherited}
-
-test socket-13.1 {Testing use of shared socket between two threads} \
- {socket testthread} {
-
- set mainthread [testthread names]
- proc ThreadReap {} {
- global mainthread
- testthread errorproc ThreadNullError
- while {[llength [testthread names]] > 1} {
- foreach tid [testthread names] {
- if {$tid != $mainthread} {
- catch {testthread send -async $tid {testthread exit}}
- update
- }
- }
- }
- testthread errorproc ThreadError
- return [llength [testthread names]]
- }
-
- removeFile script
-
- set f [open script w]
- puts $f {
- set f [socket -server accept 2828]
- proc accept {s a p} {
- fileevent $s readable [list echo $s]
- fconfigure $s -buffering line
- }
- proc echo {s} {
- global i
- set l [gets $s]
- if {[eof $s]} {
- global x
- close $s
- set x done
- } else {
- incr i
- puts $s $l
- }
- }
- set i 0
- vwait x
- close $f
-
- # thread cleans itself up.
- testthread exit
- }
- close $f
-
- # create a thread
- set serverthread [testthread create { source script } ]
- update
-
-
- set s [socket 127.0.0.1 2828]
- fconfigure $s -buffering line
- catch {
- puts $s "hello"
- gets $s result
- }
- close $s
- update
-
- after 2000
- ThreadReap
-
- set result
-
-} hello
-
-# cleanup
-if {[string match sock* $commandSocket] == 1} {
- puts $commandSocket exit
- flush $commandSocket
-}
-catch {close $commandSocket}
-catch {close $remoteProcChan}
-::tcltest::cleanupTests
-flush stdout
-return
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/source.test b/tests/source.test
deleted file mode 100644
index 74a3589..0000000
--- a/tests/source.test
+++ /dev/null
@@ -1,197 +0,0 @@
-# Commands covered: source
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-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: source.test,v 1.3 1999/04/16 00:47:34 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test source-1.1 {source command} {
- set x "old x value"
- set y "old y value"
- set z "old z value"
- makeFile {
- set x 22
- set y 33
- set z 44
- } source.file
- source source.file
- list $x $y $z
-} {22 33 44}
-test source-1.2 {source command} {
- makeFile {list result} source.file
- source source.file
-} result
-test source-1.3 {source command} {
- set y {\ }
-
- set fd [open source.file w]
- fconfigure $fd -translation lf
- puts -nonewline $fd "list a b c "
- puts $fd [string index $y 0]
- puts $fd "d e f"
- close $fd
-
- source source.file
-} {a b c d e f}
-
-test source-2.3 {source error conditions} {
- makeFile {
- set x 146
- error "error in sourced file"
- set y $x
- } source.file
- list [catch {source source.file} msg] $msg $errorInfo
-} {1 {error in sourced file} {error in sourced file
- while executing
-"error "error in sourced file""
- (file "source.file" line 3)
- invoked from within
-"source source.file"}}
-test source-2.4 {source error conditions} {
- makeFile {break} source.file
- catch {source source.file}
-} 3
-test source-2.5 {source error conditions} {
- makeFile {continue} source.file
- catch {source source.file}
-} 4
-test source-2.6 {source error conditions} {
- normalizeMsg [list [catch {source _non_existent_} msg] $msg $errorCode]
-} {1 {couldn't read file "_non_existent_": no such file or directory} {posix enoent {no such file or directory}}}
-
-test source-3.1 {return in middle of source file} {
- makeFile {
- set x new-x
- return allDone
- set y new-y
- } source.file
- set x old-x
- set y old-y
- set z [source source.file]
- list $x $y $z
-} {new-x old-y allDone}
-test source-3.2 {return with special code etc.} {
- makeFile {
- set x new-x
- return -code break "Silly result"
- set y new-y
- } source.file
- list [catch {source source.file} msg] $msg
-} {3 {Silly result}}
-test source-3.3 {return with special code etc.} {
- makeFile {
- set x new-x
- return -code error "Simulated error"
- set y new-y
- } source.file
- list [catch {source source.file} msg] $msg $errorInfo $errorCode
-} {1 {Simulated error} {Simulated error
- while executing
-"source source.file"} NONE}
-test source-3.4 {return with special code etc.} {
- makeFile {
- set x new-x
- return -code error -errorinfo "Simulated errorInfo stuff"
- set y new-y
- } source.file
- list [catch {source source.file} msg] $msg $errorInfo $errorCode
-} {1 {} {Simulated errorInfo stuff
- invoked from within
-"source source.file"} NONE}
-test source-3.5 {return with special code etc.} {
- makeFile {
- set x new-x
- return -code error -errorinfo "Simulated errorInfo stuff" \
- -errorcode {a b c}
- set y new-y
- } source.file
- list [catch {source source.file} msg] $msg $errorInfo $errorCode
-} {1 {} {Simulated errorInfo stuff
- invoked from within
-"source source.file"} {a b c}}
-
-# Test for the Macintosh specfic features of the source command
-test source-4.1 {source error conditions} {macOnly} {
- list [catch {source -rsrc _no_exist_} msg] $msg
-} [list 1 "The resource \"_no_exist_\" could not be loaded from application."]
-test source-4.2 {source error conditions} {macOnly} {
- list [catch {source -rsrcid bad_id} msg] $msg
-} [list 1 "expected integer but got \"bad_id\""]
-test source-4.3 {source error conditions} {macOnly} {
- list [catch {source -rsrc rsrcName fileName extra} msg] $msg
-} {1 {wrong # args: should be "source fileName" or "source -rsrc name ?fileName?" or "source -rsrcid id ?fileName?"}}
-test source-4.4 {source error conditions} {macOnly} {
- list [catch {source non_switch rsrcName} msg] $msg
-} {1 {bad argument: should be "source fileName" or "source -rsrc name ?fileName?" or "source -rsrcid id ?fileName?"}}
-test source-4.5 {source error conditions} {macOnly} {
- list [catch {source -bad_switch argument} msg] $msg
-} {1 {bad argument: should be "source fileName" or "source -rsrc name ?fileName?" or "source -rsrcid id ?fileName?"}}
-test source-5.1 {source resource files} {macOnly} {
- list [catch {source -rsrc rsrcName bad_file} msg] $msg
-} [list 1 "Error finding the file: \"bad_file\"."]
-test source-5.2 {source resource files} {macOnly} {
- makeFile {return} source.file
- list [catch {source -rsrc rsrcName source.file} msg] $msg
-} [list 1 "Error reading the file: \"source.file\"."]
-test source-5.3 {source resource files} {macOnly} {
- testWriteTextResource -rsrc rsrcName -file rsrc.file {set msg2 ok; return}
- set result [catch {source -rsrc rsrcName rsrc.file} msg]
- removeFile rsrc.file
- list $msg2 $result $msg
-} [list ok 0 {}]
-test source-5.4 {source resource files} {macOnly} {
- catch {unset msg2}
- testWriteTextResource -rsrc fileRsrcName -file rsrc.file {set msg2 ok; return}
- source -rsrc fileRsrcName rsrc.file
- set result [catch {source -rsrc fileRsrcName} msg]
- removeFile rsrc.file
- list $msg2 $result $msg
-} [list ok 1 {The resource "fileRsrcName" could not be loaded from application.}]
-test source-5.5 {source resource files} {macOnly} {
- testWriteTextResource -rsrcid 200 -file rsrc.file {set msg2 hello; set msg3 bye}
- set result [catch {source -rsrcid 200 rsrc.file} msg]
- removeFile rsrc.file
- list $msg2 $result $msg
-} [list hello 0 bye]
-test source-5.6 {source resource files} {macOnly} {
- testWriteTextResource -rsrcid 200 -file rsrc.file {set msg2 hello; error bad; set msg3 bye}
- set result [catch {source -rsrcid 200 rsrc.file} msg]
- removeFile rsrc.file
- list $msg2 $result $msg
-} [list hello 1 bad]
-
-test source-6.1 {source is binary ok} {
- set x {}
- makeFile [list set x "a b\0c"] source.file
- source source.file
- string length $x
-} 5
-
-# cleanup
-catch {::tcltest::removeFile source.file}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/split.test b/tests/split.test
deleted file mode 100644
index fc78e84..0000000
--- a/tests/split.test
+++ /dev/null
@@ -1,84 +0,0 @@
-# Commands covered: split
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-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: split.test,v 1.3 1999/04/16 00:47:34 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test split-1.1 {basic split commands} {
- split "a\n b\t\r c\n "
-} {a {} b {} {} c {} {}}
-test split-1.2 {basic split commands} {
- split "word 1xyzword 2zword 3" xyz
-} {{word 1} {} {} {word 2} {word 3}}
-test split-1.3 {basic split commands} {
- split "12345" {}
-} {1 2 3 4 5}
-test split-1.4 {basic split commands} {
- split "a\}b\[c\{\]\$"
-} "a\\}b\\\[c\\{\\\]\\\$"
-test split-1.5 {basic split commands} {
- split {} {}
-} {}
-test split-1.6 {basic split commands} {
- split {}
-} {}
-test split-1.7 {basic split commands} {
- split { }
-} {{} {} {} {}}
-test split-1.8 {basic split commands} {
- proc foo {} {
- set x {}
- foreach f [split {]\n} {}] {
- append x $f
- }
- return $x
- }
- foo
-} {]\n}
-test split-1.9 {basic split commands} {
- proc foo {} {
- set x ab\000c
- set y [split $x {}]
- return $y
- }
- foo
-} "a b \000 c"
-test split-1.10 {basic split commands} {
- split "a0ab1b2bbb3\000c4" ab\000c
-} {{} 0 {} 1 2 {} {} 3 {} 4}
-
-test split-2.1 {split errors} {
- list [catch split msg] $msg $errorCode
-} {1 {wrong # args: should be "split string ?splitChars?"} NONE}
-test split-2.2 {split errors} {
- list [catch {split a b c} msg] $msg $errorCode
-} {1 {wrong # args: should be "split string ?splitChars?"} NONE}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/stack.test b/tests/stack.test
deleted file mode 100644
index 1e62788..0000000
--- a/tests/stack.test
+++ /dev/null
@@ -1,41 +0,0 @@
-# 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-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: stack.test,v 1.2 1999/04/16 00:47:34 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# 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?)}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/string.test b/tests/string.test
deleted file mode 100644
index 641b8c2..0000000
--- a/tests/string.test
+++ /dev/null
@@ -1,403 +0,0 @@
-# Commands covered: string
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: string.test,v 1.3 1999/04/16 00:47:34 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test string-1.1 {string compare} {
- string compare abcde abdef
-} -1
-test string-1.2 {string compare} {
- string c abcde ABCDE
-} 1
-test string-1.3 {string compare} {
- string compare abcde abcde
-} 0
-test string-1.4 {string compare} {
- list [catch {string compare a} msg] $msg
-} {1 {wrong # args: should be "string compare string1 string2"}}
-test string-1.5 {string compare} {
- list [catch {string compare a b c} msg] $msg
-} {1 {wrong # args: should be "string compare string1 string2"}}
-
-test string-2.1 {string first} {
- string first bq abcdefgbcefgbqrs
-} 12
-test string-2.2 {string first} {
- string fir bcd abcdefgbcefgbqrs
-} 1
-test string-2.3 {string first} {
- string f b abcdefgbcefgbqrs
-} 1
-test string-2.4 {string first} {
- string first xxx x123xx345xxx789xxx012
-} 9
-test string-2.5 {string first} {
- string first "" x123xx345xxx789xxx012
-} -1
-test string-2.6 {string first} {
- list [catch {string first a} msg] $msg
-} {1 {wrong # args: should be "string first string1 string2"}}
-test string-2.7 {string first} {
- list [catch {string first a b c} msg] $msg
-} {1 {wrong # args: should be "string first string1 string2"}}
-
-test string-3.1 {string index} {
- string index abcde 0
-} a
-test string-3.2 {string index} {
- string i abcde 4
-} e
-test string-3.3 {string index} {
- string index abcde 5
-} {}
-test string-3.4 {string index} {
- list [catch {string index abcde -10} msg] $msg
-} {0 {}}
-test string-3.5 {string index} {
- list [catch {string index} msg] $msg
-} {1 {wrong # args: should be "string index string charIndex"}}
-test string-3.6 {string index} {
- list [catch {string index a b c} msg] $msg
-} {1 {wrong # args: should be "string index string charIndex"}}
-test string-3.7 {string index} {
- list [catch {string index a xyz} msg] $msg
-} {1 {expected integer but got "xyz"}}
-
-test string-4.1 {string last} {
- string la xxx xxxx123xx345x678
-} 1
-test string-4.2 {string last} {
- string last xx xxxx123xx345x678
-} 7
-test string-4.3 {string last} {
- string las x xxxx123xx345x678
-} 12
-test string-4.4 {string last} {
- list [catch {string last a} msg] $msg
-} {1 {wrong # args: should be "string last string1 string2"}}
-test string-4.5 {string last} {
- list [catch {string last a b c} msg] $msg
-} {1 {wrong # args: should be "string last string1 string2"}}
-
-test string-5.1 {string length} {
- string length "a little string"
-} 15
-test string-5.2 {string length} {
- string le ""
-} 0
-test string-5.3 {string length} {
- list [catch {string length} msg] $msg
-} {1 {wrong # args: should be "string length string"}}
-test string-5.4 {string length} {
- list [catch {string length a b} msg] $msg
-} {1 {wrong # args: should be "string length string"}}
-
-test string-6.1 {string match} {
- string match abc abc
-} 1
-test string-6.2 {string match} {
- string m abc abd
-} 0
-test string-6.3 {string match} {
- string match ab*c abc
-} 1
-test string-6.4 {string match} {
- string match ab**c abc
-} 1
-test string-6.5 {string match} {
- string match ab* abcdef
-} 1
-test string-6.6 {string match} {
- string match *c abc
-} 1
-test string-6.7 {string match} {
- string match *3*6*9 0123456789
-} 1
-test string-6.8 {string match} {
- string match *3*6*9 01234567890
-} 0
-test string-6.9 {string match} {
- string match a?c abc
-} 1
-test string-6.10 {string match} {
- string match a??c abc
-} 0
-test string-6.11 {string match} {
- string match ?1??4???8? 0123456789
-} 1
-test string-6.12 {string match} {
- string match {[abc]bc} abc
-} 1
-test string-6.13 {string match} {
- string match {a[abc]c} abc
-} 1
-test string-6.14 {string match} {
- string match {a[xyz]c} abc
-} 0
-test string-6.15 {string match} {
- string match {12[2-7]45} 12345
-} 1
-test string-6.16 {string match} {
- string match {12[ab2-4cd]45} 12345
-} 1
-test string-6.17 {string match} {
- string match {12[ab2-4cd]45} 12b45
-} 1
-test string-6.18 {string match} {
- string match {12[ab2-4cd]45} 12d45
-} 1
-test string-6.19 {string match} {
- string match {12[ab2-4cd]45} 12145
-} 0
-test string-6.20 {string match} {
- string match {12[ab2-4cd]45} 12545
-} 0
-test string-6.21 {string match} {
- string match {a\*b} a*b
-} 1
-test string-6.22 {string match} {
- string match {a\*b} ab
-} 0
-test string-6.23 {string match} {
- string match {a\*\?\[\]\\\x} "a*?\[\]\\x"
-} 1
-test string-6.24 {string match} {
- string match ** ""
-} 1
-test string-6.25 {string match} {
- string match *. ""
-} 0
-test string-6.26 {string match} {
- string match "" ""
-} 1
-test string-6.27 {string match} {
- string match \[a a
-} 1
-test string-6.28 {string match} {
- list [catch {string match a} msg] $msg
-} {1 {wrong # args: should be "string match pattern string"}}
-test string-6.29 {string match} {
- list [catch {string match a b c} msg] $msg
-} {1 {wrong # args: should be "string match pattern string"}}
-
-test string-7.1 {string range} {
- string range abcdefghijklmnop 2 14
-} {cdefghijklmno}
-test string-7.2 {string range} {
- string range abcdefghijklmnop 7 1000
-} {hijklmnop}
-test string-7.3 {string range} {
- string range abcdefghijklmnop 10 e
-} {klmnop}
-test string-7.4 {string range} {
- string range abcdefghijklmnop 10 9
-} {}
-test string-7.5 {string range} {
- string range abcdefghijklmnop -3 2
-} {abc}
-test string-7.6 {string range} {
- string range abcdefghijklmnop -3 -2
-} {}
-test string-7.7 {string range} {
- string range abcdefghijklmnop 1000 1010
-} {}
-test string-7.8 {string range} {
- string range abcdefghijklmnop -100 end
-} {abcdefghijklmnop}
-test string-7.9 {string range} {
- list [catch {string range} msg] $msg
-} {1 {wrong # args: should be "string range string first last"}}
-test string-7.10 {string range} {
- list [catch {string range a 1} msg] $msg
-} {1 {wrong # args: should be "string range string first last"}}
-test string-7.11 {string range} {
- list [catch {string range a 1 2 3} msg] $msg
-} {1 {wrong # args: should be "string range string first last"}}
-test string-7.12 {string range} {
- list [catch {string range abc abc 1} msg] $msg
-} {1 {bad index "abc": must be integer or "end"}}
-test string-7.13 {string range} {
- list [catch {string range abc 1 eof} msg] $msg
-} {1 {bad index "eof": must be integer or "end"}}
-test string-7.14 {string range} {
- string range abcdefghijklmnop end end
-} {p}
-test string-7.15 {string range} {
- string range abcdefghijklmnop e 1000
-} {p}
-
-test string-8.1 {string trim} {
- string trim " XYZ "
-} {XYZ}
-test string-8.2 {string trim} {
- string trim "\t\nXYZ\t\n\r\n"
-} {XYZ}
-test string-8.3 {string trim} {
- string trim " A XYZ A "
-} {A XYZ A}
-test string-8.4 {string trim} {
- string trim "XXYYZZABC XXYYZZ" ZYX
-} {ABC }
-test string-8.5 {string trim} {
- string trim " \t\r "
-} {}
-test string-8.6 {string trim} {
- string trim {abcdefg} {}
-} {abcdefg}
-test string-8.7 {string trim} {
- string trim {}
-} {}
-test string-8.8 {string trim} {
- string trim ABC DEF
-} {ABC}
-test string-8.9 {string trim} {
- list [catch {string trim} msg] $msg
-} {1 {wrong # args: should be "string trim string ?chars?"}}
-test string-8.10 {string trim} {
- list [catch {string trim a b c} msg] $msg
-} {1 {wrong # args: should be "string trim string ?chars?"}}
-
-test string-9.1 {string trimleft} {
- string trimleft " XYZ "
-} {XYZ }
-test string-9.2 {string trimleft} {
- list [catch {string trimleft} msg] $msg
-} {1 {wrong # args: should be "string trimleft string ?chars?"}}
-
-test string-10.1 {string trimright} {
- string trimright " XYZ "
-} { XYZ}
-test string-10.2 {string trimright} {
- string trimright " "
-} {}
-test string-10.3 {string trimright} {
- string trimright ""
-} {}
-test string-10.4 {string trimright errors} {
- list [catch {string trimright} msg] $msg
-} {1 {wrong # args: should be "string trimright string ?chars?"}}
-test string-10.5 {string trimright errors} {
- list [catch {string trimg a} msg] $msg
-} {1 {bad option "trimg": must be compare, first, index, last, length, match, range, tolower, toupper, totitle, trim, trimleft, trimright, wordend, or wordstart}}
-
-test string-11.1 {string tolower} {
- string tolower ABCDeF
-} {abcdef}
-test string-11.2 {string tolower} {
- string tolower "ABC XyZ"
-} {abc xyz}
-test string-11.3 {string tolower} {
- string tolower {123#$&*()}
-} {123#$&*()}
-test string-11.4 {string tolower} {
- list [catch {string tolower} msg] $msg
-} {1 {wrong # args: should be "string tolower string"}}
-test string-11.5 {string tolower} {
- list [catch {string tolower a b} msg] $msg
-} {1 {wrong # args: should be "string tolower string"}}
-
-test string-12.1 {string toupper} {
- string toupper abCDEf
-} {ABCDEF}
-test string-12.2 {string toupper} {
- string toupper "abc xYz"
-} {ABC XYZ}
-test string-12.3 {string toupper} {
- string toupper {123#$&*()}
-} {123#$&*()}
-test string-12.4 {string toupper} {
- list [catch {string toupper} msg] $msg
-} {1 {wrong # args: should be "string toupper string"}}
-test string-12.5 {string toupper} {
- list [catch {string toupper a b} msg] $msg
-} {1 {wrong # args: should be "string toupper string"}}
-
-test string-13.1 {string wordend} {
- list [catch {string wordend a} msg] $msg
-} {1 {wrong # args: should be "string wordend string index"}}
-test string-13.2 {string wordend} {
- list [catch {string wordend a b c} msg] $msg
-} {1 {wrong # args: should be "string wordend string index"}}
-test string-13.3 {string wordend} {
- list [catch {string wordend a gorp} msg] $msg
-} {1 {expected integer but got "gorp"}}
-test string-13.4 {string wordend} {
- string wordend abc. -1
-} 3
-test string-13.5 {string wordend} {
- string wordend abc. 100
-} 4
-test string-13.6 {string wordend} {
- string wordend "word_one two three" 2
-} 8
-test string-13.7 {string wordend} {
- string wordend "one .&# three" 5
-} 6
-test string-13.8 {string wordend} {
- string worde "x.y" 0
-} 1
-
-test string-14.1 {string wordstart} {
- list [catch {string word a} msg] $msg
-} {1 {ambiguous option "word": must be compare, first, index, last, length, match, range, tolower, toupper, totitle, trim, trimleft, trimright, wordend, or wordstart}}
-test string-14.2 {string wordstart} {
- list [catch {string wordstart a} msg] $msg
-} {1 {wrong # args: should be "string wordstart string index"}}
-test string-14.3 {string wordstart} {
- list [catch {string wordstart a b c} msg] $msg
-} {1 {wrong # args: should be "string wordstart string index"}}
-test string-14.4 {string wordstart} {
- list [catch {string wordstart a gorp} msg] $msg
-} {1 {expected integer but got "gorp"}}
-test string-14.5 {string wordstart} {
- string wordstart "one two three_words" 400
-} 8
-test string-14.6 {string wordstart} {
- string wordstart "one two three_words" 2
-} 0
-test string-14.7 {string wordend} {
- string wordstart "one two three_words" -2
-} 0
-test string-14.8 {string wordend} {
- string wordstart "one .*&^ three" 6
-} 6
-test string-14.9 {string wordend} {
- string wordstart "one two three" 4
-} 4
-
-test string-15.1 {error conditions} {
- list [catch {string gorp a b} msg] $msg
-} {1 {bad option "gorp": must be compare, first, index, last, length, match, range, tolower, toupper, totitle, trim, trimleft, trimright, wordend, or wordstart}}
-test string-15.2 {error conditions} {
- list [catch {string} msg] $msg
-} {1 {wrong # args: should be "string option arg ?arg ...?"}}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/stringObj.test b/tests/stringObj.test
deleted file mode 100644
index 33100e5..0000000
--- a/tests/stringObj.test
+++ /dev/null
@@ -1,209 +0,0 @@
-# Commands covered: none
-#
-# This file contains tests for the procedures in tclStringObj.c
-# that implement the Tcl type manager for the string type.
-#
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 1995-1997 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: stringObj.test,v 1.3 1999/04/16 00:47:35 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[info commands testobj] == {}} {
- puts "This application hasn't been compiled with the \"testobj\""
- puts "command, so I can't test the Tcl type and object support."
- ::tcltest::cleanupTests
- return
-}
-
-test stringObj-1.1 {string type registration} {
- set t [testobj types]
- set first [string first "string" $t]
- set result [expr {$first != -1}]
-} {1}
-
-test stringObj-2.1 {Tcl_NewStringObj} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [teststringobj set 1 abcd]
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} abcd string 2}
-
-test stringObj-3.1 {Tcl_SetStringObj, existing "empty string" object} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testobj newobj 1]
- lappend result [teststringobj set 1 xyz] ;# makes existing obj a string
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} {} xyz string 2}
-test stringObj-3.2 {Tcl_SetStringObj, existing non-"empty string" object} {
- set result ""
- lappend result [testobj freeallvars]
- lappend result [testintobj set 1 512]
- lappend result [teststringobj set 1 foo] ;# makes existing obj a string
- lappend result [testobj type 1]
- lappend result [testobj refcount 1]
-} {{} 512 foo string 2}
-
-test stringObj-4.1 {Tcl_SetObjLength procedure, string gets shorter} {
- testobj freeallvars
- teststringobj set 1 test
- teststringobj setlength 1 3
- list [teststringobj length 1] [teststringobj length2 1] \
- [teststringobj get 1]
-} {3 4 tes}
-test stringObj-4.2 {Tcl_SetObjLength procedure, string gets longer} {
- testobj freeallvars
- teststringobj set 1 abcdef
- teststringobj setlength 1 10
- list [teststringobj length 1] [teststringobj length2 1]
-} {10 10}
-test stringObj-4.3 {Tcl_SetObjLength procedure, string gets longer} {
- testobj freeallvars
- teststringobj set 1 abcdef
- teststringobj append 1 xyzq -1
- list [teststringobj length 1] [teststringobj length2 1] \
- [teststringobj get 1]
-} {10 20 abcdefxyzq}
-test stringObj-4.4 {Tcl_SetObjLength procedure, "expty string", length 0} {
- testobj freeallvars
- testobj newobj 1
- teststringobj setlength 1 0
- list [teststringobj length2 1] [teststringobj get 1]
-} {0 {}}
-
-test stringObj-5.1 {Tcl_AppendToObj procedure, type conversion} {
- testobj freeallvars
- testintobj set2 1 43
- teststringobj append 1 xyz -1
- teststringobj get 1
-} {43xyz}
-test stringObj-5.2 {Tcl_AppendToObj procedure, length calculation} {
- testobj freeallvars
- teststringobj set 1 {x y }
- teststringobj append 1 bbCCddEE 4
- teststringobj append 1 123 -1
- teststringobj get 1
-} {x y bbCC123}
-test stringObj-5.3 {Tcl_AppendToObj procedure, reallocating space} {
- testobj freeallvars
- teststringobj set 1 xyz
- teststringobj setlength 1 15
- teststringobj setlength 1 2
- set result {}
- teststringobj append 1 1234567890123 -1
- lappend result [teststringobj length 1] [teststringobj length2 1]
- teststringobj setlength 1 10
- teststringobj append 1 abcdef -1
- lappend result [teststringobj length 1] [teststringobj length2 1] \
- [teststringobj get 1]
-} {15 15 16 32 xy12345678abcdef}
-
-test stringObj-6.1 {Tcl_AppendStringsToObj procedure, type conversion} {
- testobj freeallvars
- teststringobj set2 1 [list a b]
- teststringobj appendstrings 1 xyz { 1234 } foo
- teststringobj get 1
-} {a bxyz 1234 foo}
-test stringObj-6.2 {Tcl_AppendStringsToObj procedure, counting space} {
- testobj freeallvars
- teststringobj set 1 abc
- teststringobj appendstrings 1
- list [teststringobj length 1] [teststringobj get 1]
-} {3 abc}
-test stringObj-6.3 {Tcl_AppendStringsToObj procedure, counting space} {
- testobj freeallvars
- teststringobj set 1 abc
- teststringobj appendstrings 1 {} {} {} {}
- list [teststringobj length 1] [teststringobj get 1]
-} {3 abc}
-test stringObj-6.4 {Tcl_AppendStringsToObj procedure, counting space} {
- testobj freeallvars
- teststringobj set 1 abc
- teststringobj appendstrings 1 { 123 } abcdefg
- list [teststringobj length 1] [teststringobj get 1]
-} {15 {abc 123 abcdefg}}
-test stringObj-6.5 {Tcl_AppendStringsToObj procedure, don't double space if initial string empty} {
- testobj freeallvars
- testobj newobj 1
- teststringobj appendstrings 1 123 abcdefg
- list [teststringobj length 1] [teststringobj length2 1] [teststringobj get 1]
-} {10 10 123abcdefg}
-test stringObj-6.6 {Tcl_AppendStringsToObj procedure, space reallocation} {
- testobj freeallvars
- teststringobj set 1 abc
- teststringobj setlength 1 10
- teststringobj setlength 1 2
- teststringobj appendstrings 1 34567890
- list [teststringobj length 1] [teststringobj length2 1] \
- [teststringobj get 1]
-} {10 10 ab34567890}
-test stringObj-6.7 {Tcl_AppendStringsToObj procedure, space reallocation} {
- testobj freeallvars
- teststringobj set 1 abc
- teststringobj setlength 1 10
- teststringobj setlength 1 2
- teststringobj appendstrings 1 34567890x
- list [teststringobj length 1] [teststringobj length2 1] \
- [teststringobj get 1]
-} {11 22 ab34567890x}
-test stringObj-6.8 {Tcl_AppendStringsToObj procedure, object totally empty} {
- testobj freeallvars
- testobj newobj 1
- teststringobj appendstrings 1 {}
- list [teststringobj length2 1] [teststringobj get 1]
-} {0 {}}
-
-test stringObj-7.1 {ConvertToStringType procedure} {
- testobj freeallvars
- teststringobj set2 1 [list a b]
- teststringobj append 1 x -1
- list [teststringobj length 1] [teststringobj length2 1] \
- [teststringobj get 1]
-} {4 8 {a bx}}
-test stringObj-7.2 {ConvertToStringType procedure, null object} {
- testobj freeallvars
- testobj newobj 1
- teststringobj appendstrings 1 {}
- list [teststringobj length 1] [teststringobj length2 1] \
- [teststringobj get 1]
-} {0 0 {}}
-
-test stringObj-8.1 {DupStringInternalRep procedure} {
- testobj freeallvars
- teststringobj set 1 {}
- teststringobj append 1 abcde -1
- testobj duplicate 1 2
- list [teststringobj length 1] [teststringobj length2 1] \
- [teststringobj length 2] [teststringobj length2 2] \
- [teststringobj get 2]
-} {5 10 5 5 abcde}
-
-testobj freeallvars
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/subst.test b/tests/subst.test
deleted file mode 100644
index 51546d2..0000000
--- a/tests/subst.test
+++ /dev/null
@@ -1,125 +0,0 @@
-# Commands covered: subst
-#
-# 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) 1994 The Regents of the University of California.
-# Copyright (c) 1994 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: subst.test,v 1.3 1999/04/16 00:47:35 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test subst-1.1 {basics} {
- list [catch {subst} msg] $msg
-} {1 {wrong # args: should be "subst ?-nobackslashes? ?-nocommands? ?-novariables? string"}}
-test subst-1.2 {basics} {
- list [catch {subst a b c} msg] $msg
-} {1 {wrong # args: should be "subst ?-nobackslashes? ?-nocommands? ?-novariables? string"}}
-
-test subst-2.1 {simple strings} {
- subst {}
-} {}
-test subst-2.2 {simple strings} {
- subst a
-} a
-test subst-2.3 {simple strings} {
- subst abcdefg
-} abcdefg
-
-test subst-3.1 {backslash substitutions} {
- subst {\x\$x\[foo bar]\\}
-} "x\$x\[foo bar]\\"
-
-test subst-4.1 {variable substitutions} {
- set a 44
- subst {$a}
-} {44}
-test subst-4.2 {variable substitutions} {
- set a 44
- subst {x$a.y{$a}.z}
-} {x44.y{44}.z}
-test subst-4.3 {variable substitutions} {
- catch {unset a}
- set a(13) 82
- set i 13
- subst {x.$a($i)}
-} {x.82}
-catch {unset a}
-set long {This is a very long string, intentionally made so long that it
- will overflow the static character size for dstrings, so that
- additional memory will have to be allocated by subst. That way,
- if the subst procedure forgets to free up memory while returning
- an error, there will be memory that isn't freed (this will be
- detected when the tests are run under a checking memory allocator
- such as Purify).}
-test subst-4.4 {variable substitutions} {
- list [catch {subst {$long $a}} msg] $msg
-} {1 {can't read "a": no such variable}}
-
-test subst-5.1 {command substitutions} {
- subst {[concat {}]}
-} {}
-test subst-5.2 {command substitutions} {
- subst {[concat A test string]}
-} {A test string}
-test subst-5.3 {command substitutions} {
- subst {x.[concat foo].y.[concat bar].z}
-} {x.foo.y.bar.z}
-test subst-5.4 {command substitutions} {
- list [catch {subst {$long [set long] [bogus_command]}} msg] $msg
-} {1 {invalid command name "bogus_command"}}
-
-test subst-6.1 {clear the result after command substitution} {
- catch {unset a}
- list [catch {subst {[concat foo] $a}} msg] $msg
-} {1 {can't read "a": no such variable}}
-
-test subst-7.1 {switches} {
- list [catch {subst foo bar} msg] $msg
-} {1 {wrong # args: should be "subst ?-nobackslashes? ?-nocommands? ?-novariables? string"}}
-test subst-7.2 {switches} {
- list [catch {subst -no bar} msg] $msg
-} {1 {ambiguous switch "-no": must be -nobackslashes, -nocommands, or -novariables}}
-test subst-7.3 {switches} {
- list [catch {subst -bogus bar} msg] $msg
-} {1 {bad switch "-bogus": must be -nobackslashes, -nocommands, or -novariables}}
-test subst-7.4 {switches} {
- set x 123
- subst -nobackslashes {abc $x [expr 1+2] \\\x41}
-} {abc 123 3 \\\x41}
-test subst-7.5 {switches} {
- set x 123
- subst -nocommands {abc $x [expr 1+2] \\\x41}
-} {abc 123 [expr 1+2] \A}
-test subst-7.6 {switches} {
- set x 123
- subst -novariables {abc $x [expr 1+2] \\\x41}
-} {abc $x 3 \A}
-test subst-7.7 {switches} {
- set x 123
- subst -nov -nob -noc {abc $x [expr 1+2] \\\x41}
-} {abc $x [expr 1+2] \\\x41}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/switch.test b/tests/switch.test
deleted file mode 100644
index cdbfc61..0000000
--- a/tests/switch.test
+++ /dev/null
@@ -1,198 +0,0 @@
-# Commands covered: switch
-#
-# 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) 1993 The Regents of the University of California.
-# Copyright (c) 1994 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: switch.test,v 1.3 1999/04/16 00:47:35 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test switch-1.1 {simple patterns} {
- switch a a {format 1} b {format 2} c {format 3} default {format 4}
-} 1
-test switch-1.2 {simple patterns} {
- switch b a {format 1} b {format 2} c {format 3} default {format 4}
-} 2
-test switch-1.3 {simple patterns} {
- switch x a {format 1} b {format 2} c {format 3} default {format 4}
-} 4
-test switch-1.4 {simple patterns} {
- switch x a {format 1} b {format 2} c {format 3}
-} {}
-test switch-1.5 {simple pattern matches many times} {
- switch b a {format 1} b {format 2} b {format 3} b {format 4}
-} 2
-test switch-1.6 {simple patterns} {
- switch default a {format 1} default {format 2} c {format 3} default {format 4}
-} 2
-test switch-1.7 {simple patterns} {
- switch x a {format 1} default {format 2} c {format 3} default {format 4}
-} 4
-
-test switch-2.1 {single-argument form for pattern/command pairs} {
- switch b {
- a {format 1}
- b {format 2}
- default {format 6}
- }
-} {2}
-test switch-2.2 {single-argument form for pattern/command pairs} {
- list [catch {switch z {a 2 b}} msg] $msg
-} {1 {extra switch pattern with no body}}
-
-test switch-3.1 {-exact vs. -glob vs. -regexp} {
- switch -exact aaaab {
- ^a*b$ {concat regexp}
- *b {concat glob}
- aaaab {concat exact}
- default {concat none}
- }
-} exact
-test switch-3.2 {-exact vs. -glob vs. -regexp} {
- switch -regexp aaaab {
- ^a*b$ {concat regexp}
- *b {concat glob}
- aaaab {concat exact}
- default {concat none}
- }
-} regexp
-test switch-3.3 {-exact vs. -glob vs. -regexp} {
- switch -glob aaaab {
- ^a*b$ {concat regexp}
- *b {concat glob}
- aaaab {concat exact}
- default {concat none}
- }
-} glob
-test switch-3.4 {-exact vs. -glob vs. -regexp} {
- switch aaaab {^a*b$} {concat regexp} *b {concat glob} \
- aaaab {concat exact} default {concat none}
-} exact
-test switch-3.5 {-exact vs. -glob vs. -regexp} {
- switch -- -glob {
- ^g.*b$ {concat regexp}
- -* {concat glob}
- -glob {concat exact}
- default {concat none}
- }
-} exact
-test switch-3.6 {-exact vs. -glob vs. -regexp} {
- list [catch {switch -foo a b c} msg] $msg
-} {1 {bad option "-foo": must be -exact, -glob, -regexp, or --}}
-
-test switch-4.1 {error in executed command} {
- list [catch {switch a a {error "Just a test"} default {format 1}} msg] \
- $msg $errorInfo
-} {1 {Just a test} {Just a test
- while executing
-"error "Just a test""
- ("a" arm line 1)
- invoked from within
-"switch a a {error "Just a test"} default {format 1}"}}
-test switch-4.2 {error: not enough args} {
- list [catch {switch} msg] $msg
-} {1 {wrong # args: should be "switch ?switches? string pattern body ... ?default body?"}}
-test switch-4.3 {error: pattern with no body} {
- list [catch {switch a b} msg] $msg
-} {1 {extra switch pattern with no body}}
-test switch-4.4 {error: pattern with no body} {
- list [catch {switch a b {format 1} c} msg] $msg
-} {1 {extra switch pattern with no body}}
-test switch-4.5 {error in default command} {
- list [catch {switch foo a {error switch1} b {error switch 3} \
- default {error switch2}} msg] $msg $errorInfo
-} {1 switch2 {switch2
- while executing
-"error switch2"
- ("default" arm line 1)
- invoked from within
-"switch foo a {error switch1} b {error switch 3} default {error switch2}"}}
-
-test switch-5.1 {errors in -regexp matching} {
- list [catch {switch -regexp aaaab {
- *b {concat glob}
- aaaab {concat exact}
- default {concat none}
- }} msg] $msg
-} {1 {couldn't compile regular expression pattern: quantifier operand invalid}}
-
-test switch-6.1 {backslashes in patterns} {
- switch -exact {\a\$\.\[} {
- \a\$\.\[ {concat first}
- \a\\$\.\\[ {concat second}
- \\a\\$\\.\\[ {concat third}
- {\a\\$\.\\[} {concat fourth}
- {\\a\\$\\.\\[} {concat fifth}
- default {concat none}
- }
-} third
-test switch-6.2 {backslashes in patterns} {
- switch -exact {\a\$\.\[} {
- \a\$\.\[ {concat first}
- {\a\$\.\[} {concat second}
- {{\a\$\.\[}} {concat third}
- default {concat none}
- }
-} second
-
-test switch-7.1 {"-" bodies} {
- switch a {
- a -
- b -
- c {concat 1}
- default {concat 2}
- }
-} 1
-test switch-7.2 {"-" bodies} {
- list [catch {
- switch a {
- a -
- b -
- c -
- }
- } msg] $msg
-} {1 {no body specified for pattern "a"}}
-test switch-7.3 {"-" bodies} {
- list [catch {
- switch a {
- a -
- b -foo
- c -
- }
- } msg] $msg
-} {1 {invalid command name "-foo"}}
-
-test switch-8.1 {empty body} {
- set msg {}
- switch {2} {
- 1 {set msg 1}
- 2 {}
- default {set msg 2}
- }
-} {}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/thread.test b/tests/thread.test
deleted file mode 100644
index b3051ed..0000000
--- a/tests/thread.test
+++ /dev/null
@@ -1,240 +0,0 @@
-# Commands covered: (test)thread
-#
-# 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) 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: thread.test,v 1.2 1999/04/16 00:47:35 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[info command testthread] == ""} {
- puts "skipping: tests require the testthread command"
- ::tcltest::cleanupTests
- return
-}
-
-set mainthread [testthread names]
-proc ThreadReap {} {
- global mainthread
- testthread errorproc ThreadNullError
- while {[llength [testthread names]] > 1} {
- foreach tid [testthread names] {
- if {$tid != $mainthread} {
- catch {testthread send -async $tid {testthread exit}}
- update
- }
- }
- }
- testthread errorproc ThreadError
- return [llength [testthread names]]
-}
-testthread errorproc ThreadError
-proc ThreadError {id info} {
- global threadError
- set threadError $info
-}
-proc ThreadNullError {id info} {
- # ignore
-}
-
-test thread-1.1 {Tcl_ThreadObjCmd: no args} {
- list [catch {testthread} msg] $msg
-} {1 {wrong # args: should be "testthread option ?args?"}}
-
-test thread-1.2 {Tcl_ThreadObjCmd: bad option} {
- list [catch {testthread foo} msg] $msg
-} {1 {bad option "foo": must be create, exit, id, names, send, wait, or errorproc}}
-
-test thread-1.3 {Tcl_ThreadObjCmd: initial thread list} {
- list [catch {testthread names} mainthread] [llength $mainthread]
-} {0 1}
-
-test thread-1.4 {Tcl_ThreadObjCmd: thread create } {
- set serverthread [testthread create]
- update
- set numthreads [llength [testthread names]]
-} {2}
-ThreadReap
-
-test thread-1.5 {Tcl_ThreadObjCmd: thread create one shot} {
- testthread create {set x 5}
- foreach try {0 1 2 4 5 6} {
- # Try various ways to yeild
- update
- after 10
- set l [llength [testthread names]]
- if {$l == 1} {
- break
- }
- }
- set l
-} {1}
-ThreadReap
-
-test thread-1.6 {Tcl_ThreadObjCmd: thread exit} {
- testthread create {testthread exit}
- update
- after 10
- llength [testthread names]
-} {1}
-ThreadReap
-
-test thread-1.7 {Tcl_ThreadObjCmd: thread id args} {
- set x [catch {testthread id x} msg]
- list $x $msg
-} {1 {wrong # args: should be "testthread id"}}
-
-test thread-1.8 {Tcl_ThreadObjCmd: thread id} {
- string compare [testthread id] $mainthread
-} {0}
-
-test thread-1.9 {Tcl_ThreadObjCmd: thread names args} {
- set x [catch {testthread names x} msg]
- list $x $msg
-} {1 {wrong # args: should be "testthread names"}}
-
-test thread-1.10 {Tcl_ThreadObjCmd: thread id} {
- string compare [testthread names] $mainthread
-} {0}
-
-test thread-1.11 {Tcl_ThreadObjCmd: send args} {
- set x [catch {testthread send} msg]
- list $x $msg
-} {1 {wrong # args: should be "testthread send ?-async? id script"}}
-
-test thread-1.12 {Tcl_ThreadObjCmd: send nonint} {
- set x [catch {testthread send abc command} msg]
- list $x $msg
-} {1 {expected integer but got "abc"}}
-
-test thread-1.13 {Tcl_ThreadObjCmd: send args} {
- set serverthread [testthread create]
- set five [testthread send $serverthread {set x 5}]
- ThreadReap
- set five
-} 5
-
-test thread-1.14 {Tcl_ThreadObjCmd: send bad id} {
- set tid [expr $mainthread + 10]
- set x [catch {testthread send $tid {set x 5}} msg]
- list $x $msg
-} {1 {invalid thread id}}
-
-test thread-1.15 {Tcl_ThreadObjCmd: wait} {
- set serverthread [testthread create {set z 5 ; testthread wait}]
- set five [testthread send $serverthread {set z}]
- ThreadReap
- set five
-} 5
-
-test thread-1.16 {Tcl_ThreadObjCmd: errorproc args} {
- set x [catch {testthread errorproc foo bar} msg]
- list $x $msg
-} {1 {wrong # args: should be "testthread errorproc proc"}}
-
-test thread-1.17 {Tcl_ThreadObjCmd: errorproc change} {
- testthread errorproc foo
- testthread errorproc ThreadError
-} {}
-
-# The tests above also cover:
-# TclCreateThread, except when pthread_create fails
-# NewThread, safe and regular
-# ThreadErrorProc, except for printing to standard error
-
-test thread-2.1 {ListUpdateInner and ListRemove} {
- catch {unset tid}
- foreach t {0 1 2} {
- upvar #0 t$t tid
- set tid [testthread create]
- }
- ThreadReap
-} 1
-
-test thread-3.1 {TclThreadList} {
- catch {unset tid}
- set mainthread [testthread names]
- set l1 {}
- foreach t {0 1 2} {
- lappend l1 [testthread create]
- }
- set l2 [testthread names]
- list $l1 $l2
- set c [string compare [lsort -integer [concat $mainthread $l1]] [lsort -integer $l2]]
- ThreadReap
- set c
-} 0
-
-test thread-4.1 {TclThreadSend to self} {
- catch {unset x}
- testthread send [testthread id] {
- set x 4
- }
- set x
-} {4}
-
-test thread-4.1 {TclThreadSend -async} {
- set mainthread [testthread names]
- set serverthread [testthread create]
- testthread send -async $serverthread {
- after 1000
- testthread exit
- }
- set two [llength [testthread names]]
- after 1500 {set done 1}
- vwait done
- list [llength [testthread names]] $two
-} {1 2}
-
-test thread-4.2 {TclThreadSend preserve errorInfo} {
- set mainthread [testthread names]
- set serverthread [testthread create]
- set x [catch {testthread send $serverthread {set undef}} msg]
- list $x $msg $errorInfo
-} {1 {can't read "undef": no such variable} {can't read "undef": no such variable
- while executing
-"set undef"
- invoked from within
-"testthread send $serverthread {set undef}"}}
-ThreadReap
-
-test thread-4.3 {TclThreadSend preserve code} {
- set mainthread [testthread names]
- set serverthread [testthread create]
- set x [catch {testthread send $serverthread {break}} msg]
- list $x $msg $errorInfo
-} {3 {} {}}
-ThreadReap
-
-test thread-4.4 {TclThreadSend preserve errorCode} {
- set mainthread [testthread names]
- set serverthread [testthread create]
- set x [catch {testthread send $serverthread {error ERR INFO CODE}} msg]
- list $x $msg $errorCode
-} {1 ERR CODE}
-ThreadReap
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/timer.test b/tests/timer.test
deleted file mode 100644
index 0e6f4e6..0000000
--- a/tests/timer.test
+++ /dev/null
@@ -1,554 +0,0 @@
-# This file contains a collection of tests for the procedures in the
-# file tclTimer.c, which includes the "after" Tcl command. Sourcing
-# this file into Tcl runs the tests and generates output for errors.
-# No output means no errors were found.
-#
-# 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) 1997 by 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: timer.test,v 1.3 1999/04/16 00:47:35 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test timer-1.1 {Tcl_CreateTimerHandler procedure} {
- foreach i [after info] {
- after cancel $i
- }
- set x ""
- foreach i {100 200 1000 50 150} {
- after $i lappend x $i
- }
- after 200
- update
- set x
-} {50 100 150 200}
-
-test timer-2.1 {Tcl_DeleteTimerHandler procedure} {
- foreach i [after info] {
- after cancel $i
- }
- set x ""
- foreach i {100 200 300 50 150} {
- after $i lappend x $i
- }
- after cancel lappend x 150
- after cancel lappend x 50
- after 200
- update
- set x
-} {100 200}
-
-# No tests for Tcl_ServiceTimer or ResetTimer, since it is already tested
-# above.
-
-test timer-3.1 {TimerHandlerEventProc procedure: event masks} {
- set x start
- after 100 { set x fired }
- update idletasks
- set result $x
- after 200
- update
- lappend result $x
-} {start fired}
-test timer-3.2 {TimerHandlerEventProc procedure: multiple timers} {
- foreach i [after info] {
- after cancel $i
- }
- foreach i {200 600 1000} {
- after $i lappend x $i
- }
- after 200
- set result ""
- set x ""
- update
- lappend result $x
- after 400
- update
- lappend result $x
- after 400
- update
- lappend result $x
-} {200 {200 600} {200 600 1000}}
-test timer-3.3 {TimerHandlerEventProc procedure: reentrant timer deletion} {
- foreach i [after info] {
- after cancel $i
- }
- set x {}
- after 100 lappend x 100
- set i [after 300 lappend x 300]
- after 200 after cancel $i
- after 400
- update
- set x
-} 100
-test timer-3.4 {TimerHandlerEventProc procedure: all expired timers fire} {
- foreach i [after info] {
- after cancel $i
- }
- set x {}
- after 100 lappend x a
- after 200 lappend x b
- after 300 lappend x c
- after 300
- vwait x
- set x
-} {a b c}
-test timer-3.5 {TimerHandlerEventProc procedure: reentrantly added timers don't fire} {
- foreach i [after info] {
- after cancel $i
- }
- set x {}
- after 100 {lappend x a; after 0 lappend x b}
- after 100
- vwait x
- set x
-} a
-test timer-3.6 {TimerHandlerEventProc procedure: reentrantly added timers don't fire} {
- foreach i [after info] {
- after cancel $i
- }
- set x {}
- after 100 {lappend x a; after 100 lappend x b; after 100}
- after 100
- vwait x
- set result $x
- vwait x
- lappend result $x
-} {a {a b}}
-
-# No tests for Tcl_DoWhenIdle: it's already tested by other tests
-# below.
-
-test timer-4.1 {Tcl_CancelIdleCall procedure} {
- foreach i [after info] {
- after cancel $i
- }
- set x before
- set y before
- set z before
- after idle set x after1
- after idle set y after2
- after idle set z after3
- after cancel set y after2
- update idletasks
- concat $x $y $z
-} {after1 before after3}
-test timer-4.2 {Tcl_CancelIdleCall procedure} {
- foreach i [after info] {
- after cancel $i
- }
- set x before
- set y before
- set z before
- after idle set x after1
- after idle set y after2
- after idle set z after3
- after cancel set x after1
- update idletasks
- concat $x $y $z
-} {before after2 after3}
-
-test timer-5.1 {Tcl_ServiceIdle, self-rescheduling handlers} {
- foreach i [after info] {
- after cancel $i
- }
- set x 1
- set y 23
- after idle {incr x; after idle {incr x; after idle {incr x}}}
- after idle {incr y}
- vwait x
- set result "$x $y"
- update idletasks
- lappend result $x
-} {2 24 4}
-
-test timer-6.1 {Tcl_AfterCmd procedure, basics} {
- list [catch {after} msg] $msg
-} {1 {wrong # args: should be "after option ?arg arg ...?"}}
-test timer-6.2 {Tcl_AfterCmd procedure, basics} {
- list [catch {after 2x} msg] $msg
-} {1 {expected integer but got "2x"}}
-test timer-6.3 {Tcl_AfterCmd procedure, basics} {
- list [catch {after gorp} msg] $msg
-} {1 {bad argument "gorp": must be cancel, idle, info, or a number}}
-test timer-6.4 {Tcl_AfterCmd procedure, ms argument} {
- set x before
- after 400 {set x after}
- after 200
- update
- set y $x
- after 400
- update
- list $y $x
-} {before after}
-test timer-6.5 {Tcl_AfterCmd procedure, ms argument} {
- set x before
- after 300 set x after
- after 200
- update
- set y $x
- after 200
- update
- list $y $x
-} {before after}
-test timer-6.6 {Tcl_AfterCmd procedure, cancel option} {
- list [catch {after cancel} msg] $msg
-} {1 {wrong # args: should be "after cancel id|command"}}
-test timer-6.7 {Tcl_AfterCmd procedure, cancel option} {
- after cancel after#1
-} {}
-test timer-6.8 {Tcl_AfterCmd procedure, cancel option} {
- after cancel {foo bar}
-} {}
-test timer-6.9 {Tcl_AfterCmd procedure, cancel option} {
- foreach i [after info] {
- after cancel $i
- }
- set x before
- set y [after 100 set x after]
- after cancel $y
- after 200
- update
- set x
-} {before}
-test timer-6.10 {Tcl_AfterCmd procedure, cancel option} {
- foreach i [after info] {
- after cancel $i
- }
- set x before
- after 100 set x after
- after cancel {set x after}
- after 200
- update
- set x
-} {before}
-test timer-6.11 {Tcl_AfterCmd procedure, cancel option} {
- foreach i [after info] {
- after cancel $i
- }
- set x before
- after 100 set x after
- set id [after 300 set x after]
- after cancel $id
- after 200
- update
- set y $x
- set x cleared
- after 200
- update
- list $y $x
-} {after cleared}
-test timer-6.12 {Tcl_AfterCmd procedure, cancel option} {
- foreach i [after info] {
- after cancel $i
- }
- set x first
- after idle lappend x second
- after idle lappend x third
- set i [after idle lappend x fourth]
- after cancel {lappend x second}
- after cancel $i
- update idletasks
- set x
-} {first third}
-test timer-6.13 {Tcl_AfterCmd procedure, cancel option, multiple arguments for command} {
- foreach i [after info] {
- after cancel $i
- }
- set x first
- after idle lappend x second
- after idle lappend x third
- set i [after idle lappend x fourth]
- after cancel lappend x second
- after cancel $i
- update idletasks
- set x
-} {first third}
-test timer-6.14 {Tcl_AfterCmd procedure, cancel option, cancel during handler, used to dump core} {
- foreach i [after info] {
- after cancel $i
- }
- set id [
- after 100 {
- set x done
- after cancel $id
- }
- ]
- vwait x
-} {}
-test timer-6.15 {Tcl_AfterCmd procedure, cancel option, multiple interps} {
- foreach i [after info] {
- after cancel $i
- }
- interp create x
- x eval {set a before; set b before; after idle {set a a-after};
- after idle {set b b-after}}
- set result [llength [x eval after info]]
- lappend result [llength [after info]]
- after cancel {set b b-after}
- set a aaa
- set b bbb
- x eval {after cancel set a a-after}
- update idletasks
- lappend result $a $b [x eval {list $a $b}]
- interp delete x
- set result
-} {2 0 aaa bbb {before b-after}}
-test timer-6.16 {Tcl_AfterCmd procedure, idle option} {
- list [catch {after idle} msg] $msg
-} {1 {wrong # args: should be "after idle script script ..."}}
-test timer-6.17 {Tcl_AfterCmd procedure, idle option} {
- set x before
- after idle {set x after}
- set y $x
- update idletasks
- list $y $x
-} {before after}
-test timer-6.18 {Tcl_AfterCmd procedure, idle option} {
- set x before
- after idle set x after
- set y $x
- update idletasks
- list $y $x
-} {before after}
-set event1 [after idle event 1]
-set event2 [after 1000 event 2]
-interp create x
-set childEvent [x eval {after idle event in child}]
-test timer-6.19 {Tcl_AfterCmd, info option} {
- lsort [after info]
-} [lsort "$event1 $event2"]
-test timer-6.20 {Tcl_AfterCmd, info option} {
- list [catch {after info a b} msg] $msg
-} {1 {wrong # args: should be "after info ?id?"}}
-test timer-6.21 {Tcl_AfterCmd, info option} {
- list [catch {after info $childEvent} msg] $msg
-} "1 {event \"$childEvent\" doesn't exist}"
-test timer-6.22 {Tcl_AfterCmd, info option} {
- list [after info $event1] [after info $event2]
-} {{{event 1} idle} {{event 2} timer}}
-
-after cancel $event1
-after cancel $event2
-interp delete x
-
-test timer-6.23 {Tcl_AfterCmd procedure, no option, script with NULL} {
- foreach i [after info] {
- after cancel $i
- }
- set x "hello world"
- after 1 "set x ab\0cd"
- after 10
- update
- string length $x
-} {5}
-test timer-6.24 {Tcl_AfterCmd procedure, no option, script with NULL} {
- foreach i [after info] {
- after cancel $i
- }
- set x "hello world"
- after 1 set x ab\0cd
- after 10
- update
- string length $x
-} {5}
-test timer-6.25 {Tcl_AfterCmd procedure, cancel option, script with NULL} {
- foreach i [after info] {
- after cancel $i
- }
- set x "hello world"
- after 1 set x ab\0cd
- after cancel "set x ab\0ef"
- set x [llength [after info]]
- foreach i [after info] {
- after cancel $i
- }
- set x
-} {1}
-test timer-6.26 {Tcl_AfterCmd procedure, cancel option, script with NULL} {
- foreach i [after info] {
- after cancel $i
- }
- set x "hello world"
- after 1 set x ab\0cd
- after cancel set x ab\0ef
- set y [llength [after info]]
- foreach i [after info] {
- after cancel $i
- }
- set y
-} {1}
-test timer-6.27 {Tcl_AfterCmd procedure, idle option, script with NULL} {
- foreach i [after info] {
- after cancel $i
- }
- set x "hello world"
- after idle "set x ab\0cd"
- update
- string length $x
-} {5}
-test timer-6.28 {Tcl_AfterCmd procedure, idle option, script with NULL} {
- foreach i [after info] {
- after cancel $i
- }
- set x "hello world"
- after idle set x ab\0cd
- update
- string length $x
-} {5}
-test timer-6.29 {Tcl_AfterCmd procedure, info option, script with NULL} {
- foreach i [after info] {
- after cancel $i
- }
- set x "hello world"
- set id junk
- set id [after 1 set x ab\0cd]
- update
- set y [string length [lindex [lindex [after info $id] 0] 2]]
- foreach i [after info] {
- after cancel $i
- }
- set y
-} {5}
-
-set event [after idle foo bar]
-scan $event after#%d id
-
-test timer-7.1 {GetAfterEvent procedure} {
- list [catch {after info xfter#$id} msg] $msg
-} "1 {event \"xfter#$id\" doesn't exist}"
-test timer-7.2 {GetAfterEvent procedure} {
- list [catch {after info afterx$id} msg] $msg
-} "1 {event \"afterx$id\" doesn't exist}"
-test timer-7.3 {GetAfterEvent procedure} {
- list [catch {after info after#ab} msg] $msg
-} {1 {event "after#ab" doesn't exist}}
-test timer-7.4 {GetAfterEvent procedure} {
- list [catch {after info after#} msg] $msg
-} {1 {event "after#" doesn't exist}}
-test timer-7.5 {GetAfterEvent procedure} {
- list [catch {after info after#${id}x} msg] $msg
-} "1 {event \"after#${id}x\" doesn't exist}"
-test timer-7.6 {GetAfterEvent procedure} {
- list [catch {after info afterx[expr $id+1]} msg] $msg
-} "1 {event \"afterx[expr $id+1]\" doesn't exist}"
-after cancel $event
-
-test timer-8.1 {AfterProc procedure} {
- set x before
- proc foo {} {
- set x untouched
- after 100 {set x after}
- after 200
- update
- return $x
- }
- list [foo] $x
-} {untouched after}
-test timer-8.2 {AfterProc procedure} {
- catch {rename bgerror {}}
- proc bgerror msg {
- global x errorInfo
- set x [list $msg $errorInfo]
- }
- set x empty
- after 100 {error "After error"}
- after 200
- set y $x
- update
- catch {rename bgerror {}}
- list $y $x
-} {empty {{After error} {After error
- while executing
-"error "After error""
- ("after" script)}}}
-test timer-8.3 {AfterProc procedure, deleting handler from itself} {
- foreach i [after info] {
- after cancel $i
- }
- proc foo {} {
- global x
- set x {}
- foreach i [after info] {
- lappend x [after info $i]
- }
- after cancel foo
- }
- after idle foo
- after 1000 {error "I shouldn't ever have executed"}
- update idletasks
- set x
-} {{{error "I shouldn't ever have executed"} timer}}
-test timer-8.4 {AfterProc procedure, deleting handler from itself} {
- foreach i [after info] {
- after cancel $i
- }
- proc foo {} {
- global x
- set x {}
- foreach i [after info] {
- lappend x [after info $i]
- }
- after cancel foo
- }
- after 1000 {error "I shouldn't ever have executed"}
- after idle foo
- update idletasks
- set x
-} {{{error "I shouldn't ever have executed"} timer}}
-
-foreach i [after info] {
- after cancel $i
-}
-
-# No test for FreeAfterPtr, since it is already tested above.
-
-
-test timer-9.1 {AfterCleanupProc procedure} {
- catch {interp delete x}
- interp create x
- x eval {after 200 {
- lappend x after
- puts "part 1: this message should not appear"
- }}
- after 200 {lappend x after2}
- x eval {after 200 {
- lappend x after3
- puts "part 2: this message should not appear"
- }}
- after 200 {lappend x after4}
- x eval {after 200 {
- lappend x after5
- puts "part 3: this message should not appear"
- }}
- interp delete x
- set x before
- after 300
- update
- set x
-} {before after2 after4}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/trace.test b/tests/trace.test
deleted file mode 100644
index a2dd45e..0000000
--- a/tests/trace.test
+++ /dev/null
@@ -1,984 +0,0 @@
-# Commands covered: trace
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: trace.test,v 1.3 1999/04/16 00:47:35 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-proc traceScalar {name1 name2 op} {
- global info
- set info [list $name1 $name2 $op [catch {uplevel set $name1} msg] $msg]
-}
-proc traceScalarAppend {name1 name2 op} {
- global info
- lappend info $name1 $name2 $op [catch {uplevel set $name1} msg] $msg
-}
-proc traceArray {name1 name2 op} {
- global info
- set info [list $name1 $name2 $op [catch {uplevel set [set name1]($name2)} msg] $msg]
-}
-proc traceArray2 {name1 name2 op} {
- global info
- set info [list $name1 $name2 $op]
-}
-proc traceProc {name1 name2 op} {
- global info
- set info [concat $info [list $name1 $name2 $op]]
-}
-proc traceTag {tag args} {
- global info
- set info [concat $info $tag]
-}
-proc traceError {args} {
- error "trace returned error"
-}
-proc traceCheck {cmd args} {
- global info
- set info [list [catch $cmd msg] $msg]
-}
-proc traceCrtElement {value name1 name2 op} {
- uplevel set ${name1}($name2) $value
-}
-
-# Read-tracing on variables
-
-test trace-1.1 {trace variable reads} {
- catch {unset x}
- set info {}
- trace var x r traceScalar
- list [catch {set x} msg] $msg $info
-} {1 {can't read "x": no such variable} {x {} r 1 {can't read "x": no such variable}}}
-test trace-1.2 {trace variable reads} {
- catch {unset x}
- set x 123
- set info {}
- trace var x r traceScalar
- list [catch {set x} msg] $msg $info
-} {0 123 {x {} r 0 123}}
-test trace-1.3 {trace variable reads} {
- catch {unset x}
- set info {}
- trace var x r traceScalar
- set x 123
- set info
-} {}
-test trace-1.4 {trace array element reads} {
- catch {unset x}
- set info {}
- trace var x(2) r traceArray
- list [catch {set x(2)} msg] $msg $info
-} {1 {can't read "x(2)": no such element in array} {x 2 r 1 {can't read "x(2)": no such element in array}}}
-test trace-1.5 {trace array element reads} {
- catch {unset x}
- set x(2) zzz
- set info {}
- trace var x(2) r traceArray
- list [catch {set x(2)} msg] $msg $info
-} {0 zzz {x 2 r 0 zzz}}
-test trace-1.6 {trace array element reads} {
- catch {unset x}
- set info {}
- trace variable x r traceArray2
- proc p {} {
- global x
- set x(2) willi
- return $x(2)
- }
- list [catch {p} msg] $msg $info
-} {0 willi {x 2 r}}
-test trace-1.7 {trace array element reads, create element undefined if nonexistant} {
- catch {unset x}
- set info {}
- trace variable x r q
- proc q {name1 name2 op} {
- global info
- set info [list $name1 $name2 $op]
- global $name1
- set ${name1}($name2) wolf
- }
- proc p {} {
- global x
- set x(X) willi
- return $x(Y)
- }
- list [catch {p} msg] $msg $info
-} {0 wolf {x Y r}}
-test trace-1.8 {trace reads on whole arrays} {
- catch {unset x}
- set info {}
- trace var x r traceArray
- list [catch {set x(2)} msg] $msg $info
-} {1 {can't read "x(2)": no such variable} {}}
-test trace-1.9 {trace reads on whole arrays} {
- catch {unset x}
- set x(2) zzz
- set info {}
- trace var x r traceArray
- list [catch {set x(2)} msg] $msg $info
-} {0 zzz {x 2 r 0 zzz}}
-test trace-1.10 {trace variable reads} {
- catch {unset x}
- set x 444
- set info {}
- trace var x r traceScalar
- unset x
- set info
-} {}
-
-# Basic write-tracing on variables
-
-test trace-2.1 {trace variable writes} {
- catch {unset x}
- set info {}
- trace var x w traceScalar
- set x 123
- set info
-} {x {} w 0 123}
-test trace-2.2 {trace writes to array elements} {
- catch {unset x}
- set info {}
- trace var x(33) w traceArray
- set x(33) 444
- set info
-} {x 33 w 0 444}
-test trace-2.3 {trace writes on whole arrays} {
- catch {unset x}
- set info {}
- trace var x w traceArray
- set x(abc) qq
- set info
-} {x abc w 0 qq}
-test trace-2.4 {trace variable writes} {
- catch {unset x}
- set x 1234
- set info {}
- trace var x w traceScalar
- set x
- set info
-} {}
-test trace-2.5 {trace variable writes} {
- catch {unset x}
- set x 1234
- set info {}
- trace var x w traceScalar
- unset x
- set info
-} {}
-
-# append no longer triggers read traces when fetching the old values of
-# variables before doing the append operation. However, lappend _does_
-# still trigger these read traces. Also lappend triggers only one write
-# trace: after appending all arguments to the list.
-
-test trace-3.1 {trace variable read-modify-writes} {
- catch {unset x}
- set info {}
- trace var x r traceScalarAppend
- append x 123
- append x 456
- lappend x 789
- set info
-} {x {} r 0 123456}
-test trace-3.2 {trace variable read-modify-writes} {
- catch {unset x}
- set info {}
- trace var x rw traceScalarAppend
- append x 123
- lappend x 456
- set info
-} {x {} w 0 123 x {} r 0 123 x {} w 0 {123 456}}
-
-# Basic unset-tracing on variables
-
-test trace-4.1 {trace variable unsets} {
- catch {unset x}
- set info {}
- trace var x u traceScalar
- catch {unset x}
- set info
-} {x {} u 1 {can't read "x": no such variable}}
-test trace-4.2 {variable mustn't exist during unset trace} {
- catch {unset x}
- set x 1234
- set info {}
- trace var x u traceScalar
- unset x
- set info
-} {x {} u 1 {can't read "x": no such variable}}
-test trace-4.3 {unset traces mustn't be called during reads and writes} {
- catch {unset x}
- set info {}
- trace var x u traceScalar
- set x 44
- set x
- set info
-} {}
-test trace-4.4 {trace unsets on array elements} {
- catch {unset x}
- set x(0) 18
- set info {}
- trace var x(1) u traceArray
- catch {unset x(1)}
- set info
-} {x 1 u 1 {can't read "x(1)": no such element in array}}
-test trace-4.5 {trace unsets on array elements} {
- catch {unset x}
- set x(1) 18
- set info {}
- trace var x(1) u traceArray
- unset x(1)
- set info
-} {x 1 u 1 {can't read "x(1)": no such element in array}}
-test trace-4.6 {trace unsets on array elements} {
- catch {unset x}
- set x(1) 18
- set info {}
- trace var x(1) u traceArray
- unset x
- set info
-} {x 1 u 1 {can't read "x(1)": no such variable}}
-test trace-4.7 {trace unsets on whole arrays} {
- catch {unset x}
- set x(1) 18
- set info {}
- trace var x u traceProc
- catch {unset x(0)}
- set info
-} {}
-test trace-4.8 {trace unsets on whole arrays} {
- catch {unset x}
- set x(1) 18
- set x(2) 144
- set x(3) 14
- set info {}
- trace var x u traceProc
- unset x(1)
- set info
-} {x 1 u}
-test trace-4.9 {trace unsets on whole arrays} {
- catch {unset x}
- set x(1) 18
- set x(2) 144
- set x(3) 14
- set info {}
- trace var x u traceProc
- unset x
- set info
-} {x {} u}
-
-# Trace multiple trace types at once.
-
-test trace-5.1 {multiple ops traced at once} {
- catch {unset x}
- set info {}
- trace var x rwu traceProc
- catch {set x}
- set x 22
- set x
- set x 33
- unset x
- set info
-} {x {} r x {} w x {} r x {} w x {} u}
-test trace-5.2 {multiple ops traced on array element} {
- catch {unset x}
- set info {}
- trace var x(0) rwu traceProc
- catch {set x(0)}
- set x(0) 22
- set x(0)
- set x(0) 33
- unset x(0)
- unset x
- set info
-} {x 0 r x 0 w x 0 r x 0 w x 0 u}
-test trace-5.3 {multiple ops traced on whole array} {
- catch {unset x}
- set info {}
- trace var x rwu traceProc
- catch {set x(0)}
- set x(0) 22
- set x(0)
- set x(0) 33
- unset x(0)
- unset x
- set info
-} {x 0 w x 0 r x 0 w x 0 u x {} u}
-
-# Check order of invocation of traces
-
-test trace-6.1 {order of invocation of traces} {
- catch {unset x}
- set info {}
- trace var x r "traceTag 1"
- trace var x r "traceTag 2"
- trace var x r "traceTag 3"
- catch {set x}
- set x 22
- set x
- set info
-} {3 2 1 3 2 1}
-test trace-6.2 {order of invocation of traces} {
- catch {unset x}
- set x(0) 44
- set info {}
- trace var x(0) r "traceTag 1"
- trace var x(0) r "traceTag 2"
- trace var x(0) r "traceTag 3"
- set x(0)
- set info
-} {3 2 1}
-test trace-6.3 {order of invocation of traces} {
- catch {unset x}
- set x(0) 44
- set info {}
- trace var x(0) r "traceTag 1"
- trace var x r "traceTag A1"
- trace var x(0) r "traceTag 2"
- trace var x r "traceTag A2"
- trace var x(0) r "traceTag 3"
- trace var x r "traceTag A3"
- set x(0)
- set info
-} {A3 A2 A1 3 2 1}
-
-# Check effects of errors in trace procedures
-
-test trace-7.1 {error returns from traces} {
- catch {unset x}
- set x 123
- set info {}
- trace var x r "traceTag 1"
- trace var x r traceError
- list [catch {set x} msg] $msg $info
-} {1 {can't read "x": trace returned error} {}}
-test trace-7.2 {error returns from traces} {
- catch {unset x}
- set x 123
- set info {}
- trace var x w "traceTag 1"
- trace var x w traceError
- list [catch {set x 44} msg] $msg $info
-} {1 {can't set "x": trace returned error} {}}
-test trace-7.3 {error returns from traces} {
- catch {unset x}
- set x 123
- set info {}
- trace var x w traceError
- list [catch {append x 44} msg] $msg $info
-} {1 {can't set "x": trace returned error} {}}
-test trace-7.4 {error returns from traces} {
- catch {unset x}
- set x 123
- set info {}
- trace var x u "traceTag 1"
- trace var x u traceError
- list [catch {unset x} msg] $msg $info
-} {0 {} 1}
-test trace-7.5 {error returns from traces} {
- catch {unset x}
- set x(0) 123
- set info {}
- trace var x(0) r "traceTag 1"
- trace var x r "traceTag 2"
- trace var x r traceError
- trace var x r "traceTag 3"
- list [catch {set x(0)} msg] $msg $info
-} {1 {can't read "x(0)": trace returned error} 3}
-test trace-7.6 {error returns from traces} {
- catch {unset x}
- set x 123
- trace var x u traceError
- list [catch {unset x} msg] $msg
-} {0 {}}
-test trace-7.7 {error returns from traces} {
- # This test just makes sure that the memory for the error message
- # gets deallocated correctly when the trace is invoked again or
- # when the trace is deleted.
- catch {unset x}
- set x 123
- trace var x r traceError
- catch {set x}
- catch {set x}
- trace vdelete x r traceError
-} {}
-
-# Check to see that variables are expunged before trace
-# procedures are invoked, so trace procedure can even manipulate
-# a new copy of the variables.
-
-test trace-8.1 {be sure variable is unset before trace is called} {
- catch {unset x}
- set x 33
- set info {}
- trace var x u {traceCheck {uplevel set x}}
- unset x
- set info
-} {1 {can't read "x": no such variable}}
-test trace-8.2 {be sure variable is unset before trace is called} {
- catch {unset x}
- set x 33
- set info {}
- trace var x u {traceCheck {uplevel set x 22}}
- unset x
- concat $info [list [catch {set x} msg] $msg]
-} {0 22 0 22}
-test trace-8.3 {be sure traces are cleared before unset trace called} {
- catch {unset x}
- set x 33
- set info {}
- trace var x u {traceCheck {uplevel trace vinfo x}}
- unset x
- set info
-} {0 {}}
-test trace-8.4 {set new trace during unset trace} {
- catch {unset x}
- set x 33
- set info {}
- trace var x u {traceCheck {global x; trace var x u traceProc}}
- unset x
- concat $info [trace vinfo x]
-} {0 {} {u traceProc}}
-
-test trace-9.1 {make sure array elements are unset before traces are called} {
- catch {unset x}
- set x(0) 33
- set info {}
- trace var x(0) u {traceCheck {uplevel set x(0)}}
- unset x(0)
- set info
-} {1 {can't read "x(0)": no such element in array}}
-test trace-9.2 {make sure array elements are unset before traces are called} {
- catch {unset x}
- set x(0) 33
- set info {}
- trace var x(0) u {traceCheck {uplevel set x(0) zzz}}
- unset x(0)
- concat $info [list [catch {set x(0)} msg] $msg]
-} {0 zzz 0 zzz}
-test trace-9.3 {array elements are unset before traces are called} {
- catch {unset x}
- set x(0) 33
- set info {}
- trace var x(0) u {traceCheck {global x; trace vinfo x(0)}}
- unset x(0)
- set info
-} {0 {}}
-test trace-9.4 {set new array element trace during unset trace} {
- catch {unset x}
- set x(0) 33
- set info {}
- trace var x(0) u {traceCheck {uplevel {trace variable x(0) r {}}}}
- catch {unset x(0)}
- concat $info [trace vinfo x(0)]
-} {0 {} {r {}}}
-
-test trace-10.1 {make sure arrays are unset before traces are called} {
- catch {unset x}
- set x(0) 33
- set info {}
- trace var x u {traceCheck {uplevel set x(0)}}
- unset x
- set info
-} {1 {can't read "x(0)": no such variable}}
-test trace-10.2 {make sure arrays are unset before traces are called} {
- catch {unset x}
- set x(y) 33
- set info {}
- trace var x u {traceCheck {uplevel set x(y) 22}}
- unset x
- concat $info [list [catch {set x(y)} msg] $msg]
-} {0 22 0 22}
-test trace-10.3 {make sure arrays are unset before traces are called} {
- catch {unset x}
- set x(y) 33
- set info {}
- trace var x u {traceCheck {uplevel array exists x}}
- unset x
- set info
-} {0 0}
-test trace-10.4 {make sure arrays are unset before traces are called} {
- catch {unset x}
- set x(y) 33
- set info {}
- set cmd {traceCheck {uplevel {trace vinfo x}}}
- trace var x u $cmd
- unset x
- set info
-} {0 {}}
-test trace-10.5 {set new array trace during unset trace} {
- catch {unset x}
- set x(y) 33
- set info {}
- trace var x u {traceCheck {global x; trace var x r {}}}
- unset x
- concat $info [trace vinfo x]
-} {0 {} {r {}}}
-test trace-10.6 {create scalar during array unset trace} {
- catch {unset x}
- set x(y) 33
- set info {}
- trace var x u {traceCheck {global x; set x 44}}
- unset x
- concat $info [list [catch {set x} msg] $msg]
-} {0 44 0 44}
-
-# Check special conditions (e.g. errors) in Tcl_TraceVar2.
-
-test trace-11.1 {creating array when setting variable traces} {
- catch {unset x}
- set info {}
- trace var x(0) w traceProc
- list [catch {set x 22} msg] $msg
-} {1 {can't set "x": variable is array}}
-test trace-11.2 {creating array when setting variable traces} {
- catch {unset x}
- set info {}
- trace var x(0) w traceProc
- list [catch {set x(0)} msg] $msg
-} {1 {can't read "x(0)": no such element in array}}
-test trace-11.3 {creating array when setting variable traces} {
- catch {unset x}
- set info {}
- trace var x(0) w traceProc
- set x(0) 22
- set info
-} {x 0 w}
-test trace-11.4 {creating variable when setting variable traces} {
- catch {unset x}
- set info {}
- trace var x w traceProc
- list [catch {set x} msg] $msg
-} {1 {can't read "x": no such variable}}
-test trace-11.5 {creating variable when setting variable traces} {
- catch {unset x}
- set info {}
- trace var x w traceProc
- set x 22
- set info
-} {x {} w}
-test trace-11.6 {creating variable when setting variable traces} {
- catch {unset x}
- set info {}
- trace var x w traceProc
- set x(0) 22
- set info
-} {x 0 w}
-test trace-11.7 {create array element during read trace} {
- catch {unset x}
- set x(2) zzz
- trace var x r {traceCrtElement xyzzy}
- list [catch {set x(3)} msg] $msg
-} {0 xyzzy}
-test trace-11.8 {errors when setting variable traces} {
- catch {unset x}
- set x 44
- list [catch {trace var x(0) w traceProc} msg] $msg
-} {1 {can't trace "x(0)": variable isn't array}}
-
-# Check deleting one trace from another.
-
-test trace-12.1 {delete one trace from another} {
- proc delTraces {args} {
- global x
- trace vdel x r {traceTag 2}
- trace vdel x r {traceTag 3}
- trace vdel x r {traceTag 4}
- }
- catch {unset x}
- set x 44
- set info {}
- trace var x r {traceTag 1}
- trace var x r {traceTag 2}
- trace var x r {traceTag 3}
- trace var x r {traceTag 4}
- trace var x r delTraces
- trace var x r {traceTag 5}
- set x
- set info
-} {5 1}
-
-# Check operation and syntax of "trace" command.
-
-test trace-13.1 {trace command (overall)} {
- list [catch {trace} msg] $msg
-} {1 {wrong # args: should be "trace option [arg arg ...]"}}
-test trace-13.2 {trace command (overall)} {
- list [catch {trace gorp} msg] $msg
-} {1 {bad option "gorp": must be variable, vdelete, or vinfo}}
-test trace-13.3 {trace command ("variable" option)} {
- list [catch {trace variable x y} msg] $msg
-} {1 {wrong # args: should be "trace variable name ops command"}}
-test trace-13.4 {trace command ("variable" option)} {
- list [catch {trace var x y z z2} msg] $msg
-} {1 {wrong # args: should be "trace variable name ops command"}}
-test trace-13.5 {trace command ("variable" option)} {
- list [catch {trace var x y z} msg] $msg
-} {1 {bad operations "y": should be one or more of rwu}}
-test trace-13.6 {trace command ("vdelete" option)} {
- list [catch {trace vdelete x y} msg] $msg
-} {1 {wrong # args: should be "trace vdelete name ops command"}}
-test trace-13.7 {trace command ("vdelete" option)} {
- list [catch {trace vdelete x y z foo} msg] $msg
-} {1 {wrong # args: should be "trace vdelete name ops command"}}
-test trace-13.8 {trace command ("vdelete" option)} {
- list [catch {trace vdelete x y z} msg] $msg
-} {1 {bad operations "y": should be one or more of rwu}}
-test trace-13.9 {trace command ("vdelete" option)} {
- catch {unset x}
- set info {}
- trace var x w traceProc
- trace vdelete x w traceProc
-} {}
-test trace-13.10 {trace command ("vdelete" option)} {
- catch {unset x}
- set info {}
- trace var x w traceProc
- trace vdelete x w traceProc
- set x 12345
- set info
-} {}
-test trace-13.11 {trace command ("vdelete" option)} {
- catch {unset x}
- set info {}
- trace var x w {traceTag 1}
- trace var x w traceProc
- trace var x w {traceTag 2}
- set x yy
- trace vdelete x w traceProc
- set x 12345
- trace vdelete x w {traceTag 1}
- set x foo
- trace vdelete x w {traceTag 2}
- set x gorp
- set info
-} {2 x {} w 1 2 1 2}
-test trace-13.12 {trace command ("vdelete" option)} {
- catch {unset x}
- set info {}
- trace var x w {traceTag 1}
- trace vdelete x w non_existent
- set x 12345
- set info
-} {1}
-test trace-13.13 {trace command ("vinfo" option)} {
- list [catch {trace vinfo} msg] $msg]
-} {1 {wrong # args: should be "trace vinfo name"]}}
-test trace-13.14 {trace command ("vinfo" option)} {
- list [catch {trace vinfo x y} msg] $msg]
-} {1 {wrong # args: should be "trace vinfo name"]}}
-test trace-13.15 {trace command ("vinfo" option)} {
- catch {unset x}
- trace var x w {traceTag 1}
- trace var x w traceProc
- trace var x w {traceTag 2}
- trace vinfo x
-} {{w {traceTag 2}} {w traceProc} {w {traceTag 1}}}
-test trace-13.16 {trace command ("vinfo" option)} {
- catch {unset x}
- trace vinfo x
-} {}
-test trace-13.17 {trace command ("vinfo" option)} {
- catch {unset x}
- trace vinfo x(0)
-} {}
-test trace-13.18 {trace command ("vinfo" option)} {
- catch {unset x}
- set x 44
- trace vinfo x(0)
-} {}
-test trace-13.19 {trace command ("vinfo" option)} {
- catch {unset x}
- set x 44
- trace var x w {traceTag 1}
- proc check {} {global x; trace vinfo x}
- check
-} {{w {traceTag 1}}}
-
-# Check fancy trace commands (long ones, weird arguments, etc.)
-
-test trace-14.1 {long trace command} {
- catch {unset x}
- set info {}
- trace var x w {traceTag {This is a very very long argument. It's \
- designed to test out the facilities of TraceVarProc for dealing \
- with such long arguments by malloc-ing space. One possibility \
- is that space doesn't get freed properly. If this happens, then \
- invoking this test over and over again will eventually leak memory.}}
- set x 44
- set info
-} {This is a very very long argument. It's \
- designed to test out the facilities of TraceVarProc for dealing \
- with such long arguments by malloc-ing space. One possibility \
- is that space doesn't get freed properly. If this happens, then \
- invoking this test over and over again will eventually leak memory.}
-test trace-14.2 {long trace command result to ignore} {
- proc longResult {args} {return "quite a bit of text, designed to
- generate a core leak if this command file is invoked over and over again
- and memory isn't being recycled correctly"}
- catch {unset x}
- trace var x w longResult
- set x 44
- set x 5
- set x abcde
-} abcde
-test trace-14.3 {special list-handling in trace commands} {
- catch {unset "x y z"}
- set "x y z(a\n\{)" 44
- set info {}
- trace var "x y z(a\n\{)" w traceProc
- set "x y z(a\n\{)" 33
- set info
-} "{x y z} a\\n\\{ w"
-
-# Check for proper handling of unsets during traces.
-
-proc traceUnset {unsetName args} {
- global info
- upvar $unsetName x
- lappend info [catch {unset x} msg] $msg [catch {set x} msg] $msg
-}
-proc traceReset {unsetName resetName args} {
- global info
- upvar $unsetName x $resetName y
- lappend info [catch {unset x} msg] $msg [catch {set y xyzzy} msg] $msg
-}
-proc traceReset2 {unsetName resetName args} {
- global info
- lappend info [catch {uplevel unset $unsetName} msg] $msg \
- [catch {uplevel set $resetName xyzzy} msg] $msg
-}
-proc traceAppend {string name1 name2 op} {
- global info
- lappend info $string
-}
-
-test trace-15.1 {unsets during read traces} {
- catch {unset y}
- set y 1234
- set info {}
- trace var y r {traceUnset y}
- trace var y u {traceAppend unset}
- lappend info [catch {set y} msg] $msg
-} {unset 0 {} 1 {can't read "x": no such variable} 1 {can't read "y": no such variable}}
-test trace-15.2 {unsets during read traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) r {traceUnset y(0)}
- lappend info [catch {set y(0)} msg] $msg
-} {0 {} 1 {can't read "x": no such variable} 1 {can't read "y(0)": no such element in array}}
-test trace-15.3 {unsets during read traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) r {traceUnset y}
- lappend info [catch {set y(0)} msg] $msg
-} {0 {} 1 {can't read "x": no such variable} 1 {can't read "y(0)": no such variable}}
-test trace-15.4 {unsets during read traces} {
- catch {unset y}
- set y 1234
- set info {}
- trace var y r {traceReset y y}
- lappend info [catch {set y} msg] $msg
-} {0 {} 0 xyzzy 0 xyzzy}
-test trace-15.5 {unsets during read traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) r {traceReset y(0) y(0)}
- lappend info [catch {set y(0)} msg] $msg
-} {0 {} 0 xyzzy 0 xyzzy}
-test trace-15.6 {unsets during read traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) r {traceReset y y(0)}
- lappend info [catch {set y(0)} msg] $msg [catch {set y(0)} msg] $msg
-} {0 {} 1 {can't set "y": upvar refers to element in deleted array} 1 {can't read "y(0)": no such variable} 1 {can't read "y(0)": no such variable}}
-test trace-15.7 {unsets during read traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) r {traceReset2 y y(0)}
- lappend info [catch {set y(0)} msg] $msg [catch {set y(0)} msg] $msg
-} {0 {} 0 xyzzy 1 {can't read "y(0)": no such element in array} 0 xyzzy}
-test trace-15.8 {unsets during write traces} {
- catch {unset y}
- set y 1234
- set info {}
- trace var y w {traceUnset y}
- trace var y u {traceAppend unset}
- lappend info [catch {set y xxx} msg] $msg
-} {unset 0 {} 1 {can't read "x": no such variable} 0 {}}
-test trace-15.9 {unsets during write traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) w {traceUnset y(0)}
- lappend info [catch {set y(0) xxx} msg] $msg
-} {0 {} 1 {can't read "x": no such variable} 0 {}}
-test trace-15.10 {unsets during write traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) w {traceUnset y}
- lappend info [catch {set y(0) xxx} msg] $msg
-} {0 {} 1 {can't read "x": no such variable} 0 {}}
-test trace-15.11 {unsets during write traces} {
- catch {unset y}
- set y 1234
- set info {}
- trace var y w {traceReset y y}
- lappend info [catch {set y xxx} msg] $msg
-} {0 {} 0 xyzzy 0 xyzzy}
-test trace-15.12 {unsets during write traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) w {traceReset y(0) y(0)}
- lappend info [catch {set y(0) xxx} msg] $msg
-} {0 {} 0 xyzzy 0 xyzzy}
-test trace-15.13 {unsets during write traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) w {traceReset y y(0)}
- lappend info [catch {set y(0) xxx} msg] $msg [catch {set y(0)} msg] $msg
-} {0 {} 1 {can't set "y": upvar refers to element in deleted array} 0 {} 1 {can't read "y(0)": no such variable}}
-test trace-15.14 {unsets during write traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) w {traceReset2 y y(0)}
- lappend info [catch {set y(0) xxx} msg] $msg [catch {set y(0)} msg] $msg
-} {0 {} 0 xyzzy 0 {} 0 xyzzy}
-test trace-15.15 {unsets during unset traces} {
- catch {unset y}
- set y 1234
- set info {}
- trace var y u {traceUnset y}
- lappend info [catch {unset y} msg] $msg [catch {set y} msg] $msg
-} {1 {can't unset "x": no such variable} 1 {can't read "x": no such variable} 0 {} 1 {can't read "y": no such variable}}
-test trace-15.16 {unsets during unset traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) u {traceUnset y(0)}
- lappend info [catch {unset y(0)} msg] $msg [catch {set y(0)} msg] $msg
-} {1 {can't unset "x": no such variable} 1 {can't read "x": no such variable} 0 {} 1 {can't read "y(0)": no such element in array}}
-test trace-15.17 {unsets during unset traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) u {traceUnset y}
- lappend info [catch {unset y(0)} msg] $msg [catch {set y(0)} msg] $msg
-} {0 {} 1 {can't read "x": no such variable} 0 {} 1 {can't read "y(0)": no such variable}}
-test trace-15.18 {unsets during unset traces} {
- catch {unset y}
- set y 1234
- set info {}
- trace var y u {traceReset2 y y}
- lappend info [catch {unset y} msg] $msg [catch {set y} msg] $msg
-} {1 {can't unset "y": no such variable} 0 xyzzy 0 {} 0 xyzzy}
-test trace-15.19 {unsets during unset traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) u {traceReset2 y(0) y(0)}
- lappend info [catch {unset y(0)} msg] $msg [catch {set y(0)} msg] $msg
-} {1 {can't unset "y(0)": no such element in array} 0 xyzzy 0 {} 0 xyzzy}
-test trace-15.20 {unsets during unset traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) u {traceReset2 y y(0)}
- lappend info [catch {unset y(0)} msg] $msg [catch {set y(0)} msg] $msg
-} {0 {} 0 xyzzy 0 {} 0 xyzzy}
-test trace-15.21 {unsets cancelling traces} {
- catch {unset y}
- set y 1234
- set info {}
- trace var y r {traceAppend first}
- trace var y r {traceUnset y}
- trace var y r {traceAppend third}
- trace var y u {traceAppend unset}
- lappend info [catch {set y} msg] $msg
-} {third unset 0 {} 1 {can't read "x": no such variable} 1 {can't read "y": no such variable}}
-test trace-15.22 {unsets cancelling traces} {
- catch {unset y}
- set y(0) 1234
- set info {}
- trace var y(0) r {traceAppend first}
- trace var y(0) r {traceUnset y}
- trace var y(0) r {traceAppend third}
- trace var y(0) u {traceAppend unset}
- lappend info [catch {set y(0)} msg] $msg
-} {third unset 0 {} 1 {can't read "x": no such variable} 1 {can't read "y(0)": no such variable}}
-
-# Check various non-interference between traces and other things.
-
-test trace-16.1 {trace doesn't prevent unset errors} {
- catch {unset x}
- set info {}
- trace var x u {traceProc}
- list [catch {unset x} msg] $msg $info
-} {1 {can't unset "x": no such variable} {x {} u}}
-test trace-16.2 {traced variables must survive procedure exits} {
- catch {unset x}
- proc p1 {} {global x; trace var x w traceProc}
- p1
- trace vinfo x
-} {{w traceProc}}
-test trace-16.3 {traced variables must survive procedure exits} {
- catch {unset x}
- set info {}
- proc p1 {} {global x; trace var x w traceProc}
- p1
- set x 44
- set info
-} {x {} w}
-
-# Be sure that procedure frames are released before unset traces
-# are invoked.
-
-test trace-17.1 {unset traces on procedure returns} {
- proc p1 {x y} {set a 44; p2 14}
- proc p2 {z} {trace var z u {traceCheck {lsort [uplevel {info vars}]}}}
- set info {}
- p1 foo bar
- set info
-} {0 {a x y}}
-
-# Delete arrays when done, so they can be re-used as scalars
-# elsewhere.
-
-catch {unset x}
-catch {unset y}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/unixFCmd.test b/tests/unixFCmd.test
deleted file mode 100644
index d026aa3..0000000
--- a/tests/unixFCmd.test
+++ /dev/null
@@ -1,300 +0,0 @@
-# This file tests the tclUnixFCmd.c file.
-#
-# 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) 1996 Sun Microsystems, Inc.
-#
-# See the file "license.terms" for information on usage and redistribution
-# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-#
-# RCS: @(#) $Id: unixFCmd.test,v 1.6 1999/04/16 00:47:35 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Several tests require need to match results against the unix username
-set user {}
-if {$tcl_platform(platform) == "unix"} {
- catch {set user [exec whoami]}
- if {$user == ""} {
- catch {regexp {^[^(]*\(([^)]*)\)} [exec id] dummy user}
- }
- if {$user == ""} {
- set user "root"
- }
-}
-
-proc openup {path} {
- testchmod 777 $path
- if {[file isdirectory $path]} {
- catch {
- foreach p [glob [file join $path *]] {
- openup $p
- }
- }
- }
-}
-
-proc cleanup {args} {
- foreach p ". $args" {
- set x ""
- catch {
- set x [glob [file join $p tf*] [file join $p td*]]
- }
- foreach file $x {
- if {[catch {file delete -force -- $file}]} {
- openup $file
- file delete -force -- $file
- }
- }
- }
-}
-
-test unixFCmd-1.1 {TclpRenameFile: EACCES} {unixOnly notRoot} {
- cleanup
- file mkdir td1/td2/td3
- exec chmod 000 td1/td2
- set msg [list [catch {file rename td1/td2/td3 td2} msg] $msg]
- exec chmod 755 td1/td2
- set msg
-} {1 {error renaming "td1/td2/td3": permission denied}}
-test unixFCmd-1.2 {TclpRenameFile: EEXIST} {unixOnly notRoot} {
- cleanup
- file mkdir td1/td2
- file mkdir td2
- list [catch {file rename td2 td1} msg] $msg
-} {1 {error renaming "td2" to "td1/td2": file already exists}}
-test unixFCmd-1.3 {TclpRenameFile: EINVAL} {unixOnly notRoot} {
- cleanup
- file mkdir td1
- list [catch {file rename td1 td1} msg] $msg
-} {1 {error renaming "td1" to "td1/td1": trying to rename a volume or move a directory into itself}}
-test unixFCmd-1.4 {TclpRenameFile: EISDIR} {emptyTest unixOnly notRoot} {
- # can't make it happen
-} {}
-test unixFCmd-1.5 {TclpRenameFile: ENOENT} {unixOnly notRoot} {
- cleanup
- file mkdir td1
- list [catch {file rename td2 td1} msg] $msg
-} {1 {error renaming "td2": no such file or directory}}
-test unixFCmd-1.6 {TclpRenameFile: ENOTDIR} {emptyTest unixOnly notRoot} {
- # can't make it happen
-} {}
-test unixFCmd-1.7 {TclpRenameFile: EXDEV} {unixOnly notRoot} {
- cleanup
- file mkdir foo/bar
- file attr foo -perm 040555
- set catchResult [catch {file rename foo/bar /tmp} msg]
- set msg [lindex [split $msg :] end]
- catch {file delete /tmp/bar}
- catch {file attr foo -perm 040777}
- catch {file delete -force foo}
- list $catchResult $msg
-} {1 { permission denied}}
-test unixFCmd-1.8 {Checking EINTR Bug} {unixOnly notRoot nonPortable} {
- testalarm
- after 2000
- list [testgotsig] [testgotsig]
-} {1 0}
-test unixFCmd-1.9 {Checking EINTR Bug} {unixOnly notRoot nonPortable} {
- cleanup
- set f [open tfalarm w]
- puts $f {
- after 2000
- puts "hello world"
- exit 0
- }
- close $f
- testalarm
- set pipe [open "|[info nameofexecutable] tfalarm" r+]
- set line [read $pipe 1]
- catch {close $pipe}
- list $line [testgotsig]
-} {h 1}
-test unixFCmd-2.1 {TclpCopyFile: target exists: lstat(dst) == 0} \
- {unixOnly notRoot} {
- cleanup
- exec touch tf1
- exec touch tf2
- file copy -force tf1 tf2
-} {}
-test unixFCmd-2.2 {TclpCopyFile: src is symlink} {unixOnly notRoot} {
- cleanup
- exec ln -s tf1 tf2
- file copy tf2 tf3
- file type tf3
-} {link}
-test unixFCmd-2.3 {TclpCopyFile: src is block} {unixOnly notRoot} {
- cleanup
- set null "/dev/null"
- while {[file type $null] != "characterSpecial"} {
- set null [file join [file dirname $null] [file readlink $null]]
- }
- # file copy $null tf1
-} {}
-test unixFCmd-2.4 {TclpCopyFile: src is fifo} {unixOnly notRoot} {
- cleanup
- if [catch {exec mknod tf1 p}] {
- list 1
- } else {
- file copy tf1 tf2
- expr {"[file type tf1]" == "[file type tf2]"}
- }
-} {1}
-test unixFCmd-2.5 {TclpCopyFile: copy attributes} {unixOnly notRoot} {
- cleanup
- exec touch tf1
- exec chmod 472 tf1
- file copy tf1 tf2
- string range [exec ls -l tf2] 0 9
-} {-r--rwx-w-}
-
-test unixFCmd-3.1 {CopyFile not done} {emptyTest unixOnly notRoot} {
-} {}
-
-test unixFCmd-4.1 {TclpDeleteFile not done} {emptyTest unixOnly notRoot} {
-} {}
-
-test unixFCmd-5.1 {TclpCreateDirectory not done} {emptyTest unixOnly notRoot} {
-} {}
-
-test unixFCmd-6.1 {TclpCopyDirectory not done} {emptyTest unixOnly notRoot} {
-} {}
-
-test unixFCmd-7.1 {TclpRemoveDirectory not done} {emptyTest unixOnly notRoot} {
-} {}
-
-test unixFCmd-8.1 {TraverseUnixTree not done} {emptyTest unixOnly notRoot} {
-} {}
-
-test unixFCmd-9.1 {TraversalCopy not done} {emptyTest unixOnly notRoot} {
-} {}
-
-test unixFCmd-10.1 {TraversalDelete not done} {emptyTest unixOnly notRoot} {
-} {}
-
-test unixFCmd-11.1 {CopyFileAttrs not done} {emptyTest unixOnly notRoot} {
-} {}
-
-test unixFCmd-12.1 {GetGroupAttribute - file not found} {unixOnly notRoot} {
- catch {file delete -force -- foo.test}
- list [catch {file attributes foo.test -group} msg] $msg
-} {1 {could not read "foo.test": no such file or directory}}
-test unixFCmd-12.2 {GetGroupAttribute - file found} {unixOnly notRoot} {
- catch {file delete -force -- foo.test}
- close [open foo.test w]
- list [catch {file attributes foo.test -group}] [file delete -force -- foo.test]
-} {0 {}}
-
-test unixFCmd-13.1 {GetOwnerAttribute - file not found} {unixOnly notRoot} {
- catch {file delete -force -- foo.test}
- list [catch {file attributes foo.test -group} msg] $msg
-} {1 {could not read "foo.test": no such file or directory}}
-test unixFCmd-13.2 {GetOwnerAttribute} {unixOnly notRoot} {
- catch {file delete -force -- foo.test}
- close [open foo.test w]
- list [catch {file attributes foo.test -owner} msg] \
- [string compare $msg $user] [file delete -force -- foo.test]
-} {0 0 {}}
-
-test unixFCmd-14.1 {GetPermissionsAttribute - file not found} {unixOnly notRoot} {
- catch {file delete -force -- foo.test}
- list [catch {file attributes foo.test -permissions} msg] $msg
-} {1 {could not read "foo.test": no such file or directory}}
-test unixFCmd-14.2 {GetPermissionsAttribute} {unixOnly notRoot} {
- catch {file delete -force -- foo.test}
- close [open foo.test w]
- list [catch {file attribute foo.test -permissions}] \
- [file delete -force -- foo.test]
-} {0 {}}
-
-# Find a group that exists on this system, or else skip tests that require
-# groups
-set ::tcltest::testConfig(foundGroup) 0
-catch {
- set groupList [exec groups]
- set group [lindex $groupList 0]
- set ::tcltest::testConfig(foundGroup) 1
-}
-
-#groups hard to test
-test unixFCmd-15.1 {SetGroupAttribute - invalid group} {unixOnly notRoot} {
- catch {file delete -force -- foo.test}
- list [catch {file attributes foo.test -group foozzz} msg] \
- $msg [file delete -force -- foo.test]
-} {1 {could not set group for file "foo.test": group "foozzz" does not exist} {}}
-test unixFCmd-15.2 {SetGroupAttribute - invalid file} \
- {unixOnly notRoot foundGroup} {
- catch {file delete -force -- foo.test}
- list [catch {file attributes foo.test -group $group} msg] $msg
-} {1 {could not set group for file "foo.test": no such file or directory}}
-
-#changing owners hard to do
-test unixFCmd-16.1 {SetOwnerAttribute - current owner} {unixOnly notRoot} {
- catch {file delete -force -- foo.test}
- close [open foo.test w]
- list [catch {file attributes foo.test -owner $user} msg] \
- $msg [string compare [file attributes foo.test -owner] $user] \
- [file delete -force -- foo.test]
-} {0 {} 0 {}}
-test unixFCmd-16.2 {SetOwnerAttribute - invalid file} {unixOnly notRoot} {
- catch {file delete -force -- foo.test}
- list [catch {file attributes foo.test -owner $user} msg] $msg
-} {1 {could not set owner for file "foo.test": no such file or directory}}
-test unixFCmd-16.3 {SetOwnerAttribute - invalid owner} {unixOnly notRoot} {
- catch {file delete -force -- foo.test}
- list [catch {file attributes foo.test -owner foozzz} msg] $msg
-} {1 {could not set owner for file "foo.test": user "foozzz" does not exist}}
-
-
-test unixFCmd-17.1 {SetPermissionsAttribute} {unixOnly notRoot} {
- catch {file delete -force -- foo.test}
- close [open foo.test w]
- list [catch {file attributes foo.test -permissions 0000} msg] \
- $msg [file attributes foo.test -permissions] \
- [file delete -force -- foo.test]
-} {0 {} 00000 {}}
-test unixFCmd-17.2 {SetPermissionsAttribute} {unixOnly notRoot} {
- catch {file delete -force -- foo.test}
- list [catch {file attributes foo.test -permissions 0000} msg] $msg
-} {1 {could not set permissions for file "foo.test": no such file or directory}}
-test unixFCmd-17.3 {SetPermissionsAttribute} {unixOnly notRoot} {
- catch {file delete -force -- foo.test}
- close [open foo.test w]
- list [catch {file attributes foo.test -permissions foo} msg] $msg \
- [file delete -force -- foo.test]
-} {1 {expected integer but got "foo"} {}}
-test unixFCmd-18.1 {Unix pwd} {nonPortable unixOnly notRoot} {
- # This test is nonportable because SunOS generates a weird error
- # message when the current directory isn't readable.
- set cd [pwd]
- set nd $cd/tstdir
- file mkdir $nd
- cd $nd
- exec chmod 000 $nd
- set r [list [catch {pwd} res] [string range $res 0 36]];
- cd $cd;
- exec chmod 755 $nd
- file delete $nd
- set r
-} {1 {error getting working directory name:}}
-
-# cleanup
-cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/unixFile.test b/tests/unixFile.test
deleted file mode 100644
index c18ac20..0000000
--- a/tests/unixFile.test
+++ /dev/null
@@ -1,77 +0,0 @@
-# This file contains tests for the routines in the file tclUnixFile.c
-#
-# 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-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: unixFile.test,v 1.3 1999/04/16 00:47:35 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[info commands testobj] == {}} {
- puts "This application hasn't been compiled with the \"testfindexecutable\""
- puts "command, so I can't test the Tcl_FindExecutable function"
- ::tcltest::cleanupTests
- return
-}
-
-catch {
- set oldPath $env(PATH)
- close [open junk w]
- file attributes junk -perm 0777
-}
-set absPath [file join [pwd] junk]
-
-test unixFile-1.1 {Tcl_FindExecutable} {unixOnly} {
- set env(PATH) ""
- testfindexecutable junk
-} $absPath
-test unixFile-1.2 {Tcl_FindExecutable} {unixOnly} {
- set env(PATH) "/dummy"
- testfindexecutable junk
-} {}
-test unixFile-1.3 {Tcl_FindExecutable} {unixOnly} {
- set env(PATH) "/dummy:[pwd]"
- testfindexecutable junk
-} $absPath
-test unixFile-1.4 {Tcl_FindExecutable} {unixOnly} {
- set env(PATH) "/dummy:"
- testfindexecutable junk
-} $absPath
-test unixFile-1.5 {Tcl_FindExecutable} {unixOnly} {
- set env(PATH) "/dummy:/dummy"
- testfindexecutable junk
-} {}
-test unixFile-1.6 {Tcl_FindExecutable} {unixOnly} {
- set env(PATH) "/dummy::/dummy"
- testfindexecutable junk
-} $absPath
-test unixFile-1.7 {Tcl_FindExecutable} {unixOnly} {
- set env(PATH) ":/dummy"
- testfindexecutable junk
-} $absPath
-
-# cleanup
-catch {set env(PATH) $oldPath}
-file delete junk
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/unixInit.test b/tests/unixInit.test
deleted file mode 100644
index 313f3c1..0000000
--- a/tests/unixInit.test
+++ /dev/null
@@ -1,205 +0,0 @@
-# The file tests the functions in the tclUnixInit.c file.
-#
-# 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) 1997 by 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: unixInit.test,v 1.2 1999/04/16 00:47:35 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-catch {set oldlibrary $env(TCL_LIBRARY); unset env(TCL_LIBRARY)}
-catch {set oldlang $env(LANG)}
-set env(LANG) C
-
-# Some tests will fail if they are run on a machine that doesn't have
-# this Tcl version installed (as opposed to built) on it.
-if {[catch {
- set f [open "|[list $tcltest]" w+]
- exec kill -PIPE [pid $f]
- close $f
-}]} {
- set ::tcltest::testConfig(installedTcl) 0
-} else {
- set ::tcltest::testConfig(installedTcl) 1
-}
-
-test unixInit-1.1 {TclpInitPlatform: ignore SIGPIPE} {unixOnly installedTcl} {
- set x {}
-
- # Watch out for a race condition here. If tcltest is too slow to start
- # then we'll kill it before it has a chance to set up its signal handler.
-
- set f [open "|[list $tcltest]" w+]
- puts $f "puts hi"
- flush $f
- gets $f
- exec kill -PIPE [pid $f]
- lappend x [catch {close $f}]
-
- set f [open "|[list $tcltest]" w+]
- puts $f "puts hi"
- flush $f
- gets $f
- exec kill [pid $f]
- lappend x [catch {close $f}]
-
- set x
-} {0 1}
-
-proc getlibpath "{program [list $tcltest]}" {
- set f [open "|$program" w+]
- fconfigure $f -buffering none
- puts $f {puts $tcl_libPath; exit}
- set path [gets $f]
- close $f
- return $path
-}
-
-# Some tests require the testgetdefenc command
-
-set ::tcltest::testConfig(testgetdefenc) \
- [expr {[info commands testgetdefenc] != {}}]
-
-test unixInit-2.0 {TclpInitLibraryPath: setting tclDefaultEncodingDir} \
- {unixOnly testgetdefenc} {
- set origDir [testgetdefenc]
- testsetdefenc slappy
- set path [testgetdefenc]
- testsetdefenc $origDir
- set path
-} {slappy}
-test unixInit-2.1 {TclpInitLibraryPath: value of installLib, developLib} \
- {unixOnly installedTcl} {
- set path [getlibpath]
-
- set installLib lib/tcl[info tclversion]
- if {[string match {*[ab]*} [info patchlevel]]} {
- set developLib tcl[info patchlevel]/library
- } else {
- set developLib tcl[info tclversion]/library
- }
- set prefix [file dirname [file dirname $tcltest]]
-
- set x {}
- lappend x [string compare [lindex $path 0] $prefix/$installLib]
- lappend x [string compare [lindex $path 1] [file dirname $prefix]/$developLib]
- set x
-} {0 0}
-test unixInit-2.2 {TclpInitLibraryPath: TCL_LIBRARY} {unixOnly installedTcl} {
- # ((str != NULL) && (str[0] != '\0'))
-
- set env(TCL_LIBRARY) sparkly
- set path [getlibpath]
- unset env(TCL_LIBRARY)
-
- lindex $path 0
-} "sparkly"
-test unixInit-2.3 {TclpInitLibraryPath: TCL_LIBRARY wrong version} \
- {unixOnly installedTcl} {
- # ((pathc > 0) && (strcasecmp(installLib + 4, pathv[pathc - 1]) != 0))
-
- set env(TCL_LIBRARY) /a/b/tcl1.7
- set path [getlibpath]
- unset env(TCL_LIBRARY)
-
- lrange $path 0 1
-} [list /a/b/tcl1.7 /a/b/tcl[info tclversion]]
-test unixInit-2.4 {TclpInitLibraryPath: TCL_LIBRARY: INTL} \
- {unixOnly installedTcl} {
- # Child process translates env variable from native encoding.
-
- set env(TCL_LIBRARY) "\xa7"
- set x [lindex [getlibpath] 0]
- unset env(TCL_LIBRARY)
- unset env(LANG)
-
- set x
-} "\xa7"
-test unixInit-2.5 {TclpInitLibraryPath: compiled-in library path} \
- {emptyTest unixOnly} {
- # cannot test
-} {}
-test unixInit-2.6 {TclpInitLibraryPath: executable relative} \
- {unixOnly installedTcl} {
- file delete -force /tmp/sparkly
- file mkdir /tmp/sparkly/bin
- file copy $tcltest /tmp/sparkly/bin/tcltest
-
- file mkdir /tmp/sparkly/lib/tcl[info tclversion]
- close [open /tmp/sparkly/lib/tcl[info tclversion]/init.tcl w]
-
- set x [lrange [getlibpath /tmp/sparkly/bin/tcltest] 0 1]
- file delete -force /tmp/sparkly
- set x
-} [list /tmp/sparkly/lib/tcl[info tclversion] /tmp/tcl[info patchlevel]/library]
-test unixInit-2.7 {TclpInitLibraryPath: compiled-in library path} \
- {emptyTest unixOnly} {
- # would need test command to get defaultLibDir and compare it to
- # [lindex $auto_path end]
-} {}
-test unixInit-3.1 {TclpSetInitialEncodings} {unixOnly installedTcl} {
- set env(LANG) C
-
- set f [open "|[list $tcltest]" w+]
- fconfigure $f -buffering none
- puts $f {puts [encoding system]; exit}
- set enc [gets $f]
- close $f
- unset env(LANG)
-
- set enc
-} {iso8859-1}
-test unixInit-3.2 {TclpSetInitialEncodings} {unixOnly installedTcl} {
- set env(LANG) japanese
-
- set f [open "|[list $tcltest]" w+]
- fconfigure $f -buffering none
- puts $f {puts [encoding system]; exit}
- set enc [gets $f]
- close $f
- unset env(LANG)
-
- set enc
-} {euc-jp}
-
-test unixInit-4.1 {TclpSetVariables} {unixOnly} {
- # just make sure they exist
-
- set a [list $tcl_library $tcl_pkgPath $tcl_platform(os)]
- set a [list $tcl_platform(osVersion) $tcl_platform(machine)]
- set tcl_platform(platform)
-} "unix"
-
-test unixInit-5.1 {Tcl_Init} {emptyTest unixOnly} {
- # test initScript
-} {}
-
-test unixInit-6.1 {Tcl_SourceRCFile} {emptyTest unixOnly} {
-} {}
-
-# cleanup
-catch {unset env(TCL_LIBRARY); set env(TCL_LIBRARY) $oldlibrary}
-catch {unset env(LANG); set env(LANG) $oldlang}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/unixNotfy.test b/tests/unixNotfy.test
deleted file mode 100644
index 2775597..0000000
--- a/tests/unixNotfy.test
+++ /dev/null
@@ -1,99 +0,0 @@
-# This file contains tests for tclUnixNotfy.c.
-#
-# 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) 1997 by 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: unixNotfy.test,v 1.4 1999/04/16 00:47:36 stanton Exp $
-
-# The tests should not be run if you have a notifier which is unable to
-# detect infinite vwaits, as the tests below will hang. The presence of
-# the "testthread" command indicates that this is the case.
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-set ::tcltest::testConfig(testthread) \
- [expr {[info commands testthread] != {}}]
-
-# The next two tests will hang if threads are enabled because the notifier
-# will not necessarily wait for ever in this case, so it does not generate
-# an error.
-
-test unixNotfy-1.1 {Tcl_DeleteFileHandler} {unixOnly && !testthread} {
- catch {vwait x}
- set f [open foo w]
- fileevent $f writable {set x 1}
- vwait x
- close $f
- list [catch {vwait x} msg] $msg
-} {1 {can't wait for variable "x": would wait forever}}
-test unixNotfy-1.2 {Tcl_DeleteFileHandler} {unixOnly && !testthread} {
- catch {vwait x}
- set f1 [open foo w]
- set f2 [open foo2 w]
- fileevent $f1 writable {set x 1}
- fileevent $f2 writable {set y 1}
- vwait x
- close $f1
- vwait y
- close $f2
- list [catch {vwait x} msg] $msg
-} {1 {can't wait for variable "x": would wait forever}}
-
-
-test unixNotfy-2.1 {Tcl_DeleteFileHandler} {unixOnly testthread} {
- update
- set f [open foo w]
- fileevent $f writable {set x 1}
- vwait x
- close $f
- testthread create "after 500
- testthread send [testthread id] {set x ok}
- testthread exit"
- vwait x
- set x
-} {ok}
-test unixNotfy-1.2 {Tcl_DeleteFileHandler} {unixOnly testthread} {
- update
- set f1 [open foo w]
- set f2 [open foo2 w]
- fileevent $f1 writable {set x 1}
- fileevent $f2 writable {set y 1}
- vwait x
- close $f1
- vwait y
- close $f2
- testthread create "after 500
- testthread send [testthread id] {set x ok}
- testthread exit"
- vwait x
- set x
-} {ok}
-
-
-
-# cleanup
-file delete foo
-file delete foo2
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/unknown.test b/tests/unknown.test
deleted file mode 100644
index 791a9d1..0000000
--- a/tests/unknown.test
+++ /dev/null
@@ -1,78 +0,0 @@
-# Commands covered: unknown
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: unknown.test,v 1.3 1999/04/16 00:47:36 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-catch {unset x}
-catch {rename unknown unknown.old}
-
-test unknown-1.1 {non-existent "unknown" command} {
- list [catch {_non-existent_ foo bar} msg] $msg
-} {1 {invalid command name "_non-existent_"}}
-
-proc unknown {args} {
- global x
- set x $args
-}
-
-test unknown-2.1 {calling "unknown" command} {
- foobar x y z
- set x
-} {foobar x y z}
-test unknown-2.2 {calling "unknown" command with lots of args} {
- foobar 1 2 3 4 5 6 7
- set x
-} {foobar 1 2 3 4 5 6 7}
-test unknown-2.3 {calling "unknown" command with lots of args} {
- foobar 1 2 3 4 5 6 7 8
- set x
-} {foobar 1 2 3 4 5 6 7 8}
-test unknown-2.4 {calling "unknown" command with lots of args} {
- foobar 1 2 3 4 5 6 7 8 9
- set x
-} {foobar 1 2 3 4 5 6 7 8 9}
-
-test unknown-3.1 {argument quoting in calls to "unknown"} {
- foobar \{ \} a\{b \; "\\" \$a a\[b \]
- set x
-} "foobar \\{ \\} a\\{b {;} \\\\ {\$a} {a\[b} \\]"
-
-proc unknown args {
- error "unknown failed"
-}
-
-test unknown-4.1 {errors in "unknown" procedure} {
- list [catch {non-existent a b} msg] $msg $errorCode
-} {1 {unknown failed} NONE}
-
-# cleanup
-catch {rename unknown {}}
-catch {rename unknown.old unknown}
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/uplevel.test b/tests/uplevel.test
deleted file mode 100644
index 857c8e1..0000000
--- a/tests/uplevel.test
+++ /dev/null
@@ -1,128 +0,0 @@
-# Commands covered: uplevel
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: uplevel.test,v 1.3 1999/04/16 00:47:36 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-proc a {x y} {
- newset z [expr $x+$y]
- return $z
-}
-proc newset {name value} {
- uplevel set $name $value
- uplevel 1 {uplevel 1 {set xyz 22}}
-}
-
-test uplevel-1.1 {simple operation} {
- set xyz 0
- a 22 33
-} 55
-test uplevel-1.2 {command is another uplevel command} {
- set xyz 0
- a 22 33
- set xyz
-} 22
-
-proc a1 {} {
- b1
- global a a1
- set a $x
- set a1 $y
-}
-proc b1 {} {
- c1
- global b b1
- set b $x
- set b1 $y
-}
-proc c1 {} {
- uplevel 1 set x 111
- uplevel #2 set y 222
- uplevel 2 set x 333
- uplevel #1 set y 444
- uplevel 3 set x 555
- uplevel #0 set y 666
-}
-a1
-test uplevel-2.1 {relative and absolute uplevel} {set a} 333
-test uplevel-2.2 {relative and absolute uplevel} {set a1} 444
-test uplevel-2.3 {relative and absolute uplevel} {set b} 111
-test uplevel-2.4 {relative and absolute uplevel} {set b1} 222
-test uplevel-2.5 {relative and absolute uplevel} {set x} 555
-test uplevel-2.6 {relative and absolute uplevel} {set y} 666
-
-test uplevel-3.1 {uplevel to same level} {
- set x 33
- uplevel #0 set x 44
- set x
-} 44
-test uplevel-3.2 {uplevel to same level} {
- set x 33
- uplevel 0 set x
-} 33
-test uplevel-3.3 {uplevel to same level} {
- set y xxx
- proc a1 {} {set y 55; uplevel 0 set y 66; return $y}
- a1
-} 66
-test uplevel-3.4 {uplevel to same level} {
- set y zzz
- proc a1 {} {set y 55; uplevel #1 set y}
- a1
-} 55
-
-test uplevel-4.1 {error: non-existent level} {
- list [catch c1 msg] $msg
-} {1 {bad level "#2"}}
-test uplevel-4.2 {error: non-existent level} {
- proc c2 {} {uplevel 3 {set a b}}
- list [catch c2 msg] $msg
-} {1 {bad level "3"}}
-test uplevel-4.3 {error: not enough args} {
- list [catch uplevel msg] $msg
-} {1 {wrong # args: should be "uplevel ?level? command ?arg ...?"}}
-test uplevel-4.4 {error: not enough args} {
- proc upBug {} {uplevel 1}
- list [catch upBug msg] $msg
-} {1 {wrong # args: should be "uplevel ?level? command ?arg ...?"}}
-
-proc a2 {} {
- uplevel a3
-}
-proc a3 {} {
- global x y
- set x [info level]
- set y [info level 1]
-}
-a2
-test uplevel-5.1 {info level} {set x} 1
-test uplevel-5.2 {info level} {set y} a3
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/upvar.test b/tests/upvar.test
deleted file mode 100644
index 2fe81c9..0000000
--- a/tests/upvar.test
+++ /dev/null
@@ -1,416 +0,0 @@
-# Commands covered: upvar
-#
-# 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) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 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: upvar.test,v 1.4 1999/04/16 00:47:36 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test upvar-1.1 {reading variables with upvar} {
- proc p1 {a b} {set c 22; set d 33; p2}
- proc p2 {} {upvar a x1 b x2 c x3 d x4; set a abc; list $x1 $x2 $x3 $x4 $a}
- p1 foo bar
-} {foo bar 22 33 abc}
-test upvar-1.2 {reading variables with upvar} {
- proc p1 {a b} {set c 22; set d 33; p2}
- proc p2 {} {p3}
- proc p3 {} {upvar 2 a x1 b x2 c x3 d x4; set a abc; list $x1 $x2 $x3 $x4 $a}
- p1 foo bar
-} {foo bar 22 33 abc}
-test upvar-1.3 {reading variables with upvar} {
- proc p1 {a b} {set c 22; set d 33; p2}
- proc p2 {} {p3}
- proc p3 {} {
- upvar #1 a x1 b x2 c x3 d x4
- set a abc
- list $x1 $x2 $x3 $x4 $a
- }
- p1 foo bar
-} {foo bar 22 33 abc}
-test upvar-1.4 {reading variables with upvar} {
- set x1 44
- set x2 55
- proc p1 {} {p2}
- proc p2 {} {
- upvar 2 x1 x1 x2 a
- upvar #0 x1 b
- set c $b
- incr b 3
- list $x1 $a $b
- }
- p1
-} {47 55 47}
-test upvar-1.5 {reading array elements with upvar} {
- proc p1 {} {set a(0) zeroth; set a(1) first; p2}
- proc p2 {} {upvar a(0) x; set x}
- p1
-} {zeroth}
-
-test upvar-2.1 {writing variables with upvar} {
- proc p1 {a b} {set c 22; set d 33; p2; list $a $b $c $d}
- proc p2 {} {
- upvar a x1 b x2 c x3 d x4
- set x1 14
- set x4 88
- }
- p1 foo bar
-} {14 bar 22 88}
-test upvar-2.2 {writing variables with upvar} {
- set x1 44
- set x2 55
- proc p1 {x1 x2} {
- upvar #0 x1 a
- upvar x2 b
- set a $x1
- set b $x2
- }
- p1 newbits morebits
- list $x1 $x2
-} {newbits morebits}
-test upvar-2.3 {writing variables with upvar} {
- catch {unset x1}
- catch {unset x2}
- proc p1 {x1 x2} {
- upvar #0 x1 a
- upvar x2 b
- set a $x1
- set b $x2
- }
- p1 newbits morebits
- list [catch {set x1} msg] $msg [catch {set x2} msg] $msg
-} {0 newbits 0 morebits}
-test upvar-2.4 {writing array elements with upvar} {
- proc p1 {} {set a(0) zeroth; set a(1) first; list [p2] $a(0)}
- proc p2 {} {upvar a(0) x; set x xyzzy}
- p1
-} {xyzzy xyzzy}
-
-test upvar-3.1 {unsetting variables with upvar} {
- proc p1 {a b} {set c 22; set d 33; p2; lsort [info vars]}
- proc p2 {} {
- upvar 1 a x1 d x2
- unset x1 x2
- }
- p1 foo bar
-} {b c}
-test upvar-3.2 {unsetting variables with upvar} {
- proc p1 {a b} {set c 22; set d 33; p2; lsort [info vars]}
- proc p2 {} {
- upvar 1 a x1 d x2
- unset x1 x2
- set x2 28
- }
- p1 foo bar
-} {b c d}
-test upvar-3.3 {unsetting variables with upvar} {
- set x1 44
- set x2 55
- proc p1 {} {p2}
- proc p2 {} {
- upvar 2 x1 a
- upvar #0 x2 b
- unset a b
- }
- p1
- list [info exists x1] [info exists x2]
-} {0 0}
-test upvar-3.4 {unsetting variables with upvar} {
- set x1 44
- set x2 55
- proc p1 {} {
- upvar x1 a x2 b
- unset a b
- set b 118
- }
- p1
- list [info exists x1] [catch {set x2} msg] $msg
-} {0 0 118}
-test upvar-3.5 {unsetting array elements with upvar} {
- proc p1 {} {
- set a(0) zeroth
- set a(1) first
- set a(2) second
- p2
- array names a
- }
- proc p2 {} {upvar a(0) x; unset x}
- p1
-} {1 2}
-test upvar-3.6 {unsetting then resetting array elements with upvar} {
- proc p1 {} {
- set a(0) zeroth
- set a(1) first
- set a(2) second
- p2
- list [array names a] [catch {set a(0)} msg] $msg
- }
- proc p2 {} {upvar a(0) x; unset x; set x 12345}
- p1
-} {{0 1 2} 0 12345}
-
-test upvar-4.1 {nested upvars} {
- set x1 88
- proc p1 {a b} {set c 22; set d 33; p2}
- proc p2 {} {global x1; upvar c x2; p3}
- proc p3 {} {
- upvar x1 a x2 b
- list $a $b
- }
- p1 14 15
-} {88 22}
-test upvar-4.2 {nested upvars} {
- set x1 88
- proc p1 {a b} {set c 22; set d 33; p2; list $a $b $c $d}
- proc p2 {} {global x1; upvar c x2; p3}
- proc p3 {} {
- upvar x1 a x2 b
- set a foo
- set b bar
- }
- list [p1 14 15] $x1
-} {{14 15 bar 33} foo}
-
-proc tproc {args} {global x; set x [list $args [uplevel info vars]]}
-test upvar-5.1 {traces involving upvars} {
- proc p1 {a b} {set c 22; set d 33; trace var c rw tproc; p2}
- proc p2 {} {upvar c x1; set x1 22}
- set x ---
- p1 foo bar
- set x
-} {{x1 {} w} x1}
-test upvar-5.2 {traces involving upvars} {
- proc p1 {a b} {set c 22; set d 33; trace var c rw tproc; p2}
- proc p2 {} {upvar c x1; set x1}
- set x ---
- p1 foo bar
- set x
-} {{x1 {} r} x1}
-test upvar-5.3 {traces involving upvars} {
- proc p1 {a b} {set c 22; set d 33; trace var c rwu tproc; p2}
- proc p2 {} {upvar c x1; unset x1}
- set x ---
- p1 foo bar
- set x
-} {{x1 {} u} x1}
-
-test upvar-6.1 {retargeting an upvar} {
- proc p1 {} {
- set a(0) zeroth
- set a(1) first
- set a(2) second
- p2
- }
- proc p2 {} {
- upvar a x
- set result {}
- foreach i [array names x] {
- upvar a($i) x
- lappend result $x
- }
- lsort $result
- }
- p1
-} {first second zeroth}
-test upvar-6.2 {retargeting an upvar} {
- set x 44
- set y abcde
- proc p1 {} {
- global x
- set result $x
- upvar y x
- lappend result $x
- }
- p1
-} {44 abcde}
-test upvar-6.3 {retargeting an upvar} {
- set x 44
- set y abcde
- proc p1 {} {
- upvar y x
- lappend result $x
- global x
- lappend result $x
- }
- p1
-} {abcde 44}
-
-test upvar-7.1 {upvar to same level} {
- set x 44
- set y 55
- catch {unset uv}
- upvar #0 x uv
- set uv abc
- upvar 0 y uv
- set uv xyzzy
- list $x $y
-} {abc xyzzy}
-test upvar-7.2 {upvar to same level} {
- set x 1234
- set y 4567
- proc p1 {x y} {
- upvar 0 x uv
- set uv $y
- return "$x $y"
- }
- p1 44 89
-} {89 89}
-test upvar-7.3 {upvar to same level} {
- set x 1234
- set y 4567
- proc p1 {x y} {
- upvar #1 x uv
- set uv $y
- return "$x $y"
- }
- p1 xyz abc
-} {abc abc}
-test upvar-7.4 {upvar to same level: tricky problems when deleting variable table} {
- proc tt {} {upvar #1 toto loc; return $loc}
- list [catch tt msg] $msg
-} {1 {can't read "loc": no such variable}}
-test upvar-7.5 {potential memory leak when deleting variable table} {
- proc leak {} {
- array set foo {1 2 3 4}
- upvar 0 foo(1) bar
- }
- leak
-} {}
-
-test upvar-8.1 {errors in upvar command} {
- list [catch upvar msg] $msg
-} {1 {wrong # args: should be "upvar ?level? otherVar localVar ?otherVar localVar ...?"}}
-test upvar-8.2 {errors in upvar command} {
- list [catch {upvar 1} msg] $msg
-} {1 {wrong # args: should be "upvar ?level? otherVar localVar ?otherVar localVar ...?"}}
-test upvar-8.3 {errors in upvar command} {
- proc p1 {} {upvar a b c}
- list [catch p1 msg] $msg
-} {1 {wrong # args: should be "upvar ?level? otherVar localVar ?otherVar localVar ...?"}}
-test upvar-8.4 {errors in upvar command} {
- proc p1 {} {upvar 0 b b}
- list [catch p1 msg] $msg
-} {1 {can't upvar from variable to itself}}
-test upvar-8.5 {errors in upvar command} {
- proc p1 {} {upvar 0 a b; upvar 0 b a}
- list [catch p1 msg] $msg
-} {1 {can't upvar from variable to itself}}
-test upvar-8.6 {errors in upvar command} {
- proc p1 {} {set a 33; upvar b a}
- list [catch p1 msg] $msg
-} {1 {variable "a" already exists}}
-test upvar-8.7 {errors in upvar command} {
- proc p1 {} {trace variable a w foo; upvar b a}
- list [catch p1 msg] $msg
-} {1 {variable "a" has traces: can't use for upvar}}
-test upvar-8.8 {create nested array with upvar} {
- proc p1 {} {upvar x(a) b; set b(2) 44}
- catch {unset x}
- list [catch p1 msg] $msg
-} {1 {can't set "b(2)": variable isn't array}}
-test upvar-8.9 {upvar won't create namespace variable that refers to procedure variable} {
- catch {eval namespace delete [namespace children :: test_ns_*]}
- catch {rename MakeLink ""}
- namespace eval ::test_ns_1 {}
- proc MakeLink {a} {
- namespace eval ::test_ns_1 {
- upvar a a
- }
- unset ::test_ns_1::a
- }
- list [catch {MakeLink 1} msg] $msg
-} {1 {bad variable name "a": upvar won't create namespace variable that refers to procedure variable}}
-test upvar-8.10 {upvar will create element alias for new array element} {
- catch {unset upvarArray}
- array set upvarArray {}
- catch {upvar 0 upvarArray(elem) upvarArrayElemAlias}
-} {0}
-
-if {[info commands testupvar] != {}} {
- test upvar-9.1 {Tcl_UpVar2 procedure} {
- list [catch {testupvar xyz a {} x global} msg] $msg
- } {1 {bad level "xyz"}}
- test upvar-9.2 {Tcl_UpVar2 procedure} {
- catch {unset a}
- catch {unset x}
- set a 44
- list [catch {testupvar #0 a 1 x global} msg] $msg
- } {1 {can't access "a(1)": variable isn't array}}
- test upvar-9.3 {Tcl_UpVar2 procedure} {
- proc foo {} {
- testupvar 1 a {} x local
- set x
- }
- catch {unset a}
- catch {unset x}
- set a 44
- foo
- } {44}
- test upvar-9.4 {Tcl_UpVar2 procedure} {
- proc foo {} {
- testupvar 1 a {} _up_ global
- list [catch {set x} msg] $msg
- }
- catch {unset a}
- catch {unset _up_}
- set a 44
- concat [foo] $_up_
- } {1 {can't read "x": no such variable} 44}
- test upvar-9.5 {Tcl_UpVar2 procedure} {
- proc foo {} {
- testupvar 1 a b x local
- set x
- }
- catch {unset a}
- catch {unset x}
- set a(b) 1234
- foo
- } {1234}
- test upvar-9.6 {Tcl_UpVar procedure} {
- proc foo {} {
- testupvar 1 a x local
- set x
- }
- catch {unset a}
- catch {unset x}
- set a xyzzy
- foo
- } {xyzzy}
- test upvar-9.7 {Tcl_UpVar procedure} {
- proc foo {} {
- testupvar #0 a(b) x local
- set x
- }
- catch {unset a}
- catch {unset x}
- set a(b) 1234
- foo
- } {1234}
-}
-catch {unset a}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/utf.test b/tests/utf.test
deleted file mode 100644
index eb9952f..0000000
--- a/tests/utf.test
+++ /dev/null
@@ -1,276 +0,0 @@
-# This file contains a collection of tests for tclUtf.c
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 1997 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: utf.test,v 1.2 1999/04/16 00:47:36 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-catch {unset x}
-
-test utf-1.1 {Tcl_UniCharToUtf: 1 byte sequences} {
- set x \x01
-} [bytestring "\x01"]
-test utf-1.2 {Tcl_UniCharToUtf: 2 byte sequences} {
- set x "\x00"
-} [bytestring "\xc0\x80"]
-test utf-1.3 {Tcl_UniCharToUtf: 2 byte sequences} {
- set x "\xe0"
-} [bytestring "\xc3\xa0"]
-test utf-1.4 {Tcl_UniCharToUtf: 3 byte sequences} {
- set x "\u4e4e"
-} [bytestring "\xe4\xb9\x8e"]
-
-test utf-2.1 {Tcl_UtfToUniChar: low ascii} {
- string length "abc"
-} {3}
-test utf-2.2 {Tcl_UtfToUniChar: naked trail bytes} {
- string length [bytestring "\x82\x83\x84"]
-} {3}
-test utf-2.3 {Tcl_UtfToUniChar: lead (2-byte) followed by non-trail} {
- string length [bytestring "\xC2"]
-} {1}
-test utf-2.4 {Tcl_UtfToUniChar: lead (2-byte) followed by trail} {
- string length [bytestring "\xC2\xa2"]
-} {1}
-test utf-2.5 {Tcl_UtfToUniChar: lead (3-byte) followed by non-trail} {
- string length [bytestring "\xE2"]
-} {1}
-test utf-2.6 {Tcl_UtfToUniChar: lead (3-byte) followed by 1 trail} {
- string length [bytestring "\xE2\xA2"]
-} {2}
-test utf-2.7 {Tcl_UtfToUniChar: lead (3-byte) followed by 2 trail} {
- string length [bytestring "\xE4\xb9\x8e"]
-} {1}
-test utf-2.8 {Tcl_UtfToUniChar: longer UTF sequences not supported} {
- string length [bytestring "\xF4\xA2\xA2\xA2"]
-} {4}
-
-test utf-3.1 {Tcl_UtfCharComplete} {
-} {}
-
-test utf-4.1 {Tcl_NumUtfChars: zero length} {
- string length ""
-} {0}
-test utf-4.2 {Tcl_NumUtfChars: length 1} {
- string length [bytestring "\xC2\xA2"]
-} {1}
-test utf-4.3 {Tcl_NumUtfChars: long string} {
- string length [bytestring "abc\xC2\xA2\xe4\xb9\x8e\uA2\u4e4e"]
-} {7}
-
-test utf-5.1 {Tcl_UtfFindFirsts} {
-} {}
-
-test utf-6.1 {Tcl_UtfNext} {
-} {}
-
-test utf-7.1 {Tcl_UtfPrev} {
-} {}
-
-test utf-8.1 {Tcl_UniCharAtIndex: index = 0} {
- string index abcd 0
-} {a}
-test utf-8.2 {Tcl_UniCharAtIndex: index = 0} {
- string index \u4e4e\u25a 0
-} "\u4e4e"
-test utf-8.3 {Tcl_UniCharAtIndex: index > 0} {
- string index abcd 2
-} {c}
-test utf-8.4 {Tcl_UniCharAtIndex: index > 0} {
- string index \u4e4e\u25a\xff\u543 2
-} "\uff"
-
-test utf-9.1 {Tcl_UtfAtIndex: index = 0} {
- string range abcd 0 2
-} {abc}
-test utf-9.2 {Tcl_UtfAtIndex: index > 0} {
- string range \u4e4e\u25a\xff\u543klmnop 1 5
-} "\u25a\xff\u543kl"
-
-
-test utf-10.1 {Tcl_UtfBackslash: dst == NULL} {
- set x \n
-} {
-}
-test utf-10.2 {Tcl_UtfBackslash: \u subst} {
- set x \ua2
-} [bytestring "\xc2\xa2"]
-test utf-10.3 {Tcl_UtfBackslash: longer \u subst} {
- set x \u4e21
-} [bytestring "\xe4\xb8\xa1"]
-test utf-10.4 {Tcl_UtfBackslash: stops at first non-hex} {
- set x \u4e2k
-} "[bytestring \xd3\xa2]k"
-test utf-10.5 {Tcl_UtfBackslash: stops after 4 hex chars} {
- set x \u4e216
-} "[bytestring \xe4\xb8\xa1]6"
-proc bsCheck {char num} {
- global errNum
- test utf-10.$errNum {backslash substitution} {
- scan $char %c value
- set value
- } $num
- incr errNum
-}
-set errNum 6
-bsCheck \b 8
-bsCheck \e 101
-bsCheck \f 12
-bsCheck \n 10
-bsCheck \r 13
-bsCheck \t 9
-bsCheck \v 11
-bsCheck \{ 123
-bsCheck \} 125
-bsCheck \[ 91
-bsCheck \] 93
-bsCheck \$ 36
-bsCheck \ 32
-bsCheck \; 59
-bsCheck \\ 92
-bsCheck \Ca 67
-bsCheck \Ma 77
-bsCheck \CMa 67
-bsCheck \8a 8
-bsCheck \14 12
-bsCheck \141 97
-bsCheck b\0 98
-bsCheck \x 120
-bsCheck \xa 10
-bsCheck \xA 10
-bsCheck \x41 65
-bsCheck \x541 65
-bsCheck \u 117
-bsCheck \uk 117
-bsCheck \u41 65
-bsCheck \ua 10
-bsCheck \uA 10
-bsCheck \340 224
-bsCheck \ua1 161
-bsCheck \u4e21 20001
-
-test utf-11.1 {Tcl_UtfToUpper} {
- string toupper {}
-} {}
-test utf-11.2 {Tcl_UtfToUpper} {
- string toupper abc
-} ABC
-test utf-11.3 {Tcl_UtfToUpper} {
- string toupper \u00e3ab
-} \u00c3AB
-test utf-11.4 {Tcl_UtfToUpper} {
- string toupper \u01e3ab
-} \u01e2AB
-
-test utf-12.1 {Tcl_UtfToLower} {
- string tolower {}
-} {}
-test utf-12.2 {Tcl_UtfToLower} {
- string tolower ABC
-} abc
-test utf-12.3 {Tcl_UtfToLower} {
- string tolower \u00c3AB
-} \u00e3ab
-test utf-12.4 {Tcl_UtfToLower} {
- string tolower \u01e2AB
-} \u01e3ab
-
-test utf-13.1 {Tcl_UtfToTitle} {
- string totitle {}
-} {}
-test utf-13.2 {Tcl_UtfToTitle} {
- string totitle abc
-} Abc
-test utf-13.3 {Tcl_UtfToTitle} {
- string totitle \u00e3ab
-} \u00c3ab
-test utf-13.4 {Tcl_UtfToTitle} {
- string totitle \u01f3ab
-} \u01f2ab
-
-test utf-14.1 {Tcl_UniCharToUpper, negative delta} {
- string toupper aA
-} AA
-test utf-14.2 {Tcl_UniCharToUpper, positive delta} {
- string toupper \u0178\u00ff
-} \u0178\u0178
-test utf-14.3 {Tcl_UniCharToUpper, no delta} {
- string toupper !
-} !
-
-test utf-15.1 {Tcl_UniCharToLower, negative delta} {
- string tolower aA
-} aa
-test utf-15.2 {Tcl_UniCharToLower, positive delta} {
- string tolower \u0178\u00ff
-} \u00ff\u00ff
-test utf-16.1 {Tcl_UniCharToLower, no delta} {
- string tolower !
-} !
-
-test utf-17.1 {Tcl_UniCharToTitle, add one for title} {
- string totitle \u01c4
-} \u01c5
-test utf-17.2 {Tcl_UniCharToTitle, subtract one for title} {
- string totitle \u01c6
-} \u01c5
-test utf-17.3 {Tcl_UniCharToTitle, subtract delta for title (positive)} {
- string totitle \u017f
-} \u0053
-test utf-17.4 {Tcl_UniCharToTitle, subtract delta for title (negative)} {
- string totitle \u00ff
-} \u0178
-test utf-17.5 {Tcl_UniCharToTitle, no delta} {
- string totitle !
-} !
-
-test utf-18.1 {TclUniCharLen} {
- list [regexp \\d abc456def foo] $foo
-} {1 4}
-
-test utf-19.1 {TclUniCharNcmp} {
-} {}
-
-test utf-20.1 {TclUniCharIsAlnum} {
-} {}
-
-test utf-21.1 {TclUniCharIsWordChar} {
- string wordend "xyz123_bar fg" 0
-} 10
-test utf-21.1 {TclUniCharIsWordChar} {
- string wordend "x\u5080z123_bar\u203c fg" 0
-} 10
-
-test utf-22.1 {TclUniCharIsAlpha} {
-} {}
-
-test utf-23.1 {TclUniCharIsDigit} {
-} {}
-
-test utf-23.1 {TclUniCharIsSpace} {
-} {}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/util.test b/tests/util.test
deleted file mode 100644
index 3c8b7b0..0000000
--- a/tests/util.test
+++ /dev/null
@@ -1,306 +0,0 @@
-# This file is a Tcl script to test the code in the file tclUtil.c.
-# This file is organized in the standard fashion for Tcl tests.
-#
-# Copyright (c) 1995-1998 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: util.test,v 1.4 1999/04/16 00:47:36 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {[info commands testobj] == {}} {
- puts "This application hasn't been compiled with the \"testobj\""
- puts "command, so I can't test the Tcl type and object support."
- ::tcltest::cleanupTests
- return
-}
-
-test util-1.1 {TclFindElement procedure - binary element in middle of list} {
- lindex {0 foo\x00help 1} 1
-} "foo\x00help"
-test util-1.2 {TclFindElement procedure - binary element at end of list} {
- lindex {0 foo\x00help} 1
-} "foo\x00help"
-
-test util-2.1 {TclCopyAndCollapse procedure - normal string} {
- lindex {0 foo} 1
-} {foo}
-test util-2.2 {TclCopyAndCollapse procedure - string with backslashes} {
- lindex {0 foo\n\x00help 1} 1
-} "foo\n\x00help"
-
-test util-3.1 {Tcl_ScanCountedElement procedure - don't leave unmatched braces} {
- # This test checks for a very tricky feature. Any list element
- # generated with Tcl_ScanCountedElement and Tcl_ConvertElement must
- # have the property that it can be enclosing in curly braces to make
- # an embedded sub-list. If this property doesn't hold, then
- # Tcl_DStringStartSublist doesn't work.
-
- set x {}
- lappend x " \\\{ \\"
- concat $x [llength "{$x}"]
-} {\ \\\{\ \\ 1}
-
-test util-4.1 {Tcl_ConcatObj - backslash-space at end of argument} {
- concat a {b\ } c
-} {a b\ c}
-test util-4.2 {Tcl_ConcatObj - backslash-space at end of argument} {
- concat a {b\ } c
-} {a b\ c}
-test util-4.3 {Tcl_ConcatObj - backslash-space at end of argument} {
- concat a {b\\ } c
-} {a b\\ c}
-test util-4.4 {Tcl_ConcatObj - backslash-space at end of argument} {
- concat a {b } c
-} {a b c}
-test util-4.5 {Tcl_ConcatObj - backslash-space at end of argument} {
- concat a { } c
-} {a c}
-
-test util-5.1 {Tcl_StringMatch} {
- string match ab*c abc
-} 1
-test util-5.2 {Tcl_StringMatch} {
- string match ab**c abc
-} 1
-test util-5.3 {Tcl_StringMatch} {
- string match ab* abcdef
-} 1
-test util-5.4 {Tcl_StringMatch} {
- string match *c abc
-} 1
-test util-5.5 {Tcl_StringMatch} {
- string match *3*6*9 0123456789
-} 1
-test util-5.6 {Tcl_StringMatch} {
- string match *3*6*9 01234567890
-} 0
-test util-5.7 {Tcl_StringMatch: UTF-8} {
- string match *u \u4e4fu
-} 1
-test util-5.8 {Tcl_StringMatch} {
- string match a?c abc
-} 1
-test util-5.9 {Tcl_StringMatch: UTF-8} {
- # skip one character in string
-
- string match a?c a\u4e4fc
-} 1
-test util-5.10 {Tcl_StringMatch} {
- string match a??c abc
-} 0
-test util-5.11 {Tcl_StringMatch} {
- string match ?1??4???8? 0123456789
-} 1
-test util-5.12 {Tcl_StringMatch} {
- string match {[abc]bc} abc
-} 1
-test util-5.13 {Tcl_StringMatch: UTF-8} {
- # string += Tcl_UtfToUniChar(string, &ch);
-
- string match "\[\u4e4fxy\]bc" "\u4e4fbc"
-} 1
-test util-5.14 {Tcl_StringMatch} {
- # if ((*pattern == ']') || (*pattern == '\0'))
- # badly formed pattern
-
- string match {[]} {[]}
-} 0
-test util-5.15 {Tcl_StringMatch} {
- # if ((*pattern == ']') || (*pattern == '\0'))
- # badly formed pattern
-
- string match {[} {[}
-} 0
-test util-5.16 {Tcl_StringMatch} {
- string match {a[abc]c} abc
-} 1
-test util-5.17 {Tcl_StringMatch: UTF-8} {
- # pattern += Tcl_UtfToUniChar(pattern, &endChar);
- # get 1 UTF-8 character
-
- string match "a\[a\u4e4fc]c" "a\u4e4fc"
-} 1
-test util-5.18 {Tcl_StringMatch: UTF-8} {
- # pattern += Tcl_UtfToUniChar(pattern, &endChar);
- # proper advance: wrong answer would match on UTF trail byte of \u4e4f
-
- string match {a[a\u4e4fc]c} [bytestring a\u008fc]
-} 0
-test util-5.19 {Tcl_StringMatch: UTF-8} {
- # pattern += Tcl_UtfToUniChar(pattern, &endChar);
- # proper advance.
-
- string match {a[a\u4e4fc]c} "acc"
-} 1
-test util-5.20 {Tcl_StringMatch} {
- string match {a[xyz]c} abc
-} 0
-test util-5.21 {Tcl_StringMatch} {
- string match {12[2-7]45} 12345
-} 1
-test util-5.22 {Tcl_StringMatch: UTF-8 range} {
- string match "\[\u4e00-\u4e4f]" "0"
-} 0
-test util-5.23 {Tcl_StringMatch: UTF-8 range} {
- string match "\[\u4e00-\u4e4f]" "\u4e33"
-} 1
-test util-5.24 {Tcl_StringMatch: UTF-8 range} {
- string match "\[\u4e00-\u4e4f]" "\uff08"
-} 0
-test util-5.25 {Tcl_StringMatch} {
- string match {12[ab2-4cd]45} 12345
-} 1
-test util-5.26 {Tcl_StringMatch} {
- string match {12[ab2-4cd]45} 12b45
-} 1
-test util-5.27 {Tcl_StringMatch} {
- string match {12[ab2-4cd]45} 12d45
-} 1
-test util-5.28 {Tcl_StringMatch} {
- string match {12[ab2-4cd]45} 12145
-} 0
-test util-5.29 {Tcl_StringMatch} {
- string match {12[ab2-4cd]45} 12545
-} 0
-test util-5.30 {Tcl_StringMatch: forwards range} {
- string match {[k-w]} "z"
-} 0
-test util-5.31 {Tcl_StringMatch: forwards range} {
- string match {[k-w]} "w"
-} 1
-test util-5.32 {Tcl_StringMatch: forwards range} {
- string match {[k-w]} "r"
-} 1
-test util-5.33 {Tcl_StringMatch: forwards range} {
- string match {[k-w]} "k"
-} 1
-test util-5.34 {Tcl_StringMatch: forwards range} {
- string match {[k-w]} "a"
-} 0
-test util-5.35 {Tcl_StringMatch: reverse range} {
- string match {[w-k]} "z"
-} 0
-test util-5.36 {Tcl_StringMatch: reverse range} {
- string match {[w-k]} "w"
-} 1
-test util-5.37 {Tcl_StringMatch: reverse range} {
- string match {[w-k]} "r"
-} 1
-test util-5.38 {Tcl_StringMatch: reverse range} {
- string match {[w-k]} "k"
-} 1
-test util-5.39 {Tcl_StringMatch: reverse range} {
- string match {[w-k]} "a"
-} 0
-test util-5.40 {Tcl_StringMatch: skip correct number of ']'} {
- string match {[A-]x} Ax
-} 0
-test util-5.41 {Tcl_StringMatch: skip correct number of ']'} {
- string match {[A-]]x} Ax
-} 1
-test util-5.42 {Tcl_StringMatch: skip correct number of ']'} {
- string match {[A-]]x} \ue1x
-} 0
-test util-5.43 {Tcl_StringMatch: skip correct number of ']'} {
- string match \[A-]\ue1]x \ue1x
-} 1
-test util-5.44 {Tcl_StringMatch: skip correct number of ']'} {
- string match {[A-]h]x} hx
-} 1
-test util-5.45 {Tcl_StringMatch} {
- # if (*pattern == '\0')
- # badly formed pattern, still treats as a set
-
- string match {[a} a
-} 1
-test util-5.46 {Tcl_StringMatch} {
- string match {a\*b} a*b
-} 1
-test util-5.47 {Tcl_StringMatch} {
- string match {a\*b} ab
-} 0
-test util-5.48 {Tcl_StringMatch} {
- string match {a\*\?\[\]\\\x} "a*?\[\]\\x"
-} 1
-test util-5.49 {Tcl_StringMatch} {
- string match ** ""
-} 1
-test util-5.50 {Tcl_StringMatch} {
- string match *. ""
-} 0
-test util-5.51 {Tcl_StringMatch} {
- string match "" ""
-} 1
-
-test util-6.1 {Tcl_PrintDouble - using tcl_precision} {
- concat x[expr 1.4]
-} {x1.4}
-test util-6.2 {Tcl_PrintDouble - using tcl_precision} {
- concat x[expr 1.39999999999]
-} {x1.39999999999}
-test util-6.3 {Tcl_PrintDouble - using tcl_precision} {
- concat x[expr 1.399999999999]
-} {x1.4}
-test util-6.4 {Tcl_PrintDouble - using tcl_precision} {
- set tcl_precision 5
- concat x[expr 1.123412341234]
-} {x1.1234}
-set tcl_precision 12
-test util-6.5 {Tcl_PrintDouble - make sure there's a decimal point} {
- concat x[expr 2.0]
-} {x2.0}
-test util-6.6 {Tcl_PrintDouble - make sure there's a decimal point} {eformat} {
- concat x[expr 3.0e98]
-} {x3e+98}
-
-test util-7.1 {TclPrecTraceProc - unset callbacks} {
- set tcl_precision 7
- set x $tcl_precision
- unset tcl_precision
- list $x $tcl_precision
-} {7 7}
-test util-7.2 {TclPrecTraceProc - read traces, sharing among interpreters} {
- set tcl_precision 12
- interp create child
- set x [child eval set tcl_precision]
- child eval {set tcl_precision 6}
- interp delete child
- list $x $tcl_precision
-} {12 6}
-test util-7.3 {TclPrecTraceProc - write traces, safe interpreters} {
- set tcl_precision 12
- interp create -safe child
- set x [child eval {
- list [catch {set tcl_precision 8} msg] $msg
- }]
- interp delete child
- list $x $tcl_precision
-} {{1 {can't set "tcl_precision": can't modify precision from a safe interpreter}} 12}
-test util-7.4 {TclPrecTraceProc - write traces, bogus values} {
- set tcl_precision 12
- list [catch {set tcl_precision abc} msg] $msg $tcl_precision
-} {1 {can't set "tcl_precision": improper value for precision} 12}
-
-set tcl_precision 12
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/var.test b/tests/var.test
deleted file mode 100644
index 9145fc5..0000000
--- a/tests/var.test
+++ /dev/null
@@ -1,610 +0,0 @@
-# This file contains tests for the tclVar.c source file. Tests appear in
-# the same order as the C code that they test. The set of tests is
-# currently incomplete since it currently includes only new tests for
-# code changed for the addition of Tcl namespaces. Other variable-
-# related tests appear in several other test files including
-# namespace.test, set.test, trace.test, and upvar.test.
-#
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 1997 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: var.test,v 1.5 1999/04/16 00:47:36 stanton Exp $
-#
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-catch {rename p ""}
-catch {namespace delete test_ns_var}
-catch {unset xx}
-catch {unset x}
-catch {unset y}
-catch {unset i}
-catch {unset a}
-catch {unset arr}
-
-test var-1.1 {TclLookupVar, Array handling} {
- catch {unset a}
- set x "incr" ;# force no compilation and runtime call to Tcl_IncrCmd
- set i 10
- set arr(foo) 37
- list [$x i] $i [$x arr(foo)] $arr(foo)
-} {11 11 38 38}
-test var-1.2 {TclLookupVar, TCL_GLOBAL_ONLY implies global namespace var} {
- set x "global value"
- namespace eval test_ns_var {
- variable x "namespace value"
- proc p {} {
- global x ;# specifies TCL_GLOBAL_ONLY to get global x
- return $x
- }
- }
- test_ns_var::p
-} {global value}
-test var-1.3 {TclLookupVar, TCL_NAMESPACE_ONLY implies namespace var} {
- namespace eval test_ns_var {
- proc q {} {
- variable x ;# specifies TCL_NAMESPACE_ONLY to get namespace x
- return $x
- }
- }
- test_ns_var::q
-} {namespace value}
-test var-1.4 {TclLookupVar, no active call frame implies global namespace var} {
- set x
-} {global value}
-test var-1.5 {TclLookupVar, active call frame pushed for namespace eval implies namespace var} {
- namespace eval test_ns_var {set x}
-} {namespace value}
-test var-1.6 {TclLookupVar, name starts with :: implies some namespace var} {
- namespace eval test_ns_var {set ::x}
-} {global value}
-test var-1.7 {TclLookupVar, error finding namespace var} {
- list [catch {set a:::b} msg] $msg
-} {1 {can't read "a:::b": no such variable}}
-test var-1.8 {TclLookupVar, error finding namespace var} {
- list [catch {set ::foobarfoo} msg] $msg
-} {1 {can't read "::foobarfoo": no such variable}}
-test var-1.9 {TclLookupVar, create new namespace var} {
- namespace eval test_ns_var {
- set v hello
- }
-} {hello}
-test var-1.10 {TclLookupVar, create new namespace var} {
- catch {unset y}
- namespace eval test_ns_var {
- set ::y 789
- }
- set y
-} {789}
-test var-1.11 {TclLookupVar, error creating new namespace var} {
- namespace eval test_ns_var {
- list [catch {set ::test_ns_var::foo::bar 314159} msg] $msg
- }
-} {1 {can't set "::test_ns_var::foo::bar": parent namespace doesn't exist}}
-test var-1.12 {TclLookupVar, error creating new namespace var} {
- namespace eval test_ns_var {
- list [catch {set ::test_ns_var::foo:: 1997} msg] $msg
- }
-} {1 {can't set "::test_ns_var::foo::": parent namespace doesn't exist}}
-test var-1.13 {TclLookupVar, new namespace var is created in a particular namespace} {
- catch {unset aNeWnAmEiNnS}
- namespace eval test_ns_var {
- namespace eval test_ns_var2::test_ns_var3 {
- set aNeWnAmEiNnS 77777
- }
- # namespace which builds a name by traversing nsPtr chain to ::
- namespace which -variable test_ns_var2::test_ns_var3::aNeWnAmEiNnS
- }
-} {::test_ns_var::test_ns_var2::test_ns_var3::aNeWnAmEiNnS}
-test var-1.14 {TclLookupVar, namespace code ignores ":"s in middle and end of var names} {
- namespace eval test_ns_var {
- set : 123
- set v: 456
- set x:y: 789
- list [set :] [set v:] [set x:y:] \
- ${:} ${v:} ${x:y:} \
- [expr {[lsearch [info vars] :] != -1}] \
- [expr {[lsearch [info vars] v:] != -1}] \
- [expr {[lsearch [info vars] x:y:] != -1}]
- }
-} {123 456 789 123 456 789 1 1 1}
-test var-1.15 {TclLookupVar, resurrect variable via upvar to deleted namespace: compiled code path} {
- namespace eval test_ns_var {
- variable foo 2
- }
- proc p {} {
- variable ::test_ns_var::foo
- lappend result [catch {set foo} msg] $msg
- namespace delete ::test_ns_var
- lappend result [catch {set foo 3} msg] $msg
- lappend result [catch {set foo(3) 3} msg] $msg
- }
- p
-} {0 2 1 {can't set "foo": upvar refers to variable in deleted namespace} 1 {can't set "foo(3)": upvar refers to variable in deleted namespace}}
-test var-1.16 {TclLookupVar, resurrect variable via upvar to deleted namespace: uncompiled code path} {
- namespace eval test_ns_var {
- variable result
- namespace eval subns {
- variable foo 2
- }
- upvar 0 subns::foo foo
- lappend result [catch {set foo} msg] $msg
- namespace delete subns
- lappend result [catch {set foo 3} msg] $msg
- lappend result [catch {set foo(3) 3} msg] $msg
- namespace delete [namespace current]
- set result
- }
-} {0 2 1 {can't set "foo": upvar refers to variable in deleted namespace} 1 {can't set "foo(3)": upvar refers to variable in deleted namespace}}
-test var-1.17 {TclLookupVar, resurrect array element via upvar to deleted array: compiled code path} {
- namespace eval test_ns_var {
- variable result
- proc p {} {
- array set x {1 2 3 4}
- upvar 0 x(1) foo
- lappend result [catch {set foo} msg] $msg
- unset x
- lappend result [catch {set foo 3} msg] $msg
- }
- set result [p]
- namespace delete [namespace current]
- set result
- }
-} {0 2 1 {can't set "foo": upvar refers to element in deleted array}}
-test var-1.18 {TclLookupVar, resurrect array element via upvar to deleted array: uncompiled code path} {
- namespace eval test_ns_var {
- variable result {}
- variable x
- array set x {1 2 3 4}
- upvar 0 x(1) foo
- lappend result [catch {set foo} msg] $msg
- unset x
- lappend result [catch {set foo 3} msg] $msg
- namespace delete [namespace current]
- set result
- }
-} {0 2 1 {can't set "foo": upvar refers to element in deleted array}}
-
-test var-2.1 {Tcl_LappendObjCmd, create var if new} {
- catch {unset x}
- lappend x 1 2
-} {1 2}
-
-test var-3.1 {MakeUpvar, TCL_NAMESPACE_ONLY not specified for other var} {
- catch {unset x}
- set x 1997
- proc p {} {
- global x ;# calls MakeUpvar with TCL_NAMESPACE_ONLY for other var x
- return $x
- }
- p
-} {1997}
-test var-3.2 {MakeUpvar, other var has TCL_NAMESPACE_ONLY specified} {
- namespace eval test_ns_var {
- catch {unset v}
- variable v 1998
- proc p {} {
- variable v ;# TCL_NAMESPACE_ONLY specified for other var x
- return $v
- }
- p
- }
-} {1998}
-if {[info commands testupvar] != {}} {
- test var-3.3 {MakeUpvar, my var has TCL_GLOBAL_ONLY specified} {
- catch {unset a}
- set a 123321
- proc p {} {
- # create global xx linked to global a
- testupvar 1 a {} xx global
- }
- list [p] $xx [set xx 789] $a
- } {{} 123321 789 789}
- test var-3.4 {MakeUpvar, my var has TCL_NAMESPACE_ONLY specified} {
- catch {unset a}
- set a 456
- namespace eval test_ns_var {
- catch {unset ::test_ns_var::vv}
- proc p {} {
- # create namespace var vv linked to global a
- testupvar 1 a {} vv namespace
- }
- p
- }
- list $test_ns_var::vv [set test_ns_var::vv 123] $a
- } {456 123 123}
-}
-test var-3.5 {MakeUpvar, no call frame so my var will be in global :: ns} {
- catch {unset aaaaa}
- catch {unset xxxxx}
- set aaaaa 77777
- upvar #0 aaaaa xxxxx
- list [set xxxxx] [set aaaaa]
-} {77777 77777}
-test var-3.6 {MakeUpvar, active call frame pushed for namespace eval} {
- catch {unset a}
- set a 121212
- namespace eval test_ns_var {
- upvar ::a vvv
- set vvv
- }
-} {121212}
-test var-3.7 {MakeUpvar, my var has ::s} {
- catch {unset a}
- set a 789789
- upvar #0 a test_ns_var::lnk
- namespace eval test_ns_var {
- set lnk
- }
-} {789789}
-test var-3.8 {MakeUpvar, my var already exists in global ns} {
- catch {unset aaaaa}
- catch {unset xxxxx}
- set aaaaa 456654
- set xxxxx hello
- upvar #0 aaaaa xxxxx
- set xxxxx
-} {hello}
-test var-3.9 {MakeUpvar, my var has invalid ns name} {
- catch {unset aaaaa}
- set aaaaa 789789
- list [catch {upvar #0 aaaaa test_ns_fred::lnk} msg] $msg
-} {1 {bad variable name "test_ns_fred::lnk": unknown namespace}}
-
-if {[info commands testgetvarfullname] != {}} {
- test var-4.1 {Tcl_GetVariableName, global variable} {
- catch {unset a}
- set a 123
- testgetvarfullname a global
- } ::a
- test var-4.2 {Tcl_GetVariableName, namespace variable} {
- namespace eval test_ns_var {
- variable george
- testgetvarfullname george namespace
- }
- } ::test_ns_var::george
- test var-4.3 {Tcl_GetVariableName, variable can't be array element} {
- catch {unset a}
- set a(1) foo
- list [catch {testgetvarfullname a(1) global} msg] $msg
- } {1 {unknown variable "a(1)"}}
-}
-
-test var-5.1 {Tcl_GetVariableFullName, global variable} {
- catch {unset a}
- set a bar
- namespace which -variable a
-} {::a}
-test var-5.2 {Tcl_GetVariableFullName, namespace variable} {
- namespace eval test_ns_var {
- variable martha
- namespace which -variable martha
- }
-} {::test_ns_var::martha}
-test var-5.3 {Tcl_GetVariableFullName, namespace variable} {
- namespace which -variable test_ns_var::martha
-} {::test_ns_var::martha}
-
-test var-6.1 {Tcl_GlobalObjCmd, variable is qualified by a namespace name} {
- namespace eval test_ns_var {
- variable boeing 777
- }
- proc p {} {
- global ::test_ns_var::boeing
- set boeing
- }
- p
-} {777}
-test var-6.2 {Tcl_GlobalObjCmd, variable is qualified by a namespace name} {
- namespace eval test_ns_var {
- namespace eval test_ns_nested {
- variable java java
- }
- proc p {} {
- global ::test_ns_var::test_ns_nested::java
- set java
- }
- }
- test_ns_var::p
-} {java}
-test var-6.3 {Tcl_GlobalObjCmd, variable named {} qualified by a namespace name} {
- set ::test_ns_var::test_ns_nested:: 24
- proc p {} {
- global ::test_ns_var::test_ns_nested::
- set {}
- }
- p
-} {24}
-
-test var-7.1 {Tcl_VariableObjCmd, create and initialize one new ns variable} {
- catch {namespace delete test_ns_var}
- namespace eval test_ns_var {
- variable one 1
- }
- list [info vars test_ns_var::*] [set test_ns_var::one]
-} {::test_ns_var::one 1}
-test var-7.2 {Tcl_VariableObjCmd, if new and no value, leave undefined} {
- set two 2222222
- namespace eval test_ns_var {
- variable two
- }
- list [info exists test_ns_var::two] [catch {set test_ns_var::two} msg] $msg
-} {0 1 {can't read "test_ns_var::two": no such variable}}
-test var-7.3 {Tcl_VariableObjCmd, "define" var already created above} {
- namespace eval test_ns_var {
- variable two 2
- }
- list [info vars test_ns_var::*] \
- [namespace eval test_ns_var {set two}]
-} {{::test_ns_var::two ::test_ns_var::one} 2}
-test var-7.4 {Tcl_VariableObjCmd, list of vars} {
- namespace eval test_ns_var {
- variable three 3 four 4
- }
- list [info vars test_ns_var::*] \
- [namespace eval test_ns_var {expr $three+$four}]
-} {{::test_ns_var::four ::test_ns_var::three ::test_ns_var::two ::test_ns_var::one} 7}
-test var-7.5 {Tcl_VariableObjCmd, value for last var is optional} {
- catch {unset a}
- catch {unset five}
- catch {unset six}
- set a ""
- set five 555
- set six 666
- namespace eval test_ns_var {
- variable five 5 six
- lappend a $five
- }
- lappend a $test_ns_var::five \
- [set test_ns_var::six 6] [set test_ns_var::six] $six
- catch {unset five}
- catch {unset six}
- set a
-} {5 5 6 6 666}
-catch {unset newvar}
-test var-7.6 {Tcl_VariableObjCmd, variable name can be qualified} {
- namespace eval test_ns_var {
- variable ::newvar cheers!
- }
- set newvar
-} {cheers!}
-catch {unset newvar}
-test var-7.7 {Tcl_VariableObjCmd, bad var name} {
- namespace eval test_ns_var {
- list [catch {variable sev:::en 7} msg] $msg
- }
-} {1 {can't define "sev:::en": parent namespace doesn't exist}}
-test var-7.8 {Tcl_VariableObjCmd, if var already exists and no value is given, leave value unchanged} {
- set a ""
- namespace eval test_ns_var {
- variable eight 8
- lappend a $eight
- variable eight
- lappend a $eight
- }
- set a
-} {8 8}
-test var-7.9 {Tcl_VariableObjCmd, mark as namespace var so var persists until namespace is destroyed or var is unset} {
- catch {namespace delete test_ns_var2}
- set a ""
- namespace eval test_ns_var2 {
- variable x 123
- variable y
- variable z
- }
- lappend a [info vars test_ns_var2::*]
- lappend a [info exists test_ns_var2::x] [info exists test_ns_var2::y] \
- [info exists test_ns_var2::z]
- lappend a [list [catch {set test_ns_var2::y} msg] $msg]
- lappend a [info vars test_ns_var2::*]
- lappend a [info exists test_ns_var2::y] [info exists test_ns_var2::z]
- lappend a [set test_ns_var2::y hello]
- lappend a [info exists test_ns_var2::y] [info exists test_ns_var2::z]
- lappend a [list [catch {unset test_ns_var2::y} msg] $msg]
- lappend a [info vars test_ns_var2::*]
- lappend a [info exists test_ns_var2::y] [info exists test_ns_var2::z]
- lappend a [list [catch {unset test_ns_var2::z} msg] $msg]
- lappend a [namespace delete test_ns_var2]
- set a
-} {{::test_ns_var2::x ::test_ns_var2::y ::test_ns_var2::z} 1 0 0\
-{1 {can't read "test_ns_var2::y": no such variable}}\
-{::test_ns_var2::x ::test_ns_var2::y ::test_ns_var2::z} 0 0\
-hello 1 0\
-{0 {}}\
-{::test_ns_var2::x ::test_ns_var2::z} 0 0\
-{1 {can't unset "test_ns_var2::z": no such variable}}\
-{}}
-test var-7.10 {Tcl_VariableObjCmd, variable cmd inside proc creates local link var} {
- namespace eval test_ns_var {
- proc p {} {
- variable eight
- list [set eight] [info vars]
- }
- p
- }
-} {8 eight}
-test var-7.11 {Tcl_VariableObjCmd, variable cmd inside proc creates local link var} {
- proc p {} { ;# note this proc is at global :: scope
- variable test_ns_var::eight
- list [set eight] [info vars]
- }
- p
-} {8 eight}
-test var-7.12 {Tcl_VariableObjCmd, variable cmd inside proc creates local link var} {
- namespace eval test_ns_var {
- variable {} {My name is empty}
- }
- proc p {} { ;# note this proc is at global :: scope
- variable test_ns_var::
- list [set {}] [info vars]
- }
- p
-} {{My name is empty} {{}}}
-test var-7.13 {Tcl_VariableObjCmd, variable named ":"} {
- namespace eval test_ns_var {
- variable : {My name is ":"}
- proc p {} {
- variable :
- list [set :] [info vars]
- }
- p
- }
-} {{My name is ":"} :}
-
-test var-8.1 {TclDeleteVars, "unset" traces are called with fully-qualified var names} {
- catch {namespace delete test_ns_var}
- catch {unset a}
- namespace eval test_ns_var {
- variable v 123
- variable info ""
-
- proc traceUnset {name1 name2 op} {
- variable info
- set info [concat $info [list $name1 $name2 $op]]
- }
-
- trace var v u [namespace code traceUnset]
- }
- list [unset test_ns_var::v] $test_ns_var::info
-} {{} {test_ns_var::v {} u}}
-
-if {[info commands testsetnoerr] == {}} {
- puts "This application hasn't been compiled with the \"testsetnoerr\""
- puts "command, so I can't test TclSetVar etc."
-} else {
-test var-9.1 {behaviour of TclGet/SetVar simple get/set} {
- catch {unset u}; catch {unset v}
- list \
- [set u a; testsetnoerr u] \
- [testsetnoerr v b] \
- [testseterr u] \
- [unset v; testseterr v b]
-} [list {before get a} {before set b} {before get a} {before set b}]
-test var-9.2 {behaviour of TclGet/SetVar namespace get/set} {
- catch {namespace delete ns}
- namespace eval ns {variable u a; variable v}
- list \
- [testsetnoerr ns::u] \
- [testsetnoerr ns::v b] \
- [testseterr ns::u] \
- [unset ns::v; testseterr ns::v b]
-} [list {before get a} {before set b} {before get a} {before set b}]
-test var-9.3 {behaviour of TclGetVar no variable} {
- catch {unset u}
- list \
- [catch {testsetnoerr u} res] $res \
- [catch {testseterr u} res] $res
-} {1 {before get} 1 {can't read "u": no such variable}}
-test var-9.4 {behaviour of TclGetVar no namespace variable} {
- catch {namespace delete ns}
- namespace eval ns {}
- list \
- [catch {testsetnoerr ns::w} res] $res \
- [catch {testseterr ns::w} res] $res
-} {1 {before get} 1 {can't read "ns::w": no such variable}}
-test var-9.5 {behaviour of TclGetVar no namespace} {
- catch {namespace delete ns}
- list \
- [catch {testsetnoerr ns::u} res] $res \
- [catch {testseterr ns::v} res] $res
-} {1 {before get} 1 {can't read "ns::v": no such variable}}
-test var-9.6 {behaviour of TclSetVar no namespace} {
- catch {namespace delete ns}
- list \
- [catch {testsetnoerr ns::v 1} res] $res \
- [catch {testseterr ns::v 1} res] $res
-} {1 {before set} 1 {can't set "ns::v": parent namespace doesn't exist}}
-test var-9.7 {behaviour of TclGetVar array variable} {
- catch {unset arr}
- set arr(1) 1;
- list \
- [catch {testsetnoerr arr} res] $res \
- [catch {testseterr arr} res] $res
-} {1 {before get} 1 {can't read "arr": variable is array}}
-test var-9.8 {behaviour of TclSetVar array variable} {
- catch {unset arr}
- set arr(1) 1
- list \
- [catch {testsetnoerr arr 2} res] $res \
- [catch {testseterr arr 2} res] $res
-} {1 {before set} 1 {can't set "arr": variable is array}}
-test var-9.9 {behaviour of TclGetVar read trace success} {
- proc resetvar {val name elem op} {upvar 1 $name v; set v $val}
- catch {unset u}; catch {unset v}
- set u 10
- trace var u r [list resetvar 1]
- trace var v r [list resetvar 2]
- list \
- [testsetnoerr u] \
- [testseterr v]
-} {{before get 1} {before get 2}}
-test var-9.10 {behaviour of TclGetVar read trace error} {
- proc writeonly args {error "write-only"}
- set v 456
- trace var v r writeonly
- list \
- [catch {testsetnoerr v} msg] $msg \
- [catch {testseterr v} msg] $msg
-} {1 {before get} 1 {can't read "v": write-only}}
-test var-9.11 {behaviour of TclSetVar write trace success} {
- proc doubleval {name elem op} {upvar 1 $name v; set v [expr {2 * $v}]}
- catch {unset u}; catch {unset v}
- set v 1
- trace var v w doubleval
- trace var u w doubleval
- list \
- [testsetnoerr u 2] \
- [testseterr v 3]
-} {{before set 4} {before set 6}}
-test var-9.12 {behaviour of TclSetVar write trace error} {
- proc readonly args {error "read-only"}
- set v 456
- trace var v w readonly
- list \
- [catch {testsetnoerr v 2} msg] $msg $v \
- [catch {testseterr v 3} msg] $msg $v
-} {1 {before set} 2 1 {can't set "v": read-only} 3}
-}
-test var-10.1 {can't nest arrays with array set} {
- catch {unset arr}
- list [catch {array set arr(x) {a 1 b 2}} res] $res
-} {1 {can't set "arr(x)(a)": variable isn't array}}
-
-catch {namespace delete ns}
-catch {unset arr}
-catch {unset v}
-
-catch {rename p ""}
-catch {namespace delete test_ns_var}
-catch {namespace delete test_ns_var2}
-catch {unset xx}
-catch {unset x}
-catch {unset y}
-catch {unset i}
-catch {unset a}
-catch {unset xxxxx}
-catch {unset aaaaa}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/while-old.test b/tests/while-old.test
deleted file mode 100644
index f0d55ab..0000000
--- a/tests/while-old.test
+++ /dev/null
@@ -1,132 +0,0 @@
-# Commands covered: while
-#
-# This file contains the original set of tests for Tcl's while command.
-# Since the while command is now compiled, a new set of tests covering
-# the new implementation is in the file "while.test". Sourcing this file
-# into Tcl runs the tests and generates output for errors.
-# No output means no errors were found.
-#
-# Copyright (c) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994-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: while-old.test,v 1.3 1999/04/16 00:47:36 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test while-old-1.1 {basic while loops} {
- set count 0
- while {$count < 10} {set count [expr $count+1]}
- set count
-} 10
-test while-old-1.2 {basic while loops} {
- set value xxx
- while {2 > 3} {set value yyy}
- set value
-} xxx
-test while-old-1.3 {basic while loops} {
- set value 1
- while {"true"} {
- incr value;
- if {$value > 5} {
- break;
- }
- }
- set value
-} 6
-test while-old-1.4 {basic while loops, multiline test expr} {
- set value 1
- while {($tcl_platform(platform) != "foobar1") && \
- ($tcl_platform(platform) != "foobar2")} {
- incr value
- break
- }
- set value
-} {2}
-test while-old-1.5 {basic while loops, test expr in quotes} {
- set value 1
- while "0 < 3" {set value 2; break}
- set value
-} {2}
-
-test while-old-2.1 {continue in while loop} {
- set list {1 2 3 4 5}
- set index 0
- set result {}
- while {$index < 5} {
- if {$index == 2} {set index [expr $index+1]; continue}
- set result [concat $result [lindex $list $index]]
- set index [expr $index+1]
- }
- set result
-} {1 2 4 5}
-
-test while-old-3.1 {break in while loop} {
- set list {1 2 3 4 5}
- set index 0
- set result {}
- while {$index < 5} {
- if {$index == 3} break
- set result [concat $result [lindex $list $index]]
- set index [expr $index+1]
- }
- set result
-} {1 2 3}
-
-test while-old-4.1 {errors in while loops} {
- set err [catch {while} msg]
- list $err $msg
-} {1 {wrong # args: should be "while test command"}}
-test while-old-4.2 {errors in while loops} {
- set err [catch {while 1} msg]
- list $err $msg
-} {1 {wrong # args: should be "while test command"}}
-test while-old-4.3 {errors in while loops} {
- set err [catch {while 1 2 3} msg]
- list $err $msg
-} {1 {wrong # args: should be "while test command"}}
-test while-old-4.4 {errors in while loops} {
- set err [catch {while {"a"+"b"} {error "loop aborted"}} msg]
- list $err $msg
-} {1 {can't use non-numeric string as operand of "+"}}
-test while-old-4.5 {errors in while loops} {
- catch {unset x}
- set x 1
- set err [catch {while {$x} {set x foo}} msg]
- list $err $msg
-} {1 {expected boolean value but got "foo"}}
-test while-old-4.6 {errors in while loops} {
- set err [catch {while {1} {error "loop aborted"}} msg]
- list $err $msg $errorInfo
-} {1 {loop aborted} {loop aborted
- while executing
-"error "loop aborted""}}
-
-test while-old-5.1 {while return result} {
- while {0} {set a 400}
-} {}
-test while-old-5.2 {while return result} {
- set x 1
- while {$x} {set x 0}
-} {}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/while.test b/tests/while.test
deleted file mode 100644
index f4c7581..0000000
--- a/tests/while.test
+++ /dev/null
@@ -1,633 +0,0 @@
-# Commands covered: while
-#
-# 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) 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: while.test,v 1.3 1999/04/16 00:47:36 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# Basic "while" operation.
-
-catch {unset i}
-catch {unset a}
-
-test while-1.1 {TclCompileWhileCmd: missing test expression} {
- catch {while } msg
- set msg
-} {wrong # args: should be "while test command"}
-test while-1.2 {TclCompileWhileCmd: error in test expression} {
- set i 0
- catch {while {$i<} break} msg
- set errorInfo
-} {syntax error in expression "$i<"
- ("while" test expression)
- while compiling
-"while {$i<} break"}
-test while-1.3 {TclCompileWhileCmd: error in test expression} {
- set err [catch {while {"a"+"b"} {error "loop aborted"}} msg]
- list $err $msg
-} {1 {can't use non-numeric string as operand of "+"}}
-test while-1.4 {TclCompileWhileCmd: multiline test expr} {
- set value 1
- while {($tcl_platform(platform) != "foobar1") && \
- ($tcl_platform(platform) != "foobar2")} {
- incr value
- break
- }
- set value
-} {2}
-test while-1.5 {TclCompileWhileCmd: non-numeric boolean test expr} {
- set value 1
- while {"true"} {
- incr value;
- if {$value > 5} {
- break;
- }
- }
- set value
-} 6
-test while-1.6 {TclCompileWhileCmd: test expr is enclosed in quotes} {
- set i 0
- while "$i > 5" {}
-} {}
-test while-1.7 {TclCompileWhileCmd: missing command body} {
- set i 0
- catch {while {$i < 5} } msg
- set msg
-} {wrong # args: should be "while test command"}
-test while-1.8 {TclCompileWhileCmd: error compiling command body} {
- set i 0
- catch {while {$i < 5} {set}} msg
- set errorInfo
-} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- ("while" body line 1)
- while compiling
-"while {$i < 5} {set}"}
-test while-1.9 {TclCompileWhileCmd: simple command body} {
- set a {}
- set i 1
- while {$i<6} {
- if $i==4 break
- set a [concat $a $i]
- incr i
- }
- set a
-} {1 2 3}
-test while-1.10 {TclCompileWhileCmd: command body in quotes} {
- set a {}
- set i 1
- while {$i<6} "append a x; incr i"
- set a
-} {xxxxx}
-test while-1.11 {TclCompileWhileCmd: computed command body} {
- catch {unset x1}
- catch {unset bb}
- catch {unset x2}
- set x1 {append a x1; }
- set bb {break}
- set x2 {; append a x2; incr i}
- set a {}
- set i 1
- while {$i<6} $x1$bb$x2
- set a
-} {x1}
-test while-1.12 {TclCompileWhileCmd: long command body} {
- set a {}
- set i 1
- while {$i<6} {
- if $i==4 break
- if $i>5 continue
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- set a [concat $a $i]
- incr i
- }
- set a
-} {1 2 3}
-test while-1.13 {TclCompileWhileCmd: while command result} {
- set i 0
- set a [while {$i < 5} {incr i}]
- set a
-} {}
-test while-1.14 {TclCompileWhileCmd: while command result} {
- set i 0
- set a [while {$i < 5} {if $i==3 break; incr i}]
- set a
-} {}
-
-# Check "while" and "continue".
-
-test while-2.1 {continue tests} {
- set a {}
- set i 1
- while {$i <= 4} {
- incr i
- if {$i == 3} continue
- set a [concat $a $i]
- }
- set a
-} {2 4 5}
-test while-2.2 {continue tests} {
- set a {}
- set i 1
- while {$i <= 4} {
- incr i
- if {$i != 2} continue
- set a [concat $a $i]
- }
- set a
-} {2}
-test while-2.3 {continue tests, nested loops} {
- set msg {}
- set i 1
- while {$i <= 4} {
- incr i
- set a 1
- while {$a <= 2} {
- incr a
- if {$i>=3 && $a>=3} continue
- set msg [concat $msg "$i.$a"]
- }
- }
- set msg
-} {2.2 2.3 3.2 4.2 5.2}
-test while-2.4 {continue tests, long command body} {
- set a {}
- set i 1
- while {$i<6} {
- if $i==2 {incr i; continue}
- if $i==4 break
- if $i>5 continue
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- set a [concat $a $i]
- incr i
- }
- set a
-} {1 3}
-
-# Check "while" and "break".
-
-test while-3.1 {break tests} {
- set a {}
- set i 1
- while {$i <= 4} {
- if {$i == 3} break
- set a [concat $a $i]
- incr i
- }
- set a
-} {1 2}
-test while-3.2 {break tests, nested loops} {
- set msg {}
- set i 1
- while {$i <= 4} {
- set a 1
- while {$a <= 2} {
- if {$i>=2 && $a>=2} break
- set msg [concat $msg "$i.$a"]
- incr a
- }
- incr i
- }
- set msg
-} {1.1 1.2 2.1 3.1 4.1}
-test while-3.3 {break tests, long command body} {
- set a {}
- set i 1
- while {$i<6} {
- if $i==2 {incr i; continue}
- if $i==5 break
- if $i>5 continue
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if $i==4 break
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- set a [concat $a $i]
- incr i
- }
- set a
-} {1 3}
-
-# Check "while" with computed command names.
-
-test while-4.1 {while and computed command names} {
- set i 0
- set z while
- $z {$i < 10} {
- incr i
- }
- set i
-} 10
-test while-4.2 {while (not compiled): missing test expression} {
- set z while
- catch {$z } msg
- set msg
-} {wrong # args: should be "while test command"}
-test while-4.3 {while (not compiled): error in test expression} {
- set i 0
- set z while
- catch {$z {$i<} {set x 1}} msg
- set errorInfo
-} {syntax error in expression "$i<"
- while executing
-"$z {$i<} {set x 1}"}
-test while-4.4 {while (not compiled): error in test expression} {
- set z while
- set err [catch {$z {"a"+"b"} {error "loop aborted"}} msg]
- list $err $msg
-} {1 {can't use non-numeric string as operand of "+"}}
-test while-4.5 {while (not compiled): multiline test expr} {
- set value 1
- set z while
- $z {($tcl_platform(platform) != "foobar1") && \
- ($tcl_platform(platform) != "foobar2")} {
- incr value
- break
- }
- set value
-} {2}
-test while-4.6 {while (not compiled): non-numeric boolean test expr} {
- set value 1
- set z while
- $z {"true"} {
- incr value;
- if {$value > 5} {
- break;
- }
- }
- set value
-} 6
-test while-4.7 {while (not compiled): test expr is enclosed in quotes} {
- set i 0
- set z while
- $z "$i > 5" {}
-} {}
-test while-4.8 {while (not compiled): missing command body} {
- set i 0
- set z while
- catch {$z {$i < 5} } msg
- set msg
-} {wrong # args: should be "while test command"}
-test while-4.9 {while (not compiled): error compiling command body} {
- set i 0
- set z while
- catch {$z {$i < 5} {set}} msg
- set errorInfo
-} {wrong # args: should be "set varName ?newValue?"
- while compiling
-"set"
- ("while" body line 1)
- invoked from within
-"$z {$i < 5} {set}"}
-test while-4.10 {while (not compiled): simple command body} {
- set a {}
- set i 1
- set z while
- $z {$i<6} {
- if $i==4 break
- set a [concat $a $i]
- incr i
- }
- set a
-} {1 2 3}
-test while-4.11 {while (not compiled): command body in quotes} {
- set a {}
- set i 1
- set z while
- $z {$i<6} "append a x; incr i"
- set a
-} {xxxxx}
-test while-4.12 {while (not compiled): computed command body} {
- set z while
- catch {unset x1}
- catch {unset bb}
- catch {unset x2}
- set x1 {append a x1; }
- set bb {break}
- set x2 {; append a x2; incr i}
- set a {}
- set i 1
- $z {$i<6} $x1$bb$x2
- set a
-} {x1}
-test while-4.13 {while (not compiled): long command body} {
- set a {}
- set z while
- set i 1
- $z {$i<6} {
- if $i==4 break
- if $i>5 continue
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- set a [concat $a $i]
- incr i
- }
- set a
-} {1 2 3}
-test while-4.14 {while (not compiled): while command result} {
- set i 0
- set z while
- set a [$z {$i < 5} {incr i}]
- set a
-} {}
-test while-4.15 {while (not compiled): while command result} {
- set i 0
- set z while
- set a [$z {$i < 5} {if $i==3 break; incr i}]
- set a
-} {}
-
-# Check "break" with computed command names.
-
-test while-5.1 {break and computed command names} {
- set i 0
- set z break
- while 1 {
- if {$i > 10} $z
- incr i
- }
- set i
-} 11
-test while-5.2 {break tests with computed command names} {
- set a {}
- set i 1
- set z break
- while {$i <= 4} {
- if {$i == 3} $z
- set a [concat $a $i]
- incr i
- }
- set a
-} {1 2}
-test while-5.3 {break tests, nested loops with computed command names} {
- set msg {}
- set i 1
- set z break
- while {$i <= 4} {
- set a 1
- while {$a <= 2} {
- if {$i>=2 && $a>=2} $z
- set msg [concat $msg "$i.$a"]
- incr a
- }
- incr i
- }
- set msg
-} {1.1 1.2 2.1 3.1 4.1}
-test while-5.4 {break tests, long command body with computed command names} {
- set a {}
- set i 1
- set z break
- while {$i<6} {
- if $i==2 {incr i; continue}
- if $i==5 $z
- if $i>5 continue
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if $i==4 $z
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- set a [concat $a $i]
- incr i
- }
- set a
-} {1 3}
-
-# Check "continue" with computed command names.
-
-test while-6.1 {continue and computed command names} {
- set i 0
- set z continue
- while 1 {
- incr i
- if {$i < 10} $z
- break
- }
- set i
-} 10
-test while-6.2 {continue tests} {
- set a {}
- set i 1
- set z continue
- while {$i <= 4} {
- incr i
- if {$i == 3} $z
- set a [concat $a $i]
- }
- set a
-} {2 4 5}
-test while-6.3 {continue tests with computed command names} {
- set a {}
- set i 1
- set z continue
- while {$i <= 4} {
- incr i
- if {$i != 2} $z
- set a [concat $a $i]
- }
- set a
-} {2}
-test while-6.4 {continue tests, nested loops with computed command names} {
- set msg {}
- set i 1
- set z continue
- while {$i <= 4} {
- incr i
- set a 1
- while {$a <= 2} {
- incr a
- if {$i>=3 && $a>=3} $z
- set msg [concat $msg "$i.$a"]
- }
- }
- set msg
-} {2.2 2.3 3.2 4.2 5.2}
-test while-6.5 {continue tests, long command body with computed command names} {
- set a {}
- set i 1
- set z continue
- while {$i<6} {
- if $i==2 {incr i; continue}
- if $i==4 break
- if $i>5 $z
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- if {$i>6 && $tcl_platform(machine)=="xxx"} {
- catch {set a $a} msg
- catch {incr i 5} msg
- catch {incr i -5} msg
- }
- set a [concat $a $i]
- incr i
- }
- set a
-} {1 3}
-
-# Test for incorrect "double evaluation" semantics
-
-test while-7.1 {delayed substitution of body} {knownBug} {
- set i 0
- while {[incr i] < 10} "
- set result $i
- "
- set result
-} {0}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/winConsole.test b/tests/winConsole.test
deleted file mode 100644
index 8a18b2c..0000000
--- a/tests/winConsole.test
+++ /dev/null
@@ -1,51 +0,0 @@
-# This file tests the tclWinConsole.c file.
-#
-# 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) 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: winConsole.test,v 1.2 1999/04/16 00:47:36 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-
-test winConsole-1.1 {Console file channel: non-blocking gets} \
- {pcOnly interactive} {
-
- set oldmode [fconfigure stdin]
-
- puts stdout "Enter abcdef<return> now: " nonewline
- flush stdout
- fileevent stdin readable {
- if {[gets stdin line] >= 0} {
- set result $line
- } else {
- set result "gets failed"
- }
- }
-
- fconfigure stdin -blocking 0 -buffering line
-
- set result {}
- vwait result
-
- #cleanup the fileevent
- fileevent stdin readable {}
- eval fconfigure stdin $oldmode
-
- set result
-
-} "abcdef"
-
-#cleanup
-
-::tcltest::cleanupTests
-return
-
diff --git a/tests/winDde.test b/tests/winDde.test
deleted file mode 100644
index e9b65d8..0000000
--- a/tests/winDde.test
+++ /dev/null
@@ -1,152 +0,0 @@
-# This file tests the tclWinDde.c file.
-#
-# 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) 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: winDde.test,v 1.2 1999/04/16 00:47:37 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-if {$tcl_platform(platform) == "windows"} {
- if [catch {
- set lib [lindex [glob [file join [pwd] [file dirname \
- [info nameofexecutable]] tcldde*.dll]] 0]
- load $lib dde
- }] {
- puts "Unable to find the dde package. Skipping registry tests."
- ::tcltest::cleanupTests
- return
- }
-}
-
-set scriptName script1.tcl
-
-
-proc createChildProcess { ddeServerName } {
-
- file delete -force $::scriptName
-
- set f [open $::scriptName w+]
- puts $f {
- if [catch {
- set lib [lindex [glob [file join [pwd] [file dirname \
- [info nameofexecutable]] tcldde*.dll]] 0]
- load $lib dde
- }] {
- puts "Unable to find the dde package. Skipping registry tests."
- ::tcltest::cleanupTests
- return
- }
- }
- puts $f "dde servername $ddeServerName"
- puts $f {
- puts ready
- vwait done
- update
- exit
- }
- close $f
-
- set f [open "|$::tcltest $::scriptName" r]
- gets $f
- return $f
-}
-
-test winDde-1.1 {Settings the server's topic name} {pcOnly} {
- list [dde servername foobar] [dde servername] [dde servername self]
-} {foobar foobar self}
-
-test winDde-2.1 {Checking for other services} {pcOnly} {
- expr [llength [dde services {} {}]] >= 0
-} 1
-
-test winDde-2.2 {Checking for existence, with service and topic specified} \
- {pcOnly} {
- llength [dde services TclEval self]
-} 1
-
-test winDde-2.3 {Checking for existence, with only the service specified} \
- {pcOnly} {
- expr [llength [dde services TclEval {}]] >= 1
-} 1
-
-test winDde-3.1 {DDE execute locally} {pcOnly} {
- set a ""
- dde execute TclEval self {set a "foo"}
- set a
-} foo
-
-test winDde-3.2 {DDE execute -async locally} {pcOnly} {
- set a ""
- dde execute -async TclEval self {set a "foo"}
- update
- set a
-} foo
-
-test winDde-3.3 {DDE request locally} {pcOnly} {
- set a ""
- dde execute TclEval self {set a "foo"}
- dde request TclEval self a
-} foo
-
-test winDde-3.4 {DDE eval locally} {pcOnly} {
- set a ""
- dde eval self set a "foo"
-} foo
-
-test winDde-4.1 {DDE execute remotely} {pcOnly} {
- set a ""
- set child [createChildProcess child]
- dde execute TclEval child {set a "foo"}
-
- dde execute TclEval child {set done 1}
-
- set a
-} ""
-
-test winDde-4.2 {DDE execute remotely} {pcOnly} {
- set a ""
- set child [createChildProcess child]
- dde execute -async TclEval child {set a "foo"}
-
- dde execute TclEval child {set done 1}
-
- set a
-} ""
-
-test winDde-4.3 {DDE request locally} {pcOnly} {
- set a ""
- set child [createChildProcess child]
- dde execute TclEval child {set a "foo"}
- set a [dde request TclEval child a]
-
-
- dde execute TclEval child {set done 1}
-
- set a
-} foo
-
-test winDde-4.4 {DDE eval locally} {pcOnly} {
- set a ""
- set child [createChildProcess child]
- set a [dde eval child set a "foo"]
-
- dde execute TclEval child {set done 1}
-
- set a
-} foo
-
-
-#cleanup
-file delete -force $::scriptName
-::tcltest::cleanupTests
-return
-
diff --git a/tests/winFCmd.test b/tests/winFCmd.test
deleted file mode 100644
index 935198e..0000000
--- a/tests/winFCmd.test
+++ /dev/null
@@ -1,978 +0,0 @@
-# This file tests the tclWinFCmd.c file.
-#
-# 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) 1996-1997 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: winFCmd.test,v 1.4 1999/04/16 00:47:37 stanton Exp $
-#
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-proc createfile {file {string a}} {
- set f [open $file w]
- puts -nonewline $f $string
- close $f
- return $string
-}
-
-proc contents {file} {
- set f [open $file r]
- set r [read $f]
- close $f
- set r
-}
-
-proc cleanup {args} {
- foreach p ". $args" {
- set x ""
- catch {
- set x [glob [file join $p tf*] [file join $p td*]]
- }
- if {$x != ""} {
- catch {eval file delete -force -- $x}
- }
- }
-}
-
-set ::tcltest::testConfig(cdrom) 0
-set ::tcltest::testConfig(exdev) 0
-
-# find a CD-ROM so we can test read-only filesystems.
-
-set cdrom {}
-set nodrive x:
-foreach p {d e f g h i j k l m n o p q r s t u v w x y z} {
- set name ${p}:/dummy~~.fil
- if [catch {set fd [open $name w]}] {
- set err [lindex $errorCode 1]
- if {$cdrom == "" && $err == "EACCES"} {
- set cdrom ${p}:
- }
- if {$err == "ENOENT"} {
- set nodrive ${p}:
- }
- } else {
- close $fd
- file delete $name
- }
-}
-
-proc findfile {dir} {
- foreach p [glob $dir/*] {
- if {[file type $p] == "file"} {
- return $p
- }
- }
- foreach p [glob $dir/*] {
- if {[file type $p] == "directory"} {
- set f [findfile $p]
- if {$f != ""} {
- return $f
- }
- }
- }
- return ""
-}
-
-if {$cdrom != ""} {
- set ::tcltest::testConfig(cdrom) 1
- set cdfile [findfile $cdrom]
-}
-
-if {[file exists c:/] && [file exists d:/]} {
- catch {file delete d:/tf1}
- if {[catch {close [open d:/tf1 w]}] == 0} {
- file delete d:/tf1
- set ::tcltest::testConfig(exdev) 1
- }
-}
-
-file delete -force -- td1
-set foo [catch {open td1 w} testfile]
-if {$foo} {
- set ::tcltest::testConfig(longFileNames) 0
-} else {
- close $testfile
- set ::tcltest::testConfig(longFileNames) 1
- file delete -force -- td1
-}
-
-# A really long file name
-# length of longname is 1216 chars, which should be greater than any static
-# buffer or allowable filename.
-
-set longname "abcdefghihjllmnopqrstuvwxyz01234567890"
-append longname $longname
-append longname $longname
-append longname $longname
-append longname $longname
-append longname $longname
-
-# Uses the "testfile" command instead of the "file" command. The "file"
-# command provides several layers of sanity checks on the arguments and
-# it can be difficult to actually forward "insane" arguments to the
-# low-level posix emulation layer.
-
-test winFCmd-1.1 {TclpRenameFile: errno: EACCES} {pcOnly cdrom} {
- list [catch {testfile mv $cdfile $cdrom/dummy~~.fil} msg] $msg
-} {1 EACCES}
-test winFCmd-1.2 {TclpRenameFile: errno: EEXIST} {pcOnly} {
- cleanup
- file mkdir td1/td2/td3
- file mkdir td2
- list [catch {testfile mv td2 td1/td2} msg] $msg
-} {1 EEXIST}
-test winFCmd-1.3 {TclpRenameFile: errno: EINVAL} {pcOnly} {
- cleanup
- list [catch {testfile mv / td1} msg] $msg
-} {1 EINVAL}
-test winFCmd-1.4 {TclpRenameFile: errno: EINVAL} {pcOnly} {
- cleanup
- file mkdir td1
- list [catch {testfile mv td1 td1/td2} msg] $msg
-} {1 EINVAL}
-test winFCmd-1.5 {TclpRenameFile: errno: EISDIR} {pcOnly} {
- cleanup
- file mkdir td1
- createfile tf1
- list [catch {testfile mv tf1 td1} msg] $msg
-} {1 EISDIR}
-test winFCmd-1.6 {TclpRenameFile: errno: ENOENT} {pcOnly} {
- cleanup
- list [catch {testfile mv tf1 tf2} msg] $msg
-} {1 ENOENT}
-test winFCmd-1.7 {TclpRenameFile: errno: ENOENT} {pcOnly} {
- cleanup
- list [catch {testfile mv "" tf2} msg] $msg
-} {1 ENOENT}
-test winFCmd-1.8 {TclpRenameFile: errno: ENOENT} {pcOnly} {
- cleanup
- createfile tf1
- list [catch {testfile mv tf1 ""} msg] $msg
-} {1 ENOENT}
-test winFCmd-1.9 {TclpRenameFile: errno: ENOTDIR} {pcOnly} {
- cleanup
- file mkdir td1
- createfile tf1
- list [catch {testfile mv td1 tf1} msg] $msg
-} {1 ENOTDIR}
-test winFCmd-1.10 {TclpRenameFile: errno: EXDEV} {pcOnly exdev} {
- file delete -force d:/tf1
- file mkdir c:/tf1
- set msg [list [catch {testfile mv c:/tf1 d:/tf1} msg] $msg]
- file delete -force c:/tf1
- set msg
-} {1 EXDEV}
-test winFCmd-1.11 {TclpRenameFile: errno: EACCES} {pcOnly} {
- cleanup
- set fd [open tf1 w]
- set msg [list [catch {testfile mv tf1 tf2} msg] $msg]
- close $fd
- set msg
-} {1 EACCES}
-test winFCmd-1.12 {TclpRenameFile: errno: EACCES} {pcOnly} {
- cleanup
- createfile tf1
- set fd [open tf2 w]
- set msg [list [catch {testfile mv tf1 tf2} msg] $msg]
- close $fd
- set msg
-} {1 EACCES}
-test winFCmd-1.13 {TclpRenameFile: errno: EACCES} {pcOnly} {
- cleanup
- list [catch {testfile mv nul tf1} msg] $msg
-} {1 EACCES}
-test winFCmd-1.14 {TclpRenameFile: errno: EACCES} {95} {
- cleanup
- createfile tf1
- list [catch {testfile mv tf1 nul} msg] $msg
-} {1 EACCES}
-test winFCmd-1.15 {TclpRenameFile: errno: EEXIST} {nt} {
- cleanup
- createfile tf1
- list [catch {testfile mv tf1 nul} msg] $msg
-} {1 EEXIST}
-test winFCmd-1.16 {TclpRenameFile: MoveFile() != FALSE} {pcOnly} {
- cleanup
- createfile tf1 tf1
- testfile mv tf1 tf2
- list [file exists tf1] [contents tf2]
-} {0 tf1}
-test winFCmd-1.17 {TclpRenameFile: MoveFile() == FALSE} {pcOnly} {
- cleanup
- list [catch {testfile mv tf1 tf2} msg] $msg
-} {1 ENOENT}
-test winFCmd-1.18 {TclpRenameFile: srcAttr == -1} {pcOnly} {
- cleanup
- list [catch {testfile mv tf1 tf2} msg] $msg
-} {1 ENOENT}
-test winFCmd-1.19 {TclpRenameFile: errno == EACCES} {pcOnly} {
- cleanup
- list [catch {testfile mv nul tf1} msg] $msg
-} {1 EACCES}
-test winFCmd-1.20 {TclpRenameFile: src is dir} {nt} {
- # under 95, this would actually succeed and move the current dir out from
- # under the current process!
- cleanup
- file delete /tf1
- list [catch {testfile mv [pwd] /tf1} msg] $msg
-} {1 EACCES}
-test winFCmd-1.21 {TclpRenameFile: long src} {pcOnly} {
- cleanup
- list [catch {testfile mv $longname tf1} msg] $msg
-} {1 ENAMETOOLONG}
-test winFCmd-1.22 {TclpRenameFile: long dst} {pcOnly} {
- cleanup
- createfile tf1
- list [catch {testfile mv tf1 $longname} msg] $msg
-} {1 ENAMETOOLONG}
-test winFCmd-1.23 {TclpRenameFile: move dir into self} {pcOnly} {
- cleanup
- file mkdir td1
- list [catch {testfile mv [pwd]/td1 td1/td2} msg] $msg
-} {1 EINVAL}
-test winFCmd-1.24 {TclpRenameFile: move a root dir} {pcOnly} {
- cleanup
- list [catch {testfile mv / c:/} msg] $msg
-} {1 EINVAL}
-test winFCmd-1.25 {TclpRenameFile: cross file systems} {pcOnly cdrom} {
- cleanup
- file mkdir td1
- list [catch {testfile mv td1 $cdrom/td1} msg] $msg
-} {1 EXDEV}
-test winFCmd-1.26 {TclpRenameFile: readonly fs} {pcOnly cdrom} {
- cleanup
- list [catch {testfile mv $cdfile $cdrom/dummy~~.fil} msg] $msg
-} {1 EACCES}
-test winFCmd-1.27 {TclpRenameFile: open file} {pcOnly} {
- cleanup
- set fd [open tf1 w]
- set msg [list [catch {testfile mv tf1 tf2} msg] $msg]
- close $fd
- set msg
-} {1 EACCES}
-test winFCmd-1.28 {TclpRenameFile: errno == EEXIST} {pcOnly} {
- cleanup
- createfile tf1
- createfile tf2
- testfile mv tf1 tf2
- list [file exist tf1] [file exist tf2]
-} {0 1}
-test winFCmd-1.29 {TclpRenameFile: src is dir} {pcOnly} {
- cleanup
- file mkdir td1
- createfile tf1
- list [catch {testfile mv td1 tf1} msg] $msg
-} {1 ENOTDIR}
-test winFCmd-1.30 {TclpRenameFile: dst is dir} {pcOnly} {
- cleanup
- file mkdir td1
- file mkdir td2/td2
- list [catch {testfile mv td1 td2} msg] $msg
-} {1 EEXIST}
-test winFCmd-1.31 {TclpRenameFile: TclpRemoveDirectory fails} {pcOnly} {
- cleanup
- file mkdir td1
- file mkdir td2/td2
- list [catch {testfile mv td1 td2} msg] $msg
-} {1 EEXIST}
-test winFCmd-1.32 {TclpRenameFile: TclpRemoveDirectory succeeds} {pcOnly} {
- cleanup
- file mkdir td1/td2
- file mkdir td2
- testfile mv td1 td2
- list [file exist td1] [file exist td2] [file exist td2/td2]
-} {0 1 1}
-test winFCmd-1.33 {TclpRenameFile: After removing dst dir, MoveFile fails} \
- {pcOnly exdev} {
- file mkdir d:/td1
- testchmod 000 d:/td1
- set msg [list [catch {testfile mv c:/windows d:/td1} msg] $msg]
- set msg "$msg [file writable d:/td1]"
- file delete d:/td1
- set msg
-} {1 EXDEV 0}
-test winFCmd-1.34 {TclpRenameFile: src is dir, dst is not} {pcOnly} {
- file mkdir td1
- createfile tf1
- list [catch {testfile mv td1 tf1} msg] $msg
-} {1 ENOTDIR}
-test winFCmd-1.35 {TclpRenameFile: src is not dir, dst is} {pcOnly} {
- file mkdir td1
- createfile tf1
- list [catch {testfile mv tf1 td1} msg] $msg
-} {1 EISDIR}
-test winFCmd-1.36 {TclpRenameFile: src and dst not dir} {pcOnly} {
- createfile tf1 tf1
- createfile tf2 tf2
- testfile mv tf1 tf2
- contents tf2
-} {tf1}
-test winFCmd-1.37 {TclpRenameFile: need to restore temp file} {pcOnly} {
- # Can't figure out how to cause this.
- # Need a file that can't be copied.
-} {}
-
-test winFCmd-2.1 {TclpCopyFile: errno: EACCES} {pcOnly cdrom} {
- cleanup
- list [catch {testfile cp $cdfile $cdrom/dummy~~.fil} msg] $msg
-} {1 EACCES}
-test winFCmd-2.2 {TclpCopyFile: errno: EISDIR} {pcOnly} {
- cleanup
- file mkdir td1
- list [catch {testfile cp td1 tf1} msg] $msg
-} {1 EISDIR}
-test winFCmd-2.3 {TclpCopyFile: errno: EISDIR} {pcOnly} {
- cleanup
- createfile tf1
- file mkdir td1
- list [catch {testfile cp tf1 td1} msg] $msg
-} {1 EISDIR}
-test winFCmd-2.4 {TclpCopyFile: errno: ENOENT} {pcOnly} {
- cleanup
- list [catch {testfile cp tf1 tf2} msg] $msg
-} {1 ENOENT}
-test winFCmd-2.5 {TclpCopyFile: errno: ENOENT} {pcOnly} {
- cleanup
- list [catch {testfile cp "" tf2} msg] $msg
-} {1 ENOENT}
-test winFCmd-2.6 {TclpCopyFile: errno: ENOENT} {pcOnly} {
- cleanup
- createfile tf1
- list [catch {testfile cp tf1 ""} msg] $msg
-} {1 ENOENT}
-test winFCmd-2.7 {TclpCopyFile: errno: EACCES} {95} {
- cleanup
- createfile tf1
- set fd [open tf2 w]
- set msg [list [catch {testfile cp tf1 tf2} msg] $msg]
- close $fd
- set msg
-} {1 EACCES}
-test winFCmd-2.8 {TclpCopyFile: errno: EACCES} {nt} {
- cleanup
- list [catch {testfile cp nul tf1} msg] $msg
-} {1 EACCES}
-test winFCmd-2.9 {TclpCopyFile: errno: ENOENT} {95} {
- cleanup
- list [catch {testfile cp nul tf1} msg] $msg
-} {1 ENOENT}
-test winFCmd-2.10 {TclpCopyFile: CopyFile succeeds} {pcOnly} {
- cleanup
- createfile tf1 tf1
- testfile cp tf1 tf2
- list [contents tf1] [contents tf2]
-} {tf1 tf1}
-test winFCmd-2.11 {TclpCopyFile: CopyFile succeeds} {pcOnly} {
- cleanup
- createfile tf1 tf1
- createfile tf2 tf2
- testfile cp tf1 tf2
- list [contents tf1] [contents tf2]
-} {tf1 tf1}
-test winFCmd-2.12 {TclpCopyFile: CopyFile succeeds} {pcOnly} {
- cleanup
- createfile tf1 tf1
- testchmod 000 tf1
- testfile cp tf1 tf2
- list [contents tf2] [file writable tf2]
-} {tf1 0}
-test winFCmd-2.13 {TclpCopyFile: CopyFile fails} {pcOnly} {
- cleanup
- createfile tf1
- file mkdir td1
- list [catch {testfile cp tf1 td1} msg] $msg
-} {1 EISDIR}
-test winFCmd-2.14 {TclpCopyFile: errno == EACCES} {pcOnly} {
- cleanup
- file mkdir td1
- list [catch {testfile cp td1 tf1} msg] $msg
-} {1 EISDIR}
-test winFCmd-2.15 {TclpCopyFile: src is directory} {pcOnly} {
- cleanup
- file mkdir td1
- list [catch {testfile cp td1 tf1} msg] $msg
-} {1 EISDIR}
-test winFCmd-2.16 {TclpCopyFile: dst is directory} {pcOnly} {
- cleanup
- createfile tf1
- file mkdir td1
- list [catch {testfile cp tf1 td1} msg] $msg
-} {1 EISDIR}
-test winFCmd-2.17 {TclpCopyFile: dst is readonly} {pcOnly} {
- cleanup
- createfile tf1 tf1
- createfile tf2 tf2
- testchmod 000 tf2
- testfile cp tf1 tf2
- list [file writable tf2] [contents tf2]
-} {1 tf1}
-test winFCmd-2.18 {TclpCopyFile: still can't copy onto dst} {95} {
- cleanup
- createfile tf1
- createfile tf2
- testchmod 000 tf2
- set fd [open tf2]
- set msg [list [catch {testfile cp tf1 tf2} msg] $msg]
- close $fd
- set msg "$msg [file writable tf2]"
-} {1 EACCES 0}
-
-test winFCmd-3.1 {TclpDeleteFile: errno: EACCES} {pcOnly cdrom} {
- list [catch {testfile rm $cdfile $cdrom/dummy~~.fil} msg] $msg
-} {1 EACCES}
-test winFCmd-3.2 {TclpDeleteFile: errno: EISDIR} {pcOnly} {
- cleanup
- file mkdir td1
- list [catch {testfile rm td1} msg] $msg
-} {1 EISDIR}
-test winFCmd-3.3 {TclpDeleteFile: errno: ENOENT} {pcOnly} {
- cleanup
- list [catch {testfile rm tf1} msg] $msg
-} {1 ENOENT}
-test winFCmd-3.4 {TclpDeleteFile: errno: ENOENT} {pcOnly} {
- cleanup
- list [catch {testfile rm ""} msg] $msg
-} {1 ENOENT}
-test winFCmd-3.5 {TclpDeleteFile: errno: EACCES} {pcOnly} {
- cleanup
- set fd [open tf1 w]
- set msg [list [catch {testfile rm tf1} msg] $msg]
- close $fd
- set msg
-} {1 EACCES}
-test winFCmd-3.6 {TclpDeleteFile: errno: EACCES} {pcOnly} {
- cleanup
- list [catch {testfile rm nul} msg] $msg
-} {1 EACCES}
-test winFCmd-3.7 {TclpDeleteFile: DeleteFile succeeds} {pcOnly} {
- cleanup
- createfile tf1
- testfile rm tf1
- file exist tf1
-} {0}
-test winFCmd-3.8 {TclpDeleteFile: DeleteFile fails} {pcOnly} {
- cleanup
- file mkdir td1
- list [catch {testfile rm td1} msg] $msg
-} {1 EISDIR}
-test winFCmd-3.9 {TclpDeleteFile: errno == EACCES} {pcOnly} {
- cleanup
- set fd [open tf1 w]
- set msg [list [catch {testfile rm tf1} msg] $msg]
- close $fd
- set msg
-} {1 EACCES}
-test winFCmd-3.10 {TclpDeleteFile: path is readonly} {pcOnly} {
- cleanup
- createfile tf1
- testchmod 000 tf1
- testfile rm tf1
- file exists tf1
-} {0}
-test winFCmd-3.11 {TclpDeleteFile: still can't remove path} {pcOnly} {
- cleanup
- set fd [open tf1 w]
- testchmod 000 tf1
- set msg [list [catch {testfile rm tf1} msg] $msg]
- close $fd
- set msg
-} {1 EACCES}
-
-test winFCmd-4.1 {TclpCreateDirectory: errno: EACCES} {nt cdrom} {
- list [catch {testfile mkdir $cdrom/dummy~~.dir} msg] $msg
-} {1 EACCES}
-test winFCmd-4.2 {TclpCreateDirectory: errno: EACCES} {95 cdrom} {
- list [catch {testfile mkdir $cdrom/dummy~~.dir} msg] $msg
-} {1 ENOSPC}
-test winFCmd-4.3 {TclpCreateDirectory: errno: EEXIST} {pcOnly} {
- cleanup
- file mkdir td1
- list [catch {testfile mkdir td1} msg] $msg
-} {1 EEXIST}
-test winFCmd-4.4 {TclpCreateDirectory: errno: ENOENT} {pcOnly} {
- cleanup
- list [catch {testfile mkdir td1/td2} msg] $msg
-} {1 ENOENT}
-test winFCmd-4.5 {TclpCreateDirectory: CreateDirectory succeeds} {pcOnly} {
- cleanup
- testfile mkdir td1
- file type td1
-} {directory}
-
-test winFCmd-5.1 {TclpCopyDirectory: calls TraverseWinTree} {pcOnly} {
- cleanup
- file mkdir td1
- testfile cpdir td1 td2
- list [file type td1] [file type td2]
-} {directory directory}
-
-test winFCmd-6.1 {TclpRemoveDirectory: errno: EACCES} {pcOnly} {
- cleanup
- file mkdir td1
- testchmod 000 td1
- testfile rmdir td1
- file exist td1
-} {0}
-test winFCmd-6.2 {TclpRemoveDirectory: errno: EEXIST} {pcOnly} {
- cleanup
- file mkdir td1/td2
- list [catch {testfile rmdir td1} msg] $msg
-} {1 {td1 EEXIST}}
-test winFCmd-6.3 {TclpRemoveDirectory: errno: EACCES} {pcOnly} {
- # can't test this w/o removing everything on your hard disk first!
- # testfile rmdir /
-} {}
-test winFCmd-6.4 {TclpRemoveDirectory: errno: ENOENT} {pcOnly} {
- cleanup
- list [catch {testfile rmdir td1} msg] $msg
-} {1 {td1 ENOENT}}
-test winFCmd-6.5 {TclpRemoveDirectory: errno: ENOENT} {pcOnly} {
- cleanup
- list [catch {testfile rmdir ""} msg] $msg
-} {1 ENOENT}
-test winFCmd-6.6 {TclpRemoveDirectory: errno: ENOTDIR} {pcOnly} {
- cleanup
- createfile tf1
- list [catch {testfile rmdir tf1} msg] $msg
-} {1 {tf1 ENOTDIR}}
-test winFCmd-6.7 {TclpRemoveDirectory: RemoveDirectory succeeds} {pcOnly} {
- cleanup
- file mkdir td1
- testfile rmdir td1
- file exists td1
-} {0}
-test winFCmd-6.8 {TclpRemoveDirectory: RemoveDirectory fails} {pcOnly} {
- cleanup
- createfile tf1
- list [catch {testfile rmdir tf1} msg] $msg
-} {1 {tf1 ENOTDIR}}
-test winFCmd-6.9 {TclpRemoveDirectory: errno == EACCES} {pcOnly} {
- cleanup
- file mkdir td1
- testchmod 000 td1
- testfile rmdir td1
- file exists td1
-} {0}
-test winFCmd-6.10 {TclpRemoveDirectory: attr == -1} {95} {
- cleanup
- list [catch {testfile rmdir nul} msg] $msg
-} {1 {nul EACCES}}
-test winFCmd-6.11 {TclpRemoveDirectory: attr == -1} {nt} {
- cleanup
- list [catch {testfile rmdir /} msg] $msg
-} {1 {\ EACCES}}
-test winFCmd-6.12 {TclpRemoveDirectory: errno == EACCES} {95} {
- cleanup
- createfile tf1
- list [catch {testfile rmdir tf1} msg] $msg
-} {1 {tf1 ENOTDIR}}
-test winFCmd-6.13 {TclpRemoveDirectory: write-protected} {pcOnly} {
- cleanup
- file mkdir td1
- testchmod 000 td1
- testfile rmdir td1
- file exists td1
-} {0}
-test winFCmd-6.14 {TclpRemoveDirectory: check if empty dir} {95} {
- cleanup
- file mkdir td1/td2
- list [catch {testfile rmdir td1} msg] $msg
-} {1 {td1 EEXIST}}
-test winFCmd-6.15 {TclpRemoveDirectory: !recursive} {pcOnly} {
- cleanup
- file mkdir td1/td2
- list [catch {testfile rmdir td1} msg] $msg
-} {1 {td1 EEXIST}}
-test winFCmd-6.16 {TclpRemoveDirectory: recursive, but errno != EEXIST} {pcOnly} {
- cleanup
- createfile tf1
- list [catch {testfile rmdir -force tf1} msg] $msg
-} {1 {tf1 ENOTDIR}}
-test winFCmd-6.17 {TclpRemoveDirectory: calls TraverseWinTree} {pcOnly} {
- cleanup
- file mkdir td1/td2
- testfile rmdir -force td1
- file exists td1
-} {0}
-
-test winFCmd-7.1 {TraverseWinTree: targetPtr == NULL} {pcOnly} {
- cleanup
- file mkdir td1/td2/td3
- testfile rmdir -force td1
- file exists td1
-} {0}
-test winFCmd-7.2 {TraverseWinTree: targetPtr != NULL} {pcOnly} {
- cleanup
- file mkdir td1/td2/td3
- testfile cpdir td1 td2
- list [file exists td1] [file exists td2]
-} {1 1}
-test winFCmd-7.3 {TraverseWinTree: sourceAttr == -1} {pcOnly} {
- cleanup
- list [catch {testfile cpdir td1 td2} msg] $msg
-} {1 {td1 ENOENT}}
-test winFCmd-7.4 {TraverseWinTree: source isn't directory} {pcOnly} {
- cleanup
- file mkdir td1
- createfile td1/tf1 tf1
- testfile cpdir td1 td2
- contents td2/tf1
-} {tf1}
-test winFCmd-7.5 {TraverseWinTree: call TraversalCopy: DOTREE_F} {pcOnly} {
- cleanup
- file mkdir td1
- createfile td1/tf1 tf1
- testfile cpdir td1 td2
- contents td2/tf1
-} {tf1}
-test winFCmd-7.6 {TraverseWinTree: call TraversalDelete: DOTREE_F} {pcOnly} {
- cleanup
- file mkdir td1
- createfile td1/tf1 tf1
- testfile rmdir -force td1
- file exists td1
-} {0}
-test winFCmd-7.7 {TraverseWinTree: append \ to source if necessary} {pcOnly} {
- cleanup
- file mkdir td1
- createfile td1/tf1 tf1
- testfile cpdir td1 td2
- contents td2/tf1
-} {tf1}
-test winFCmd-7.8 {TraverseWinTree: append \ to source if necessary} {95 cdrom} {
- list [catch {testfile rmdir $cdrom/} msg] $msg
-} "1 {$cdrom\\ EEXIST}"
-test winFCmd-7.9 {TraverseWinTree: append \ to source if necessary} {nt cdrom} {
- list [catch {testfile rmdir $cdrom/} msg] $msg
-} "1 {$cdrom\\ EACCES}"
-test winFCmd-7.10 {TraverseWinTree: can't read directory: handle == INVALID} \
- {pcOnly} {
- # can't make it happen
-} {}
-test winFCmd-7.11 {TraverseWinTree: call TraversalCopy: DOTREE_PRED} {pcOnly} {
- cleanup
- file mkdir td1
- testchmod 000 td1
- createfile td1/tf1 tf1
- testfile cpdir td1 td2
- list [file exists td2] [file writable td2]
-} {1 0}
-test winFCmd-7.12 {TraverseWinTree: call TraversalDelete: DOTREE_PRED} {pcOnly} {
- cleanup
- file mkdir td1
- createfile td1/tf1 tf1
- testfile rmdir -force td1
- file exists td1
-} {0}
-test winFCmd-7.13 {TraverseWinTree: append \ to target if necessary} {pcOnly} {
- cleanup
- file mkdir td1
- createfile td1/tf1 tf1
- testfile cpdir td1 td2
- contents td2/tf1
-} {tf1}
-test winFCmd-7.14 {TraverseWinTree: append \ to target if necessary} {95} {
- cleanup
- file mkdir td1
- list [catch {testfile cpdir td1 /} msg] $msg
-} {1 {\ EEXIST}}
-test winFCmd-7.15 {TraverseWinTree: append \ to target if necessary} {nt} {
- cleanup
- file mkdir td1
- list [catch {testfile cpdir td1 /} msg] $msg
-} {1 {\ EACCES}}
-test winFCmd-7.16 {TraverseWinTree: recurse on files: no files} {pcOnly} {
- cleanup
- file mkdir td1
- testfile cpdir td1 td2
-} {}
-test winFCmd-7.17 {TraverseWinTree: recurse on files: one file} {pcOnly} {
- cleanup
- file mkdir td1
- createfile td1/td2
- testfile cpdir td1 td2
- glob td2/*
-} {td2/td2}
-test winFCmd-7.18 {TraverseWinTree: recurse on files: several files and dir} \
- {pcOnly} {
- cleanup
- file mkdir td1
- createfile td1/tf1
- createfile td1/tf2
- file mkdir td1/td2/td3
- createfile td1/tf3
- createfile td1/tf4
- testfile cpdir td1 td2
- lsort [glob td2/*]
-} {td2/td2 td2/tf1 td2/tf2 td2/tf3 td2/tf4}
-test winFCmd-7.19 {TraverseWinTree: call TraversalCopy: DOTREE_POSTD} {pcOnly} {
- cleanup
- file mkdir td1
- testchmod 000 td1
- createfile td1/tf1 tf1
- testfile cpdir td1 td2
- list [file exists td2] [file writable td2]
-} {1 0}
-test winFCmd-7.20 {TraverseWinTree: call TraversalDelete: DOTREE_POSTD} \
- {pcOnly} {
- cleanup
- file mkdir td1
- createfile td1/tf1 tf1
- testfile rmdir -force td1
- file exists td1
-} {0}
-test winFCmd-7.21 {TraverseWinTree: fill errorPtr} {pcOnly} {
- cleanup
- list [catch {testfile cpdir td1 td2} msg] $msg
-} {1 {td1 ENOENT}}
-
-test winFCmd-8.1 {TraversalCopy: DOTREE_F} {pcOnly} {
- cleanup
- file mkdir td1
- list [catch {testfile cpdir td1 td1} msg] $msg
-} {1 {td1 EEXIST}}
-test winFCmd-8.2 {TraversalCopy: DOTREE_PRED} {pcOnly} {
- cleanup
- file mkdir td1/td2
- testchmod 000 td1
- testfile cpdir td1 td2
- list [file writable td1] [file writable td1/td2]
-} {0 1}
-test winFCmd-8.3 {TraversalCopy: DOTREE_POSTD} {pcOnly} {
- cleanup
- file mkdir td1
- testfile cpdir td1 td2
-} {}
-
-test winFCmd-9.1 {TraversalDelete: DOTREE_F} {pcOnly} {
- cleanup
- file mkdir td1
- createfile td1/tf1
- testfile rmdir -force td1
-} {}
-test winFCmd-9.2 {TraversalDelete: DOTREE_F} {95} {
- cleanup
- file mkdir td1
- set fd [open td1/tf1 w]
- set msg [list [catch {testfile rmdir -force td1} msg] $msg]
- close $fd
- set msg
-} {1 {td1\tf1 EACCES}}
-test winFCmd-9.3 {TraversalDelete: DOTREE_PRED} {pcOnly} {
- cleanup
- file mkdir td1/td2
- testchmod 000 td1
- testfile rmdir -force td1
- file exists td1
-} {0}
-test winFCmd-9.4 {TraversalDelete: DOTREE_POSTD} {pcOnly} {
- cleanup
- file mkdir td1/td1/td3/td4/td5
- testfile rmdir -force td1
-} {}
-
-test winFCmd-10.1 {AttributesPosixError - get} {pcOnly} {
- cleanup
- list [catch {file attributes td1 -archive} msg] $msg
-} {1 {could not read "td1": no such file or directory}}
-test winFCmd-10.2 {AttributesPosixError - set} {pcOnly} {
- cleanup
- list [catch {file attributes td1 -archive 0} msg] $msg
-} {1 {could not read "td1": no such file or directory}}
-
-test winFCmd-11.1 {GetWinFileAttributes} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {file attributes td1 -archive} msg] $msg [cleanup]
-} {0 1 {}}
-test winFCmd-11.2 {GetWinFileAttributes} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {file attributes td1 -readonly} msg] $msg [cleanup]
-} {0 0 {}}
-test winFCmd-11.3 {GetWinFileAttributes} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {file attributes td1 -hidden} msg] $msg [cleanup]
-} {0 0 {}}
-test winFCmd-11.4 {GetWinFileAttributes} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {file attributes td1 -system} msg] $msg [cleanup]
-} {0 0 {}}
-test winfcmd-11.5 {GetWinFileAttributes} {pcOnly} {
- # attr of relative paths that resolve to root was failing
- # don't care about answer, just that test runs.
-
- set old [pwd]
- cd c:/
- file attr c:
- file attr c:.
- file attr .
- cd $old
-} {}
-
-test winFCmd-12.1 {ConvertFileNameFormat} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {string tolower [file attributes td1 -longname]} msg] $msg [cleanup]
-} {0 td1 {}}
-test winFCmd-12.2 {ConvertFileNameFormat} {pcOnly} {
- cleanup
- file mkdir td1
- close [open td1/td1 w]
- list [catch {string tolower [file attributes td1/td1 -longname]} msg] $msg [cleanup]
-} {0 td1/td1 {}}
-test winFCmd-12.3 {ConvertFileNameFormat} {pcOnly} {
- cleanup
- file mkdir td1
- file mkdir td1/td2
- close [open td1/td3 w]
- list [catch {string tolower [file attributes td1/td2/../td3 -longname]} msg] $msg [cleanup]
-} {0 td1/td2/../td3 {}}
-test winFCmd-12.4 {ConvertFileNameFormat} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {string tolower [file attributes ./td1 -longname]} msg] $msg [cleanup]
-} {0 ./td1 {}}
-test winFCmd-12.5 {ConvertFileNameFormat: absolute path} {pcOnly} {
- list [file attributes / -longname] [file attributes \\ -longname]
-} {/ /}
-test winFCmd-12.6 {ConvertFileNameFormat: absolute path with drive} {pcOnly} {
- catch {file delete -force -- c:/td1}
- close [open c:/td1 w]
- list [catch {string tolower [file attributes c:/td1 -longname]} msg] $msg [file delete -force -- c:/td1]
-} {0 c:/td1 {}}
-test winFCmd-12.7 {ConvertFileNameFormat} {nonPortable pcOnly} {
- string tolower [file attributes //bisque/tcl/ws -longname]
-} {//bisque/tcl/ws}
-test winFCmd-12.8 {ConvertFileNameFormat} {pcOnly longFileNames} {
- cleanup
- close [open td1 w]
- list [catch {string tolower [file attributes td1 -longname]} msg] $msg [cleanup]
-} {0 td1 {}}
-test winFCmd-12.10 {ConvertFileNameFormat} {longFileNames pcOnly} {
- cleanup
- close [open td1td1td1 w]
- list [catch {file attributes td1td1td1 -shortname}] [cleanup]
-} {0 {}}
-test winFCmd-12.11 {ConvertFileNameFormat} {longFileNames pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {string tolower [file attributes td1 -shortname]} msg] $msg [cleanup]
-} {0 td1 {}}
-
-test winFCmd-13.1 {GetWinFileLongName} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {string tolower [file attributes td1 -longname]} msg] $msg [cleanup]
-} {0 td1 {}}
-
-test winFCmd-14.1 {GetWinFileShortName} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {string tolower [file attributes td1 -shortname]} msg] $msg [cleanup]
-} {0 td1 {}}
-
-test winFCmd-15.1 {SetWinFileAttributes} {pcOnly} {
- cleanup
- list [catch {file attributes td1 -archive 0} msg] $msg
-} {1 {could not read "td1": no such file or directory}}
-test winFCmd-15.2 {SetWinFileAttributes - archive} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {file attributes td1 -archive 1} msg] $msg [file attributes td1 -archive] [cleanup]
-} {0 {} 1 {}}
-test winFCmd-15.3 {SetWinFileAttributes - archive} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {file attributes td1 -archive 0} msg] $msg [file attributes td1 -archive] [cleanup]
-} {0 {} 0 {}}
-test winFCmd-15.4 {SetWinFileAttributes - hidden} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {file attributes td1 -hidden 1} msg] $msg [file attributes td1 -hidden] [file attributes td1 -hidden 0] [cleanup]
-} {0 {} 1 {} {}}
-test winFCmd-15.5 {SetWinFileAttributes - hidden} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {file attributes td1 -hidden 0} msg] $msg [file attributes td1 -hidden] [cleanup]
-} {0 {} 0 {}}
-test winFCmd-15.6 {SetWinFileAttributes - readonly} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {file attributes td1 -readonly 1} msg] $msg [file attributes td1 -readonly] [cleanup]
-} {0 {} 1 {}}
-test winFCmd-15.7 {SetWinFileAttributes - readonly} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {file attributes td1 -readonly 0} msg] $msg [file attributes td1 -readonly] [cleanup]
-} {0 {} 0 {}}
-test winFCmd-15.8 {SetWinFileAttributes - system} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {file attributes td1 -system 1} msg] $msg [file attributes td1 -system] [cleanup]
-} {0 {} 1 {}}
-test winFCmd-15.9 {SetWinFileAttributes - system} {pcOnly} {
- cleanup
- close [open td1 w]
- list [catch {file attributes td1 -system 0} msg] $msg [file attributes td1 -system] [cleanup]
-} {0 {} 0 {}}
-test winFCmd-15.10 {SetWinFileAttributes - failing} {pcOnly cdrom} {
- cleanup
- catch {file attributes $cdfile -archive 1}
-} {1}
-
-# This block of code used to occur after the "return" call, so I'm
-# commenting it out and assuming that this code is still under construction.
-#foreach source {tef ted tnf tnd "" nul com1} {
-# foreach chmodsrc {000 755} {
-# foreach dest "tfn tfe tdn tdempty tdfull td1/td2 $p $p/td1 {} nul" {
-# foreach chmoddst {000 755} {
-# puts hi
-# cleanup
-# file delete -force ted tef
-# file mkdir ted
-# createfile tef
-# createfile tfe
-# file mkdir tdempty
-# file mkdir tdfull/td1/td2
-#
-# catch {testchmod $chmodsrc $source}
-# catch {testchmod $chmoddst $dest}
-#
-# if [catch {file rename $source $dest} msg] {
-# puts "file rename $source ($chmodsrc) $dest ($chmoddst)"
-# puts $msg
-# }
-# }
-# }
-# }
-#}
-
-# cleanup
-cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/winFile.test b/tests/winFile.test
deleted file mode 100644
index 677150d..0000000
--- a/tests/winFile.test
+++ /dev/null
@@ -1,64 +0,0 @@
-# This file tests the tclWinFile.c file.
-#
-# 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) 1997 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: winFile.test,v 1.2 1999/04/16 00:47:37 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-test winFile-1.1 {TclpGetUserHome} {pcOnly} {
- list [catch {glob ~nosuchuser} msg] $msg
-} {1 {user "nosuchuser" doesn't exist}}
-test winFile-1.2 {TclpGetUserHome} {nt nonPortable} {
- # The administrator account should always exist.
-
- catch {glob ~administrator}
-} {0}
-test winFile-1.2 {TclpGetUserHome} {95} {
- # Find some user in system.ini and then see if they have a home.
-
- set f [open $::env(windir)/system.ini]
- set x 0
- while {![eof $f]} {
- set line [gets $f]
- if {$line == "\[Password Lists]"} {
- gets $f
- set name [lindex [split [gets $f] =] 0]
- if {$name != ""} {
- set x [catch {glob ~$name}]
- break
- }
- }
- }
- close $f
- set x
-} {0}
-test winFile-1.3 {TclpGetUserHome} {nt nonPortable} {
- catch {glob ~stanton@workgroup}
-} {0}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/winNotify.test b/tests/winNotify.test
deleted file mode 100644
index c8c3d9e..0000000
--- a/tests/winNotify.test
+++ /dev/null
@@ -1,173 +0,0 @@
-# This file tests the tclWinNotify.c file.
-#
-# 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) 1997 by 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: winNotify.test,v 1.3 1999/04/16 00:47:37 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-set ::tcltest::testConfig(testeventloop) \
- [expr {[info commands testeventloop] != {}}]
-
-# There is no explicit test for InitNotifier or NotifierExitHandler
-
-test winNotify-1.1 {Tcl_SetTimer: positive timeout} {pcOnly} {
- set done 0
- after 1000 { set done 1 }
- vwait done
- set done
-} 1
-test winNotify-1.2 {Tcl_SetTimer: positive timeout, message pending} {pcOnly} {
- set x 0
- set y 1
- set a1 [after 0 { incr y }]
- after cancel $a1
- after 500 { incr x }
- vwait x
- list $x $y
-} {1 1}
-test winNotify-1.3 {Tcl_SetTimer: cancelling positive timeout} {pcOnly} {
- set x 0
- set y 1
- set id [after 10000 { incr y }]
- after 0 { incr x }
- vwait x
- after cancel $id
- list $x $y
-} {1 1}
-test winNotify-1.4 {Tcl_SetTimer: null timeout, message pending} {pcOnly} {
- set x 0
- set y 1
- after 0 { incr x }
- after 0 { incr y }
- vwait x
- list $x $y
-} {1 2}
-
-test winNotify-2.1 {Tcl_ResetIdleTimer} {pcOnly} {
- set x 0
- update
- after idle { incr x }
- vwait x
- set x
-} 1
-test winNotify-2.2 {Tcl_ResetIdleTimer: message pending} {pcOnly} {
- set x 0
- set y 1
- update
- after idle { incr x }
- after idle { incr y }
- update
- list $x $y
-} {1 2}
-
-test winNotify-3.1 {NotifierProc: non-modal normal timer} {pcOnly testeventloop} {
- update
- set x 0
- foreach i [after info] {
- after cancel $i
- }
- after 500 { incr x; testeventloop done }
- testeventloop wait
- set x
-} 1
-test winNotify-3.2 {NotifierProc: non-modal normal timer, rescheduled} {pcOnly testeventloop} {
- update
- set x 0
- foreach i [after info] {
- after cancel $i
- }
- after 500 { incr x; after 100 {incr x; testeventloop done }}
- testeventloop wait
- set x
-} 2
-test winNotify-3.3 {NotifierProc: modal normal timer} {pcOnly} {
- update
- set x 0
- foreach i [after info] {
- after cancel $i
- }
- after 500 { incr x }
- vwait x
- set x
-} 1
-test winNotify-3.4 {NotifierProc: modal normal timer, rescheduled} {pcOnly} {
- update
- set x 0
- foreach i [after info] {
- after cancel $i
- }
- set y 0
- after 500 { incr y; after 100 {incr x}}
- vwait x
- list $x $y
-} {1 1}
-test winNotify-3.5 {NotifierProc: non-modal idle timer} {pcOnly testeventloop} {
- update
- set x 0
- foreach i [after info] {
- after cancel $i
- }
- after idle { incr x; testeventloop done }
- testeventloop wait
- set x
-} 1
-test winNotify-3.6 {NotifierProc: non-modal idle timer, rescheduled} {pcOnly testeventloop} {
- update
- set x 0
- foreach i [after info] {
- after cancel $i
- }
- after idle { incr x; after idle {incr x; testeventloop done }}
- testeventloop wait
- set x
-} 2
-test winNotify-3.7 {NotifierProc: modal idle timer} {pcOnly} {
- update
- set x 0
- foreach i [after info] {
- after cancel $i
- }
- after idle { incr x }
- vwait x
- set x
-} 1
-test winNotify-3.8 {NotifierProc: modal idle timer, rescheduled} {pcOnly} {
- update
- set x 0
- foreach i [after info] {
- after cancel $i
- }
- set y 0
- after idle { incr y; after idle {incr x}}
- vwait x
- list $x $y
-} {1 1}
-
-# Tcl_DoOneEvent is tested by the timer.test, io.test, and event.test files
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/winPipe.test b/tests/winPipe.test
deleted file mode 100644
index 2d23544..0000000
--- a/tests/winPipe.test
+++ /dev/null
@@ -1,413 +0,0 @@
-#
-# winPipe.test --
-#
-# This file contains a collection of tests for tclWinPipe.c
-#
-# Sourcing this file into Tcl runs the tests and generates output for
-# errors. No output means no errors were found.
-#
-# Copyright (c) 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: winPipe.test,v 1.6 1999/04/16 00:47:37 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-set bindir [file join [pwd] [file dirname [info nameofexecutable]]]
-set cat16 [file join $bindir cat16.exe]
-set cat32 [file join $bindir cat32.exe]
-
-set ::tcltest::testConfig(cat32) [file exists $cat32]
-set ::tcltest::testConfig(cat16) [file exists $cat16]
-
-if {[catch {puts console1 ""}]} {
- set ::tcltest::testConfig(AllocConsole) 1
-} else {
- set ::tcltest::testConfig(.console) 1
-}
-
-set big bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n
-append big $big
-append big $big
-append big $big
-append big $big
-append big $big
-append big $big
-
-set f [open "little" w]
-puts -nonewline $f "little"
-close $f
-
-set f [open "big" w]
-puts -nonewline $f $big
-close $f
-
-proc contents {file} {
- set f [open $file r]
- set r [read $f]
- close $f
- set r
-}
-
-set f [open more w]
-puts $f {
- while {[eof stdin] == 0} {
- puts -nonewline [read stdin]
- }
-}
-close $f
-
-test winpipe-1.1 {32 bit comprehensive tests: from little file} {pcOnly stdio cat32} {
- exec $cat32 < little > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} {little stderr32}
-test winpipe-1.2 {32 bit comprehensive tests: from big file} {pcOnly stdio cat32} {
- exec $cat32 < big > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} "{$big} stderr32"
-test winpipe-1.3 {32 bit comprehensive tests: a little from pipe} {nt stdio cat32} {
- exec $tcltest more < little | $cat32 > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} {little stderr32}
-test winpipe-1.4 {32 bit comprehensive tests: a lot from pipe} {nt stdio cat32} {
- exec $tcltest more < big | $cat32 > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} "{$big} stderr32"
-test winpipe-1.5 {32 bit comprehensive tests: a lot from pipe} {95 stdio cat32} {
- exec command /c type big |& $cat32 > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} "{$big} stderr32"
-test winpipe-1.6 {32 bit comprehensive tests: from console} \
- {pcOnly stdio cat32 AllocConsole} {
- # would block waiting for human input
-} {}
-test winpipe-1.7 {32 bit comprehensive tests: from NUL} {pcOnly stdio cat32} {
- exec $cat32 < nul > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} {{} stderr32}
-test winpipe-1.8 {32 bit comprehensive tests: from socket} {pcOnly stdio cat32} {
- # doesn't work
-} {}
-test winpipe-1.9 {32 bit comprehensive tests: from nowhere} \
- {pcOnly stdio cat32 .console} {
- exec $cat32 > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} {{} stderr32}
-test winpipe-1.10 {32 bit comprehensive tests: from file handle} \
- {pcOnly stdio cat32} {
- set f [open "little" r]
- exec $cat32 <@$f > stdout 2> stderr
- close $f
- list [contents stdout] [contents stderr]
-} {little stderr32}
-test winpipe-1.11 {32 bit comprehensive tests: read from application} \
- {pcOnly stdio cat32} {
- set f [open "|$cat32 < little" r]
- gets $f line
- catch {close $f} msg
- list $line $msg
-} {little stderr32}
-test winpipe-1.12 {32 bit comprehensive tests: a little to file} \
- {pcOnly stdio cat32} {
- exec $cat32 < little > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} {little stderr32}
-test winpipe-1.13 {32 bit comprehensive tests: a lot to file} \
- {pcOnly stdio cat32} {
- exec $cat32 < big > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} "{$big} stderr32"
-test winpipe-1.14 {32 bit comprehensive tests: a little to pipe} \
- {pcOnly stdio cat32} {
- exec $cat32 < little | $tcltest more > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} {little stderr32}
-test winpipe-1.15 {32 bit comprehensive tests: a lot to pipe} \
- {pcOnly stdio cat32} {
- exec $cat32 < big | $tcltest more > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} "{$big} stderr32"
-test winpipe-1.16 {32 bit comprehensive tests: to console} {pcOnly stdio cat32} {
- catch {exec $cat32 << "You should see this\n" >@stdout} msg
- set msg
-} stderr32
-test winpipe-1.17 {32 bit comprehensive tests: to NUL} {pcOnly stdio cat32} {
- # some apps hang when sending a large amount to NUL. $cat32 isn't one.
- catch {exec $cat32 < big > nul} msg
- set msg
-} stderr32
-test winpipe-1.18 {32 bit comprehensive tests: to nowhere} \
- {pcOnly stdio cat32 .console} {
- exec $cat32 < big >&@stdout
-} {}
-test winpipe-1.19 {32 bit comprehensive tests: to file handle} {pcOnly stdio cat32} {
- set f1 [open "stdout" w]
- set f2 [open "stderr" w]
- exec $cat32 < little >@$f1 2>@$f2
- close $f1
- close $f2
- list [contents stdout] [contents stderr]
-} {little stderr32}
-test winpipe-1.20 {32 bit comprehensive tests: write to application} \
- {pcOnly stdio cat32} {
- set f [open "|$cat32 > stdout" w]
- puts -nonewline $f "foo"
- catch {close $f} msg
- list [contents stdout] $msg
-} {foo stderr32}
-test winpipe-1.21 {32 bit comprehensive tests: read/write application} \
- {pcOnly stdio cat32} {
- set f [open "|$cat32" r+]
- puts $f $big
- puts $f \032
- flush $f
- set r [read $f 64]
- catch {close $f}
- set r
-} "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-
-
-test winpipe-2.1 {16 bit comprehensive tests: from little file} {pcOnly stdio cat16} {
- exec $cat16 < little > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} "little stderr16"
-test winpipe-2.2 {16 bit comprehensive tests: from big file} {pcOnly stdio cat16} {
- exec $cat16 < big > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} "{$big} stderr16"
-test winpipe-2.3 {16 bit comprehensive tests: a little from pipe} {pcOnly stdio cat16} {
- exec $tcltest more < little | $cat16 > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} {little stderr16}
-test winpipe-2.4 {16 bit comprehensive tests: a lot from pipe} {nt stdio cat16} {
- exec $cat16 < big | $cat16 > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} "{$big} stderr16stderr16"
-test winpipe-2.5 {16 bit comprehensive tests: a lot from pipe} {95 stdio cat16} {
- exec $tcltest more < big | $cat16 > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} "{$big} stderr16"
-test winpipe-2.6 {16 bit comprehensive tests: from console} \
- {pcOnly stdio cat16 AllocConsole} {
- # would block waiting for human input
-} {}
-test winpipe-2.7 {16 bit comprehensive tests: from NUL} {nt stdio cat16} {
- exec $cat16 < nul > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} "{} stderr16"
-test winpipe-2.8 {16 bit comprehensive tests: from socket} {pcOnly stdio cat16} {
- # doesn't work
-} {}
-test winpipe-2.9 {16 bit comprehensive tests: from nowhere} {pcOnly stdio cat16 .console} {
- exec $cat16 > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} "{} stderr16"
-test winpipe-2.10 {16 bit comprehensive tests: from file handle} {pcOnly stdio cat16} {
- set f [open "little" r]
- exec $cat16 <@$f > stdout 2> stderr
- close $f
- list [contents stdout] [contents stderr]
-} "little stderr16"
-test winpipe-2.11 {16 bit comprehensive tests: read from application} {pcOnly stdio cat16} {
- set f [open "|$cat16 < little" r]
- gets $f line
- catch {close $f} msg
- list $line $msg
-} "little stderr16"
-test winpipe-2.12 {16 bit comprehensive tests: a little to file} {pcOnly stdio cat16} {
- exec $cat16 < little > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} "little stderr16"
-test winpipe-2.13 {16 bit comprehensive tests: a lot to file} {pcOnly stdio cat16} {
- exec $cat16 < big > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} "{$big} stderr16"
-test winpipe-2.14 {16 bit comprehensive tests: a little to pipe} {pcOnly stdio cat16} {
- exec $cat16 < little | $tcltest more > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} {little stderr16}
-test winpipe-2.15 {16 bit comprehensive tests: a lot to pipe} {pcOnly stdio cat16} {
- exec $cat16 < big | $tcltest more > stdout 2> stderr
- list [contents stdout] [contents stderr]
-} "{$big} stderr16"
-test winpipe-2.16 {16 bit comprehensive tests: to console} {pcOnly stdio cat16} {
- catch {exec $cat16 << "You should see this\n" >@stdout} msg
- set msg
-} [lindex stderr16 0]
-test winpipe-2.17 {16 bit comprehensive tests: to NUL} {nt stdio cat16} {
- # some apps hang when sending a large amount to NUL. cat16 isn't one.
- catch {exec $cat16 < big > nul} msg
- set msg
-} stderr16
-test winpipe-2.18 {16 bit comprehensive tests: to nowhere} {pcOnly stdio cat16 .console} {
- exec $cat16 < big >&@stdout
-} {}
-test winpipe-2.19 {16 bit comprehensive tests: to file handle} {pcOnly stdio cat16} {
- set f1 [open "stdout" w]
- set f2 [open "stderr" w]
- exec $cat16 < little >@$f1 2>@$f2
- close $f1
- close $f2
- list [contents stdout] [contents stderr]
-} "little stderr16"
-test winpipe-2.20 {16 bit comprehensive tests: write to application} {pcOnly stdio cat16} {
- set f [open "|$cat16 > stdout" w]
- puts -nonewline $f "foo"
- catch {close $f} msg
- list [contents stdout] $msg
-} "foo stderr16"
-test winpipe-2.21 {16 bit comprehensive tests: read/write application} {nt stdio cat16} {
- set f [open "|$cat16" r+]
- puts $f $big
- puts $f \032
- flush $f
- set r [read $f 64]
- catch {close $f}
- set r
-} "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
-file delete more
-
-test winpipe-4.1 {Tcl_WaitPid} {nt stdio} {
- proc readResults {f} {
- global x result
- if { [eof $f] } {
- close $f
- set x 1
- } else {
- set line [read $f ]
- set result "$result$line"
- }
- }
-
- set f [open "|$cat32 < big 2> stderr" r]
- fconfigure $f -buffering none -blocking 0
- fileevent $f readable "readResults $f"
- set x 0
- set result ""
- vwait x
- list $result $x [contents stderr]
-} "{$big} 1 stderr32"
-
-close [open nothing w]
-
-catch {set env_tmp $env(TMP)}
-catch {set env_temp $env(TEMP)}
-
-set env(TMP) c:/
-set env(TEMP) c:/
-
-test winpipe-4.1 {TclpCreateTempFile: cleanup temp files} {pcOnly stdio} {
- set x {}
- set existing [glob -nocomplain c:/tcl*.tmp]
- exec $tcltest < nothing
- foreach p [glob -nocomplain c:/tcl*.tmp] {
- if {[lsearch $existing $p] == -1} {
- lappend x $p
- }
- }
- set x
-} {}
-test winpipe-4.2 {TclpCreateTempFile: TMP and TEMP not defined} {pcOnly stdio} {
- set tmp $env(TMP)
- set temp $env(TEMP)
- unset env(TMP)
- unset env(TEMP)
- exec $tcltest < nothing
- set env(TMP) $tmp
- set env(TEMP) $temp
- set x {}
-} {}
-test winpipe-4.3 {TclpCreateTempFile: TMP specifies non-existent directory} \
- {pcOnly stdio} {
- set tmp $env(TMP)
- set env(TMP) snarky
- exec $tcltest < nothing
- set env(TMP) $tmp
- set x {}
-} {}
-test winpipe-4.4 {TclpCreateTempFile: TEMP specifies non-existent directory} \
- {pcOnly stdio} {
- set tmp $env(TMP)
- set temp $env(TEMP)
- unset env(TMP)
- set env(TEMP) snarky
- exec $tcltest < nothing
- set env(TMP) $tmp
- set env(TEMP) $temp
- set x {}
-} {}
-
-test winpipe-5.1 {PipeSetupProc & PipeCheckProc: read threads} \
- {pcOnly stdio cat32} {
- set f [open "|$cat32" r+]
- fconfigure $f -blocking 0
- fileevent $f writable { set x writable }
- set x {}
- vwait x
- fileevent $f writable {}
- fileevent $f readable { lappend x readable }
- after 100 { lappend x timeout }
- vwait x
- puts $f foobar
- flush $f
- vwait x
- lappend x [read $f]
- after 100 { lappend x timeout }
- vwait x
- lappend x [catch {close $f} msg] $msg
-} {writable timeout readable {foobar
-} timeout 1 stderr32}
-test winpipe-5.2 {PipeSetupProc & PipeCheckProc: write threads} \
- {pcOnly stdio cat32} {
- set f [open "|$cat32" r+]
- fconfigure $f -blocking 0
- fileevent $f writable { set x writable }
- set x {}
- vwait x
- puts -nonewline $f $big$big$big$big
- flush $f
- after 100 { lappend x timeout }
- vwait x
- lappend x [catch {close $f} msg] $msg
-} {writable timeout 0 {}}
-
-makeFile {
- puts "[list $argv0 $argv]"
-} echoArgs.tcl
-
-test winpipe-4.1 {BuildCommandLine: null arguments} {pcOnly stdio} {
- exec $tcltest echoArgs.tcl foo "" bar
-} {echoArgs.tcl {foo {} bar}}
-test winpipe-4.1 {BuildCommandLine: null arguments} {pcOnly stdio} {
- exec $tcltest echoArgs.tcl foo \" bar
-} {echoArgs.tcl {foo {"} bar}}
-
-# restore old values for env(TMP) and env(TEMP)
-
-if {[catch {set env(TMP) $env_tmp}]} {
- unset env(TMP)
-}
-if {[catch {set env(TEMP) $env_temp}]} {
- unset env(TEMP)
-}
-
-# cleanup
-file delete big little stdout stderr nothing echoArgs.tcl
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/winTime.test b/tests/winTime.test
deleted file mode 100644
index 417f4bc..0000000
--- a/tests/winTime.test
+++ /dev/null
@@ -1,49 +0,0 @@
-# This file tests the tclWinTime.c file.
-#
-# 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) 1997 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: winTime.test,v 1.2 1999/04/16 00:47:37 stanton Exp $
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- source [file join [pwd] [file dirname [info script]] defs.tcl]
-}
-
-# The next two tests will crash on Windows if the check for negative
-# clock values is not done properly.
-
-test winTime-1.1 {TclpGetDate} {pcOnly} {
- set ::env(TZ) JST-9
- set result [clock format -1 -format %Y]
- unset ::env(TZ)
- set result
-} {1970}
-test winTime-1.2 {TclpGetDate} {pcOnly} {
- set ::env(TZ) PST8
- set result [clock format 1 -format %Y]
- unset ::env(TZ)
- set result
-} {1969}
-
-# cleanup
-::tcltest::cleanupTests
-return
-
-
-
-
-
-
-
-
-
-
-
-