os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/case.test
First public contribution.
1 # Commands covered: case
3 # This file contains a collection of tests for one or more of the Tcl
4 # built-in commands. Sourcing this file into Tcl runs the tests and
5 # generates output for errors. No output means no errors were found.
7 # Copyright (c) 1991-1993 The Regents of the University of California.
8 # Copyright (c) 1994 Sun Microsystems, Inc.
9 # Copyright (c) 1998-1999 by Scriptics Corporation.
11 # See the file "license.terms" for information on usage and redistribution
12 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 # RCS: @(#) $Id: case.test,v 1.5 2000/04/10 17:18:57 ericm Exp $
16 if {[lsearch [namespace children] ::tcltest] == -1} {
17 package require tcltest
18 namespace import -force ::tcltest::*
21 test case-1.1 {simple pattern} {
22 case a in a {format 1} b {format 2} c {format 3} default {format 4}
24 test case-1.2 {simple pattern} {
25 case b a {format 1} b {format 2} c {format 3} default {format 4}
27 test case-1.3 {simple pattern} {
28 case x in a {format 1} b {format 2} c {format 3} default {format 4}
30 test case-1.4 {simple pattern} {
31 case x a {format 1} b {format 2} c {format 3}
33 test case-1.5 {simple pattern matches many times} {
34 case b a {format 1} b {format 2} b {format 3} b {format 4}
36 test case-1.6 {fancier pattern} {
37 case cx a {format 1} *c {format 2} *x {format 3} default {format 4}
39 test case-1.7 {list of patterns} {
40 case abc in {a b c} {format 1} {def abc ghi} {format 2}
43 test case-2.1 {error in executed command} {
44 list [catch {case a in a {error "Just a test"} default {format 1}} msg] \
46 } {1 {Just a test} {Just a test
51 "case a in a {error "Just a test"} default {format 1}"}}
52 test case-2.2 {error: not enough args} {
53 list [catch {case} msg] $msg
54 } {1 {wrong # args: should be "case string ?in? patList body ... ?default body?"}}
55 test case-2.3 {error: pattern with no body} {
56 list [catch {case a b} msg] $msg
57 } {1 {extra case pattern with no body}}
58 test case-2.4 {error: pattern with no body} {
59 list [catch {case a in b {format 1} c} msg] $msg
60 } {1 {extra case pattern with no body}}
61 test case-2.5 {error in default command} {
62 list [catch {case foo in a {error case1} default {error case2} \
63 b {error case 3}} msg] $msg $errorInfo
67 ("default" arm line 1)
69 "case foo in a {error case1} default {error case2} b {error case 3}"}}
71 test case-3.1 {single-argument form for pattern/command pairs} {
78 test case-3.2 {single-argument form for pattern/command pairs} {
85 test case-3.3 {single-argument form for pattern/command pairs} {
86 list [catch {case z in {a 2 b}} msg] $msg
87 } {1 {extra case pattern with no body}}
90 ::tcltest::cleanupTests