Index: tests/parameters.xotcl =================================================================== diff -u -r120f51260309bbe35ba0f142a25e1b18947e3635 -rc6066a15de738754028991b2b57b8f1d5a1cccaa --- tests/parameters.xotcl (.../parameters.xotcl) (revision 120f51260309bbe35ba0f142a25e1b18947e3635) +++ tests/parameters.xotcl (.../parameters.xotcl) (revision c6066a15de738754028991b2b57b8f1d5a1cccaa) @@ -84,9 +84,9 @@ ? {catch {D create d1 -d 123}} 0 "create d1 with required argument given" ? {catch {D create d1}} 1 "create d1 without required argument given" -?? {D create d1} "::d1 configure: required argument 'd' is missing" "check error msg" +? {D create d1} "::d1 configure: required argument 'd' is missing" "check error msg" -?? {D create d2 -d x -b a} \ +? {D create d2 -d x -b a} \ {expected boolean value but got "a"} \ "create d2 without required argument given" @@ -95,39 +95,39 @@ #if {[info exists x]} {puts stderr x=$x} } -?? {d1 foo} \ +? {d1 foo} \ "::d1 foo: required argument 'r' is missing" \ "call method without a required argument" -?? {d1 foo -r a} \ +? {d1 foo -r a} \ {expected integer but got "a"} \ "required argument is not integer" -?? {d1 foo -r 1} \ +? {d1 foo -r 1} \ {expected integer but got "aaa"} \ "default value is not of type integer" -?? {d1 foo -r 1 -x 1 -object d1} \ +? {d1 foo -r 1 -x 1 -object d1} \ "" \ "pass object" -?? {d1 foo -r 1 -x 1 -object d11} \ - {Invalid argument: cannot convert 'd11' to object} \ +? {d1 foo -r 1 -x 1 -object d11} \ + {expected object but got "d11"} \ "pass non-existing object" -?? {d1 foo -r 1 -x 1 -class D} \ +? {d1 foo -r 1 -x 1 -class D} \ "" \ "pass class" -?? {d1 foo -r 1 -x 1 -class d1} \ - {Invalid argument: cannot convert 'd1' to class} \ +? {d1 foo -r 1 -x 1 -class d1} \ + {expected class but got "d1"} \ "pass object instead of class" -?? {d1 foo -r 1 -x 1 -class D11} \ - {Invalid argument: cannot convert 'D11' to class} \ +? {d1 foo -r 1 -x 1 -class D11} \ + {expected class but got "D11"} \ "pass non-existing class" -?? {D method foo {a:relation} {}} \ +? {D method foo {a:relation} {}} \ {Parameter option 'relation' not allowed} \ "don't allow relation option as method parameter" @@ -149,7 +149,31 @@ ? {d1 foo 1 2} "1-1-0-1" "omit optional argument" ? {d1 foo 1} "1-0-0-1" "omit optional arguments" +# +# non required positional arguments +# +Test case multivalued +Object create o +D method foo {m:integer,multivalued} { + return $m +} +? {d1 foo ""} "" "emtpy list" +? {d1 foo 1} "1" "single value" +? {d1 foo {1 2}} "1 2" "multiple values" +? {d1 foo {1 a 2}} \ + {invalid value in "1 a 2": expected integer but got "a"} \ + "multiple values with wrong value" + +D method foo {m:object,multivalued} { + return $m +} +? {d1 foo ""} "" "emtpy list" +? {d1 foo o} "o" "single value" +? {d1 foo {o d1 x}} \ + {invalid value in "o d1 x": expected object but got "x"} \ + "multiple values" + # # subst default tests # @@ -288,15 +312,15 @@ } d1 foo 1 -?? {d1 foo 10} \ +? {d1 foo 10} \ "Value '10' of parameter a is not between 1 and 3" \ "invalid value" D method foo {a:unknowntype} { puts stderr a=$a } -?? {d1 foo 10} \ +? {d1 foo 10} \ "::xotcl::parameterType: unable to dispatch method 'type=unknowntype'" \ "missing type checker" @@ -312,7 +336,7 @@ } ? {d1 foo a} "a=a" -?? {d1 foo 10} \ +? {d1 foo 10} \ "Value '10' of parameter a not in permissible values a|b|c" \ "invalid value" @@ -322,7 +346,7 @@ ? {d1 foo a good -c b} "a=a,b=good,c=b" ? {d1 foo a good} "a=a,b=good,c=a" -?? {d1 foo b "very good"} \ +? {d1 foo b "very good"} \ "Value 'very good' of parameter b not in permissible values good|bad" \ "invalid value (not included)" @@ -339,12 +363,12 @@ ? {d1 foo 2 -b 4 9} "a=2,b=4,c=9" ? {d1 foo 2 10} "a=2,b=3,c=10" -?? {d1 foo 2 11} \ +? {d1 foo 2 11} \ "Value '11' of parameter c not between 5 and 10" \ "invalid value" # define type twice -?? {D method foo {a:int,range,arg=1-3} {return a=$a}} \ +? {D method foo {a:int,range,arg=1-3} {return a=$a}} \ "Refuse to redefine parameter converter to use usertype" \ "invalid value" @@ -413,36 +437,36 @@ D method foo-type {x:type,arg=::C} {return $x} ? {d1 foo-base ::xotcl2::Object} "::xotcl2::Object" -?? {d1 foo-base C} \ +? {d1 foo-base C} \ "Value 'C' of x is not a baseclass" \ "not a base class" ? {d1 foo-class D} "D" -?? {d1 foo-class xxx} \ - "Invalid argument: cannot convert 'xxx' to class" \ +? {d1 foo-class xxx} \ + {expected class but got "xxx"} \ "not a class" -?? {d1 foo-class o} \ - "Invalid argument: cannot convert 'o' to class" \ +? {d1 foo-class o} \ + {expected class but got "o"} \ "not a class" ? {d1 foo-meta ::xotcl2::Class} "::xotcl2::Class" -?? {d1 foo-meta ::xotcl2::Object} \ +? {d1 foo-meta ::xotcl2::Object} \ "Value '::xotcl2::Object' of x is not a metaclass" \ "not a base class" ? {d1 foo-mixin c1} "c1" -?? {d1 foo-mixin o} \ +? {d1 foo-mixin o} \ "Value 'o' of x has not mixin ::M" \ "does not have mixin M" ? {d1 foo-object o} "o" -?? {d1 foo-object xxx} \ - "Invalid argument: cannot convert 'xxx' to object" \ +? {d1 foo-object xxx} \ + {expected object but got "xxx"} \ "not an object" ? {d1 foo-type d1} "d1" ? {d1 foo-type c1} "c1" -?? {d1 foo-type o} \ +? {d1 foo-type o} \ "Value 'o' of x of not of type ::C" \ "o not of type ::C" @@ -465,12 +489,12 @@ b:baseclass } ? {ParamTest create p -o o} ::p -?? {ParamTest create p -o xxx} \ - "Invalid argument: cannot convert 'xxx' to object" \ +? {ParamTest create p -o xxx} \ + {expected object but got "xxx"} \ "not an object" ? {ParamTest create p -mix c1} ::p -?? {ParamTest create p -mix o} \ +? {ParamTest create p -mix o} \ "Value 'o' of mix has not mixin M" \ "does not have mixin M" @@ -496,8 +520,8 @@ ? {p o o} \ "o" \ "value is an object" -?? {p o xxx} \ - "Invalid argument: cannot convert 'xxx' to object" \ +? {p o xxx} \ + {expected object but got "xxx"} \ "value is not an object" ParamTest slots { @@ -511,8 +535,8 @@ "o c1 d1" \ "value is a list of objects (multiple elements)" -?? {p os {o xxx d1}} \ - "Invalid argument: cannot convert 'xxx' to object" \ +? {p os {o xxx d1}} \ + {expected object but got "xxx"} \ "list with invalid object" ## TODO regression test for type checking, parameter options (initcmd,