home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tcl8.0 / tests / for-old.test < prev    next >
Encoding:
Text File  |  1997-08-15  |  1.8 KB  |  67 lines  |  [TEXT/ALFA]

  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. # SCCS: @(#) for-old.test 1.14 97/01/13 13:42:18
  16.  
  17. if {[string compare test [info procs test]] == 1} then {source defs}
  18.  
  19. # Check "for" and its use of continue and break.
  20.  
  21. catch {unset a i}
  22. test for-old-1.1 {for tests} {
  23.     set a {}
  24.     for {set i 1} {$i<6} {set i [expr $i+1]} {
  25.     set a [concat $a $i]
  26.     }
  27.     set a
  28. } {1 2 3 4 5}
  29. test for-old-1.2 {for tests} {
  30.     set a {}
  31.     for {set i 1} {$i<6} {set i [expr $i+1]} {
  32.     if $i==4 continue
  33.     set a [concat $a $i]
  34.     }
  35.     set a
  36. } {1 2 3 5}
  37. test for-old-1.3 {for tests} {
  38.     set a {}
  39.     for {set i 1} {$i<6} {set i [expr $i+1]} {
  40.     if $i==4 break
  41.     set a [concat $a $i]
  42.     }
  43.     set a
  44. } {1 2 3}
  45. test for-old-1.4 {for tests} {catch {for 1 2 3} msg} 1
  46. test for-old-1.5 {for tests} {
  47.     catch {for 1 2 3} msg
  48.     set msg
  49. } {wrong # args: should be "for start test next command"}
  50. test for-old-1.6 {for tests} {catch {for 1 2 3 4 5} msg} 1
  51. test for-old-1.7 {for tests} {
  52.     catch {for 1 2 3 4 5} msg
  53.     set msg
  54. } {wrong # args: should be "for start test next command"}
  55. test for-old-1.8 {for tests} {
  56.     set a {xyz}
  57.     for {set i 1} {$i<6} {set i [expr $i+1]} {}
  58.     set a
  59. } xyz
  60. test for-old-1.9 {for tests} {
  61.     set a {}
  62.     for {set i 1} {$i<6} {set i [expr $i+1]; if $i==4 break} {
  63.     set a [concat $a $i]
  64.     }
  65.     set a
  66. } {1 2 3}
  67.