From a3fac538645e0c672ac7c8d5e86f8cfbb1ec8426 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 13 May 2015 19:34:19 +0200 Subject: [PATCH] add parser tests for use of 'else' after bad conditionals Change-Id: I9885f629a2f6511574eebd81896a1d9f258e55cb Reviewed-by: Joerg Bornemann Reviewed-by: Oswald Buddenhagen --- tests/auto/tools/qmakelib/tst_qmakelib.cpp | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/auto/tools/qmakelib/tst_qmakelib.cpp b/tests/auto/tools/qmakelib/tst_qmakelib.cpp index 0667b673000..441a36e34d5 100644 --- a/tests/auto/tools/qmakelib/tst_qmakelib.cpp +++ b/tests/auto/tools/qmakelib/tst_qmakelib.cpp @@ -1373,6 +1373,29 @@ void tst_qmakelib::proParser_data() << "in:1: Unexpected 'else'." << false; + QTest::newRow("double-test-else") + << "foo bar\nelse" + << TS( + /* 0 */ << H(TokBranch) + /* 1 */ /* then branch */ << I(0) + /* 3 */ /* else branch */ << I(1) // This seems weird + /* 5 */ << H(TokTerminator)) + << "in:1: Extra characters after test expression." + << false; + + QTest::newRow("test-function-else") + << "foo bar()\nelse" + << TS( + /* 0 */ << H(TokLine) << H(1) + /* 2 */ << H(TokTestCall) // This seems pointless + /* 3 */ << H(TokFuncTerminator) + /* 4 */ << H(TokBranch) + /* 5 */ /* then branch */ << I(0) + /* 7 */ /* else branch */ << I(1) // This seems weird + /* 9 */ << H(TokTerminator)) + << "in:1: Extra characters after test expression." + << false; + // Braces QTest::newRow("{}")