⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 for.test

📁 linux系统下的音频通信
💻 TEST
📖 第 1 页 / 共 2 页
字号:
# Commands covered:  for, continue, break## This file contains a collection of tests for one or more of the Tcl# built-in commands.  Sourcing this file into Tcl runs the tests and# generates output for errors.  No output means no errors were found.## Copyright (c) 1996 Sun Microsystems, Inc.## See the file "license.terms" for information on usage and redistribution# of this file, and for a DISCLAIMER OF ALL WARRANTIES.## SCCS: @(#) for.test 1.10 97/07/02 16:40:59if {[string compare test [info procs test]] == 1} then {source defs}# Basic "for" operation.test for-1.1 {TclCompileForCmd: missing initial command} {    list [catch {for} msg] $msg} {1 {wrong # args: should be "for start test next command"}}test for-1.2 {TclCompileForCmd: error in initial command} {    list [catch {for {set}} msg] $msg $errorInfo} {1 {wrong # args: should be "for start test next command"} {wrong # args: should be "for start test next command"    while compiling"for {set}"}}catch {unset i}test for-1.3 {TclCompileForCmd: missing test expression} {    catch {for {set i 0}} msg    set msg} {wrong # args: should be "for start test next command"}test for-1.4 {TclCompileForCmd: error in test expression} {    catch {for {set i 0} {$i<}} msg    set errorInfo} {wrong # args: should be "for start test next command"    while compiling"for {set i 0} {$i<}"}test for-1.5 {TclCompileForCmd: test expression is enclosed in quotes} {    set i 0    for {} "$i > 5" {incr i} {}} {}test for-1.6 {TclCompileForCmd: missing "next" command} {    catch {for {set i 0} {$i < 5}} msg    set msg} {wrong # args: should be "for start test next command"}test for-1.7 {TclCompileForCmd: missing command body} {    catch {for {set i 0} {$i < 5} {incr i}} msg    set msg} {wrong # args: should be "for start test next command"}test for-1.8 {TclCompileForCmd: error compiling command body} {    catch {for {set i 0} {$i < 5} {incr i} {set}} msg    set errorInfo} {wrong # args: should be "set varName ?newValue?"    while compiling"set"    ("for" body line 1)    while compiling"for {set i 0} {$i < 5} {incr i} {set}"}catch {unset a}test for-1.9 {TclCompileForCmd: simple command body} {    set a {}    for {set i 1} {$i<6} {set i [expr $i+1]} {	if $i==4 break	set a [concat $a $i]    }    set a} {1 2 3}test for-1.10 {TclCompileForCmd: command body in quotes} {    set a {}    for {set i 1} {$i<6} {set i [expr $i+1]} "append a x"    set a} {xxxxx}test for-1.11 {TclCompileForCmd: computed command body} {    catch {unset x1}    catch {unset bb}    catch {unset x2}    set x1 {append a x1; }    set bb {break}    set x2 {; append a x2}    set a {}    for {set i 1} {$i<6} {set i [expr $i+1]} $x1$bb$x2    set a} {x1}test for-1.12 {TclCompileForCmd: error in "next" command} {    catch {for {set i 0} {$i < 5} {set} {puts $i}} msg    set errorInfo} {wrong # args: should be "set varName ?newValue?"    while compiling"set"    ("for" loop-end command)    while compiling"for {set i 0} {$i < 5} {set} {puts $i}"}test for-1.13 {TclCompileForCmd: long command body} {    set a {}    for {set i 1} {$i<6} {set i [expr $i+1]} {	if $i==4 break	if $i>5 continue	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	set a [concat $a $i]    }    set a} {1 2 3}test for-1.14 {TclCompileForCmd: for command result} {    set a [for {set i 0} {$i < 5} {incr i} {}]    set a} {}test for-1.15 {TclCompileForCmd: for command result} {    set a [for {set i 0} {$i < 5} {incr i} {if $i==3 break}]    set a} {}# Check "for" and "continue".test for-2.1 {TclCompileContinueCmd: arguments after "continue"} {    catch {continue foo} msg    set msg} {wrong # args: should be "continue"}test for-2.2 {TclCompileContinueCmd: continue result} {    catch continue} 4test for-2.3 {continue tests} {    set a {}    for {set i 1} {$i <= 4} {set i [expr $i+1]} {	if {$i == 2} continue	set a [concat $a $i]    }    set a} {1 3 4}test for-2.4 {continue tests} {    set a {}    for {set i 1} {$i <= 4} {set i [expr $i+1]} {	if {$i != 2} continue	set a [concat $a $i]    }    set a} {2}test for-2.5 {continue tests, nested loops} {    set msg {}    for {set i 1} {$i <= 4} {incr i} {	for {set a 1} {$a <= 2} {incr a} {            if {$i>=2 && $a>=2} continue            set msg [concat $msg "$i.$a"]        }    }    set msg} {1.1 1.2 2.1 3.1 4.1}test for-2.6 {continue tests, long command body} {    set a {}    for {set i 1} {$i<6} {set i [expr $i+1]} {	if $i==2 continue	if $i==4 break	if $i>5 continue	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	set a [concat $a $i]    }    set a} {1 3}# Check "for" and "break".test for-3.1 {TclCompileBreakCmd: arguments after "break"} {    catch {break foo} msg    set msg} {wrong # args: should be "break"}test for-3.2 {TclCompileBreakCmd: break result} {    catch break} 3test for-3.3 {break tests} {    set a {}    for {set i 1} {$i <= 4} {incr i} {	if {$i == 3} break	set a [concat $a $i]    }    set a} {1 2}test for-3.4 {break tests, nested loops} {    set msg {}    for {set i 1} {$i <= 4} {incr i} {	for {set a 1} {$a <= 2} {incr a} {            if {$i>=2 && $a>=2} break            set msg [concat $msg "$i.$a"]        }    }    set msg} {1.1 1.2 2.1 3.1 4.1}test for-3.5 {break tests, long command body} {    set a {}    for {set i 1} {$i<6} {set i [expr $i+1]} {	if $i==2 continue	if $i==5 break	if $i>5 continue	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	if $i==4 break	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	if {$i>6 && $tcl_platform(machine)=="xxx"} {	    catch {set a $a} msg	    catch {incr i 5} msg	    catch {incr i -5} msg	}	set a [concat $a $i]    }    set a} {1 3}# A simplified version of exmh's mail formatting routine to stress "for",# "break", "while", and "if".proc formatMail {} {    array set lines {        0 {Return-path: george@tcl} \        1 {Return-path: <george@tcl>} \        2 {Received: from tcl by tcl.Somewhere.COM (SMI-8.6/SMI-SVR4)} \        3 {	id LAA10027; Wed, 11 Sep 1996 11:14:53 -0700} \        4 {Message-id: <199609111814.LAA10027@tcl.Somewhere.COM>} \        5 {X-mailer: exmh version 1.6.9 8/22/96} \        6 {Mime-version: 1.0} \        7 {Content-type: text/plain; charset=iso-8859-1} \        8 {Content-transfer-encoding: quoted-printable} \        9 {Content-length: 2162} \        10 {To: fred} \        11 {Subject: tcl7.6} \        12 {Date: Wed, 11 Sep 1996 11:14:53 -0700} \        13 {From: George <george@tcl>} \        14 {The Tcl 7.6 and Tk 4.2 releases} \        15 {} \        16 {This page contains information about Tcl 7.6 and Tk4.2, which are the most recent} \        17 {releases of the Tcl scripting language and the Tk toolkit. The first beta versions of these} \        18 {releases were released on August 30, 1996. These releases contain only minor changes,} \        19 {so we hope to have only a single beta release and to go final in early October, 1996. } \        20 {} \        21 {} \        22 {What's new } \        23 {} \        24 {The most important changes in the releases are summarized below. See the README} \

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -