Index: library/xotcl/tests/slottest.xotcl =================================================================== diff -u -r5d1617640ad71fd52b069f81cfcadbe4cbb6f2a2 -reb758924a74f48512c98a40a539ab0c4e5a35de9 --- library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision 5d1617640ad71fd52b069f81cfcadbe4cbb6f2a2) +++ library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision eb758924a74f48512c98a40a539ab0c4e5a35de9) @@ -3,7 +3,7 @@ package require XOTcl 2.0; namespace import -force ::xotcl::* package require nx::test -nx::Test parameter count 1000 +nx::test configure -count 1000 # what's new: # - slots instances are manager objects for slot values @@ -141,12 +141,33 @@ ? {O2 superclass} "::M" # +# test "... info default ..." and "... info instdefault ..." +# +::nx::test case info-default { + ::xotcl::Class create ::Test + ::Test proc m0 {-id:required {-flag:boolean true} -switch:switch x {y 1}} {return 0} + ::Test instproc m1 {-id:required {-flag:boolean true} -switch:switch x {y 1}} {return 0} + + ? {::Test info default m0 y default0} 1 + ? {info exists default0} 1 + + ? {::Test info default m0 x default1} 0 + + unset -nocomplain default0 default1 + + ? {::Test info instdefault m1 y default0} 1 + ? {info exists default0} 1 + + ? {::Test info instdefault m1 x default1} 0 + } + +# # The main difference between an Attribute and a Role is that it # references some other objects # ::xotcl::MetaSlot create Role -superclass Attribute -parameter {references} -::nx::Test case info-slots-heritage { +::nx::test case info-slots-heritage { ::xotcl::Class create C -parameter {c1 c2} ::xotcl::Class create D -superclass C -parameter {c2 c3} @@ -359,7 +380,7 @@ # redefine setter for foo of class A #A slot foo method assign {domain var val} ... -A::slot::foo public method assign {domain var val} { +A::slot::foo public object method assign {domain var val} { # Do something with [self] that isn't valid before init #puts setter-[self proc] $domain set $var $val @@ -372,14 +393,14 @@ #puts [A serialize] ################### -nx::Test case req-param { +nx::test case req-param { ::xotcl::Class create C -parameter {y:required x:required} C instproc init args {set ::_ $args} set ::_ "" ? {C create c2 -y 1 -x} {value for parameter '-x' expected} ? {set ::_} "" - ? {c2 x} {can't read "x": no such variable} + ? {::nsf::is object c2} 0 ? {C create c3 -y 1 -x 0} "::c3" ? {set ::_} "" ? {c3 x} "0" @@ -389,7 +410,7 @@ ################### # Application Slots # -nx::Test case app-slots +nx::test case app-slots Class Person -slots { Attribute create name @@ -475,21 +496,21 @@ ####################################################### # defaultcmd via slots ####################################################### -nx::Test case defaultcmd +nx::test case defaultcmd set ::hu 0 Class C -slots { Attribute create x -defaultcmd {incr ::hu; set x 101} } C c1 -? {c1 info vars} "" +? {c1 info vars} "__initcmd" ? {c1 set x} 101 -? {c1 info vars} "x" +? {c1 info vars} "x __initcmd" ? {set ::hu 1} 1 ####################################################### # nested contains ####################################################### -nx::Test case nested-contains +nx::test case nested-contains Class Point -parameter {{x 100} {y 300}} Class Rectangle -parameter {color} @@ -521,7 +542,7 @@ ####################################################### # assign via slots ####################################################### -nx::Test case assign-via-slots +nx::test case assign-via-slots Class create A -slots { Attribute create foo -default 1 -proc assign {domain var value} { @@ -568,7 +589,7 @@ x move y ? {y a} 4 -::nx::Test case slots-compat +::nx::test case slots-compat # # Some tests covering the backward compatibility of NX/XOTcl2 hybrid # slots to the XOTcl1 slot API (as extracted from the XOTcl language