Index: library/xotcl/tests/slottest.xotcl =================================================================== diff -u -N -r59e100d383b22ea1407f5e5c40e303f2c6bb9027 -re13b154388485b71f544c2db0ff2038da06e08d4 --- library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision 59e100d383b22ea1407f5e5c40e303f2c6bb9027) +++ library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision e13b154388485b71f544c2db0ff2038da06e08d4) @@ -568,13 +568,64 @@ x move y ? {y a} 4 -exit +::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 + # reference) + # + + # + # 1) old-style Attribute creation + # + + Class Window -slots { + Attribute scrollbar; # old style + Attribute create title; # new style + } + + ? {lsort [Window info slots]} "::Window::slot::scrollbar ::Window::slot::title" + + # + # 2) Dropped/missing slot attributes: multivalued + # + + Class Person -slots { + Attribute name + Attribute salary -default 0 + Attribute projects -default {} -multivalued true + } + + ? {lsort [Person info slots]} "::Person::slot::name ::Person::slot::projects ::Person::slot::salary" + + ? {Person::slot::name multivalued} 0 + ? {Person::slot::salary multivalued} 0 + ? {Person::slot::projects multivalued} 1 + + Person p2 -name "John Doe" + ? {p2 name} "John Doe" + ? {p2 salary} "0" + ? {p2 projects} [list] + + Project compatPrj -name XOTclCompat + p2 projects add ::compatPrj + p2 projects add some-other-value + + ? {lsort [p2 projects]} "::compatPrj some-other-value" + p2 projects delete some-other-value + ? {lsort [p2 projects]} "::compatPrj" -#puts [Person array get __defaults] -#puts [Person serialize] -puts [Serializer all] -eval [Serializer all] + ? {catch {p2 name add BOOM!}} 1 + ? {p2 name} "John Doe" +} +exit + + #puts [Person array get __defaults] + #puts [Person serialize] + puts [Serializer all] + eval [Serializer all] + ? {p2 salary} 1009 ? {catch {p2 append salary b}} 1 ? {p2 salary} 1009 @@ -686,6 +737,10 @@ puts stderr DONE-[p1 name]-[p1 age] p3 age 77 + + + + exit puts [XoXML asXML]