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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
|
##########################################################################
# TEPAM - Tcl's Enhanced Procedure and Argument Manager
##########################################################################
#
# proc_subproc.test:
# This file is part of the enhanced procedure and argument manager's regression
# test. It validates the declaration and call of the procedure sub commands.
#
# Copyright (C) 2009, 2010 Andreas Drollinger
#
# Id: proc_subproc.test
##########################################################################
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
##########################################################################
source [file join \
[file dirname [file dirname [file join [pwd] [info script]]]] \
devtools testutilities.tcl]
testsNeedTcl 8.3
testsNeedTcltest 1.0
catch {namespace delete ::tepam}
testing {
useLocal tepam.tcl tepam
}
######## Main procedure and sub procedures, top-down declaration ########
# Declaration
test tepam-sp.dcl_td.dcl.1 "tepam, sub procedure top-down declaration - main procedure declaration" \
-body {tepam::procedure {MainProc1} {} {return Proc1}} \
-result "" -output ""
test tepam-sp.dcl_td.dcl.2 "tepam, sub procedure top-down declaration - first sub procedure declaration" \
-body {tepam::procedure {MainProc1 SubProc1} {} {return Proc11}} \
-result "" -output ""
test tepam-sp.dcl_td.dcl.3 "tepam, sub procedure top-down declaration - second sub procedure declaration" \
-body {tepam::procedure {MainProc1 SubProc2} {} {return Proc12}} \
-result "" -output ""
test tepam-sp.dcl_td.dcl.4 "tepam, sub procedure top-down declaration - sub sub procedure declaration" \
-body {tepam::procedure {MainProc1 SubProc2 SubProc22} {} {return Proc122}} \
-result "" -output ""
# Help
test tepam-sp.dcl_td.hlp.1 "tepam, sub procedure top-down declaration - main procedure help" \
-body {MainProc1 -help} \
-result "" -output {SYNOPSIS\s+MainProc1\s+MainProc1 SubProc1\s+MainProc1 SubProc2\s+MainProc1 SubProc2 SubProc22\s*$} -match regexp
test tepam-sp.dcl_td.hlp.2 "tepam, sub procedure top-down declaration - first sub procedure help" \
-body {MainProc1 SubProc1 -help} \
-result "" -output {SYNOPSIS\s+MainProc1 SubProc1\s+$} -match regexp
test tepam-sp.dcl_td.hlp.3 "tepam, sub procedure top-down declaration - second sub procedure help" \
-body {MainProc1 SubProc2 -help} \
-result "" -output {SYNOPSIS\s+MainProc1 SubProc2\s+MainProc1 SubProc2 SubProc22\s*$} -match regexp
test tepam-sp.dcl_td.hlp.4 "tepam, sub procedure top-down declaration - sub sub procedure help" \
-body {MainProc1 SubProc2 SubProc22 -help} \
-result "" -output {SYNOPSIS\s+MainProc1 SubProc2 SubProc22\s+$} -match regexp
# Execution
test tepam-sp.dcl_td.exe.1 "tepam, sub procedure top-down declaration - main procedure execution" \
-body {MainProc1} \
-result "Proc1" -output "" -match exact
test tepam-sp.dcl_td.exe.2 "tepam, sub procedure top-down declaration - first sub procedure execution" \
-body {MainProc1 SubProc1} \
-result "Proc11" -output "" -match exact
test tepam-sp.dcl_td.exe.3 "tepam, sub procedure top-down declaration - second sub procedure execution" \
-body {MainProc1 SubProc2} \
-result "Proc12" -output "" -match exact
test tepam-sp.dcl_td.exe.4 "tepam, sub procedure top-down declaration - sub sub procedure execution" \
-body {MainProc1 SubProc2 SubProc22} \
-result "Proc122" -output "" -match exact
######## Main procedure and sub procedures, buttom-up declaration ########
# Declaration
test tepam-sp.dcl_bu.dcl.1 "tepam, sub procedure buttom-up declaration - sub sub procedure declaration" \
-body {tepam::procedure {MainProc2 SubProc2 SubProc22} {} {return Proc222}} \
-result "" -output ""
test tepam-sp.dcl_bu.dcl.2 "tepam, sub procedure buttom-up declaration - second sub procedure declaration" \
-body {tepam::procedure {MainProc2 SubProc2} {} {return Proc22}} \
-result "" -output ""
test tepam-sp.dcl_bu.dcl.3 "tepam, sub procedure buttom-up declaration - first sub procedure declaration" \
-body {tepam::procedure {MainProc2 SubProc1} {} {return Proc21}} \
-result "" -output ""
test tepam-sp.dcl_bu.dcl.4 "tepam, sub procedure buttom-up declaration - main procedure declaration" \
-body {tepam::procedure {MainProc2} {} {return Proc2}} \
-result "" -output ""
# Help
test tepam-sp.dcl_bu.hlp.1 "tepam, sub procedure buttom-down declaration - main procedure help" \
-body {MainProc2 -help} \
-result "" -output {SYNOPSIS\s+MainProc2\s+MainProc2 SubProc1\s+MainProc2 SubProc2\s+MainProc2 SubProc2 SubProc22\s*$} -match regexp
test tepam-sp.dcl_bu.hlp.2 "tepam, sub procedure buttom-down declaration - first sub procedure help" \
-body {MainProc2 SubProc1 -help} \
-result "" -output {SYNOPSIS\s+MainProc2 SubProc1\s+$} -match regexp
test tepam-sp.dcl_bu.hlp.3 "tepam, sub procedure buttom-down declaration - second sub procedure help" \
-body {MainProc2 SubProc2 -help} \
-result "" -output {SYNOPSIS\s+MainProc2 SubProc2\s+MainProc2 SubProc2 SubProc22\s*$} -match regexp
test tepam-sp.dcl_bu.hlp.4 "tepam, sub procedure buttom-down declaration - sub sub procedure help" \
-body {MainProc2 SubProc2 SubProc22 -help} \
-result "" -output {SYNOPSIS\s+MainProc2 SubProc2 SubProc22\s+$} -match regexp
# Execution
test tepam-sp.dcl_bu.exe.1 "tepam, sub procedure buttom-up declaration - main procedure execution" \
-body {MainProc2} \
-result "Proc2" -output "" -match exact
test tepam-sp.dcl_bu.exe.2 "tepam, sub procedure buttom-up declaration - first sub procedure execution" \
-body {MainProc2 SubProc1} \
-result "Proc21" -output "" -match exact
test tepam-sp.dcl_bu.exe.3 "tepam, sub procedure buttom-up declaration - second sub procedure execution" \
-body {MainProc2 SubProc2} \
-result "Proc22" -output "" -match exact
test tepam-sp.dcl_bu.exe.4 "tepam, sub procedure buttom-up declaration - sub sub procedure execution" \
-body {MainProc2 SubProc2 SubProc22} \
-result "Proc222" -output "" -match exact
######## Only sub procedures (no main procedure) ########
# Declaration
test tepam-sp.dcl_sc.dcl.1 "tepam, sub procedure without main procedure - first sub procedure declaration" \
-body {tepam::procedure {MainProc3 SubProc1} {} {return Proc31}} \
-result "" -output ""
test tepam-sp.dcl_sc.dcl.2 "tepam, sub procedure without main procedure - second sub procedure declaration" \
-body {tepam::procedure {MainProc3 SubProc2} {} {return Proc32}} \
-result "" -output ""
test tepam-sp.dcl_sc.dcl.3 "tepam, sub procedure without main procedure - sub sub procedure declaration" \
-body {tepam::procedure {MainProc3 SubProc2 SubProc22} {} {return Proc322}} \
-result "" -output ""
# Help
test tepam-sp.dcl_sc.hlp.1 "tepam, sub procedure without main procedure - main procedure help" \
-body {MainProc3 -help} \
-result "" -output {SYNOPSIS\s+MainProc3 SubProc1\s+MainProc3 SubProc2\s+MainProc3 SubProc2 SubProc22\s*$} -match regexp
test tepam-sp.dcl_sc.hlp.2 "tepam, sub procedure without main procedure - first sub procedure help" \
-body {MainProc3 SubProc1 -help} \
-result "" -output {SYNOPSIS\s+MainProc3 SubProc1\s+$} -match regexp
test tepam-sp.dcl_sc.hlp.3 "tepam, sub procedure without main procedure - second sub procedure help" \
-body {MainProc3 SubProc2 -help} \
-result "" -output {SYNOPSIS\s+MainProc3 SubProc2\s+MainProc3 SubProc2 SubProc22\s*$} -match regexp
test tepam-sp.dcl_sc.hlp.4 "tepam, sub procedure without main procedure - sub sub procedure help" \
-body {MainProc3 SubProc2 SubProc22 -help} \
-result "" -output {SYNOPSIS\s+MainProc3 SubProc2 SubProc22\s+$} -match regexp
# Execution
test tepam-sp.dcl_sc.exe.1 "tepam, sub procedure without main procedure - main procedure execution" \
-body {MainProc3} \
-returnCodes error -result {'::MainProc3' requires a subcommand} -output "" -match exact
test tepam-sp.dcl_sc.exe.2 "tepam, sub procedure without main procedure - first sub procedure execution" \
-body {MainProc3 SubProc1} \
-result "Proc31" -output "" -match exact
test tepam-sp.dcl_sc.exe.3 "tepam, sub procedure without main procedure - second sub procedure execution" \
-body {MainProc3 SubProc2} \
-result "Proc32" -output "" -match exact
test tepam-sp.dcl_sc.exe.4 "tepam, sub procedure without main procedure - sub sub procedure execution" \
-body {MainProc3 SubProc2 SubProc22} \
-result "Proc322" -output "" -match exact
######## Specific tests about the help text ########
namespace eval ::TestNS {
tepam::procedure {MainProc4} {
-description "DescrMain"
-args { {a0 -description "MainProc4 arg"} }
-example {TestNS::MainProc4 "Hello0"}
} {}
tepam::procedure {MainProc4 SubProc1} {
-description "DescrSub1"
-args { {a1 -description "DescrSub1 arg"} }
-example {TestNS::MainProc4 DescrSub1 "Hello1"}
} {}
tepam::procedure {MainProc4 SubProc2} {
-description "DescrSub2"
-args { {a2 -description "DescrSub2 arg"} }
-example {TestNS::MainProc4 DescrSub2 "Hello2"}
} {}
tepam::procedure {MainProc4 SubProc3} {
-description "DescrSub3"
-args { {a3 -description "DescrSub3 arg"} }
-example {TestNS::MainProc4 DescrSub3 "Hello3"}
} {}
tepam::procedure {MainProc4 SubProc3 SubSubProc31} {
-description "SubSubProc31"
-args { {a31 -description "DescrSubSub31 arg"} }
-example {TestNS::MainProc4 DescrSub3 SubSubProc31 "Hello31"}
} {}
}
test tepam-sp.help_main "tepam, main, sub and sub-sub procedures, help main" \
-body {::TestNS::MainProc4 -help} \
-result "" -output [join {
{NAME}
{ TestNS::MainProc4}
{SYNOPSIS}
{ TestNS::MainProc4}
{ <a0>}
{ MainProc4 arg}
{ TestNS::MainProc4 SubProc1}
{ <a1>}
{ DescrSub1 arg}
{ TestNS::MainProc4 SubProc2}
{ <a2>}
{ DescrSub2 arg}
{ TestNS::MainProc4 SubProc3}
{ <a3>}
{ DescrSub3 arg}
{ TestNS::MainProc4 SubProc3 SubSubProc31}
{ <a31>}
{ DescrSubSub31 arg}
{DESCRIPTION}
{ TestNS::MainProc4}
{ DescrMain}
{ TestNS::MainProc4 SubProc1}
{ DescrSub1}
{ TestNS::MainProc4 SubProc2}
{ DescrSub2}
{ TestNS::MainProc4 SubProc3}
{ DescrSub3}
{ TestNS::MainProc4 SubProc3 SubSubProc31}
{ SubSubProc31}
{EXAMPLE}
{ TestNS::MainProc4}
{ TestNS::MainProc4 "Hello0"}
{ TestNS::MainProc4 SubProc1}
{ TestNS::MainProc4 DescrSub1 "Hello1"}
{ TestNS::MainProc4 SubProc2}
{ TestNS::MainProc4 DescrSub2 "Hello2"}
{ TestNS::MainProc4 SubProc3}
{ TestNS::MainProc4 DescrSub3 "Hello3"}
{ TestNS::MainProc4 SubProc3 SubSubProc31}
{ TestNS::MainProc4 DescrSub3 SubSubProc31 "Hello31"}
{} {}
} "\n"]
test tepam-sp.help_sp1 "tepam, main, sub and sub-sub procedures, help sub-proc 1" \
-body {::TestNS::MainProc4 SubProc1 -help} \
-result "" -output [join {
{NAME}
{ TestNS::MainProc4 SubProc1}
{SYNOPSIS}
{ TestNS::MainProc4 SubProc1}
{ <a1>}
{ DescrSub1 arg}
{DESCRIPTION}
{ DescrSub1}
{EXAMPLE}
{ TestNS::MainProc4 DescrSub1 "Hello1"}
{} {}
} "\n"]
test tepam-sp.help_sp3 "tepam, main, sub and sub-sub procedures, help sub-proc 3" \
-body {::TestNS::MainProc4 SubProc3 -help} \
-result "" -output [join {
{NAME}
{ TestNS::MainProc4 SubProc3}
{SYNOPSIS}
{ TestNS::MainProc4 SubProc3}
{ <a3>}
{ DescrSub3 arg}
{ TestNS::MainProc4 SubProc3 SubSubProc31}
{ <a31>}
{ DescrSubSub31 arg}
{DESCRIPTION}
{ TestNS::MainProc4 SubProc3}
{ DescrSub3}
{ TestNS::MainProc4 SubProc3 SubSubProc31}
{ SubSubProc31}
{EXAMPLE}
{ TestNS::MainProc4 SubProc3}
{ TestNS::MainProc4 DescrSub3 "Hello3"}
{ TestNS::MainProc4 SubProc3 SubSubProc31}
{ TestNS::MainProc4 DescrSub3 SubSubProc31 "Hello31"}
{} {}
} "\n"]
test tepam-sp.help_sp31 "tepam, main, sub and sub-sub procedures, help sub-sub-proc 3" \
-body {::TestNS::MainProc4 SubProc3 SubSubProc31 -help} \
-result "" -output [join {
{NAME}
{ TestNS::MainProc4 SubProc3 SubSubProc31}
{SYNOPSIS}
{ TestNS::MainProc4 SubProc3 SubSubProc31}
{ <a31>}
{ DescrSubSub31 arg}
{DESCRIPTION}
{ SubSubProc31}
{EXAMPLE}
{ TestNS::MainProc4 DescrSub3 SubSubProc31 "Hello31"}
{} {}
} "\n"]
######## With one unnamed argument ########
######## That's all ########
::tcltest::cleanupTests
return
##########################################################################
# Id: proc_subproc.test
# Modifications:
#
# Revision 2015/03/05 21:50:55 droll
# * Added a test to detect failures in generated help text for procedures that contain sub-commands.
#
# Revision 2010/02/11 21:50:55 droll
# * TEPAM module checkin
##########################################################################
|