Index: tests/submethods.test =================================================================== diff -u -r0f86bfbcfeca560a5444cdd00bd535e0960e6d00 -ra2ab20d38f32b93bf4673def3a71214773b46bdf --- tests/submethods.test (.../submethods.test) (revision 0f86bfbcfeca560a5444cdd00bd535e0960e6d00) +++ tests/submethods.test (.../submethods.test) (revision a2ab20d38f32b93bf4673def3a71214773b46bdf) @@ -985,6 +985,88 @@ } +nx::test case ensemble-private-helper { + + nx::Class create B { + :public method "bar 1" {} {return [list B.bar.1 {*}[next]]} + :public method "baz 1" {} {return [list B.baz.1 {*}[next]]} + :create b1 { + :public object method foo {} {: -local bar 1} + :public object method foo2 {} {:bar 1} + :private object method "bar 1" {} {: -local baz 1} + :private object method "baz 1" {} {return [list "b1.baz.1" {*}[next]]} + } + } + nx::Class create C -superclass B { + :public method "bar 1" {} {return [list C.bar.1 {*}[next]]} + :public method "baz 1" {} {return [list C.baz.1 {*}[next]]} + :create c1 { + :public object method foo {} {: -local bar 1} + :public object method foo2 {} {:bar 1} + :private object method "bar 1" {} {: -local baz 1} + :private object method "baz 1" {} {return [list "c1.baz.1" {*}[next]]} + } + } + + ? {b1 bar 1} "B.bar.1" + ? {b1 baz 1} "B.baz.1" + ? {b1 foo} "b1.baz.1 B.baz.1" + ? {b1 foo2} "B.bar.1" + + ? {c1 bar 1} "C.bar.1 B.bar.1" + ? {c1 baz 1} "C.baz.1 B.baz.1" + ? {c1 foo} "c1.baz.1 C.baz.1 B.baz.1" + ? {c1 foo2} "C.bar.1 B.bar.1" +} + +nx::test case ensemble-private-local-checks { + + nx::Class create B { + :public method "bar 1" {} {return [list B.bar.1 {*}[next]]} + :public method "bar 2" {} {return [list B.bar.2 {*}[next]]} + :public method FOO1 {} {: -local bar 1} + :public method FOO2 {} {:bar 1} + :public method "FOO3 FAR FIM" {} {: -local bar 1} + :create b1 { + :public object method foo {} {: -local bar 1} + :public object method faa {} {: -local noop 2} + :public object method fee1 {} {: -local bar 2} + :public object method fee2 {} {: -local bar 3} + :private object method "bar 1" {} {: -local baz 1} + :private object method "baz 1" {} {return "b1.baz.1"} + } + } + nx::Class create C -superclass B { + :public method "bar 1" {} {return [list C.bar.1 {*}[next]]} + :public method "baz 1" {} {return [list C.baz.1 {*}[next]]} + :create c1 { + :public object method foo {} {: -local bar 1} + :public object method faa {} {: -local noop 2} + :public object method fee1 {} {: -local bar 2} + :public object method fee2 {} {: -local bar 3} + :private object method "bar 1" {} {: -local baz 1} + :private object method "baz 1" {} {return "c1.baz.1"} + } + } + + ? {b1 faa} "::b1: unable to dispatch method 'noop'" + ? {b1 foo} "b1.baz.1" + ? {b1 fee1} "B.bar.2" + ? {b1 fee2} "unable to dispatch sub-method \"3\" of ::b1 bar; valid are: bar 1, bar 2" + ? {b1 FOO1} "B.bar.1" + ? {b1 FOO2} "B.bar.1" + ? {b1 FOO3 FAR FIM} "B.bar.1" + + ? {c1 faa} "::c1: unable to dispatch method 'noop'" + ? {c1 foo} "c1.baz.1" + ? {c1 fee1} "B.bar.2" + ? {c1 fee2} "unable to dispatch sub-method \"3\" of ::c1 bar; valid are: bar 1, bar 2" + ? {c1 FOO1} "B.bar.1" + ? {c1 FOO2} "C.bar.1 B.bar.1" + ? {c1 FOO3 FAR FIM} "B.bar.1" + +} + # # Local variables: # mode: tcl