Index: generic/nsf.c =================================================================== diff -u -rf0bca18a085d7e071f54af9b4f0136b65ad1f8e6 -r0756410503b3b64d5b057afbdc3acb14278ef379 --- generic/nsf.c (.../nsf.c) (revision f0bca18a085d7e071f54af9b4f0136b65ad1f8e6) +++ generic/nsf.c (.../nsf.c) (revision 0756410503b3b64d5b057afbdc3acb14278ef379) @@ -16727,13 +16727,11 @@ nonnull_assert(pPtr != NULL); nonnull_assert(clientData != NULL); - fprintf(stderr, "Nsf_ConvertToTclObjType: converterArg %p\n", (void*)pPtr->converterArg); if (unlikely(pPtr->converterArg != NULL)) { const Tcl_ObjType *tclObjType = pPtr->converterArg->internalRep.twoPtrValue.ptr1; if (tclObjType != NULL) { result = Tcl_ConvertToType(interp, objPtr, tclObjType); - fprintf(stderr, "Nsf_ConvertToTclObjType:type %p -> %d\n", (void*)tclObjType, result); if (result != TCL_OK) { Tcl_ResetResult(interp); @@ -16794,9 +16792,15 @@ nonnull_assert(clientData != NULL); if (unlikely(pPtr->converterArg != NULL)) { - Tcl_Obj *objv[4]; - /*fprintf(stderr, "ConvertToTclobj %s (must be %s)\n", ObjStr(objPtr), ObjStr(pPtr->converterArg));*/ + /* + * Using "string is ..." as value checker. + */ + Tcl_Obj *objv[4], *resultObj; + /* fprintf(stderr, "ConvertToTclobj %s (must be %s)\n", ObjStr(objPtr), ObjStr(pPtr->converterArg));*/ + resultObj = Tcl_GetObjResult(interp); + Tcl_IncrRefCount(resultObj); + objv[0] = NULL; objv[1] = pPtr->converterArg; objv[2] = NsfGlobalObjs[NSF_OPTION_STRICT]; @@ -16805,14 +16809,23 @@ result = NsfCallCommand(interp, NSF_STRING_IS, 4, objv); if (likely(result == TCL_OK)) { int success; + Tcl_GetIntFromObj(interp, Tcl_GetObjResult(interp), &success); if (success == 1) { *clientData = objPtr; + /* + * Restore the original result, which was clobbered by the "string is" + * command. Restoring is necessary in cases, where this function is + * used as result value function of a method. + */ + Tcl_SetObjResult(interp, resultObj); } else { Tcl_ResetResult(interp); result = NsfObjErrType(interp, NULL, objPtr, ObjStr(pPtr->converterArg), (Nsf_Param *)pPtr); } } + Tcl_DecrRefCount(resultObj); + } else { result = TCL_OK; @@ -31939,14 +31952,17 @@ } } paramPtr = paramWrapperPtr->paramPtr; - if (paramPtrPtr != NULL) *paramPtrPtr = paramPtr; + if (paramPtrPtr != NULL) { + *paramPtrPtr = paramPtr; + } if (isNamed) { paramPtr->flags &= ~NSF_ARG_UNNAMED; } RUNTIME_STATE(interp)->doClassConverterOmitUnknown = 1; outObjPtr = NULL; + result = ArgumentCheck(interp, valueObj, paramPtr, doCheckArguments, &flags, &checkedData, &outObjPtr); RUNTIME_STATE(interp)->doClassConverterOmitUnknown = 0; Index: tests/returns.test =================================================================== diff -u -r8e2e356e9bcef39f43dfe3690b82d9586c7adc72 -r0756410503b3b64d5b057afbdc3acb14278ef379 --- tests/returns.test (.../returns.test) (revision 8e2e356e9bcef39f43dfe3690b82d9586c7adc72) +++ tests/returns.test (.../returns.test) (revision 0756410503b3b64d5b057afbdc3acb14278ef379) @@ -9,147 +9,147 @@ # # The same tests are in this test suite, once with and once without -# checking +# checking # # Make sure, checking is turned on # ::nsf::configure checkresult true nx::test configure -count 10000 -nx::test case int-returns { - nx::Class create C { - # scripted method without paramdefs - :method bar-ok1 {a b} {return 1} - :method bar-ok2 {a b} {return $a} - # scripted method with paramdefs - :method bar-nok {a b:integer} {return a} - # alias to tcl-cmd (no param defs) - :alias incr -frame object ::incr - :alias lappend -frame object ::lappend - :create c1 - } +nx::test case int-returns { + nx::Class create C { + # scripted method without paramdefs + :method bar-ok1 {a b} {return 1} + :method bar-ok2 {a b} {return $a} + # scripted method with paramdefs + :method bar-nok {a b:integer} {return a} + # alias to tcl-cmd (no param defs) + :alias incr -frame object ::incr + :alias lappend -frame object ::lappend + :create c1 + } - ::nsf::method::property C bar-ok1 returns integer - ::nsf::method::property C bar-ok2 returns integer - ::nsf::method::property C bar-nok returns integer - ::nsf::method::property C incr returns integer - ::nsf::method::property C lappend returns integer + ::nsf::method::property C bar-ok1 returns integer + ::nsf::method::property C bar-ok2 returns integer + ::nsf::method::property C bar-nok returns integer + ::nsf::method::property C incr returns integer + ::nsf::method::property C lappend returns integer - ? {c1 bar-ok1 1 2} 1 - ? {c1 bar-ok2 1 2} 1 - ? {c1 bar-nok 1 2} {expected integer but got "a" as return value} + ? {c1 bar-ok1 1 2} 1 + ? {c1 bar-ok2 1 2} 1 + ? {c1 bar-nok 1 2} {expected integer but got "a" as return value} - ? {c1 incr x} 1 - ? {c1 incr x} 10002 + ? {c1 incr x} 1 + ? {c1 incr x} 10002 - ? {c1 lappend l e1} {expected integer but got "e1" as return value} + ? {c1 lappend l e1} {expected integer but got "e1" as return value} - # query the returns value - ? {::nsf::method::property C lappend returns} integer + # query the returns value + ? {::nsf::method::property C lappend returns} integer - # reset it to empty - ? {::nsf::method::property C lappend returns ""} "" - ? {::nsf::method::property C bar-ok1 returns ""} "" - ? {::nsf::method::property C bar-ok2 returns ""} "" - ? {::nsf::method::property C bar-nok returns ""} "" + # reset it to empty + ? {::nsf::method::property C lappend returns ""} "" + ? {::nsf::method::property C bar-ok1 returns ""} "" + ? {::nsf::method::property C bar-ok2 returns ""} "" + ? {::nsf::method::property C bar-nok returns ""} "" - # no checking - ? {c1 bar-ok1 1 2} 1 - ? {c1 bar-ok2 1 2} 1 - ? {c1 bar-nok 1 2} a - ? {c1 lappend l e2} "e1 e2" + # no checking + ? {c1 bar-ok1 1 2} 1 + ? {c1 bar-ok2 1 2} 1 + ? {c1 bar-nok 1 2} a + ? {c1 lappend l e2} "e1 e2" - # query returns "", if there is no returns checking - ? {::nsf::method::property C lappend returns} "" - ? {::nsf::method::property ::nx::Class method returns} "" + # query returns "", if there is no returns checking + ? {::nsf::method::property C lappend returns} "" + ? {::nsf::method::property ::nx::Class method returns} "" } nx::test configure -count 10 -nx::test case app-specific-returns { +nx::test case app-specific-returns { - ::nx::methodParameterSlot object method type=range {name value arg} { - lassign [split $arg -] min max - if {$value < $min || $value > $max} { - error "Value '$value' of parameter $name not between $min and $max" - } - return $value + ::nx::methodParameterSlot object method type=range {name value arg} { + lassign [split $arg -] min max + if {$value < $min || $value > $max} { + error "Value '$value' of parameter $name not between $min and $max" } + return $value + } - nx::Class create C { - :method bar-ok1 {a b} {return 1} - :method bar-ok2 {a b} {return $a} - :method bar-nok {a b:integer} {return a} - :alias incr -frame object ::incr - :alias lappend -frame object ::lappend - :create c1 - } + nx::Class create C { + :method bar-ok1 {a b} {return 1} + :method bar-ok2 {a b} {return $a} + :method bar-nok {a b:integer} {return a} + :alias incr -frame object ::incr + :alias lappend -frame object ::lappend + :create c1 + } - ::nsf::method::property C bar-ok1 returns range,arg=1-3 - ::nsf::method::property C bar-ok2 returns range,arg=1-3 - ::nsf::method::property C bar-nok returns range,arg=1-3 - ::nsf::method::property C incr returns range,arg=1-30 - ::nsf::method::property C lappend returns range,arg=1-30 + ::nsf::method::property C bar-ok1 returns range,arg=1-3 + ::nsf::method::property C bar-ok2 returns range,arg=1-3 + ::nsf::method::property C bar-nok returns range,arg=1-3 + ::nsf::method::property C incr returns range,arg=1-30 + ::nsf::method::property C lappend returns range,arg=1-30 - ? {c1 bar-ok1 1 2} 1 - ? {c1 bar-ok2 1 2} 1 - ? {c1 bar-nok 1 2} {Value 'a' of parameter return-value not between 1 and 3} + ? {c1 bar-ok1 1 2} 1 + ? {c1 bar-ok2 1 2} 1 + ? {c1 bar-nok 1 2} {Value 'a' of parameter return-value not between 1 and 3} - ? {c1 incr x} 1 - ? {c1 incr x} 12 + ? {c1 incr x} 1 + ? {c1 incr x} 12 - ? {c1 lappend l e1} {Value 'e1' of parameter return-value not between 1 and 30} + ? {c1 lappend l e1} {Value 'e1' of parameter return-value not between 1 and 30} } nx::test configure -count 1000 -nx::test case converting-returns { +nx::test case converting-returns { - ::nx::methodParameterSlot object method type=sex {name value args} { - #puts stderr "[current] slot specific converter" - switch -glob $value { - m* {return m} - f* {return f} - default {error "expected sex but got $value"} - } + ::nx::methodParameterSlot object method type=sex {name value args} { + #puts stderr "[current] slot specific converter" + switch -glob $value { + m* {return m} + f* {return f} + default {error "expected sex but got $value"} } + } - nx::Class create C { - :method bar-ok1 {a b} {return male} - :method bar-ok2 {a b} {return $a} - :method bar-nok {a b:integer} {return $b} - :alias set -frame object ::set - :create c1 - } + nx::Class create C { + :method bar-ok1 {a b} {return male} + :method bar-ok2 {a b} {return $a} + :method bar-nok {a b:integer} {return $b} + :alias set -frame object ::set + :create c1 + } - ::nsf::method::property C bar-ok1 returns sex - ::nsf::method::property C bar-ok2 returns sex - ::nsf::method::property C bar-nok returns sex - ::nsf::method::property C set returns sex + ::nsf::method::property C bar-ok1 returns sex + ::nsf::method::property C bar-ok2 returns sex + ::nsf::method::property C bar-nok returns sex + ::nsf::method::property C set returns sex - ? {c1 bar-ok1 1 2} male - ? {c1 bar-ok2 female 2} female - ? {c1 bar-nok 1 6} {expected sex but got 6} + ? {c1 bar-ok1 1 2} male + ? {c1 bar-ok2 female 2} female + ? {c1 bar-nok 1 6} {expected sex but got 6} - ? {c1 set x male} male - ? {c1 eval {set :x}} male - ? {c1 set x} male + ? {c1 set x male} male + ? {c1 eval {set :x}} male + ? {c1 set x} male - ? {c1 set x hugo} {expected sex but got hugo} + ? {c1 set x hugo} {expected sex but got hugo} - ::nsf::method::property C bar-ok1 returns sex,convert - ::nsf::method::property C bar-ok2 returns sex,convert - ::nsf::method::property C bar-nok returns sex,convert - ::nsf::method::property C set returns sex,convert + ::nsf::method::property C bar-ok1 returns sex,convert + ::nsf::method::property C bar-ok2 returns sex,convert + ::nsf::method::property C bar-nok returns sex,convert + ::nsf::method::property C set returns sex,convert - ? {c1 bar-ok1 1 2} m - ? {c1 bar-ok2 female 2} f - ? {c1 bar-nok 1 6} {expected sex but got 6} + ? {c1 bar-ok1 1 2} m + ? {c1 bar-ok2 female 2} f + ? {c1 bar-nok 1 6} {expected sex but got 6} - ? {c1 set x male} m - ? {c1 eval {set :x}} male - ? {c1 set x} m + ? {c1 set x male} m + ? {c1 eval {set :x}} male + ? {c1 set x} m - ? {c1 set x hugo} {expected sex but got hugo} + ? {c1 set x hugo} {expected sex but got hugo} } # @@ -158,205 +158,236 @@ ::nsf::configure checkresults false ::nx::test configure -count 1000 -::nx::test case int-returns-nocheck { - nx::Class create C { - # scripted method without paramdefs - :method bar-ok1 {a b} {return 1} - :method bar-ok2 {a b} {return $a} - # scripted method with paramdefs - :method bar-nok {a b:integer} {return a} - # alias to tcl-cmd (no param defs) - :alias incr -frame object ::incr - :alias lappend -frame object ::lappend - :create c1 - } +::nx::test case int-returns-nocheck { + nx::Class create C { + # scripted method without paramdefs + :method bar-ok1 {a b} {return 1} + :method bar-ok2 {a b} {return $a} + # scripted method with paramdefs + :method bar-nok {a b:integer} {return a} + # alias to tcl-cmd (no param defs) + :alias incr -frame object ::incr + :alias lappend -frame object ::lappend + :create c1 + } - ::nsf::method::property C bar-ok1 returns integer - ::nsf::method::property C bar-ok2 returns integer - ::nsf::method::property C bar-nok returns integer - ::nsf::method::property C incr returns integer - ::nsf::method::property C lappend returns integer + ::nsf::method::property C bar-ok1 returns integer + ::nsf::method::property C bar-ok2 returns integer + ::nsf::method::property C bar-nok returns integer + ::nsf::method::property C incr returns integer + ::nsf::method::property C lappend returns integer - ? {c1 bar-ok1 1 2} 1 - ? {c1 bar-ok2 1 2} 1 - ? {c1 bar-nok 1 2} a + ? {c1 bar-ok1 1 2} 1 + ? {c1 bar-ok2 1 2} 1 + ? {c1 bar-nok 1 2} a - ? {c1 incr x} 1 - ? {c1 incr x} 1002 + ? {c1 incr x} 1 + ? {c1 incr x} 1002 - ? {c1 lappend l e1} e1 + ? {c1 lappend l e1} e1 - # query the returns value - ? {::nsf::method::property C lappend returns} integer + # query the returns value + ? {::nsf::method::property C lappend returns} integer - # reset it to empty - ? {::nsf::method::property C lappend returns ""} "" + # reset it to empty + ? {::nsf::method::property C lappend returns ""} "" - c1 eval {set :l e1} - # no checking on lappend - ? {c1 lappend l e2} "e1 e2" + c1 eval {set :l e1} + # no checking on lappend + ? {c1 lappend l e2} "e1 e2" - # query returns "", if there is no returns checking - ? {::nsf::method::property C lappend returns} "" - ? {::nsf::method::property ::nx::Class method returns} "" + # query returns "", if there is no returns checking + ? {::nsf::method::property C lappend returns} "" + ? {::nsf::method::property ::nx::Class method returns} "" } ::nx::test configure -count 10 -::nx::test case app-specific-returns-nocheck { +::nx::test case app-specific-returns-nocheck { - ::nx::methodParameterSlot object method type=range {name value arg} { - lassign [split $arg -] min max - if {$value < $min || $value > $max} { - error "Value '$value' of parameter $name not between $min and $max" - } - return $value + ::nx::methodParameterSlot object method type=range {name value arg} { + lassign [split $arg -] min max + if {$value < $min || $value > $max} { + error "Value '$value' of parameter $name not between $min and $max" } + return $value + } - nx::Class create C { - :method bar-ok1 {a b} {return 1} - :method bar-ok2 {a b} {return $a} - :method bar-nok {a b:integer} {return a} - :alias incr -frame object ::incr - :alias lappend -frame object ::lappend - :create c1 - } + nx::Class create C { + :method bar-ok1 {a b} {return 1} + :method bar-ok2 {a b} {return $a} + :method bar-nok {a b:integer} {return a} + :alias incr -frame object ::incr + :alias lappend -frame object ::lappend + :create c1 + } - ::nsf::method::property C bar-ok1 returns range,arg=1-3 - ::nsf::method::property C bar-ok2 returns range,arg=1-3 - ::nsf::method::property C bar-nok returns range,arg=1-3 - ::nsf::method::property C incr returns range,arg=1-30 - ::nsf::method::property C lappend returns range,arg=1-30 + ::nsf::method::property C bar-ok1 returns range,arg=1-3 + ::nsf::method::property C bar-ok2 returns range,arg=1-3 + ::nsf::method::property C bar-nok returns range,arg=1-3 + ::nsf::method::property C incr returns range,arg=1-30 + ::nsf::method::property C lappend returns range,arg=1-30 - ? {c1 bar-ok1 1 2} 1 - ? {c1 bar-ok2 1 2} 1 - ? {c1 bar-nok 1 2} a + ? {c1 bar-ok1 1 2} 1 + ? {c1 bar-ok2 1 2} 1 + ? {c1 bar-nok 1 2} a - ? {c1 incr x} 1 - ? {c1 incr x} 12 + ? {c1 incr x} 1 + ? {c1 incr x} 12 - ? {c1 lappend l e1} e1 + ? {c1 lappend l e1} e1 } ::nx::test configure -count 1000 -::nx::test case converting-returns-nocheck { +::nx::test case converting-returns-nocheck { - ::nx::methodParameterSlot object method type=sex {name value args} { - #puts stderr "[current] slot specific converter" - switch -glob $value { - m* {return m} - f* {return f} - default {error "expected sex but got $value"} - } + ::nx::methodParameterSlot object method type=sex {name value args} { + #puts stderr "[current] slot specific converter" + switch -glob $value { + m* {return m} + f* {return f} + default {error "expected sex but got $value"} } + } - nx::Class create C { - :method bar-ok1 {a b} {return male} - :method bar-ok2 {a b} {return $a} - :method bar-nok {a b:integer} {return $b} - :alias set -frame object ::set - :create c1 - } + nx::Class create C { + :method bar-ok1 {a b} {return male} + :method bar-ok2 {a b} {return $a} + :method bar-nok {a b:integer} {return $b} + :alias set -frame object ::set + :create c1 + } - # - # turn off checker - # - ::nsf::method::property C bar-ok1 returns sex - ::nsf::method::property C bar-ok2 returns sex - ::nsf::method::property C bar-nok returns sex - ::nsf::method::property C set returns sex + # + # turn off checker + # + ::nsf::method::property C bar-ok1 returns sex + ::nsf::method::property C bar-ok2 returns sex + ::nsf::method::property C bar-nok returns sex + ::nsf::method::property C set returns sex - ? {c1 bar-ok1 1 2} male - ? {c1 bar-ok2 female 2} female - ? {c1 bar-nok 1 6} 6 + ? {c1 bar-ok1 1 2} male + ? {c1 bar-ok2 female 2} female + ? {c1 bar-nok 1 6} 6 - ? {c1 set x male} male - ? {c1 eval {set :x}} male - ? {c1 set x} male + ? {c1 set x male} male + ? {c1 eval {set :x}} male + ? {c1 set x} male - ? {c1 set x hugo} hugo + ? {c1 set x hugo} hugo - # - # don't turn off converter - # - ::nsf::method::property C bar-ok1 returns sex,convert - ::nsf::method::property C bar-ok2 returns sex,convert - ::nsf::method::property C bar-nok returns sex,convert - ::nsf::method::property C set returns sex,convert + # + # don't turn off converter + # + ::nsf::method::property C bar-ok1 returns sex,convert + ::nsf::method::property C bar-ok2 returns sex,convert + ::nsf::method::property C bar-nok returns sex,convert + ::nsf::method::property C set returns sex,convert - ? {c1 bar-ok1 1 2} m - ? {c1 bar-ok2 female 2} f - ? {c1 bar-nok 1 6} {expected sex but got 6} + ? {c1 bar-ok1 1 2} m + ? {c1 bar-ok2 female 2} f + ? {c1 bar-nok 1 6} {expected sex but got 6} - ? {c1 set x male} m - ? {c1 eval {set :x}} male - ? {c1 set x} m + ? {c1 set x male} m + ? {c1 eval {set :x}} male + ? {c1 set x} m - ? {c1 set x hugo} {expected sex but got hugo} + ? {c1 set x hugo} {expected sex but got hugo} } ::nsf::configure checkresults true -::nx::test case int-returns-sugar { - nx::Class create C { - # scripted method without paramdefs - :method bar-ok1 {a b} -returns integer {return 1} - :method bar-ok2 {a b} -returns integer {return $a} - # scripted method with paramdefs - :method bar-nok {a b:integer} -returns integer {return a} - # alias to tcl-cmd (no param defs) - :alias incr -returns integer -frame object ::incr - :alias lappend -returns integer -frame object ::lappend - :forward ++ -returns integer ::expr 1 + - :forward | -returns integer ::append _ - :public object method instances {} -returns object,1..n {:info instances} - :create c1 - } +::nx::test case int-returns-sugar { + nx::Class create C { + # scripted method without paramdefs + :method bar-ok1 {a b} -returns integer {return 1} + :method bar-ok2 {a b} -returns integer {return $a} + # scripted method with paramdefs + :method bar-nok {a b:integer} -returns integer {return a} + # alias to tcl-cmd (no param defs) + :alias incr -returns integer -frame object ::incr + :alias lappend -returns integer -frame object ::lappend + :forward ++ -returns integer ::expr 1 + + :forward | -returns integer ::append _ + :public object method instances {} -returns object,1..n {:info instances} + :create c1 + } - package req nx::serializer - set s [C serialize] + package req nx::serializer + set s [C serialize] puts $s - ? [list set _ [regsub -all returns $s returns s]] 8 "occurrences of returns" + ? [list set _ [regsub -all returns $s returns s]] 8 "occurrences of returns" - ? {c1 bar-ok1 1 2} 1 - ? {c1 bar-ok2 1 2} 1 - ? {c1 ++ 1000} 1001 - ? {c1 | a} {expected integer but got "a" as return value} - ? {::nsf::method::property ::C ::nsf::classes::C::bar-nok returns} integer - ? {c1 bar-nok 1 2} {expected integer but got "a" as return value} + ? {c1 bar-ok1 1 2} 1 + ? {c1 bar-ok2 1 2} 1 + ? {c1 ++ 1000} 1001 + ? {c1 | a} {expected integer but got "a" as return value} + ? {::nsf::method::property ::C ::nsf::classes::C::bar-nok returns} integer + ? {c1 bar-nok 1 2} {expected integer but got "a" as return value} - ? {C instances} ::c1 + ? {C instances} ::c1 - ? {c1 incr x} 1 - ? {c1 incr x} 1002 + ? {c1 incr x} 1 + ? {c1 incr x} 1002 - ? {c1 lappend l e1} {expected integer but got "e1" as return value} + ? {c1 lappend l e1} {expected integer but got "e1" as return value} - # query the returns value - ? {::nsf::method::property C lappend returns} integer + # query the returns value + ? {::nsf::method::property C lappend returns} integer - # reset it to empty - ? {::nsf::method::property C lappend returns ""} "" - ? {::nsf::method::property C bar-ok1 returns ""} "" - ? {::nsf::method::property C bar-ok2 returns ""} "" - ? {::nsf::method::property C bar-nok returns ""} "" - ? {::nsf::method::property C ++ returns ""} "" - ? {::nsf::method::property C | returns ""} "" + # reset it to empty + ? {::nsf::method::property C lappend returns ""} "" + ? {::nsf::method::property C bar-ok1 returns ""} "" + ? {::nsf::method::property C bar-ok2 returns ""} "" + ? {::nsf::method::property C bar-nok returns ""} "" + ? {::nsf::method::property C ++ returns ""} "" + ? {::nsf::method::property C | returns ""} "" - # no checking - ? {c1 bar-ok1 1 2} 1 - ? {c1 bar-ok2 1 2} 1 - ? {c1 bar-nok 1 2} a - ? {c1 lappend l e2} "e1 e2" - ? {c1 ++ 1000} 1001 - ? {c1 | a} "a" + # no checking + ? {c1 bar-ok1 1 2} 1 + ? {c1 bar-ok2 1 2} 1 + ? {c1 bar-nok 1 2} a + ? {c1 lappend l e2} "e1 e2" + ? {c1 ++ 1000} 1001 + ? {c1 | a} "a" - # query returns "", if there is no returns checking - ? {::nsf::method::property C lappend returns} "" - ? {::nsf::method::property ::nx::Class method returns} "" + # query returns "", if there is no returns checking + ? {::nsf::method::property C lappend returns} "" + ? {::nsf::method::property ::nx::Class method returns} "" } +::nx::test case int-returns-string-checks { + ::nx::Class create TestOK { + # + # strings test with "string is alpha" checker + # + :public method get1 {} -returns alpha { return a } + :public method get2 {} -returns alpha { return 1 } + :public method get3 {} -returns alpha,1..n { return {a b c} } + :public method get4 {} -returns alpha,1..n { return {a 1 c} } + # + # built-in checker + # + :public method get5 {} -returns integer { return 2 } + :public method get6 {} -returns integer { return a } + :public method get7 {} -returns integer,1..n { return {1 2 3} } + :public method get8 {} -returns integer,1..n { return {1 2 a} } + + :create a + } + + ? {a get1} a + ? {a get2} {expected alpha but got "1" as return value} + ? {a get3} {a b c} + ? {a get4} {invalid value in "a 1 c": expected alpha but got "1" as return value} + ? {a get5} 2 + ? {a get6} {expected integer but got "a" as return value} + ? {a get7} {1 2 3} + ? {a get8} {invalid value in "1 2 a": expected integer but got "a" as return value} +} + + ::nx::test case empty-paramdefs-robustedness { ::nx::Object create ku { # 1: Create an empty or checker-free parameter spec @@ -384,4 +415,3 @@ # tcl-indent-level: 2 # indent-tabs-mode: nil # End: -