[Development] [QML] Making tryCompare accept a message
Alan Alpert
416365416c at gmail.com
Wed Jul 31 18:50:36 CEST 2013
On Wed, Jul 31, 2013 at 4:34 AM, Albert Astals Cid
<albert.astals at canonical.com> wrote:
> Hi, when using the QML TestLib the compare function has a message parameter
>
> \qmlmethod TestCase::compare(actual, expected, message = "")
>
> Fails the current test case if \a actual is not the same as
> \a expected, and displays the optional \a message.
>
> We have found the need for tryCompare to have also the message parameter since
> at the moment is not there
>
> \qmlmethod TestCase::tryCompare(obj, property, expected, timeout = 5000)
>
> So I was wondering if we should introduce a new function like
>
> \qmlmethod TestCase::tryCompareWithMessage(obj, property, expected,
> message = "", timeout = 5000)
>
> or if we could use javascript trickery to just change the existing tryCompare
> function to
>
> \qmlmethod TestCase::tryCompare(obj, property, expected, message = "",
> timeout = 5000)
>
> and then in the code do (note code is untested but something like that should
> be possible)
>
> if (typeof(message) == "number") {
> // The 4th parameter used to be timeout
> timeout = msg
> message = undefined
> }
>
> i.e. use Javascript type magic to still let people pass the timeout as fourth
> parameter to keep compatibility with the old signature.
>
> Personally i favour this second option but if you prefer the first one that's
> fine too.
What's the problem with the third option?
\qmlmethod TestCase::tryCompare(obj, property, expected, timeout =
5000, message = "")
Yes, you'll need to specify a timeout sometimes when you don't want
to, but there's a similar problem if you put message first.
--
Alan Alpert
More information about the Development
mailing list