| 1 |
# Commands covered: concat |
| 2 |
# |
| 3 |
# This file contains a collection of tests for one or more of the Tcl built-in |
| 4 |
# commands. Sourcing this file into Tcl runs the tests and generates output |
| 5 |
# for errors. No output means no errors were found. |
| 6 |
# |
| 7 |
# Copyright (c) 1991-1993 The Regents of the University of California. |
| 8 |
# Copyright (c) 1994-1996 Sun Microsystems, Inc. |
| 9 |
# Copyright (c) 1998-1999 by Scriptics Corporation. |
| 10 |
# |
| 11 |
# See the file "license.terms" for information on usage and redistribution of |
| 12 |
# this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 13 |
|
| 14 |
if {"::tcltest" ni [namespace children]} { |
| 15 |
package require tcltest 2.5 |
| 16 |
namespace import -force ::tcltest::* |
| 17 |
} |
| 18 |
|
| 19 |
test concat-1.1 {simple concatenation} { |
| 20 |
concat a b c d e f g |
| 21 |
} {a b c d e f g} |
| 22 |
test concat-1.2 {merging lists together} { |
| 23 |
concat a {b c d} {e f g h} |
| 24 |
} {a b c d e f g h} |
| 25 |
test concat-1.3 {merge lists, retain sub-lists} { |
| 26 |
concat a {b {c d}} {{e f}} g h |
| 27 |
} {a b {c d} {e f} g h} |
| 28 |
test concat-1.4 {special characters} { |
| 29 |
concat a\{ {b \{c d} \{d |
| 30 |
} "a{ b \\{c d {d" |
| 31 |
|
| 32 |
test concat-2.1 {error: one empty argument} { |
| 33 |
concat {} |
| 34 |
} {} |
| 35 |
|
| 36 |
test concat-3.1 {error: no arguments} { |
| 37 |
list [catch concat msg] $msg |
| 38 |
} {0 {}} |
| 39 |
|
| 40 |
test concat-4.1 {pruning off extra white space} { |
| 41 |
concat {} {a b c} |
| 42 |
} {a b c} |
| 43 |
test concat-4.2 {pruning off extra white space} { |
| 44 |
concat x y " a b c \n\t " " " " def " |
| 45 |
} {x y a b c def} |
| 46 |
test concat-4.3 {pruning off extra white space sets length correctly} { |
| 47 |
llength [concat { {{a}} }] |
| 48 |
} 1 |
| 49 |
|
| 50 |
# cleanup |
| 51 |
::tcltest::cleanupTests |
| 52 |
return |
| 53 |
|
| 54 |
# Local Variables: |
| 55 |
# mode: tcl |
| 56 |
# fill-column: 78 |
| 57 |
# End: |