Index: tests/protected.test =================================================================== diff -u -r38de75d755e2a10fb0fb5a2b75bf08a751b4b5c0 -r88d8fd1e2b40d5797eb86a0be4c5cae7c595fac6 --- tests/protected.test (.../protected.test) (revision 38de75d755e2a10fb0fb5a2b75bf08a751b4b5c0) +++ tests/protected.test (.../protected.test) (revision 88d8fd1e2b40d5797eb86a0be4c5cae7c595fac6) @@ -167,4 +167,46 @@ ? {o1 bar} "o1" ? {o1 foo2} "M2 M o1" -} \ No newline at end of file +} + +# +# test nsf::my + patch instead of "nsf::my -local" on classes +# + +nx::Test case my+handle-instead-of-my-local { + nx::Class create Base { + :protected method privateMethod {a b} { expr {$a + $b} } + :public method foo {a b} { nsf::my [Base info method handle privateMethod] $a $b } + } + + nx::Class create Sub -superclass Base { + :public method bar {a b} { nsf::my [Sub info method handle privateMethod] $a $b } + :public method privateMethod {a b} { expr {$a * $b} } + + :create s1 + } + + ? {s1 foo 3 4} 7 + ? {s1 bar 3 4} 12 +} + +# +# test object::dispatch instead of "nsf::my -local" on classes +# + +nx::Test case dispatch-instead-of-my-local { + nx::Class create Base { + :protected method privateMethod {a b} { expr {$a + $b} } + :public method foo {a b} { nsf::object::dispatch [self] [Base info method handle privateMethod] $a $b } + } + + nx::Class create Sub -superclass Base { + :public method bar {a b} { nsf::object::dispatch [self] [Sub info method handle privateMethod] $a $b } + :public method privateMethod {a b} { expr {$a * $b} } + + :create s1 + } + + ? {s1 foo 3 4} 7 + ? {s1 bar 3 4} 12 +}