1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
/* KDevelop QMake Support
*
* Copyright 2006 Andreas Pakulat <apaku@gmx.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/*
Some notes for special cases to test:
somescope:anotherscope {
}
scope | scope : SOMEVAR = foo
eval($${subdir}.depends = $$basename($${subdir})/$(MAKEFILE)
eval( $$somefunc( $$VAR, else ) ) {
} else {
}
scopename: (no statement, is accepted by qmake)
*/
#include "parsetest.h"
#include "qmakedriver.h"
#include "ast.h"
#include "testhelpers.h"
QTEST_MAIN(ParseTest)
ParseTest::ParseTest(QObject* parent)
: QObject(parent)
{
}
ParseTest::~ParseTest()
{
}
BEGINTESTFUNCIMPL(ParseTest, successSimpleProject, 2)
ENDTESTFUNCIMPL
DATAFUNCIMPL(ParseTest, successSimpleProject, "VAR = VALUE\nfunc1(arg1)\n")
BEGINTESTFAILFUNCIMPL(ParseTest, failSimpleProject, "Missing value for variable and no lineending")
ENDTESTFUNCIMPL
DATAFUNCIMPL(ParseTest, failSimpleProject, "foo(")
BEGINTESTFUNCIMPL(ParseTest, successFullProject, 10)
ENDTESTFUNCIMPL
DATAFUNCIMPL(ParseTest, successFullProject,
"#Comment\n"
"VARIABLE1 = Value1 Value2\n"
"VARIABLE2= Value1 Value2\n"
"VARIABLE3 =Value1 Value2\n"
"VARIABLE4=Value1 Value2\n"
"VARIABLE = Value1 Value2 #some comment\n"
"VARIABLE = $$Value1 $(Value2) $${Value3} #some comment\n"
"VARIABLE = $$Value1 $(Value2) $${Value3} \\\nValue4\n"
"message( foo, bar, $$foobar( foo, $$FOOBAR ), $${FOOBAR}, $(SHELL) ) : FO=0\n"
"message( foo, bar, $$foobar( foo, $$FOOBAR ), $${FOOBAR}, $(SHELL) ) { \n"
"FOO = bar\n"
"}\n"
"!do()\n")
BEGINTESTFAILFUNCIMPL(ParseTest, failFullProject, "Missing closing brace in scope for fo()")
ENDTESTFUNCIMPL
DATAFUNCIMPL(ParseTest, failFullProject, "#Comment\n"
"VARIABLE1 = Value1 Value2\n"
"VARIABLE2= Value1 Value2\n"
"VARIABLE3 =Value1 Value2\n"
"VARIABLE4=Value1 Value2\n"
"VARIABLE4=Value1 Value2 \\\n"
" Value3 Value4\n"
"fo()\n{\n"
"VARIABLE = Value1 Value2 \\#some comment\n"
"win32 : FOOBAR=Value1\n"
"fun1()|!fun2(): FOOBAR=Value1\n")
void ParseTest::init()
{
ast = new QMake::ProjectAST();
QVERIFY(ast != nullptr);
}
void ParseTest::cleanup()
{
delete ast;
ast = nullptr;
QVERIFY(ast == nullptr);
}
|