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 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
|
##########################################################################
# TEPAM - Tcl's Enhanced Procedure and Argument Manager
##########################################################################
#
# proc_call_arg_unn.test:
# This file is part of the enhanced procedure and argument manager's regression
# test. It validates the usage of the different combinations of named and
# unnamed arguments using the non-default argument organization (unnamed
# arguments first, named at the end).
#
# Copyright (C) 2009, 2010 Andreas Drollinger
#
# Id: proc_call_arg_unn.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.5
testsNeedTcltest 1.0
catch {namespace delete ::tepam}
testing {
useLocal tepam.tcl tepam
}
set tepam::named_arguments_first 0
# Tests is an extension of the test command. It adds the option -variations that allows \
# specifying a list values. For each of these values the test command is executed, replacing all '%1'
# of the original test command string by the altered value.
proc tests {name description args} {
set VariationList(0) {""}; # Default variation list 0, in case no variations are required
for {set NbrVariationLists 0} {1} {incr NbrVariationLists} {
set VariationListPos [lsearch -exact $args -variations]
if {$VariationListPos<0} break
set VariationList($NbrVariationLists) [lindex $args [expr $VariationListPos+1]]
set args [lreplace $args $VariationListPos [expr $VariationListPos+1]]
}
for {set TestNbr 0} {$TestNbr<[llength $VariationList(0)]} {incr TestNbr} {
set TestExec "test \"$name\.$TestNbr\" \"$description.$TestNbr\""
foreach Arg $args {
set NewArg $Arg
for {set vl 0} {$vl<$NbrVariationLists} {incr vl} {
regsub -all "%[expr $vl+1]" $NewArg [lindex $VariationList($vl) $TestNbr] NewArg
}
append TestExec " \{$NewArg\}"
}
uplevel 1 $TestExec
}
}
######## Argument combinations ########
# Unnamed arguments first: No arguments:
tepam::procedure Procedure_Arg_0a {-args {}} {return ""}
tepam::procedure Procedure_Arg_0b {} {return ""}
foreach c {a b} {
tests tepam-proccall.unn.noarg.$c.0 "Procedure calls, UNN, no arguments defined, $c, 0" \
-body "Procedure_Arg_0$c" \
-result "" -output ""
tests tepam-proccall.unn.noarg.$c.1 "Procedure calls, UNN, no arguments defined, $c, 1" \
-variations { Parameter2 {""} ?} \
-body "Procedure_Arg_0$c %1" \
-returnCodes error -result "*Too many arguments:*" -output "" -match glob
tests tepam-proccall.unn.noarg.$c.2 "Procedure calls, UNN, no arguments defined, $c, 2" \
-variations { -Parameter2} \
-body "Procedure_Arg_0$c -- %1" \
-returnCodes error -result "*Too many arguments:*" -output "" -match glob
tests tepam-proccall.unn.noarg.$c.3 "Procedure calls, UNN, no arguments defined, $c, 3" \
-variations { -Parameter2} \
-body "Procedure_Arg_0$c %1" \
-returnCodes error -result "*Too many arguments:*" -output "" -match glob
}
# Unnamed argument (1) without default value:
tepam::procedure Procedure_Arg_1 {
-args {
{Arg1}
}
} {
return "Arg1:$Arg1"
}
tests tepam-proccall.unn.1un.0 "Procedure calls, UNN, one argument without default value, 0" \
-body "Procedure_Arg_1" \
-returnCodes error -result "*Required argument is missing: Arg1*" -output "" -match glob
tests tepam-proccall.unn.1un.1 "Procedure calls, UNN, one argument without default value, 1" \
-body "Procedure_Arg_1 --" \
-result "Arg1:--" -output ""
tests tepam-proccall.unn.1un.2 "Procedure calls, UNN, one argument without default value, 2" \
-variations {abc 123 {} {asd asdf {xx 123 34}} } \
-body "Procedure_Arg_1 \"%1\"" \
-result "Arg1:%1" -output ""
tests tepam-proccall.unn.1un.3 "Procedure calls, UNN, one argument without default value, 3" \
-variations {abc 123 "" "{asd asdf {xx 123 34}}"} \
-body "Procedure_Arg_1 -- \"%1\"" \
-returnCodes error -result "*: Too many arguments:*" -output "" -match glob
tests tepam-proccall.unn.1un.4 "Procedure calls, UNN, one argument without default value, 4" \
-variations { abc 123 "" "{asd asdf {xx 123 34}}"} \
-body "Procedure_Arg_1 -Arg1 \"%1\"" \
-returnCodes error -result "*: Too many arguments:*" -output "" -match glob
tests tepam-proccall.unn.1un.5 "Procedure calls, UNN, one argument without default value, 5" \
-variations { abc 123 "" "{asd asdf {xx 123 34}}"} \
-body "Procedure_Arg_1 -Arg1 \"%1\" --" \
-returnCodes error -result "*: Too many arguments:*" -output "" -match glob
tests tepam-proccall.unn.1un.6 "Procedure calls, UNN, one argument without default value, 6" \
-variations { Parameter2 "" ?} \
-body "Procedure_Arg_1 Parameter1 \"%1\"" \
-returnCodes error -result "*: Too many arguments:*" -output "" -match glob
tests tepam-proccall.unn.1un.7 "Procedure calls, UNN, one argument without default value, 7" \
-variations { -Parameter2} \
-body "Procedure_Arg_1 Parameter1 \"%1\"" \
-returnCodes error -result "*: Too many arguments:*" -output "" -match glob
tests tepam-proccall.unn.1un.8 "Procedure calls, UNN, one argument without default value, 8" \
-variations { -Parameter2} \
-body "Procedure_Arg_1 -- Parameter1 \"%1\"" \
-returnCodes error -result "*: Too many arguments:*" -output "" -match glob
# Unnamed arguments (2) without default value:
tepam::procedure Procedure_Arg_2b {
-args {
{Arg1}
{Arg2}
}
} {
return "Arg1:$Arg1, Arg2:$Arg2"
}
tests tepam-proccall.unn.2un.0 "Procedure calls, UNN, two argument without default value, 0" \
-body "Procedure_Arg_2b" \
-returnCodes error -result "*: Required argument is missing: Arg1" -output "" -match glob
tests tepam-proccall.unn.2un.1 "Procedure calls, UNN, two argument without default value, 0" \
-body "Procedure_Arg_2b --" \
-returnCodes error -result "*: Required argument is missing: Arg2" -output "" -match glob
tests tepam-proccall.unn.2un.2 "Procedure calls, UNN, two argument without default value, 0" \
-variations { abc 123 "" "{asd asdf {xx 123 34}}"} \
-body "Procedure_Arg_2b \"%1\"" \
-returnCodes error -result "*: Required argument is missing: Arg2" -output "" -match glob
tests tepam-proccall.unn.2un.3 "Procedure calls, UNN, two argument without default value, 0" \
-variations {a "" {}} \
-variations {b "" 123} \
-body "Procedure_Arg_2b \"%1\" \"%2\"" \
-result "Arg1:%1, Arg2:%2" -output ""
# Unnamed arguments partitially with default value:
tepam::procedure Procedure_Arg_2 {
-args {
{Arg1}
{Arg2 -default 2}
}
} {
return "Arg1:$Arg1, Arg2:$Arg2"
}
tests tepam-proccall.unn.1dun1un.0 "Procedure calls, UNN, two argument, one with default value, 0" \
-body "Procedure_Arg_2" \
-returnCodes error -result "*: Required argument is missing: Arg1*" -output "" -match glob
tests tepam-proccall.unn.1dun1un.1 "Procedure calls, UNN, two argument, one with default value, 0" \
-variations {abc 123 "" {asd asdf {xx 123 34}}} \
-body "Procedure_Arg_2 \"%1\"" \
-result "Arg1:%1, Arg2:2" -output ""
tests tepam-proccall.unn.1dun1un.2 "Procedure calls, UNN, two argument, one with default value, 0" \
-variations { Parameter2 -Parameter2 "" ?} \
-body "Procedure_Arg_2 Parameter1 \"%1\"" \
-result "Arg1:Parameter1, Arg2:%1" -output ""
tests tepam-proccall.unn.1dun1un.3 "Procedure calls, UNN, two argument, one with default value, 0" \
-variations { Parameter2 "" ?} \
-body "Procedure_Arg_2 Parameter1 Parameter2 \"%1\"" \
-returnCodes error -result "*: Too many arguments:*" -output "" -match glob
tests tepam-proccall.unn.1dun1un.4 "Procedure calls, UNN, two argument, one with default value, 0" \
-variations { -Parameter2} \
-body "Procedure_Arg_2 Parameter1 Parameter2 \"%1\"" \
-returnCodes error -result "*: Too many arguments:*" -output "" -match glob
# Unnamed arguments with default value:
tepam::procedure Procedure_Arg_2a {
-args {
{Arg1 -default 1}
{Arg2 -default 2}
}
} {
return "Arg1:$Arg1, Arg2:$Arg2"
}
tests tepam-proccall.unn.2dun.0 "Procedure calls, UNN, two argument with default values, 0" \
-body "Procedure_Arg_2a" \
-result "Arg1:1, Arg2:2" -output ""
tests tepam-proccall.unn.2dun.1 "Procedure calls, UNN, two argument with default values, 0" \
-variations { abc 123 "" "{asd asdf {xx 123 34}}"} \
-body "Procedure_Arg_2a \"%1\"" \
-result "Arg1:%1, Arg2:2" -output ""
tests tepam-proccall.unn.2dun.2 "Procedure calls, UNN, two argument with default values, 0" \
-variations { Parameter2 -Parameter2 "" ?} \
-body "Procedure_Arg_2a Parameter1 \"%1\"" \
-result "Arg1:Parameter1, Arg2:%1" -output ""
tests tepam-proccall.unn.2dun.3 "Procedure calls, UNN, two argument with default values, 0" \
-variations { Parameter2 "" ?} \
-body "Procedure_Arg_2a Parameter1 Parameter2 \"%1\"" \
-returnCodes error -result "*: Too many arguments:*" -output "" -match glob
tests tepam-proccall.unn.2dun.4 "Procedure calls, UNN, two argument with default values, 0" \
-variations { -Parameter2} \
-body "Procedure_Arg_2a Parameter1 Parameter2 \"%1\"" \
-returnCodes error -result "*: Too many arguments:*" -output "" -match glob
# One named and one unnamed argument, without default values (1)
tepam::procedure Procedure_Arg_2d {
-args {
{-Arg1}
{Arg2}
}
} {
return "Arg1:$Arg1, Arg2:$Arg2"
}
tests tepam-proccall.unn.1un1n.0 "Procedure calls, UNN, one unnamed and one named argument, 0" \
-body "Procedure_Arg_2d" \
-returnCodes error -result "*Required argument is missing: Arg1*" -output "" -match glob
tests tepam-proccall.unn.1un1n.1 "Procedure calls, UNN, one unnamed and one named argument, 1" \
-variations { abc 123 "" "{asd asdf {xx 123 34}}"} \
-body "Procedure_Arg_2d \"%1\"" \
-returnCodes error -result "*Required argument is missing: Arg1*" -output "" -match glob
tests tepam-proccall.unn.1un1n.2 "Procedure calls, UNN, one unnamed and one named argument, 2" \
-variations {a "" {}} \
-variations {b "" 123} \
-body "Procedure_Arg_2d \"%1\" \"%2\"" \
-returnCodes error -result "*is not an option*" -output "" -match glob
tests tepam-proccall.unn.1un1n.3 "Procedure calls, UNN, one unnamed and one named argument, 3" \
-variations {a "" {}} \
-variations {b "" 123} \
-body "Procedure_Arg_2d \"%2\" -Arg1 \"%1\"" \
-result "Arg1:%1, Arg2:%2" -output ""
tests tepam-proccall.unn.1un1n.4 "Procedure calls, UNN, one unnamed and one named argument, 4" \
-variations {a "" {}} \
-variations {b "" 123} \
-body "Procedure_Arg_2d -Arg1 \"%1\" -Arg2 \"%2\"" \
-returnCodes error -result "*is not an option*" -output "" -match glob
tests tepam-proccall.unn.1un1n.5 "Procedure calls, UNN, one unnamed and one named argument, 5" \
-variations {a "" {}} \
-variations {b "" 123} \
-body "Procedure_Arg_2d -Arg2 \"%2\" -Arg1 \"%1\"" \
-returnCodes error -result "*is not an option*" -output "" -match glob
# One named and one unnamed argument, without default values (2)
tepam::procedure Procedure_Arg_2e {
-args {
{Arg2}
{-Arg1}
}
} {
return "Arg1:$Arg1, Arg2:$Arg2"
}
tests tepam-proccall.unn.1un1n.6 "Procedure calls, UNN, one unnamed and one named argument, 6" \
-body "Procedure_Arg_2d" \
-returnCodes error -result "*: Required argument is missing: Arg1" -output "" -match glob
tests tepam-proccall.unn.1un1n.7 "Procedure calls, UNN, one unnamed and one named argument, 7" \
-variations { abc 123 "" "{asd asdf {xx 123 34}}"} \
-body "Procedure_Arg_2d \"%1\"" \
-returnCodes error -result "*Required argument is missing: Arg1*" -output "" -match glob
tests tepam-proccall.unn.1un1n.8 "Procedure calls, UNN, one unnamed and one named argument, 8" \
-variations {a "" {}} \
-variations {b "" 123} \
-body "Procedure_Arg_2d \"%1\" \"%2\"" \
-returnCodes error -result "*is not an option*" -output "" -match glob
tests tepam-proccall.unn.1un1n.9 "Procedure calls, UNN, one unnamed and one named argument, 9" \
-variations {a "" {}} \
-variations {b "" 123} \
-body "Procedure_Arg_2d \"%2\" -Arg1 \"%1\"" \
-result "Arg1:%1, Arg2:%2" -output ""
tests tepam-proccall.unn.1un1n.10 "Procedure calls, UNN, one unnamed and one named argument, 10" \
-variations {a "" {}} \
-variations {b "" 123} \
-body "Procedure_Arg_2d -Arg1 \"%1\" -Arg2 \"%2\"" \
-returnCodes error -result "*is not an option*" -output "" -match glob
tests tepam-proccall.unn.1un1n.11 "Procedure calls, UNN, one unnamed and one named argument, 11" \
-variations {a "" {}} \
-variations {b "" 123} \
-body "Procedure_Arg_2d -Arg2 \"%2\" -Arg1 \"%1\"" \
-returnCodes error -result "*is not an option*" -output "" -match glob
# Two named arguments, without default values
tepam::procedure Procedure_Arg_2c {
-args {
{-Arg1}
{-Arg2}
}
} {
return "Arg1:$Arg1, Arg2:$Arg2"
}
tests tepam-proccall.unn.2n.0 "Procedure calls, UNN, two named argument, 0" \
-body "Procedure_Arg_2c" \
-returnCodes error -result "*Required argument is missing: Arg1*" -output "" -match glob
tests tepam-proccall.unn.2n.1 "Procedure calls, UNN, two named argument, 1" \
-variations { abc 123 "" "{asd asdf {xx 123 34}}"} \
-body "Procedure_Arg_2c -Arg1 \"%1\"" \
-returnCodes error -result "*Required argument is missing: Arg2*" -output "" -match glob
tests tepam-proccall.unn.2n.2 "Procedure calls, UNN, two named argument, 2" \
-variations {a "" {}} \
-variations {b "" 123} \
-body "Procedure_Arg_2c -Arg1 \"%1\" -Arg2 \"%2\"" \
-result "Arg1:%1, Arg2:%2" -output ""
tests tepam-proccall.unn.2n.3 "Procedure calls, UNN, two named argument, 3" \
-variations {a "" {}} \
-variations {b "" 123} \
-body "Procedure_Arg_2c -Arg2 \"%2\" -Arg1 \"%1\"" \
-result "Arg1:%1, Arg2:%2" -output ""
tests tepam-proccall.unn.2n.4 "Procedure calls, UNN, two named argument, 4" \
-variations {a "" {}} \
-variations {b "" 123} \
-variations {c "" {}} \
-body "Procedure_Arg_2c \"%3\" -Arg1 \"%1\" -Arg2 \"%2\"" \
-returnCodes error -result "*is not an option*" -output "" -match glob
# Multiple arguments - One unnamed argument
tepam::procedure Procedure_Multiple_Arg1 {
-args {
{Arg -multiple}
}
} {
return $Arg
}
tests tepam-proccall.unn.1mu.0 "Procedure calls, UNN, one unnamed multiple argument, 0" \
-body "Procedure_Multiple_Arg1" \
-returnCodes error -result "*Required argument is missing: Arg*" -output "" -match glob
tests tepam-proccall.unn.1mu.1 "Procedure calls, UNN, one unnamed multiple argument, 1" \
-body "Procedure_Multiple_Arg1 Hello" \
-result "Hello" -output ""
tests tepam-proccall.unn.1mu.2 "Procedure calls, UNN, one unnamed multiple argument, 2" \
-body "Procedure_Multiple_Arg1 {Hello world}" \
-result "{Hello world}" -output ""
tests tepam-proccall.unn.1mu.3 "Procedure calls, UNN, one unnamed multiple argument, 3" \
-body "Procedure_Multiple_Arg1 {Hello my} world" \
-result "{Hello my} world" -output ""
tests tepam-proccall.unn.1mu.4 "Procedure calls, UNN, one unnamed multiple argument, 4" \
-body "Procedure_Multiple_Arg1 Hello {my world}" \
-result "Hello {my world}" -output ""
tests tepam-proccall.unn.1mu.5 "Procedure calls, UNN, one unnamed multiple argument, 5" \
-body "Procedure_Multiple_Arg1 {Hello my} {nice world}" \
-result "{Hello my} {nice world}" -output ""
tests tepam-proccall.unn.1mu.6 "Procedure calls, UNN, one unnamed multiple argument, 6" \
-body "Procedure_Multiple_Arg1 {Hello my} {nice world,} {how are} you" \
-result "{Hello my} {nice world,} {how are} you" -output ""
# Multiple arguments - Two unnamed argument, both not optional
tepam::procedure Procedure_Multiple_Arg2a {
-args {
{Arg1}
{Arg2 -multiple}
}
} {
return $Arg1:$Arg2
}
tests tepam-proccall.unn.1mu1u.0 "Procedure calls, UNN, two unnamed argument, one is multiple, 0" \
-body "Procedure_Multiple_Arg2a" \
-returnCodes error -result "*Required argument is missing: Arg*" -output "" -match glob
tests tepam-proccall.unn.1mu1u.1 "Procedure calls, UNN, two unnamed argument, one is multiple, 1" \
-body "Procedure_Multiple_Arg2a Message" \
-returnCodes error -result "*Required argument is missing: Arg*" -output "" -match glob
tests tepam-proccall.unn.1mu1u.2 "Procedure calls, UNN, two unnamed argument, one is multiple, 2" \
-body "Procedure_Multiple_Arg2a Message Hello" \
-result "Message:Hello" -output ""
tests tepam-proccall.unn.1mu1u.3 "Procedure calls, UNN, two unnamed argument, one is multiple, 3" \
-body "Procedure_Multiple_Arg2a Message {Hello world}" \
-result "Message:{Hello world}" -output ""
tests tepam-proccall.unn.1mu1u.4 "Procedure calls, UNN, two unnamed argument, one is multiple, 4" \
-body "Procedure_Multiple_Arg2a Message Hello world" \
-result "Message:Hello world" -output ""
tests tepam-proccall.unn.1mu1u.5 "Procedure calls, UNN, two unnamed argument, one is multiple, 5" \
-body "Procedure_Multiple_Arg2a Message Hello all world" \
-result "Message:Hello all world" -output ""
tests tepam-proccall.unn.1mu1u.6 "Procedure calls, UNN, two unnamed argument, one is multiple, 6" \
-body "Procedure_Multiple_Arg2a Message {Hello my} world" \
-result "Message:{Hello my} world" -output ""
tests tepam-proccall.unn.1mu1u.7 "Procedure calls, UNN, two unnamed argument, one is multiple, 7" \
-body "Procedure_Multiple_Arg2a Message Hello {my world}" \
-result "Message:Hello {my world}" -output ""
tests tepam-proccall.unn.1mu1u.8 "Procedure calls, UNN, two unnamed argument, one is multiple, 8" \
-body "Procedure_Multiple_Arg2a Message {Hello my} {nice world}" \
-result "Message:{Hello my} {nice world}" -output ""
tests tepam-proccall.unn.1mu1u.9 "Procedure calls, UNN, two unnamed argument, one is multiple, 9" \
-body "Procedure_Multiple_Arg2a Message {Hello my} {nice world,} {how are} you" \
-result "Message:{Hello my} {nice world,} {how are} you" -output ""
# Multiple arguments - Two unnamed argument, the second is optinoal
tepam::procedure Procedure_Multiple_Arg2b {
-args {
{Arg1}
{Arg2 -default "" -multiple}
}
} {
return $Arg1:$Arg2
}
tests tepam-proccall.unn.1dmu1u.0 "Procedure calls, UNN, two unnamed argument, one has default and is multiple, 0" \
-body "Procedure_Multiple_Arg2b" \
-returnCodes error -result "*Required argument is missing: Arg*" -output "" -match glob
tests tepam-proccall.unn.1dmu1u.1 "Procedure calls, UNN, two unnamed argument, one has default and is multiple, 1" \
-body "Procedure_Multiple_Arg2b Message" \
-result "Message:" -output ""
tests tepam-proccall.unn.1dmu1u.2 "Procedure calls, UNN, two unnamed argument, one has default and is multiple, 2" \
-body "Procedure_Multiple_Arg2b Message Hello" \
-result "Message:Hello" -output ""
tests tepam-proccall.unn.1dmu1u.3 "Procedure calls, UNN, two unnamed argument, one has default and is multiple, 3" \
-body "Procedure_Multiple_Arg2b Message {Hello world}" \
-result "Message:{Hello world}" -output ""
tests tepam-proccall.unn.1dmu1u.4 "Procedure calls, UNN, two unnamed argument, one has default and is multiple, 4" \
-body "Procedure_Multiple_Arg2b Message Hello world" \
-result "Message:Hello world" -output ""
tests tepam-proccall.unn.1dmu1u.5 "Procedure calls, UNN, two unnamed argument, one has default and is multiple, 5" \
-body "Procedure_Multiple_Arg2b Message Hello all world" \
-result "Message:Hello all world" -output ""
# Multiple arguments - Two unnamed argument, both are optinoal
tepam::procedure Procedure_Multiple_Arg2c {
-args {
{Arg1 -default ""}
{Arg2 -default "" -multiple}
}
} {
return $Arg1:$Arg2
}
tests tepam-proccall.unn.1dmu1du.0 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 0" \
-body "Procedure_Multiple_Arg2c" \
-result ":" -output ""
tests tepam-proccall.unn.1dmu1du.1 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 1" \
-body "Procedure_Multiple_Arg2c Message" \
-result "Message:" -output ""
tests tepam-proccall.unn.1dmu1du.2 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 2" \
-body "Procedure_Multiple_Arg2c Message Hello" \
-result "Message:Hello" -output ""
tests tepam-proccall.unn.1dmu1du.3 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 3" \
-body "Procedure_Multiple_Arg2c Message {Hello world}" \
-result "Message:{Hello world}" -output ""
tests tepam-proccall.unn.1dmu1du.4 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 4" \
-body "Procedure_Multiple_Arg2c Message Hello world" \
-result "Message:Hello world" -output ""
tests tepam-proccall.unn.1dmu1du.5 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 5" \
-body "Procedure_Multiple_Arg2c Message Hello all world" \
-result "Message:Hello all world" -output ""
tests tepam-proccall.unn.1dmu1du.6 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 6" \
-body "Procedure_Multiple_Arg2c Message \"Hello all\" world" \
-result "Message:{Hello all} world" -output ""
tests tepam-proccall.unn.1dmu1du.7 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 7" \
-body "Procedure_Multiple_Arg2c Message Hello \"all world\"" \
-result "Message:Hello {all world}" -output ""
# Multiple arguments - Two named arguments
tepam::procedure Procedure_Multiple_Arg1 {
-args {
{-Arg1 -multiple}
{-Arg2 -multiple}
}
} {
return "$Arg1:$Arg2"
}
tests tepam-proccall.unn.2mu.0 "Procedure calls, UNN, two unnamed argument that are multiple, 0" \
-body "Procedure_Multiple_Arg1" \
-returnCodes error -result "*Required argument is missing: Arg1*" -output "" -match glob
tests tepam-proccall.unn.2mu.1 "Procedure calls, UNN, two unnamed argument that are multiple, 1" \
-body "Procedure_Multiple_Arg1 -Arg1 Hello" \
-returnCodes error -result "*Required argument is missing: Arg2*" -output "" -match glob
tests tepam-proccall.unn.2mu.2 "Procedure calls, UNN, two unnamed argument that are multiple, 2" \
-body "Procedure_Multiple_Arg1 -Arg1 Hello -Arg2 world" \
-result "Hello:world" -output ""
tests tepam-proccall.unn.2mu.3 "Procedure calls, UNN, two unnamed argument that are multiple, 3" \
-body "Procedure_Multiple_Arg1 -Arg1 \"\" -Arg2 \"Hello world\"" \
-result "{}:{Hello world}" -output ""
tests tepam-proccall.unn.2mu.4 "Procedure calls, UNN, two unnamed argument that are multiple, 4" \
-body "Procedure_Multiple_Arg1 -Arg1 \"\" -Arg2 Hello -Arg2 world" \
-result "{}:Hello world" -output ""
tests tepam-proccall.unn.2mu.5 "Procedure calls, UNN, two unnamed argument that are multiple, 5" \
-body "Procedure_Multiple_Arg1 -Arg1 \"\" -Arg2 Hello -Arg2 all -Arg2 world" \
-result "{}:Hello all world" -output ""
# Multiple arguments - One named argument
tepam::procedure Procedure_Multiple_Arg3 {
-args {
{-Arg -multiple}
}
} {
return $Arg
}
tests tepam-proccall.unn.1mn.0 "Procedure calls, UNN, one named multiple argument, 0" \
-body "Procedure_Multiple_Arg3" \
-returnCodes error -result "*Required argument is missing: Arg*" -output "" -match glob
tests tepam-proccall.unn.1mn.1 "Procedure calls, UNN, one named multiple argument, 1" \
-body "Procedure_Multiple_Arg3 -Arg Hello" \
-result "Hello" -output ""
tests tepam-proccall.unn.1mn.2 "Procedure calls, UNN, one named multiple argument, 2" \
-body "Procedure_Multiple_Arg3 -Arg Hello world" \
-returnCodes error -result "*Argument 'world' is not an option*" -output "" -match glob
tests tepam-proccall.unn.1mn.3 "Procedure calls, UNN, one named multiple argument, 3" \
-body "Procedure_Multiple_Arg3 -Arg {Hello world}" \
-result "{Hello world}" -output ""
tests tepam-proccall.unn.1mn.4 "Procedure calls, UNN, one named multiple argument, 4" \
-body "Procedure_Multiple_Arg3 -Arg Hello -Arg world" \
-result "Hello world" -output ""
tests tepam-proccall.unn.1mn.5 "Procedure calls, UNN, one named multiple argument, 5" \
-body "Procedure_Multiple_Arg3 -Arg {Hello my} -Arg world" \
-result "{Hello my} world" -output ""
tests tepam-proccall.unn.1mn.6 "Procedure calls, UNN, one named multiple argument, 6" \
-body "Procedure_Multiple_Arg3 -Arg Hello -Arg {my world}" \
-result "Hello {my world}" -output ""
tests tepam-proccall.unn.1mn.7 "Procedure calls, UNN, one named multiple argument, 7" \
-body "Procedure_Multiple_Arg3 -Arg {Hello my} -Arg {nice world}" \
-result "{Hello my} {nice world}" -output ""
tests tepam-proccall.unn.1mn.8 "Procedure calls, UNN, one named multiple argument, 8" \
-body "Procedure_Multiple_Arg3 -Arg {Hello my} -Arg {nice world,} -Arg {how are} -Arg you" \
-result "{Hello my} {nice world,} {how are} you" -output ""
######## That's all ########
::tcltest::cleanupTests
return
##########################################################################
# Id: proc_call_arg_unn.test
# Modifications:
#
# Revision 1.1 2010/02/11 21:50:55 droll
# * TEPAM module checkin
##########################################################################
|