1#---------------------------------------------------------------------
2# TITLE:
3#       typeoption.test
4#
5# AUTHOR:
6#       Arnulf Wiedemann with a lot of code form the snit tests by
7#       Will Duquette
8#
9# DESCRIPTION:
10#       Test cases for ::itcl::type proc, method, typemethod commands.
11#       Uses the ::tcltest:: harness.
12#
13#    The tests assume tcltest 2.2
14#-----------------------------------------------------------------------
15
16package require tcltest 2.2
17namespace import ::tcltest::*
18::tcltest::loadTestedCommands
19package require itcl
20
21interp alias {} type {} ::itcl::type
22
23loadTestedCommands
24
25#-----------------------------------------------------------------------
26# Instance Introspection
27
28test iinfo-1.2 {object info too few args} -body {
29    type dog { }
30
31    dog create spot
32
33    spot info
34} -returnCodes {
35    error
36} -cleanup {
37    dog destroy
38} -result {wrong # args: should be one of...
39  info args procname
40  info body procname
41  info component ?name? ?-inherit? ?-value?
42  info components ?pattern?
43  info default method aname varname
44  info delegated ?name? ?-inherit? ?-value?
45  info instances ?pattern?
46  info method ?name? ?-protection? ?-type? ?-name? ?-args? ?-body?
47  info methods ?pattern?
48  info options ?pattern?
49  info type
50  info typemethod ?name? ?-protection? ?-type? ?-name? ?-args? ?-body?
51  info typemethods ?pattern?
52  info types ?pattern?
53  info typevariable ?name? ?-protection? ?-type? ?-name? ?-init? ?-value?
54  info typevars ?pattern?
55  info variable ?name? ?-protection? ?-type? ?-name? ?-init? ?-value? ?-config? ?-scope?
56  info variables ?pattern?
57...and others described on the man page}
58
59test iinfo-1.3 {object info too many args} -body {
60    type dog { }
61
62    dog create spot
63
64    spot info type foo
65} -returnCodes {
66    error
67} -cleanup {
68    dog destroy
69} -result {wrong # args: should be "info type"}
70
71test iinfo-2.1 {object info type} -body {
72    type dog { }
73
74    dog create spot
75    spot info type
76} -cleanup {
77    dog destroy
78} -result {::dog}
79
80test iinfo-3.1 {object info typevars} -body {
81    type dog {
82        typevariable thisvar 1
83        typevariable thatvar 2
84
85        constructor {args} {
86        }
87    }
88
89    dog create spot
90    lsort [spot info typevars]
91} -cleanup {
92    dog destroy
93} -result {::dog::thatvar ::dog::thisvar}
94
95test iinfo-3.2 {object info typevars with pattern} -body {
96    type dog {
97        typevariable thisvar 1
98        typevariable thatvar 2
99
100        constructor {args} {
101        }
102    }
103
104    dog create spot
105    spot info typevars *this*
106} -cleanup {
107    dog destroy
108} -result {::dog::thisvar}
109
110test iinfo-3.1a {object info typevarable} -body {
111    type dog {
112        typevariable thisvar 1
113        typevariable thatvar 2
114
115        constructor {args} {
116        }
117    }
118
119    dog create spot
120    spot info typevariable thatvar -name -protection -type -init -value
121} -cleanup {
122    dog destroy
123} -result {::dog::thatvar public common 2 2}
124
125test iinfo-4.1 {object info vars} -body {
126    type dog {
127        variable hisvar 1
128
129        constructor {args} {
130            variable hervar
131            set hervar 2
132        }
133    }
134
135    dog create spot
136    lsort [spot info vars]
137} -cleanup {
138    dog destroy
139} -result {hisvar itcl_options}
140
141test iinfo-4.2 {object info vars with pattern} -body {
142    type dog {
143        variable hisvar 1
144
145        constructor {args} {
146            variable hervar
147            set hervar 2
148        }
149    }
150
151    dog create spot
152    spot info vars "*his*"
153} -cleanup {
154    dog destroy
155} -result {hisvar itcl_options}
156
157test iinfo-5.1 {object info no vars defined besides itcl_options} -body {
158    type dog { }
159
160    dog create spot
161    list [spot info vars] [spot info typevars]
162} -cleanup {
163    dog destroy
164} -result {itcl_options {}}
165
166test iinfo-6.1 {info options with no options} -body {
167    type dog { }
168    dog create spot
169
170    llength [spot info options]
171} -cleanup {
172    dog destroy
173} -result {0}
174
175test iinfo-6.2 {info options with only local options} -body {
176    type dog {
177        option -foo a
178        option -bar b
179    }
180    dog create spot
181
182    lsort [spot info options]
183} -cleanup {
184    dog destroy
185} -result {-bar -foo}
186
187test iinfo-6.3 {info options with local and delegated options} -body {
188    type dog {
189        option -foo a
190        option -bar b
191        delegate option -quux to sibling
192    }
193    dog create spot
194
195    lsort [spot info options]
196} -cleanup {
197    dog destroy
198} -result {-bar -foo -quux}
199
200test iinfo-6.3a {info option} -body {
201    type dog {
202        option -foo a
203        option -bar b
204        delegate option -quux to sibling
205    }
206    dog create spot
207
208    lsort [spot info option]
209} -cleanup {
210    dog destroy
211} -result {-bar -foo}
212
213test iinfo-6.3b {info option with options} -body {
214    type dog {
215        option -foo -cgetmethod xx -configuremethodvar yy -default a
216        option -bar b
217        delegate option -quux to sibling
218    }
219    dog create spot
220
221    spot info option -foo
222} -cleanup {
223    dog destroy
224} -result {protected ::dog::-foo foo Foo a xx {} {} yy}
225
226test iinfo-7.1 {info typemethods, simple case} -body {
227    type dog { }
228
229    dog spot
230
231    lsort [spot info typemethods]
232} -cleanup {
233    dog destroy
234} -result {create destroy info}
235
236test iinfo-7.2 {info typemethods, with pattern} -body {
237    type dog { }
238
239    dog spot
240
241    spot info typemethods i*
242} -cleanup {
243    dog destroy
244} -result {info}
245
246test iinfo-7.3 {info typemethods, with explicit typemethods} -body {
247    type dog {
248        typemethod foo {} {}
249        typeconstructor {
250            set comp string
251        }
252        delegate typemethod bar to comp
253    }
254
255    dog spot
256
257    lsort [spot info typemethods]
258} -cleanup {
259    dog destroy
260} -result {bar create destroy foo info}
261
262test iinfo-7.4 {info typemethods, with implicit typemethods} -body {
263    type dog {
264        delegate typemethod * to comp
265
266        typeconstructor {
267            set comp string
268        }
269    }
270
271    dog create spot
272
273    set a [lsort [spot info typemethods]]
274
275    dog length foo
276    dog is boolean yes
277
278    set b [lsort [spot info typemethods]]
279
280    set c [spot info typemethods len*]
281
282    list $a $b $c
283} -cleanup {
284    dog destroy
285} -result {{create destroy info} {create destroy info is length} length}
286
287test iinfo-7.5 {info typemethods, with hierarchical typemethods} -body {
288    type dog {
289        delegate typemethod {comp foo} to comp
290
291        typeconstructor {
292            set comp string
293        }
294        typemethod {comp bar} {} {}
295    }
296
297    dog create spot
298
299    lsort [spot info typemethods]
300} -cleanup {
301    dog destroy
302} -result {{comp bar} {comp foo} create destroy info}
303
304test iinfo-7.5a {info typemethod} -body {
305    type dog {
306        typemethod tail {args} { set a b }
307    }
308
309    dog create spot
310
311    lsort [spot info typemethod]
312} -cleanup {
313    dog destroy
314} -result {::dog::tail}
315
316test iinfo-7.5b {info typemethod with options} -body {
317    type dog {
318        typemethod tail {args} { set a b }
319    }
320
321    dog create spot
322
323    spot info typemethod tail -name -protection -args -body -type
324} -cleanup {
325    dog destroy
326} -result {::dog::tail public {?arg arg ...?} { set a b } typemethod}
327
328
329test iinfo-8.1 {info methods, simple case} -body {
330    type dog { }
331
332    dog spot
333
334    lsort [spot info methods]
335} -cleanup {
336    dog destroy
337} -result {destroy info}
338
339test iinfo-8.2 {info methods, with pattern} -body {
340    type dog { }
341
342    dog spot
343
344    spot info methods i*
345} -cleanup {
346    dog destroy
347} -result {info}
348
349test iinfo-8.1a {info method} -body {
350    type dog {
351        method tail {args} { set a b }
352    }
353
354    dog spot
355
356    lsort [spot info method]
357} -cleanup {
358    dog destroy
359} -result {::dog::callinstance ::dog::cget ::dog::configure ::dog::destroy ::dog::getinstancevar ::dog::info ::dog::isa ::dog::mymethod ::dog::myproc ::dog::mytypemethod ::dog::mytypevar ::dog::myvar ::dog::tail ::dog::unknown}
360
361test iinfo-8.1b {info method with options} -body {
362    type dog {
363        method tail {args} { set a b }
364    }
365
366    dog spot
367
368    spot info method tail -name -protection -args -body -type
369} -cleanup {
370    dog destroy
371} -result {::dog::tail public {?arg arg ...?} { set a b } method}
372
373test iinfo-8.3 {info methods, with explicit methods} -body {
374    type dog {
375        method foo {} {}
376        typeconstructor {
377            set comp string
378        }
379        delegate method bar to comp
380    }
381
382    dog spot
383
384    lsort [spot info methods]
385} -cleanup {
386    dog destroy
387} -result {bar destroy foo info}
388
389test iinfo-8.4 {info methods, with implicit methods} -body {
390    type dog {
391        delegate method * to comp
392
393        constructor {args} {
394            set comp string
395        }
396    }
397
398    dog create spot
399
400    set a [lsort [spot info methods]]
401
402    spot length foo
403    spot is boolean yes
404
405    set b [lsort [spot info methods]]
406
407    set c [spot info methods len*]
408
409    list $a $b $c
410} -cleanup {
411    dog destroy
412} -result {{destroy info} {destroy info is length} length}
413
414test iinfo-8.5 {info methods, with hierarchical methods} -body {
415    type dog {
416        delegate method {comp foo} to comp
417
418        constructor {args} {
419            set comp string
420        }
421        method {comp bar} {} {}
422    }
423
424    dog create spot
425
426    lsort [spot info methods]
427} -cleanup {
428    dog destroy
429} -result {{comp bar} {comp foo} destroy info}
430
431test iinfo-9.1 {info args} -body {
432    type dog {
433	method bark {volume} {}
434    }
435
436    dog spot
437
438    spot info args bark
439} -cleanup {
440    dog destroy
441} -result {volume}
442
443test iinfo-9.2 {info args, too few args} -body {
444    type dog {
445	method bark {volume} {}
446    }
447
448    dog spot
449
450    spot info args
451} -returnCodes error -cleanup {
452    dog destroy
453} -result {wrong # args: should be "info args method"}
454
455test iinfo-9.3 {info args, too many args} -body {
456    type dog {
457	method bark {volume} {}
458    }
459
460    dog spot
461
462    spot info args bark wag
463} -returnCodes error -cleanup {
464    dog destroy
465} -result {wrong # args: should be "info args method"}
466
467test iinfo-9.4 {info args, unknown method} -body {
468    type dog {
469    }
470
471    dog spot
472
473    spot info args bark
474} -returnCodes error -cleanup {
475    dog destroy
476} -result {"bark" isn't a method}
477
478test iinfo-9.5 {info args, delegated method} -body {
479    type dog {
480	component x
481        typeconstructor {
482	    set x string
483        }
484	delegate method bark to x
485    }
486
487    dog spot
488
489    spot info args bark
490} -returnCodes error -cleanup {
491    dog destroy
492} -result {delegated method "bark"}
493
494test iinfo-10.1 {info default} -body {
495    type dog {
496	method bark {{volume 50}} {}
497    }
498
499    dog spot
500
501    list [spot info default bark volume def] $def
502} -cleanup {
503    dog destroy
504} -result {1 50}
505
506test iinfo-10.2 {info default, too few args} -body {
507    type dog {
508	method bark {volume} {}
509    }
510
511    dog spot
512
513    spot info default
514} -returnCodes error -cleanup {
515    dog destroy
516} -result {wrong # args, should be info default <method> <argName> <varName>}
517
518test iinfo-10.3 {info default, too many args} -body {
519    type dog {
520	method bark {volume} {}
521    }
522
523    dog spot
524
525    spot info default bark wag def foo
526} -returnCodes error -cleanup {
527    dog destroy
528} -result {wrong # args, should be info default <method> <argName> <varName>}
529
530test iinfo-10.4 {info default, unknown method} -body {
531    type dog {
532    }
533
534    dog spot
535
536    spot info default bark x var
537} -returnCodes error -cleanup {
538    dog destroy
539} -result {unknown method "bark"}
540
541test iinfo-10.5 {info default, delegated method} -body {
542    type dog {
543	component x
544	typeconstructor {
545	    set x string
546	}
547	delegate method bark to x
548    }
549
550    dog spot
551
552    spot info default bark x var
553} -returnCodes error -cleanup {
554    dog destroy
555} -result {delegated method "bark"}
556
557test iinfo-11.1 {info body} -body {
558    type dog {
559	typevariable x
560	variable y
561	method bark {volume} {
562	    speaker on
563	    speaker play bark.snd
564	    speaker off
565	}
566    }
567
568    dog spot
569
570    spot info body bark
571} -cleanup {
572    dog destroy
573} -result {
574	    speaker on
575	    speaker play bark.snd
576	    speaker off
577	}
578
579test iinfo-11.2 {info body, too few args} -body {
580    type dog {
581	method bark {volume} {}
582    }
583
584    dog spot
585
586    spot info body
587} -returnCodes error -cleanup {
588    dog destroy
589} -result {wrong # args: should be "info body method"}
590
591test iinfo-11.3 {info body, too many args} -body {
592    type dog {
593	method bark {volume} {}
594    }
595
596    dog spot
597
598    spot info body bark wag
599} -returnCodes error -cleanup {
600    dog destroy
601} -result {wrong # args: should be "info body method"}
602
603test iinfo-11.4 {info body, unknown method} -body {
604    type dog {
605    }
606
607    dog spot
608
609    spot info body bark
610} -returnCodes error -cleanup {
611    dog destroy
612} -result {"bark" isn't a method}
613
614test iinfo-11.5 {info body, delegated method} -body {
615    type dog {
616	component x
617	typeconstructor {
618	    set x string
619	}
620	delegate method bark to x
621    }
622
623    dog spot
624
625    spot info body bark
626} -returnCodes error -cleanup {
627    dog destroy
628} -result {delegated method "bark"}
629
630#-----------------------------------------------------------------------
631# Type Introspection
632
633test tinfo-1.2 {type info too few args} -body {
634    type dog { }
635
636    dog info
637} -returnCodes {
638    error
639} -cleanup {
640    dog destroy
641} -result {wrong # args: should be one of...
642  info args procname
643  info body procname
644  info component ?name? ?-inherit? ?-value?
645  info components ?pattern?
646  info default method aname varname
647  info delegated ?name? ?-inherit? ?-value?
648  info instances ?pattern?
649  info method ?name? ?-protection? ?-type? ?-name? ?-args? ?-body?
650  info methods ?pattern?
651  info options ?pattern?
652  info type
653  info typemethod ?name? ?-protection? ?-type? ?-name? ?-args? ?-body?
654  info typemethods ?pattern?
655  info types ?pattern?
656  info typevariable ?name? ?-protection? ?-type? ?-name? ?-init? ?-value?
657  info typevars ?pattern?
658  info variable ?name? ?-protection? ?-type? ?-name? ?-init? ?-value? ?-config? ?-scope?
659  info variables ?pattern?
660...and others described on the man page}
661
662
663test tinfo-1.3 {type info too many args} -body {
664    type dog { }
665
666    dog info instances foo bar
667} -returnCodes {
668    error
669} -cleanup {
670    dog destroy
671} -result {wrong # args should be: info instances ?pattern?}
672
673test tinfo-2.1 {type info typevars} -body {
674    type dog {
675        typevariable thisvar 1
676        typevariable thatvar 2
677
678        constructor {args} {
679        }
680    }
681
682    dog create spot
683    lsort [dog info typevars]
684} -cleanup {
685    dog destroy
686} -result {::dog::thatvar ::dog::thisvar}
687
688test tinfo-3.1 {type info instances} -body {
689    type dog { }
690
691    dog create spot
692    dog create fido
693
694    lsort [dog info instances]
695} -cleanup {
696    dog destroy
697} -result {::fido ::spot}
698
699test tinfo-3.3 {type info instances with non-global namespaces} -body {
700    type dog { }
701
702    dog create ::spot
703
704    namespace eval ::dogs:: {
705        set ::qname [dog create fido]
706    }
707
708    list $qname [lsort [dog info instances]]
709} -cleanup {
710    dog destroy
711} -result {::dogs::fido {::dogs::fido ::spot}}
712
713test tinfo-3.4 {type info instances with pattern} -body {
714    type dog { }
715
716    dog create spot
717    dog create fido
718
719    dog info instances "*f*"
720} -cleanup {
721    dog destroy
722} -result {::fido}
723
724test tinfo-4.1 {type info typevars with pattern} -body {
725    type dog {
726        typevariable thisvar 1
727        typevariable thatvar 2
728
729        constructor {args} {
730        }
731    }
732
733    dog create spot
734    dog info typevars *this*
735} -cleanup {
736    dog destroy
737} -result {::dog::thisvar}
738
739test tinfo-5.1 {type info typemethods, simple case} -body {
740    type dog { }
741
742    lsort [dog info typemethods]
743} -cleanup {
744    dog destroy
745} -result {create destroy info}
746
747test tinfo-5.2 {type info typemethods, with pattern} -body {
748    type dog { }
749
750    dog info typemethods i*
751} -cleanup {
752    dog destroy
753} -result {info}
754
755test tinfo-5.3 {type info typemethods, with explicit typemethods} -body {
756    type dog {
757        typemethod foo {} {}
758        typeconstructor {
759	    set comp string
760	}
761        delegate typemethod bar to comp
762    }
763
764    lsort [dog info typemethods]
765} -cleanup {
766    dog destroy
767} -result {bar create destroy foo info}
768
769test tinfo-5.4 {type info typemethods, with implicit typemethods} -body {
770    type dog {
771        delegate typemethod * to comp
772
773        typeconstructor {
774            set comp string
775        }
776    }
777
778    set a [lsort [dog info typemethods]]
779
780    dog length foo
781    dog is boolean yes
782
783    set b [lsort [dog info typemethods]]
784
785    set c [dog info typemethods len*]
786
787    list $a $b $c
788} -cleanup {
789    dog destroy
790} -result {{create destroy info} {create destroy info is length} length}
791
792test tinfo-5.5 {info typemethods, with hierarchical typemethods} -body {
793    type dog {
794        delegate typemethod {comp foo} to comp
795
796        typeconstructor {
797            set comp string
798        }
799        typemethod {comp bar} {} {}
800    }
801
802    lsort [dog info typemethods]
803} -cleanup {
804    dog destroy
805} -result {{comp bar} {comp foo} create destroy info}
806
807test tinfo-6.1 {type info args} -body {
808    type dog {
809	typemethod bark {volume} {}
810    }
811
812    dog info args bark
813} -cleanup {
814    dog destroy
815} -result {volume}
816
817test tinfo-6.2 {type info args, too few args} -body {
818    type dog {
819	typemethod bark {volume} {}
820    }
821
822    dog info args
823} -returnCodes error -cleanup {
824    dog destroy
825} -result {wrong # args: should be "info args method"}
826
827test tinfo-6.3 {type info args, too many args} -body {
828    type dog {
829	typemethod bark {volume} {}
830    }
831
832    dog info args bark wag
833} -returnCodes error -cleanup {
834    dog destroy
835} -result {wrong # args: should be "info args method"}
836
837test tinfo-6.4 {type info args, unknown method} -body {
838    type dog {
839    }
840
841    dog info args bark
842} -returnCodes error -cleanup {
843    dog destroy
844} -result {"bark" isn't a method}
845
846test tinfo-6.5 {type info args, delegated method} -body {
847    type dog {
848        typeconstructor {
849            set x string
850        }
851	delegate typemethod bark to x
852    }
853
854    dog info args bark
855} -returnCodes error -cleanup {
856    dog destroy
857} -result {delegated typemethod "bark"}
858
859test tinfo-7.1 {type info default} -body {
860    type dog {
861	typemethod bark {{volume 50}} {}
862    }
863
864    list [dog info default bark volume def] $def
865} -cleanup {
866    dog destroy
867} -result {1 50}
868
869test tinfo-7.2 {type info default, too few args} -body {
870    type dog {
871	typemethod bark {volume} {}
872    }
873
874    dog info default
875} -returnCodes error -cleanup {
876    dog destroy
877} -result {wrong # args, should be info default <method> <argName> <varName>}
878
879test tinfo-7.3 {type info default, too many args} -body {
880    type dog {
881	typemethod bark {volume} {}
882    }
883
884    dog info default bark wag def foo
885} -returnCodes error -cleanup {
886    dog destroy
887} -result {wrong # args, should be info default <method> <argName> <varName>}
888
889test tinfo-7.4 {type info default, unknown method} -body {
890    type dog {
891    }
892
893    dog info default bark x var
894} -returnCodes error -cleanup {
895    dog destroy
896} -result {unknown method "bark"}
897
898test tinfo-7.5 {type info default, delegated method} -body {
899    type dog {
900        typeconstructor {
901            set x string
902        }
903	delegate typemethod bark to x
904    }
905
906    dog info default bark x var
907} -returnCodes error -cleanup {
908    dog destroy
909} -result {delegated typemethod "bark"}
910
911test tinfo-8.1 {type info body} -body {
912    type dog {
913	typevariable x
914	variable y
915	typemethod bark {volume} {
916	    speaker on
917	    speaker play bark.snd
918	    speaker off
919	}
920    }
921
922    dog info body bark
923} -cleanup {
924    dog destroy
925} -result {
926	    speaker on
927	    speaker play bark.snd
928	    speaker off
929	}
930
931test tinfo-8.2 {type info body, too few args} -body {
932    type dog {
933	typemethod bark {volume} {}
934    }
935
936    dog info body
937} -returnCodes error -cleanup {
938    dog destroy
939} -result {wrong # args: should be "info body method"}
940
941test tinfo-8.3 {type info body, too many args} -body {
942    type dog {
943	typemethod bark {volume} {}
944    }
945
946    dog info body bark wag
947} -returnCodes error -cleanup {
948    dog destroy
949} -result {wrong # args: should be "info body method"}
950
951test tinfo-8.4 {type info body, unknown method} -body {
952    type dog {
953    }
954
955    dog info body bark
956} -returnCodes error -cleanup {
957    dog destroy
958} -result {"bark" isn't a method}
959
960test tinfo-8.5 {type info body, delegated method} -body {
961    type dog {
962        typeconstructor {
963            set x string
964        }
965	delegate typemethod bark to x
966    }
967
968    dog info body bark
969} -returnCodes {
970    error
971}  -cleanup {
972    dog destroy
973} -result {delegated typemethod "bark"}
974
975test tinfo-10.1 {type info types} -body {
976    type dog {
977    }
978
979    type cat {
980    }
981
982    lsort [dog info types]
983} -cleanup {
984    dog destroy
985    cat destroy
986} -result {cat dog}
987
988test tinfo-10.2 {type info components} -body {
989    type dog {
990        component comp1
991        component comp2
992    }
993
994    type cat {
995        component comp1
996        component comp1a
997    }
998
999    set a [lsort [dog info components]]
1000    set b [lsort [cat info components]]
1001    list $a $b
1002} -cleanup {
1003    dog destroy
1004    cat destroy
1005} -result {{comp1 comp2} {comp1 comp1a}}
1006
1007test tinfo-10.2a {type info component} -body {
1008    type dog {
1009        component comp1
1010        component comp2
1011    }
1012
1013    type cat {
1014        component comp1
1015        component comp1a
1016    }
1017
1018    set a [lsort [dog info component]]
1019    set b [lsort [cat info component]]
1020    list $a $b
1021} -cleanup {
1022    dog destroy
1023    cat destroy
1024} -result {{::dog::comp1 ::dog::comp2} {::cat::comp1 ::cat::comp1a}}
1025
1026test tinfo-10.2b {type info component with options} -body {
1027    type dog {
1028        component comp1
1029        component comp2
1030    }
1031
1032    dog info component comp1 -name -inherit
1033} -cleanup {
1034    dog destroy
1035} -result {::dog::comp1 0}
1036
1037test tinfo-10.4 {type info delegated methods} -body {
1038    type dog {
1039    }
1040
1041
1042    dog info delegated xxx
1043} -returnCodes {
1044    error
1045} -cleanup {
1046    dog destroy
1047} -result {wrong # args: should be one of...
1048  info methods ?pattern?
1049  info typemethods ?pattern?
1050  info options ?pattern?
1051...and others described on the man page}
1052
1053test tinfo-10.5 {type info delegated methods} -body {
1054    type dog {
1055        component comp1
1056        component comp2
1057        delegate method wag to comp1
1058        delegate method tail to comp2
1059        delegate typemethod typewag to comp1
1060        delegate typemethod typetail to comp2
1061        typeconstructor {
1062	    set comp1 string
1063	    set comp2 string
1064        }
1065    }
1066
1067
1068    lsort [dog info delegated methods]
1069} -cleanup {
1070    dog destroy
1071} -result {{tail comp2} {wag comp1}}
1072
1073test tinfo-10.5a {type info delegated method} -body {
1074    type dog {
1075        component comp1
1076        component comp2
1077        delegate method wag to comp1
1078        delegate method tail to comp2
1079        delegate typemethod typewag to comp1
1080        delegate typemethod typetail to comp2
1081        typeconstructor {
1082	    set comp1 string
1083	    set comp2 string
1084        }
1085    }
1086
1087
1088    lsort [dog info delegated method]
1089} -cleanup {
1090    dog destroy
1091} -result {tail wag}
1092
1093test tinfo-10.5b {type info delegated method with options} -body {
1094    type dog {
1095        component comp1
1096        component comp2
1097        delegate method wag to comp1
1098        delegate method tail to comp2
1099        delegate typemethod typewag to comp1
1100        delegate typemethod typetail to comp2
1101        typeconstructor {
1102	    set comp1 string
1103	    set comp2 string
1104        }
1105    }
1106
1107
1108    dog info delegated method wag -name -component -using -as -exceptions
1109} -cleanup {
1110    dog destroy
1111} -result {wag comp1 {} {} {}}
1112
1113test tinfo-10.5c {type info delegated typemethod} -body {
1114    type dog {
1115        component comp1
1116        component comp2
1117        delegate method wag to comp1
1118        delegate method tail to comp2
1119        delegate typemethod typewag to comp1
1120        delegate typemethod typetail to comp2
1121        typeconstructor {
1122	    set comp1 string
1123	    set comp2 string
1124        }
1125    }
1126
1127
1128    lsort [dog info delegated typemethod]
1129} -cleanup {
1130    dog destroy
1131} -result {typetail typewag}
1132
1133test tinfo-10.5d {type info delegated typemethod with options} -body {
1134    type dog {
1135        component comp1
1136        component comp2
1137        delegate method wag to comp1
1138        delegate method tail to comp2
1139        delegate typemethod typewag to comp1
1140        delegate typemethod typetail to comp2
1141        typeconstructor {
1142	    set comp1 string
1143	    set comp2 string
1144        }
1145    }
1146
1147
1148    dog info delegated typemethod typewag -name -component -using -as -exceptions
1149} -cleanup {
1150    dog destroy
1151} -result {typewag comp1 {} {} {}}
1152
1153test tinfo-10.6 {type info delegated typemethods} -body {
1154    type dog {
1155        component comp1
1156        component comp2
1157        delegate method wag to comp1
1158        delegate method tail to comp2
1159        delegate typemethod typewag to comp1
1160        delegate typemethod typetail to comp2
1161        typeconstructor {
1162	    set comp1 string
1163	    set comp2 string
1164        }
1165    }
1166
1167
1168    lsort [dog info delegated typemethods]
1169} -cleanup {
1170    dog destroy
1171} -result {{typetail comp2} {typewag comp1}}
1172
1173test tinfo-10.7 {type info delegated options} -body {
1174    type dog {
1175        component comp1
1176        component comp2
1177        component comp3
1178        delegate option -foo to comp1
1179        delegate option -bar to comp2
1180        delegate option * to comp3
1181        typeconstructor {
1182	    set comp1 string
1183	    set comp2 string
1184	    set comp3 string
1185        }
1186    }
1187
1188
1189    lsort [dog info delegated options]
1190} -cleanup {
1191    dog destroy
1192} -result {{* comp3} {-bar comp2} {-foo comp1}}
1193
1194test tinfo-11.1 {type info type} -body {
1195    type dog {
1196        typeconstructor {
1197        }
1198    }
1199
1200    dog info type
1201} -cleanup {
1202    dog destroy
1203} -result {::dog}
1204
1205
1206#---------------------------------------------------------------------
1207# Clean up
1208
1209cleanupTests
1210return
1211