cmdr
Check-in [2fa5347d94]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:cmdr::ask - Added basic testsuite. More requires a linenoise mockup to prevent actual interaction while exercising the command implementation.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2fa5347d9428a0a97b934cb47625625b94858649
User & Date: andreask 2014-05-23 22:08:15
Original Comment: cmdr::ask - Added basic testsuite. More requires a linenoise mockup to prevent actual interaction.
References
2014-05-23
22:19 Closed ticket [a80ac87036]: Add facilities for user interaction plus 4 other changes artifact: 7ab7393038 user: aku
Context
2014-05-26
17:19
cmdr::color - Need -prefixes 0 to avoid name/names clash. check-in: 27ba981e40 user: aku tags: trunk
2014-05-23
22:08
cmdr::ask - Added basic testsuite. More requires a linenoise mockup to prevent actual interaction while exercising the command implementation. check-in: 2fa5347d94 user: andreask tags: trunk
21:51
cmdr::ask - Fixed a syntax problem. Fixed scope issue (string command). Tweaked the prompt setup. Plus example apps (also for interactive testing). check-in: 1eeef53431 user: andreask tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added tests/ask.test.










































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# -*- tcl -*- tcl.tk//DSL tcltest//EN//2.0
# # ## ### ##### ######## ############# #####################
## Testing the cmdr::color package.

kt check Tcl     8.5
kt check tcltest 2

kt require support Tclx
kt require support debug
kt require support debug::caller
kt require support linenoise
kt require support try
kt require support struct::matrix
kt require support textutil::adjust

kt local   support cmdr::tty
kt local   support cmdr::color
kt local   testing cmdr::ask

# # ## ### ##### ######## ############# #####################
## Basic wrong#args checks.

test cmdr-ask-1.0 {ask, wrong num args, not enough} -body {
    cmdr ask
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask subcommand ?argument ...?"}

test cmdr-ask-1.1 {ask, bogus sub-command, not enough args} -body {
    cmdr ask foo
} -returnCodes error \
    -result {unknown or ambiguous subcommand "foo": must be choose, menu, string, string*, string/extended, or yn}

# # ## ### ##### ######## ############# #####################
## Go through the API commands.
## yn, string, string*, string/extended, menu, choose
#
## Only basic args checks. Everything else goes into interaction,
## which the tcltest is not suited for.
#
## Idea: Replace linenoise with a mockup command to record calls and
## returns fixed results.

# # ## ### ##### ######## ############# #####################
## yn

test cmdr-ask-yn-1.0 {ask, wrong num args, not enough} -body {
    cmdr ask yn
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask yn query ?default?"}

test cmdr-ask-yn-1.1 {ask, wrong num args, too many} -body {
    cmdr ask yn Q D X
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask yn query ?default?"}

# # ## ### ##### ######## ############# #####################
## string

test cmdr-ask-string-1.0 {ask, wrong num args, not enough} -body {
    cmdr ask string
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask string query ?default?"}

test cmdr-ask-string-1.1 {ask, wrong num args, too many} -body {
    cmdr ask string Q D X
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask string query ?default?"}

# # ## ### ##### ######## ############# #####################
## string*

test cmdr-ask-string*-1.0 {ask, wrong num args, not enough} -body {
    cmdr ask string*
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask string* query"}

test cmdr-ask-string*-1.1 {ask, wrong num args, too many} -body {
    cmdr ask string* Q X
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask string* query"}

# # ## ### ##### ######## ############# #####################
## string/extended

test cmdr-ask-string/extended-1.0 {ask, wrong num args, not enough} -body {
    cmdr ask string/extended
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask string/extended query ..."}

# # ## ### ##### ######## ############# #####################
## choose

test cmdr-ask-choose-1.0 {ask, wrong num args, not enough} -body {
    cmdr ask choose
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask choose query choices ?default?"}

test cmdr-ask-choose-1.1 {ask, wrong num args, not enough} -body {
    cmdr ask choose Q
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask choose query choices ?default?"}

test cmdr-ask-choose-1.2 {ask, wrong num args, too many} -body {
    cmdr ask choose Q C D X
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask choose query choices ?default?"}

# # ## ### ##### ######## ############# #####################
## menu

test cmdr-ask-menu-1.0 {ask, wrong num args, not enough} -body {
    cmdr ask menu
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask menu header prompt choices ?default?"}

test cmdr-ask-menu-1.1 {ask, wrong num args, not enough} -body {
    cmdr ask menu H
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask menu header prompt choices ?default?"}

test cmdr-ask-menu-1.2 {ask, wrong num args, not enough} -body {
    cmdr ask menu H P
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask menu header prompt choices ?default?"}

test cmdr-ask-menu-1.3 {ask, wrong num args, too many} -body {
    cmdr ask menu H P C D X
} -returnCodes error \
    -result {wrong # args: should be "cmdr ask menu header prompt choices ?default?"}

# # ## ### ##### ######## ############# #####################
cleanupTests
return