88 lines
3.7 KiB
Plaintext
88 lines
3.7 KiB
Plaintext
|
# 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.
|
||
|
# All rights reserved.
|
||
|
#
|
||
|
# Permission is hereby granted, without written agreement and without
|
||
|
# license or royalty fees, to use, copy, modify, and distribute this
|
||
|
# software and its documentation for any purpose, provided that the
|
||
|
# above copyright notice and the following two paragraphs appear in
|
||
|
# all copies of this software.
|
||
|
#
|
||
|
# IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
|
||
|
# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
|
||
|
# OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
|
||
|
# CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
|
#
|
||
|
# THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
||
|
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||
|
# AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||
|
# ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
|
||
|
# PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||
|
#
|
||
|
# $Header: /user6/ouster/tcl/tests/RCS/list.test,v 1.18 93/10/28 16:14:10 ouster Exp $ (Berkeley)
|
||
|
|
||
|
if {[string compare test [info procs test]] == 1} then {source defs}
|
||
|
|
||
|
# 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.
|
||
|
|
||
|
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 {}
|