Index: tests/methods.test =================================================================== diff -u -rfb2161a532110a28aba2553b2fa1cae60ac2d475 -r1d09ffd51baae51ba946eb3b617462d3931a9622 --- tests/methods.test (.../methods.test) (revision fb2161a532110a28aba2553b2fa1cae60ac2d475) +++ tests/methods.test (.../methods.test) (revision 1d09ffd51baae51ba946eb3b617462d3931a9622) @@ -2,11 +2,10 @@ package require nx ::nx::configure defaultMethodCallProtection false package require nx::test -namespace import ::nx::* -Test parameter count 10 +nx::Test parameter count 10 -Class create C { +nx::Class create C { # methods :method plain_method {} {return [current method]} :public method public_method {} {return [current method]} @@ -72,31 +71,31 @@ # create a fresh object (different from c1) C create c2 # test scripted class level methods -Test case scripted-class-level-methods { +nx::Test case scripted-class-level-methods { ? {c2 plain_method} "plain_method" ? {c2 public_method} "public_method" ? {catch {c2 protected_method}} 1 ? {::nsf::dispatch c2 protected_method} "protected_method" } # class level forwards -Test case class-level-forwards { +nx::Test case class-level-forwards { ? {c2 plain_forward} "plain_method" ? {c2 public_forward} "public_method" ? {catch {c2 protected_forward}} 1 ? {::nsf::dispatch c2 protected_forward} "protected_method" } # class level setter -Test case class-level-setter { +nx::Test case class-level-setter { ? {c2 plain_setter 1} "1" ? {c2 public_setter 2} "2" ? {catch {c2 protected_setter 3}} 1 ? {::nsf::dispatch c2 protected_setter 4} "4" } # class level alias ....TODO: wanted behavior of [current method]? not "plain_alias"? -Test case class-level-alias { +nx::Test case class-level-alias { ? {c2 plain_alias} "plain_method" ? {c2 public_alias} "public_method" ? {catch {c2 protected_alias}} 1 @@ -106,31 +105,31 @@ ########### # scripted class level methods -Test case scripted-class-object-level { +nx::Test case scripted-class-object-level { ? {C plain_object_method} "plain_object_method" ? {C public_object_method} "public_object_method" ? {catch {C protected_object_method}} 1 ? {::nsf::dispatch C protected_object_method} "protected_object_method" } # class level forwards -Test case class-object-level-forwards { +nx::Test case class-object-level-forwards { ? {C plain_object_forward} "plain_object_method" ? {C public_object_forward} "public_object_method" ? {catch {C protected_object_forward}} 1 ? {::nsf::dispatch C protected_object_forward} "protected_object_method" } # class level setter -Test case class-object-level-setter { +nx::Test case class-object-level-setter { ? {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" } # class level alias ....TODO: wanted behavior of [current method]? not "plain_alias"? -Test case class-object-level-alias { +nx::Test case class-object-level-alias { ? {C plain_object_alias} "plain_object_method" ? {C public_object_alias} "public_object_method" ? {catch {C protected_object_alias}} 1 @@ -140,31 +139,31 @@ ########### # scripted object level methods -Test case scripted-object-level-methods { +nx::Test case scripted-object-level-methods { ? {c1 plain_object_method} "plain_object_method" ? {c1 public_object_method} "public_object_method" ? {catch {c1 protected_object_method}} 1 ? {::nsf::dispatch c1 protected_object_method} "protected_object_method" } # object level forwards -Test case object-level-forwards { +nx::Test case object-level-forwards { ? {c1 plain_object_forward} "plain_object_method" ? {c1 public_object_forward} "public_object_method" ? {catch {c1 protected_object_forward}} 1 ? {::nsf::dispatch c1 protected_object_forward} "protected_object_method" } # object level setter -Test case object-level-setter { +nx::Test case object-level-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" } # object level alias ....TODO: wanted behavior of [current method]? not "plain_alias"? -Test case object-level-alias { +nx::Test case object-level-alias { ? {c1 plain_object_alias} "plain_object_method" ? {c1 public_object_alias} "public_object_method" ? {catch {c1 protected_object_alias}} 1 @@ -178,8 +177,8 @@ C destroy -Test case colondispatch { - Object create ::o { +nx::Test case colondispatch { + nx::Object create ::o { #:public method foo args {;} :public method bar args {;} } @@ -189,10 +188,10 @@ ? {o eval :foo} "::o: unable to dispatch method 'foo'" } -Test case mixinguards { +nx::Test case mixinguards { # define a Class C and mixin class M - Class create C - Class create M + nx::Class create C + nx::Class create M # register the mixin on C as a class mixin and define a mixinguard C mixin M @@ -209,10 +208,10 @@ ? {C class info mixin guard M} "" } -Test case mixin-via-objectparam { +nx::Test case mixin-via-objectparam { # add an object and class mixin via object-parameter and via slots - Class create M1; Class create M2; Class create M3; Class create M4 - Class create C -mixin M1 -object-mixin M2 { + nx::Class create M1; nx::Class create M2; nx::Class create M3; nx::Class create M4 + nx::Class create C -mixin M1 -object-mixin M2 { :mixin add M3 :class mixin add M4 } @@ -227,15 +226,15 @@ } # testing next via nonpos-args -Test case next-from-nonpos-args { +nx::Test case next-from-nonpos-args { - Object create o { + nx::Object create o { :method bar {-y:required -x:required} { #puts stderr "+++ o x=$x, y=$y [current args] ... next [current nextmethod]" return [list x $x y $y [current args]] } } - Class create M { + nx::Class create M { :method bar {-x:required -y:required} { #puts stderr "+++ M x=$x, y=$y [current args] ... next [current nextmethod]" return [list x $x y $y [current args] -- {*}[next]] @@ -250,9 +249,9 @@ # # test method property with protected/public # -Test case property-method { +nx::Test case property-method { - Class create C { + nx::Class create C { set x [:property a] ? [list set _ $x] "::nsf::classes::C::a" @@ -283,7 +282,7 @@ ? {C C} C2 ? {C D} "Method 'D' unknown for ::C. Consider '::C create D ' instead of '::C D '" - Object create o { + nx::Object create o { set x [:property a] ? [list set _ $x] "::o::a" @@ -298,9 +297,9 @@ ? {o d} "::o: unable to dispatch method 'd'" } -Test case subcmd { +nx::Test case subcmd { - Class create Foo { + nx::Class create Foo { :method "Info filter guard" {filter} {return [current object]-[current method]} :method "Info filter methods" {-guards pattern:optional} {return [current object]-[current method]} @@ -329,8 +328,8 @@ } package req nx::serializer -Test case class-object-property { - Class create C { +nx::Test case class-object-property { + nx::Class create C { :class property x :property a:int :create c1 @@ -367,9 +366,9 @@ # # Test method deletion # -Test parameter count 1 +nx::Test parameter count 1 -Test case methoddelete { +nx::Test case methoddelete { nx::Class create C { :public method foo {x} {return $x} :public class method bar {x} {return $x} @@ -388,9 +387,9 @@ # # Test error message of method modifier # -Test parameter count 1 +nx::Test parameter count 1 -Test case errormessage { +nx::Test case errormessage { nx::Class create C ? {C public method foo {x} {return $x}} "::nsf::classes::C::foo" ? {C public object method bar {x} {return $x}} \ @@ -407,7 +406,7 @@ # # test dispatch without object # -Test case dispatch-without-object { +nx::Test case dispatch-without-object { nx::Object create o { # property defines a setter, we need a current object @@ -441,7 +440,7 @@ # c) ensemble methods on level 2 # nx::Test case scopes { - Object create o1 { + nx::Object create o1 { :public method foo {} {return [namespace current]-[namespace which info]} :public method "info foo" {} {return [namespace current]-[namespace which info]} :public method "info bar foo" {} {return [namespace current]-[namespace which info]} @@ -451,7 +450,7 @@ ? {o1 info foo} "::-::info" ? {o1 info bar foo} "::-::info" - Class create C { + nx::Class create C { :public method foo {} {return [namespace current]-[namespace which info]} :public method "info foo" {} {return [namespace current]-[namespace which info]} :public method "info bar foo" {} {return [namespace current]-[namespace which info]} @@ -473,12 +472,12 @@ nx::Test case namespaced-scopes { namespace eval ::ns { - Object create o1 { + nx::Object create o1 { :public method foo {} {return [namespace current]-[namespace which info]} :public method "info foo" {} {return [namespace current]-[namespace which info]} :public method "info bar foo" {} {return [namespace current]-[namespace which info]} } - Class create C { + nx::Class create C { :public method foo {} {return [namespace current]-[namespace which info]} :public method "info foo" {} {return [namespace current]-[namespace which info]} :public method "info bar foo" {} {return [namespace current]-[namespace which info]} @@ -504,8 +503,8 @@ # c) ensemble methods on level 2 # nx::Test case nested-scopes { - Object create o - Object create o::o1 { + nx::Object create o + nx::Object create o::o1 { :public method foo {} {return [namespace current]-[namespace which info]} :public method "info foo" {} {return [namespace current]-[namespace which info]} :public method "info bar foo" {} {return [namespace current]-[namespace which info]} @@ -515,7 +514,7 @@ ? {o::o1 info foo} "::o-::info" ? {o::o1 info bar foo} "::o-::info" - Class create o::C { + nx::Class create o::C { :public method foo {} {return [namespace current]-[namespace which info]} :public method "info foo" {} {return [namespace current]-[namespace which info]} :public method "info bar foo" {} {return [namespace current]-[namespace which info]} @@ -536,7 +535,7 @@ # c) test ensemble methods # nx::Test case delete-per-object { - Object create o1 { + nx::Object create o1 { :property a1 :property a2 :public method foo {} {return [namespace current]-[namespace which info]} @@ -582,7 +581,7 @@ # c) test ensemble methods # nx::Test case delete-per-object-on-class { - Class create C { + nx::Class create C { :class property a1 :public class method foo {} {return [namespace current]-[namespace which info]} :public class method "info foo" {} {return [namespace current]-[namespace which info]} @@ -621,7 +620,7 @@ # c) test ensemble methods # nx::Test case delete-class-level-method { - Class create C { + nx::Class create C { :property a1 :public method foo {} {return [namespace current]-[namespace which info]} :public method "info foo" {} {return [namespace current]-[namespace which info]}