Index: xotcl/tests/forwardtest.xotcl =================================================================== diff -u -rab63a4908f87f226de9730e0afa820388c93acc4 -rf733c5df1b1a91a473d0e361ff206deaa4ecfa0a --- xotcl/tests/forwardtest.xotcl (.../forwardtest.xotcl) (revision ab63a4908f87f226de9730e0afa820388c93acc4) +++ xotcl/tests/forwardtest.xotcl (.../forwardtest.xotcl) (revision f733c5df1b1a91a473d0e361ff206deaa4ecfa0a) @@ -1,12 +1,12 @@ -# $Id: forwardtest.xotcl,v 1.2 2004/10/13 10:35:43 neumann Exp $ +# $Id: forwardtest.xotcl,v 1.3 2004/11/27 21:10:33 neumann Exp $ package require XOTcl namespace import -force xotcl::* +package require xotcl::test -proc ? {got expected} { - if {![string equal $got $expected]} { - error "got '$got' expected '$expected'" - } - puts "$expected -> OK" +proc ? {cmd expected} { + set t [Test new -cmd $cmd] + $t expected $expected + $t run } ########################################### @@ -17,7 +17,7 @@ tail proc wag args { return $args } dog forward wag tail %proc -? [dog wag 100] 100 +? {dog wag 100} 100 ########################################### @@ -30,7 +30,7 @@ x1 Incr x x1 Incr x x1 Incr x -? [x1 x] 103 +? {x1 x} 103 puts "======" ########################################### @@ -39,7 +39,7 @@ Object obj obj forward addOne expr 1 + -? [obj addOne 5] 6 +? {obj addOne 5} 6 puts "======" ########################################### @@ -49,10 +49,10 @@ target proc foo args {return $args} obj forward foo target %proc %self a1 a2 -? [obj foo x1 x2] [list ::obj a1 a2 x1 x2] +? {obj foo x1 x2} [list ::obj a1 a2 x1 x2] obj forward foo target %proc %self %%self %%p -? [obj foo x1 x2] [list ::obj %self %p x1 x2] +? {obj foo x1 x2} [list ::obj %self %p x1 x2] puts "======" @@ -64,14 +64,14 @@ mixin proc unknown {m args} {return [concat [self] $m $args]} obj forward Mixin mixin %1 %self -? [obj Mixin add M1] [list ::mixin add ::obj M1] -? [catch {obj Mixin}] 1 +? {obj Mixin add M1} [list ::mixin add ::obj M1] +? {catch {obj Mixin}} 1 obj forward Mixin -default {getter setter} mixin %1 %self -? [obj Mixin add M1] [list ::mixin add ::obj M1] -? [obj Mixin M1] [list ::mixin setter ::obj M1] -? [obj Mixin] [list ::mixin getter ::obj] +? {obj Mixin add M1} [list ::mixin add ::obj M1] +? {obj Mixin M1} [list ::mixin setter ::obj M1] +? {obj Mixin} [list ::mixin getter ::obj] puts "======" @@ -91,16 +91,16 @@ } Object instforward Info -methodprefix @ Info %1 %self -? [x1 Info class] ::X -? [x1 Info help] [list help mixin class] +? {x1 Info class} ::X +? {x1 Info help} [list help mixin class] ########################################### # variations of placement of options ########################################### obj set x 1 obj forward i1 -objscope incr x -? [obj i1] 2 +? {obj i1} 2 puts "======" ########################################### @@ -109,90 +109,91 @@ Class C C instforward Info -methodprefix @ Info %1 %self -? [C info instforward] Info +? {C info instforward} Info C instforward XXXo x -? [lsort [C info instforward]] [list Info XXXo] +? {lsort [C info instforward]} [list Info XXXo] -? [C info instforward X*] [list XXXo] -? [lsort [C info instforward *o]] [list Info XXXo] +? {C info instforward X*} [list XXXo] +? {lsort [C info instforward *o]} [list Info XXXo] # delete the forwarder C instproc XXXo {} {} -? [C info instforward] [list Info] +? {C info instforward} [list Info] # get the definition of a instforwarder -? [C info instforward -definition Info] [list -methodprefix @ Info %1 %self] +? {C info instforward -definition Info} [list -methodprefix @ Info %1 %self] # chek introspection for objects -? [lsort [obj info forward]] "Mixin addOne foo i1" -? [obj info forward -definition Mixin] "-default {getter setter} mixin %1 %self" -? [obj info forward -definition addOne] "expr 1 +" -? [obj info forward -definition foo] "target %proc %self %%self %%p" -? [obj info forward -definition i1] "-objscope ::incr x" +? {lsort [obj info forward]} "Mixin addOne foo i1" +? {obj info forward -definition Mixin} "-default {getter setter} mixin %1 %self" +? {obj info forward -definition addOne} "expr 1 +" +? {obj info forward -definition foo} "target %proc %self %%self %%p" +? {obj info forward -definition i1} "-objscope ::incr x" puts "======" ########################################### # test serializer ########################################### package require xotcl::serializer obj proc test {} {puts "i am [self proc]"} -puts [set a [Serializer deepSerialize obj]] +set a [Serializer deepSerialize obj] +#puts <<$a>> eval $a -? $a [Serializer deepSerialize obj] +? {set ::a} [Serializer deepSerialize obj] ########################################### # test optional target cmd ########################################### obj set x 2 obj forward append -objscope -? [obj append x y z] 2yz +? {obj append x y z} 2yz Object n; Object n::x; Object o; o forward ::n::x -? [o x self] ::n::x +? {o x self} ::n::x ########################################### # arg including instvar ########################################### obj set x 10 obj forward x* expr {%my set x} * -? [obj x* 10] "100" +? {obj x* 10} "100" ########################################### # positional arguments ########################################### obj forward @end-13 list {%@end 13} -? [obj @end-13 1 2 3 ] [list 1 2 3 13] +? {obj @end-13 1 2 3 } [list 1 2 3 13] obj forward @-1-13 list {%@-1 13} -? [obj @-1-13 1 2 3 ] [list 1 2 13 3] +? {obj @-1-13 1 2 3 } [list 1 2 13 3] obj forward @1-13 list {%@1 13} -? [obj @1-13 1 2 3 ] [list 13 1 2 3] -? [obj @1-13] [list 13] +? {obj @1-13 1 2 3 } [list 13 1 2 3] +? {obj @1-13} [list 13] obj forward @2-13 list {%@2 13} -? [obj @2-13 1 2 3 ] [list 1 13 2 3] +? {obj @2-13 1 2 3 } [list 1 13 2 3] obj forward @list 10 {%@0 list} {%@end 99} -? [obj @list] [list 10 99] -? [obj @list a b c] [list 10 a b c 99] +? {obj @list} [list 10 99] +? {obj @list a b c} [list 10 a b c 99] obj forward @list {%@end 99} {%@0 list} 10 -? [obj @list] [list 10 99] -? [obj @list a b c] [list 10 a b c 99] +? {obj @list} [list 10 99] +? {obj @list a b c} [list 10 a b c 99] obj forward @list {%@2 2} {%@1 1} {%@0 list} -? [obj @list] [list 1 2] -? [obj @list a b c] [list 1 2 a b c] +? {obj @list} [list 1 2] +? {obj @list a b c} [list 1 2 a b c] obj forward @list x y z {%@0 list} {%@1 1} {%@2 2} -? [obj @list] [list 1 2 x y z] -? [obj @list a b c] [list 1 2 x y z a b c] +? {obj @list} [list 1 2 x y z] +? {obj @list a b c} [list 1 2 x y z a b c] obj forward @list x y z {%@2 2} {%@1 1} {%@0 list} -? [obj @list] [list x 1 y 2 z] -? [obj @list a b c] [list x 1 y 2 z a b c] +? {obj @list} [list x 1 y 2 z] +? {obj @list a b c} [list x 1 y 2 z a b c] Object instproc f args { next } @@ -203,25 +204,25 @@ NS::Main proc m1 {} { my m2 } NS::Main proc m2 {} { - ? [namespace eval :: {Object toplevelObj1}] ::toplevelObj1 + ? {namespace eval :: {Object toplevelObj1}} ::toplevelObj1 - ? [namespace current] ::NS - ? [NS create m1] ::NS::m1 + ? [list set _ [namespace current]] ::NS + ? [list set _ [NS create m1]] ::NS::m1 NS filter f - ? [NS create m2] ::NS::m2 + ? [list set _ [NS create m2]] ::NS::m2 NS filter "" namespace eval ::test { - ? [NS create m3] ::test::m3 + ? [list set _ [NS create m3]] ::test::m3 NS filter f - ? [NS create m4] ::test::m4 + ? [list set _ [NS create m4]] ::test::m4 NS filter "" } namespace eval test { - ? [NS create m5] ::NS::test::m5 + ? [list set _ [NS create m5]] ::NS::test::m5 NS filter f - ? [NS create m6] ::NS::test::m6 + ? [list set _ [NS create m6]] ::NS::test::m6 NS filter "" } @@ -230,25 +231,25 @@ NS::Main instproc i1 {} { my i2 } NS::Main instproc i2 {} { - ? [namespace eval :: {Object toplevelObj2}] ::toplevelObj2 + ? {namespace eval :: {Object toplevelObj2}} ::toplevelObj2 - ? [namespace current] ::NS - ? [NS create i1] ::NS::i1 + ? [list set _ [namespace current]] ::NS + ? [list set _ [NS create i1]] ::NS::i1 NS filter f - ? [NS create i2] ::NS::i2 + ? [list set _ [NS create i2]] ::NS::i2 NS filter "" namespace eval ::test { - ? [NS create i3] ::test::i3 + ? [list set _ [NS create i3]] ::test::i3 NS filter f - ? [NS create i4] ::test::i4 + ? [list set _ [NS create i4]] ::test::i4 NS filter "" } namespace eval test { - ? [NS create i5] ::NS::test::i5 + ? [list set _ [NS create i5]] ::NS::test::i5 NS filter f - ? [NS create i6] ::NS::test::i6 + ? [list set _ [NS create i6]] ::NS::test::i6 NS filter "" } @@ -260,16 +261,16 @@ m i1 puts ==== -? [NS create n1] ::n1 +? [list set _ [NS create n1]] ::n1 NS filter f -? [NS create n2] ::n2 +? [list set _ [NS create n2]] ::n2 NS filter "" puts ==== namespace eval test { - ? [NS create n1] ::test::n1 - ? [NS create n3] ::test::n3 + ? [list set _ [NS create n1]] ::test::n1 + ? [list set _ [NS create n3]] ::test::n3 NS filter f - ? [NS create n4] ::test::n4 + ? [list set _ [NS create n4]] ::test::n4 NS filter "" }