1# Commands covered:  join
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 © 1991-1993 The Regents of the University of California.
8# Copyright © 1994 Sun Microsystems, Inc.
9# Copyright © 1998-1999 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
14if {"::tcltest" ni [namespace children]} {
15    package require tcltest 2.5
16    namespace import -force ::tcltest::*
17}
18
19test join-1.1 {basic join commands} {
20    join {a b c} xyz
21} axyzbxyzc
22test join-1.2 {basic join commands} {
23    join {a b c} {}
24} abc
25test join-1.3 {basic join commands} {
26    join {} xyz
27} {}
28test join-1.4 {basic join commands} {
29    join {12 34 56}
30} {12 34 56}
31
32test join-2.1 {join errors} {
33    list [catch join msg] $msg $errorCode
34} {1 {wrong # args: should be "join list ?joinString?"} {TCL WRONGARGS}}
35test join-2.2 {join errors} {
36    list [catch {join a b c} msg] $msg $errorCode
37} {1 {wrong # args: should be "join list ?joinString?"} {TCL WRONGARGS}}
38test join-2.3 {join errors} {
39    list [catch {join "a \{ c" 111} msg] $msg $errorCode
40} {1 {unmatched open brace in list} {TCL VALUE LIST BRACE}}
41
42test join-3.1 {joinString is binary ok} {
43  string length [join {a b c} a\0b]
44} 9
45test join-3.2 {join is binary ok} {
46  string length [join "a\0b a\0b a\0b"]
47} 11
48
49test join-4.1 {shimmer segfault prevention} {
50    set l {0 0}
51    join $l $l
52} {00 00}
53
54# cleanup
55::tcltest::cleanupTests
56return
57
58# Local Variables:
59# mode: tcl
60# End:
61