1# Test file for: 2# auto_mkindex 3# 4# This file provides example cases for testing the Tcl autoloading 5# facility. Things are much more complicated with namespaces and classes. 6# The "auto_mkindex" facility can no longer be built on top of a simple 7# regular expression parser. It must recognize constructs like this: 8# 9# namespace eval foo { 10# class Internal { ... } 11# body Internal::func {x y} { ... } 12# namespace eval bar { 13# class Another { ... } 14# } 15# } 16# 17# Note that class definitions can be nested inside of namespaces. 18# 19# Copyright (c) 1993-1998 Lucent Technologies, Inc. 20 21# 22# Should be able to handle simple class definitions, even if 23# they are prefaced with white space. 24# 25namespace import itcl::* 26 27class Simple1 { 28 variable x 0 29 public method bump {} {incr x} 30} 31 itcl::class Simple2 { 32 variable x 0 33 public variable by 1 34 public method bump {} 35 } 36 37itcl::ensemble ens { 38 part one {x} {} 39 part two {x y} {} 40 part three {x y z} {} 41} 42 43# 44# Should be able to handle "body" and "configbody" declarations. 45# 46body Simple2::bump {} {incr x $by} 47configbody Simple2::by {if {$by <= 0} {error "bad increment"}} 48 49# 50# Should be able to handle class declarations within namespaces, 51# even if they have explicit namespace paths. 52# 53namespace eval buried { 54 class inside { 55 variable x 0 56 public variable by 1 57 public method bump {} 58 method skip {x y z} {} 59 proc find {args} {} 60 } 61 body inside::bump {} {incr x $by} 62 configbody inside::by {if {$by <= 0} {error "bad increment"}} 63 64 class ::top { 65 method skip {x y z} {} 66 method ignore {} {} 67 public proc find {args} {} 68 protected proc notice {args} {} 69 } 70 71 ensemble ens { 72 part one {x} {} 73 part two {x y} {} 74 part three {x y z} {} 75 } 76 77 namespace eval under { 78 itcl::class neath { } 79 } 80 namespace eval deep { 81 ::itcl::class within { } 82 } 83} 84