Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/tests/lrepeat.test @ 25

Last change on this file since 25 was 25, checked in by landauf, 16 years ago

added tcl to libs

File size: 1.9 KB
Line 
1# Commands covered:  lrepeat
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) 2003 by Simon Geard.
8#
9# See the file "license.terms" for information on usage and redistribution
10# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11#
12# RCS: @(#) $Id: lrepeat.test,v 1.2 2003/10/06 14:32:22 dgp Exp $
13
14if {[lsearch [namespace children] ::tcltest] == -1} {
15    package require tcltest 2
16    namespace import -force ::tcltest::*
17}
18
19## Arg errors
20test lrepeat-1.1 {error cases} {
21    -body {
22        lrepeat
23    }
24    -returnCodes 1
25    -result {wrong # args: should be "lrepeat positiveCount value ?value ...?"}
26}
27test lrepeat-1.2 {error cases} {
28    -body {
29        lrepeat 1
30    }
31    -returnCodes 1
32    -result {wrong # args: should be "lrepeat positiveCount value ?value ...?"}
33}
34test lrepeat-1.3 {error cases} {
35    -body {
36        lrepeat a 1
37    }
38    -returnCodes 1
39    -result {expected integer but got "a"}
40}
41test lrepeat-1.4 {error cases} {
42    -body {
43        lrepeat -3 1
44    }
45    -returnCodes 1
46    -result {must have a count of at least 1}
47}
48test lrepeat-1.5 {error cases} {
49    -body {
50        lrepeat 0
51    }
52    -returnCodes 1
53    -result {wrong # args: should be "lrepeat positiveCount value ?value ...?"}
54}
55test lrepeat-1.6 {error cases} {
56    -body {
57        lrepeat 3.5 1
58    }
59    -returnCodes 1
60    -result {expected integer but got "3.5"}
61}
62
63## Okay
64test lrepeat-2.1 {normal cases} {
65    lrepeat 10 a
66} {a a a a a a a a a a}
67test lrepeat-2.2 {normal cases} {
68    lrepeat 3 [lrepeat 3 0]
69} {{0 0 0} {0 0 0} {0 0 0}}
70test lrepeat-2.3 {normal cases} {
71    lrepeat 3 a b c
72} {a b c a b c a b c}
73test lrepeat-2.4 {normal cases} {
74    lrepeat 3 [lrepeat 2 a] b c
75} {{a a} b c {a a} b c {a a} b c}
76
77# cleanup
78::tcltest::cleanupTests
79return
Note: See TracBrowser for help on using the repository browser.