diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-07-05 10:41:57 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-07-05 17:02:25 +0200 |
commit | 9f11f62c80115565219f156d41d764a5e37ef084 (patch) | |
tree | 4f05fb0cc1b8dd7924af115b07eb5479c62438a4 /src/qmltest | |
parent | db3f55748b3f77f6b19d8599c5cb136159c90c0b (diff) |
Modernize QuickTest's TestCase.qml
Avoid using the deprecated arguments; use rest parameters instead.
Change-Id: Ie6977376873e1f54154dcbd7d6d73401e4a1879d
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'src/qmltest')
-rw-r--r-- | src/qmltest/TestCase.qml | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/qmltest/TestCase.qml b/src/qmltest/TestCase.qml index 1c9011e01e..c7d940600d 100644 --- a/src/qmltest/TestCase.qml +++ b/src/qmltest/TestCase.qml @@ -442,8 +442,8 @@ Item { displays the optional \a message. Similar to \c{QVERIFY(condition)} or \c{QVERIFY2(condition, message)} in C++. */ - function verify(cond, msg) { - if (arguments.length > 2) + function verify(cond, msg, ...args) { + if (args.length > 0) qtest_fail("More than two arguments given to verify(). Did you mean tryVerify() or tryCompare()?", 1) if (msg === undefined) @@ -1028,17 +1028,18 @@ Item { \sa compare(), SignalSpy::wait() */ - function tryCompare(obj, prop, value, timeout, msg) { - if (arguments.length == 1 || (typeof(prop) != "string" && typeof(prop) != "number")) { + function tryCompare(obj, prop, ...args) { + if (typeof(prop) != "string" && typeof(prop) != "number") { qtest_results.fail("A property name as string or index is required for tryCompare", util.callerFile(), util.callerLine()) throw new Error("QtQuickTest::fail") } - if (arguments.length == 2) { + if (args.length == 0) { qtest_results.fail("A value is required for tryCompare", util.callerFile(), util.callerLine()) throw new Error("QtQuickTest::fail") } + let [value, timeout, msg] = args if (timeout !== undefined && typeof(timeout) != "number") { qtest_results.fail("timeout should be a number", util.callerFile(), util.callerLine()) |