[25] | 1 | # Commands covered: llength |
---|
| 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 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: llength.test,v 1.6 2004/05/19 12:23:58 dkf Exp $ |
---|
| 15 | |
---|
| 16 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
| 17 | package require tcltest |
---|
| 18 | namespace import -force ::tcltest::* |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | test llength-1.1 {length of list} { |
---|
| 22 | llength {a b c d} |
---|
| 23 | } 4 |
---|
| 24 | test llength-1.2 {length of list} { |
---|
| 25 | llength {a b c {a b {c d}} d} |
---|
| 26 | } 5 |
---|
| 27 | test llength-1.3 {length of list} { |
---|
| 28 | llength {} |
---|
| 29 | } 0 |
---|
| 30 | |
---|
| 31 | test llength-2.1 {error conditions} { |
---|
| 32 | list [catch {llength} msg] $msg |
---|
| 33 | } {1 {wrong # args: should be "llength list"}} |
---|
| 34 | test llength-2.2 {error conditions} { |
---|
| 35 | list [catch {llength 123 2} msg] $msg |
---|
| 36 | } {1 {wrong # args: should be "llength list"}} |
---|
| 37 | test llength-2.3 {error conditions} { |
---|
| 38 | list [catch {llength "a b c \{"} msg] $msg |
---|
| 39 | } {1 {unmatched open brace in list}} |
---|
| 40 | |
---|
| 41 | # cleanup |
---|
| 42 | ::tcltest::cleanupTests |
---|
| 43 | return |
---|