From 348b51327fe72fc8ea4292a3b5cb4df178c1d234 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 2 Feb 2012 14:47:07 +1000 Subject: Ensure || expressions in v4 will always exit. Change-Id: I7188e38403fec96f83f3bdfc68b763a9aec9346a Task-number: QTBUG-24038 Reviewed-by: Michael Brasser --- tests/auto/declarative/v4/data/nestedLogicalOr.qml | 14 ++++++++++++++ tests/auto/declarative/v4/tst_v4.cpp | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/auto/declarative/v4/data/nestedLogicalOr.qml (limited to 'tests/auto/declarative') diff --git a/tests/auto/declarative/v4/data/nestedLogicalOr.qml b/tests/auto/declarative/v4/data/nestedLogicalOr.qml new file mode 100644 index 0000000000..c4478a3e7b --- /dev/null +++ b/tests/auto/declarative/v4/data/nestedLogicalOr.qml @@ -0,0 +1,14 @@ +import Qt.v4 1.0 + +Result { + property bool val1: false + property bool val2: true + property bool val3: false + + property bool b1: (false || false || true) + property bool b2: (false || (false || true)) + property bool b3: ((false || false) || true) + property bool b4: (val1 || (val2 || val3)) ? true : false + + result: b1 && b2 && b3 && b4 +} diff --git a/tests/auto/declarative/v4/tst_v4.cpp b/tests/auto/declarative/v4/tst_v4.cpp index 751fb337b4..fb6f8776e0 100644 --- a/tests/auto/declarative/v4/tst_v4.cpp +++ b/tests/auto/declarative/v4/tst_v4.cpp @@ -62,6 +62,7 @@ private slots: void unnecessaryReeval(); void logicalOr(); + void nestedLogicalOr(); void conditionalExpr(); void qtscript(); void qtscript_data(); @@ -183,6 +184,21 @@ void tst_v4::logicalOr() } } +void tst_v4::nestedLogicalOr() +{ + //we are primarily testing that v4 does not get caught in a loop (QTBUG-24038) + QDeclarativeComponent component(&engine, testFileUrl("nestedLogicalOr.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 1); + delete o; +} + void tst_v4::conditionalExpr() { { -- cgit v1.2.3