1 |
578 |
markom |
# Commands covered: lrange
|
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 |
|
|
#
|
10 |
|
|
# See the file "license.terms" for information on usage and redistribution
|
11 |
|
|
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
12 |
|
|
#
|
13 |
|
|
# RCS: @(#) $Id: lrange.test,v 1.1.1.1 2002-01-16 10:25:36 markom Exp $
|
14 |
|
|
|
15 |
|
|
if {[string compare test [info procs test]] == 1} then {source defs}
|
16 |
|
|
|
17 |
|
|
test lrange-1.1 {range of list elements} {
|
18 |
|
|
lrange {a b c d} 1 2
|
19 |
|
|
} {b c}
|
20 |
|
|
test lrange-1.2 {range of list elements} {
|
21 |
|
|
lrange {a {bcd e {f g {}}} l14 l15 d} 1 1
|
22 |
|
|
} {{bcd e {f g {}}}}
|
23 |
|
|
test lrange-1.3 {range of list elements} {
|
24 |
|
|
lrange {a {bcd e {f g {}}} l14 l15 d} 3 end
|
25 |
|
|
} {l15 d}
|
26 |
|
|
test lrange-1.4 {range of list elements} {
|
27 |
|
|
lrange {a {bcd e {f g {}}} l14 l15 d} 4 10000
|
28 |
|
|
} {d}
|
29 |
|
|
test lrange-1.5 {range of list elements} {
|
30 |
|
|
lrange {a {bcd e {f g {}}} l14 l15 d} 4 3
|
31 |
|
|
} {}
|
32 |
|
|
test lrange-1.6 {range of list elements} {
|
33 |
|
|
lrange {a {bcd e {f g {}}} l14 l15 d} 10 11
|
34 |
|
|
} {}
|
35 |
|
|
test lrange-1.7 {range of list elements} {
|
36 |
|
|
lrange {a b c d e} -1 2
|
37 |
|
|
} {a b c}
|
38 |
|
|
test lrange-1.8 {range of list elements} {
|
39 |
|
|
lrange {a b c d e} -2 -1
|
40 |
|
|
} {}
|
41 |
|
|
test lrange-1.9 {range of list elements} {
|
42 |
|
|
lrange {a b c d e} -2 e
|
43 |
|
|
} {a b c d e}
|
44 |
|
|
test lrange-1.10 {range of list elements} {
|
45 |
|
|
lrange "a b\{c d" 1 2
|
46 |
|
|
} "b\\{c d"
|
47 |
|
|
test lrange-1.11 {range of list elements} {
|
48 |
|
|
lrange "a b c d" end end
|
49 |
|
|
} d
|
50 |
|
|
test lrange-1.12 {range of list elements} {
|
51 |
|
|
lrange "a b c d" end 100000
|
52 |
|
|
} d
|
53 |
|
|
test lrange-1.13 {range of list elements} {
|
54 |
|
|
lrange "a b c d" e 3
|
55 |
|
|
} d
|
56 |
|
|
test lrange-1.14 {range of list elements} {
|
57 |
|
|
lrange "a b c d" end 2
|
58 |
|
|
} {}
|
59 |
|
|
test lrange-1.15 {range of list elements} {
|
60 |
|
|
concat \"[lrange {a b \{\ } 0 2]"
|
61 |
|
|
} {"a b \{\ "}
|
62 |
|
|
test lrange-1.16 {list element quoting} {
|
63 |
|
|
lrange {[append a .b]} 0 end
|
64 |
|
|
} {{[append} a .b\]}
|
65 |
|
|
|
66 |
|
|
test lrange-2.1 {error conditions} {
|
67 |
|
|
list [catch {lrange a b} msg] $msg
|
68 |
|
|
} {1 {wrong # args: should be "lrange list first last"}}
|
69 |
|
|
test lrange-2.2 {error conditions} {
|
70 |
|
|
list [catch {lrange a b 6 7} msg] $msg
|
71 |
|
|
} {1 {wrong # args: should be "lrange list first last"}}
|
72 |
|
|
test lrange-2.3 {error conditions} {
|
73 |
|
|
list [catch {lrange a b 6} msg] $msg
|
74 |
|
|
} {1 {bad index "b": must be integer or "end"}}
|
75 |
|
|
test lrange-2.4 {error conditions} {
|
76 |
|
|
list [catch {lrange a 0 enigma} msg] $msg
|
77 |
|
|
} {1 {bad index "enigma": must be integer or "end"}}
|
78 |
|
|
test lrange-2.5 {error conditions} {
|
79 |
|
|
list [catch {lrange "a \{b c" 3 4} msg] $msg
|
80 |
|
|
} {1 {unmatched open brace in list}}
|
81 |
|
|
test lrange-2.6 {error conditions} {
|
82 |
|
|
list [catch {lrange "a b c \{ d e" 1 4} msg] $msg
|
83 |
|
|
} {1 {unmatched open brace in list}}
|