OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [itcl/] [tests/] [inherit.test] - Blame information for rev 1773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
#
2
# Tests for inheritance and scope handling
3
# ----------------------------------------------------------------------
4
#   AUTHOR:  Michael J. McLennan
5
#            Bell Labs Innovations for Lucent Technologies
6
#            mmclennan@lucent.com
7
#            http://www.tcltk.com/itcl
8
#
9
#      RCS:  $Id: inherit.test,v 1.1.1.1 2002-01-16 10:24:47 markom Exp $
10
# ----------------------------------------------------------------------
11
#            Copyright (c) 1993-1998  Lucent Technologies, Inc.
12
# ======================================================================
13
# See the file "license.terms" for information on usage and
14
# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
15
 
16
if {[string compare test [info procs test]] == 1} then {source defs}
17
 
18
# ----------------------------------------------------------------------
19
#  Test construction/destruction with inheritance
20
# ----------------------------------------------------------------------
21
test inherit-1.1 {define classes with constructors/destructors} {
22
    variable ::test_cd_watch ""
23
    itcl::class test_cd_foo {
24
        constructor {x y} {
25
            global ::test_cd_watch
26
            lappend test_cd_watch "foo: $x $y"
27
        }
28
        destructor {
29
            global ::test_cd_watch
30
            lappend test_cd_watch "foo destruct"
31
        }
32
    }
33
    itcl::class test_cd_bar {
34
        constructor {args} {
35
            global ::test_cd_watch
36
            lappend test_cd_watch "bar: $args"
37
        }
38
        destructor {
39
            global ::test_cd_watch
40
            lappend test_cd_watch "bar destruct"
41
        }
42
    }
43
    itcl::class test_cd_foobar {
44
        inherit test_cd_foo test_cd_bar
45
        constructor {x y args} {
46
            test_cd_foo::constructor $x $y
47
        } {
48
            global ::test_cd_watch
49
            lappend test_cd_watch "foobar: $x $y ($args)"
50
        }
51
        destructor {
52
            global ::test_cd_watch
53
            lappend test_cd_watch "foobar destruct"
54
        }
55
    }
56
    itcl::class test_cd_geek {
57
        constructor {} {
58
            global ::test_cd_watch
59
            lappend test_cd_watch "geek"
60
        }
61
        destructor {
62
            global ::test_cd_watch
63
            lappend test_cd_watch "geek destruct"
64
        }
65
    }
66
    itcl::class test_cd_mongrel {
67
        inherit test_cd_foobar test_cd_geek
68
        constructor {x} {
69
            eval test_cd_foobar::constructor 1 2 fred $x
70
        } {
71
            global ::test_cd_watch
72
            lappend test_cd_watch "mongrel: $x"
73
        }
74
        destructor {
75
            global ::test_cd_watch
76
            lappend test_cd_watch "mongrel destruct"
77
        }
78
    }
79
    itcl::class test_cd_none {
80
        inherit test_cd_bar test_cd_geek
81
    }
82
    itcl::class test_cd_skip {
83
        inherit test_cd_none
84
        constructor {} {
85
            global ::test_cd_watch
86
            lappend test_cd_watch "skip"
87
        }
88
        destructor {
89
            global ::test_cd_watch
90
            lappend test_cd_watch "skip destruct"
91
        }
92
    }
93
} {}
94
 
95
test inherit-1.2 {constructors should be invoked in the proper order} {
96
    set ::test_cd_watch ""
97
    list [test_cd_mongrel #auto bob] [set ::test_cd_watch]
98
} {test_cd_mongrel0 {{foo: 1 2} {bar: } {foobar: 1 2 (fred bob)} geek {mongrel: bob}}}
99
 
100
test inherit-1.3 {destructors should be invoked in the proper order} {
101
    set ::test_cd_watch ""
102
    list [delete object test_cd_mongrel0] [set ::test_cd_watch]
103
} {{} {{mongrel destruct} {foobar destruct} {foo destruct} {bar destruct} {geek destruct}}}
104
 
105
test inherit-1.4 {constructors are optional} {
106
    set ::test_cd_watch ""
107
    list [test_cd_none #auto] [set ::test_cd_watch]
108
} {test_cd_none0 {geek {bar: }}}
109
 
110
test inherit-1.5 {destructors are optional} {
111
    set ::test_cd_watch ""
112
    list [delete object test_cd_none0] [set ::test_cd_watch]
113
} {{} {{bar destruct} {geek destruct}}}
114
 
115
test inherit-1.6 {construction ok if constructors are missing} {
116
    set ::test_cd_watch ""
117
    list [test_cd_skip #auto] [set ::test_cd_watch]
118
} {test_cd_skip0 {geek {bar: } skip}}
119
 
120
test inherit-1.7 {destruction ok if destructors are missing} {
121
    set ::test_cd_watch ""
122
    list [delete object test_cd_skip0] [set ::test_cd_watch]
123
} {{} {{skip destruct} {bar destruct} {geek destruct}}}
124
 
125
test inherit-1.8 {errors during construction are cleaned up and reported} {
126
    global errorInfo test_cd_watch
127
    set test_cd_watch ""
128
    body test_cd_bar::constructor {args} {error "bar: failed"}
129
    list [catch {test_cd_mongrel #auto bob} msg] $msg \
130
        $errorInfo $test_cd_watch
131
} {1 {bar: failed} {bar: failed
132
    while executing
133
"error "bar: failed""
134
    while constructing object "::test_cd_mongrel1" in ::test_cd_bar::constructor (body line 1)
135
    while constructing object "::test_cd_mongrel1" in ::test_cd_foobar::constructor (body line 1)
136
    invoked from within
137
"test_cd_foobar::constructor 1 2 fred bob"
138
    ("eval" body line 1)
139
    invoked from within
140
"eval test_cd_foobar::constructor 1 2 fred $x"
141
    while constructing object "::test_cd_mongrel1" in ::test_cd_mongrel::constructor (body line 2)
142
    invoked from within
143
"test_cd_mongrel #auto bob"} {{foo: 1 2} {mongrel destruct} {foobar destruct} {foo destruct} {bar destruct} {geek destruct}}}
144
 
145
test inherit-1.9 {errors during destruction prevent object delete} {
146
    global errorInfo test_cd_watch
147
    body test_cd_bar::constructor {args} {return "bar: $args"}
148
    body test_cd_bar::destructor {} {error "bar: failed"}
149
    test_cd_mongrel mongrel1 ted
150
    set test_cd_watch ""
151
    list [catch {delete object mongrel1} msg] $msg \
152
        $errorInfo $test_cd_watch [find objects mongrel*]
153
} {1 {bar: failed} {bar: failed
154
    while executing
155
"error "bar: failed""
156
    while deleting object "::mongrel1" in ::test_cd_bar::destructor (body line 1)
157
    invoked from within
158
"delete object mongrel1"} {{mongrel destruct} {foobar destruct} {foo destruct}} mongrel1}
159
 
160
test inherit-1.10 {errors during destruction prevent class delete} {
161
    list [catch {delete class test_cd_foo} msg] $msg
162
} {1 {bar: failed}}
163
 
164
eval namespace delete [find classes test_cd_*]
165
 
166
# ----------------------------------------------------------------------
167
#  Test data member access and scoping
168
# ----------------------------------------------------------------------
169
test inherit-2.1 {define classes with data members} {
170
    itcl::class test_cd_foo {
171
        protected variable x "foo-x"
172
        method do {args} {eval $args}
173
    }
174
    itcl::class test_cd_bar {
175
        protected variable x "bar-x"
176
        method do {args} {eval $args}
177
    }
178
    itcl::class test_cd_foobar {
179
        inherit test_cd_foo test_cd_bar
180
        method do {args} {eval $args}
181
    }
182
    itcl::class test_cd_geek {
183
        method do {args} {eval $args}
184
    }
185
    itcl::class test_cd_mongrel {
186
        inherit test_cd_foobar test_cd_geek
187
        protected variable x "mongrel-x"
188
        method do {args} {eval $args}
189
    }
190
} {}
191
 
192
test inherit-2.2 {"info" provides access to shadowed data members} {
193
    test_cd_mongrel #auto
194
    list [lsort [test_cd_mongrel0 info variable]] \
195
         [test_cd_mongrel0 info variable test_cd_foo::x] \
196
         [test_cd_mongrel0 info variable test_cd_bar::x] \
197
         [test_cd_mongrel0 info variable test_cd_mongrel::x] \
198
         [test_cd_mongrel0 info variable x]
199
} {{::test_cd_bar::x ::test_cd_foo::x ::test_cd_mongrel::this ::test_cd_mongrel::x} {protected variable ::test_cd_foo::x foo-x foo-x} {protected variable ::test_cd_bar::x bar-x bar-x} {protected variable ::test_cd_mongrel::x mongrel-x mongrel-x} {protected variable ::test_cd_mongrel::x mongrel-x mongrel-x}}
200
 
201
test inherit-2.3 {variable resolution works properly in methods} {
202
    list [test_cd_mongrel0 test_cd_foo::do set x] \
203
         [test_cd_mongrel0 test_cd_bar::do set x] \
204
         [test_cd_mongrel0 test_cd_foobar::do set x] \
205
         [test_cd_mongrel0 test_cd_mongrel::do set x]
206
} {foo-x bar-x foo-x mongrel-x}
207
 
208
test inherit-2.4 {methods have access to shadowed data members} {
209
    list [test_cd_mongrel0 test_cd_foobar::do set x] \
210
         [test_cd_mongrel0 test_cd_foobar::do set test_cd_foo::x] \
211
         [test_cd_mongrel0 test_cd_foobar::do set test_cd_bar::x] \
212
         [test_cd_mongrel0 test_cd_mongrel::do set test_cd_foo::x] \
213
         [test_cd_mongrel0 test_cd_mongrel::do set test_cd_bar::x]
214
} {foo-x foo-x bar-x foo-x bar-x}
215
 
216
eval namespace delete [find classes test_cd_*]
217
 
218
# ----------------------------------------------------------------------
219
#  Test public variables and "configure" method
220
# ----------------------------------------------------------------------
221
test inherit-3.1 {define classes with public variables} {
222
    variable ::test_cd_watch ""
223
    itcl::class test_cd_foo {
224
        public variable x "foo-x" {
225
            global test_cd_watch
226
            lappend test_cd_watch "foo: $x in scope [namespace current]"
227
        }
228
        method do {args} {eval $args}
229
    }
230
    itcl::class test_cd_bar {
231
        public variable x "bar-x" {
232
            global test_cd_watch
233
            lappend test_cd_watch "bar: $x in scope [namespace current]"
234
        }
235
        method do {args} {eval $args}
236
    }
237
    itcl::class test_cd_foobar {
238
        inherit test_cd_foo test_cd_bar
239
        method do {args} {eval $args}
240
    }
241
    itcl::class test_cd_geek {
242
        method do {args} {eval $args}
243
    }
244
    itcl::class test_cd_mongrel {
245
        inherit test_cd_foobar test_cd_geek
246
        public variable x "mongrel-x" {
247
            global test_cd_watch
248
            lappend test_cd_watch "mongrel: $x in scope [namespace current]"
249
        }
250
        method do {args} {eval $args}
251
    }
252
} {}
253
 
254
test inherit-3.2 {create an object with public variables} {
255
    test_cd_mongrel #auto
256
} {test_cd_mongrel0}
257
 
258
test inherit-3.3 {"configure" lists all public variables} {
259
    lsort [test_cd_mongrel0 configure]
260
} {{-test_cd_bar::x bar-x bar-x} {-test_cd_foo::x foo-x foo-x} {-x mongrel-x mongrel-x}}
261
 
262
test inherit-3.4 {"configure" treats simple names as "most specific"} {
263
    lsort [test_cd_mongrel0 configure -x]
264
} {-x mongrel-x mongrel-x}
265
 
266
test inherit-3.5 {"configure" treats simple names as "most specific"} {
267
    set ::test_cd_watch ""
268
    list [test_cd_mongrel0 configure -x hello] \
269
         [set ::test_cd_watch]
270
} {{} {{mongrel: hello in scope ::test_cd_mongrel}}}
271
 
272
test inherit-3.6 {"configure" allows access to shadowed options} {
273
    set ::test_cd_watch ""
274
    list [test_cd_mongrel0 configure -test_cd_foo::x hello] \
275
         [test_cd_mongrel0 configure -test_cd_bar::x there] \
276
         [set ::test_cd_watch]
277
} {{} {} {{foo: hello in scope ::test_cd_foo} {bar: there in scope ::test_cd_bar}}}
278
 
279
test inherit-3.7 {"configure" will change several variables at once} {
280
    set ::test_cd_watch ""
281
    list [test_cd_mongrel0 configure -x one \
282
                                     -test_cd_foo::x two \
283
                                     -test_cd_bar::x three] \
284
         [set ::test_cd_watch]
285
} {{} {{mongrel: one in scope ::test_cd_mongrel} {foo: two in scope ::test_cd_foo} {bar: three in scope ::test_cd_bar}}}
286
 
287
test inherit-3.8 {"cget" does proper name resolution} {
288
    list [test_cd_mongrel0 cget -x] \
289
         [test_cd_mongrel0 cget -test_cd_foo::x] \
290
         [test_cd_mongrel0 cget -test_cd_bar::x] \
291
         [test_cd_mongrel0 cget -test_cd_mongrel::x]
292
} {one two three one}
293
 
294
eval namespace delete [find classes test_cd_*]
295
 
296
# ----------------------------------------------------------------------
297
#  Test inheritance info
298
# ----------------------------------------------------------------------
299
test inherit-4.1 {define classes for inheritance info} {
300
    itcl::class test_cd_foo {
301
        method do {args} {eval $args}
302
    }
303
    itcl::class test_cd_bar {
304
        method do {args} {eval $args}
305
    }
306
    itcl::class test_cd_foobar {
307
        inherit test_cd_foo test_cd_bar
308
        method do {args} {eval $args}
309
    }
310
    itcl::class test_cd_geek {
311
        method do {args} {eval $args}
312
    }
313
    itcl::class test_cd_mongrel {
314
        inherit test_cd_foobar test_cd_geek
315
        method do {args} {eval $args}
316
    }
317
} {}
318
 
319
test inherit-4.2 {create an object for inheritance tests} {
320
    test_cd_mongrel #auto
321
} {test_cd_mongrel0}
322
 
323
test inherit-4.3 {"info class" should be virtual} {
324
    list [test_cd_mongrel0 info class] \
325
         [test_cd_mongrel0 test_cd_foo::do info class] \
326
         [test_cd_mongrel0 test_cd_geek::do info class]
327
} {::test_cd_mongrel ::test_cd_mongrel ::test_cd_mongrel}
328
 
329
test inherit-4.4 {"info inherit" depends on class scope} {
330
    list [test_cd_mongrel0 info inherit] \
331
         [test_cd_mongrel0 test_cd_foo::do info inherit] \
332
         [test_cd_mongrel0 test_cd_foobar::do info inherit]
333
} {{::test_cd_foobar ::test_cd_geek} {} {::test_cd_foo ::test_cd_bar}}
334
 
335
test inherit-4.5 {"info heritage" depends on class scope} {
336
    list [test_cd_mongrel0 info heritage] \
337
         [test_cd_mongrel0 test_cd_foo::do info heritage] \
338
         [test_cd_mongrel0 test_cd_foobar::do info heritage]
339
} {{::test_cd_mongrel ::test_cd_foobar ::test_cd_foo ::test_cd_bar ::test_cd_geek} ::test_cd_foo {::test_cd_foobar ::test_cd_foo ::test_cd_bar}}
340
 
341
test inherit-4.6 {built-in "isa" method works} {
342
    set status ""
343
    foreach c [test_cd_mongrel0 info heritage] {
344
        lappend status [test_cd_mongrel0 isa $c]
345
    }
346
    set status
347
} {1 1 1 1 1}
348
 
349
test inherit-4.7 {built-in "isa" method works within methods} {
350
    set status ""
351
    foreach c [test_cd_mongrel0 info heritage] {
352
        lappend status [test_cd_mongrel0 test_cd_foo::do isa $c]
353
    }
354
    set status
355
} {1 1 1 1 1}
356
 
357
test inherit-4.8 {built-in "isa" method recognizes bad classes} {
358
    class test_cd_other {}
359
    test_cd_mongrel0 isa test_cd_other
360
} {0}
361
 
362
test inherit-4.9 {built-in "isa" method recognizes bad classes} {
363
    list [catch {test_cd_mongrel0 isa test_cd_bogus} msg] $msg
364
} {1 {class "test_cd_bogus" not found in context "::test_cd_foo"}}
365
 
366
eval namespace delete [find classes test_cd_*]
367
 
368
# ----------------------------------------------------------------------
369
#  Test "find objects"
370
# ----------------------------------------------------------------------
371
test inherit-5.1 {define classes for inheritance info} {
372
    itcl::class test_cd_foo {
373
    }
374
    itcl::class test_cd_bar {
375
    }
376
    itcl::class test_cd_foobar {
377
        inherit test_cd_foo test_cd_bar
378
    }
379
    itcl::class test_cd_geek {
380
    }
381
    itcl::class test_cd_mongrel {
382
        inherit test_cd_foobar test_cd_geek
383
    }
384
} {}
385
 
386
test inherit-5.2 {create objects for info tests} {
387
    list [test_cd_foo #auto] [test_cd_foo #auto] \
388
         [test_cd_foobar #auto] \
389
         [test_cd_geek #auto] \
390
         [test_cd_mongrel #auto]
391
} {test_cd_foo0 test_cd_foo1 test_cd_foobar0 test_cd_geek0 test_cd_mongrel0}
392
 
393
test inherit-5.3 {find objects: -class qualifier} {
394
    lsort [find objects -class test_cd_foo]
395
} {test_cd_foo0 test_cd_foo1}
396
 
397
test inherit-5.4 {find objects: -class qualifier} {
398
    lsort [find objects -class test_cd_mongrel]
399
} {test_cd_mongrel0}
400
 
401
test inherit-5.5 {find objects: -isa qualifier} {
402
    lsort [find objects -isa test_cd_foo]
403
} {test_cd_foo0 test_cd_foo1 test_cd_foobar0 test_cd_mongrel0}
404
 
405
test inherit-5.6 {find objects: -isa qualifier} {
406
    lsort [find objects -isa test_cd_mongrel]
407
} {test_cd_mongrel0}
408
 
409
test inherit-5.7 {find objects: name qualifier} {
410
    lsort [find objects test_cd_foo*]
411
} {test_cd_foo0 test_cd_foo1 test_cd_foobar0}
412
 
413
test inherit-5.8 {find objects: -class and -isa qualifiers} {
414
    lsort [find objects -isa test_cd_foo -class test_cd_foobar]
415
} {test_cd_foobar0}
416
 
417
test inherit-5.9 {find objects: -isa and name qualifiers} {
418
    lsort [find objects -isa test_cd_foo *0]
419
} {test_cd_foo0 test_cd_foobar0 test_cd_mongrel0}
420
 
421
test inherit-5.10 {find objects: usage errors} {
422
    list [catch {find objects -xyzzy} msg] $msg
423
} {1 {wrong # args: should be "find objects ?-class className? ?-isa className? ?pattern?"}}
424
 
425
eval namespace delete [find classes test_cd_*]
426
 
427
# ----------------------------------------------------------------------
428
#  Test method scoping and execution
429
# ----------------------------------------------------------------------
430
test inherit-6.1 {define classes for scope tests} {
431
    itcl::class test_cd_foo {
432
        method check {} {return "foo"}
433
        method do {args} {return "foo says: [eval $args]"}
434
    }
435
    itcl::class test_cd_bar {
436
        method check {} {return "bar"}
437
        method do {args} {return "bar says: [eval $args]"}
438
    }
439
    itcl::class test_cd_foobar {
440
        inherit test_cd_foo test_cd_bar
441
        method check {} {return "foobar"}
442
        method do {args} {return "foobar says: [eval $args]"}
443
    }
444
    itcl::class test_cd_geek {
445
        method check {} {return "geek"}
446
        method do {args} {return "geek says: [eval $args]"}
447
    }
448
    itcl::class test_cd_mongrel {
449
        inherit test_cd_foobar test_cd_geek
450
        method check {} {return "mongrel"}
451
        method do {args} {return "mongrel says: [eval $args]"}
452
    }
453
} {}
454
 
455
test inherit-6.2 {create objects for scoping tests} {
456
    list [test_cd_mongrel #auto] [test_cd_foobar #auto]
457
} {test_cd_mongrel0 test_cd_foobar0}
458
 
459
test inherit-6.3 {methods are "virtual" outside of the class} {
460
    test_cd_mongrel0 check
461
} {mongrel}
462
 
463
test inherit-6.4 {specific methods can be accessed by name} {
464
    test_cd_mongrel0 test_cd_foo::check
465
} {foo}
466
 
467
test inherit-6.5 {methods are "virtual" within a class too} {
468
    test_cd_mongrel0 test_cd_foobar::do check
469
} {foobar says: mongrel}
470
 
471
test inherit-6.6 {methods are executed where they were defined} {
472
    list [test_cd_mongrel0 test_cd_foo::do namespace current] \
473
         [test_cd_mongrel0 test_cd_foobar::do namespace current] \
474
         [test_cd_mongrel0 do namespace current] \
475
} {{foo says: ::test_cd_foo} {foobar says: ::test_cd_foobar} {mongrel says: ::test_cd_mongrel}}
476
 
477
test inherit-6.7 {"virtual" command no longer exists} {
478
    list [catch {
479
        test_cd_mongrel0 test_cd_foobar::do virtual namespace current
480
    } msg] $msg
481
} {1 {invalid command name "virtual"}}
482
 
483
test inherit-6.8 {"previous" command no longer exists} {
484
    list [catch {
485
        test_cd_mongrel0 test_cd_foobar::do previous check
486
    } msg] $msg
487
} {1 {invalid command name "previous"}}
488
 
489
test inherit-6.9 {errors are detected and reported across class boundaries} {
490
    list [catch {
491
        test_cd_mongrel0 do test_cd_foobar0 do error "test" "some error"
492
    } msg] $msg [set ::errorInfo]
493
} {1 test {some error
494
    ("eval" body line 1)
495
    invoked from within
496
"eval $args"
497
    (object "::test_cd_foobar0" method "::test_cd_foobar::do" body line 1)
498
    invoked from within
499
"test_cd_foobar0 do error test {some error}"
500
    ("eval" body line 1)
501
    invoked from within
502
"eval $args"
503
    (object "::test_cd_mongrel0" method "::test_cd_mongrel::do" body line 1)
504
    invoked from within
505
"test_cd_mongrel0 do test_cd_foobar0 do error "test" "some error""}}
506
 
507
test inherit-6.10 {errors codes are preserved across class boundaries} {
508
    list [catch {
509
        test_cd_mongrel0 do test_cd_foobar0 do error "test" "problem" CODE-BLUE
510
    } msg] $msg [set ::errorCode]
511
} {1 test CODE-BLUE}
512
 
513
test inherit-6.11 {multi-value error codes are preserved across class boundaries} {
514
    list [catch {
515
        test_cd_mongrel0 do test_cd_foobar0 do error "test" "problem" "CODE BLUE 123"
516
    } msg] $msg [set ::errorCode]
517
} {1 test {CODE BLUE 123}}
518
 
519
eval namespace delete [find classes test_cd_*]
520
 
521
# ----------------------------------------------------------------------
522
#  Test inheritance errors
523
# ----------------------------------------------------------------------
524
test inherit-7.1 {cannot inherit from non-existant class} {
525
    list [catch {
526
        itcl::class bogus {
527
            inherit non_existant_class_xyzzy
528
        }
529
    } msg] $msg
530
} {1 {cannot inherit from "non_existant_class_xyzzy" (class "non_existant_class_xyzzy" not found in context "::")}}
531
 
532
test inherit-7.2 {cannot inherit from procs} {
533
    proc inherit_test_proc {x y} {
534
        error "never call this"
535
    }
536
    list [catch {
537
        itcl::class bogus {
538
            inherit inherit_test_proc
539
        }
540
    } msg] $msg
541
} {1 {cannot inherit from "inherit_test_proc" (class "inherit_test_proc" not found in context "::")}}
542
 
543
test inherit-7.3 {cannot inherit from yourself} {
544
    list [catch {
545
        itcl::class bogus {
546
            inherit bogus
547
        }
548
    } msg] $msg
549
} {1 {class "bogus" cannot inherit from itself}}
550
 
551
test inherit-7.4 {cannot have more than one inherit statement} {
552
    list [catch {
553
        itcl::class test_inherit_base1 { }
554
        itcl::class test_inherit_base2 { }
555
        itcl::class bogus {
556
            inherit test_inherit_base1
557
            inherit test_inherit_base2
558
        }
559
    } msg] $msg
560
} {1 {inheritance "test_inherit_base1 " already defined for class "::bogus"}}
561
 
562
# ----------------------------------------------------------------------
563
#  Multiple base class error detection
564
# ----------------------------------------------------------------------
565
test inherit-8.1 {cannot inherit from the same base class more than once} {
566
    class test_mi_base {}
567
    class test_mi_foo {inherit test_mi_base}
568
    class test_mi_bar {inherit test_mi_base}
569
    list [catch {
570
        class test_mi_foobar {inherit test_mi_foo test_mi_bar}
571
    } msg] $msg
572
} {1 {class "::test_mi_foobar" inherits base class "::test_mi_base" more than once:
573
  test_mi_foobar->test_mi_foo->test_mi_base
574
  test_mi_foobar->test_mi_bar->test_mi_base}}
575
 
576
delete class test_mi_base

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.