diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2005-06-01 11:00:24 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2005-06-01 11:00:24 (GMT) |
commit | 854f85bb1700aa6f106cc6a443cb0eb2e917f2de (patch) | |
tree | d3bbe95a2b84f8455477e5d9e709e78633b6d7bd /tests/switch.test | |
parent | 8f397c357860e5098e4eeea5140ed0d3c724075d (diff) | |
download | tcl-854f85bb1700aa6f106cc6a443cb0eb2e917f2de.zip tcl-854f85bb1700aa6f106cc6a443cb0eb2e917f2de.tar.gz tcl-854f85bb1700aa6f106cc6a443cb0eb2e917f2de.tar.bz2 |
Implementation of TIP#241 from Joe Mistachkin
Also compilation of [switch -glob -nocase] from Donal Fellows
Diffstat (limited to 'tests/switch.test')
-rw-r--r-- | tests/switch.test | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/tests/switch.test b/tests/switch.test index b06155c..e05f2ca 100644 --- a/tests/switch.test +++ b/tests/switch.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: switch.test,v 1.12 2005/05/10 18:35:24 kennykb Exp $ +# RCS: @(#) $Id: switch.test,v 1.13 2005/06/01 11:00:35 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -39,6 +39,18 @@ test switch-1.6 {simple patterns} { test switch-1.7 {simple patterns} { switch x a {format 1} default {format 2} c {format 3} default {format 4} } 4 +test switch-1.8 {simple patterns with -nocase} { + switch -nocase b a {format 1} b {format 2} c {format 3} default {format 4} +} 2 +test switch-1.9 {simple patterns with -nocase} { + switch -nocase B a {format 1} b {format 2} c {format 3} default {format 4} +} 2 +test switch-1.10 {simple patterns with -nocase} { + switch -nocase b a {format 1} B {format 2} c {format 3} default {format 4} +} 2 +test switch-1.11 {simple patterns with -nocase} { + switch -nocase x a {format 1} default {format 2} c {format 3} default {format 4} +} 4 test switch-2.1 {single-argument form for pattern/command pairs} { switch b { @@ -89,7 +101,43 @@ test switch-3.5 {-exact vs. -glob vs. -regexp} { } exact test switch-3.6 {-exact vs. -glob vs. -regexp} { list [catch {switch -foo a b c} msg] $msg -} {1 {bad option "-foo": must be -exact, -glob, -indexvar, -matchvar, -regexp, or --}} +} {1 {bad option "-foo": must be -exact, -glob, -indexvar, -matchvar, -nocase, -regexp, or --}} +test switch-3.7 {-exact vs. -glob vs. -regexp with -nocase} { + switch -exact -nocase aaaab { + ^a*b$ {concat regexp} + *b {concat glob} + aaaab {concat exact} + default {concat none} + } +} exact +test switch-3.8 {-exact vs. -glob vs. -regexp with -nocase} { + switch -regexp -nocase aaaab { + ^a*b$ {concat regexp} + *b {concat glob} + aaaab {concat exact} + default {concat none} + } +} regexp +test switch-3.9 {-exact vs. -glob vs. -regexp with -nocase} { + switch -glob -nocase aaaab { + ^a*b$ {concat regexp} + *b {concat glob} + aaaab {concat exact} + default {concat none} + } +} glob +test switch-3.10 {-exact vs. -glob vs. -regexp with -nocase} { + switch -nocase aaaab {^a*b$} {concat regexp} *b {concat glob} \ + aaaab {concat exact} default {concat none} +} exact +test switch-3.11 {-exact vs. -glob vs. -regexp with -nocase} { + switch -nocase -- -glob { + ^g.*b$ {concat regexp} + -* {concat glob} + -glob {concat exact} + default {concat none} + } +} exact test switch-4.1 {error in executed command} { list [catch {switch a a {error "Just a test"} default {format 1}} msg] \ |