aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@kdab.com>2016-05-03 09:57:24 +0200
committerKevin Ottens <kevin.ottens@kdab.com>2016-05-03 08:00:30 +0000
commit373c621bf4dc2ab07bb9c4f19c783fd36debb0dc (patch)
tree24e30fb67062712d4dae249c56492de712c146e2 /tests
parent42fd8ec2495001c1435bbc34017416c18e691bb3 (diff)
Add QVector support to JS sequences
Change-Id: I731355aa1754721236f3711a65af4f96781cebc0 Task-number: QTBUG-51467 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceSort.qml26
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.cpp12
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp2
3 files changed, 39 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml b/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml
index b130408c18..74c7cda9a3 100644
--- a/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml
@@ -64,6 +64,16 @@ Item {
var actual = msc.reals(realList);
return checkResults(expected, actual, fn);
}
+ function doIntVectorTest(intList, fn) {
+ var expected = createExpected(intList, fn);
+ var actual = msc.integerVector(intList);
+ return checkResults(expected, actual, fn);
+ }
+ function doRealVectorTest(realList, fn) {
+ var expected = createExpected(realList, fn);
+ var actual = msc.realVector(realList);
+ return checkResults(expected, actual, fn);
+ }
function test_qtbug_25269(useCustomCompare) {
return doStringTest( [ "one", "two", "three" ], null );
@@ -92,4 +102,20 @@ Item {
var fn = useCustomCompare ? compareNumbers : null;
return doRealTest( [ -3.4, 1, 10, 4.23, -30.1, 4.24, 4.21, -1, -1, 12, -100, 87.4, 101.3, -8.88888, 7.76, 10.10, 1.1, -1.1, -0, 11, 12.8, 0.001, -11, -0.75, 99999.99, 11.12, 32.3, 3.333333, 9.876 ], fn );
}
+ function test_number_vector_insertionSort(useCustomCompare) {
+ var fn = useCustomCompare ? compareNumbers : null;
+ return doIntVectorTest( [ 7, 3, 9, 1, 0, -1, 20, -11 ], fn );
+ }
+ function test_number_vector_quickSort(useCustomCompare) {
+ var fn = useCustomCompare ? compareNumbers : null;
+ return doIntVectorTest( [ 7, 3, 37, 9, 1, 0, -1, 20, -11, -300, -87, 1, 3, -2, 100, 108, 96, 9, 99999, 12, 11, 11, 12, 11, 13, -13, 10, 10, 10, 8, 12 ], fn );
+ }
+ function test_real_vector_insertionSort(useCustomCompare) {
+ var fn = useCustomCompare ? compareNumbers : null;
+ return doRealVectorTest( [ -3.4, 1, 10, 4.23, -30.1, 4.24, 4.21, -1, -1 ], fn );
+ }
+ function test_real_vector_quickSort(useCustomCompare) {
+ var fn = useCustomCompare ? compareNumbers : null;
+ return doRealVectorTest( [ -3.4, 1, 10, 4.23, -30.1, 4.24, 4.21, -1, -1, 12, -100, 87.4, 101.3, -8.88888, 7.76, 10.10, 1.1, -1.1, -0, 11, 12.8, 0.001, -11, -0.75, 99999.99, 11.12, 32.3, 3.333333, 9.876 ], fn );
+ }
}
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp
index 2afa21ddd6..d9ddcd71a7 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.cpp
+++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp
@@ -295,6 +295,18 @@ public:
{
return v;
}
+ Q_INVOKABLE QVector<int> integerVector(QVector<int> v) const
+ {
+ return v;
+ }
+ Q_INVOKABLE QVector<qreal> realVector(QVector<qreal> v) const
+ {
+ return v;
+ }
+ Q_INVOKABLE QVector<bool> boolVector(QVector<bool> v) const
+ {
+ return v;
+ }
};
static MyInheritedQmlObject *theSingletonObject = 0;
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 9b17f70a91..87f9f963f9 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -7336,7 +7336,7 @@ void tst_qqmlecmascript::sequenceSort_data()
QTest::newRow("qtbug_25269") << "test_qtbug_25269" << false;
- const char *types[] = { "alphabet", "numbers", "reals" };
+ const char *types[] = { "alphabet", "numbers", "reals", "number_vector", "real_vector" };
const char *sort[] = { "insertionSort", "quickSort" };
for (size_t t=0 ; t < sizeof(types)/sizeof(types[0]) ; ++t) {