OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tcl8.6.12 / tests / llength.test
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 if {"::tcltest" ni [namespace children]} {
15     package require tcltest 2.5
16     namespace import -force ::tcltest::*
17 }
18
19 test llength-1.1 {length of list} {
20     llength {a b c d}
21 } 4
22 test llength-1.2 {length of list} {
23     llength {a b c {a b {c d}} d}
24 } 5
25 test llength-1.3 {length of list} {
26     llength {}
27 } 0
28
29 test llength-2.1 {error conditions} {
30     list [catch {llength} msg] $msg
31 } {1 {wrong # args: should be "llength list"}}
32 test llength-2.2 {error conditions} {
33     list [catch {llength 123 2} msg] $msg
34 } {1 {wrong # args: should be "llength list"}}
35 test llength-2.3 {error conditions} {
36     list [catch {llength "a b c \{"} msg] $msg
37 } {1 {unmatched open brace in list}}
38
39 # cleanup
40 ::tcltest::cleanupTests
41 return