Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/tests/for-old.test @ 25

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

added tcl to libs

File size: 2.0 KB
Line 
1# Commands covered:  for, continue, break
2#
3# This file contains the original set of tests for Tcl's for command.
4# Since the for command is now compiled, a new set of tests covering
5# the new implementation is in the file "for.test". Sourcing this file
6# into Tcl runs the tests and generates output for errors.
7# No output means no errors were found.
8#
9# Copyright (c) 1991-1993 The Regents of the University of California.
10# Copyright (c) 1994-1996 Sun Microsystems, Inc.
11#
12# See the file "license.terms" for information on usage and redistribution
13# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14#
15# RCS: @(#) $Id: for-old.test,v 1.6 2004/05/19 12:25:30 dkf Exp $
16
17if {[lsearch [namespace children] ::tcltest] == -1} {
18    package require tcltest
19    namespace import -force ::tcltest::*
20}
21
22# Check "for" and its use of continue and break.
23
24catch {unset a i}
25test for-old-1.1 {for tests} {
26    set a {}
27    for {set i 1} {$i<6} {set i [expr $i+1]} {
28        set a [concat $a $i]
29    }
30    set a
31} {1 2 3 4 5}
32test for-old-1.2 {for tests} {
33    set a {}
34    for {set i 1} {$i<6} {set i [expr $i+1]} {
35        if $i==4 continue
36        set a [concat $a $i]
37    }
38    set a
39} {1 2 3 5}
40test for-old-1.3 {for tests} {
41    set a {}
42    for {set i 1} {$i<6} {set i [expr $i+1]} {
43        if $i==4 break
44        set a [concat $a $i]
45    }
46    set a
47} {1 2 3}
48test for-old-1.4 {for tests} {catch {for 1 2 3} msg} 1
49test for-old-1.5 {for tests} {
50    catch {for 1 2 3} msg
51    set msg
52} {wrong # args: should be "for start test next command"}
53test for-old-1.6 {for tests} {catch {for 1 2 3 4 5} msg} 1
54test for-old-1.7 {for tests} {
55    catch {for 1 2 3 4 5} msg
56    set msg
57} {wrong # args: should be "for start test next command"}
58test for-old-1.8 {for tests} {
59    set a {xyz}
60    for {set i 1} {$i<6} {set i [expr $i+1]} {}
61    set a
62} xyz
63test for-old-1.9 {for tests} {
64    set a {}
65    for {set i 1} {$i<6} {set i [expr $i+1]; if $i==4 break} {
66        set a [concat $a $i]
67    }
68    set a
69} {1 2 3}
70
71# cleanup
72::tcltest::cleanupTests
73return
Note: See TracBrowser for help on using the repository browser.