# -*- Tcl -*- package require nx namespace path nx # Don't use test, since both, package test and contains redefine "new", # so we have a conflict.... proc ? {cmd expected {msg ""}} { #puts "??? $cmd" set r [uplevel $cmd] if {$msg eq ""} {set msg $cmd} if {$r ne $expected} { puts stderr "ERROR $msg returned '$r' ne '$expected'" error "FAILED $msg returned '$r' ne '$expected'" } else { puts stderr "OK $msg" } } # # We define here a few attributes of type method, such we can add # arbitrary "-" calls # Class create Tree { :attribute label :attribute contains:method :attribute foo:method :public method foo {arg} {set :x $arg} } set y [Tree new -foo hu] ? [list $y eval {set :x}] hu # # actually, the intention was to define an xotcl-like -contains # set x [Tree create 1 -label 1 -contains { ? {self} ::1 ? {namespace current} ::1 Tree create 1.1 -label 1.1 Tree create 1.2 -label 1.2 -contains { ? {self} ::1::1.2 ? {namespace current} ::1::1.2 Tree create 1.2.1 -label 1.2.1 Tree create 1.2.2 -label 1.2.2 -contains { Tree create 1.2.2.1 -label 1.2.2.1 ? {self} ::1::1.2::1.2.2 } Tree create 1.2.3 -label 1.2.3 } Tree create 1.3 -label 1.3 }] namespace path "" # Test resolving of implicit namespaces in relationcmds (here # superclass) in the nx namespace. namespace eval ::nx { #puts stderr =====1 set c [Class create C -superclass Class { :class-object method foo {} {;} }] ? {set c} ::C # recreate set c [Class create C -superclass Class ] ? {set c} ::C #puts stderr =====3 } package forget nx package req nx package require XOTcl package forget XOTcl package require XOTcl puts stderr ===EXIT