Index: TODO =================================================================== diff -u -r38de75d755e2a10fb0fb5a2b75bf08a751b4b5c0 -r88d8fd1e2b40d5797eb86a0be4c5cae7c595fac6 --- TODO (.../TODO) (revision 38de75d755e2a10fb0fb5a2b75bf08a751b4b5c0) +++ TODO (.../TODO) (revision 88d8fd1e2b40d5797eb86a0be4c5cae7c595fac6) @@ -3326,10 +3326,13 @@ * fixed "nsf::my -local ..." (never worked in nsf) * added regression test +- documenting current behavior + * test method-handle + next + dispatch (unwanted) + * test "my -local" vs my + method handle + * test "my -local" vs dispatch + method handle + TODO: - - test next + dispatch - - test "my -local" vs dispatch - nx: * maybe provide a replacement for -attributes, but without the magic variable. Index: tests/interceptor-slot.test =================================================================== diff -u -rb8c0176cfeae7f18490e9d6887ece97b713f0fe0 -r88d8fd1e2b40d5797eb86a0be4c5cae7c595fac6 --- tests/interceptor-slot.test (.../interceptor-slot.test) (revision b8c0176cfeae7f18490e9d6887ece97b713f0fe0) +++ tests/interceptor-slot.test (.../interceptor-slot.test) (revision 88d8fd1e2b40d5797eb86a0be4c5cae7c595fac6) @@ -221,7 +221,12 @@ ? {c1 [C info method origin foo]} "C B A " ? {c1 [B info method origin foo]} "B A " ? {c1 [A info method origin foo]} "A " - + + # documententing unwanted behavior + ? {nsf::object::dispatch c1 foo} "C B A " + ? {nsf::object::dispatch c1 [C info method origin foo]} "C C B A " + ? {nsf::object::dispatch c1 [B info method origin foo]} "B C B A " + ? {nsf::object::dispatch c1 [A info method origin foo]} "A C B A " } # 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 +}