Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.10
-
None
Description
In many places in auto tests we do this:
compare(qtest_compareInternal(null, null), true, "null");
or after refactoring from https://codereview.qt-project.org/#/c/212635/ :
compare(Compare.compareInternal(null, null), true, "null");
Which actually could be a useful public API, something like:
compare(a, b, bool expected, msg)
or maybe:
compareNotEqual() as alternative for compare(), which compares for "is-equal" and fails if it is not. And maybe this automatic failure behavior is the reason for the following hack (from http://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/imports/testlib/main.cpp#n112):
bool compare(const QVariant& act, const QVariant& exp) const { return act == exp; }
Which is not really an alternative, because:
1) it is hackish, non public API
2) it compares QVariants, which is different from comparison algorithm used by JS implementation.
3) this function also doesn't seem to be used anywhere, which indicates that it is not very useful (or maybe just well hidden... but see that two reasons above )