diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-12-01 14:32:09 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2023-02-13 10:52:21 +1000 |
commit | 4255d54c254a5f49a19017a3071b8d7ff35e70e9 (patch) | |
tree | 3f0a7d263850cb461321d76b6ca5f84a286f7322 /tests/ensemble.test | |
parent | d295fb1b6124575793add4b95860fabd1539a099 (diff) | |
download | jimtcl-4255d54c254a5f49a19017a3071b8d7ff35e70e9.zip jimtcl-4255d54c254a5f49a19017a3071b8d7ff35e70e9.tar.gz jimtcl-4255d54c254a5f49a19017a3071b8d7ff35e70e9.tar.bz2 |
ensemble: Add a simple ensemble command
Uses a prefix to automatically map from subcommand to
implementation.
Includes support for namespace ensemble
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests/ensemble.test')
-rw-r--r-- | tests/ensemble.test | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/ensemble.test b/tests/ensemble.test new file mode 100644 index 0000000..507cd20 --- /dev/null +++ b/tests/ensemble.test @@ -0,0 +1,47 @@ +source [file dirname [info script]]/testing.tcl + +needs constraint jim +needs package ensemble + +# Let's create some procs for our ensembles + +proc {foo a} {x} { + incr x +} +proc {foo b} {y} { + incr y 2 +} +test ensemble-1.1 {Basic ensemble} { + ensemble foo + foo a 5 +} 6 + +test ensemble-1.2 {ensemble -commands} { + foo -commands +} {a b} + +test ensemble-1.3 {ensemble -help} { + foo -help +} {Usage: "foo command ... ", where command is one of: a, b} + +test ensemble-1.4 {ensemble with invalid subcommand} -body { + foo c x +} -returnCodes error -result {invalid command name "foo c"} + +test ensemble-1.5 {ensemble add new commands} { + proc {foo c} {z} { + append z @ + } + foo c x +} {x@} + +test ensemble-1.6 {ensemble remove mapping} -body { + rename {foo a} "" + foo a 4 +} -returnCodes error -result {invalid command name "foo a"} + +test ensemble-1.7 {ensemble updated -commands} { + foo -commands +} {b c} + +testreport |