os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/if-old.test
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/if-old.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,164 @@
     1.4 +# Commands covered:  if
     1.5 +#
     1.6 +# This file contains the original set of tests for Tcl's if command.
     1.7 +# Since the if command is now compiled, a new set of tests covering
     1.8 +# the new implementation is in the file "if.test". Sourcing this file
     1.9 +# into Tcl runs the tests and generates output for errors.
    1.10 +# No output means no errors were found.
    1.11 +#
    1.12 +# Copyright (c) 1991-1993 The Regents of the University of California.
    1.13 +# Copyright (c) 1994-1996 Sun Microsystems, Inc.
    1.14 +# Copyright (c) 1998-1999 by Scriptics Corporation.
    1.15 +#
    1.16 +# See the file "license.terms" for information on usage and redistribution
    1.17 +# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1.18 +#
    1.19 +# RCS: @(#) $Id: if-old.test,v 1.5.24.1 2003/03/27 13:11:12 dkf Exp $
    1.20 +
    1.21 +if {[lsearch [namespace children] ::tcltest] == -1} {
    1.22 +    package require tcltest
    1.23 +    namespace import -force ::tcltest::*
    1.24 +}
    1.25 +
    1.26 +test if-old-1.1 {taking proper branch} {
    1.27 +    set a {}
    1.28 +    if 0 {set a 1} else {set a 2}
    1.29 +    set a
    1.30 +} 2
    1.31 +test if-old-1.2 {taking proper branch} {
    1.32 +    set a {}
    1.33 +    if 1 {set a 1} else {set a 2}
    1.34 +    set a
    1.35 +} 1
    1.36 +test if-old-1.3 {taking proper branch} {
    1.37 +    set a {}
    1.38 +    if 1<2 {set a 1}
    1.39 +    set a
    1.40 +} 1
    1.41 +test if-old-1.4 {taking proper branch} {
    1.42 +    set a {}
    1.43 +    if 1>2 {set a 1}
    1.44 +    set a
    1.45 +} {}
    1.46 +test if-old-1.5 {taking proper branch} {
    1.47 +    set a {}
    1.48 +    if 0 {set a 1} else {}
    1.49 +    set a
    1.50 +} {}
    1.51 +test if-old-1.6 {taking proper branch} {
    1.52 +    set a {}
    1.53 +    if 0 {set a 1} elseif 1 {set a 2} elseif 1 {set a 3} else {set a 4}
    1.54 +    set a
    1.55 +} {2}
    1.56 +test if-old-1.7 {taking proper branch} {
    1.57 +    set a {}
    1.58 +    if 0 {set a 1} elseif 0 {set a 2} elseif 1 {set a 3} else {set a 4}
    1.59 +    set a
    1.60 +} {3}
    1.61 +test if-old-1.8 {taking proper branch} {
    1.62 +    set a {}
    1.63 +    if 0 {set a 1} elseif 0 {set a 2} elseif 0 {set a 3} else {set a 4}
    1.64 +    set a
    1.65 +} {4}
    1.66 +test if-old-1.9 {taking proper branch, multiline test expr} {
    1.67 +    set a {}
    1.68 +    if {($tcl_platform(platform) != "foobar1") && \
    1.69 +	($tcl_platform(platform) != "foobar2")} {set a 3} else {set a 4}
    1.70 +    set a
    1.71 +} {3}
    1.72 +
    1.73 +
    1.74 +test if-old-2.1 {optional then-else args} {
    1.75 +    set a 44
    1.76 +    if 0 then {set a 1} elseif 0 then {set a 3} else {set a 2}
    1.77 +    set a
    1.78 +} 2
    1.79 +test if-old-2.2 {optional then-else args} {
    1.80 +    set a 44
    1.81 +    if 1 then {set a 1} else {set a 2}
    1.82 +    set a
    1.83 +} 1
    1.84 +test if-old-2.3 {optional then-else args} {
    1.85 +    set a 44
    1.86 +    if 0 {set a 1} else {set a 2}
    1.87 +    set a
    1.88 +} 2
    1.89 +test if-old-2.4 {optional then-else args} {
    1.90 +    set a 44
    1.91 +    if 1 {set a 1} else {set a 2}
    1.92 +    set a
    1.93 +} 1
    1.94 +test if-old-2.5 {optional then-else args} {
    1.95 +    set a 44
    1.96 +    if 0 then {set a 1} {set a 2}
    1.97 +    set a
    1.98 +} 2
    1.99 +test if-old-2.6 {optional then-else args} {
   1.100 +    set a 44
   1.101 +    if 1 then {set a 1} {set a 2}
   1.102 +    set a
   1.103 +} 1
   1.104 +test if-old-2.7 {optional then-else args} {
   1.105 +    set a 44
   1.106 +    if 0 then {set a 1} else {set a 2}
   1.107 +    set a
   1.108 +} 2
   1.109 +test if-old-2.8 {optional then-else args} {
   1.110 +    set a 44
   1.111 +    if 0 then {set a 1} elseif 0 {set a 2} elseif 0 {set a 3} {set a 4}
   1.112 +    set a
   1.113 +} 4
   1.114 +
   1.115 +test if-old-3.1 {return value} {
   1.116 +    if 1 then {set a 22; concat abc}
   1.117 +} abc
   1.118 +test if-old-3.2 {return value} {
   1.119 +    if 0 then {set a 22; concat abc} elseif 1 {concat def} {concat ghi}
   1.120 +} def
   1.121 +test if-old-3.3 {return value} {
   1.122 +    if 0 then {set a 22; concat abc} else {concat def}
   1.123 +} def
   1.124 +test if-old-3.4 {return value} {
   1.125 +    if 0 then {set a 22; concat abc}
   1.126 +} {}
   1.127 +test if-old-3.5 {return value} {
   1.128 +    if 0 then {set a 22; concat abc} elseif 0 {concat def}
   1.129 +} {}
   1.130 +
   1.131 +test if-old-4.1 {error conditions} {
   1.132 +    list [catch {if} msg] $msg
   1.133 +} {1 {wrong # args: no expression after "if" argument}}
   1.134 +test if-old-4.2 {error conditions} {
   1.135 +    list [catch {if {[error "error in condition"]} foo} msg] $msg
   1.136 +} {1 {error in condition}}
   1.137 +test if-old-4.3 {error conditions} {
   1.138 +    list [catch {if 2} msg] $msg
   1.139 +} {1 {wrong # args: no script following "2" argument}}
   1.140 +test if-old-4.4 {error conditions} {
   1.141 +    list [catch {if 2 then} msg] $msg
   1.142 +} {1 {wrong # args: no script following "then" argument}}
   1.143 +test if-old-4.5 {error conditions} {
   1.144 +    list [catch {if 2 the} msg] $msg
   1.145 +} {1 {invalid command name "the"}}
   1.146 +test if-old-4.6 {error conditions} {
   1.147 +    list [catch {if 2 then {[error "error in then clause"]}} msg] $msg
   1.148 +} {1 {error in then clause}}
   1.149 +test if-old-4.7 {error conditions} {
   1.150 +    list [catch {if 0 then foo elseif} msg] $msg
   1.151 +} {1 {wrong # args: no expression after "elseif" argument}}
   1.152 +test if-old-4.8 {error conditions} {
   1.153 +    list [catch {if 0 then foo elsei} msg] $msg
   1.154 +} {1 {invalid command name "elsei"}}
   1.155 +test if-old-4.9 {error conditions} {
   1.156 +    list [catch {if 0 then foo elseif 0 bar else} msg] $msg
   1.157 +} {1 {wrong # args: no script following "else" argument}}
   1.158 +test if-old-4.10 {error conditions} {
   1.159 +    list [catch {if 0 then foo elseif 0 bar els} msg] $msg
   1.160 +} {1 {invalid command name "els"}}
   1.161 +test if-old-4.11 {error conditions} {
   1.162 +    list [catch {if 0 then foo elseif 0 bar else {[error "error in else clause"]}} msg] $msg
   1.163 +} {1 {error in else clause}}
   1.164 +
   1.165 +# cleanup
   1.166 +::tcltest::cleanupTests
   1.167 +return