os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/while.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
# Commands covered:  while
sl@0
     2
#
sl@0
     3
# This file contains a collection of tests for one or more of the Tcl
sl@0
     4
# built-in commands.  Sourcing this file into Tcl runs the tests and
sl@0
     5
# generates output for errors.  No output means no errors were found.
sl@0
     6
#
sl@0
     7
# Copyright (c) 1996 Sun Microsystems, Inc.
sl@0
     8
# Copyright (c) 1998-1999 by Scriptics Corporation.
sl@0
     9
#
sl@0
    10
# See the file "license.terms" for information on usage and redistribution
sl@0
    11
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
sl@0
    12
#
sl@0
    13
# RCS: @(#) $Id: while.test,v 1.8 2001/12/04 15:36:29 dkf Exp $
sl@0
    14
sl@0
    15
if {[lsearch [namespace children] ::tcltest] == -1} {
sl@0
    16
    package require tcltest
sl@0
    17
    namespace import -force ::tcltest::*
sl@0
    18
}
sl@0
    19
sl@0
    20
# Basic "while" operation.
sl@0
    21
sl@0
    22
catch {unset i}
sl@0
    23
catch {unset a}
sl@0
    24
sl@0
    25
test while-1.1 {TclCompileWhileCmd: missing test expression} {
sl@0
    26
    catch {while } msg
sl@0
    27
    set msg
sl@0
    28
} {wrong # args: should be "while test command"}
sl@0
    29
test while-1.2 {TclCompileWhileCmd: error in test expression} {
sl@0
    30
    set i 0
sl@0
    31
    catch {while {$i<} break} msg
sl@0
    32
    set errorInfo
sl@0
    33
} {syntax error in expression "$i<": premature end of expression
sl@0
    34
    ("while" test expression)
sl@0
    35
    while compiling
sl@0
    36
"while {$i<} break"}
sl@0
    37
test while-1.3 {TclCompileWhileCmd: error in test expression} {
sl@0
    38
    set err [catch {while {"a"+"b"} {error "loop aborted"}} msg]
sl@0
    39
    list $err $msg
sl@0
    40
} {1 {can't use non-numeric string as operand of "+"}}
sl@0
    41
test while-1.4 {TclCompileWhileCmd: multiline test expr} {
sl@0
    42
    set value 1
sl@0
    43
    while {($tcl_platform(platform) != "foobar1") && \
sl@0
    44
	    ($tcl_platform(platform) != "foobar2")} {
sl@0
    45
        incr value
sl@0
    46
        break
sl@0
    47
    }
sl@0
    48
    set value
sl@0
    49
} {2}
sl@0
    50
test while-1.5 {TclCompileWhileCmd: non-numeric boolean test expr} {
sl@0
    51
    set value 1
sl@0
    52
    while {"true"} {
sl@0
    53
	incr value;
sl@0
    54
	if {$value > 5} {
sl@0
    55
	    break;
sl@0
    56
	}
sl@0
    57
    }
sl@0
    58
    set value
sl@0
    59
} 6
sl@0
    60
test while-1.6 {TclCompileWhileCmd: test expr is enclosed in quotes} {
sl@0
    61
    set i 0
sl@0
    62
    while "$i > 5" {}
sl@0
    63
} {}
sl@0
    64
test while-1.7 {TclCompileWhileCmd: missing command body} {
sl@0
    65
    set i 0
sl@0
    66
    catch {while {$i < 5} } msg
sl@0
    67
    set msg
sl@0
    68
} {wrong # args: should be "while test command"}
sl@0
    69
test while-1.8 {TclCompileWhileCmd: error compiling command body} {
sl@0
    70
    set i 0
sl@0
    71
    catch {while {$i < 5} {set}} msg
sl@0
    72
    set errorInfo
sl@0
    73
} {wrong # args: should be "set varName ?newValue?"
sl@0
    74
    while compiling
sl@0
    75
"set"
sl@0
    76
    ("while" body line 1)
sl@0
    77
    while compiling
sl@0
    78
"while {$i < 5} {set}"}
sl@0
    79
test while-1.9 {TclCompileWhileCmd: simple command body} {
sl@0
    80
    set a {}
sl@0
    81
    set i 1
sl@0
    82
    while {$i<6} {
sl@0
    83
	if $i==4 break
sl@0
    84
	set a [concat $a $i]
sl@0
    85
        incr i
sl@0
    86
    }
sl@0
    87
    set a
sl@0
    88
} {1 2 3}
sl@0
    89
test while-1.10 {TclCompileWhileCmd: command body in quotes} {
sl@0
    90
    set a {}
sl@0
    91
    set i 1
sl@0
    92
    while {$i<6} "append a x; incr i"
sl@0
    93
    set a
sl@0
    94
} {xxxxx}
sl@0
    95
test while-1.11 {TclCompileWhileCmd: computed command body} {
sl@0
    96
    catch {unset x1}
sl@0
    97
    catch {unset bb}
sl@0
    98
    catch {unset x2}
sl@0
    99
    set x1 {append a x1; }
sl@0
   100
    set bb {break}
sl@0
   101
    set x2 {; append a x2; incr i}
sl@0
   102
    set a {}
sl@0
   103
    set i 1
sl@0
   104
    while {$i<6} $x1$bb$x2
sl@0
   105
    set a
sl@0
   106
} {x1}
sl@0
   107
test while-1.12 {TclCompileWhileCmd: long command body} {
sl@0
   108
    set a {}
sl@0
   109
    set i 1
sl@0
   110
    while {$i<6} {
sl@0
   111
	if $i==4 break
sl@0
   112
	if $i>5 continue
sl@0
   113
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   114
	    catch {set a $a} msg
sl@0
   115
	    catch {incr i 5} msg
sl@0
   116
	    catch {incr i -5} msg
sl@0
   117
	}
sl@0
   118
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   119
	    catch {set a $a} msg
sl@0
   120
	    catch {incr i 5} msg
sl@0
   121
	    catch {incr i -5} msg
sl@0
   122
	}
sl@0
   123
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   124
	    catch {set a $a} msg
sl@0
   125
	    catch {incr i 5} msg
sl@0
   126
	    catch {incr i -5} msg
sl@0
   127
	}
sl@0
   128
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   129
	    catch {set a $a} msg
sl@0
   130
	    catch {incr i 5} msg
sl@0
   131
	    catch {incr i -5} msg
sl@0
   132
	}
sl@0
   133
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   134
	    catch {set a $a} msg
sl@0
   135
	    catch {incr i 5} msg
sl@0
   136
	    catch {incr i -5} msg
sl@0
   137
	}
sl@0
   138
	set a [concat $a $i]
sl@0
   139
        incr i
sl@0
   140
    }
sl@0
   141
    set a
sl@0
   142
} {1 2 3}
sl@0
   143
test while-1.13 {TclCompileWhileCmd: while command result} {
sl@0
   144
    set i 0
sl@0
   145
    set a [while {$i < 5} {incr i}]
sl@0
   146
    set a
sl@0
   147
} {}
sl@0
   148
test while-1.14 {TclCompileWhileCmd: while command result} {
sl@0
   149
    set i 0
sl@0
   150
    set a [while {$i < 5} {if $i==3 break; incr i}]
sl@0
   151
    set a
sl@0
   152
} {}
sl@0
   153
sl@0
   154
# Check "while" and "continue".
sl@0
   155
sl@0
   156
test while-2.1 {continue tests} {
sl@0
   157
    set a {}
sl@0
   158
    set i 1
sl@0
   159
    while {$i <= 4} {
sl@0
   160
        incr i
sl@0
   161
	if {$i == 3} continue
sl@0
   162
	set a [concat $a $i]
sl@0
   163
    }
sl@0
   164
    set a
sl@0
   165
} {2 4 5}
sl@0
   166
test while-2.2 {continue tests} {
sl@0
   167
    set a {}
sl@0
   168
    set i 1
sl@0
   169
    while {$i <= 4} {
sl@0
   170
        incr i
sl@0
   171
	if {$i != 2} continue
sl@0
   172
	set a [concat $a $i]
sl@0
   173
    }
sl@0
   174
    set a
sl@0
   175
} {2}
sl@0
   176
test while-2.3 {continue tests, nested loops} {
sl@0
   177
    set msg {}
sl@0
   178
    set i 1
sl@0
   179
    while {$i <= 4} {
sl@0
   180
        incr i
sl@0
   181
        set a 1
sl@0
   182
	while {$a <= 2} {
sl@0
   183
            incr a
sl@0
   184
            if {$i>=3 && $a>=3} continue
sl@0
   185
            set msg [concat $msg "$i.$a"]
sl@0
   186
        }
sl@0
   187
    }
sl@0
   188
    set msg
sl@0
   189
} {2.2 2.3 3.2 4.2 5.2}
sl@0
   190
test while-2.4 {continue tests, long command body} {
sl@0
   191
    set a {}
sl@0
   192
    set i 1
sl@0
   193
    while {$i<6} {
sl@0
   194
	if $i==2 {incr i; continue}
sl@0
   195
	if $i==4 break
sl@0
   196
	if $i>5 continue
sl@0
   197
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   198
	    catch {set a $a} msg
sl@0
   199
	    catch {incr i 5} msg
sl@0
   200
	    catch {incr i -5} msg
sl@0
   201
	}
sl@0
   202
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   203
	    catch {set a $a} msg
sl@0
   204
	    catch {incr i 5} msg
sl@0
   205
	    catch {incr i -5} msg
sl@0
   206
	}
sl@0
   207
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   208
	    catch {set a $a} msg
sl@0
   209
	    catch {incr i 5} msg
sl@0
   210
	    catch {incr i -5} msg
sl@0
   211
	}
sl@0
   212
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   213
	    catch {set a $a} msg
sl@0
   214
	    catch {incr i 5} msg
sl@0
   215
	    catch {incr i -5} msg
sl@0
   216
	}
sl@0
   217
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   218
	    catch {set a $a} msg
sl@0
   219
	    catch {incr i 5} msg
sl@0
   220
	    catch {incr i -5} msg
sl@0
   221
	}
sl@0
   222
	set a [concat $a $i]
sl@0
   223
        incr i
sl@0
   224
    }
sl@0
   225
    set a
sl@0
   226
} {1 3}
sl@0
   227
sl@0
   228
# Check "while" and "break".
sl@0
   229
sl@0
   230
test while-3.1 {break tests} {
sl@0
   231
    set a {}
sl@0
   232
    set i 1
sl@0
   233
    while {$i <= 4} {
sl@0
   234
	if {$i == 3} break
sl@0
   235
	set a [concat $a $i]
sl@0
   236
        incr i
sl@0
   237
    }
sl@0
   238
    set a
sl@0
   239
} {1 2}
sl@0
   240
test while-3.2 {break tests, nested loops} {
sl@0
   241
    set msg {}
sl@0
   242
    set i 1
sl@0
   243
    while {$i <= 4} {
sl@0
   244
        set a 1
sl@0
   245
	while {$a <= 2} {
sl@0
   246
            if {$i>=2 && $a>=2} break
sl@0
   247
            set msg [concat $msg "$i.$a"]
sl@0
   248
            incr a
sl@0
   249
        }
sl@0
   250
        incr i
sl@0
   251
    }
sl@0
   252
    set msg
sl@0
   253
} {1.1 1.2 2.1 3.1 4.1}
sl@0
   254
test while-3.3 {break tests, long command body} {
sl@0
   255
    set a {}
sl@0
   256
    set i 1
sl@0
   257
    while {$i<6} {
sl@0
   258
	if $i==2 {incr i; continue}
sl@0
   259
	if $i==5 break
sl@0
   260
	if $i>5 continue
sl@0
   261
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   262
	    catch {set a $a} msg
sl@0
   263
	    catch {incr i 5} msg
sl@0
   264
	    catch {incr i -5} msg
sl@0
   265
	}
sl@0
   266
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   267
	    catch {set a $a} msg
sl@0
   268
	    catch {incr i 5} msg
sl@0
   269
	    catch {incr i -5} msg
sl@0
   270
	}
sl@0
   271
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   272
	    catch {set a $a} msg
sl@0
   273
	    catch {incr i 5} msg
sl@0
   274
	    catch {incr i -5} msg
sl@0
   275
	}
sl@0
   276
	if $i==4 break
sl@0
   277
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   278
	    catch {set a $a} msg
sl@0
   279
	    catch {incr i 5} msg
sl@0
   280
	    catch {incr i -5} msg
sl@0
   281
	}
sl@0
   282
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   283
	    catch {set a $a} msg
sl@0
   284
	    catch {incr i 5} msg
sl@0
   285
	    catch {incr i -5} msg
sl@0
   286
	}
sl@0
   287
	set a [concat $a $i]
sl@0
   288
        incr i
sl@0
   289
    }
sl@0
   290
    set a
sl@0
   291
} {1 3}
sl@0
   292
sl@0
   293
# Check "while" with computed command names.
sl@0
   294
sl@0
   295
test while-4.1 {while and computed command names} {
sl@0
   296
    set i 0
sl@0
   297
    set z while
sl@0
   298
    $z {$i < 10} {
sl@0
   299
        incr i
sl@0
   300
    }
sl@0
   301
    set i
sl@0
   302
} 10
sl@0
   303
test while-4.2 {while (not compiled): missing test expression} {
sl@0
   304
    set z while
sl@0
   305
    catch {$z } msg
sl@0
   306
    set msg
sl@0
   307
} {wrong # args: should be "while test command"}
sl@0
   308
test while-4.3 {while (not compiled): error in test expression} {
sl@0
   309
    set i 0
sl@0
   310
    set z while
sl@0
   311
    catch {$z {$i<} {set x 1}} msg
sl@0
   312
    set errorInfo
sl@0
   313
} {syntax error in expression "$i<": premature end of expression
sl@0
   314
    while executing
sl@0
   315
"$z {$i<} {set x 1}"}
sl@0
   316
test while-4.4 {while (not compiled): error in test expression} {
sl@0
   317
    set z while
sl@0
   318
    set err [catch {$z {"a"+"b"} {error "loop aborted"}} msg]
sl@0
   319
    list $err $msg
sl@0
   320
} {1 {can't use non-numeric string as operand of "+"}}
sl@0
   321
test while-4.5 {while (not compiled): multiline test expr} {
sl@0
   322
    set value 1
sl@0
   323
    set z while
sl@0
   324
    $z {($tcl_platform(platform) != "foobar1") && \
sl@0
   325
	    ($tcl_platform(platform) != "foobar2")} {
sl@0
   326
        incr value
sl@0
   327
        break
sl@0
   328
    }
sl@0
   329
    set value
sl@0
   330
} {2}
sl@0
   331
test while-4.6 {while (not compiled): non-numeric boolean test expr} {
sl@0
   332
    set value 1
sl@0
   333
    set z while
sl@0
   334
    $z {"true"} {
sl@0
   335
	incr value;
sl@0
   336
	if {$value > 5} {
sl@0
   337
	    break;
sl@0
   338
	}
sl@0
   339
    }
sl@0
   340
    set value
sl@0
   341
} 6
sl@0
   342
test while-4.7 {while (not compiled): test expr is enclosed in quotes} {
sl@0
   343
    set i 0
sl@0
   344
    set z while
sl@0
   345
    $z "$i > 5" {}
sl@0
   346
} {}
sl@0
   347
test while-4.8 {while (not compiled): missing command body} {
sl@0
   348
    set i 0
sl@0
   349
    set z while
sl@0
   350
    catch {$z {$i < 5} } msg
sl@0
   351
    set msg
sl@0
   352
} {wrong # args: should be "while test command"}
sl@0
   353
test while-4.9 {while (not compiled): error compiling command body} {
sl@0
   354
    set i 0
sl@0
   355
    set z while
sl@0
   356
    catch {$z {$i < 5} {set}} msg
sl@0
   357
    set errorInfo
sl@0
   358
} {wrong # args: should be "set varName ?newValue?"
sl@0
   359
    while compiling
sl@0
   360
"set"
sl@0
   361
    ("while" body line 1)
sl@0
   362
    invoked from within
sl@0
   363
"$z {$i < 5} {set}"}
sl@0
   364
test while-4.10 {while (not compiled): simple command body} {
sl@0
   365
    set a {}
sl@0
   366
    set i 1
sl@0
   367
    set z while
sl@0
   368
    $z {$i<6} {
sl@0
   369
	if $i==4 break
sl@0
   370
	set a [concat $a $i]
sl@0
   371
        incr i
sl@0
   372
    }
sl@0
   373
    set a
sl@0
   374
} {1 2 3}
sl@0
   375
test while-4.11 {while (not compiled): command body in quotes} {
sl@0
   376
    set a {}
sl@0
   377
    set i 1
sl@0
   378
    set z while
sl@0
   379
    $z {$i<6} "append a x; incr i"
sl@0
   380
    set a
sl@0
   381
} {xxxxx}
sl@0
   382
test while-4.12 {while (not compiled): computed command body} {
sl@0
   383
    set z while
sl@0
   384
    catch {unset x1}
sl@0
   385
    catch {unset bb}
sl@0
   386
    catch {unset x2}
sl@0
   387
    set x1 {append a x1; }
sl@0
   388
    set bb {break}
sl@0
   389
    set x2 {; append a x2; incr i}
sl@0
   390
    set a {}
sl@0
   391
    set i 1
sl@0
   392
    $z {$i<6} $x1$bb$x2
sl@0
   393
    set a
sl@0
   394
} {x1}
sl@0
   395
test while-4.13 {while (not compiled): long command body} {
sl@0
   396
    set a {}
sl@0
   397
    set z while
sl@0
   398
    set i 1
sl@0
   399
    $z {$i<6} {
sl@0
   400
	if $i==4 break
sl@0
   401
	if $i>5 continue
sl@0
   402
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   403
	    catch {set a $a} msg
sl@0
   404
	    catch {incr i 5} msg
sl@0
   405
	    catch {incr i -5} msg
sl@0
   406
	}
sl@0
   407
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   408
	    catch {set a $a} msg
sl@0
   409
	    catch {incr i 5} msg
sl@0
   410
	    catch {incr i -5} msg
sl@0
   411
	}
sl@0
   412
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   413
	    catch {set a $a} msg
sl@0
   414
	    catch {incr i 5} msg
sl@0
   415
	    catch {incr i -5} msg
sl@0
   416
	}
sl@0
   417
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   418
	    catch {set a $a} msg
sl@0
   419
	    catch {incr i 5} msg
sl@0
   420
	    catch {incr i -5} msg
sl@0
   421
	}
sl@0
   422
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   423
	    catch {set a $a} msg
sl@0
   424
	    catch {incr i 5} msg
sl@0
   425
	    catch {incr i -5} msg
sl@0
   426
	}
sl@0
   427
	set a [concat $a $i]
sl@0
   428
        incr i
sl@0
   429
    }
sl@0
   430
    set a
sl@0
   431
} {1 2 3}
sl@0
   432
test while-4.14 {while (not compiled): while command result} {
sl@0
   433
    set i 0
sl@0
   434
    set z while
sl@0
   435
    set a [$z {$i < 5} {incr i}]
sl@0
   436
    set a
sl@0
   437
} {}
sl@0
   438
test while-4.15 {while (not compiled): while command result} {
sl@0
   439
    set i 0
sl@0
   440
    set z while
sl@0
   441
    set a [$z {$i < 5} {if $i==3 break; incr i}]
sl@0
   442
    set a
sl@0
   443
} {}
sl@0
   444
sl@0
   445
# Check "break" with computed command names.
sl@0
   446
sl@0
   447
test while-5.1 {break and computed command names} {
sl@0
   448
    set i 0
sl@0
   449
    set z break
sl@0
   450
    while 1 {
sl@0
   451
        if {$i > 10} $z
sl@0
   452
        incr i
sl@0
   453
    }
sl@0
   454
    set i
sl@0
   455
} 11
sl@0
   456
test while-5.2 {break tests with computed command names} {
sl@0
   457
    set a {}
sl@0
   458
    set i 1
sl@0
   459
    set z break
sl@0
   460
    while {$i <= 4} {
sl@0
   461
	if {$i == 3} $z
sl@0
   462
	set a [concat $a $i]
sl@0
   463
        incr i
sl@0
   464
    }
sl@0
   465
    set a
sl@0
   466
} {1 2}
sl@0
   467
test while-5.3 {break tests, nested loops with computed command names} {
sl@0
   468
    set msg {}
sl@0
   469
    set i 1
sl@0
   470
    set z break
sl@0
   471
    while {$i <= 4} {
sl@0
   472
        set a 1
sl@0
   473
	while {$a <= 2} {
sl@0
   474
            if {$i>=2 && $a>=2} $z
sl@0
   475
            set msg [concat $msg "$i.$a"]
sl@0
   476
            incr a
sl@0
   477
        }
sl@0
   478
        incr i
sl@0
   479
    }
sl@0
   480
    set msg
sl@0
   481
} {1.1 1.2 2.1 3.1 4.1}
sl@0
   482
test while-5.4 {break tests, long command body with computed command names} {
sl@0
   483
    set a {}
sl@0
   484
    set i 1
sl@0
   485
    set z break
sl@0
   486
    while {$i<6} {
sl@0
   487
	if $i==2 {incr i; continue}
sl@0
   488
	if $i==5 $z
sl@0
   489
	if $i>5 continue
sl@0
   490
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   491
	    catch {set a $a} msg
sl@0
   492
	    catch {incr i 5} msg
sl@0
   493
	    catch {incr i -5} msg
sl@0
   494
	}
sl@0
   495
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   496
	    catch {set a $a} msg
sl@0
   497
	    catch {incr i 5} msg
sl@0
   498
	    catch {incr i -5} msg
sl@0
   499
	}
sl@0
   500
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   501
	    catch {set a $a} msg
sl@0
   502
	    catch {incr i 5} msg
sl@0
   503
	    catch {incr i -5} msg
sl@0
   504
	}
sl@0
   505
	if $i==4 $z
sl@0
   506
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   507
	    catch {set a $a} msg
sl@0
   508
	    catch {incr i 5} msg
sl@0
   509
	    catch {incr i -5} msg
sl@0
   510
	}
sl@0
   511
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   512
	    catch {set a $a} msg
sl@0
   513
	    catch {incr i 5} msg
sl@0
   514
	    catch {incr i -5} msg
sl@0
   515
	}
sl@0
   516
	set a [concat $a $i]
sl@0
   517
        incr i
sl@0
   518
    }
sl@0
   519
    set a
sl@0
   520
} {1 3}
sl@0
   521
sl@0
   522
# Check "continue" with computed command names.
sl@0
   523
sl@0
   524
test while-6.1 {continue and computed command names} {
sl@0
   525
    set i 0
sl@0
   526
    set z continue
sl@0
   527
    while 1 {
sl@0
   528
        incr i
sl@0
   529
        if {$i < 10} $z
sl@0
   530
        break
sl@0
   531
    }
sl@0
   532
    set i
sl@0
   533
} 10
sl@0
   534
test while-6.2 {continue tests} {
sl@0
   535
    set a {}
sl@0
   536
    set i 1
sl@0
   537
    set z continue
sl@0
   538
    while {$i <= 4} {
sl@0
   539
        incr i
sl@0
   540
	if {$i == 3} $z
sl@0
   541
	set a [concat $a $i]
sl@0
   542
    }
sl@0
   543
    set a
sl@0
   544
} {2 4 5}
sl@0
   545
test while-6.3 {continue tests with computed command names} {
sl@0
   546
    set a {}
sl@0
   547
    set i 1
sl@0
   548
    set z continue
sl@0
   549
    while {$i <= 4} {
sl@0
   550
        incr i
sl@0
   551
	if {$i != 2} $z
sl@0
   552
	set a [concat $a $i]
sl@0
   553
    }
sl@0
   554
    set a
sl@0
   555
} {2}
sl@0
   556
test while-6.4 {continue tests, nested loops with computed command names} {
sl@0
   557
    set msg {}
sl@0
   558
    set i 1
sl@0
   559
    set z continue
sl@0
   560
    while {$i <= 4} {
sl@0
   561
        incr i
sl@0
   562
        set a 1
sl@0
   563
	while {$a <= 2} {
sl@0
   564
            incr a
sl@0
   565
            if {$i>=3 && $a>=3} $z
sl@0
   566
            set msg [concat $msg "$i.$a"]
sl@0
   567
        }
sl@0
   568
    }
sl@0
   569
    set msg
sl@0
   570
} {2.2 2.3 3.2 4.2 5.2}
sl@0
   571
test while-6.5 {continue tests, long command body with computed command names} {
sl@0
   572
    set a {}
sl@0
   573
    set i 1
sl@0
   574
    set z continue
sl@0
   575
    while {$i<6} {
sl@0
   576
	if $i==2 {incr i; continue}
sl@0
   577
	if $i==4 break
sl@0
   578
	if $i>5 $z
sl@0
   579
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   580
	    catch {set a $a} msg
sl@0
   581
	    catch {incr i 5} msg
sl@0
   582
	    catch {incr i -5} msg
sl@0
   583
	}
sl@0
   584
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   585
	    catch {set a $a} msg
sl@0
   586
	    catch {incr i 5} msg
sl@0
   587
	    catch {incr i -5} msg
sl@0
   588
	}
sl@0
   589
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   590
	    catch {set a $a} msg
sl@0
   591
	    catch {incr i 5} msg
sl@0
   592
	    catch {incr i -5} msg
sl@0
   593
	}
sl@0
   594
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   595
	    catch {set a $a} msg
sl@0
   596
	    catch {incr i 5} msg
sl@0
   597
	    catch {incr i -5} msg
sl@0
   598
	}
sl@0
   599
	if {$i>6 && $tcl_platform(machine)=="xxx"} {
sl@0
   600
	    catch {set a $a} msg
sl@0
   601
	    catch {incr i 5} msg
sl@0
   602
	    catch {incr i -5} msg
sl@0
   603
	}
sl@0
   604
	set a [concat $a $i]
sl@0
   605
        incr i
sl@0
   606
    }
sl@0
   607
    set a
sl@0
   608
} {1 3}
sl@0
   609
sl@0
   610
# Test for incorrect "double evaluation" semantics
sl@0
   611
sl@0
   612
test while-7.1 {delayed substitution of body} {
sl@0
   613
    set i 0
sl@0
   614
    while {[incr i] < 10} "
sl@0
   615
       set result $i
sl@0
   616
    "
sl@0
   617
    proc p {} {
sl@0
   618
	set i 0
sl@0
   619
	while {[incr i] < 10} "
sl@0
   620
	    set result $i
sl@0
   621
	"
sl@0
   622
	set result
sl@0
   623
    }
sl@0
   624
    append result [p]
sl@0
   625
} {00}
sl@0
   626
sl@0
   627
# cleanup
sl@0
   628
::tcltest::cleanupTests
sl@0
   629
return