aboutsummaryrefslogtreecommitdiff
path: root/tests/ensemble.test
blob: 3ad60a20d7f2f959d4c946d09d9e05dc7dcc0974 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# vim:se syntax=tcl:
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