1##########################################################################
2# TEPAM - Tcl's Enhanced Procedure and Argument Manager
3##########################################################################
4#
5# proc_call_arg_unn.test:
6# This file is part of the enhanced procedure and argument manager's regression
7# test. It validates the usage of the different combinations of named and
8# unnamed arguments using the non-default argument organization (unnamed 
9# arguments first, named at the end).
10#
11# Copyright (C) 2009, 2010 Andreas Drollinger
12# 
13# RCS: @(#) $Id: proc_call_arg_unn.test,v 1.1 2010/02/11 21:50:55 droll Exp $
14##########################################################################
15# See the file "license.terms" for information on usage and redistribution
16# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
17##########################################################################
18
19source [file join \
20   [file dirname [file dirname [file join [pwd] [info script]]]] \
21   devtools testutilities.tcl]
22
23testsNeedTcl     8.3
24testsNeedTcltest 1.0
25
26catch {namespace delete ::tepam}
27testing {
28   useLocal tepam.tcl tepam
29}
30set tepam::named_arguments_first 0
31
32# Tests is an extension of the test command. It adds the option -variations that allows \
33# specifying a list values. For each of these values the test command is executed, replacing all '%1' 
34# of the original test command string by the altered value.
35proc tests {name description args} {
36   set VariationList(0) {""}; # Default variation list 0, in case no variations are required
37   for {set NbrVariationLists 0} {1} {incr NbrVariationLists} {
38      set VariationListPos [lsearch -exact $args -variations]
39      if {$VariationListPos<0} break
40      set VariationList($NbrVariationLists) [lindex $args [expr $VariationListPos+1]]
41      set args [lreplace $args $VariationListPos [expr $VariationListPos+1]]
42   }
43   for {set TestNbr 0} {$TestNbr<[llength $VariationList(0)]} {incr TestNbr} {
44      set TestExec "test \"$name\.$TestNbr\" \"$description.$TestNbr\""
45      foreach Arg $args {
46         set NewArg $Arg
47         for {set vl 0} {$vl<$NbrVariationLists} {incr vl} {
48            regsub -all "%[expr $vl+1]" $NewArg [lindex $VariationList($vl) $TestNbr] NewArg
49         }
50         append TestExec " \{$NewArg\}"
51      }
52      uplevel 1 $TestExec
53   }
54}
55
56######## Argument combinations ########
57
58   # Unnamed arguments first: No arguments:
59
60      tepam::procedure Procedure_Arg_0a {-args {}} {return ""}
61      tepam::procedure Procedure_Arg_0b {} {return ""}
62
63      foreach c {a b} {
64         tests tepam-proccall.unn.noarg.$c.0 "Procedure calls, UNN, no arguments defined, $c, 0"  \
65               -body "Procedure_Arg_0$c" \
66               -result "" -output ""
67         tests tepam-proccall.unn.noarg.$c.1 "Procedure calls, UNN, no arguments defined, $c, 1"  \
68               -variations { Parameter2 {""} ?} \
69               -body "Procedure_Arg_0$c %1" \
70               -returnCodes error -result "*Too many arguments:*" -output "" -match glob
71         tests tepam-proccall.unn.noarg.$c.2 "Procedure calls, UNN, no arguments defined, $c, 2"  \
72               -variations { -Parameter2} \
73               -body "Procedure_Arg_0$c -- %1" \
74               -returnCodes error -result "*Too many arguments:*" -output "" -match glob
75         tests tepam-proccall.unn.noarg.$c.3 "Procedure calls, UNN, no arguments defined, $c, 3"  \
76               -variations { -Parameter2} \
77               -body "Procedure_Arg_0$c %1" \
78               -returnCodes error -result "*Too many arguments:*" -output "" -match glob
79      }
80
81   # Unnamed argument (1) without default value:
82
83      tepam::procedure Procedure_Arg_1 {
84         -args {
85            {Arg1}
86         }
87      } {
88         return "Arg1:$Arg1"
89      }
90   
91      tests tepam-proccall.unn.1un.0 "Procedure calls, UNN, one argument without default value, 0"  \
92            -body "Procedure_Arg_1" \
93            -returnCodes error -result "*Required argument is missing: Arg1*" -output "" -match glob
94      tests tepam-proccall.unn.1un.1 "Procedure calls, UNN, one argument without default value, 1"  \
95            -body "Procedure_Arg_1 --" \
96            -result "Arg1:--" -output ""
97      tests tepam-proccall.unn.1un.2 "Procedure calls, UNN, one argument without default value, 2"  \
98            -variations {abc 123 {} {asd asdf {xx 123 34}} } \
99            -body "Procedure_Arg_1 \"%1\"" \
100            -result "Arg1:%1" -output ""
101      tests tepam-proccall.unn.1un.3 "Procedure calls, UNN, one argument without default value, 3"  \
102            -variations {abc 123 "" "{asd asdf {xx 123 34}}"} \
103            -body "Procedure_Arg_1 -- \"%1\"" \
104            -returnCodes error -result "*: Too many arguments:*" -output "" -match glob
105      tests tepam-proccall.unn.1un.4 "Procedure calls, UNN, one argument without default value, 4"  \
106            -variations { abc 123 "" "{asd asdf {xx 123 34}}"} \
107            -body "Procedure_Arg_1 -Arg1 \"%1\"" \
108            -returnCodes error -result "*: Too many arguments:*" -output "" -match glob
109      tests tepam-proccall.unn.1un.5 "Procedure calls, UNN, one argument without default value, 5"  \
110            -variations { abc 123 "" "{asd asdf {xx 123 34}}"} \
111            -body "Procedure_Arg_1 -Arg1 \"%1\" --" \
112            -returnCodes error -result "*: Too many arguments:*" -output "" -match glob
113      tests tepam-proccall.unn.1un.6 "Procedure calls, UNN, one argument without default value, 6"  \
114            -variations { Parameter2 "" ?} \
115            -body "Procedure_Arg_1 Parameter1 \"%1\"" \
116            -returnCodes error -result "*: Too many arguments:*" -output "" -match glob
117      tests tepam-proccall.unn.1un.7 "Procedure calls, UNN, one argument without default value, 7"  \
118            -variations { -Parameter2} \
119            -body "Procedure_Arg_1 Parameter1 \"%1\"" \
120            -returnCodes error -result "*: Too many arguments:*" -output "" -match glob
121      tests tepam-proccall.unn.1un.8 "Procedure calls, UNN, one argument without default value, 8"  \
122            -variations { -Parameter2} \
123            -body "Procedure_Arg_1 -- Parameter1 \"%1\"" \
124            -returnCodes error -result "*: Too many arguments:*" -output "" -match glob
125
126   # Unnamed arguments (2) without default value:
127
128      tepam::procedure Procedure_Arg_2b {
129         -args {
130            {Arg1}
131            {Arg2}
132         }
133      } {
134         return "Arg1:$Arg1, Arg2:$Arg2"
135      }
136   
137      tests tepam-proccall.unn.2un.0 "Procedure calls, UNN, two argument without default value, 0"  \
138            -body "Procedure_Arg_2b" \
139            -returnCodes error -result "*: Required argument is missing: Arg1" -output "" -match glob
140      tests tepam-proccall.unn.2un.1 "Procedure calls, UNN, two argument without default value, 0"  \
141            -body "Procedure_Arg_2b --" \
142            -returnCodes error -result "*: Required argument is missing: Arg2" -output "" -match glob
143      tests tepam-proccall.unn.2un.2 "Procedure calls, UNN, two argument without default value, 0"  \
144            -variations { abc 123 "" "{asd asdf {xx 123 34}}"} \
145            -body "Procedure_Arg_2b \"%1\"" \
146            -returnCodes error -result "*: Required argument is missing: Arg2" -output "" -match glob
147      tests tepam-proccall.unn.2un.3 "Procedure calls, UNN, two argument without default value, 0"  \
148            -variations {a "" {}} \
149            -variations {b "" 123} \
150            -body "Procedure_Arg_2b  \"%1\"  \"%2\"" \
151            -result "Arg1:%1, Arg2:%2" -output ""
152
153   # Unnamed arguments partitially with default value:
154
155      tepam::procedure Procedure_Arg_2 {
156         -args {
157            {Arg1}
158            {Arg2 -default 2}
159         }
160      } {
161         return "Arg1:$Arg1, Arg2:$Arg2"
162      }
163   
164      tests tepam-proccall.unn.1dun1un.0 "Procedure calls, UNN, two argument, one with default value, 0"  \
165            -body "Procedure_Arg_2" \
166            -returnCodes error -result "*: Required argument is missing: Arg1*" -output "" -match glob
167      tests tepam-proccall.unn.1dun1un.1 "Procedure calls, UNN, two argument, one with default value, 0"  \
168            -variations {abc 123 "" {asd asdf {xx 123 34}}} \
169            -body "Procedure_Arg_2 \"%1\"" \
170            -result "Arg1:%1, Arg2:2" -output ""
171      tests tepam-proccall.unn.1dun1un.2 "Procedure calls, UNN, two argument, one with default value, 0"  \
172            -variations { Parameter2 -Parameter2 "" ?} \
173            -body "Procedure_Arg_2 Parameter1 \"%1\"" \
174            -result "Arg1:Parameter1, Arg2:%1" -output ""
175      tests tepam-proccall.unn.1dun1un.3 "Procedure calls, UNN, two argument, one with default value, 0"  \
176            -variations { Parameter2  "" ?} \
177            -body "Procedure_Arg_2 Parameter1 Parameter2 \"%1\"" \
178            -returnCodes error -result "*: Too many arguments:*" -output "" -match glob
179      tests tepam-proccall.unn.1dun1un.4 "Procedure calls, UNN, two argument, one with default value, 0"  \
180            -variations { -Parameter2} \
181            -body "Procedure_Arg_2 Parameter1 Parameter2 \"%1\"" \
182            -returnCodes error -result "*: Too many arguments:*" -output "" -match glob
183
184   # Unnamed arguments with default value:
185
186      tepam::procedure Procedure_Arg_2a {
187         -args {
188            {Arg1 -default 1}
189            {Arg2 -default 2}
190         }
191      } {
192         return "Arg1:$Arg1, Arg2:$Arg2"
193      }
194   
195      tests tepam-proccall.unn.2dun.0 "Procedure calls, UNN, two argument with default values, 0"  \
196            -body "Procedure_Arg_2a" \
197            -result "Arg1:1, Arg2:2" -output ""
198      tests tepam-proccall.unn.2dun.1 "Procedure calls, UNN, two argument with default values, 0"  \
199            -variations { abc 123 "" "{asd asdf {xx 123 34}}"} \
200            -body "Procedure_Arg_2a \"%1\"" \
201            -result "Arg1:%1, Arg2:2" -output ""
202      tests tepam-proccall.unn.2dun.2 "Procedure calls, UNN, two argument with default values, 0"  \
203            -variations { Parameter2 -Parameter2 "" ?} \
204            -body "Procedure_Arg_2a Parameter1 \"%1\"" \
205            -result "Arg1:Parameter1, Arg2:%1" -output ""
206      tests tepam-proccall.unn.2dun.3 "Procedure calls, UNN, two argument with default values, 0"  \
207            -variations { Parameter2 "" ?} \
208            -body "Procedure_Arg_2a Parameter1 Parameter2 \"%1\"" \
209            -returnCodes error -result "*: Too many arguments:*" -output "" -match glob
210      tests tepam-proccall.unn.2dun.4 "Procedure calls, UNN, two argument with default values, 0"  \
211            -variations { -Parameter2} \
212            -body "Procedure_Arg_2a Parameter1 Parameter2 \"%1\"" \
213            -returnCodes error -result "*: Too many arguments:*" -output "" -match glob
214
215   # One named and one unnamed argument, without default values (1)
216
217      tepam::procedure Procedure_Arg_2d {
218         -args {
219            {-Arg1}
220            {Arg2}
221         }
222      } {
223         return "Arg1:$Arg1, Arg2:$Arg2"
224      }
225   
226      tests tepam-proccall.unn.1un1n.0 "Procedure calls, UNN, one unnamed and one named argument, 0"  \
227            -body "Procedure_Arg_2d" \
228            -returnCodes error -result "*Required argument is missing: Arg1*" -output "" -match glob
229      tests tepam-proccall.unn.1un1n.1 "Procedure calls, UNN, one unnamed and one named argument, 1"  \
230            -variations { abc 123 "" "{asd asdf {xx 123 34}}"} \
231            -body "Procedure_Arg_2d \"%1\"" \
232            -returnCodes error -result "*Required argument is missing: Arg1*" -output "" -match glob
233      tests tepam-proccall.unn.1un1n.2 "Procedure calls, UNN, one unnamed and one named argument, 2"  \
234            -variations {a "" {}} \
235            -variations {b "" 123} \
236            -body "Procedure_Arg_2d  \"%1\"  \"%2\"" \
237            -returnCodes error -result "*is not an option*" -output "" -match glob
238      tests tepam-proccall.unn.1un1n.3 "Procedure calls, UNN, one unnamed and one named argument, 3"  \
239            -variations {a "" {}} \
240            -variations {b "" 123} \
241            -body "Procedure_Arg_2d  \"%2\" -Arg1 \"%1\"" \
242            -result "Arg1:%1, Arg2:%2" -output ""
243      tests tepam-proccall.unn.1un1n.4 "Procedure calls, UNN, one unnamed and one named argument, 4"  \
244            -variations {a "" {}} \
245            -variations {b "" 123} \
246            -body "Procedure_Arg_2d  -Arg1 \"%1\" -Arg2 \"%2\"" \
247            -returnCodes error -result "*is not an option*" -output "" -match glob
248      tests tepam-proccall.unn.1un1n.5 "Procedure calls, UNN, one unnamed and one named argument, 5"  \
249            -variations {a "" {}} \
250            -variations {b "" 123} \
251            -body "Procedure_Arg_2d  -Arg2 \"%2\" -Arg1 \"%1\"" \
252            -returnCodes error -result "*is not an option*" -output "" -match glob
253
254   # One named and one unnamed argument, without default values (2)
255
256      tepam::procedure Procedure_Arg_2e {
257         -args {
258            {Arg2}
259            {-Arg1}
260         }
261      } {
262         return "Arg1:$Arg1, Arg2:$Arg2"
263      }
264   
265      tests tepam-proccall.unn.1un1n.6 "Procedure calls, UNN, one unnamed and one named argument, 6"  \
266            -body "Procedure_Arg_2d" \
267            -returnCodes error -result "*: Required argument is missing: Arg1" -output "" -match glob
268      tests tepam-proccall.unn.1un1n.7 "Procedure calls, UNN, one unnamed and one named argument, 7"  \
269            -variations { abc 123 "" "{asd asdf {xx 123 34}}"} \
270            -body "Procedure_Arg_2d \"%1\"" \
271            -returnCodes error -result "*Required argument is missing: Arg1*" -output "" -match glob
272      tests tepam-proccall.unn.1un1n.8 "Procedure calls, UNN, one unnamed and one named argument, 8"  \
273            -variations {a "" {}} \
274            -variations {b "" 123} \
275            -body "Procedure_Arg_2d  \"%1\"  \"%2\"" \
276            -returnCodes error -result "*is not an option*" -output "" -match glob
277      tests tepam-proccall.unn.1un1n.9 "Procedure calls, UNN, one unnamed and one named argument, 9"  \
278            -variations {a "" {}} \
279            -variations {b "" 123} \
280            -body "Procedure_Arg_2d  \"%2\" -Arg1 \"%1\"" \
281            -result "Arg1:%1, Arg2:%2" -output ""
282      tests tepam-proccall.unn.1un1n.10 "Procedure calls, UNN, one unnamed and one named argument, 10"  \
283            -variations {a "" {}} \
284            -variations {b "" 123} \
285            -body "Procedure_Arg_2d  -Arg1 \"%1\" -Arg2 \"%2\"" \
286            -returnCodes error -result "*is not an option*" -output "" -match glob
287      tests tepam-proccall.unn.1un1n.11 "Procedure calls, UNN, one unnamed and one named argument, 11"  \
288            -variations {a "" {}} \
289            -variations {b "" 123} \
290            -body "Procedure_Arg_2d  -Arg2 \"%2\" -Arg1 \"%1\"" \
291            -returnCodes error -result "*is not an option*" -output "" -match glob
292
293   # Two named arguments, without default values
294
295      tepam::procedure Procedure_Arg_2c {
296         -args {
297            {-Arg1}
298            {-Arg2}
299         }
300      } {
301         return "Arg1:$Arg1, Arg2:$Arg2"
302      }
303   
304      tests tepam-proccall.unn.2n.0 "Procedure calls, UNN, two named argument, 0"  \
305            -body "Procedure_Arg_2c" \
306            -returnCodes error -result "*Required argument is missing: Arg1*" -output "" -match glob
307      tests tepam-proccall.unn.2n.1 "Procedure calls, UNN, two named argument, 1"  \
308            -variations { abc 123 "" "{asd asdf {xx 123 34}}"} \
309            -body "Procedure_Arg_2c -Arg1 \"%1\"" \
310            -returnCodes error -result "*Required argument is missing: Arg2*" -output "" -match glob
311      tests tepam-proccall.unn.2n.2 "Procedure calls, UNN, two named argument, 2"  \
312            -variations {a "" {}} \
313            -variations {b "" 123} \
314            -body "Procedure_Arg_2c -Arg1 \"%1\" -Arg2 \"%2\"" \
315            -result "Arg1:%1, Arg2:%2" -output ""
316      tests tepam-proccall.unn.2n.3 "Procedure calls, UNN, two named argument, 3"  \
317            -variations {a "" {}} \
318            -variations {b "" 123} \
319            -body "Procedure_Arg_2c -Arg2 \"%2\" -Arg1 \"%1\"" \
320            -result "Arg1:%1, Arg2:%2" -output ""
321      tests tepam-proccall.unn.2n.4 "Procedure calls, UNN, two named argument, 4"  \
322            -variations {a "" {}} \
323            -variations {b "" 123} \
324            -variations {c "" {}} \
325            -body "Procedure_Arg_2c \"%3\" -Arg1 \"%1\" -Arg2 \"%2\"" \
326            -returnCodes error -result "*is not an option*" -output "" -match glob
327
328   # Multiple arguments - One unnamed argument
329
330      tepam::procedure Procedure_Multiple_Arg1 {
331         -args {
332            {Arg -multiple}
333         }
334      } {
335         return $Arg
336      }
337
338      tests tepam-proccall.unn.1mu.0 "Procedure calls, UNN, one unnamed multiple argument, 0"  \
339               -body "Procedure_Multiple_Arg1" \
340               -returnCodes error -result "*Required argument is missing: Arg*" -output "" -match glob
341      tests tepam-proccall.unn.1mu.1 "Procedure calls, UNN, one unnamed multiple argument, 1"  \
342               -body "Procedure_Multiple_Arg1 Hello" \
343               -result "Hello" -output ""
344      tests tepam-proccall.unn.1mu.2 "Procedure calls, UNN, one unnamed multiple argument, 2"  \
345               -body "Procedure_Multiple_Arg1 {Hello world}" \
346               -result "{Hello world}" -output ""
347      tests tepam-proccall.unn.1mu.3 "Procedure calls, UNN, one unnamed multiple argument, 3"  \
348               -body "Procedure_Multiple_Arg1 {Hello my} world" \
349               -result "{Hello my} world" -output ""
350      tests tepam-proccall.unn.1mu.4 "Procedure calls, UNN, one unnamed multiple argument, 4"  \
351               -body "Procedure_Multiple_Arg1 Hello {my world}" \
352               -result "Hello {my world}" -output ""
353      tests tepam-proccall.unn.1mu.5 "Procedure calls, UNN, one unnamed multiple argument, 5"  \
354               -body "Procedure_Multiple_Arg1 {Hello my} {nice world}" \
355               -result "{Hello my} {nice world}" -output ""
356      tests tepam-proccall.unn.1mu.6 "Procedure calls, UNN, one unnamed multiple argument, 6"  \
357               -body "Procedure_Multiple_Arg1 {Hello my} {nice world,} {how are} you" \
358               -result "{Hello my} {nice world,} {how are} you" -output ""
359
360   # Multiple arguments - Two unnamed argument, both not optional
361
362      tepam::procedure Procedure_Multiple_Arg2a {
363         -args {
364            {Arg1}
365            {Arg2 -multiple}
366         }
367      } {
368         return $Arg1:$Arg2
369      }
370
371      tests tepam-proccall.unn.1mu1u.0 "Procedure calls, UNN, two unnamed argument, one is multiple, 0"  \
372               -body "Procedure_Multiple_Arg2a" \
373               -returnCodes error -result "*Required argument is missing: Arg*" -output "" -match glob
374      tests tepam-proccall.unn.1mu1u.1 "Procedure calls, UNN, two unnamed argument, one is multiple, 1"  \
375               -body "Procedure_Multiple_Arg2a Message" \
376               -returnCodes error -result "*Required argument is missing: Arg*" -output "" -match glob
377      tests tepam-proccall.unn.1mu1u.2 "Procedure calls, UNN, two unnamed argument, one is multiple, 2"  \
378               -body "Procedure_Multiple_Arg2a Message Hello" \
379               -result "Message:Hello" -output ""
380      tests tepam-proccall.unn.1mu1u.3 "Procedure calls, UNN, two unnamed argument, one is multiple, 3"  \
381               -body "Procedure_Multiple_Arg2a Message {Hello world}" \
382               -result "Message:{Hello world}" -output ""
383      tests tepam-proccall.unn.1mu1u.4 "Procedure calls, UNN, two unnamed argument, one is multiple, 4"  \
384               -body "Procedure_Multiple_Arg2a Message Hello world" \
385               -result "Message:Hello world" -output ""
386      tests tepam-proccall.unn.1mu1u.5 "Procedure calls, UNN, two unnamed argument, one is multiple, 5"  \
387               -body "Procedure_Multiple_Arg2a Message Hello all world" \
388               -result "Message:Hello all world" -output ""
389      tests tepam-proccall.unn.1mu1u.6 "Procedure calls, UNN, two unnamed argument, one is multiple, 6"  \
390               -body "Procedure_Multiple_Arg2a Message {Hello my} world" \
391               -result "Message:{Hello my} world" -output ""
392      tests tepam-proccall.unn.1mu1u.7 "Procedure calls, UNN, two unnamed argument, one is multiple, 7"  \
393               -body "Procedure_Multiple_Arg2a Message Hello {my world}" \
394               -result "Message:Hello {my world}" -output ""
395      tests tepam-proccall.unn.1mu1u.8 "Procedure calls, UNN, two unnamed argument, one is multiple, 8"  \
396               -body "Procedure_Multiple_Arg2a Message {Hello my} {nice world}" \
397               -result "Message:{Hello my} {nice world}" -output ""
398      tests tepam-proccall.unn.1mu1u.9 "Procedure calls, UNN, two unnamed argument, one is multiple, 9"  \
399               -body "Procedure_Multiple_Arg2a Message {Hello my} {nice world,} {how are} you" \
400               -result "Message:{Hello my} {nice world,} {how are} you" -output ""
401
402   # Multiple arguments - Two unnamed argument, the second is optinoal
403
404      tepam::procedure Procedure_Multiple_Arg2b {
405         -args {
406            {Arg1}
407            {Arg2 -default "" -multiple}
408         }
409      } {
410         return $Arg1:$Arg2
411      }
412
413      tests tepam-proccall.unn.1dmu1u.0 "Procedure calls, UNN, two unnamed argument, one has default and is multiple, 0"  \
414               -body "Procedure_Multiple_Arg2b" \
415               -returnCodes error -result "*Required argument is missing: Arg*" -output "" -match glob
416      tests tepam-proccall.unn.1dmu1u.1 "Procedure calls, UNN, two unnamed argument, one has default and is multiple, 1"  \
417               -body "Procedure_Multiple_Arg2b Message" \
418               -result "Message:" -output ""
419      tests tepam-proccall.unn.1dmu1u.2 "Procedure calls, UNN, two unnamed argument, one has default and is multiple, 2"  \
420               -body "Procedure_Multiple_Arg2b Message Hello" \
421               -result "Message:Hello" -output ""
422      tests tepam-proccall.unn.1dmu1u.3 "Procedure calls, UNN, two unnamed argument, one has default and is multiple, 3"  \
423               -body "Procedure_Multiple_Arg2b Message {Hello world}" \
424               -result "Message:{Hello world}" -output ""
425      tests tepam-proccall.unn.1dmu1u.4 "Procedure calls, UNN, two unnamed argument, one has default and is multiple, 4"  \
426               -body "Procedure_Multiple_Arg2b Message Hello world" \
427               -result "Message:Hello world" -output ""
428      tests tepam-proccall.unn.1dmu1u.5 "Procedure calls, UNN, two unnamed argument, one has default and is multiple, 5"  \
429               -body "Procedure_Multiple_Arg2b Message Hello all world" \
430               -result "Message:Hello all world" -output ""
431
432   # Multiple arguments - Two unnamed argument, both are optinoal
433
434      tepam::procedure Procedure_Multiple_Arg2c {
435         -args {
436            {Arg1 -default ""}
437            {Arg2 -default "" -multiple}
438         }
439      } {
440         return $Arg1:$Arg2
441      }
442
443      tests tepam-proccall.unn.1dmu1du.0 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 0"  \
444               -body "Procedure_Multiple_Arg2c" \
445               -result ":" -output ""
446      tests tepam-proccall.unn.1dmu1du.1 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 1"  \
447               -body "Procedure_Multiple_Arg2c Message" \
448               -result "Message:" -output ""
449      tests tepam-proccall.unn.1dmu1du.2 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 2"  \
450               -body "Procedure_Multiple_Arg2c Message Hello" \
451               -result "Message:Hello" -output ""
452      tests tepam-proccall.unn.1dmu1du.3 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 3"  \
453               -body "Procedure_Multiple_Arg2c Message {Hello world}" \
454               -result "Message:{Hello world}" -output ""
455      tests tepam-proccall.unn.1dmu1du.4 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 4"  \
456               -body "Procedure_Multiple_Arg2c Message Hello world" \
457               -result "Message:Hello world" -output ""
458      tests tepam-proccall.unn.1dmu1du.5 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 5"  \
459               -body "Procedure_Multiple_Arg2c Message Hello all world" \
460               -result "Message:Hello all world" -output ""
461      tests tepam-proccall.unn.1dmu1du.6 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 6"  \
462               -body "Procedure_Multiple_Arg2c Message \"Hello all\" world" \
463               -result "Message:{Hello all} world" -output ""
464      tests tepam-proccall.unn.1dmu1du.7 "Procedure calls, UNN, two unnamed argument, both have default, one is multiple, 7"  \
465               -body "Procedure_Multiple_Arg2c Message Hello \"all world\"" \
466               -result "Message:Hello {all world}" -output ""
467
468   # Multiple arguments - Two named arguments
469
470      tepam::procedure Procedure_Multiple_Arg1 {
471         -args {
472            {-Arg1 -multiple}
473            {-Arg2 -multiple}
474         }
475      } {
476         return "$Arg1:$Arg2"
477      }
478
479      tests tepam-proccall.unn.2mu.0 "Procedure calls, UNN, two unnamed argument that are multiple, 0"  \
480               -body "Procedure_Multiple_Arg1" \
481               -returnCodes error -result "*Required argument is missing: Arg1*" -output "" -match glob
482      tests tepam-proccall.unn.2mu.1 "Procedure calls, UNN, two unnamed argument that are multiple, 1"  \
483               -body "Procedure_Multiple_Arg1 -Arg1 Hello" \
484               -returnCodes error -result "*Required argument is missing: Arg2*" -output "" -match glob
485      tests tepam-proccall.unn.2mu.2 "Procedure calls, UNN, two unnamed argument that are multiple, 2"  \
486               -body "Procedure_Multiple_Arg1 -Arg1 Hello -Arg2 world" \
487               -result "Hello:world" -output ""
488      tests tepam-proccall.unn.2mu.3 "Procedure calls, UNN, two unnamed argument that are multiple, 3"  \
489               -body "Procedure_Multiple_Arg1 -Arg1 \"\" -Arg2 \"Hello world\"" \
490               -result "{}:{Hello world}" -output ""
491      tests tepam-proccall.unn.2mu.4 "Procedure calls, UNN, two unnamed argument that are multiple, 4"  \
492               -body "Procedure_Multiple_Arg1 -Arg1 \"\" -Arg2 Hello -Arg2 world" \
493               -result "{}:Hello world" -output ""
494      tests tepam-proccall.unn.2mu.5 "Procedure calls, UNN, two unnamed argument that are multiple, 5"  \
495               -body "Procedure_Multiple_Arg1 -Arg1 \"\" -Arg2 Hello -Arg2 all -Arg2 world" \
496               -result "{}:Hello all world" -output ""
497
498   # Multiple arguments - One named argument
499
500      tepam::procedure Procedure_Multiple_Arg3 {
501         -args {
502            {-Arg -multiple}
503         }
504      } {
505         return $Arg
506      }
507
508      tests tepam-proccall.unn.1mn.0 "Procedure calls, UNN, one named multiple argument, 0"  \
509               -body "Procedure_Multiple_Arg3" \
510               -returnCodes error -result "*Required argument is missing: Arg*" -output "" -match glob
511      tests tepam-proccall.unn.1mn.1 "Procedure calls, UNN, one named multiple argument, 1"  \
512               -body "Procedure_Multiple_Arg3 -Arg Hello" \
513               -result "Hello" -output ""
514      tests tepam-proccall.unn.1mn.2 "Procedure calls, UNN, one named multiple argument, 2"  \
515               -body "Procedure_Multiple_Arg3 -Arg Hello world" \
516               -returnCodes error -result "*Argument 'world' is not an option*" -output "" -match glob
517      tests tepam-proccall.unn.1mn.3 "Procedure calls, UNN, one named multiple argument, 3"  \
518               -body "Procedure_Multiple_Arg3 -Arg {Hello world}" \
519               -result "{Hello world}" -output ""
520      tests tepam-proccall.unn.1mn.4 "Procedure calls, UNN, one named multiple argument, 4"  \
521               -body "Procedure_Multiple_Arg3 -Arg Hello -Arg world" \
522               -result "Hello world" -output ""
523      tests tepam-proccall.unn.1mn.5 "Procedure calls, UNN, one named multiple argument, 5"  \
524               -body "Procedure_Multiple_Arg3 -Arg {Hello my} -Arg world" \
525               -result "{Hello my} world" -output ""
526      tests tepam-proccall.unn.1mn.6 "Procedure calls, UNN, one named multiple argument, 6"  \
527               -body "Procedure_Multiple_Arg3 -Arg Hello -Arg {my world}" \
528               -result "Hello {my world}" -output ""
529      tests tepam-proccall.unn.1mn.7 "Procedure calls, UNN, one named multiple argument, 7"  \
530               -body "Procedure_Multiple_Arg3 -Arg {Hello my} -Arg {nice world}" \
531               -result "{Hello my} {nice world}" -output ""
532      tests tepam-proccall.unn.1mn.8 "Procedure calls, UNN, one named multiple argument, 8"  \
533               -body "Procedure_Multiple_Arg3 -Arg {Hello my} -Arg {nice world,} -Arg {how are} -Arg you" \
534               -result "{Hello my} {nice world,} {how are} you" -output ""
535
536######## That's all ########
537
538::tcltest::cleanupTests
539return
540
541##########################################################################
542# $RCSfile: proc_call_arg_unn.test,v $ - ($Name:  $)
543# $Id: proc_call_arg_unn.test,v 1.1 2010/02/11 21:50:55 droll Exp $
544# Modifications:
545# $Log: proc_call_arg_unn.test,v $
546# Revision 1.1  2010/02/11 21:50:55  droll
547# TEPAM module checkin
548#
549##########################################################################
550
551