1 | # Commands covered: concat |
---|
2 | # |
---|
3 | # This file contains a collection of tests for one or more of the Tcl |
---|
4 | # built-in commands. Sourcing this file into Tcl runs the tests and |
---|
5 | # generates output 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 |
---|
12 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
13 | # |
---|
14 | # RCS: @(#) $Id: concat.test,v 1.6 2004/05/19 10:55:05 dkf Exp $ |
---|
15 | |
---|
16 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
17 | package require tcltest |
---|
18 | namespace import -force ::tcltest::* |
---|
19 | } |
---|
20 | |
---|
21 | test concat-1.1 {simple concatenation} { |
---|
22 | concat a b c d e f g |
---|
23 | } {a b c d e f g} |
---|
24 | test concat-1.2 {merging lists together} { |
---|
25 | concat a {b c d} {e f g h} |
---|
26 | } {a b c d e f g h} |
---|
27 | test concat-1.3 {merge lists, retain sub-lists} { |
---|
28 | concat a {b {c d}} {{e f}} g h |
---|
29 | } {a b {c d} {e f} g h} |
---|
30 | test concat-1.4 {special characters} { |
---|
31 | concat a\{ {b \{c d} \{d |
---|
32 | } "a{ b \\{c d {d" |
---|
33 | |
---|
34 | test concat-2.1 {error: one empty argument} { |
---|
35 | concat {} |
---|
36 | } {} |
---|
37 | |
---|
38 | test concat-3.1 {error: no arguments} { |
---|
39 | list [catch concat msg] $msg |
---|
40 | } {0 {}} |
---|
41 | |
---|
42 | test concat-4.1 {pruning off extra white space} { |
---|
43 | concat {} {a b c} |
---|
44 | } {a b c} |
---|
45 | test concat-4.2 {pruning off extra white space} { |
---|
46 | concat x y " a b c \n\t " " " " def " |
---|
47 | } {x y a b c def} |
---|
48 | test concat-4.3 {pruning off extra white space sets length correctly} { |
---|
49 | llength [concat { {{a}} }] |
---|
50 | } 1 |
---|
51 | |
---|
52 | # cleanup |
---|
53 | ::tcltest::cleanupTests |
---|
54 | return |
---|