Index: tests/aliastest.xotcl =================================================================== diff -u -rdb7c710aa3b6386c33af9a318876f21a88b8aafd -rf852fb6ccdfd85c86ae15f2a9ee84350e2d56dab --- tests/aliastest.xotcl (.../aliastest.xotcl) (revision db7c710aa3b6386c33af9a318876f21a88b8aafd) +++ tests/aliastest.xotcl (.../aliastest.xotcl) (revision f852fb6ccdfd85c86ae15f2a9ee84350e2d56dab) @@ -229,7 +229,6 @@ } V method bar {z} { return $z } - V method -per-object bar {z} { return $z } proc foo args { return [.bar ${.z}]-[set .z]-[my bar [set .z]] } @@ -243,4 +242,119 @@ V method FOO1 {} {} ? {lsort [V info methods -defined -methodtype scripted]} {bar} rename ::foo "" -? {lsort [V info methods -per-object -defined -methodtype scripted]} {bar} \ No newline at end of file +? {lsort [V info methods -per-object -defined -methodtype scripted]} {bar} + + +# +# Tests for the ::xotcl::alias store, used for introspection for +# aliases. The alias store (an associative variable) is mostly +# necessary for for the direct aliases (e.g. aliases to C implemented +# tcl commands), for which we have no stubs at the place where the +# alias was registered. +# +::xotcl::use xotcl2 + +# +# structure of the ::xotcl::alias store: +# ,, -> +# + +Object create o +Class create C + +o method bar args {;} + +? {info vars ::xotcl::alias} ::xotcl::alias +? {array exists ::xotcl::alias} 1 + +proc ::foo args {;} +::xotcl::alias ::o FOO ::foo +::xotcl::alias ::C FOO ::foo +? {info exists ::xotcl::alias(::o,FOO,1)} 1 +? {info exists ::xotcl::alias(::C,FOO,0)} 1 +? {array get ::xotcl::alias ::o,FOO,1} "::o,FOO,1 ::foo" +? {array get ::xotcl::alias ::C,FOO,0} "::C,FOO,0 ::foo" +? {o info alias -definition FOO} ::foo +? {C info alias -definition FOO} ::foo + +::xotcl::alias o FOO ::o::bar +? {info exists ::xotcl::alias(::o,FOO,1)} 1 +? {array get ::xotcl::alias ::o,FOO,1} "::o,FOO,1 ::o::bar" +? {o info alias -definition FOO} ::o::bar + +# AliasDelete in XOTclRemovePMethod +o method FOO {} {} +? {info exists ::xotcl::alias(::o,FOO,1)} 0 +? {array get ::xotcl::alias ::o,FOO,1} "" +? {o info alias -definition FOO} "" + +# AliasDelete in XOTclRemoveIMethod +C method FOO {} {} +? {info exists ::xotcl::alias(::C,FOO,0)} 0 +? {array get ::xotcl::alias ::C,FOO,0} "" +? {C info alias -definition FOO} "" + +::xotcl::alias ::o BAR ::foo +::xotcl::alias ::C BAR ::foo + +# AliasDelete in XOTclAddObjectMethod +? {info exists ::xotcl::alias(::o,BAR,1)} 1 +::o method BAR {} {;} +? {info exists ::xotcl::alias(::o,BAR,1)} 0 + +# AliasDelete in XOTclAddInstanceMethod +? {info exists ::xotcl::alias(::C,BAR,0)} 1 +::C method BAR {} {;} +? {info exists ::xotcl::alias(::C,BAR,0)} 0 + +# AliasDelete in aliasCmdDeleteProc +::xotcl::alias o FOO ::foo +? {info exists ::xotcl::alias(::o,FOO,1)} 1 +rename ::foo "" +? {info exists ::xotcl::alias(::o,FOO,1)} 0 + +::xotcl::alias o FOO ::o::bar +::xotcl::alias o BAR ::o::FOO +? {info exists ::xotcl::alias(::o,FOO,1)} 1 +? {info exists ::xotcl::alias(::o,BAR,1)} 1 +o method bar {} {} +? {info exists ::xotcl::alias(::o,FOO,1)} 0 +? {info exists ::xotcl::alias(::o,BAR,1)} 0 + +# +# pulling the rug out from the proc-alias deletion mechanism +# + +proc ::foo args {;} +::xotcl::alias C FOO ::foo +? {info exists ::xotcl::alias(::C,FOO,0)} 1 +unset ::xotcl::alias(::C,FOO,0) +? {info exists ::xotcl::alias(::C,FOO,0)} 0 +? {C info alias -definition FOO} "" +? {C info methods -defined -methodtype alias} FOO +rename ::foo "" +? {C info methods -defined -methodtype alias} "" +? {info exists ::xotcl::alias(::C,FOO,0)} 0 +? {C info alias -definition FOO} "" + +# +# test renaming of Tcl proc (actually sensed by the alias, though not +# reflected by the alias definition store) +# a) is this acceptable? +# b) sync ::xotcl::alias upon "info alias" calls? is this feasible, +# e.g. through rename traces? +# + +C create c +proc ::foo args { return [self]->[self proc]} +? {info exists ::xotcl::alias(::C,FOO,0)} 0 +::xotcl::alias C FOO ::foo +? {info exists ::xotcl::alias(::C,FOO,0)} 1 +? {C info methods -defined -methodtype alias} FOO +rename ::foo ::foo2 +? {info exists ::xotcl::alias(::C,FOO,0)} 1 +? {C info methods -defined -methodtype alias} FOO +? {c FOO} ::c->foo2 +? {C info alias -definition FOO} "::foo"; # should be ::foo2 (!) + +