diff options
author | Robert Griebl <robert.griebl@pelagicore.com> | 2014-07-30 17:00:26 (GMT) |
---|---|---|
committer | Robert Griebl <robert.griebl@pelagicore.com> | 2014-08-05 12:49:17 (GMT) |
commit | bb0239e9b3c0b1d00255ef9dfbb36c1ba4e2d123 (patch) | |
tree | 5c99db90db11ddc7e62ff83ea3a9e2267a83abeb /tests | |
parent | ec808b78e1b8d5cf128b3ef3e6933cb5ddd48544 (diff) | |
download | Qt-bb0239e9b3c0b1d00255ef9dfbb36c1ba4e2d123.zip Qt-bb0239e9b3c0b1d00255ef9dfbb36c1ba4e2d123.tar.gz Qt-bb0239e9b3c0b1d00255ef9dfbb36c1ba4e2d123.tar.bz2 |
Add handling of value-type lists to QDeclarativeExpression::evaluate()
QDeclarativeExpression::evaluate() converts all arrays to QList<QObject *>,
even if the items cannot be represented by a QObject *. In case of a
string-list, a QList of null-pointers is returned (which isn't very helpful).
This patch makes evaluate() convert arrays, which contain ONLY value-type
items, into a plain QVariantList.
Change-Id: I4e5052af9fb296a4b692df7840bdd188298f7416
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 0e9e9be..ac548b1 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -447,6 +447,16 @@ void tst_qdeclarativeecmascript::arrayExpressions() QCOMPARE(list.at(1), &obj2); QCOMPARE(list.at(2), &obj3); QCOMPARE(list.at(3), (QObject *)0); + + MyExpression expr2(&context, "[1, 2, \"foo\", \"bar\"]"); + result = expr2.evaluate(); + QCOMPARE(result.userType(), qMetaTypeId<QList<QVariant> >()); + QList<QVariant> list2 = qvariant_cast<QList<QVariant> >(result); + QCOMPARE(list2.count(), 4); + QCOMPARE(list2.at(0), QVariant(1)); + QCOMPARE(list2.at(1), QVariant(2)); + QCOMPARE(list2.at(2), QVariant(QString("foo"))); + QCOMPARE(list2.at(3), QVariant(QString("bar"))); } // Tests that modifying a context property will reevaluate expressions |