Index: tests/methods.test =================================================================== diff -u -r714fdeeeeca44ee6f77d93349a0afec4c4b139cc -r24c2302b26cc3d8e608103a269ab3c82392501ff --- tests/methods.test (.../methods.test) (revision 714fdeeeeca44ee6f77d93349a0afec4c4b139cc) +++ tests/methods.test (.../methods.test) (revision 24c2302b26cc3d8e608103a269ab3c82392501ff) @@ -66,10 +66,10 @@ } C property -accessor public s0 C property -accessor protected s1 -? {c1 s0 0} 0 -? {::nsf::dispatch c1 s1 1} 1 +? {c1 s0 set 0} 0 +? {::nsf::dispatch c1 s1 set 1} 1 C object property -accessor public {s3 ""} -? {C s3 3} 3 +? {C s3 set 3} 3 # create a fresh object (different from c1) C create c2 @@ -93,9 +93,9 @@ nx::test case class-level-setter { ? {c2 plain_setter 1} {::c2: unable to dispatch method 'plain_setter'} #? {c2 plain_setter 1} 1 - ? {c2 public_setter 2} "2" - ? {catch {c2 protected_setter 3}} 1 - ? {::nsf::dispatch c2 protected_setter 4} "4" + ? {c2 public_setter set 2} "2" + ? {catch {c2 protected_setter set 3}} 1 + ? {::nsf::dispatch c2 protected_setter set 4} "4" } # class level alias .... @@ -128,9 +128,9 @@ nx::test case class-object-level-setter { ? {C plain_object_setter 1} {method 'plain_object_setter' unknown for ::C; consider '::C create plain_object_setter 1' instead of '::C plain_object_setter 1'} #? {C plain_object_setter 1} "1" - ? {C public_object_setter 2} "2" - ? {catch {C protected_object_setter 3}} 1 - ? {::nsf::dispatch C protected_object_setter 4} "4" + ? {C public_object_setter set 2} "2" + ? {catch {C protected_object_setter set 3}} 1 + ? {::nsf::dispatch C protected_object_setter set 4} "4" } # class level alias .... @@ -163,9 +163,9 @@ nx::test case object-level-setter { ? {c1 plain_object_setter 1} {::c1: unable to dispatch method 'plain_object_setter'} #? {c1 plain_object_setter 1} "1" - ? {c1 public_object_setter 2} "2" - ? {catch {c1 protected_object_setter 3}} 1 - ? {::nsf::dispatch c1 protected_object_setter 4} "4" + ? {c1 public_object_setter set 2} "2" + ? {catch {c1 protected_object_setter set 3}} 1 + ? {::nsf::dispatch c1 protected_object_setter set 4} "4" } # object level alias .... @@ -205,14 +205,15 @@ nx::Class create M # register the mixin on C as a object mixin and define a mixinguard - C mixin M + puts stderr XXXX=[nx::Class info method definition mixin] + C mixin set M C mixin guard M {1 == 1} ? {C info mixin guard M} "1 == 1" C mixin guard M {} ? {C info mixin guard M} "" # now the same as class mixin and class mixin guard - C object mixin M + C object mixin set M C object mixin guard M {1 == 1} ? {C info object mixin guard M} "1 == 1" C object mixin guard M {} @@ -221,19 +222,39 @@ nx::test case mixin-via-objectparam { # add an object and class mixin via object-parameter and via slots - nx::Class create M1; nx::Class create M2; nx::Class create M3; nx::Class create M4 + foreach c {M1 M2 M3 M4 M5} {nx::Class create $c} + nx::Class create C -mixin M1 -object-mixin M2 { :mixin add M3 :object mixin add M4 } ? {lsort [C info object mixin classes]} "::M2 ::M4" - #? {lsort [C info object mixin classes]} "::M2" + ? {lsort [C info mixin classes]} "::M1 ::M3" + ? {lsort [C object mixin get]} "::M2 ::M4" + ? {lsort [C mixin get]} "::M1 ::M3" + + ? {lsort [C object mixin]} {wrong # args: use "::C object mixin add|clear|delete|get|guard|set"} + ? {lsort [C mixin]} {wrong # args: use "::C mixin add|clear|delete|get|guard|set"} + + ? {catch {C mixin M5} errorMsg} 1 ? {lsort [C info mixin classes]} "::M1 ::M3" - #? {lsort [C info mixin classes]} "::M1" - C destroy - M1 destroy; M2 destroy; M3 destroy; M4 destroy; + + ? {catch {C object mixin M5} errorMsg} 1 + ? {lsort [C info object mixin classes]} "::M2 ::M4" + + ? {C mixin set M5} ::M5 + ? {lsort [C info mixin classes]} "::M5" + + ? {C object mixin set M5} "::M5" + ? {lsort [C info object mixin classes]} "::M5" + + ? {C configure -mixin M1} "" + ? {C cget -mixin} "::M1" + + ? {C configure -object-mixin M2} "" + ? {C cget -object-mixin} "::M2" } # testing next via nonpos-args @@ -252,7 +273,7 @@ } } - o object mixin M + o object mixin set M ? {o bar -x 13 -y 14} "x 13 y 14 {-x 13 -y 14} -- x 13 y 14 {-x 13 -y 14}" ? {o bar -y 14 -x 13} "x 13 y 14 {-y 14 -x 13} -- x 13 y 14 {-y 14 -x 13}" } @@ -282,16 +303,16 @@ } C create c1 -a 1 - ? {c1 a} 1 + ? {c1 a get} 1 ? {c1 cget -b} b1 ? {c1 cget -c} c1 ? {c1 d} "::c1: unable to dispatch method 'd'" - ? {C A 2} 2 - ? {C A} 2 + ? {C A set 2} 2 + ? {C A get} 2 ? {C B} {method 'B' unknown for ::C; consider '::C create B ' instead of '::C B '} #? {C B} B2 - ? {C C} C2 + ? {C C get} C2 ? {C D} "method 'D' unknown for ::C; consider '::C create D ' instead of '::C D '" nx::Object create o { @@ -303,10 +324,10 @@ :object property -accessor public {c c1} :object property -accessor protected {d d1} } - ? {o a 2} 2 + ? {o a set 2} 2 ? {o b} {::o: unable to dispatch method 'b'} #? {o b} b1 - ? {o c} c1 + ? {o c get} c1 ? {o d} "::o: unable to dispatch method 'd'" } @@ -347,11 +368,11 @@ :property -accessor public a:int :create c1 } - ? {C x 1} 1 - ? {C x} 1 + ? {C x set 1} 1 + ? {C x get} 1 ? {lsort [C info methods]} "a" ? {lsort [C info object methods]} "x" - ? {c1 a b} {expected integer but got "b" for parameter "a"} + ? {c1 a set b} {expected integer but got "b" for parameter "value"} set s(C) [C serialize] set s(c1) [c1 serialize] @@ -370,10 +391,10 @@ ? {nsf::object::exists c1} 1 # tests should work as again - ? {C x} 1 + ? {C x get} 1 ? {lsort [C info methods]} "a" ? {lsort [C info object methods]} "x" - ? {c1 a b} {expected integer but got "b" for parameter "a"} + ? {c1 a set b} {expected integer but got "b" for parameter "value"} } # @@ -434,7 +455,7 @@ } # dispatch methods without current object - ? ::o::a "method ::o::a not dispatched on valid object" + ? ::o::a {wrong # args: use "::o ::o::a add|delete|get|set|unset"} ? ::o::b "::o2" ? ::o::foo "no current object; command called outside the context of a Next Scripting method" ? ::o::x "no current object; x called outside the context of a Next Scripting method" @@ -1161,7 +1182,7 @@ ? {c1 foo} 1 ? {c1 bar} 2 - db object mixin Profile + db object mixin set Profile ? {c1 foo} 1 ? {c1 bar} 2 @@ -1225,7 +1246,7 @@ ? bar0 2 ? bar 2 - ns_cache object mixin Profile + ns_cache object mixin set Profile # the version with tcl-uplevel should fail ? bar0 {can't read "x": no such variable}