diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2011-11-29 13:06:47 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-30 12:28:27 +0100 |
commit | dcf1e555d7d2ff435098fe910262cc77dcf835db (patch) | |
tree | 294a94c138e3cebe025bd7a3f4abc0be6776cd12 /tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | |
parent | 92b2a05dcae983be6f108e010114c129809b9234 (diff) |
Extend the grammar of QML binding declarations.
This allows the use of non-iterative statements
on the right hand side of a binding declaration.
Change-Id: I60fac880766ba99a410b3647e41b1252677a372f
Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 5565aaf137..3fdf1e905c 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -233,6 +233,8 @@ private slots: void automaticSemicolon(); void unaryExpression(); void switchStatement(); + void withStatement(); + void tryStatement(); private: static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -5339,6 +5341,75 @@ void tst_qdeclarativeecmascript::switchStatement() object->setStringProperty("something else"); QCOMPARE(object->value(), 1); } + + { + QDeclarativeComponent component(&engine, TEST_FILE("switchStatement.6.qml")); + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + + // `object->value()' is the number of executed statements + + object->setStringProperty("A"); + QCOMPARE(object->value(), 123); + + object->setStringProperty("S"); + QCOMPARE(object->value(), 123); + + object->setStringProperty("D"); + QCOMPARE(object->value(), 321); + + object->setStringProperty("F"); + QCOMPARE(object->value(), 321); + + object->setStringProperty("something else"); + QCOMPARE(object->value(), 0); + } +} + +void tst_qdeclarativeecmascript::withStatement() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("withStatement.1.qml")); + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->value(), 123); + } +} + +void tst_qdeclarativeecmascript::tryStatement() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("tryStatement.1.qml")); + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->value(), 123); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("tryStatement.2.qml")); + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->value(), 321); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("tryStatement.3.qml")); + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->value(), 1); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("tryStatement.4.qml")); + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->value(), 1); + } } QTEST_MAIN(tst_qdeclarativeecmascript) |