aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals@canonical.com>2013-05-15 17:28:35 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-29 08:23:09 +0200
commit3414cc6c7a4e021ec2c9a4f369acc2a0a0568c58 (patch)
treed7e6ebf8d60d12623ed349bdbe7f1fe4b33ecdbf
parent114c9a16e240558a8aea2004696369e78ef5ac80 (diff)
Make sure tryCompare value argument is not undefined
It happens often that people convert a compare(foo.bar, 3) to a tryCompare(foo.bar, 3) and unfortunately that succeeds but doesn't do what they expected This makes tryCompare fail if no third argument is given Task-number: QTBUG-31427 Change-Id: I0c9618dae9aad4be55aa35c3e2dcf3535728beaa Reviewed-by: Alan Alpert <aalpert@blackberry.com>
-rw-r--r--dist/changes-5.1.03
-rw-r--r--src/imports/testlib/TestCase.qml5
2 files changed, 8 insertions, 0 deletions
diff --git a/dist/changes-5.1.0 b/dist/changes-5.1.0
index 50bdc2f9f8..8633d22eef 100644
--- a/dist/changes-5.1.0
+++ b/dist/changes-5.1.0
@@ -43,6 +43,9 @@ Third party components
as count, which are based off of the data model will no longer update
immediately if queried. Updates are batched to happen once per frame (or
when properties are being set).
+
+ - tryCompare now correctly fails when it only gets two parameters
+
****************************************************************************
* Library *
****************************************************************************
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index 7584241ca6..0bec4cddf2 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -291,6 +291,11 @@ Item {
}
function tryCompare(obj, prop, value, timeout) {
+ if (arguments.length == 2) {
+ qtest_results.fail("A value is required for tryCompare",
+ util.callerFile(), util.callerLine())
+ throw new Error("QtQuickTest::fail")
+ }
if (!timeout)
timeout = 5000
if (!qtest_compareInternal(obj[prop], value))