File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,26 @@ test protect-1.1 {define a class with various protection levels} {
4444 }
4545 method do {args} {eval $args}
4646 }
47+
48+ # other class to test private/protected methods and procs of test_pr from there (see [3a2e7bf0e2]):
49+ itcl::class test_pr_b {
50+ public proc testp {} {
51+ set o [test_pr #auto]
52+ set res {}
53+ lappend res [catch { $o prom } v] $v [catch { $o prim } v] $v
54+ lappend res [catch { test_pr::prop } v] $v [catch { test_pr::prip } v] $v
55+ itcl::delete object $o
56+ set res
57+ }
58+ public method testm {} {
59+ set o [test_pr #auto]
60+ set res {}
61+ lappend res [catch { $o prom } v] $v [catch { $o prim } v] $v
62+ lappend res [catch { test_pr::prop } v] $v [catch { test_pr::prip } v] $v
63+ itcl::delete object $o
64+ set res
65+ }
66+ }
4767} ""
4868
4969test protect-1.2 {create an object to execute tests} {
@@ -110,6 +130,18 @@ test protect-1.8b {private procs can be accessed from inside} {
110130 list [catch {test_pr0 do prip} msg] $msg
111131} {0 {private proc}}
112132
133+ test protect-1.8c {protected/private methods/procs are blocked from outside, also in some itcl proc body, [3a2e7bf0e2]} -body {
134+ test_pr_b::testp
135+ } -match glob -result {1 {bad option "prom"*} 1 {bad option "prim"*} 1 {can't access "::test_pr::prop": protected function} 1 {can't access "::test_pr::prip": private function}}
136+
137+ test protect-1.8d {protected/private methods/procs are blocked from outside, also in some itcl method body, [3a2e7bf0e2]} -body {
138+ set b [test_pr_b #auto]
139+ set res [$b testm]
140+ itcl::delete object $b
141+ unset -nocomplain b
142+ set res
143+ } -match glob -result {1 {bad option "prom"*} 1 {bad option "prim"*} 1 {invalid command name "test_pr::prop"} 1 {invalid command name "test_pr::prip"}}
144+
113145test protect-1.9a {public commons can be accessed from outside} {
114146 list [catch {set test_pr::pubc} msg] $msg
115147} {0 {public com}}
You can’t perform that action at this time.
0 commit comments