Index: tests/objifdtest.xotcl =================================================================== diff -u -N --- tests/objifdtest.xotcl (revision ffd2368a61d1328d71f07ef8b922820bf8263c25) +++ tests/objifdtest.xotcl (revision 0) @@ -1,56 +0,0 @@ -package require XOTcl -namespace import -force xotcl::* -package require xotcl::test - -proc ? {cmd expected {msg ""}} { - set count 10 - if {$msg ne ""} { - set t [Test new -cmd $cmd -count $count -msg $msg] - } else { - set t [Test new -cmd $cmd -count $count] - } - $t expected $expected - $t run -} - -catch {::xotcl::configure cacheinterface true} - -puts stderr =====START -Class C -parameter {a {b:boolean} {c 1}} - -C c1 -? {C configureargs} "-instfilter:relation -superclass:relation -instmixin:relation -mixin:relation -filter:relation -class:relation args" -? {c1 configureargs} "-a -b:boolean {-c 1} -mixin:relation -filter:relation -class:relation args" - -# reclass to Object, no neet to do anything on caching -puts stderr "=== reclass c1 to Object" -c1 class Object -? {c1 configureargs} "-mixin:relation -filter:relation -class:relation args" - -puts stderr "=== create Class D" -Class D -superclass C -parameter {d:required} -D d1 -d 100 -? {d1 configureargs} "-d:required -a -b:boolean {-c 1} -mixin:relation -filter:relation -class:relation args" - - -set case "instmixin M into D" -Class M -parameter {m1 m2 b} -Class M2 -parameter {b2} -puts stderr "=== $case" -D instmixin M -? {d1 configureargs} "-b -m1 -m2 -d:required -a {-c 1} -mixin:relation -filter:relation -class:relation args" "$case: mixin added" -M instmixin M2 -? {d1 configureargs} "-b2 -b -m1 -m2 -d:required -a {-c 1} -mixin:relation -filter:relation -class:relation args" "$case: transitive mixin added" -D instmixin "" -#we should have again the old interface -? {d1 configureargs} "-d:required -a -b:boolean {-c 1} -mixin:relation -filter:relation -class:relation args" "$case: mixin removed" - -set case "instmixin M into C" -puts stderr "=== $case" -C instmixin M -? {d1 configureargs} "-b2 -b -m1 -m2 -d:required -a {-c 1} -mixin:relation -filter:relation -class:relation args" "$case: mixin added" -C instmixin "" -#we should have again the old interface -? {d1 configureargs} "-d:required -a -b:boolean {-c 1} -mixin:relation -filter:relation -class:relation args" "$case: mixin removed" - -puts stderr =====END \ No newline at end of file Index: tests/objparametertest.xotcl =================================================================== diff -u -N --- tests/objparametertest.xotcl (revision 0) +++ tests/objparametertest.xotcl (revision 01a359f1ffe941861c0e10b358b01c2b2b702f38) @@ -0,0 +1,77 @@ +package require XOTcl +namespace import -force xotcl::* +package require xotcl::test + +proc ? {cmd expected {msg ""}} { + set count 10 + if {$msg ne ""} { + set t [Test new -cmd $cmd -count $count -msg $msg] + } else { + set t [Test new -cmd $cmd -count $count] + } + $t expected $expected + $t run +} + +catch {::xotcl::configure cacheinterface true} + +puts stderr =====START +Class C -parameter {a {b:boolean} {c 1}} + +C c1 +? {C objectparameter} "-instfilter:relation -superclass:relation -instmixin:relation -mixin:relation -filter:relation -class:relation args" +? {c1 objectparameter} {-a {-b:boolean,initcmd { +if {[::xotcl::my exists b]} {::xotcl::my set __oldvalue(b) [::xotcl::my set b]} +::xotcl::my trace add variable b write [list ::C::slot::b __value_changed_cmd [::xotcl::self] { +::xotcl::my check_single_value [$obj set b] {[::C::slot::b type=boolean b $value]} boolean $obj b}]}} {-c 1} -mixin:relation -filter:relation -class:relation args} + +# reclass to Object, no neet to do anything on caching +puts stderr "=== reclass c1 to Object" +c1 class Object +? {c1 objectparameter} "-mixin:relation -filter:relation -class:relation args" + +puts stderr "=== create Class D" +Class D -superclass C -parameter {d:required} +D d1 -d 100 +? {d1 objectparameter} {-d:required -a {-b:boolean,initcmd { +if {[::xotcl::my exists b]} {::xotcl::my set __oldvalue(b) [::xotcl::my set b]} +::xotcl::my trace add variable b write [list ::C::slot::b __value_changed_cmd [::xotcl::self] { +::xotcl::my check_single_value [$obj set b] {[::C::slot::b type=boolean b $value]} boolean $obj b}]}} {-c 1} -mixin:relation -filter:relation -class:relation args} + +puts stderr 2 +set case "instmixin M into D" +Class M -parameter {m1 m2 b} +Class M2 -parameter {b2} +puts stderr "=== $case" +D instmixin M +? {d1 objectparameter} "-b -m1 -m2 -d:required -a {-c 1} -mixin:relation -filter:relation -class:relation args" "$case: mixin added" +M instmixin M2 +? {d1 objectparameter} "-b2 -b -m1 -m2 -d:required -a {-c 1} -mixin:relation -filter:relation -class:relation args" "$case: transitive mixin added" +D instmixin "" +#we should have again the old interface +? {d1 objectparameter} {-d:required -a {-b:boolean,initcmd { +if {[::xotcl::my exists b]} {::xotcl::my set __oldvalue(b) [::xotcl::my set b]} +::xotcl::my trace add variable b write [list ::C::slot::b __value_changed_cmd [::xotcl::self] { +::xotcl::my check_single_value [$obj set b] {[::C::slot::b type=boolean b $value]} boolean $obj b}]}} {-c 1} -mixin:relation -filter:relation -class:relation args} + +set case "instmixin M into C" +puts stderr "=== $case" +C instmixin M +? {d1 objectparameter} "-b2 -b -m1 -m2 -d:required -a {-c 1} -mixin:relation -filter:relation -class:relation args" "$case: mixin added" +C instmixin "" +#we should have again the old interface +? {d1 objectparameter} {-d:required -a {-b:boolean,initcmd { +if {[::xotcl::my exists b]} {::xotcl::my set __oldvalue(b) [::xotcl::my set b]} +::xotcl::my trace add variable b write [list ::C::slot::b __value_changed_cmd [::xotcl::self] { +::xotcl::my check_single_value [$obj set b] {[::C::slot::b type=boolean b $value]} boolean $obj b}]}} {-c 1} -mixin:relation -filter:relation -class:relation args} + +# test passed arguments +? {catch {D create d1 -d 123}} 0 "create d1 with required argument given" +? {catch {D create d1}} 1 "create d1 without required argument given" + +## TODO: initcmd->trackType {obj var type} => trace var ... + +## TODO regression test for type checking, parameter options (initcmd, +## substdefault, combinations with defaults, ...), etc. + +puts stderr =====END \ No newline at end of file