summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/tools')
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp25
-rw-r--r--tests/auto/tools/qmake/qmake.pro6
-rw-r--r--tests/auto/tools/qmake/testdata/comments/comments.pro31
-rw-r--r--tests/auto/tools/qmake/testdata/func_export/func_export.pro19
-rw-r--r--tests/auto/tools/qmake/testdata/func_variables/func_variables.pro49
-rw-r--r--tests/auto/tools/qmake/testdata/functions/1.cpp32
-rw-r--r--tests/auto/tools/qmake/testdata/functions/2.cpp32
-rw-r--r--tests/auto/tools/qmake/testdata/functions/functions.pro184
-rw-r--r--tests/auto/tools/qmake/testdata/functions/one/1.cpp32
-rw-r--r--tests/auto/tools/qmake/testdata/functions/one/2.cpp32
-rw-r--r--tests/auto/tools/qmake/testdata/functions/textfile1
-rw-r--r--tests/auto/tools/qmake/testdata/functions/three/wildcard21.cpp32
-rw-r--r--tests/auto/tools/qmake/testdata/functions/three/wildcard22.cpp32
-rw-r--r--tests/auto/tools/qmake/testdata/functions/two/1.cpp32
-rw-r--r--tests/auto/tools/qmake/testdata/functions/two/2.cpp32
-rw-r--r--tests/auto/tools/qmake/testdata/functions/wildcard21.cpp32
-rw-r--r--tests/auto/tools/qmake/testdata/functions/wildcard22.cpp32
-rw-r--r--tests/auto/tools/qmake/testdata/include_function/existing_file.pri3
-rw-r--r--tests/auto/tools/qmake/testdata/include_function/include_existing_file.pro7
-rw-r--r--tests/auto/tools/qmake/testdata/include_function/include_missing_file.pro3
-rw-r--r--tests/auto/tools/qmake/testdata/include_function/include_missing_file2.pro3
-rw-r--r--tests/auto/tools/qmake/testdata/json/json.pro26
-rw-r--r--tests/auto/tools/qmake/testdata/json/test.json9
-rw-r--r--tests/auto/tools/qmake/testdata/operators/operators.pro23
-rw-r--r--tests/auto/tools/qmake/testdata/resources/main.cpp (renamed from tests/auto/tools/qmake/testdata/include_function/main.cpp)9
-rw-r--r--tests/auto/tools/qmake/testdata/resources/resources.pro10
-rw-r--r--tests/auto/tools/qmake/testdata/resources/subdir/file.txt0
-rw-r--r--tests/auto/tools/qmake/testdata/resources/test.qrc5
-rw-r--r--tests/auto/tools/qmake/testdata/variables/variables.pro12
-rw-r--r--tests/auto/tools/qmake/tst_qmake.cpp129
-rw-r--r--tests/auto/tools/qmakelib/evaltest.cpp2513
-rw-r--r--tests/auto/tools/qmakelib/parsertest.cpp1987
-rw-r--r--tests/auto/tools/qmakelib/qmakelib.pro12
-rw-r--r--tests/auto/tools/qmakelib/testdata/cat/file1.txt2
-rw-r--r--tests/auto/tools/qmakelib/testdata/cat/file2.txt5
-rw-r--r--tests/auto/tools/qmakelib/testdata/files/dir/file1.txt0
-rw-r--r--tests/auto/tools/qmakelib/testdata/files/dir/file2.txt0
-rw-r--r--tests/auto/tools/qmakelib/testdata/files/file1.txt0
-rw-r--r--tests/auto/tools/qmakelib/testdata/files/file2.txt0
-rw-r--r--tests/auto/tools/qmakelib/testdata/files/other.txt0
-rw-r--r--tests/auto/tools/qmakelib/testdata/fromfile/badfile.prx1
-rw-r--r--tests/auto/tools/qmakelib/testdata/fromfile/infile.prx (renamed from tests/auto/tools/qmake/testdata/functions/infiletest.pro)0
-rw-r--r--tests/auto/tools/qmakelib/testdata/include/inc.pri8
-rw-r--r--tests/auto/tools/qmakelib/testdata/mkspecs/fake-g++/qmake.conf1
-rw-r--r--tests/auto/tools/qmakelib/testdata/mkspecs/features/default_post.prf1
-rw-r--r--tests/auto/tools/qmakelib/testdata/mkspecs/features/default_pre.prf1
-rw-r--r--tests/auto/tools/qmakelib/testdata/mkspecs/features/spec_post.prf1
-rw-r--r--tests/auto/tools/qmakelib/testdata/mkspecs/features/spec_pre.prf1
-rw-r--r--tests/auto/tools/qmakelib/testdata/mkspecs/features/testfeat.prf1
-rw-r--r--tests/auto/tools/qmakelib/tst_qmakelib.cpp2059
-rw-r--r--tests/auto/tools/qmakelib/tst_qmakelib.h111
51 files changed, 4841 insertions, 2737 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 00e5c60b29..350c6142d2 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -87,6 +87,18 @@ struct QTBUG_31218_Derived : QTBUG_31218<-1<0> {};
class QTBUG_45790 : Bug() { };
#endif
+class CreatableGadget
+{
+ Q_GADGET
+public:
+ Q_INVOKABLE CreatableGadget()
+ {
+ CreatableGadget::qt_static_metacall((QObject*)this, QMetaObject::ReadProperty, -1, Q_NULLPTR);
+ }
+};
+
+CreatableGadget creatableGadget; // Force the compiler to use the constructor
+
struct MyStruct {};
struct MyStruct2 {};
@@ -680,7 +692,7 @@ void tst_Moc::oldStyleCasts()
QStringList args;
args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
- << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIE" << "-";
+ << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-";
proc.start("gcc", args);
QVERIFY(proc.waitForStarted());
proc.write(mocOut);
@@ -750,7 +762,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
QStringList args;
args << "-c" << "-x" << "c++" << "-I" << ".."
- << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIE" << "-";
+ << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-";
proc.start("gcc", args);
QVERIFY(proc.waitForStarted());
proc.write(mocOut);
@@ -1029,7 +1041,7 @@ void tst_Moc::ignoreOptionClashes()
// If -pthread wasn't ignored, it was parsed as a prefix of "thread/", which breaks compilation.
QStringList gccArgs;
gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
- << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null" << "-fPIE" << "-";
+ << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null" << "-fPIC" << "-";
proc.start("gcc", gccArgs);
QVERIFY(proc.waitForStarted());
proc.write(mocOut);
@@ -1870,6 +1882,13 @@ void tst_Moc::warnings_data()
<< 1
<< QString()
<< QString("standard input:5: Error: Class declaration lacks Q_OBJECT macro.");
+
+ QTest::newRow("QTBUG-46210: crash on invalid macro")
+ << QByteArray("#define Foo(a, b, c) a b c #a #b #c a##b##c #d\n Foo(45);")
+ << QStringList()
+ << 1
+ << QString("IGNORE_ALL_STDOUT")
+ << QString(":2: Error: '#' is not followed by a macro parameter");
}
void tst_Moc::warnings()
diff --git a/tests/auto/tools/qmake/qmake.pro b/tests/auto/tools/qmake/qmake.pro
index 5ed3073e20..d0817247db 100644
--- a/tests/auto/tools/qmake/qmake.pro
+++ b/tests/auto/tools/qmake/qmake.pro
@@ -8,5 +8,11 @@ SOURCES += tst_qmake.cpp testcompiler.cpp
QT = core testlib
cross_compile: DEFINES += QMAKE_CROSS_COMPILED
+debug_and_release {
+ CONFIG(debug, debug|release): \
+ DEFINES += DEBUG_BUILD
+ else: \
+ DEFINES += RELEASE_BUILD
+}
TESTDATA += testdata/*
diff --git a/tests/auto/tools/qmake/testdata/comments/comments.pro b/tests/auto/tools/qmake/testdata/comments/comments.pro
deleted file mode 100644
index 510ab95ab3..0000000000
--- a/tests/auto/tools/qmake/testdata/comments/comments.pro
+++ /dev/null
@@ -1,31 +0,0 @@
-LIST = 1 2 3 4 #a comment
-!equals( LIST, 1 2 3 4 ) {
- message( "FAILED: inline comment" )
-}
-
-LIST = 1 \
- 2 \
-# 3 \
- 4
-!equals( LIST, 1 2 4 ) {
- message( "FAILED: commented out continuation" )
-}
-
-LIST = 1 \
- 2 \#comment
- 3 \
- 4
-!equals( LIST, 1 2 3 4 ) {
- message( "FAILED: comment at end of continuation")
-}
-
-
-LIST = 1 2 3 4#comment
-!equals( LIST, 1 2 3 4 ) {
- message( "FAILED: no space before comment" )
-}
-
-LIST = 1 2 3 4$${LITERAL_HASH}five
-!equals( LIST, 1 2 3 4$${LITERAL_HASH}five ) {
- message( "FAILED: using LITERAL_HASH" )
-}
diff --git a/tests/auto/tools/qmake/testdata/func_export/func_export.pro b/tests/auto/tools/qmake/testdata/func_export/func_export.pro
deleted file mode 100644
index fc3818985b..0000000000
--- a/tests/auto/tools/qmake/testdata/func_export/func_export.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-defineTest(doExport) {
- EXPORTED += $$1
- export(EXPORTED)
-}
-
-defineTest(callDoExport) {
- doExport(bar)
- doExport(baz)
- EXPORTED = oink
- !isEqual(EXPORTED, "oink") {
- message( "FAILED: function-scope exports [$$EXPORTED] != oink" )
- }
-}
-
-doExport(foo)
-callDoExport()
-!isEqual(EXPORTED, "foo bar baz") {
- message( "FAILED: global-scope exports [$$EXPORTED] != foo bar baz" )
-}
diff --git a/tests/auto/tools/qmake/testdata/func_variables/func_variables.pro b/tests/auto/tools/qmake/testdata/func_variables/func_variables.pro
deleted file mode 100644
index cc13437f4a..0000000000
--- a/tests/auto/tools/qmake/testdata/func_variables/func_variables.pro
+++ /dev/null
@@ -1,49 +0,0 @@
-defineTest(testVariable) {
- varname=$$1
- value=$$eval($$varname)
- RESULT=$$value
- export(RESULT)
-}
-
-defineTest(callTest) {
- myvar=$$1
- testVariable(myvar)
-}
-
-defineTest(callTestExport) {
- myvar=$$1
- export(myvar)
- testVariable(myvar)
-}
-
-defineTest(callTestExportChange) {
- myvar=foo
- export(myvar)
- myvar=$$1
- testVariable(myvar)
-}
-
-value=direct
-myvar=$$value
-testVariable(myvar)
-!isEqual(RESULT,$$value) {
- message( "FAILED: result [$$RESULT] != $$value" )
-}
-
-value=export
-callTestExport($$value)
-!isEqual(RESULT,$$value) {
- message( "FAILED: result [$$RESULT] != $$value" )
-}
-
-value=export_and_change
-callTestExportChange($$value)
-!isEqual(RESULT,$$value) {
- message( "FAILED: result [$$RESULT] != $$value" )
-}
-
-value=local
-callTest($$value)
-!isEqual(RESULT,$$value) {
- message( "FAILED: result [$$RESULT] != $$value" )
-}
diff --git a/tests/auto/tools/qmake/testdata/functions/1.cpp b/tests/auto/tools/qmake/testdata/functions/1.cpp
deleted file mode 100644
index 8bdc2e59e8..0000000000
--- a/tests/auto/tools/qmake/testdata/functions/1.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
diff --git a/tests/auto/tools/qmake/testdata/functions/2.cpp b/tests/auto/tools/qmake/testdata/functions/2.cpp
deleted file mode 100644
index 8bdc2e59e8..0000000000
--- a/tests/auto/tools/qmake/testdata/functions/2.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
diff --git a/tests/auto/tools/qmake/testdata/functions/functions.pro b/tests/auto/tools/qmake/testdata/functions/functions.pro
deleted file mode 100644
index 5db8036188..0000000000
--- a/tests/auto/tools/qmake/testdata/functions/functions.pro
+++ /dev/null
@@ -1,184 +0,0 @@
-VAR = qt thread
-
-defineTest(testReplace) {
- !isEqual(1, $$2):message("FAILED: $$3: got $$1, expected $${2}.")
-}
-
-#count
-!count( VAR, 2 ) {
- message( "FAILED: count function: $$VAR" )
-}
-
-#contains
-!contains( VAR, thread ) {
- message( "FAILED: contains function: $$VAR" )
-}
-
-#exists
-!exists( functions.pro ) {
- message( "FAILED: exists function" )
-}
-
-#isEmpty
-isEmpty( VAR ) {
- message( "FAILED: isEmpty function: $VAR" )
-}
-
-#files
-!equals($$list($$files(one/*.cpp)), "one/1.cpp one/2.cpp") {
- message( "FAILED: files function: one/*.cpp" )
-}
-!equals($$list($$files(one/1*.cpp)), "one/1.cpp") {
- message( "FAILED: files function: one/1*.cpp" )
-}
-!equals($$list($$files(two/*.cpp)), "two/1.cpp two/2.cpp") {
- message( "FAILED: files function: two/*.cpp" )
-}
-!equals($$list($$files(three/wildcard*.cpp)), "three/wildcard21.cpp three/wildcard22.cpp") {
- message( "FAILED: files function: three/wildcard*.cpp" )
-}
-!equals($$list($$files(*.cpp)), "1.cpp 2.cpp wildcard21.cpp wildcard22.cpp") {
- message( "FAILED: files function: *.cpp" )
-}
-!equals($$list($$files(wildcard*.cpp)), "wildcard21.cpp wildcard22.cpp") {
- message( "FAILED: files function: wildcard*.cpp" )
-}
-
-#infile
-!infile( infiletest.pro, DEFINES, QT_DLL ){
- message( "FAILED: infile function" )
-}
-
-#include
-include( infiletest.pro, "", true )
-!contains( DEFINES, QT_DLL ) {
- message( "FAILED: include function: $$DEFINES" )
-}
-
-#replace
-VERSION=1.0.0
-VERSION_replaced=$$replace(VERSION,\\.,_)
-!isEqual(VERSION_replaced, 1_0_0) {
- message( "FAILED: replace function: $$VERSION_replaced" )
-}
-
-#test functions
-defineTest(myTestFunction) {
- RESULT =
- list=$$1
- for(l, list) {
- RESULT += $$l
- }
- export(RESULT)
-}
-myTestFunction(oink baa moo)
-!equals($$list($$member(RESULT, 0)), "oink") {
- message("FAILED: myTestFunction: $$RESULT")
-}
-myTestFunction("oink baa" moo)
-!equals($$list($$member(RESULT, 0)), "oink baa") {
- message("FAILED: myTestFunction: $$RESULT")
-}
-myTestFunction(oink "baa moo")
-!equals($$list($$member(RESULT, 0)), "oink") {
- message("FAILED: myTestFunction: $$RESULT")
-}
-myTestFunction("oink baa moo")
-!equals($$list($$member(RESULT, 0)), "oink baa moo") {
- message("FAILED: myTestFunction: $$RESULT")
-}
-
-#recursive
-defineReplace(myRecursiveReplaceFunction) {
- RESULT =
- list = $$1
- RESULT += $$member(list, 0)
- list -= $$RESULT
- !isEmpty(list):RESULT += $$myRecursiveReplaceFunction($$list)
- return($$RESULT)
-}
-RESULT = $$myRecursiveReplaceFunction(oink baa moo)
-!isEqual(RESULT, "oink baa moo") {
- message( "FAILED: myRecursiveReplaceFunction [$$RESULT] != oink baa moo" )
-}
-
-moo = "this is a test" "for real"
-fn = $$OUT_PWD/testdir/afile
-write_file($$fn, moo)|message("FAILED: write_file() failed")
-exists($$fn)|message("FAILED: write_file() didn't write anything")
-mooout = $$cat($$fn, line)
-equals(moo, $$mooout)|message("FAILED: write_file() wrote something wrong")
-moo += "another line"
-write_file($$fn, moo)|message("FAILED: write_file() failed (take 2)")
-mooout = $$cat($$fn, line)
-equals(moo, $$mooout)|message("FAILED: write_file() wrote something wrong (take 2)")
-mooadd = "yet another line"
-write_file($$fn, mooadd, append)|message("FAILED: write_file() failed (append)")
-moo += $$mooadd
-mooout = $$cat($$fn, line)
-equals(moo, $$mooout)|message("FAILED: write_file() wrote something wrong when appending")
-
-pn = $$OUT_PWD/testpath/subdir
-mkpath($$pn)|message("FAILED: mkpath() failed")
-exists($$pn)|message("FAILED: mkpath() didn't create anything")
-
-in = easy "less easy" sca$${LITERAL_HASH}ry crazy$$escape_expand(\\t\\r\\n) $$escape_expand(\\t)shit \'no\"way\\here
-out = "easy \"less easy\" sca\$\${LITERAL_HASH}ry crazy\$\$escape_expand(\\\\t\\\\r\\\\n) \$\$escape_expand(\\\\t)shit \\\'no\\\"way\\\\here"
-testReplace($$val_escape(in), $$out, "val_escape")
-
-testReplace($$shadowed($$PWD/something), $$OUT_PWD/something, "shadowed")
-testReplace($$shadowed($$PWD), $$OUT_PWD, "shadowed (take 2)")
-
-#format_number
-spc = " "
-testReplace($$format_number(13), 13, "simple number format")
-testReplace($$format_number(-13), -13, "negative number format")
-testReplace($$format_number(13, ibase=16), 19, "hex input number format")
-testReplace($$format_number(13, obase=16), d, "hex output number format")
-testReplace($$format_number(13, width=5), " $$spc 13", "right aligned number format")
-testReplace($$format_number(13, width=5 leftalign), "13 $$spc ", "left aligned number format")
-testReplace($$format_number(13, width=5 zeropad), "00013", "zero-padded number format")
-testReplace($$format_number(13, width=5 alwayssign), "$$spc +13", "always signed number format")
-testReplace($$format_number(13, width=5 alwayssign zeropad), "+0013", "zero-padded always signed number format")
-testReplace($$format_number(13, width=5 padsign), " $$spc 13", "sign-padded number format")
-testReplace($$format_number(13, width=5 padsign zeropad), " 0013", "zero-padded sign-padded number format")
-
-testReplace($$clean_path("c:$${DIR_SEPARATOR}crazy//path/../trolls"), "c:/crazy/trolls", "clean_path")
-
-testReplace($$shell_path("/crazy/trolls"), "$${QMAKE_DIR_SEP}crazy$${QMAKE_DIR_SEP}trolls", "shell_path")
-testReplace($$system_path("/crazy/trolls"), "$${DIR_SEPARATOR}crazy$${DIR_SEPARATOR}trolls", "system_path")
-
-testReplace($$absolute_path("crazy/trolls"), "$$PWD/crazy/trolls", "absolute_path")
-testReplace($$absolute_path("crazy/trolls", "/fake/path"), "/fake/path/crazy/trolls", "absolute_path with base")
-testReplace($$absolute_path(""), "$$PWD", "absolute_path of empty")
-testReplace($$relative_path($$_PRO_FILE_PWD_), $$basename($$_PRO_FILE_), "relative_path")
-testReplace($$relative_path("/fake/trolls", "/fake/path"), "../trolls", "relative_path with base")
-testReplace($$relative_path(""), "", "relative_path of empty")
-
-#this test is very rudimentary. the backend function is thoroughly tested in qt creator
-in = "some nasty & ugly\" path & thing\\"
-out_cmd = "\"some nasty & ugly\\\" path ^& thing\\\\^\""
-out_sh = "'some nasty & ugly\" path & thing\\'"
-equals(QMAKE_HOST.os, Windows): \
- out = $$out_cmd
-else: \
- out = $$out_sh
-testReplace($$system_quote($$in), $$out, "system_quote")
-!equals(QMAKE_DIR_SEP, /): \
- out = $$out_cmd
-else: \
- out = $$out_sh
-testReplace($$shell_quote($$in), $$out, "shell_quote")
-
-testReplace($$reverse($$list(one two three)), three two one, "reverse")
-
-testReplace($$cat(textfile), hi '"holla he"' 'hu!')
-
-MOD.a.depends =
-MOD.b.depends =
-MOD.b.priority = 1
-MOD.c.depends = a b
-testReplace($$resolve_depends($$list(c), "MOD."), c b a)
-MOD.a.priority = 1
-MOD.b.priority = 0
-testReplace($$resolve_depends($$list(c), "MOD."), c a b)
diff --git a/tests/auto/tools/qmake/testdata/functions/one/1.cpp b/tests/auto/tools/qmake/testdata/functions/one/1.cpp
deleted file mode 100644
index 8bdc2e59e8..0000000000
--- a/tests/auto/tools/qmake/testdata/functions/one/1.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
diff --git a/tests/auto/tools/qmake/testdata/functions/one/2.cpp b/tests/auto/tools/qmake/testdata/functions/one/2.cpp
deleted file mode 100644
index 8bdc2e59e8..0000000000
--- a/tests/auto/tools/qmake/testdata/functions/one/2.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
diff --git a/tests/auto/tools/qmake/testdata/functions/textfile b/tests/auto/tools/qmake/testdata/functions/textfile
deleted file mode 100644
index a8248ed6f8..0000000000
--- a/tests/auto/tools/qmake/testdata/functions/textfile
+++ /dev/null
@@ -1 +0,0 @@
-hi "holla he" hu!
diff --git a/tests/auto/tools/qmake/testdata/functions/three/wildcard21.cpp b/tests/auto/tools/qmake/testdata/functions/three/wildcard21.cpp
deleted file mode 100644
index 8bdc2e59e8..0000000000
--- a/tests/auto/tools/qmake/testdata/functions/three/wildcard21.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
diff --git a/tests/auto/tools/qmake/testdata/functions/three/wildcard22.cpp b/tests/auto/tools/qmake/testdata/functions/three/wildcard22.cpp
deleted file mode 100644
index 8bdc2e59e8..0000000000
--- a/tests/auto/tools/qmake/testdata/functions/three/wildcard22.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
diff --git a/tests/auto/tools/qmake/testdata/functions/two/1.cpp b/tests/auto/tools/qmake/testdata/functions/two/1.cpp
deleted file mode 100644
index 8bdc2e59e8..0000000000
--- a/tests/auto/tools/qmake/testdata/functions/two/1.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
diff --git a/tests/auto/tools/qmake/testdata/functions/two/2.cpp b/tests/auto/tools/qmake/testdata/functions/two/2.cpp
deleted file mode 100644
index 8bdc2e59e8..0000000000
--- a/tests/auto/tools/qmake/testdata/functions/two/2.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
diff --git a/tests/auto/tools/qmake/testdata/functions/wildcard21.cpp b/tests/auto/tools/qmake/testdata/functions/wildcard21.cpp
deleted file mode 100644
index 8bdc2e59e8..0000000000
--- a/tests/auto/tools/qmake/testdata/functions/wildcard21.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
diff --git a/tests/auto/tools/qmake/testdata/functions/wildcard22.cpp b/tests/auto/tools/qmake/testdata/functions/wildcard22.cpp
deleted file mode 100644
index 8bdc2e59e8..0000000000
--- a/tests/auto/tools/qmake/testdata/functions/wildcard22.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
diff --git a/tests/auto/tools/qmake/testdata/include_function/existing_file.pri b/tests/auto/tools/qmake/testdata/include_function/existing_file.pri
deleted file mode 100644
index 8b9aaca340..0000000000
--- a/tests/auto/tools/qmake/testdata/include_function/existing_file.pri
+++ /dev/null
@@ -1,3 +0,0 @@
-QT =
-CONFIG = console
-SOURCES = main.cpp
diff --git a/tests/auto/tools/qmake/testdata/include_function/include_existing_file.pro b/tests/auto/tools/qmake/testdata/include_function/include_existing_file.pro
deleted file mode 100644
index 424062a9ac..0000000000
--- a/tests/auto/tools/qmake/testdata/include_function/include_existing_file.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-# Test to see if include(), by default, succeeds when the specific file
-# to include exists
-include(existing_file.pri)
-
-# Test to see if by specifying full set of parameters to include()
-# succeeds when the specified filed to include exists
-include(existing_file.pri, "", false)
diff --git a/tests/auto/tools/qmake/testdata/include_function/include_missing_file.pro b/tests/auto/tools/qmake/testdata/include_function/include_missing_file.pro
deleted file mode 100644
index 0b59981240..0000000000
--- a/tests/auto/tools/qmake/testdata/include_function/include_missing_file.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-# Test to see if include(), by default, fails when the specific file
-# to include does not exist
-include(missing_file.pri)
diff --git a/tests/auto/tools/qmake/testdata/include_function/include_missing_file2.pro b/tests/auto/tools/qmake/testdata/include_function/include_missing_file2.pro
deleted file mode 100644
index 542b9ff516..0000000000
--- a/tests/auto/tools/qmake/testdata/include_function/include_missing_file2.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-# Specifying full set of parameters to include() to test that a warning
-# is shown for this non-existing file.
-include(missing_file.pri, "", false)
diff --git a/tests/auto/tools/qmake/testdata/json/json.pro b/tests/auto/tools/qmake/testdata/json/json.pro
deleted file mode 100644
index 33440b3209..0000000000
--- a/tests/auto/tools/qmake/testdata/json/json.pro
+++ /dev/null
@@ -1,26 +0,0 @@
-jsontext = $$cat($$PWD/test.json)
-parseJson(jsontext, json)
-
-# print all keys
-message(json._KEYS_ $${json._KEYS_})
-
-# print array
-message(json.array._KEYS_ $${json.array._KEYS_})
-for(key, json.array._KEYS_): \
- message(json.array.$${key} $$eval(json.array.$${key}))
-
-# print object
-message(json.object._KEYS_ $${json.object._KEYS_})
-for(key, json.object._KEYS_): \
- message(json.object.$${key} $$eval(json.object.$${key}))
-
-# print value tyes
-message(json.string: $${json.string})
-message(json.number: $${json.number})
-message(json.true: $${json.true})
-message(json.false: $${json.false})
-message(json.null: $${json.null})
-
-# check that booleans work
-$${json.true}: message(json.true is true)
-!$${json.false}: message(json.false is false)
diff --git a/tests/auto/tools/qmake/testdata/json/test.json b/tests/auto/tools/qmake/testdata/json/test.json
deleted file mode 100644
index cc82908eba..0000000000
--- a/tests/auto/tools/qmake/testdata/json/test.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "array" : ["arrayItem1", "arrayItem2", "arrayItem3"],
- "object" : { "key1" : "objectValue1", "key2" : "objectValue2" },
- "string" : "test string",
- "number" : 999,
- "true" : true,
- "false" :false,
- "null" : null
-}
diff --git a/tests/auto/tools/qmake/testdata/operators/operators.pro b/tests/auto/tools/qmake/testdata/operators/operators.pro
deleted file mode 100644
index 463fa73d81..0000000000
--- a/tests/auto/tools/qmake/testdata/operators/operators.pro
+++ /dev/null
@@ -1,23 +0,0 @@
-VAR = qt thread
-
-VAR += debug
-!contains( VAR, debug ) {
- message( "FAILED: +=" )
-}
-
-VAR -= thread
-contains( VAR, thread ) {
- message( "FAILED: -=" )
-}
-
-VAR = thread
-VAR *= thread
-!count( VAR, 1 ) {
- message( "FAILED: *=" )
-}
-
-VAR = thread QT_DLL debug
-VAR ~= s/QT_+/Q_
-!contains( VAR, Q_DLL ) {
- message( "FAILED: ~=" )
-}
diff --git a/tests/auto/tools/qmake/testdata/include_function/main.cpp b/tests/auto/tools/qmake/testdata/resources/main.cpp
index 68e9c98e77..78f9814396 100644
--- a/tests/auto/tools/qmake/testdata/include_function/main.cpp
+++ b/tests/auto/tools/qmake/testdata/resources/main.cpp
@@ -31,7 +31,12 @@
**
****************************************************************************/
-int main(int /*argc*/, char ** /*argv*/)
+
+
+#include <qguiapplication.h>
+
+int main( int argc, char **argv )
{
- return 0;
+ QGuiApplication a( argc, argv );
+ return a.exec();
}
diff --git a/tests/auto/tools/qmake/testdata/resources/resources.pro b/tests/auto/tools/qmake/testdata/resources/resources.pro
new file mode 100644
index 0000000000..f024fe5617
--- /dev/null
+++ b/tests/auto/tools/qmake/testdata/resources/resources.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+SOURCES = main.cpp
+
+pro_file.files = resources.pro
+pro_file.prefix = /prefix
+
+subdir.files = subdir/file.txt
+subdir.base = subdir
+
+RESOURCES = test.qrc main.cpp pro_file subdir
diff --git a/tests/auto/tools/qmake/testdata/resources/subdir/file.txt b/tests/auto/tools/qmake/testdata/resources/subdir/file.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/tools/qmake/testdata/resources/subdir/file.txt
diff --git a/tests/auto/tools/qmake/testdata/resources/test.qrc b/tests/auto/tools/qmake/testdata/resources/test.qrc
new file mode 100644
index 0000000000..decde3dd24
--- /dev/null
+++ b/tests/auto/tools/qmake/testdata/resources/test.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>test.qrc</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/tools/qmake/testdata/variables/variables.pro b/tests/auto/tools/qmake/testdata/variables/variables.pro
deleted file mode 100644
index e4b9eaa884..0000000000
--- a/tests/auto/tools/qmake/testdata/variables/variables.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-VAR = 1 2 3 4 5
-JOINEDVAR = $$join( VAR, "-GLUE-", "-BEFORE-", "-AFTER-" )
-!contains( JOINEDVAR, -BEFORE-1-GLUE-2-GLUE-3-GLUE-4-GLUE-5-AFTER- ) {
- message( "FAILED: join [$$JOINEDVAR != -BEFORE-1-GLUE-2-GLUE-3-GLUE-4-GLUE-5-AFTER-]" )
-}
-
-# To test member we need to use join
-NEWVAR = $$member( VAR, 4 ) $$member( VAR, 3 ) $$member( VAR, 2 )
-JOINEDNEWVAR = $$join( NEWVAR, "-" )
-!contains( JOINEDNEWVAR, 5-4-3 ) {
- message( "FAILED: member [$$JOINEDNEWVAR != 5-4-3]" )
-}
diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp
index 8d7f7bbc68..ac94d1a2b9 100644
--- a/tests/auto/tools/qmake/tst_qmake.cpp
+++ b/tests/auto/tools/qmake/tst_qmake.cpp
@@ -39,6 +39,14 @@
#include <QStandardPaths>
#include <QDir>
+#if defined(DEBUG_BUILD)
+# define DIR_INFIX "debug/"
+#elif defined(RELEASE_BUILD)
+# define DIR_INFIX "release/"
+#else
+# define DIR_INFIX ""
+#endif
+
class tst_qmake : public QObject
{
Q_OBJECT
@@ -60,12 +68,6 @@ private slots:
void simple_dll();
void subdirs();
void subdir_via_pro_file_extra_target();
- void functions();
- void operators();
- void variables();
- void func_export();
- void func_variables();
- void comments();
void duplicateLibraryEntries();
void export_across_file_boundaries();
void include_dir();
@@ -80,11 +82,10 @@ private slots:
#if defined(Q_OS_MAC)
void bundle_spaces();
#endif
- void includefunction();
void substitutes();
void project();
void proFileCache();
- void json();
+ void resources();
private:
TestCompiler test_compiler;
@@ -253,43 +254,6 @@ void tst_qmake::subdir_via_pro_file_extra_target()
QVERIFY( test_compiler.make( workDir, "extratarget" ));
}
-void tst_qmake::functions()
-{
- QString workDir = base_path + "/testdata/functions";
- QString buildDir = base_path + "/testdata/functions_build";
- QVERIFY( test_compiler.qmake( workDir, "functions", buildDir ));
-}
-
-void tst_qmake::operators()
-{
- QString workDir = base_path + "/testdata/operators";
- QVERIFY( test_compiler.qmake( workDir, "operators" ));
-}
-
-void tst_qmake::variables()
-{
- QString workDir = base_path + "/testdata/variables";
- QVERIFY(test_compiler.qmake( workDir, "variables" ));
-}
-
-void tst_qmake::func_export()
-{
- QString workDir = base_path + "/testdata/func_export";
- QVERIFY(test_compiler.qmake( workDir, "func_export" ));
-}
-
-void tst_qmake::func_variables()
-{
- QString workDir = base_path + "/testdata/func_variables";
- QVERIFY(test_compiler.qmake( workDir, "func_variables" ));
-}
-
-void tst_qmake::comments()
-{
- QString workDir = base_path + "/testdata/comments";
- QVERIFY(test_compiler.qmake( workDir, "comments" ));
-}
-
void tst_qmake::duplicateLibraryEntries()
{
QVERIFY(true);
@@ -490,26 +454,6 @@ void tst_qmake::bundle_spaces()
}
#endif // defined(Q_OS_MAC)
-void tst_qmake::includefunction()
-{
- QString workDir = base_path + "/testdata/include_function";
- QRegExp warningMsg("Cannot read .*: No such file or directory");
- QVERIFY(test_compiler.qmake( workDir, "include_existing_file"));
- QVERIFY(!test_compiler.commandOutput().contains(warningMsg));
-
- // test include() usage on a missing file
- test_compiler.clearCommandOutput();
- workDir = base_path + "/testdata/include_function";
- QVERIFY(test_compiler.qmake( workDir, "include_missing_file" ));
- QVERIFY(test_compiler.commandOutput().contains(warningMsg));
-
- // test include() usage on a missing file when all function parameters are used
- test_compiler.clearCommandOutput();
- workDir = base_path + "/testdata/include_function";
- QVERIFY(test_compiler.qmake( workDir, "include_missing_file2" ));
- QVERIFY(test_compiler.commandOutput().contains(warningMsg));
-}
-
void tst_qmake::substitutes()
{
QString workDir = base_path + "/testdata/substitutes";
@@ -555,32 +499,37 @@ void tst_qmake::proFileCache()
QVERIFY( test_compiler.qmake( workDir, "pro_file_cache" ));
}
-void tst_qmake::json()
+void tst_qmake::resources()
{
- QString workDir = base_path + "/testdata/json";
- QVERIFY( test_compiler.qmake( workDir, "json.pro" ));
- QString output = test_compiler.commandOutput();
-
- // all keys
- QVERIFY(output.contains("json._KEYS_ array false null number object string true"));
- // array
- QVERIFY(output.contains("json.array._KEYS_ 0 1 2"));
- QVERIFY(output.contains("json.array.0 arrayItem1"));
- QVERIFY(output.contains("json.array.1 arrayItem2"));
- QVERIFY(output.contains("json.array.2 arrayItem3"));
- // object
- QVERIFY(output.contains("json.object._KEYS_ key1 key2"));
- QVERIFY(output.contains("json.object.key1 objectValue1"));
- QVERIFY(output.contains("json.object.key1 objectValue1"));
- // value types
- QVERIFY(output.contains("json.string: test string"));
- QVERIFY(output.contains("json.number: 999"));
- QVERIFY(output.contains("json.true: true"));
- QVERIFY(output.contains("json.false: false"));
- QVERIFY(output.contains("json.null:"));
- // functional booleans
- QVERIFY(output.contains("json.true is true"));
- QVERIFY(output.contains("json.false is false"));
+ QString workDir = base_path + "/testdata/resources";
+ QVERIFY(test_compiler.qmake(workDir, "resources"));
+
+ {
+ QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_pro_file.qrc");
+ QVERIFY(qrcFile.exists());
+ QVERIFY(qrcFile.open(QFile::ReadOnly));
+ QByteArray qrcXml = qrcFile.readAll();
+ QVERIFY(qrcXml.contains("alias=\"resources.pro\""));
+ QVERIFY(qrcXml.contains("prefix=\"/prefix\""));
+ }
+
+ {
+ QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_subdir.qrc");
+ QVERIFY(qrcFile.exists());
+ QVERIFY(qrcFile.open(QFile::ReadOnly));
+ QByteArray qrcXml = qrcFile.readAll();
+ QVERIFY(qrcXml.contains("alias=\"file.txt\""));
+ }
+
+ {
+ QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_qmake_immediate.qrc");
+ QVERIFY(qrcFile.exists());
+ QVERIFY(qrcFile.open(QFile::ReadOnly));
+ QByteArray qrcXml = qrcFile.readAll();
+ QVERIFY(qrcXml.contains("alias=\"main.cpp\""));
+ }
+
+ QVERIFY(test_compiler.make(workDir));
}
QTEST_MAIN(tst_qmake)
diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp
new file mode 100644
index 0000000000..fab2cdce17
--- /dev/null
+++ b/tests/auto/tools/qmakelib/evaltest.cpp
@@ -0,0 +1,2513 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "tst_qmakelib.h"
+
+#include <proitems.h>
+#include <qmakevfs.h>
+#include <qmakeparser.h>
+#include <qmakeglobals.h>
+#include <qmakeevaluator.h>
+
+void tst_qmakelib::addAssignments()
+{
+ QTest::newRow("assignment")
+ << "VAR = foo bar baz"
+ << "VAR = foo bar baz"
+ << ""
+ << true;
+
+ QTest::newRow("appending")
+ << "VAR = foo bar baz\nVAR += foo gaz gaz"
+ << "VAR = foo bar baz foo gaz gaz"
+ << ""
+ << true;
+
+ QTest::newRow("unique appending")
+ << "VAR = foo bar baz\nVAR *= foo gaz gaz"
+ << "VAR = foo bar baz gaz"
+ << ""
+ << true;
+
+ QTest::newRow("removing")
+ << "VAR = foo bar foo baz\nVAR -= foo gaz gaz"
+ << "VAR = bar baz"
+ << ""
+ << true;
+
+ // Somewhat unexpectedly, the g modifier is implicit within each element.
+ QTest::newRow("replacing")
+ << "VAR = foo bar foo baz\nVAR ~= s,o,0,"
+ << "VAR = f00 bar foo baz"
+ << ""
+ << true;
+
+ // Consistently with the "there are no empty elements", what becomes empty gets zapped.
+ QTest::newRow("replacing with nothing")
+ << "VAR = foo bar foo baz\nVAR ~= s,foo,,"
+ << "VAR = bar foo baz"
+ << ""
+ << true;
+
+ QTest::newRow("replacing case-insensitively")
+ << "VAR = foO bar foo baz\nVAR ~= s,o,0,i"
+ << "VAR = f00 bar foo baz"
+ << ""
+ << true;
+
+ // In all elements, not all within each/one/??? element.
+ QTest::newRow("replacing globally")
+ << "VAR = foo bar foo baz\nVAR ~= s,o,0,g"
+ << "VAR = f00 bar f00 baz"
+ << ""
+ << true;
+
+ // Replacing with the same string counts as no match.
+ // This is rather questionable ...
+ QTest::newRow("replacing with same")
+ << "VAR = foo bar foo baz\nVAR ~= s,ba[rz],bar,"
+ << "VAR = foo bar foo bar"
+ << ""
+ << true;
+
+ QTest::newRow("replacing with auto-quote")
+ << "VAR = foo [bar] foo baz\nVAR ~= s,[bar],bar,q"
+ << "VAR = foo bar foo baz"
+ << ""
+ << true;
+
+ QTest::newRow("replacing with expansions")
+ << "VAR = foo bar foo baz\nPAT = foo\nREPL = 'yee haw'\nVAR ~= s,$$PAT,$$REPL,"
+ << "VAR = 'yee haw' bar foo baz"
+ << ""
+ << true;
+
+ QTest::newRow("~= with bad function")
+ << "VAR ~= m/foo/"
+ << ""
+ << "##:1: The ~= operator can handle only the s/// function."
+ << true; // rather questionable
+
+ QTest::newRow("~= s with bad number of arguments")
+ << "VAR ~= s/bla\nVAR ~= s/bla/foo//"
+ << ""
+ << "##:1: The s/// function expects 3 or 4 arguments.\n"
+ "##:2: The s/// function expects 3 or 4 arguments."
+ << true; // rather questionable
+}
+
+void tst_qmakelib::addExpansions()
+{
+ QTest::newRow("expand variable")
+ << "V1 = foo\nVAR = $$V1"
+ << "VAR = foo"
+ << ""
+ << true;
+
+ QTest::newRow("expand property")
+ << "VAR = $$[P1]"
+ << "VAR = 'prop val'"
+ << ""
+ << true;
+
+ QTest::newRow("expand environment variable")
+ << "VAR = $$(E1)"
+ << "VAR = 'env var'"
+ << ""
+ << true;
+
+ // These test addStr/addStr.
+
+ QTest::newRow("expand: str $$(env)")
+ << "VAR = foo $$(E1)"
+ << "VAR = foo 'env var'"
+ << ""
+ << true;
+
+ QTest::newRow("expand: str$$(env)")
+ << "VAR = foo$$(E1)"
+ << "VAR = 'fooenv var'"
+ << ""
+ << true;
+
+ QTest::newRow("expand: 'str $$(env)'")
+ << "VAR = 'foo $$(E1)'"
+ << "VAR = 'foo env var'"
+ << ""
+ << true;
+
+ // These test addStr/addStrList
+
+ QTest::newRow("expand: str $$var")
+ << "V1 = foo barbaz\nVAR = str $$V1"
+ << "VAR = str foo barbaz"
+ << ""
+ << true;
+
+ QTest::newRow("expand: $$var str")
+ << "V1 = foo barbaz\nVAR = $$V1 str"
+ << "VAR = foo barbaz str"
+ << ""
+ << true;
+
+ QTest::newRow("expand: str$$var")
+ << "V1 = foo barbaz\nVAR = str$$V1"
+ << "VAR = strfoo barbaz"
+ << ""
+ << true;
+
+ QTest::newRow("expand: $${var}str")
+ << "V1 = foo barbaz\nVAR = $${V1}str"
+ << "VAR = foo barbazstr"
+ << ""
+ << true;
+
+ QTest::newRow("expand: 'str $$var'")
+ << "V1 = foo barbaz\nVAR = 'str $$V1'"
+ << "VAR = 'str foo barbaz'"
+ << ""
+ << true;
+
+ QTest::newRow("expand: '$$var str'")
+ << "V1 = foo barbaz\nVAR = '$$V1 str'"
+ << "VAR = 'foo barbaz str'"
+ << ""
+ << true;
+
+ // Same again in joined context
+
+ QTest::newRow("expand joined: str $$(env)")
+ << "VAR = $$quote(foo $$(E1))"
+ << "VAR = 'foo env var'"
+ << ""
+ << true;
+
+ QTest::newRow("expand joined: str$$(env)")
+ << "VAR = $$quote(foo$$(E1))"
+ << "VAR = 'fooenv var'"
+ << ""
+ << true;
+
+ QTest::newRow("expand joined: 'str $$(env)'")
+ << "VAR = $$quote('foo $$(E1)')"
+ << "VAR = 'foo env var'"
+ << ""
+ << true;
+
+ QTest::newRow("expand joined: str $$var")
+ << "V1 = foo barbaz\nVAR = $$quote(str $$V1)"
+ << "VAR = 'str foo barbaz'"
+ << ""
+ << true;
+
+ QTest::newRow("expand joined: $$var str")
+ << "V1 = foo barbaz\nVAR = $$quote($$V1 str)"
+ << "VAR = 'foo barbaz str'"
+ << ""
+ << true;
+
+ QTest::newRow("expand joined: str$$var")
+ << "V1 = foo barbaz\nVAR = $$quote(str$$V1)"
+ << "VAR = 'strfoo barbaz'"
+ << ""
+ << true;
+
+ QTest::newRow("expand joined: $${var}str")
+ << "V1 = foo barbaz\nVAR = $$quote($${V1}str)"
+ << "VAR = 'foo barbazstr'"
+ << ""
+ << true;
+
+ QTest::newRow("expand joined: 'str $$var'")
+ << "V1 = foo barbaz\nVAR = $$quote('str $$V1')"
+ << "VAR = 'str foo barbaz'"
+ << ""
+ << true;
+
+ QTest::newRow("expand joined: '$$var str'")
+ << "V1 = foo barbaz\nVAR = $$quote('$$V1 str')"
+ << "VAR = 'foo barbaz str'"
+ << ""
+ << true;
+
+ // Variable expansions on LHS
+
+ QTest::newRow("indirect assign: $$var")
+ << "V = VAR\n$$V = foo"
+ << "VAR = foo"
+ << ""
+ << true;
+
+ QTest::newRow("indirect assign: fix$$var")
+ << "V = AR\nV$$V = foo"
+ << "VAR = foo"
+ << ""
+ << true;
+
+ QTest::newRow("indirect assign: $${var}fix")
+ << "V = VA\n$${V}R = foo"
+ << "VAR = foo"
+ << ""
+ << true;
+
+ QTest::newRow("indirect assign: eval")
+ << "V = VAR\n$$eval(V) = foo"
+ << "VAR = foo"
+ << ""
+ << true;
+
+ QTest::newRow("indirect assign: multiple")
+ << "V = FOO BAR\n$$V = foo"
+ << ""
+ << "##:2: Left hand side of assignment must expand to exactly one word."
+ << true;
+}
+
+void tst_qmakelib::addControlStructs()
+{
+ QTest::newRow("true")
+ << "true: VAR = 1"
+ << "VAR = 1"
+ << ""
+ << true;
+
+ QTest::newRow("false")
+ << "false: VAR = 1"
+ << "VAR = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("true-config")
+ << "CONFIG += test\ntest: VAR = 1"
+ << "VAR = 1"
+ << ""
+ << true;
+
+ QTest::newRow("false-config")
+ << "test: VAR = 1"
+ << "VAR = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("true-wildcard")
+ << "CONFIG += testing\ntest*: VAR = 1"
+ << "VAR = 1"
+ << ""
+ << true;
+
+ QTest::newRow("false-wildcard")
+ << "test*: VAR = 1"
+ << "VAR = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("true-else")
+ << "true: VAR1 = 1\nelse: VAR2 = 1"
+ << "VAR1 = 1\nVAR2 = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("false-else")
+ << "false: VAR1 = 1\nelse: VAR2 = 1"
+ << "VAR1 = UNDEF\nVAR2 = 1"
+ << ""
+ << true;
+
+ QTest::newRow("true-else-true-else")
+ << "true: VAR1 = 1\nelse: true: VAR2 = 1\nelse: VAR3 = 1"
+ << "VAR1 = 1\nVAR2 = UNDEF\nVAR3 = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("true-else-false-else")
+ << "true: VAR1 = 1\nelse: false: VAR2 = 1\nelse: VAR3 = 1"
+ << "VAR1 = 1\nVAR2 = UNDEF\nVAR3 = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("false-else-true-else")
+ << "false: VAR1 = 1\nelse: true: VAR2 = 1\nelse: VAR3 = 1"
+ << "VAR1 = UNDEF\nVAR2 = 1\nVAR3 = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("false-else-false-else")
+ << "false: VAR1 = 1\nelse: false: VAR2 = 1\nelse: VAR3 = 1"
+ << "VAR1 = UNDEF\nVAR2 = UNDEF\nVAR3 = 1"
+ << ""
+ << true;
+
+ QTest::newRow("true-{false-else}-else")
+ << "true {\nfalse: VAR1 = 1\nelse: VAR2 = 1\n}\nelse: VAR3 = 1"
+ << "VAR1 = UNDEF\nVAR2 = 1\nVAR3 = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("NOT-true")
+ << "!true: VAR = 1"
+ << "VAR = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("NOT-false")
+ << "!false: VAR = 1"
+ << "VAR = 1"
+ << ""
+ << true;
+
+ QTest::newRow("true-AND-true")
+ << "true:true: VAR = 1"
+ << "VAR = 1"
+ << ""
+ << true;
+
+ QTest::newRow("true-AND-false")
+ << "true:false: VAR = 1"
+ << "VAR = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("false-AND-true")
+ << "false:true: VAR = 1"
+ << "VAR = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("false-OR-false")
+ << "false|false: VAR = 1"
+ << "VAR = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("true-OR-false")
+ << "true|false: VAR = 1"
+ << "VAR = 1"
+ << ""
+ << true;
+
+ QTest::newRow("false-OR-true")
+ << "false|true: VAR = 1"
+ << "VAR = 1"
+ << ""
+ << true;
+
+ QTest::newRow("NOT-false-AND-true")
+ << "!false:true: VAR = 1"
+ << "VAR = 1"
+ << ""
+ << true;
+
+ QTest::newRow("true-AND-message")
+ << "true:message(hi): VAR = 1"
+ << "VAR = 1"
+ << "Project MESSAGE: hi"
+ << true;
+
+ QTest::newRow("false-AND-message")
+ << "false:message(hi): VAR = 1"
+ << "VAR = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("true-OR-message")
+ << "true|message(hi): VAR = 1"
+ << "VAR = 1"
+ << ""
+ << true;
+
+ QTest::newRow("false-OR-message")
+ << "false|message(hi): VAR = 1"
+ << "VAR = 1"
+ << "Project MESSAGE: hi"
+ << true;
+
+ QTest::newRow("true-OR-message-AND-false")
+ << "true|message(hi):false: VAR = 1"
+ << "VAR = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("false-OR-message-AND-false")
+ << "false|message(hi):false: VAR = 1"
+ << "VAR = UNDEF"
+ << "Project MESSAGE: hi"
+ << true;
+
+ QTest::newRow("true (indirect)")
+ << "TEST = true\n$$TEST: VAR = 1"
+ << "VAR = 1"
+ << ""
+ << true;
+
+ QTest::newRow("false (indirect)")
+ << "TEST = false\n$$TEST: VAR = 1"
+ << "VAR = UNDEF"
+ << ""
+ << true;
+
+ // Yes, this is not supposed to work
+ QTest::newRow("true|false (indirect)")
+ << "TEST = true|false\n$$TEST: VAR = 1"
+ << "VAR = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("for (var, var)")
+ << "IN = one two three\nfor (IT, IN) { OUT += $$IT }"
+ << "OUT = one two three"
+ << ""
+ << true;
+
+ QTest::newRow("for (var, range)")
+ << "for (IT, 1..3) { OUT += $$IT }"
+ << "OUT = 1 2 3"
+ << ""
+ << true;
+
+ QTest::newRow("for (var, reverse-range)")
+ << "for (IT, 3..1) { OUT += $$IT }"
+ << "OUT = 3 2 1"
+ << ""
+ << true;
+
+ // This syntax is rather ridiculous.
+ QTest::newRow("for (ever)")
+ << "for (ever) {}"
+ << ""
+ << "##:1: Ran into infinite loop (> 1000 iterations)."
+ << true;
+
+ // This is even worse.
+ QTest::newRow("for (VAR, forever)")
+ << "for (VAR, forever) { OUT = $$VAR }"
+ << "OUT = 999"
+ << "##:1: Ran into infinite loop (> 1000 iterations)."
+ << true;
+
+ QTest::newRow("for (garbage)")
+ << "for (garbage) { OUT = FAIL }"
+ << "OUT = UNDEF"
+ << "##:1: Invalid loop expression."
+ << true;
+
+ QTest::newRow("next()")
+ << "IN = one two three\nfor (IT, IN) {\nequals(IT, two):next()\nOUT += $$IT\n}"
+ << "OUT = one three"
+ << ""
+ << true;
+
+ QTest::newRow("nested next()")
+ << "IN = one two three\nfor (IT, IN) {\nfor (NIT, IN):next()\nOUT += $$IT\n}"
+ << "OUT = one two three"
+ << ""
+ << true;
+
+ QTest::newRow("break()")
+ << "IN = one two three\nfor (IT, IN) {\nequals(IT, three):break()\nOUT += $$IT\n}"
+ << "OUT = one two"
+ << ""
+ << true;
+
+ QTest::newRow("nested break()")
+ << "IN = one two three\nfor (IT, IN) {\nfor (NIT, IN):break()\nOUT += $$IT\n}"
+ << "OUT = one two three"
+ << ""
+ << true;
+
+ QTest::newRow("defineReplace()")
+ << "defineReplace(func) { return($$1 + $$2) }\n"
+ "VAR = $$func(test me, \"foo bar\")"
+ << "VAR = test me + 'foo bar'"
+ << ""
+ << true;
+
+ QTest::newRow("defineTest()")
+ << "defineTest(func) { return($$1) }\n"
+ "func(true): VAR += true\n"
+ "func(false): VAR += false"
+ << "VAR = true"
+ << ""
+ << true;
+
+ QTest::newRow("true-AND-defineTest()")
+ << "true: defineTest(func)\n"
+ "defined(func): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("false-AND-defineTest()")
+ << "false: defineTest(func)\n"
+ "defined(func): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("true-OR-defineTest()")
+ << "true| defineTest(func)\n"
+ "defined(func): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("false-OR-defineTest()")
+ << "false| defineTest(func)\n"
+ "defined(func): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("variable scoping")
+ << "defineTest(func) {\n"
+ "VAR1 = modified\n!equals(VAR1, modified): return(false)\n"
+ "VAR2 += modified\n!equals(VAR2, original modified): return(false)\n"
+ "VAR3 = new var\n!equals(VAR3, new var): return(false)\n"
+ "return(true)\n"
+ "}\n"
+ "VAR1 = pristine\nVAR2 = original\nfunc(): OK = 1"
+ << "OK = 1\nVAR1 = pristine\nVAR2 = original\nVAR3 = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("ARGC and ARGS")
+ << "defineTest(func) {\n"
+ "export(ARGC)\n"
+ "export(ARGS)\n"
+ "}\n"
+ "func(test me, \"foo bar\")"
+ << "ARGC = 2\nARGS = test me 'foo bar'"
+ << ""
+ << true;
+
+ QTest::newRow("recursion")
+ << "defineReplace(func) {\n"
+ "RET = *$$member(1, 0)*\n"
+ "REST = $$member(1, 1, -1)\n"
+ "!isEmpty(REST): RET += $$func($$REST)\n"
+ "return($$RET)\n"
+ "}\n"
+ "VAR = $$func(you are ...)"
+ << "VAR = *you* *are* *...*"
+ << ""
+ << true;
+
+ QTest::newRow("top-level return()")
+ << "VAR = good\nreturn()\nVAR = bad"
+ << "VAR = good"
+ << ""
+ << true;
+
+ QTest::newRow("return() from function")
+ << "defineTest(func) {\nVAR = good\nexport(VAR)\nreturn()\nVAR = bad\nexport(VAR)\n}\n"
+ "func()"
+ << "VAR = good"
+ << ""
+ << true;
+
+ QTest::newRow("return() from nested function")
+ << "defineTest(inner) {\nVAR = initial\nexport(VAR)\nreturn()\nVAR = bad\nexport(VAR)\n}\n"
+ "defineTest(outer) {\ninner()\nVAR = final\nexport(VAR)\n}\n"
+ "outer()"
+ << "VAR = final"
+ << ""
+ << true;
+}
+
+void tst_qmakelib::addReplaceFunctions(const QString &qindir)
+{
+ QTest::newRow("$$member(): empty")
+ << "IN = \nVAR = $$member(IN)"
+ << "VAR ="
+ << ""
+ << true;
+
+ QTest::newRow("$$member(): too short")
+ << "IN = one two three\nVAR = $$member(IN, 1, 5)"
+ << "VAR =" // this is actually kinda stupid
+ << ""
+ << true;
+
+ QTest::newRow("$$member(): ok")
+ << "IN = one two three four five six seven\nVAR = $$member(IN, 1, 4)"
+ << "VAR = two three four five"
+ << ""
+ << true;
+
+ QTest::newRow("$$member(): ok (default start)")
+ << "IN = one two three\nVAR = $$member(IN)"
+ << "VAR = one"
+ << ""
+ << true;
+
+ QTest::newRow("$$member(): ok (default end)")
+ << "IN = one two three\nVAR = $$member(IN, 2)"
+ << "VAR = three"
+ << ""
+ << true;
+
+ QTest::newRow("$$member(): negative")
+ << "IN = one two three four five six seven\nVAR = $$member(IN, -4, -3)"
+ << "VAR = four five"
+ << ""
+ << true;
+
+ QTest::newRow("$$member(): inverse")
+ << "IN = one two three four five six seven\nVAR = $$member(IN, 4, 1)"
+ << "VAR = five four three two"
+ << ""
+ << true;
+
+ QTest::newRow("$$member(): dots")
+ << "IN = one two three four five six seven\nVAR = $$member(IN, 1..4)"
+ << "VAR = two three four five"
+ << ""
+ << true;
+
+ QTest::newRow("$$member(): bad number of arguments")
+ << "VAR = $$member(1, 2, 3, 4)"
+ << "VAR ="
+ << "##:1: member(var, start, end) requires one to three arguments."
+ << true;
+
+ QTest::newRow("$$member(): bad args (1)")
+ << "IN = one two three\nVAR = $$member(IN, foo, 4)"
+ << "VAR ="
+ << "##:2: member() argument 2 (start) 'foo' invalid."
+ << true;
+
+ QTest::newRow("$$member(): bad args (2)")
+ << "IN = one two three\nVAR = $$member(IN, foo..4)"
+ << "VAR ="
+ << "##:2: member() argument 2 (start) 'foo..4' invalid."
+ << true;
+
+ QTest::newRow("$$member(): bad args (3)")
+ << "IN = one two three\nVAR = $$member(IN, 4, foo)"
+ << "VAR ="
+ << "##:2: member() argument 3 (end) 'foo' invalid."
+ << true;
+
+ QTest::newRow("$$member(): bad args (4)")
+ << "IN = one two three\nVAR = $$member(IN, 4..foo)"
+ << "VAR ="
+ << "##:2: member() argument 2 (start) '4..foo' invalid."
+ << true;
+
+ QTest::newRow("$$first(): empty")
+ << "IN = \nVAR = $$first(IN)"
+ << "VAR ="
+ << ""
+ << true;
+
+ QTest::newRow("$$first(): one")
+ << "IN = one\nVAR = $$first(IN)"
+ << "VAR = one"
+ << ""
+ << true;
+
+ QTest::newRow("$$first(): multiple")
+ << "IN = one two three\nVAR = $$first(IN)"
+ << "VAR = one"
+ << ""
+ << true;
+
+ QTest::newRow("$$first(): bad number of arguments")
+ << "VAR = $$first(1, 2)"
+ << "VAR ="
+ << "##:1: first(var) requires one argument."
+ << true;
+
+ QTest::newRow("$$last(): empty")
+ << "IN = \nVAR = $$last(IN)"
+ << "VAR ="
+ << ""
+ << true;
+
+ QTest::newRow("$$last(): one")
+ << "IN = one\nVAR = $$last(IN)"
+ << "VAR = one"
+ << ""
+ << true;
+
+ QTest::newRow("$$last(): multiple")
+ << "IN = one two three\nVAR = $$last(IN)"
+ << "VAR = three"
+ << ""
+ << true;
+
+ QTest::newRow("$$last(): bad number of arguments")
+ << "VAR = $$last(1, 2)"
+ << "VAR ="
+ << "##:1: last(var) requires one argument."
+ << true;
+
+ QTest::newRow("$$size()")
+ << "IN = one two three\nVAR = $$size(IN)"
+ << "VAR = 3"
+ << ""
+ << true;
+
+ QTest::newRow("$$size(): bad number of arguments")
+ << "VAR = $$size(1, 2)"
+ << "VAR ="
+ << "##:1: size(var) requires one argument."
+ << true;
+
+ QTest::newRow("$$fromfile(): right var")
+ << "VAR = $$fromfile(" + qindir + "/fromfile/infile.prx, DEFINES)"
+ << "VAR = QT_DLL"
+ << ""
+ << true;
+
+ QTest::newRow("$$fromfile(): wrong var")
+ << "VAR = $$fromfile(" + qindir + "/fromfile/infile.prx, INCLUDES)"
+ << "VAR ="
+ << ""
+ << true;
+
+ QTest::newRow("$$fromfile(): bad file")
+ << "VAR = $$fromfile(" + qindir + "/fromfile/badfile.prx, DEFINES)"
+ << "VAR ="
+ << "Project ERROR: fail!"
+ << true;
+
+ QTest::newRow("$$fromfile(): bad number of arguments")
+ << "VAR = $$fromfile(1) \\\n$$fromfile(1, 2, 3)"
+ << "VAR ="
+ << "##:1: fromfile(file, variable) requires two arguments.\n"
+ "##:2: fromfile(file, variable) requires two arguments."
+ << true;
+
+ QTest::newRow("$$eval()")
+ << "IN = one two three\nVAR = $$eval(IN)"
+ << "VAR = one two three"
+ << ""
+ << true;
+
+ QTest::newRow("$$eval(): bad number of arguments")
+ << "VAR = $$eval(1, 2)"
+ << "VAR ="
+ << "##:1: eval(variable) requires one argument."
+ << true;
+
+ QTest::newRow("$$list()")
+ << "VARNAME = $$list(one, two three, 'four five')\nVAR = $$eval($$VARNAME)"
+ << "VAR = one two three four five" // total nonsense ...
+ << ""
+ << true;
+
+ QTest::newRow("$$sprintf()")
+ << "VAR = $$sprintf(hello %1 %2, you, there)"
+ << "VAR = 'hello you there'"
+ << ""
+ << true;
+
+ QTest::newRow("$$format_number(): simple number format")
+ << "VAR = $$format_number(13)"
+ << "VAR = 13"
+ << ""
+ << true;
+
+ QTest::newRow("$$format_number(): negative number format")
+ << "VAR = $$format_number(-13)"
+ << "VAR = -13"
+ << ""
+ << true;
+
+ QTest::newRow("$$format_number(): hex input number format")
+ << "VAR = $$format_number(13, ibase=16)"
+ << "VAR = 19"
+ << ""
+ << true;
+
+ QTest::newRow("$$format_number(): hex output number format")
+ << "VAR = $$format_number(13, obase=16)"
+ << "VAR = d"
+ << ""
+ << true;
+
+ QTest::newRow("$$format_number(): right aligned number format")
+ << "VAR = $$format_number(13, width=5)"
+ << "VAR = ' 13'"
+ << ""
+ << true;
+
+ QTest::newRow("$$format_number(): left aligned number format")
+ << "VAR = $$format_number(13, width=5 leftalign)"
+ << "VAR = '13 '"
+ << ""
+ << true;
+
+ QTest::newRow("$$format_number(): zero-padded number format")
+ << "VAR = $$format_number(13, width=5 zeropad)"
+ << "VAR = 00013"
+ << ""
+ << true;
+
+ QTest::newRow("$$format_number(): always signed number format")
+ << "VAR = $$format_number(13, width=5 alwayssign)"
+ << "VAR = ' +13'"
+ << ""
+ << true;
+
+ QTest::newRow("$$format_number(): zero-padded always signed number format")
+ << "VAR = $$format_number(13, width=5 alwayssign zeropad)"
+ << "VAR = +0013"
+ << ""
+ << true;
+
+ QTest::newRow("$$format_number(): sign-padded number format")
+ << "VAR = $$format_number(13, width=5 padsign)"
+ << "VAR = ' 13'"
+ << ""
+ << true;
+
+ QTest::newRow("$$format_number(): zero-padded sign-padded number format")
+
+ << "VAR = $$format_number(13, width=5 padsign zeropad)"
+ << "VAR = ' 0013'"
+ << ""
+ << true;
+
+ QTest::newRow("$$format_number(): bad number of arguments")
+ << "VAR = $$format_number(13, 1, 2)"
+ << "VAR ="
+ << "##:1: format_number(number[, options...]) requires one or two arguments."
+ << true;
+
+ QTest::newRow("$$format_number(): invalid option")
+ << "VAR = $$format_number(13, foo=bar)"
+ << "VAR ="
+ << "##:1: format_number(): invalid format option foo=bar."
+ << true;
+
+ QTest::newRow("$$join(): empty")
+ << "IN = \nVAR = $$join(IN, //)"
+ << "VAR ="
+ << ""
+ << true;
+
+ QTest::newRow("$$join(): multiple")
+ << "IN = one two three\nVAR = $$join(IN, //)"
+ << "VAR = one//two//three"
+ << ""
+ << true;
+
+ QTest::newRow("$$join(): multiple surrounded")
+ << "IN = one two three\nVAR = $$join(IN, //, <<, >>)"
+ << "VAR = <<one//two//three>>"
+ << ""
+ << true;
+
+ QTest::newRow("$$join(): bad number of arguments")
+ << "VAR = $$join(1, 2, 3, 4, 5)"
+ << "VAR ="
+ << "##:1: join(var, glue, before, after) requires one to four arguments."
+ << true;
+
+ QTest::newRow("$$split(): default sep")
+ << "IN = 'one/two three' 'four / five'\nVAR = $$split(IN)"
+ << "VAR = one/two three four / five"
+ << ""
+ << true;
+
+ QTest::newRow("$$split(): specified sep")
+ << "IN = 'one/two three' 'four / five'\nVAR = $$split(IN, /)"
+ << "VAR = one 'two three' 'four ' ' five'"
+ << ""
+ << true;
+
+ QTest::newRow("$$split(): bad number of arguments")
+ << "VAR = $$split(1, 2, 3)"
+ << "VAR ="
+ << "##:1: split(var, sep) requires one or two arguments."
+ << true;
+
+ QTest::newRow("$$basename(): empty")
+ << "IN = \nVAR = $$basename(IN)"
+ << "VAR ="
+ << ""
+ << true;
+
+ QTest::newRow("$$basename(): bare")
+ << "IN = file\nVAR = $$basename(IN)"
+ << "VAR = file"
+ << ""
+ << true;
+
+ QTest::newRow("$$basename(): relative")
+ << "IN = path/file\nVAR = $$basename(IN)"
+ << "VAR = file"
+ << ""
+ << true;
+
+ QTest::newRow("$$basename(): absolute")
+ << "IN = \\\\path\\\\file\nVAR = $$basename(IN)"
+ << "VAR = file"
+ << ""
+ << true;
+
+ QTest::newRow("$$basename(): bad number of arguments")
+ << "VAR = $$basename(1, 2)"
+ << "VAR ="
+ << "##:1: basename(var) requires one argument."
+ << true;
+
+ QTest::newRow("$$dirname(): empty")
+ << "IN = \nVAR = $$dirname(IN)"
+ << "VAR ="
+ << ""
+ << true;
+
+ QTest::newRow("$$dirname(): bare")
+ << "IN = file\nVAR = $$dirname(IN)"
+ << "VAR ="
+ << ""
+ << true;
+
+ QTest::newRow("$$dirname(): relative")
+ << "IN = path/file\nVAR = $$dirname(IN)"
+ << "VAR = path"
+ << ""
+ << true;
+
+ QTest::newRow("$$dirname(): absolute")
+ << "IN = \\\\path\\\\file\nVAR = $$dirname(IN)"
+ << "VAR = \\\\path"
+ << ""
+ << true;
+
+ QTest::newRow("$$dirname(): bad number of arguments")
+ << "VAR = $$dirname(1, 2)"
+ << "VAR ="
+ << "##:1: dirname(var) requires one argument."
+ << true;
+
+ QTest::newRow("$$section(): explicit end")
+ << "IN = one~two~three~four~five~six\nVAR = $$section(IN, ~, 2, 4)"
+ << "VAR = three~four~five"
+ << ""
+ << true;
+
+ QTest::newRow("$$section(): implicit end")
+ << "IN = one~two~three~four~five~six\nVAR = $$section(IN, ~, 3)"
+ << "VAR = four~five~six"
+ << ""
+ << true;
+
+ QTest::newRow("$$section(): bad number of arguments")
+ << "VAR = $$section(1, 2) \\\n$$section(1, 2, 3, 4, 5)"
+ << "VAR ="
+ << "##:1: section(var) section(var, sep, begin, end) requires three or four arguments.\n"
+ "##:2: section(var) section(var, sep, begin, end) requires three or four arguments."
+ << true;
+
+ QTest::newRow("$$find()")
+ << "IN = foo bar baz blubb\nVAR = $$find(IN, ^ba)"
+ << "VAR = bar baz"
+ << ""
+ << true;
+
+ QTest::newRow("$$find(): bad number of arguments")
+ << "VAR = $$find(1) \\\n$$find(1, 2, 3)"
+ << "VAR ="
+ << "##:1: find(var, str) requires two arguments.\n"
+ "##:2: find(var, str) requires two arguments."
+ << true;
+
+ // FIXME: $$cat() & $$system(): There is no way to generate the newlines
+ // necessary for testing "multi-line" and "blob" mode adequately.
+ // Note: these functions have *different* splitting behavior.
+
+ // This gives split_value_list() an exercise
+ QTest::newRow("$$cat(): default mode")
+ << "VAR = $$cat(" + qindir + "/cat/file2.txt)"
+ << "VAR = foo bar baz \"\\\"Hello, \\' world.\\\"\" post \"\\'Hello, \\\" world.\\'\" post \\\\\\\" \\\\\\' \\\\\\\\ \\\\a \\\\ nix \"\\\" \\\"\""
+ << ""
+ << true;
+
+ QTest::newRow("$$cat(): lines mode")
+ << "VAR = $$cat(" + qindir + "/cat/file1.txt, lines)"
+ << "VAR = '\"Hello, world.\"' 'foo bar baz'"
+ << ""
+ << true;
+
+ QTest::newRow("$$cat(): bad number of arguments")
+ << "VAR = $$cat(1, 2, 3)"
+ << "VAR ="
+ << "##:1: cat(file, singleline=true) requires one or two arguments."
+ << true;
+
+ QTest::newRow("$$system(): default mode")
+#ifdef Q_OS_WIN
+ << "VAR = $$system('echo Hello, ^\"world.&& echo foo^\" bar baz')"
+#else
+ << "VAR = $$system('echo Hello, \\\\\\\"world. && echo foo\\\\\\\" bar baz')"
+#endif
+ << "VAR = Hello, '\"world. foo\"' bar baz"
+ << ""
+ << true;
+
+ QTest::newRow("$$system(): lines mode")
+#ifdef Q_OS_WIN
+ << "VAR = $$system('echo Hello, ^\"world.&& echo foo^\" bar baz', lines)"
+#else
+ << "VAR = $$system('echo Hello, \\\\\\\"world. && echo foo\\\\\\\" bar baz', lines)"
+#endif
+ << "VAR = 'Hello, \"world.' 'foo\" bar baz'"
+ << ""
+ << true;
+
+ QTest::newRow("$$system(): bad number of arguments")
+ << "VAR = $$system(1, 2, 3)"
+ << "VAR ="
+ << "##:1: system(execute) requires one or two arguments."
+ << true;
+
+ QTest::newRow("$$unique()")
+ << "IN = foo bar foo baz\nVAR = $$unique(IN)"
+ << "VAR = foo bar baz"
+ << ""
+ << true;
+
+ QTest::newRow("$$unique(): bad number of arguments")
+ << "VAR = $$unique(1, 2)"
+ << "VAR ="
+ << "##:1: unique(var) requires one argument."
+ << true;
+
+ QTest::newRow("$$reverse()")
+ << "IN = one two three\nVAR = $$reverse(IN)"
+ << "VAR = three two one"
+ << ""
+ << true;
+
+ QTest::newRow("$$reverse(): bad number of arguments")
+ << "VAR = $$reverse(1, 2)"
+ << "VAR ="
+ << "##:1: reverse(var) requires one argument."
+ << true;
+
+ QTest::newRow("$$quote()")
+ << "VAR = $$quote(foo bar, 'foo bar')"
+ << "VAR = 'foo bar' 'foo bar'"
+ << ""
+ << true;
+
+ // FIXME: \n and \r go untested, because there is no way to get them into the
+ // expected result. And if there was one, this function would be unnecessary.
+ // In other news, the behavior of backslash escaping makes no sense.
+ QTest::newRow("$$escape_expand()")
+ << "VAR = $$escape_expand(foo\\\\ttab\\\\\\\\slash\\\\invalid, verbatim)"
+ << "VAR = 'foo\ttab\\\\\\\\slash\\\\invalid' verbatim"
+ << ""
+ << true;
+
+ QTest::newRow("$$upper()")
+ << "VAR = $$upper(kEwL, STuff)"
+ << "VAR = KEWL STUFF"
+ << ""
+ << true;
+
+ QTest::newRow("$$lower()")
+ << "VAR = $$lower(kEwL, STuff)"
+ << "VAR = kewl stuff"
+ << ""
+ << true;
+
+ QTest::newRow("$$title()")
+ << "VAR = $$title(kEwL, STuff)"
+ << "VAR = Kewl Stuff"
+ << ""
+ << true;
+
+ QTest::newRow("$$re_escape()")
+ << "VAR = $$re_escape(one, hey.*you[funny]+people)"
+ << "VAR = one hey\\\\.\\\\*you\\\\[funny\\\\]\\\\+people"
+ << ""
+ << true;
+
+ QTest::newRow("$$val_escape()")
+ << "IN = easy \"less easy\" sca$${LITERAL_HASH}ry"
+ " crazy$$escape_expand(\\\\t\\\\r\\\\n)"
+ " $$escape_expand(\\\\t)stuff \\'no\\\"way\\\\here\n"
+ "VAR = $$val_escape(IN)"
+ << "VAR = easy '\\\"less easy\\\"' sca\\$\\${LITERAL_HASH}ry"
+ " crazy\\$\\$escape_expand(\\\\\\\\t\\\\\\\\r\\\\\\\\n)"
+ " \\$\\$escape_expand(\\\\\\\\t)stuff \\\\\\'no\\\\\\\"way\\\\\\\\here"
+ << ""
+ << true;
+
+ QTest::newRow("$$val_escape(): bad number of arguments")
+ << "VAR = $$val_escape(1, 2)"
+ << "VAR ="
+ << "##:1: val_escape(var) requires one argument."
+ << true;
+
+ QTest::newRow("$$files(): non-recursive")
+ << "VAR = $$files(" + qindir + "/files/file*.txt)"
+ << "VAR = " + qindir + "/files/file1.txt "
+ + qindir + "/files/file2.txt"
+ << ""
+ << true;
+
+ QTest::newRow("$$files(): recursive")
+ << "VAR = $$files(" + qindir + "/files/file*.txt, true)"
+ << "VAR = " + qindir + "/files/file1.txt "
+ + qindir + "/files/file2.txt "
+ + qindir + "/files/dir/file1.txt "
+ + qindir + "/files/dir/file2.txt"
+ << ""
+ << true;
+
+ QTest::newRow("$$files(): bad number of arguments")
+ << "VAR = $$files(1, 2, 3)"
+ << "VAR ="
+ << "##:1: files(pattern, recursive=false) requires one or two arguments."
+ << true;
+
+#if 0
+ // FIXME: no emulated input layer
+ QTest::newRow("$$prompt()")
+ << "VAR = $$prompt(que)"
+ << "VAR = whatever"
+ << "Project PROMPT: que? "
+ << true;
+#endif
+
+ QTest::newRow("$$replace()")
+ << "IN = foo 'bar baz'\nVAR = $$replace(IN, \\\\bba, hello)"
+ << "VAR = foo 'hellor helloz'"
+ << ""
+ << true;
+
+ QTest::newRow("$$replace(): bad number of arguments")
+ << "VAR = $$replace(1, 2) \\\n$$replace(1, 2, 3, 4)"
+ << "VAR ="
+ << "##:1: replace(var, before, after) requires three arguments.\n"
+ "##:2: replace(var, before, after) requires three arguments."
+ << true;
+
+ QTest::newRow("$$sort_depends()")
+ << "foo.depends = bar baz\n"
+ "bar.depends = baz bak duck\n"
+ "baz.depends = bak\n"
+ "bak.depends = duck\n"
+ "VAR = $$sort_depends($$list(baz foo duck bar))"
+ << "VAR = foo bar baz duck"
+ << ""
+ << true;
+
+ QTest::newRow("$$resolve_depends(): basic")
+ << "foo.depends = bar baz\n"
+ "bar.depends = baz bak duck\n"
+ "baz.depends = bak\n"
+ "bak.depends = duck\n"
+ "VAR = $$resolve_depends($$list(baz foo duck bar))"
+ << "VAR = foo bar baz bak duck"
+ << ""
+ << true;
+
+ QTest::newRow("$$resolve_depends(): prefix and multiple suffixes")
+ << "MOD.foo.dep = bar baz\n"
+ "MOD.bar.dep = baz bak\n"
+ "MOD.bar.priv_dep = duck\n"
+ "MOD.baz.dep = bak\n"
+ "MOD.bak.dep = duck\n"
+ "VAR = $$resolve_depends($$list(baz foo duck bar), MOD., .dep .priv_dep)"
+ << "VAR = foo bar baz bak duck"
+ << ""
+ << true;
+
+ QTest::newRow("$$resolve_depends(): priorities: b first")
+ << "MOD.a.depends =\n"
+ "MOD.b.depends =\n"
+ "MOD.b.priority = 1\n"
+ "MOD.c.depends = a b\n"
+ "VAR = $$resolve_depends($$list(c), MOD.)"
+ << "VAR = c b a"
+ << ""
+ << true;
+
+ QTest::newRow("$$resolve_depends(): priorities: a first")
+ << "MOD.a.depends =\n"
+ "MOD.a.priority = 1\n"
+ "MOD.b.depends =\n"
+ "MOD.b.priority = 0\n"
+ "MOD.c.depends = a b\n"
+ "VAR = $$resolve_depends($$list(c), MOD.)"
+ << "VAR = c a b"
+ << ""
+ << true;
+
+ QTest::newRow("$$resolve_depends(): priorities: custom suffix")
+ << "MOD.a.depends =\n"
+ "MOD.a.prrt = 1\n"
+ "MOD.b.depends =\n"
+ "MOD.b.prrt = 0\n"
+ "MOD.c.depends = a b\n"
+ "VAR = $$resolve_depends($$list(c), MOD., .depends, .prrt)"
+ << "VAR = c a b"
+ << ""
+ << true;
+
+ QTest::newRow("$$resolve_depends(): bad number of arguments")
+ << "VAR = $$resolve_depends(1, 2, 3, 4, 5)"
+ << "VAR ="
+ << "##:1: resolve_depends(var, [prefix, [suffixes, [prio-suffix]]]) requires one to four arguments."
+ << true;
+
+ QTest::newRow("$$enumerate_vars()")
+ << "V1 = foo\nV2 = bar\nVAR = $$enumerate_vars()\n"
+ "count(VAR, 2, >=):contains(VAR, V1):contains(VAR, V2): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("$$shadowed(): bare")
+ << "VAR = $$shadowed(test.txt)"
+ << "VAR = " + QMakeEvaluator::quoteValue(ProString(m_outdir + "/test.txt"))
+ << ""
+ << true;
+
+ QTest::newRow("$$shadowed(): subdir")
+ << "VAR = $$shadowed(" + qindir + "/sub/test.txt)"
+ << "VAR = " + QMakeEvaluator::quoteValue(ProString(m_outdir + "/sub/test.txt"))
+ << ""
+ << true;
+
+ QTest::newRow("$$shadowed(): outside source dir")
+ << "VAR = $$shadowed(/some/random/path)"
+ << "VAR ="
+ << ""
+ << true;
+
+ QTest::newRow("$$shadowed(): bad number of arguments")
+ << "VAR = $$shadowed(1, 2)"
+ << "VAR ="
+ << "##:1: shadowed(path) requires one argument."
+ << true;
+
+ QTest::newRow("$$absolute_path(): relative file")
+ << "VAR = $$absolute_path(dir/file.ext)"
+ << "VAR = " + qindir + "/dir/file.ext"
+ << ""
+ << true;
+
+ QTest::newRow("$$absolute_path(): file & path")
+ << "VAR = $$absolute_path(dir/file.ext, /root/sub)"
+ << "VAR = /root/sub/dir/file.ext"
+ << ""
+ << true;
+
+ QTest::newRow("$$absolute_path(): absolute file & path")
+ << "VAR = $$absolute_path(/root/sub/dir/file.ext, /other)"
+ << "VAR = /root/sub/dir/file.ext"
+ << ""
+ << true;
+
+ QTest::newRow("$$absolute_path(): empty file & path")
+ << "VAR = $$absolute_path('', /root/sub)"
+ << "VAR = /root/sub"
+ << ""
+ << true;
+
+ QTest::newRow("$$absolute_path(): bad number of arguments")
+ << "VAR = $$absolute_path(1, 2, 3)"
+ << "VAR ="
+ << "##:1: absolute_path(path[, base]) requires one or two arguments."
+ << true;
+
+ QTest::newRow("$$relative_path(): relative file")
+ << "VAR = $$relative_path(dir/file.ext)"
+ << "VAR = dir/file.ext"
+ << ""
+ << true;
+
+ QTest::newRow("$$relative_path(): relative file to empty")
+ << "VAR = $$relative_path(dir/..)"
+ << "VAR ="
+ << ""
+ << true;
+
+ QTest::newRow("$$relative_path(): absolute file & path")
+ << "VAR = $$relative_path(/root/sub/dir/file.ext, /root/sub)"
+ << "VAR = dir/file.ext"
+ << ""
+ << true;
+
+ QTest::newRow("$$relative_path(): empty file & path")
+ << "VAR = $$relative_path('', /root/sub)"
+ << "VAR ="
+ << ""
+ << true;
+
+ QTest::newRow("$$relative_path(): bad number of arguments")
+ << "VAR = $$relative_path(1, 2, 3)"
+ << "VAR ="
+ << "##:1: relative_path(path[, base]) requires one or two arguments."
+ << true;
+
+ QTest::newRow("$$clean_path()")
+#ifdef Q_OS_WIN // This is actually kinda stupid.
+ << "VAR = $$clean_path(foo//bar\\\\../baz/)"
+#else
+ << "VAR = $$clean_path(foo//bar/../baz/)"
+#endif
+ << "VAR = foo/baz"
+ << ""
+ << true;
+
+ QTest::newRow("$$clean_path(): bad number of arguments")
+ << "VAR = $$clean_path(1, 2)"
+ << "VAR ="
+ << "##:1: clean_path(path) requires one argument."
+ << true;
+
+ QTest::newRow("$$system_path()")
+ << "VAR = $$system_path(foo/bar\\\\baz)"
+#ifdef Q_OS_WIN
+ << "VAR = foo\\\\bar\\\\baz"
+#else
+ << "VAR = foo/bar/baz"
+#endif
+ << ""
+ << true;
+
+ QTest::newRow("$$system_path(): bad number of arguments")
+ << "VAR = $$system_path(1, 2)"
+ << "VAR ="
+ << "##:1: system_path(path) requires one argument."
+ << true;
+
+ // This is is effectively $$system_path() in this test, as we load no specs
+ QTest::newRow("$$shell_path()")
+ << "VAR = $$shell_path(foo/bar\\\\baz)"
+#ifdef Q_OS_WIN
+ << "VAR = foo\\\\bar\\\\baz"
+#else
+ << "VAR = foo/bar/baz"
+#endif
+ << ""
+ << true;
+
+ QTest::newRow("$$shell_path(): bad number of arguments")
+ << "VAR = $$shell_path(1, 2)"
+ << "VAR ="
+ << "##:1: shell_path(path) requires one argument."
+ << true;
+
+ // The quoteArgs() test exercises this more thoroughly
+ QTest::newRow("$$system_quote()")
+ << "IN = \nVAR = $$system_quote(\"some nasty & ugly\\\" path & thing\\\\\")"
+#ifdef Q_OS_WIN
+ << "VAR = \"\\\"some nasty & ugly\\\\\\\" path ^& thing\\\\\\\\^\\\"\""
+#else
+ << "VAR = \"'some nasty & ugly\\\" path & thing\\\\'\""
+#endif
+ << ""
+ << true;
+
+ QTest::newRow("$$system_quote(): bad number of arguments")
+ << "VAR = $$system_quote(1, 2)"
+ << "VAR ="
+ << "##:1: system_quote(arg) requires one argument."
+ << true;
+
+ // This is is effectively $$system_path() in this test, as we load no specs
+ QTest::newRow("$$shell_quote()")
+ << "IN = \nVAR = $$shell_quote(\"some nasty & ugly\\\" path & thing\\\\\")"
+#ifdef Q_OS_WIN
+ << "VAR = \"\\\"some nasty & ugly\\\\\\\" path ^& thing\\\\\\\\^\\\"\""
+#else
+ << "VAR = \"'some nasty & ugly\\\" path & thing\\\\'\""
+#endif
+ << ""
+ << true;
+
+ QTest::newRow("$$shell_quote(): bad number of arguments")
+ << "VAR = $$shell_quote(1, 2)"
+ << "VAR ="
+ << "##:1: shell_quote(arg) requires one argument."
+ << true;
+
+ QTest::newRow("$$getenv()")
+ << "VAR = $$getenv(E1)"
+ << "VAR = 'env var'"
+ << ""
+ << true;
+
+ QTest::newRow("$$getenv(): bad number of arguments")
+ << "VAR = $$getenv(1, 2)"
+ << "VAR ="
+ << "##:1: getenv(arg) requires one argument."
+ << true;
+}
+
+void tst_qmakelib::addTestFunctions(const QString &qindir)
+{
+ QTest::newRow("defined(): found replace")
+ << "defineReplace(func) {}\ndefined(func): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("defined(): found test")
+ << "defineTest(func) {}\ndefined(func): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("defined(): not found")
+ << "defined(func): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("defined(replace): found")
+ << "defineReplace(func) {}\ndefined(func, replace): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("defined(replace): not found")
+ << "defineTest(func) {}\ndefined(func, replace): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("defined(test): found")
+ << "defineTest(func) {}\ndefined(func, test): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("defined(test): not found")
+ << "defineReplace(func) {}\ndefined(func, test): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("defined(var): found")
+ << "VAR = 1\ndefined(VAR, var): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("defined(var): not found")
+ << "defined(VAR, var): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("defined(): invalid type")
+ << "defined(VAR, nope): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: defined(function, type): unexpected type [nope]."
+ << true;
+
+ QTest::newRow("defined(): bad number of arguments")
+ << "defined(1, 2, 3): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: defined(function, [\"test\"|\"replace\"|\"var\"]) requires one or two arguments."
+ << true;
+
+ QTest::newRow("export()")
+ << "defineTest(func) {\n"
+ "VAR1 += different\nexport(VAR1)\n"
+ "unset(VAR2)\nexport(VAR2): OK = 1\nexport(OK)\n"
+ "VAR3 = new var\nexport(VAR3)\n"
+ "}\n"
+ "VAR1 = entirely\nVAR2 = set\nfunc()"
+ << "OK = 1\nVAR1 = entirely different\nVAR2 =\nVAR3 = new var"
+ << ""
+ << true;
+
+ QTest::newRow("export(): bad number of arguments")
+ << "export(1, 2): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: export(variable) requires one argument."
+ << true;
+
+ QTest::newRow("infile(): found")
+ << "infile(" + qindir + "/fromfile/infile.prx, DEFINES): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("infile(): not found")
+ << "infile(" + qindir + "/fromfile/infile.prx, INCLUDES): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("infile(plain): found")
+ << "infile(" + qindir + "/fromfile/infile.prx, DEFINES, QT_DLL): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("infile(plain): not found")
+ << "infile(" + qindir + "/fromfile/infile.prx, DEFINES, NOPE): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("infile(regex): found")
+ << "infile(" + qindir + "/fromfile/infile.prx, DEFINES, QT_.*): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("infile(regex): not found")
+ << "infile(" + qindir + "/fromfile/infile.prx, DEFINES, NO.*): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ // The early return is debatable, esp. as it's inconsistent with $$fromfile()
+ QTest::newRow("infile(): bad file")
+ << "infile(" + qindir + "/fromfile/badfile.prx, DEFINES): OK = 1\nOKE = 1"
+ << "OK = UNDEF\nOKE = UNDEF"
+ << "Project ERROR: fail!"
+ << false;
+
+ QTest::newRow("infile(): bad number of arguments")
+ << "infile(1): OK = 1\ninfile(1, 2, 3, 4): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: infile(file, var, [values]) requires two or three arguments.\n"
+ "##:2: infile(file, var, [values]) requires two or three arguments."
+ << true;
+
+ QTest::newRow("requires()")
+ << "requires(true, false, isEmpty(FOO), !isEmpty(BAR), true|false, true:false)"
+ << "QMAKE_FAILED_REQUIREMENTS = false !isEmpty(BAR) true:false"
+ << ""
+ << true;
+
+ // The sparator semantics are *very* questionable.
+ // The return value semantics are rather questionable.
+ QTest::newRow("eval()")
+ << "eval(FOO = one, two$$escape_expand(\\\\n)BAR = blah$$escape_expand(\\\\n)error(fail)$$escape_expand(\\\\n)BAZ = nope)"
+ << "FOO = one two\nBAR = blah\nBAZ = UNDEF"
+ << "Project ERROR: fail"
+ << true;
+
+ QTest::newRow("if(): true")
+ << "if(false|true): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("if(): true (space)")
+ << "if(false| true): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("if(): true (spaces)")
+ << "if( false | true ): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("if(): false")
+ << "if(false:true): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("if(): false (space)")
+ << "if(false: true): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("if(): false (spaces)")
+ << "if( false : true ): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("if(): bad number of arguments")
+ << "if(1, 2): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: if(condition) requires one argument."
+ << true;
+
+ QTest::newRow("CONFIG(simple): true")
+ << "CONFIG = debug release\nCONFIG(debug): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("CONFIG(simple): false")
+ << "CONFIG = debug release\nCONFIG(nope): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("CONFIG(alt): true")
+ << "CONFIG = debug release\nCONFIG(release, debug|release): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("CONFIG(alt): false (presence)")
+ << "CONFIG = not here\nCONFIG(debug, debug|release): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("CONFIG(alt): false (order)")
+ << "CONFIG = debug release\nCONFIG(debug, debug|release): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("CONFIG(): bad number of arguments")
+ << "CONFIG(1, 2, 3): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: CONFIG(config) requires one or two arguments."
+ << true;
+
+ QTest::newRow("contains(simple plain): true")
+ << "VAR = one two three\ncontains(VAR, two): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("contains(simple plain): false")
+ << "VAR = one two three\ncontains(VAR, four): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("contains(simple regex): true")
+ << "VAR = one two three\ncontains(VAR, tw.*): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("contains(simple regex): false")
+ << "VAR = one two three\ncontains(VAR, fo.*): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("contains(alt plain): true")
+ << "VAR = one two three\ncontains(VAR, three, two|three): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("contains(alt plain): false (presence)")
+ << "VAR = one four five\ncontains(VAR, three, two|three): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("contains(alt plain): false (order)")
+ << "VAR = one two three\ncontains(VAR, two, two|three): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("contains(alt regex): true")
+ << "VAR = one two three\ncontains(VAR, th.*, two|three): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("contains(alt regex): false (presence)")
+ << "VAR = one four five\ncontains(VAR, th.*, two|three): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("contains(alt regex): false (order)")
+ << "VAR = one two three\ncontains(VAR, tw.*, two|three): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("contains(): bad number of arguments")
+ << "contains(1): OK = 1\ncontains(1, 2, 3, 4): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: contains(var, val) requires two or three arguments.\n"
+ "##:2: contains(var, val) requires two or three arguments."
+ << true;
+
+ QTest::newRow("count(): true")
+ << "VAR = one two three\ncount(VAR, 3): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("count(): false")
+ << "VAR = one two three\ncount(VAR, 4): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("count(operators): true")
+ << "VAR = one two three\n"
+ "count(VAR, 3, equals): OKE1 = 1\n"
+ "count(VAR, 3, isEqual): OKE2 = 1\n"
+ "count(VAR, 3, =): OKE3 = 1\n"
+ "count(VAR, 3, ==): OKE4 = 1\n"
+ "count(VAR, 2, greaterThan): OKG1 = 1\n"
+ "count(VAR, 2, >): OKG2 = 1\n"
+ "count(VAR, 2, >=): OKGE = 1\n"
+ "count(VAR, 4, lessThan): OKL1 = 1\n"
+ "count(VAR, 4, <): OKL2 = 1\n"
+ "count(VAR, 4, <=): OKLE = 1\n"
+ << "OKE1 = 1\nOKE2 = 1\nOKE3 = 1\nOKE4 = 1\n"
+ "OKG1 = 1\nOKG2 = 1\nOKGE = 1\n"
+ "OKL1 = 1\nOKL2 = 1\nOKLE = 1"
+ << ""
+ << true;
+
+ QTest::newRow("count(operators): false")
+ << "VAR = one two three\n"
+ "count(VAR, 4, equals): OKE1 = 1\n"
+ "count(VAR, 4, isEqual): OKE2 = 1\n"
+ "count(VAR, 4, =): OKE3 = 1\n"
+ "count(VAR, 4, ==): OKE4 = 1\n"
+ "count(VAR, 3, greaterThan): OKG1 = 1\n"
+ "count(VAR, 3, >): OKG2 = 1\n"
+ "count(VAR, 4, >=): OKGE = 1\n"
+ "count(VAR, 3, lessThan): OKL1 = 1\n"
+ "count(VAR, 3, <): OKL2 = 1\n"
+ "count(VAR, 2, <=): OKLE = 1\n"
+ << "OKE1 = UNDEF\nOKE2 = UNDEF\nOKE3 = UNDEF\nOKE4 = UNDEF\n"
+ "OKG1 = UNDEF\nOKG2 = UNDEF\nOKGE = UNDEF\n"
+ "OKL1 = UNDEF\nOKL2 = UNDEF\nOKLE = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("count(): bad operator")
+ << "VAR = one two three\ncount(VAR, 2, !!!): OK = 1"
+ << "OK = UNDEF"
+ << "##:2: Unexpected modifier to count(!!!)."
+ << true;
+
+ QTest::newRow("count(): bad number of arguments")
+ << "count(1): OK = 1\ncount(1, 2, 3, 4): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: count(var, count, op=\"equals\") requires two or three arguments.\n"
+ "##:2: count(var, count, op=\"equals\") requires two or three arguments."
+ << true;
+
+ QTest::newRow("greaterThan(int): true")
+ << "VAR = 20\ngreaterThan(VAR, 3): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("greaterThan(int): false")
+ << "VAR = 3\ngreaterThan(VAR, 20): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("greaterThan(string): true")
+ << "VAR = foo 3\ngreaterThan(VAR, foo 20): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("greaterThan(string): false")
+ << "VAR = foo 20\ngreaterThan(VAR, foo 3): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("greaterThan(): bad number of arguments")
+ << "greaterThan(1): OK = 1\ngreaterThan(1, 2, 3): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: greaterThan(variable, value) requires two arguments.\n"
+ "##:2: greaterThan(variable, value) requires two arguments."
+ << true;
+
+ QTest::newRow("lessThan(int): true")
+ << "VAR = 3\nlessThan(VAR, 20): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("lessThan(int): false")
+ << "VAR = 20\nlessThan(VAR, 3): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("lessThan(string): true")
+ << "VAR = foo 20\nlessThan(VAR, foo 3): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("lessThan(string): false")
+ << "VAR = foo 3\nlessThan(VAR, foo 20): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("lessThan(): bad number of arguments")
+ << "lessThan(1): OK = 1\nlessThan(1, 2, 3): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: lessThan(variable, value) requires two arguments.\n"
+ "##:2: lessThan(variable, value) requires two arguments."
+ << true;
+
+ QTest::newRow("equals(): true")
+ << "VAR = foo\nequals(VAR, foo): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("equals(): false")
+ << "VAR = foo\nequals(VAR, bar): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("equals(): bad number of arguments")
+ << "equals(1): OK = 1\nequals(1, 2, 3): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: equals(variable, value) requires two arguments.\n"
+ "##:2: equals(variable, value) requires two arguments."
+ << true;
+
+ // That's just an alias, so don't test much.
+ QTest::newRow("isEqual(): true")
+ << "VAR = foo\nisEqual(VAR, foo): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("clear(): top-level")
+ << "VAR = there\nclear(VAR): OK = 1"
+ << "OK = 1\nVAR ="
+ << ""
+ << true;
+
+ QTest::newRow("clear(): scoped")
+ << "defineTest(func) {\n"
+ "clear(VAR): OK = 1\nexport(OK)\n"
+ "equals(VAR, \"\"): OKE = 1\nexport(OKE)\n"
+ "}\n"
+ "VAR = there\nfunc()"
+ << "OK = 1\nOKE = 1"
+ << ""
+ << true;
+
+ QTest::newRow("clear(): absent")
+ << "clear(VAR): OK = 1"
+ << "OK = UNDEF\nVAR = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("clear(): bad number of arguments")
+ << "clear(1, 2): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: clear(variable) requires one argument."
+ << true;
+
+ QTest::newRow("unset(): top-level")
+ << "VAR = there\nunset(VAR): OK = 1"
+ << "OK = 1\nVAR = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("unset(): scoped")
+ << "defineTest(func) {\n"
+ "unset(VAR): OK = 1\nexport(OK)\n"
+ "!defined(VAR, var): OKE = 1\nexport(OKE)\n"
+ "}\n"
+ "VAR = there\nfunc()"
+ << "OK = 1\nOKE = 1"
+ << ""
+ << true;
+
+ QTest::newRow("unset(): absent")
+ << "unset(VAR): OK = 1"
+ << "OK = UNDEF\nVAR = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("unset(): bad number of arguments")
+ << "unset(1, 2): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: unset(variable) requires one argument."
+ << true;
+
+ // This function does not follow the established naming pattern.
+ QTest::newRow("parseJson()")
+ << "jsontext = \\\n"
+ " \"{\"\\\n"
+ " \" \\\"array\\\" : [\\\"arrayItem1\\\", \\\"arrayItem2\\\", \\\"arrayItem3\\\"],\"\\\n"
+ " \" \\\"object\\\" : { \\\"key1\\\" : \\\"objectValue1\\\", \\\"key2\\\" : \\\"objectValue2\\\" },\"\\\n"
+ " \" \\\"string\\\" : \\\"test string\\\",\"\\\n"
+ " \" \\\"number\\\" : 999,\"\\\n"
+ " \" \\\"true\\\" : true,\"\\\n"
+ " \" \\\"false\\\" :false,\"\"\\\n"
+ " \" \\\"null\\\" : null\"\"\\\n"
+ " \"}\"\n"
+ "parseJson(jsontext, json): OK = 1"
+ << "OK = 1\n"
+ "json._KEYS_ = array false null number object string true\n"
+ // array
+ "json.array._KEYS_ = 0 1 2\n"
+ "json.array.0 = arrayItem1\n"
+ "json.array.1 = arrayItem2\n"
+ "json.array.2 = arrayItem3\n"
+ // object
+ "json.object._KEYS_ = key1 key2\n"
+ "json.object.key1 = objectValue1\n"
+ "json.object.key1 = objectValue1\n"
+ // value types
+ "json.string = 'test string'\n"
+ "json.number = 999\n"
+ "json.true = true\n"
+ "json.false = false\n"
+ "json.null = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("parseJson(): bad input")
+ << "jsontext = not good\n"
+ "parseJson(jsontext, json): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("parseJson(): bad number of arguments")
+ << "parseJson(1): OK = 1\nparseJson(1, 2, 3): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: parseJson(variable, into) requires two arguments.\n"
+ "##:2: parseJson(variable, into) requires two arguments."
+ << true;
+
+ QTest::newRow("include()")
+ << "include(include/inc.pri): OK = 1\nfunc()"
+ << "OK = 1\nVAR = val\n.VAR = nope"
+ << "Project MESSAGE: say hi!"
+ << true;
+
+ QTest::newRow("include(): fail")
+ << "include(include/nope.pri): OK = 1"
+ << "OK = UNDEF"
+ << "Cannot read " + m_indir + "/include/nope.pri: No such file or directory"
+ << true;
+
+ QTest::newRow("include(): silent fail")
+ << "include(include/nope.pri, , true): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("include(into)")
+ << "SUB.MISS = 1\ninclude(include/inc.pri, SUB): OK = 1"
+ << "OK = 1\nSUB.VAR = val\nSUB..VAR = UNDEF\nSUB.MISS = UNDEF\n"
+ // As a side effect, we test some things that need full project setup
+ "SUB.MATCH = 1\nSUB.QMAKESPEC = " + qindir + "/mkspecs/fake-g++"
+ << ""
+ << true;
+
+ QTest::newRow("include(): bad number of arguments")
+ << "include(1, 2, 3, 4): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: include(file, [into, [silent]]) requires one, two or three arguments."
+ << true;
+
+ QTest::newRow("load()")
+ << "load(testfeat): OK = 1"
+ << "OK = 1\nVAR = foo bar"
+ << ""
+ << true;
+
+ QTest::newRow("load(): fail")
+ << "load(no_such_feature): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: Cannot find feature no_such_feature"
+ << true;
+
+ QTest::newRow("load(): silent fail")
+ << "load(no_such_feature, true): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("load(): bad number of arguments")
+ << "load(1, 2, 3): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: load(feature) requires one or two arguments."
+ << true;
+
+ // We don't test debug() and log(), because they print directly to stderr.
+
+ QTest::newRow("message()")
+ << "message('Hello, World!'): OK = 1\nOKE = 1"
+ << "OK = 1\nOKE = 1"
+ << "Project MESSAGE: Hello, World!"
+ << true;
+
+ // Don't test that for warning() and error(), as it's the same code path.
+ QTest::newRow("message(): bad number of arguments")
+ << "message(1, 2): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: message(message) requires one argument."
+ << true;
+
+ QTest::newRow("warning()")
+ << "warning('World, be warned!'): OK = 1\nOKE = 1"
+ << "OK = 1\nOKE = 1"
+ << "Project WARNING: World, be warned!"
+ << true;
+
+ QTest::newRow("error()")
+ << "error('World, you FAIL!'): OK = 1\nOKE = 1"
+ << "OK = UNDEF\nOKE = UNDEF"
+ << "Project ERROR: World, you FAIL!"
+ << false;
+
+ QTest::newRow("system()")
+ << "system('"
+#ifdef Q_OS_WIN
+ "cd"
+#else
+ "pwd"
+#endif
+ "> '" + QMakeEvaluator::quoteValue(ProString(QDir::toNativeSeparators(
+ m_outdir + "/system_out.txt"))) + "): OK = 1\n"
+ "DIR = $$cat(" + QMakeEvaluator::quoteValue(ProString(
+ m_outdir + "/system_out.txt")) + ")"
+ << "OK = 1\nDIR = " + QMakeEvaluator::quoteValue(ProString(QDir::toNativeSeparators(m_indir)))
+ << ""
+ << true;
+
+ QTest::newRow("system(): fail")
+#ifdef Q_OS_WIN
+ << "system(no_such_cmd 2> NUL): OK = 1"
+#else
+ << "system(no_such_cmd 2> /dev/null): OK = 1"
+#endif
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("system(): bad number of arguments")
+ << "system(1, 2): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: system(exec) requires one argument."
+ << true;
+
+ QTest::newRow("isEmpty(): true (empty)")
+ << "VAR =\nisEmpty(VAR): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("isEmpty(): true (undef)")
+ << "isEmpty(VAR): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("isEmpty(): false")
+ << "VAR = val\nisEmpty(VAR): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("isEmpty(): bad number of arguments")
+ << "isEmpty(1, 2): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: isEmpty(var) requires one argument."
+ << true;
+
+ QTest::newRow("exists(plain): true")
+ << "exists(files/file1.txt): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("exists(plain): false")
+ << "exists(files/not_there.txt): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("exists(wildcard): true")
+ << "exists(files/fil*.txt): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("exists(wildcard): false")
+ << "exists(files/not_th*.txt): OK = 1"
+ << "OK = UNDEF"
+ << ""
+ << true;
+
+ QTest::newRow("exists(): bad number of arguments")
+ << "exists(1, 2): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: exists(file) requires one argument."
+ << true;
+
+ QString wpath = QMakeEvaluator::quoteValue(ProString(m_outdir + "/outdir/written.txt"));
+ QTest::newRow("write_file(): create")
+ << "VAR = 'this is text' 'yet again'\n"
+ "write_file(" + wpath + ", VAR): OK = 1\n"
+ "OUT = $$cat(" + wpath + ", lines)"
+ << "OK = 1\nOUT = 'this is text' 'yet again'"
+ << ""
+ << true;
+
+ QTest::newRow("write_file(): truncate")
+ << "VAR = 'other content'\n"
+ "write_file(" + wpath + ", VAR): OK = 1\n"
+ "OUT = $$cat(" + wpath + ", lines)"
+ << "OK = 1\nOUT = 'other content'"
+ << ""
+ << true;
+
+ QTest::newRow("write_file(): append")
+ << "VAR = 'one more line'\n"
+ "write_file(" + wpath + ", VAR, append): OK = 1\n"
+ "OUT = $$cat(" + wpath + ", lines)"
+ << "OK = 1\nOUT = 'other content' 'one more line'"
+ << ""
+ << true;
+
+ QString vpath = QMakeEvaluator::quoteValue(ProString(m_outdir));
+ QTest::newRow("write_file(): fail")
+ << "write_file(" + vpath + "): OK = 1"
+ << "OK = UNDEF"
+#ifdef Q_OS_WIN
+ << "##:1: Cannot write file " + QDir::toNativeSeparators(m_outdir) + ": Access is denied."
+#else
+ << "##:1: Cannot write file " + m_outdir + ": Is a directory"
+#endif
+ << true;
+
+ QTest::newRow("write_file(): bad number of arguments")
+ << "write_file(1, 2, 3, 4): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: write_file(name, [content var, [append]]) requires one to three arguments."
+ << true;
+
+ // FIXME: This doesn't test whether it actually works.
+ QTest::newRow("touch()")
+ << "touch(" + wpath + ", files/other.txt): OK = 1"
+ << "OK = 1"
+ << ""
+ << true;
+
+ QTest::newRow("touch(): missing target")
+ << "touch(/does/not/exist, files/other.txt): OK = 1"
+ << "OK = UNDEF"
+#ifdef Q_OS_WIN
+ << "##:1: Cannot open /does/not/exist: The system cannot find the path specified."
+#else
+ << "##:1: Cannot touch /does/not/exist: No such file or directory."
+#endif
+ << true;
+
+ QTest::newRow("touch(): missing reference")
+ << "touch(" + wpath + ", /does/not/exist): OK = 1"
+ << "OK = UNDEF"
+#ifdef Q_OS_WIN
+ << "##:1: Cannot open reference file /does/not/exist: The system cannot find the path specified."
+#else
+ << "##:1: Cannot stat() reference file /does/not/exist: No such file or directory."
+#endif
+ << true;
+
+ QTest::newRow("touch(): bad number of arguments")
+ << "touch(1): OK = 1\ntouch(1, 2, 3): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: touch(file, reffile) requires two arguments.\n"
+ "##:2: touch(file, reffile) requires two arguments."
+ << true;
+
+ QString apath = QMakeEvaluator::quoteValue(ProString(m_outdir + "/a/path"));
+ QTest::newRow("mkpath()")
+ << "mkpath(" + apath + "): OK = 1\n"
+ "exists(" + apath + "): OKE = 1"
+ << "OK = 1\nOKE = 1"
+ << ""
+ << true;
+
+ QString bpath = QMakeEvaluator::quoteValue(ProString(m_outdir + "/fail_me"));
+ QTest::newRow("mkpath(): fail")
+ << "write_file(" + bpath + ")|error(FAIL)\n"
+ "mkpath(" + bpath + "): OK = 1"
+ << "OK = UNDEF"
+ << "##:2: Cannot create directory " + QDir::toNativeSeparators(m_outdir + "/fail_me") + '.'
+ << true;
+
+ QTest::newRow("mkpath(): bad number of arguments")
+ << "mkpath(1, 2): OK = 1"
+ << "OK = UNDEF"
+ << "##:1: mkpath(file) requires one argument."
+ << true;
+
+#if 0
+ // FIXME ... insanity lies ahead
+ QTest::newRow("cache()")
+ << ""
+ << ""
+ << ""
+ << true;
+#endif
+}
+
+void tst_qmakelib::proEval_data()
+{
+ QTest::addColumn<QString>("in");
+ QTest::addColumn<QString>("out");
+ QTest::addColumn<QString>("msgs");
+ QTest::addColumn<bool>("ok");
+
+ QTest::newRow("empty")
+ << ""
+ << "VAR = UNDEF"
+ << ""
+ << true;
+
+ addAssignments();
+ addExpansions(); // Variable, etc. expansions on RHS
+ addControlStructs(); // Conditions, loops, custom functions
+
+ QString qindir = QMakeEvaluator::quoteValue(ProString(m_indir));
+ addReplaceFunctions(qindir); // Built-in replace functions
+ addTestFunctions(qindir); // Built-in test functions
+
+ // Some compound tests that verify compatibility with odd Qt 4 edge cases
+
+ QTest::newRow("empty (leading)")
+ << "defineTest(myMsg) { message(\"$$1\") }\n"
+ "XMPL = /this/is/a/test\n"
+ "message(split: $$split(XMPL, /))\n"
+ "message(split joined:$$split(XMPL, /))\n"
+ "message(\"split quoted: $$split(XMPL, /)\")\n"
+ "myMsg(my split: $$split(XMPL, /) :post)\n"
+ "myMsg(my split joined:$$split(XMPL, /):post)\n"
+ "myMsg(\"my split quoted: $$split(XMPL, /) post\")\n"
+ "OUT = word $$split(XMPL, /) done\n"
+ "message(\"assign split separate: $$OUT\")\n"
+ "OUT = word:$$split(XMPL, /):done\n"
+ "message(\"assign split joined: $$OUT\")\n"
+ "OUT = \"word $$split(XMPL, /) done\"\n"
+ "message(\"assign split quoted: $$OUT\")\n"
+ << ""
+ << "Project MESSAGE: split: this is a test\n"
+ "Project MESSAGE: split joined: this is a test\n"
+ "Project MESSAGE: split quoted: this is a test\n"
+ "Project MESSAGE: my split: this is a test :post\n"
+ "Project MESSAGE: my split joined: this is a test:post\n"
+ "Project MESSAGE: my split quoted: this is a test post\n"
+ "Project MESSAGE: assign split separate: word this is a test done\n"
+ "Project MESSAGE: assign split joined: word: this is a test:done\n"
+ "Project MESSAGE: assign split quoted: word this is a test done"
+ << true;
+
+ QTest::newRow("empty (multiple)")
+ << "defineTest(myMsg) { message(\"$$1\") }\n"
+ "XMPL = //this///is/a/////test\n"
+ "message(split: $$split(XMPL, /) :post)\n"
+ "message(split joined:$$split(XMPL, /):post)\n"
+ "message(\"split quoted: $$split(XMPL, /) post\")\n"
+ "myMsg(my split: $$split(XMPL, /) :post)\n"
+ "myMsg(my split joined:$$split(XMPL, /):post)\n"
+ "myMsg(\"my split quoted: $$split(XMPL, /) post\")\n"
+ "OUT = word $$split(XMPL, /) done\n"
+ "message(\"assign split separate: $$OUT\")\n"
+ "OUT = word:$$split(XMPL, /):done\n"
+ "message(\"assign split joined: $$OUT\")\n"
+ "OUT = \"word $$split(XMPL, /) done\"\n"
+ "message(\"assign split quoted: $$OUT\")\n"
+ << ""
+ << "Project MESSAGE: split: this is a test :post\n"
+ "Project MESSAGE: split joined: this is a test:post\n"
+ "Project MESSAGE: split quoted: this is a test post\n"
+ "Project MESSAGE: my split: this is a test :post\n"
+ "Project MESSAGE: my split joined: this is a test:post\n"
+ "Project MESSAGE: my split quoted: this is a test post\n"
+ "Project MESSAGE: assign split separate: word this is a test done\n"
+ "Project MESSAGE: assign split joined: word: this is a test:done\n"
+ "Project MESSAGE: assign split quoted: word this is a test done"
+ << true;
+}
+
+static QString formatValue(const ProStringList &vals)
+{
+ QString ret;
+
+ foreach (const ProString &str, vals) {
+ ret += QLatin1Char(' ');
+ ret += QMakeEvaluator::quoteValue(str);
+ }
+ return ret;
+}
+
+static void skipNoise(const ushort *&tokPtr)
+{
+ forever {
+ ushort tok = *tokPtr;
+ if (tok != TokLine)
+ break;
+ tokPtr += 2;
+ }
+}
+
+static bool compareState(QMakeEvaluator *eval, ProFile *out)
+{
+ bool ret = true;
+ const ushort *tokPtr = out->tokPtr();
+ forever {
+ skipNoise(tokPtr);
+ ushort tok = *tokPtr++;
+ if (!tok)
+ break;
+ if (tok != TokHashLiteral) {
+ qWarning("Expected output is malformed: not variable%s",
+ qPrintable(QMakeParser::formatProBlock(out->items())));
+ return false;
+ }
+ const ProKey &var = out->getHashStr(tokPtr);
+ tok = *tokPtr++;
+ if (tok != TokAssign) {
+ qWarning("Expected output is malformed: not assignment%s",
+ qPrintable(QMakeParser::formatProBlock(out->items())));
+ return false;
+ }
+ ProStringList value;
+ value.reserve(*tokPtr++);
+ forever {
+ skipNoise(tokPtr);
+ tok = *tokPtr++;
+ if (tok == TokValueTerminator)
+ break;
+ if (tok != (TokLiteral | TokNewStr)) {
+ qWarning("Expected output is malformed: not literal%s",
+ qPrintable(QMakeParser::formatProBlock(out->items())));
+ return false;
+ }
+ value << out->getStr(tokPtr);
+ }
+ ProValueMap::Iterator it;
+ ProValueMap *vmap = eval->findValues(var, &it);
+ if (value.length() == 1 && value.at(0) == "UNDEF") {
+ if (vmap) {
+ qWarning("Value of %s is incorrect.\n Actual:%s\nExpected: <UNDEFINED>",
+ qPrintable(var.toQString()),
+ qPrintable(formatValue(*it)));
+ ret = false;
+ }
+ } else {
+ if (!vmap) {
+ qWarning("Value of %s is incorrect.\n Actual: <UNDEFINED>\nExpected:%s",
+ qPrintable(var.toQString()),
+ qPrintable(formatValue(value)));
+ ret = false;
+ } else if (*it != value) {
+ qWarning("Value of %s is incorrect.\n Actual:%s\nExpected:%s",
+ qPrintable(var.toQString()),
+ qPrintable(formatValue(*it)), qPrintable(formatValue(value)));
+ ret = false;
+ }
+ }
+ }
+ return ret;
+}
+
+void tst_qmakelib::proEval()
+{
+ QFETCH(QString, in);
+ QFETCH(QString, out);
+ QFETCH(QString, msgs);
+ QFETCH(bool, ok);
+
+ QString infile = m_indir + "/test.pro";
+ bool verified = true;
+ QMakeTestHandler handler;
+ handler.setExpectedMessages(msgs.replace("##:", infile + ':').split('\n', QString::SkipEmptyParts));
+ QMakeVfs vfs;
+ QMakeParser parser(0, &vfs, &handler);
+ QMakeGlobals globals;
+ globals.do_cache = false;
+ globals.xqmakespec = "fake-g++";
+ globals.environment = m_env;
+ globals.setProperties(m_prop);
+ globals.setDirectories(m_indir, m_outdir);
+ ProFile *outPro = parser.parsedProBlock(out, "out", 1, QMakeParser::FullGrammar);
+ if (!outPro->isOk()) {
+ qWarning("Expected output is malformed");
+ verified = false;
+ }
+ ProFile *pro = parser.parsedProBlock(in, infile, 1, QMakeParser::FullGrammar);
+ QMakeEvaluator visitor(&globals, &parser, &vfs, &handler);
+ visitor.setOutputDir(m_outdir);
+#ifdef Q_OS_WIN
+ visitor.m_dirSep = ProString("\\");
+#else
+ visitor.m_dirSep = ProString("/");
+#endif
+ QMakeEvaluator::VisitReturn ret
+ = visitor.visitProFile(pro, QMakeHandler::EvalAuxFile, QMakeEvaluator::LoadProOnly);
+ if (handler.printedMessages()) {
+ qWarning("Got unexpected message(s)");
+ verified = false;
+ }
+ QStringList missingMsgs = handler.expectedMessages();
+ if (!missingMsgs.isEmpty()) {
+ foreach (const QString &msg, missingMsgs)
+ qWarning("Missing message: %s", qPrintable(msg));
+ verified = false;
+ }
+ if ((ret == QMakeEvaluator::ReturnTrue) != ok) {
+ static const char * const lbl[] = { "failure", "success" };
+ qWarning("Expected %s, got %s", lbl[int(ok)], lbl[1 - int(ok)]);
+ verified = false;
+ }
+ if (!compareState(&visitor, outPro))
+ verified = false;
+ pro->deref();
+ outPro->deref();
+ QVERIFY(verified);
+}
diff --git a/tests/auto/tools/qmakelib/parsertest.cpp b/tests/auto/tools/qmakelib/parsertest.cpp
new file mode 100644
index 0000000000..a7b7431a98
--- /dev/null
+++ b/tests/auto/tools/qmakelib/parsertest.cpp
@@ -0,0 +1,1987 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "tst_qmakelib.h"
+
+#include <proitems.h>
+#include <qmakevfs.h>
+#include <qmakeparser.h>
+
+class TokenStream
+{
+public:
+ TokenStream() {}
+ QString toString() const { return ts; }
+
+ TokenStream &operator<<(ushort n) { ts += QChar(n); return *this; }
+ TokenStream &operator<<(uint n) { ts += QChar(n & 0xffff); ts += QChar(n >> 16); return *this; }
+ TokenStream &operator<<(const QStringRef &s) { ts += s; return *this; }
+ TokenStream &operator<<(const ProString &s) { return *this << ushort(s.length()) << s.toQStringRef(); }
+ TokenStream &operator<<(const ProKey &s) { return *this << s.hash() << s.toString(); }
+
+private:
+ QString ts;
+};
+
+#define TS(s) (TokenStream() s).toString()
+#define H(n) ushort(n)
+#define I(n) uint(n)
+#define S(s) ProString(QString::fromWCharArray(s))
+#define HS(s) ProKey(QString::fromWCharArray(s))
+
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_MSVC(4003) // "not enough actual parameters for macro TS()"
+
+void tst_qmakelib::addParseOperators()
+{
+ QTest::newRow("assign none")
+ << "VAR ="
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 9 */ << H(TokAssign) << H(0)
+ /* 11 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("append none")
+ << "VAR +="
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 9 */ << H(TokAppend) << H(0)
+ /* 11 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("unique append none")
+ << "VAR *="
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 9 */ << H(TokAppendUnique) << H(0)
+ /* 11 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("remove none")
+ << "VAR -="
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 9 */ << H(TokRemove) << H(0)
+ /* 11 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("replace empty")
+ << "VAR ~="
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 9 */ << H(TokReplace) << H(0)
+ /* 11 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("assignment without variable")
+ << "="
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokAssign) << H(0)
+ /* 4 */ << H(TokValueTerminator))
+ << "in:1: Assignment needs exactly one word on the left hand side."
+ << false;
+
+ QTest::newRow("assignment with multiple variables")
+ << "VAR VAR ="
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokAssign) << H(0)
+ /* 4 */ << H(TokValueTerminator))
+ << "in:1: Assignment needs exactly one word on the left hand side."
+ << false;
+}
+
+void tst_qmakelib::addParseValues()
+{
+#define ASSIGN_VAR(h) \
+ H(TokLine) << H(1) \
+ << H(TokHashLiteral) << HS(L"VAR") \
+ << H(TokAssign) << H(h)
+
+ QTest::newRow("one literal")
+ << "VAR = val"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"val")
+ /* 16 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("one literal (squeezed)")
+ << "VAR=val"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"val")
+ /* 16 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("many literals")
+ << "VAR = foo barbaz bak hello"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(4)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
+ /* 16 */ << H(TokLiteral | TokNewStr) << S(L"barbaz")
+ /* 24 */ << H(TokLiteral | TokNewStr) << S(L"bak")
+ /* 29 */ << H(TokLiteral | TokNewStr) << S(L"hello")
+ /* 36 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("many literals (tab-separated")
+ << "VAR\t=\tfoo\tbarbaz\tbak\thello"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(4)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
+ /* 16 */ << H(TokLiteral | TokNewStr) << S(L"barbaz")
+ /* 24 */ << H(TokLiteral | TokNewStr) << S(L"bak")
+ /* 29 */ << H(TokLiteral | TokNewStr) << S(L"hello")
+ /* 36 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("one quoted literal")
+ << "VAR = \"val ue\""
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"val ue")
+ /* 19 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("quoted literal with missing quote")
+ << "VAR = val \"ue"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 9 */ << H(TokAssign) << H(0)
+ /* 11 */ << H(TokValueTerminator))
+ << "in:1: Missing closing \" quote"
+ << false;
+
+ QTest::newRow("many quoted literals")
+ << "VAR = \"foo\" barbaz 'bak hello' \"\""
+ << TS(
+ /* 0 */ << ASSIGN_VAR(3)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
+ /* 16 */ << H(TokLiteral | TokNewStr) << S(L"barbaz")
+ /* 24 */ << H(TokLiteral | TokNewStr) << S(L"bak hello")
+ /* 35 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("many quoted literals (with tabs)")
+ << "VAR\t=\t\"foo\"\tbarbaz\t'bak\thello'"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(3)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
+ /* 16 */ << H(TokLiteral | TokNewStr) << S(L"barbaz")
+ /* 24 */ << H(TokLiteral | TokNewStr) << S(L"bak\thello")
+ /* 35 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("quoted and unquoted spaces")
+ << " VAR = \"val ue \" "
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"val ue ")
+ /* 22 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("funny literals")
+ << "VAR = foo:bar|!baz(blam!, ${foo})"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(2)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo:bar|!baz(blam!,")
+ /* 32 */ << H(TokLiteral | TokNewStr) << S(L"${foo})")
+ /* 41 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("literals with escapes")
+ << "VAR = \\{hi\\} \\[ho\\] \\)uh\\( \"\\\\oh\\$\"\\' \\$\\${FOO}"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(5)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"{hi}")
+ /* 17 */ << H(TokLiteral | TokNewStr) << S(L"[ho]")
+ /* 23 */ << H(TokLiteral | TokNewStr) << S(L")uh(")
+ /* 29 */ << H(TokLiteral | TokNewStr) << S(L"\\oh$'")
+ /* 36 */ << H(TokLiteral | TokNewStr) << S(L"$${FOO}")
+ /* 45 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("magic variables")
+ << "VAR = $$LITERAL_HASH $$LITERAL_DOLLAR $$LITERAL_WHITESPACE $$_FILE_ $$_LINE_"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(5)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"#")
+ /* 14 */ << H(TokLiteral | TokNewStr) << S(L"$")
+ /* 17 */ << H(TokLiteral | TokNewStr) << S(L"\t")
+ /* 20 */ << H(TokLiteral | TokNewStr) << S(L"in")
+ /* 24 */ << H(TokLiteral | TokNewStr) << S(L"1")
+ /* 27 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("continuations and comments")
+ << "VAR = foo \\\n bar\n \n"
+ "GAR = foo \\ # comment\n bar \\\n # comment\n baz \\\n"
+ "\"quoted \\ #comment\n escape\" \\\n right\\\n after \\\n gorilla!\n \n\n"
+ "MOO = \\\n kuh # comment\nLOO =\n\n"
+ "FOO = bar \\\n# comment\n baz \\\n \n# comment\n"
+ "GAZ="
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 9 */ << H(TokAssign) << H(2)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
+ /* 16 */ << H(TokLiteral | TokNewStr) << S(L"bar")
+ /* 21 */ << H(TokValueTerminator)
+ /* 22 */ << H(TokLine) << H(4)
+ /* 24 */ << H(TokHashLiteral) << HS(L"GAR")
+ /* 31 */ << H(TokAssign) << H(7)
+ /* 33 */ << H(TokLiteral | TokNewStr) << S(L"foo")
+ /* 38 */ << H(TokLiteral | TokNewStr) << S(L"bar")
+ /* 43 */ << H(TokLiteral | TokNewStr) << S(L"baz")
+ /* 48 */ << H(TokLiteral | TokNewStr) << S(L"quoted escape")
+ /* 64 */ << H(TokLiteral | TokNewStr) << S(L"right")
+ /* 71 */ << H(TokLiteral | TokNewStr) << S(L"after")
+ /* 78 */ << H(TokLiteral | TokNewStr) << S(L"gorilla!")
+ /* 88 */ << H(TokValueTerminator)
+ /* 89 */ << H(TokLine) << H(15)
+ /* 91 */ << H(TokHashLiteral) << HS(L"MOO")
+ /* 98 */ << H(TokAssign) << H(0)
+ /* 100 */ << H(TokLiteral | TokNewStr) << S(L"kuh")
+ /* 105 */ << H(TokValueTerminator)
+ /* 106 */ << H(TokLine) << H(17)
+ /* 108 */ << H(TokHashLiteral) << HS(L"LOO")
+ /* 115 */ << H(TokAssign) << H(0)
+ /* 117 */ << H(TokValueTerminator)
+ /* 118 */ << H(TokLine) << H(19)
+ /* 120 */ << H(TokHashLiteral) << HS(L"FOO")
+ /* 127 */ << H(TokAssign) << H(2)
+ /* 129 */ << H(TokLiteral | TokNewStr) << S(L"bar")
+ /* 134 */ << H(TokLiteral | TokNewStr) << S(L"baz")
+ /* 139 */ << H(TokValueTerminator)
+ /* 140 */ << H(TokLine) << H(24)
+ /* 142 */ << H(TokHashLiteral) << HS(L"GAZ")
+ /* 149 */ << H(TokAssign) << H(0)
+ /* 151 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("accidental continuation")
+ << "VAR0 = \\\n this \\\n is \\\n ok\n"
+ "VAR1 = \\\n this \\\n is=still \\\n ok\n"
+ "VAR2 = \\\n this \\\n is \\\n"
+ "VAR3 = \\\n not ok\n"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"VAR0")
+ /* 10 */ << H(TokAssign) << H(3)
+ /* 12 */ << H(TokLiteral | TokNewStr) << S(L"this")
+ /* 18 */ << H(TokLiteral | TokNewStr) << S(L"is")
+ /* 22 */ << H(TokLiteral | TokNewStr) << S(L"ok")
+ /* 26 */ << H(TokValueTerminator)
+ /* 27 */ << H(TokLine) << H(5)
+ /* 29 */ << H(TokHashLiteral) << HS(L"VAR1")
+ /* 37 */ << H(TokAssign) << H(3)
+ /* 39 */ << H(TokLiteral | TokNewStr) << S(L"this")
+ /* 45 */ << H(TokLiteral | TokNewStr) << S(L"is=still")
+ /* 55 */ << H(TokLiteral | TokNewStr) << S(L"ok")
+ /* 59 */ << H(TokValueTerminator)
+ /* 60 */ << H(TokLine) << H(9)
+ /* 62 */ << H(TokHashLiteral) << HS(L"VAR2")
+ /* 70 */ << H(TokAssign) << H(6)
+ /* 72 */ << H(TokLiteral | TokNewStr) << S(L"this")
+ /* 78 */ << H(TokLiteral | TokNewStr) << S(L"is")
+ /* 82 */ << H(TokLiteral | TokNewStr) << S(L"VAR3")
+ /* 88 */ << H(TokLiteral | TokNewStr) << S(L"=")
+ /* 91 */ << H(TokLiteral | TokNewStr) << S(L"not")
+ /* 96 */ << H(TokLiteral | TokNewStr) << S(L"ok")
+ /* 100 */ << H(TokValueTerminator))
+ << "WARNING: in:12: Possible accidental line continuation"
+ << true;
+
+ QTest::newRow("plain variable expansion")
+ << "VAR = $$bar"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokVariable | TokNewStr) << HS(L"bar")
+ /* 18 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("braced variable expansion")
+ << "VAR = $${foo/bar}"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokVariable | TokNewStr) << HS(L"foo/bar")
+ /* 22 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("bogus variable expansion")
+ << "VAR = $$ "
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokVariable | TokNewStr) << HS(L"")
+ /* 15 */ << H(TokValueTerminator))
+ << "WARNING: in:1: Missing name in expansion"
+ << true;
+
+ QTest::newRow("bogus braced variable expansion")
+ << "VAR = $${}"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokVariable | TokNewStr) << HS(L"")
+ /* 15 */ << H(TokValueTerminator))
+ << "WARNING: in:1: Missing name in expansion"
+ << true;
+
+ QTest::newRow("unterminated braced variable expansion")
+ << "VAR = $${FOO"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 9 */ << H(TokAssign) << H(0)
+ /* 11 */ << H(TokVariable | TokNewStr) << HS(L"FOO")
+ /* 18 */ << H(TokValueTerminator))
+ << "in:1: Missing } terminator [found end-of-line]"
+ << false;
+
+ QTest::newRow("invalid identifier in braced variable expansion")
+ << "VAR = $${FOO/BAR+BAZ}"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 9 */ << H(TokAssign) << H(0)
+ /* 11 */ << H(TokVariable | TokNewStr) << HS(L"FOO/BAR")
+ /* 22 */ << H(TokLiteral) << S(L"+BAZ")
+ /* 28 */ << H(TokValueTerminator))
+ << "in:1: Missing } terminator [found +]"
+ << false;
+
+ QTest::newRow("property expansion")
+ << "VAR = $$[bar]"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokProperty | TokNewStr) << HS(L"bar")
+ /* 18 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("environment expansion")
+ << "VAR = $$(bar)"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokEnvVar | TokNewStr) << S(L"bar")
+ /* 16 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("plain function call")
+ << "VAR = $$bar()"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokFuncName | TokNewStr) << HS(L"bar")
+ /* 18 */ << H(TokFuncTerminator)
+ /* 19 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("braced function call")
+ << "VAR = $${bar()}"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokFuncName | TokNewStr) << HS(L"bar")
+ /* 18 */ << H(TokFuncTerminator)
+ /* 19 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("function call with one argument")
+ << "VAR = $$bar(blubb)"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokFuncName | TokNewStr) << HS(L"bar")
+ /* 18 */ << H(TokLiteral | TokNewStr) << S(L"blubb")
+ /* 25 */ << H(TokFuncTerminator)
+ /* 26 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("function call with multiple arguments")
+ << "VAR = $$bar( blubb blubb, hey ,$$you)"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokFuncName | TokNewStr) << HS(L"bar")
+ /* 18 */ << H(TokLiteral | TokNewStr) << S(L"blubb")
+ /* 25 */ << H(TokLiteral | TokNewStr) << S(L"blubb")
+ /* 32 */ << H(TokArgSeparator)
+ /* 33 */ << H(TokLiteral | TokNewStr) << S(L"hey")
+ /* 38 */ << H(TokArgSeparator)
+ /* 39 */ << H(TokVariable | TokNewStr) << HS(L"you")
+ /* 46 */ << H(TokFuncTerminator)
+ /* 47 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("nested function call")
+ << "VAR = $$foo(yo, $$bar(blubb))"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokFuncName | TokNewStr) << HS(L"foo")
+ /* 18 */ << H(TokLiteral | TokNewStr) << S(L"yo")
+ /* 22 */ << H(TokArgSeparator)
+ /* 23 */ << H(TokFuncName | TokNewStr) << HS(L"bar")
+ /* 30 */ << H(TokLiteral | TokNewStr) << S(L"blubb")
+ /* 37 */ << H(TokFuncTerminator)
+ /* 38 */ << H(TokFuncTerminator)
+ /* 39 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ // This is a rather questionable "feature"
+ QTest::newRow("function call with parenthesized argument")
+ << "VAR = $$bar(blubb (yo, man) blabb, nope)"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokFuncName | TokNewStr) << HS(L"bar")
+ /* 18 */ << H(TokLiteral | TokNewStr) << S(L"blubb")
+ /* 25 */ << H(TokLiteral | TokNewStr) << S(L"(yo,")
+ /* 31 */ << H(TokLiteral | TokNewStr) << S(L"man)")
+ /* 37 */ << H(TokLiteral | TokNewStr) << S(L"blabb")
+ /* 44 */ << H(TokArgSeparator)
+ /* 45 */ << H(TokLiteral | TokNewStr) << S(L"nope")
+ /* 51 */ << H(TokFuncTerminator)
+ /* 52 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("separate literal and expansion")
+ << "VAR = foo $$bar"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(2)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
+ /* 16 */ << H(TokVariable | TokNewStr) << HS(L"bar")
+ /* 23 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("separate expansion and literal")
+ << "VAR = $$bar foo"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokVariable | TokNewStr) << HS(L"bar")
+ /* 18 */ << H(TokLiteral | TokNewStr) << S(L"foo")
+ /* 23 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("joined literal and expansion")
+ << "VAR = foo$$bar"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
+ /* 16 */ << H(TokVariable) << HS(L"bar")
+ /* 23 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("joined expansion and literal")
+ << "VAR = $${bar}foo"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokVariable | TokNewStr) << HS(L"bar")
+ /* 18 */ << H(TokLiteral) << S(L"foo")
+ /* 23 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("plain variable expansion with funny name and literal")
+ << "VAR = $$az_AZ_09.dot/nix"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokVariable | TokNewStr) << HS(L"az_AZ_09.dot")
+ /* 27 */ << H(TokLiteral) << S(L"/nix")
+ /* 33 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("braced variable expansion with funny name")
+ << "VAR = $${az_AZ_09.dot/nix}"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokVariable | TokNewStr) << HS(L"az_AZ_09.dot/nix")
+ /* 31 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("quoted joined literal and expansion")
+ << "VAR = 'foo$$bar'"
+ << TS(
+ /* 0 */ << ASSIGN_VAR(0)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
+ /* 16 */ << H(TokVariable | TokQuoted) << HS(L"bar")
+ /* 23 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("assignment with expansion in variable name")
+ << "VAR$$EXTRA ="
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 9 */ << H(TokVariable) << HS(L"EXTRA")
+ /* 18 */ << H(TokAssign) << H(0)
+ /* 20 */ << H(TokValueTerminator))
+ << ""
+ << true;
+}
+
+void tst_qmakelib::addParseConditions()
+{
+ QTest::newRow("one test")
+ << "foo"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition))
+ << ""
+ << true;
+
+ QTest::newRow("wildcard-test")
+ << "foo-*"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo-*")
+ /* 11 */ << H(TokCondition))
+ << ""
+ << true;
+
+ // This is a rather questionable "feature"
+ QTest::newRow("one quoted test")
+ << "\"foo\""
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition))
+ << ""
+ << true;
+
+ QTest::newRow("two tests")
+ << "foo\nbar"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition)
+ /* 10 */ << H(TokLine) << H(2)
+ /* 12 */ << H(TokHashLiteral) << HS(L"bar")
+ /* 19 */ << H(TokCondition))
+ << ""
+ << true;
+
+ QTest::newRow("bogus two tests")
+ << "foo bar\nbaz"
+ << TS()
+ << "in:1: Extra characters after test expression."
+ << false;
+
+ QTest::newRow("test-AND-test")
+ << "foo:bar"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition)
+ /* 10 */ << H(TokAnd)
+ /* 11 */ << H(TokHashLiteral) << HS(L"bar")
+ /* 18 */ << H(TokCondition))
+ << ""
+ << true;
+
+ QTest::newRow("test-OR-test")
+ << " foo | bar "
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition)
+ /* 10 */ << H(TokOr)
+ /* 11 */ << H(TokHashLiteral) << HS(L"bar")
+ /* 18 */ << H(TokCondition))
+ << ""
+ << true;
+
+ QTest::newRow("NOT-test")
+ << "!foo"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokNot)
+ /* 3 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 10 */ << H(TokCondition))
+ << ""
+ << true;
+
+ QTest::newRow("NOT-NOT-test")
+ << "!!foo"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition))
+ << ""
+ << true;
+
+ // This is a rather questionable "feature"
+ QTest::newRow("quoted-NOT-test")
+ << "\"!foo\""
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokNot)
+ /* 3 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 10 */ << H(TokCondition))
+ << ""
+ << true;
+
+ // This is a rather questionable "feature"
+ QTest::newRow("NOT-quoted-test")
+ << "!\"foo\""
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokNot)
+ /* 3 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 10 */ << H(TokCondition))
+ << ""
+ << true;
+
+ QTest::newRow("test-AND-NOT-test")
+ << "foo:!bar"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition)
+ /* 10 */ << H(TokAnd)
+ /* 11 */ << H(TokNot)
+ /* 12 */ << H(TokHashLiteral) << HS(L"bar")
+ /* 19 */ << H(TokCondition))
+ << ""
+ << true;
+
+ QTest::newRow("test-assignment")
+ << "foo\nVAR="
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition)
+ /* 10 */ << H(TokLine) << H(2)
+ /* 12 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 19 */ << H(TokAssign) << H(0)
+ /* 21 */ << H(TokValueTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("test-AND-assignment")
+ << "foo: VAR ="
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition)
+ /* 10 */ << H(TokBranch)
+ /* 11 */ /* then branch */ << I(11)
+ /* 13 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 20 */ << H(TokAssign) << H(0)
+ /* 22 */ << H(TokValueTerminator)
+ /* 23 */ << H(TokTerminator)
+ /* 24 */ /* else branch */ << I(0))
+ << ""
+ << true;
+
+ QTest::newRow("test-else-test")
+ << "foo\nelse: bar"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition)
+ /* 10 */ << H(TokBranch)
+ /* 11 */ /* then branch */ << I(0)
+ /* 13 */ /* else branch */ << I(11)
+ /* 15 */ << H(TokLine) << H(2)
+ /* 17 */ << H(TokHashLiteral) << HS(L"bar")
+ /* 24 */ << H(TokCondition)
+ /* 25 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("function-else-test")
+ << "foo()\nelse: bar"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokTestCall)
+ /* 10 */ << H(TokFuncTerminator)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(0)
+ /* 14 */ /* else branch */ << I(11)
+ /* 16 */ << H(TokLine) << H(2)
+ /* 18 */ << H(TokHashLiteral) << HS(L"bar")
+ /* 25 */ << H(TokCondition)
+ /* 26 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("test-AND-test-else-test")
+ << "foo:bar\nelse: baz"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition)
+ /* 10 */ << H(TokAnd)
+ /* 11 */ << H(TokHashLiteral) << HS(L"bar")
+ /* 18 */ << H(TokCondition)
+ /* 19 */ << H(TokBranch)
+ /* 20 */ /* then branch */ << I(0)
+ /* 22 */ /* else branch */ << I(11)
+ /* 24 */ << H(TokLine) << H(2)
+ /* 26 */ << H(TokHashLiteral) << HS(L"baz")
+ /* 33 */ << H(TokCondition)
+ /* 34 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("test-AND-test-else-test-else-test-function")
+ << "foo:bar\nelse: baz\nelse: bak\nbuzz()"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition)
+ /* 10 */ << H(TokAnd)
+ /* 11 */ << H(TokHashLiteral) << HS(L"bar")
+ /* 18 */ << H(TokCondition)
+ /* 19 */ << H(TokBranch)
+ /* 20 */ /* then branch */ << I(0)
+ /* 22 */ /* else branch */ << I(27)
+ /* 24 */ << H(TokLine) << H(2)
+ /* 26 */ << H(TokHashLiteral) << HS(L"baz")
+ /* 33 */ << H(TokCondition)
+ /* 34 */ << H(TokBranch)
+ /* 35 */ /* then branch */ << I(0)
+ /* 37 */ /* else branch */ << I(11)
+ /* 39 */ << H(TokLine) << H(3)
+ /* 41 */ << H(TokHashLiteral) << HS(L"bak")
+ /* 48 */ << H(TokCondition)
+ /* 49 */ << H(TokTerminator)
+ /* 50 */ << H(TokTerminator)
+ /* 51 */ << H(TokLine) << H(4)
+ /* 53 */ << H(TokHashLiteral) << HS(L"buzz")
+ /* 61 */ << H(TokTestCall)
+ /* 62 */ << H(TokFuncTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("test-assignment-else-assignment")
+ << "foo: VAR =\nelse: VAR="
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition)
+ /* 10 */ << H(TokBranch)
+ /* 11 */ /* then branch */ << I(11)
+ /* 13 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 20 */ << H(TokAssign) << H(0)
+ /* 22 */ << H(TokValueTerminator)
+ /* 23 */ << H(TokTerminator)
+ /* 24 */ /* else branch */ << I(13)
+ /* 26 */ << H(TokLine) << H(2)
+ /* 28 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 35 */ << H(TokAssign) << H(0)
+ /* 37 */ << H(TokValueTerminator)
+ /* 38 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("test-else-test-assignment")
+ << "foo\nelse: bar: VAR ="
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition)
+ /* 10 */ << H(TokBranch)
+ /* 11 */ /* then branch */ << I(0)
+ /* 13 */ /* else branch */ << I(27)
+ /* 15 */ << H(TokLine) << H(2)
+ /* 17 */ << H(TokHashLiteral) << HS(L"bar")
+ /* 24 */ << H(TokCondition)
+ /* 25 */ << H(TokBranch)
+ /* 26 */ /* then branch */ << I(11)
+ /* 28 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 35 */ << H(TokAssign) << H(0)
+ /* 37 */ << H(TokValueTerminator)
+ /* 38 */ << H(TokTerminator)
+ /* 39 */ /* else branch */ << I(0)
+ /* 41 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("one function")
+ << "foo()"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokTestCall)
+ /* 10 */ << H(TokFuncTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("one function (with spaces)")
+ << " foo( ) "
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokTestCall)
+ /* 10 */ << H(TokFuncTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("unterminated function call")
+ << "foo(\nfoo"
+ << TS()
+ << "in:1: Missing closing parenthesis in function call"
+ << false;
+
+ QTest::newRow("function with arguments")
+ << "foo(blah, hi ho)"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokTestCall)
+ /* 10 */ << H(TokLiteral | TokNewStr) << S(L"blah")
+ /* 16 */ << H(TokArgSeparator)
+ /* 17 */ << H(TokLiteral | TokNewStr) << S(L"hi")
+ /* 21 */ << H(TokLiteral | TokNewStr) << S(L"ho")
+ /* 25 */ << H(TokFuncTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("function with empty arguments")
+ << "foo(,)"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokTestCall)
+ /* 10 */ << H(TokArgSeparator)
+ /* 11 */ << H(TokFuncTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("function with funny arguments")
+ << "foo(blah\\, \"hi , \\ho\" ,uh\\ ,\\oh ,, )"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokTestCall)
+ /* 10 */ << H(TokLiteral | TokNewStr) << S(L"blah\\")
+ /* 17 */ << H(TokArgSeparator)
+ /* 18 */ << H(TokLiteral | TokNewStr) << S(L"hi , \\ho")
+ /* 29 */ << H(TokArgSeparator)
+ /* 30 */ << H(TokLiteral | TokNewStr) << S(L"uh\\")
+ /* 35 */ << H(TokArgSeparator)
+ /* 36 */ << H(TokLiteral | TokNewStr) << S(L"\\oh")
+ /* 41 */ << H(TokArgSeparator)
+ /* 42 */ << H(TokArgSeparator)
+ /* 43 */ << H(TokFuncTerminator))
+ << "WARNING: in:1: Unescaped backslashes are deprecated\n"
+ "WARNING: in:1: Unescaped backslashes are deprecated\n"
+ "WARNING: in:1: Unescaped backslashes are deprecated\n"
+ "WARNING: in:1: Unescaped backslashes are deprecated"
+ << true;
+
+ QTest::newRow("function with nested call")
+ << "foo($$blah(hi ho))"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokTestCall)
+ /* 10 */ << H(TokFuncName | TokNewStr) << HS(L"blah")
+ /* 18 */ << H(TokLiteral | TokNewStr) << S(L"hi")
+ /* 22 */ << H(TokLiteral | TokNewStr) << S(L"ho")
+ /* 26 */ << H(TokFuncTerminator)
+ /* 27 */ << H(TokFuncTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("stand-alone parentheses")
+ << "()"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokTestCall)
+ /* 3 */ << H(TokFuncTerminator))
+ << "in:1: Opening parenthesis without prior test name."
+ << false;
+
+ QTest::newRow("bogus test and function")
+ << "foo bar()"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokTestCall)
+ /* 3 */ << H(TokFuncTerminator))
+ << "in:1: Extra characters after test expression."
+ << false;
+
+ // This is a rather questionable "feature"
+ QTest::newRow("two functions")
+ << "foo() bar()"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokTestCall)
+ /* 10 */ << H(TokFuncTerminator)
+ /* 11 */ << H(TokHashLiteral) << HS(L"bar")
+ /* 18 */ << H(TokTestCall)
+ /* 19 */ << H(TokFuncTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("function-AND-test")
+ << "foo():bar"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokTestCall)
+ /* 10 */ << H(TokFuncTerminator)
+ /* 11 */ << H(TokAnd)
+ /* 12 */ << H(TokHashLiteral) << HS(L"bar")
+ /* 19 */ << H(TokCondition))
+ << ""
+ << true;
+
+ QTest::newRow("test-AND-function")
+ << "foo:bar()"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition)
+ /* 10 */ << H(TokAnd)
+ /* 11 */ << H(TokHashLiteral) << HS(L"bar")
+ /* 18 */ << H(TokTestCall)
+ /* 19 */ << H(TokFuncTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("NOT-function-AND-test")
+ << "!foo():bar"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokNot)
+ /* 3 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 10 */ << H(TokTestCall)
+ /* 11 */ << H(TokFuncTerminator)
+ /* 12 */ << H(TokAnd)
+ /* 13 */ << H(TokHashLiteral) << HS(L"bar")
+ /* 20 */ << H(TokCondition))
+ << ""
+ << true;
+
+ QTest::newRow("test-AND-NOT-function")
+ << "foo:!bar()"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"foo")
+ /* 9 */ << H(TokCondition)
+ /* 10 */ << H(TokAnd)
+ /* 11 */ << H(TokNot)
+ /* 12 */ << H(TokHashLiteral) << HS(L"bar")
+ /* 19 */ << H(TokTestCall)
+ /* 20 */ << H(TokFuncTerminator))
+ << ""
+ << true;
+}
+
+void tst_qmakelib::addParseControlStatements()
+{
+ QTest::newRow("for(VAR, LIST) loop")
+ << "for(VAR, LIST)"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokForLoop) << HS(L"VAR")
+ /* 9 */ /* iterator */ << I(7)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"LIST")
+ /* 17 */ << H(TokValueTerminator)
+ /* 18 */ /* body */ << I(1)
+ /* 20 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("for(ever) loop")
+ << "for(ever)"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokForLoop) << HS(L"")
+ /* 6 */ /* iterator */ << I(9)
+ /* 8 */ << H(TokHashLiteral) << HS(L"ever")
+ /* 16 */ << H(TokValueTerminator)
+ /* 17 */ /* body */ << I(1)
+ /* 19 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ // This is a rather questionable "feature"
+ QTest::newRow("for($$blub) loop")
+ << "for($$blub)"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokForLoop) << HS(L"")
+ /* 6 */ /* iterator */ << I(9)
+ /* 8 */ << H(TokVariable | TokNewStr) << HS(L"blub")
+ /* 16 */ << H(TokValueTerminator)
+ /* 17 */ /* body */ << I(1)
+ /* 19 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("test-for-test-else-test")
+ << "true:for(VAR, LIST): true\nelse: true"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(31)
+ /* 14 */ << H(TokForLoop) << HS(L"VAR")
+ /* 21 */ /* iterator */ << I(7)
+ /* 23 */ << H(TokLiteral | TokNewStr) << S(L"LIST")
+ /* 29 */ << H(TokValueTerminator)
+ /* 30 */ /* body */ << I(12)
+ /* 32 */ << H(TokLine) << H(1)
+ /* 34 */ << H(TokHashLiteral) << HS(L"true")
+ /* 42 */ << H(TokCondition)
+ /* 43 */ << H(TokTerminator)
+ /* 44 */ << H(TokTerminator)
+ /* 45 */ /* else branch */ << I(12)
+ /* 47 */ << H(TokLine) << H(2)
+ /* 49 */ << H(TokHashLiteral) << HS(L"true")
+ /* 57 */ << H(TokCondition)
+ /* 58 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("next()")
+ << "for(ever): next()"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokForLoop) << HS(L"")
+ /* 6 */ /* iterator */ << I(9)
+ /* 8 */ << H(TokHashLiteral) << HS(L"ever")
+ /* 16 */ << H(TokValueTerminator)
+ /* 17 */ /* body */ << I(4)
+ /* 19 */ << H(TokLine) << H(1)
+ /* 21 */ << H(TokNext)
+ /* 22 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("break()")
+ << "for(ever): break()"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokForLoop) << HS(L"")
+ /* 6 */ /* iterator */ << I(9)
+ /* 8 */ << H(TokHashLiteral) << HS(L"ever")
+ /* 16 */ << H(TokValueTerminator)
+ /* 17 */ /* body */ << I(4)
+ /* 19 */ << H(TokLine) << H(1)
+ /* 21 */ << H(TokBreak)
+ /* 22 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("top-level return()")
+ << "return()"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokReturn))
+ << ""
+ << true;
+
+ QTest::newRow("else")
+ << "else"
+ << TS()
+ << "in:1: Unexpected 'else'."
+ << false;
+
+ QTest::newRow("test-{else}")
+ << "test { else }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"test")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(1)
+ /* 14 */ << H(TokTerminator)
+ /* 15 */ /* else branch */ << I(0))
+ << "in:1: Unexpected 'else'."
+ << false;
+
+ QTest::newRow("defineTest-{else}")
+ << "defineTest(fn) { else }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokTestDef) << HS(L"fn")
+ /* 8 */ /* body */ << I(1)
+ /* 10 */ << H(TokTerminator))
+ << "in:1: Unexpected 'else'."
+ << false;
+
+ QTest::newRow("for-else")
+ << "for(ever) { else }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokForLoop) << HS(L"")
+ /* 6 */ /* iterator */ << I(9)
+ /* 8 */ << H(TokHashLiteral) << HS(L"ever")
+ /* 16 */ << H(TokValueTerminator)
+ /* 17 */ /* body */ << I(1)
+ /* 19 */ << H(TokTerminator))
+ << "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;
+}
+
+void tst_qmakelib::addParseBraces()
+{
+ QTest::newRow("{}")
+ << "{ }"
+ << TS()
+ << ""
+ << true;
+
+ QTest::newRow("{}-newlines")
+ << "\n\n{ }\n\n"
+ << TS()
+ << ""
+ << true;
+
+ QTest::newRow("{")
+ << "{"
+ << TS()
+ << "in:2: Missing closing brace(s)."
+ << false;
+
+ QTest::newRow("test {")
+ << "test {"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"test")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(1)
+ /* 14 */ << H(TokTerminator)
+ /* 15 */ /* else branch */ << I(0))
+ << "in:2: Missing closing brace(s)."
+ << false;
+
+ QTest::newRow("}")
+ << "}"
+ << TS()
+ << "in:1: Excess closing brace."
+ << false;
+
+ QTest::newRow("{test}")
+ << "{ true }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition))
+ << ""
+ << true;
+
+ QTest::newRow("{test-newlines}")
+ << "{\ntrue\n}"
+ << TS(
+ /* 0 */ << H(TokLine) << H(2)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition))
+ << ""
+ << true;
+
+ QTest::newRow("{assignment-test}-test")
+ << "{ VAR = { foo } bar } true"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 9 */ << H(TokAssign) << H(4)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"{")
+ /* 14 */ << H(TokLiteral | TokNewStr) << S(L"foo")
+ /* 19 */ << H(TokLiteral | TokNewStr) << S(L"}")
+ /* 22 */ << H(TokLiteral | TokNewStr) << S(L"bar")
+ /* 27 */ << H(TokValueTerminator)
+ /* 28 */ << H(TokHashLiteral) << HS(L"true")
+ /* 36 */ << H(TokCondition))
+ << ""
+ << true;
+
+ QTest::newRow("assignment with excess opening brace")
+ << "VAR = { { foo }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 9 */ << H(TokAssign) << H(4)
+ /* 11 */ << H(TokLiteral | TokNewStr) << S(L"{")
+ /* 14 */ << H(TokLiteral | TokNewStr) << S(L"{")
+ /* 17 */ << H(TokLiteral | TokNewStr) << S(L"foo")
+ /* 22 */ << H(TokLiteral | TokNewStr) << S(L"}")
+ /* 25 */ << H(TokValueTerminator))
+ << "WARNING: in:1: Possible braces mismatch"
+ << true;
+
+ QTest::newRow("test-{}")
+ << "true {}"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(1)
+ /* 14 */ << H(TokTerminator)
+ /* 15 */ /* else branch */ << I(0))
+ << ""
+ << true;
+
+ QTest::newRow("test-{newlines}")
+ << "true {\n}"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(1)
+ /* 14 */ << H(TokTerminator)
+ /* 15 */ /* else branch */ << I(0))
+ << ""
+ << true;
+
+ QTest::newRow("test-{test}")
+ << "true { true }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(10)
+ /* 14 */ << H(TokHashLiteral) << HS(L"true")
+ /* 22 */ << H(TokCondition)
+ /* 23 */ << H(TokTerminator)
+ /* 24 */ /* else branch */ << I(0))
+ << ""
+ << true;
+
+ QTest::newRow("test:-{test}")
+ << "true: { true }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(10)
+ /* 14 */ << H(TokHashLiteral) << HS(L"true")
+ /* 22 */ << H(TokCondition)
+ /* 23 */ << H(TokTerminator)
+ /* 24 */ /* else branch */ << I(0))
+ << "WARNING: in:1: Excess colon in front of opening brace."
+ << true;
+
+ QTest::newRow("test-{test-newlines}")
+ << "true {\ntrue\n}"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(12)
+ /* 14 */ << H(TokLine) << H(2)
+ /* 16 */ << H(TokHashLiteral) << HS(L"true")
+ /* 24 */ << H(TokCondition)
+ /* 25 */ << H(TokTerminator)
+ /* 26 */ /* else branch */ << I(0))
+ << ""
+ << true;
+
+ QTest::newRow("test:-{test-newlines}")
+ << "true: {\ntrue\n}"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(12)
+ /* 14 */ << H(TokLine) << H(2)
+ /* 16 */ << H(TokHashLiteral) << HS(L"true")
+ /* 24 */ << H(TokCondition)
+ /* 25 */ << H(TokTerminator)
+ /* 26 */ /* else branch */ << I(0))
+ << "WARNING: in:1: Excess colon in front of opening brace."
+ << true;
+
+ QTest::newRow("test-{assignment}")
+ << "true { VAR = {foo} }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(18)
+ /* 14 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 21 */ << H(TokAssign) << H(0)
+ /* 23 */ << H(TokLiteral | TokNewStr) << S(L"{foo}")
+ /* 30 */ << H(TokValueTerminator)
+ /* 31 */ << H(TokTerminator)
+ /* 32 */ /* else branch */ << I(0))
+ << ""
+ << true;
+
+ QTest::newRow("test-{test-assignment}")
+ << "true { true: VAR = {foo} }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(33)
+ /* 14 */ << H(TokHashLiteral) << HS(L"true")
+ /* 22 */ << H(TokCondition)
+ /* 23 */ << H(TokBranch)
+ /* 24 */ /* then branch */ << I(18)
+ /* 26 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 33 */ << H(TokAssign) << H(0)
+ /* 35 */ << H(TokLiteral | TokNewStr) << S(L"{foo}")
+ /* 42 */ << H(TokValueTerminator)
+ /* 43 */ << H(TokTerminator)
+ /* 44 */ /* else branch */ << I(0)
+ /* 46 */ << H(TokTerminator)
+ /* 47 */ /* else branch */ << I(0))
+ << ""
+ << true;
+
+ QTest::newRow("test-{assignment-newlines}")
+ << "true {\nVAR = {foo}\n}"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(20)
+ /* 14 */ << H(TokLine) << H(2)
+ /* 16 */ << H(TokHashLiteral) << HS(L"VAR")
+ /* 23 */ << H(TokAssign) << H(0)
+ /* 25 */ << H(TokLiteral | TokNewStr) << S(L"{foo}")
+ /* 32 */ << H(TokValueTerminator)
+ /* 33 */ << H(TokTerminator)
+ /* 34 */ /* else branch */ << I(0))
+ << ""
+ << true;
+
+ QTest::newRow("test-{}-else-test-{}")
+ << "true {} else: true {}"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(1)
+ /* 14 */ << H(TokTerminator)
+ /* 15 */ /* else branch */ << I(18)
+ /* 17 */ << H(TokLine) << H(1)
+ /* 19 */ << H(TokHashLiteral) << HS(L"true")
+ /* 27 */ << H(TokCondition)
+ /* 28 */ << H(TokBranch)
+ /* 29 */ /* then branch */ << I(1)
+ /* 31 */ << H(TokTerminator)
+ /* 32 */ /* else branch */ << I(0)
+ /* 34 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("test-{}-else-test-{}-newlines")
+ << "true {\n}\nelse: true {\n}"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(1)
+ /* 14 */ << H(TokTerminator)
+ /* 15 */ /* else branch */ << I(18)
+ /* 17 */ << H(TokLine) << H(3)
+ /* 19 */ << H(TokHashLiteral) << HS(L"true")
+ /* 27 */ << H(TokCondition)
+ /* 28 */ << H(TokBranch)
+ /* 29 */ /* then branch */ << I(1)
+ /* 31 */ << H(TokTerminator)
+ /* 32 */ /* else branch */ << I(0)
+ /* 34 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("test-{test}-else-test-{}-newlines")
+ << "true {\ntrue\n}\nelse: true {\n}"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(12)
+ /* 14 */ << H(TokLine) << H(2)
+ /* 16 */ << H(TokHashLiteral) << HS(L"true")
+ /* 24 */ << H(TokCondition)
+ /* 25 */ << H(TokTerminator)
+ /* 26 */ /* else branch */ << I(18)
+ /* 28 */ << H(TokLine) << H(4)
+ /* 30 */ << H(TokHashLiteral) << HS(L"true")
+ /* 38 */ << H(TokCondition)
+ /* 39 */ << H(TokBranch)
+ /* 40 */ /* then branch */ << I(1)
+ /* 42 */ << H(TokTerminator)
+ /* 43 */ /* else branch */ << I(0)
+ /* 45 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("for-{next}")
+ << "for(ever) { next() }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokForLoop) << HS(L"")
+ /* 6 */ /* iterator */ << I(9)
+ /* 8 */ << H(TokHashLiteral) << HS(L"ever")
+ /* 16 */ << H(TokValueTerminator)
+ /* 17 */ /* body */ << I(4)
+ /* 19 */ << H(TokLine) << H(1)
+ /* 21 */ << H(TokNext)
+ /* 22 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("for:-{next}")
+ << "for(ever): { next() }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokForLoop) << HS(L"")
+ /* 6 */ /* iterator */ << I(9)
+ /* 8 */ << H(TokHashLiteral) << HS(L"ever")
+ /* 16 */ << H(TokValueTerminator)
+ /* 17 */ /* body */ << I(4)
+ /* 19 */ << H(TokLine) << H(1)
+ /* 21 */ << H(TokNext)
+ /* 22 */ << H(TokTerminator))
+ << "WARNING: in:1: Excess colon in front of opening brace."
+ << true;
+
+ QTest::newRow("test-for-{test-else-test-newlines}")
+ << "true:for(VAR, LIST) {\ntrue\nelse: true\n}"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(48)
+ /* 14 */ << H(TokForLoop) << HS(L"VAR")
+ /* 21 */ /* iterator */ << I(7)
+ /* 23 */ << H(TokLiteral | TokNewStr) << S(L"LIST")
+ /* 29 */ << H(TokValueTerminator)
+ /* 30 */ /* body */ << I(29)
+ /* 32 */ << H(TokLine) << H(2)
+ /* 34 */ << H(TokHashLiteral) << HS(L"true")
+ /* 42 */ << H(TokCondition)
+ /* 43 */ << H(TokBranch)
+ /* 44 */ /* then branch */ << I(0)
+ /* 46 */ /* else branch */ << I(12)
+ /* 48 */ << H(TokLine) << H(3)
+ /* 50 */ << H(TokHashLiteral) << HS(L"true")
+ /* 58 */ << H(TokCondition)
+ /* 59 */ << H(TokTerminator)
+ /* 60 */ << H(TokTerminator)
+ /* 61 */ << H(TokTerminator)
+ /* 62 */ /* else branch */ << I(0))
+ << ""
+ << true;
+
+ QTest::newRow("test-for-{test-else-test}")
+ << "true:for(VAR, LIST) { true\nelse: true }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"true")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(48)
+ /* 14 */ << H(TokForLoop) << HS(L"VAR")
+ /* 21 */ /* iterator */ << I(7)
+ /* 23 */ << H(TokLiteral | TokNewStr) << S(L"LIST")
+ /* 29 */ << H(TokValueTerminator)
+ /* 30 */ /* body */ << I(29)
+ /* 32 */ << H(TokLine) << H(1)
+ /* 34 */ << H(TokHashLiteral) << HS(L"true")
+ /* 42 */ << H(TokCondition)
+ /* 43 */ << H(TokBranch)
+ /* 44 */ /* then branch */ << I(0)
+ /* 46 */ /* else branch */ << I(12)
+ /* 48 */ << H(TokLine) << H(2)
+ /* 50 */ << H(TokHashLiteral) << HS(L"true")
+ /* 58 */ << H(TokCondition)
+ /* 59 */ << H(TokTerminator)
+ /* 60 */ << H(TokTerminator)
+ /* 61 */ << H(TokTerminator)
+ /* 62 */ /* else branch */ << I(0))
+ << ""
+ << true;
+}
+
+void tst_qmakelib::addParseCustomFunctions()
+{
+ QTest::newRow("defineTest-{newlines}")
+ << "defineTest(test) {\n}"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokTestDef) << HS(L"test")
+ /* 10 */ /* body */ << I(1)
+ /* 12 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("defineTest:-test")
+ << "defineTest(test): test"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokTestDef) << HS(L"test")
+ /* 10 */ /* body */ << I(12)
+ /* 12 */ << H(TokLine) << H(1)
+ /* 14 */ << H(TokHashLiteral) << HS(L"test")
+ /* 22 */ << H(TokCondition)
+ /* 23 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("defineTest-{test}")
+ << "defineTest(test) { test }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokTestDef) << HS(L"test")
+ /* 10 */ /* body */ << I(12)
+ /* 12 */ << H(TokLine) << H(1)
+ /* 14 */ << H(TokHashLiteral) << HS(L"test")
+ /* 22 */ << H(TokCondition)
+ /* 23 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("defineTest-{return}")
+ << "defineTest(test) { return() }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokTestDef) << HS(L"test")
+ /* 10 */ /* body */ << I(4)
+ /* 12 */ << H(TokLine) << H(1)
+ /* 14 */ << H(TokReturn)
+ /* 15 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("defineReplace-{return-stuff}")
+ << "defineReplace(stuff) { return(foo bar) }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokReplaceDef) << HS(L"stuff")
+ /* 11 */ /* body */ << I(14)
+ /* 13 */ << H(TokLine) << H(1)
+ /* 15 */ << H(TokLiteral | TokNewStr) << S(L"foo")
+ /* 20 */ << H(TokLiteral | TokNewStr) << S(L"bar")
+ /* 25 */ << H(TokReturn)
+ /* 26 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("test-AND-defineTest-{}")
+ << "test: defineTest(test) {}"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"test")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokAnd)
+ /* 12 */ << H(TokTestDef) << HS(L"test")
+ /* 20 */ /* body */ << I(1)
+ /* 22 */ << H(TokTerminator))
+ << ""
+ << true;
+
+ QTest::newRow("test-OR-defineTest-{}")
+ << "test| defineTest(test) {}"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"test")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokOr)
+ /* 12 */ << H(TokTestDef) << HS(L"test")
+ /* 20 */ /* body */ << I(1)
+ /* 22 */ << H(TokTerminator))
+ << ""
+ << true;
+}
+
+void tst_qmakelib::addParseAbuse()
+{
+ QTest::newRow("!")
+ << ""
+ << TS()
+ << ""
+ << true;
+
+ QTest::newRow("|")
+ << ""
+ << TS()
+ << ""
+ << true;
+
+ QTest::newRow(":")
+ << ""
+ << TS()
+ << ""
+ << true;
+
+ QTest::newRow("NOT-assignment")
+ << "!VAR ="
+ << TS()
+ << "in:1: Unexpected NOT operator in front of assignment."
+ << false;
+
+ QTest::newRow("NOT-{}")
+ << "!{}"
+ << TS()
+ << "in:1: Unexpected NOT operator in front of opening brace."
+ << false;
+
+ QTest::newRow("NOT-else")
+ << "test\n!else {}"
+ << TS()
+ << "in:2: Unexpected NOT operator in front of else."
+ << false;
+
+ QTest::newRow("NOT-for-{}")
+ << "!for(ever) {}"
+ << TS()
+ << "in:1: Unexpected NOT operator in front of for()."
+ << false;
+
+ QTest::newRow("NOT-defineTest-{}")
+ << "!defineTest(test) {}"
+ << TS()
+ << "in:1: Unexpected NOT operator in front of function definition."
+ << false;
+
+ QTest::newRow("AND-test")
+ << ":test"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"test")
+ /* 10 */ << H(TokCondition))
+ << "in:1: AND operator without prior condition."
+ << false;
+
+ QTest::newRow("test-AND-else")
+ << "test:else"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"test")
+ /* 10 */ << H(TokCondition))
+ << "in:1: Unexpected AND operator in front of else."
+ << false;
+
+ QTest::newRow("test-AND-AND-test")
+ << "test::test"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"test")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokAnd)
+ /* 12 */ << H(TokHashLiteral) << HS(L"test")
+ /* 20 */ << H(TokCondition))
+ << "WARNING: in:1: Stray AND operator in front of AND operator."
+ << true;
+
+ QTest::newRow("test-AND-OR-test")
+ << "test:|test"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"test")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokOr)
+ /* 12 */ << H(TokHashLiteral) << HS(L"test")
+ /* 20 */ << H(TokCondition))
+ << "WARNING: in:1: Stray AND operator in front of OR operator."
+ << true;
+
+ QTest::newRow("test-{AND-test}")
+ << "test { :test }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"test")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(10)
+ /* 14 */ << H(TokHashLiteral) << HS(L"test")
+ /* 22 */ << H(TokCondition)
+ /* 23 */ << H(TokTerminator)
+ /* 24 */ /* else branch */ << I(0))
+ << "in:1: AND operator without prior condition."
+ << false;
+
+ QTest::newRow("test-OR-assignment")
+ << "foo| VAR ="
+ << TS()
+ << "in:1: Unexpected OR operator in front of assignment."
+ << false;
+
+ QTest::newRow("test-OR-{}")
+ << "foo|{}"
+ << TS()
+ << "in:1: Unexpected OR operator in front of opening brace."
+ << false;
+
+ QTest::newRow("test-OR-for")
+ << "foo|for(ever) {}"
+ << TS()
+ << "in:1: Unexpected OR operator in front of for()."
+ << false;
+
+ QTest::newRow("OR-test")
+ << "|test"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"test")
+ /* 10 */ << H(TokCondition))
+ << "in:1: OR operator without prior condition."
+ << false;
+
+ QTest::newRow("test-OR-else")
+ << "test|else"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"test")
+ /* 10 */ << H(TokCondition))
+ << "in:1: Unexpected OR operator in front of else."
+ << false;
+
+ QTest::newRow("test-OR-OR-test")
+ << "test||test"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"test")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokOr)
+ /* 12 */ << H(TokHashLiteral) << HS(L"test")
+ /* 20 */ << H(TokCondition))
+ << "WARNING: in:1: Stray OR operator in front of OR operator."
+ << true;
+
+ QTest::newRow("test-OR-AND-test")
+ << "test|:test"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"test")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokAnd)
+ /* 12 */ << H(TokHashLiteral) << HS(L"test")
+ /* 20 */ << H(TokCondition))
+ << "WARNING: in:1: Stray OR operator in front of AND operator."
+ << true;
+
+ QTest::newRow("test-{OR-test}")
+ << "test { |test }"
+ << TS(
+ /* 0 */ << H(TokLine) << H(1)
+ /* 2 */ << H(TokHashLiteral) << HS(L"test")
+ /* 10 */ << H(TokCondition)
+ /* 11 */ << H(TokBranch)
+ /* 12 */ /* then branch */ << I(10)
+ /* 14 */ << H(TokHashLiteral) << HS(L"test")
+ /* 22 */ << H(TokCondition)
+ /* 23 */ << H(TokTerminator)
+ /* 24 */ /* else branch */ << I(0))
+ << "in:1: OR operator without prior condition."
+ << false;
+}
+
+void tst_qmakelib::proParser_data()
+{
+ QTest::addColumn<QString>("in");
+ QTest::addColumn<QString>("out");
+ QTest::addColumn<QString>("msgs");
+ QTest::addColumn<bool>("ok");
+
+ QTest::newRow("empty")
+ << ""
+ << TS()
+ << ""
+ << true;
+
+ QTest::newRow("empty (whitespace)")
+ << " \t \t"
+ << TS()
+ << ""
+ << true;
+
+ addParseOperators(); // Variable operators
+
+ addParseValues();
+
+ addParseConditions(); // "Tests"
+
+ addParseControlStatements();
+
+ addParseBraces();
+
+ addParseCustomFunctions();
+
+ addParseAbuse(); // Mostly operator abuse
+
+ // option() (these produce no tokens)
+
+ QTest::newRow("option(host_build)")
+ << "option(host_build)"
+ << TS()
+ << ""
+ << true;
+
+ QTest::newRow("option()")
+ << "option()"
+ << TS()
+ << "in:1: option() requires one literal argument."
+ << false;
+
+ QTest::newRow("option(host_build magic)")
+ << "option(host_build magic)"
+ << TS()
+ << "in:1: option() requires one literal argument."
+ << false;
+
+ QTest::newRow("option(host_build, magic)")
+ << "option(host_build, magic)"
+ << TS()
+ << "in:1: option() requires one literal argument."
+ << false;
+
+ QTest::newRow("option($$OPTION)")
+ << "option($$OPTION)"
+ << TS()
+ << "in:1: option() requires one literal argument."
+ << false;
+
+ QTest::newRow("{option(host_build)}")
+ << "{option(host_build)}"
+ << TS()
+ << "in:1: option() must appear outside any control structures."
+ << false;
+}
+
+QT_WARNING_POP
+
+void tst_qmakelib::proParser()
+{
+ QFETCH(QString, in);
+ QFETCH(QString, out);
+ QFETCH(QString, msgs);
+ QFETCH(bool, ok);
+
+ bool verified = true;
+ QMakeTestHandler handler;
+ handler.setExpectedMessages(msgs.split('\n', QString::SkipEmptyParts));
+ QMakeVfs vfs;
+ QMakeParser parser(0, &vfs, &handler);
+ ProFile *pro = parser.parsedProBlock(in, "in", 1, QMakeParser::FullGrammar);
+ if (handler.printedMessages()) {
+ qWarning("Got unexpected message(s)");
+ verified = false;
+ }
+ QStringList missingMsgs = handler.expectedMessages();
+ if (!missingMsgs.isEmpty()) {
+ foreach (const QString &msg, missingMsgs)
+ qWarning("Missing message: %s", qPrintable(msg));
+ verified = false;
+ }
+ if (pro->isOk() != ok) {
+ static const char * const lbl[] = { "failure", "success" };
+ qWarning("Expected %s, got %s", lbl[int(ok)], lbl[1 - int(ok)]);
+ verified = false;
+ }
+ if (pro->items() != out && (ok || !out.isEmpty())) {
+ qWarning("Bytecode mismatch.\nActual:%s\nExpected:%s",
+ qPrintable(QMakeParser::formatProBlock(pro->items())),
+ qPrintable(QMakeParser::formatProBlock(out)));
+ verified = false;
+ }
+ pro->deref();
+ QVERIFY(verified);
+}
diff --git a/tests/auto/tools/qmakelib/qmakelib.pro b/tests/auto/tools/qmakelib/qmakelib.pro
index e7807838aa..f1b8dfef3d 100644
--- a/tests/auto/tools/qmakelib/qmakelib.pro
+++ b/tests/auto/tools/qmakelib/qmakelib.pro
@@ -6,11 +6,19 @@ QT = core testlib
INCLUDEPATH += ../../../../qmake/library
VPATH += ../../../../qmake/library
+HEADERS += \
+ tst_qmakelib.h
+
SOURCES += \
tst_qmakelib.cpp \
+ parsertest.cpp \
+ evaltest.cpp \
ioutils.cpp \
proitems.cpp \
qmakevfs.cpp \
- qmakeparser.cpp
+ qmakeparser.cpp \
+ qmakeglobals.cpp \
+ qmakebuiltins.cpp \
+ qmakeevaluator.cpp
-DEFINES += PROPARSER_DEBUG
+DEFINES += PROPARSER_DEBUG PROEVALUATOR_FULL PROEVALUATOR_SETENV
diff --git a/tests/auto/tools/qmakelib/testdata/cat/file1.txt b/tests/auto/tools/qmakelib/testdata/cat/file1.txt
new file mode 100644
index 0000000000..e3e4cd41b6
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/cat/file1.txt
@@ -0,0 +1,2 @@
+"Hello, world."
+foo bar baz
diff --git a/tests/auto/tools/qmakelib/testdata/cat/file2.txt b/tests/auto/tools/qmakelib/testdata/cat/file2.txt
new file mode 100644
index 0000000000..18483311e6
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/cat/file2.txt
@@ -0,0 +1,5 @@
+foo bar baz
+"Hello, ' world." post
+'Hello, " world.' post
+\" \' \\ \a \ nix
+" "
diff --git a/tests/auto/tools/qmakelib/testdata/files/dir/file1.txt b/tests/auto/tools/qmakelib/testdata/files/dir/file1.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/files/dir/file1.txt
diff --git a/tests/auto/tools/qmakelib/testdata/files/dir/file2.txt b/tests/auto/tools/qmakelib/testdata/files/dir/file2.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/files/dir/file2.txt
diff --git a/tests/auto/tools/qmakelib/testdata/files/file1.txt b/tests/auto/tools/qmakelib/testdata/files/file1.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/files/file1.txt
diff --git a/tests/auto/tools/qmakelib/testdata/files/file2.txt b/tests/auto/tools/qmakelib/testdata/files/file2.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/files/file2.txt
diff --git a/tests/auto/tools/qmakelib/testdata/files/other.txt b/tests/auto/tools/qmakelib/testdata/files/other.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/files/other.txt
diff --git a/tests/auto/tools/qmakelib/testdata/fromfile/badfile.prx b/tests/auto/tools/qmakelib/testdata/fromfile/badfile.prx
new file mode 100644
index 0000000000..a916f21587
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/fromfile/badfile.prx
@@ -0,0 +1 @@
+error("fail!")
diff --git a/tests/auto/tools/qmake/testdata/functions/infiletest.pro b/tests/auto/tools/qmakelib/testdata/fromfile/infile.prx
index 821cb5cb2c..821cb5cb2c 100644
--- a/tests/auto/tools/qmake/testdata/functions/infiletest.pro
+++ b/tests/auto/tools/qmakelib/testdata/fromfile/infile.prx
diff --git a/tests/auto/tools/qmakelib/testdata/include/inc.pri b/tests/auto/tools/qmakelib/testdata/include/inc.pri
new file mode 100644
index 0000000000..1f1b3a287f
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/include/inc.pri
@@ -0,0 +1,8 @@
+VAR = val
+.VAR = nope
+
+fake-*: MATCH = 1
+
+defineTest(func) {
+ message("say hi!")
+}
diff --git a/tests/auto/tools/qmakelib/testdata/mkspecs/fake-g++/qmake.conf b/tests/auto/tools/qmakelib/testdata/mkspecs/fake-g++/qmake.conf
new file mode 100644
index 0000000000..d7a17d2429
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/mkspecs/fake-g++/qmake.conf
@@ -0,0 +1 @@
+# Nothing here
diff --git a/tests/auto/tools/qmakelib/testdata/mkspecs/features/default_post.prf b/tests/auto/tools/qmakelib/testdata/mkspecs/features/default_post.prf
new file mode 100644
index 0000000000..d7a17d2429
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/mkspecs/features/default_post.prf
@@ -0,0 +1 @@
+# Nothing here
diff --git a/tests/auto/tools/qmakelib/testdata/mkspecs/features/default_pre.prf b/tests/auto/tools/qmakelib/testdata/mkspecs/features/default_pre.prf
new file mode 100644
index 0000000000..d7a17d2429
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/mkspecs/features/default_pre.prf
@@ -0,0 +1 @@
+# Nothing here
diff --git a/tests/auto/tools/qmakelib/testdata/mkspecs/features/spec_post.prf b/tests/auto/tools/qmakelib/testdata/mkspecs/features/spec_post.prf
new file mode 100644
index 0000000000..d7a17d2429
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/mkspecs/features/spec_post.prf
@@ -0,0 +1 @@
+# Nothing here
diff --git a/tests/auto/tools/qmakelib/testdata/mkspecs/features/spec_pre.prf b/tests/auto/tools/qmakelib/testdata/mkspecs/features/spec_pre.prf
new file mode 100644
index 0000000000..d7a17d2429
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/mkspecs/features/spec_pre.prf
@@ -0,0 +1 @@
+# Nothing here
diff --git a/tests/auto/tools/qmakelib/testdata/mkspecs/features/testfeat.prf b/tests/auto/tools/qmakelib/testdata/mkspecs/features/testfeat.prf
new file mode 100644
index 0000000000..57c9a0d783
--- /dev/null
+++ b/tests/auto/tools/qmakelib/testdata/mkspecs/features/testfeat.prf
@@ -0,0 +1 @@
+VAR = foo bar
diff --git a/tests/auto/tools/qmakelib/tst_qmakelib.cpp b/tests/auto/tools/qmakelib/tst_qmakelib.cpp
index 1c6d43338d..3da48815fb 100644
--- a/tests/auto/tools/qmakelib/tst_qmakelib.cpp
+++ b/tests/auto/tools/qmakelib/tst_qmakelib.cpp
@@ -31,37 +31,112 @@
**
****************************************************************************/
-#include <QtTest/QtTest>
+#include "tst_qmakelib.h"
#include <ioutils.h>
-#include <proitems.h>
-#include <qmakevfs.h>
-#include <qmakeparser.h>
-
-#include <QObject>
using namespace QMakeInternal;
-class tst_qmakelib : public QObject
+void tst_qmakelib::initTestCase()
+{
+ m_indir = QFINDTESTDATA("testdata");
+ m_outdir = m_indir + QLatin1String("_build");
+ m_env.insert(QStringLiteral("E1"), QStringLiteral("env var"));
+#ifdef Q_OS_WIN
+ m_env.insert(QStringLiteral("COMSPEC"), qgetenv("COMSPEC"));
+#endif
+ m_prop.insert(ProKey("P1"), ProString("prop val"));
+ m_prop.insert(ProKey("QT_HOST_DATA/get"), ProString(m_indir));
+
+ QVERIFY(!m_indir.isEmpty());
+ QVERIFY(QDir(m_outdir).removeRecursively());
+ QVERIFY(QDir().mkpath(m_outdir));
+}
+
+void tst_qmakelib::cleanupTestCase()
{
- Q_OBJECT
+ QVERIFY(QDir(m_outdir).removeRecursively());
+}
+
+void tst_qmakelib::proString()
+{
+ QString qs1(QStringLiteral("this is a string"));
+
+ ProString s1(qs1);
+ QCOMPARE(s1.toQString(), QStringLiteral("this is a string"));
+
+ ProString s2(qs1, 5, 8);
+ QCOMPARE(s2.toQString(), QStringLiteral("is a str"));
+
+ QCOMPARE(s2.hash(), 0x80000000);
+ qHash(s2);
+ QCOMPARE(s2.hash(), 90404018U);
-public:
- tst_qmakelib() {}
- virtual ~tst_qmakelib() {}
+ QCOMPARE(s2.mid(0, 10).toQString(), QStringLiteral("is a str"));
+ QCOMPARE(s2.mid(1, 5).toQString(), QStringLiteral("s a s"));
+ QCOMPARE(s2.mid(10, 3).toQString(), QStringLiteral(""));
-private slots:
- void quoteArgUnix_data();
- void quoteArgUnix();
- void quoteArgWin_data();
- void quoteArgWin();
- void pathUtils();
+ QString qs2(QStringLiteral(" spacy string "));
+ QCOMPARE(ProString(qs2, 3, 13).trimmed().toQString(), QStringLiteral("spacy string"));
+ QCOMPARE(ProString(qs2, 1, 17).trimmed().toQString(), QStringLiteral("spacy string"));
- void proStringList();
+ QVERIFY(s2.toQStringRef().string()->isSharedWith(qs1));
+ s2.prepend(ProString("there "));
+ QCOMPARE(s2.toQString(), QStringLiteral("there is a str"));
+ QVERIFY(!s2.toQStringRef().string()->isSharedWith(qs1));
- void proParser_data();
- void proParser();
-};
+ ProString s3("this is a longish string with bells and whistles");
+ s3 = s3.mid(18, 17);
+ // Prepend to detached string with lots of spare space in it.
+ s3.prepend(ProString("another "));
+ QCOMPARE(s3.toQString(), QStringLiteral("another string with bells"));
+
+ // Note: The string still has plenty of spare space.
+ s3.append(QLatin1Char('.'));
+ QCOMPARE(s3.toQString(), QStringLiteral("another string with bells."));
+ s3.append(QLatin1String(" eh?"));
+ QCOMPARE(s3.toQString(), QStringLiteral("another string with bells. eh?"));
+
+ s3.append(ProString(" yeah!"));
+ QCOMPARE(s3.toQString(), QStringLiteral("another string with bells. eh? yeah!"));
+
+ bool pending = false; // Not in string, but joining => add space
+ s3.append(ProString("..."), &pending);
+ QCOMPARE(s3.toQString(), QStringLiteral("another string with bells. eh? yeah! ..."));
+ QVERIFY(pending);
+
+ ProStringList sl1;
+ sl1 << ProString("") << ProString("foo") << ProString("barbaz");
+ ProString s4a("hallo");
+ s4a.append(sl1);
+ QCOMPARE(s4a.toQString(), QStringLiteral("hallo foo barbaz"));
+ ProString s4b("hallo");
+ pending = false;
+ s4b.append(sl1, &pending);
+ QCOMPARE(s4b.toQString(), QStringLiteral("hallo foo barbaz"));
+ ProString s4c;
+ pending = false;
+ s4c.append(sl1, &pending);
+ QCOMPARE(s4c.toQString(), QStringLiteral(" foo barbaz"));
+ // bizarreness
+ ProString s4d("hallo");
+ pending = false;
+ s4d.append(sl1, &pending, true);
+ QCOMPARE(s4d.toQString(), QStringLiteral("hallo foo barbaz"));
+ ProString s4e;
+ pending = false;
+ s4e.append(sl1, &pending, true);
+ QCOMPARE(s4e.toQString(), QStringLiteral("foo barbaz"));
+
+ ProStringList sl2;
+ sl2 << ProString("foo");
+ ProString s5;
+ s5.append(sl2);
+ QCOMPARE(s5.toQString(), QStringLiteral("foo"));
+ QVERIFY(s5.toQStringRef().string()->isSharedWith(*sl2.first().toQStringRef().string()));
+
+ QCOMPARE(ProString("one") + ProString(" more"), QStringLiteral("one more"));
+}
void tst_qmakelib::proStringList()
{
@@ -171,1940 +246,24 @@ void tst_qmakelib::pathUtils()
QCOMPARE(IoUtils::resolvePath(fnbase, fn1), QStringLiteral("/a/unix/file/path"));
}
-class QMakeHandler : public QMakeParserHandler {
-public:
- QMakeHandler() : QMakeParserHandler(), printed(false) {}
- virtual void message(int type, const QString &msg, const QString &fileName, int lineNo)
- { print(fileName, lineNo, type, msg); }
-
- void setExpectedMessages(const QStringList &msgs) { expected = msgs; }
- QStringList expectedMessages() const { return expected; }
-
- bool printedMessages() const { return printed; }
-
-private:
- void print(const QString &fileName, int lineNo, int type, const QString &msg)
- {
- QString pfx = ((type & QMakeParserHandler::CategoryMask) == QMakeParserHandler::WarningMessage)
- ? QString::fromLatin1("WARNING: ") : QString();
- QString out;
- if (lineNo)
- out = QStringLiteral("%1%2:%3: %4").arg(pfx, fileName, QString::number(lineNo), msg);
- else
- out = QStringLiteral("%1%2").arg(pfx, msg);
- if (!expected.isEmpty() && expected.first() == out) {
- expected.removeAt(0);
- return;
- }
- qWarning("%s", qPrintable(out));
- printed = true;
- }
-
- QStringList expected;
- bool printed;
-};
-
-static QMakeHandler qmakeHandler;
-
-class TokenStream
+void QMakeTestHandler::print(const QString &fileName, int lineNo, int type, const QString &msg)
{
-public:
- TokenStream() {}
- QString toString() const { return ts; }
-
- TokenStream &operator<<(ushort n) { ts += QChar(n); return *this; }
- TokenStream &operator<<(uint n) { ts += QChar(n & 0xffff); ts += QChar(n >> 16); return *this; }
- TokenStream &operator<<(const QStringRef &s) { ts += s; return *this; }
- TokenStream &operator<<(const ProString &s) { return *this << ushort(s.length()) << s.toQStringRef(); }
- TokenStream &operator<<(const ProKey &s) { return *this << s.hash() << s.toString(); }
-
-private:
- QString ts;
-};
-
-#define TS(s) (TokenStream() s).toString()
-#define H(n) ushort(n)
-#define I(n) uint(n)
-#define S(s) ProString(QString::fromWCharArray(s))
-#define HS(s) ProKey(QString::fromWCharArray(s))
-
-void tst_qmakelib::proParser_data()
-{
- QTest::addColumn<QString>("in");
- QTest::addColumn<QString>("out");
- QTest::addColumn<QString>("msgs");
- QTest::addColumn<bool>("ok");
-
- QTest::newRow("empty")
- << ""
- << TS()
- << ""
- << true;
-
- QTest::newRow("empty (whitespace)")
- << " \t \t"
- << TS()
- << ""
- << true;
-
- // Variable operators
-
- QTest::newRow("assign none")
- << "VAR ="
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 9 */ << H(TokAssign) << H(0)
- /* 11 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("append none")
- << "VAR +="
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 9 */ << H(TokAppend) << H(0)
- /* 11 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("unique append none")
- << "VAR *="
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 9 */ << H(TokAppendUnique) << H(0)
- /* 11 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("remove none")
- << "VAR -="
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 9 */ << H(TokRemove) << H(0)
- /* 11 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("replace empty")
- << "VAR ~="
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 9 */ << H(TokReplace) << H(0)
- /* 11 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("assignment without variable")
- << "="
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokAssign) << H(0)
- /* 4 */ << H(TokValueTerminator))
- << "in:1: Assignment needs exactly one word on the left hand side."
- << false;
-
- QTest::newRow("assignment with multiple variables")
- << "VAR VAR ="
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokAssign) << H(0)
- /* 4 */ << H(TokValueTerminator))
- << "in:1: Assignment needs exactly one word on the left hand side."
- << false;
-
- // Values
-
-#define ASSIGN_VAR(h) \
- H(TokLine) << H(1) \
- << H(TokHashLiteral) << HS(L"VAR") \
- << H(TokAssign) << H(h)
-
- QTest::newRow("one literal")
- << "VAR = val"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"val")
- /* 16 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("one literal (squeezed)")
- << "VAR=val"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"val")
- /* 16 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("many literals")
- << "VAR = foo barbaz bak hello"
- << TS(
- /* 0 */ << ASSIGN_VAR(4)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
- /* 16 */ << H(TokLiteral | TokNewStr) << S(L"barbaz")
- /* 24 */ << H(TokLiteral | TokNewStr) << S(L"bak")
- /* 29 */ << H(TokLiteral | TokNewStr) << S(L"hello")
- /* 36 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("many literals (tab-separated")
- << "VAR\t=\tfoo\tbarbaz\tbak\thello"
- << TS(
- /* 0 */ << ASSIGN_VAR(4)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
- /* 16 */ << H(TokLiteral | TokNewStr) << S(L"barbaz")
- /* 24 */ << H(TokLiteral | TokNewStr) << S(L"bak")
- /* 29 */ << H(TokLiteral | TokNewStr) << S(L"hello")
- /* 36 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("one quoted literal")
- << "VAR = \"val ue\""
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"val ue")
- /* 19 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("quoted literal with missing quote")
- << "VAR = val \"ue"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 9 */ << H(TokAssign) << H(0)
- /* 11 */ << H(TokValueTerminator))
- << "in:1: Missing closing \" quote"
- << false;
-
- QTest::newRow("many quoted literals")
- << "VAR = \"foo\" barbaz 'bak hello' \"\""
- << TS(
- /* 0 */ << ASSIGN_VAR(3)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
- /* 16 */ << H(TokLiteral | TokNewStr) << S(L"barbaz")
- /* 24 */ << H(TokLiteral | TokNewStr) << S(L"bak hello")
- /* 35 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("many quoted literals (with tabs)")
- << "VAR\t=\t\"foo\"\tbarbaz\t'bak\thello'"
- << TS(
- /* 0 */ << ASSIGN_VAR(3)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
- /* 16 */ << H(TokLiteral | TokNewStr) << S(L"barbaz")
- /* 24 */ << H(TokLiteral | TokNewStr) << S(L"bak\thello")
- /* 35 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("quoted and unquoted spaces")
- << " VAR = \"val ue \" "
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"val ue ")
- /* 22 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("funny literals")
- << "VAR = foo:bar|!baz(blam!, ${foo})"
- << TS(
- /* 0 */ << ASSIGN_VAR(2)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo:bar|!baz(blam!,")
- /* 32 */ << H(TokLiteral | TokNewStr) << S(L"${foo})")
- /* 41 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("literals with escapes")
- << "VAR = \\{hi\\} \\[ho\\] \\)uh\\( \"\\\\oh\\$\"\\' \\$\\${FOO}"
- << TS(
- /* 0 */ << ASSIGN_VAR(5)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"{hi}")
- /* 17 */ << H(TokLiteral | TokNewStr) << S(L"[ho]")
- /* 23 */ << H(TokLiteral | TokNewStr) << S(L")uh(")
- /* 29 */ << H(TokLiteral | TokNewStr) << S(L"\\oh$'")
- /* 36 */ << H(TokLiteral | TokNewStr) << S(L"$${FOO}")
- /* 45 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("magic variables")
- << "VAR = $$LITERAL_HASH $$LITERAL_DOLLAR $$LITERAL_WHITESPACE $$_FILE_ $$_LINE_"
- << TS(
- /* 0 */ << ASSIGN_VAR(5)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"#")
- /* 14 */ << H(TokLiteral | TokNewStr) << S(L"$")
- /* 17 */ << H(TokLiteral | TokNewStr) << S(L"\t")
- /* 20 */ << H(TokLiteral | TokNewStr) << S(L"in")
- /* 24 */ << H(TokLiteral | TokNewStr) << S(L"1")
- /* 27 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("continuations and comments")
- << "VAR = foo \\\n bar\n \n"
- "GAR = foo \\ # comment\n bar \\\n # comment\n baz \\\n"
- "\"quoted \\ #comment\n escape\" \\\n right\\\n after \\\n gorilla!\n \n\n"
- "MOO = \\\n kuh # comment\nLOO =\n\n"
- "FOO = bar \\\n# comment\n baz \\\n \n# comment\n"
- "GAZ="
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 9 */ << H(TokAssign) << H(2)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
- /* 16 */ << H(TokLiteral | TokNewStr) << S(L"bar")
- /* 21 */ << H(TokValueTerminator)
- /* 22 */ << H(TokLine) << H(4)
- /* 24 */ << H(TokHashLiteral) << HS(L"GAR")
- /* 31 */ << H(TokAssign) << H(7)
- /* 33 */ << H(TokLiteral | TokNewStr) << S(L"foo")
- /* 38 */ << H(TokLiteral | TokNewStr) << S(L"bar")
- /* 43 */ << H(TokLiteral | TokNewStr) << S(L"baz")
- /* 48 */ << H(TokLiteral | TokNewStr) << S(L"quoted escape")
- /* 64 */ << H(TokLiteral | TokNewStr) << S(L"right")
- /* 71 */ << H(TokLiteral | TokNewStr) << S(L"after")
- /* 78 */ << H(TokLiteral | TokNewStr) << S(L"gorilla!")
- /* 88 */ << H(TokValueTerminator)
- /* 89 */ << H(TokLine) << H(15)
- /* 91 */ << H(TokHashLiteral) << HS(L"MOO")
- /* 98 */ << H(TokAssign) << H(0)
- /* 100 */ << H(TokLiteral | TokNewStr) << S(L"kuh")
- /* 105 */ << H(TokValueTerminator)
- /* 106 */ << H(TokLine) << H(17)
- /* 108 */ << H(TokHashLiteral) << HS(L"LOO")
- /* 115 */ << H(TokAssign) << H(0)
- /* 117 */ << H(TokValueTerminator)
- /* 118 */ << H(TokLine) << H(19)
- /* 120 */ << H(TokHashLiteral) << HS(L"FOO")
- /* 127 */ << H(TokAssign) << H(2)
- /* 129 */ << H(TokLiteral | TokNewStr) << S(L"bar")
- /* 134 */ << H(TokLiteral | TokNewStr) << S(L"baz")
- /* 139 */ << H(TokValueTerminator)
- /* 140 */ << H(TokLine) << H(24)
- /* 142 */ << H(TokHashLiteral) << HS(L"GAZ")
- /* 149 */ << H(TokAssign) << H(0)
- /* 151 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("accidental continuation")
- << "VAR0 = \\\n this \\\n is \\\n ok\n"
- "VAR1 = \\\n this \\\n is=still \\\n ok\n"
- "VAR2 = \\\n this \\\n is \\\n"
- "VAR3 = \\\n not ok\n"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"VAR0")
- /* 10 */ << H(TokAssign) << H(3)
- /* 12 */ << H(TokLiteral | TokNewStr) << S(L"this")
- /* 18 */ << H(TokLiteral | TokNewStr) << S(L"is")
- /* 22 */ << H(TokLiteral | TokNewStr) << S(L"ok")
- /* 26 */ << H(TokValueTerminator)
- /* 27 */ << H(TokLine) << H(5)
- /* 29 */ << H(TokHashLiteral) << HS(L"VAR1")
- /* 37 */ << H(TokAssign) << H(3)
- /* 39 */ << H(TokLiteral | TokNewStr) << S(L"this")
- /* 45 */ << H(TokLiteral | TokNewStr) << S(L"is=still")
- /* 55 */ << H(TokLiteral | TokNewStr) << S(L"ok")
- /* 59 */ << H(TokValueTerminator)
- /* 60 */ << H(TokLine) << H(9)
- /* 62 */ << H(TokHashLiteral) << HS(L"VAR2")
- /* 70 */ << H(TokAssign) << H(6)
- /* 72 */ << H(TokLiteral | TokNewStr) << S(L"this")
- /* 78 */ << H(TokLiteral | TokNewStr) << S(L"is")
- /* 82 */ << H(TokLiteral | TokNewStr) << S(L"VAR3")
- /* 88 */ << H(TokLiteral | TokNewStr) << S(L"=")
- /* 91 */ << H(TokLiteral | TokNewStr) << S(L"not")
- /* 96 */ << H(TokLiteral | TokNewStr) << S(L"ok")
- /* 100 */ << H(TokValueTerminator))
- << "WARNING: in:12: Possible accidental line continuation"
- << true;
-
- QTest::newRow("plain variable expansion")
- << "VAR = $$bar"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokVariable | TokNewStr) << HS(L"bar")
- /* 18 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("braced variable expansion")
- << "VAR = $${foo/bar}"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokVariable | TokNewStr) << HS(L"foo/bar")
- /* 22 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("bogus variable expansion")
- << "VAR = $$ "
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokVariable | TokNewStr) << HS(L"")
- /* 15 */ << H(TokValueTerminator))
- << "WARNING: in:1: Missing name in expansion"
- << true;
-
- QTest::newRow("bogus braced variable expansion")
- << "VAR = $${}"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokVariable | TokNewStr) << HS(L"")
- /* 15 */ << H(TokValueTerminator))
- << "WARNING: in:1: Missing name in expansion"
- << true;
-
- QTest::newRow("unterminated braced variable expansion")
- << "VAR = $${FOO"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 9 */ << H(TokAssign) << H(0)
- /* 11 */ << H(TokVariable | TokNewStr) << HS(L"FOO")
- /* 18 */ << H(TokValueTerminator))
- << "in:1: Missing } terminator [found end-of-line]"
- << false;
-
- QTest::newRow("invalid identifier in braced variable expansion")
- << "VAR = $${FOO/BAR+BAZ}"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 9 */ << H(TokAssign) << H(0)
- /* 11 */ << H(TokVariable | TokNewStr) << HS(L"FOO/BAR")
- /* 22 */ << H(TokLiteral) << S(L"+BAZ")
- /* 28 */ << H(TokValueTerminator))
- << "in:1: Missing } terminator [found +]"
- << false;
-
- QTest::newRow("property expansion")
- << "VAR = $$[bar]"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokProperty | TokNewStr) << HS(L"bar")
- /* 18 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("environment expansion")
- << "VAR = $$(bar)"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokEnvVar | TokNewStr) << S(L"bar")
- /* 16 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("plain function call")
- << "VAR = $$bar()"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokFuncName | TokNewStr) << HS(L"bar")
- /* 18 */ << H(TokFuncTerminator)
- /* 19 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("braced function call")
- << "VAR = $${bar()}"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokFuncName | TokNewStr) << HS(L"bar")
- /* 18 */ << H(TokFuncTerminator)
- /* 19 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("function call with one argument")
- << "VAR = $$bar(blubb)"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokFuncName | TokNewStr) << HS(L"bar")
- /* 18 */ << H(TokLiteral | TokNewStr) << S(L"blubb")
- /* 25 */ << H(TokFuncTerminator)
- /* 26 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("function call with multiple arguments")
- << "VAR = $$bar( blubb blubb, hey ,$$you)"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokFuncName | TokNewStr) << HS(L"bar")
- /* 18 */ << H(TokLiteral | TokNewStr) << S(L"blubb")
- /* 25 */ << H(TokLiteral | TokNewStr) << S(L"blubb")
- /* 32 */ << H(TokArgSeparator)
- /* 33 */ << H(TokLiteral | TokNewStr) << S(L"hey")
- /* 38 */ << H(TokArgSeparator)
- /* 39 */ << H(TokVariable | TokNewStr) << HS(L"you")
- /* 46 */ << H(TokFuncTerminator)
- /* 47 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("nested function call")
- << "VAR = $$foo(yo, $$bar(blubb))"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokFuncName | TokNewStr) << HS(L"foo")
- /* 18 */ << H(TokLiteral | TokNewStr) << S(L"yo")
- /* 22 */ << H(TokArgSeparator)
- /* 23 */ << H(TokFuncName | TokNewStr) << HS(L"bar")
- /* 30 */ << H(TokLiteral | TokNewStr) << S(L"blubb")
- /* 37 */ << H(TokFuncTerminator)
- /* 38 */ << H(TokFuncTerminator)
- /* 39 */ << H(TokValueTerminator))
- << ""
- << true;
-
- // This is a rather questionable "feature"
- QTest::newRow("function call with parenthesized argument")
- << "VAR = $$bar(blubb (yo, man) blabb, nope)"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokFuncName | TokNewStr) << HS(L"bar")
- /* 18 */ << H(TokLiteral | TokNewStr) << S(L"blubb")
- /* 25 */ << H(TokLiteral | TokNewStr) << S(L"(yo,")
- /* 31 */ << H(TokLiteral | TokNewStr) << S(L"man)")
- /* 37 */ << H(TokLiteral | TokNewStr) << S(L"blabb")
- /* 44 */ << H(TokArgSeparator)
- /* 45 */ << H(TokLiteral | TokNewStr) << S(L"nope")
- /* 51 */ << H(TokFuncTerminator)
- /* 52 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("separate literal and expansion")
- << "VAR = foo $$bar"
- << TS(
- /* 0 */ << ASSIGN_VAR(2)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
- /* 16 */ << H(TokVariable | TokNewStr) << HS(L"bar")
- /* 23 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("separate expansion and literal")
- << "VAR = $$bar foo"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokVariable | TokNewStr) << HS(L"bar")
- /* 18 */ << H(TokLiteral | TokNewStr) << S(L"foo")
- /* 23 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("joined literal and expansion")
- << "VAR = foo$$bar"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
- /* 16 */ << H(TokVariable) << HS(L"bar")
- /* 23 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("joined expansion and literal")
- << "VAR = $${bar}foo"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokVariable | TokNewStr) << HS(L"bar")
- /* 18 */ << H(TokLiteral) << S(L"foo")
- /* 23 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("plain variable expansion with funny name and literal")
- << "VAR = $$az_AZ_09.dot/nix"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokVariable | TokNewStr) << HS(L"az_AZ_09.dot")
- /* 27 */ << H(TokLiteral) << S(L"/nix")
- /* 33 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("braced variable expansion with funny name")
- << "VAR = $${az_AZ_09.dot/nix}"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokVariable | TokNewStr) << HS(L"az_AZ_09.dot/nix")
- /* 31 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("quoted joined literal and expansion")
- << "VAR = 'foo$$bar'"
- << TS(
- /* 0 */ << ASSIGN_VAR(0)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"foo")
- /* 16 */ << H(TokVariable | TokQuoted) << HS(L"bar")
- /* 23 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("assignment with expansion in variable name")
- << "VAR$$EXTRA ="
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 9 */ << H(TokVariable) << HS(L"EXTRA")
- /* 18 */ << H(TokAssign) << H(0)
- /* 20 */ << H(TokValueTerminator))
- << ""
- << true;
-
- // Conditionals ("Tests")
-
- QTest::newRow("one test")
- << "foo"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition))
- << ""
- << true;
-
- QTest::newRow("wildcard-test")
- << "foo-*"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo-*")
- /* 11 */ << H(TokCondition))
- << ""
- << true;
-
- // This is a rather questionable "feature"
- QTest::newRow("one quoted test")
- << "\"foo\""
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition))
- << ""
- << true;
-
- QTest::newRow("two tests")
- << "foo\nbar"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition)
- /* 10 */ << H(TokLine) << H(2)
- /* 12 */ << H(TokHashLiteral) << HS(L"bar")
- /* 19 */ << H(TokCondition))
- << ""
- << true;
-
- QTest::newRow("bogus two tests")
- << "foo bar\nbaz"
- << TS()
- << "in:1: Extra characters after test expression."
- << false;
-
- QTest::newRow("test-AND-test")
- << "foo:bar"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition)
- /* 10 */ << H(TokAnd)
- /* 11 */ << H(TokHashLiteral) << HS(L"bar")
- /* 18 */ << H(TokCondition))
- << ""
- << true;
-
- QTest::newRow("test-OR-test")
- << " foo | bar "
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition)
- /* 10 */ << H(TokOr)
- /* 11 */ << H(TokHashLiteral) << HS(L"bar")
- /* 18 */ << H(TokCondition))
- << ""
- << true;
-
- QTest::newRow("NOT-test")
- << "!foo"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokNot)
- /* 3 */ << H(TokHashLiteral) << HS(L"foo")
- /* 10 */ << H(TokCondition))
- << ""
- << true;
-
- QTest::newRow("NOT-NOT-test")
- << "!!foo"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition))
- << ""
- << true;
-
- // This is a rather questionable "feature"
- QTest::newRow("quoted-NOT-test")
- << "\"!foo\""
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokNot)
- /* 3 */ << H(TokHashLiteral) << HS(L"foo")
- /* 10 */ << H(TokCondition))
- << ""
- << true;
-
- // This is a rather questionable "feature"
- QTest::newRow("NOT-quoted-test")
- << "!\"foo\""
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokNot)
- /* 3 */ << H(TokHashLiteral) << HS(L"foo")
- /* 10 */ << H(TokCondition))
- << ""
- << true;
-
- QTest::newRow("test-AND-NOT-test")
- << "foo:!bar"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition)
- /* 10 */ << H(TokAnd)
- /* 11 */ << H(TokNot)
- /* 12 */ << H(TokHashLiteral) << HS(L"bar")
- /* 19 */ << H(TokCondition))
- << ""
- << true;
-
- QTest::newRow("test-assignment")
- << "foo\nVAR="
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition)
- /* 10 */ << H(TokLine) << H(2)
- /* 12 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 19 */ << H(TokAssign) << H(0)
- /* 21 */ << H(TokValueTerminator))
- << ""
- << true;
-
- QTest::newRow("test-AND-assignment")
- << "foo: VAR ="
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition)
- /* 10 */ << H(TokBranch)
- /* 11 */ /* then branch */ << I(11)
- /* 13 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 20 */ << H(TokAssign) << H(0)
- /* 22 */ << H(TokValueTerminator)
- /* 23 */ << H(TokTerminator)
- /* 24 */ /* else branch */ << I(0))
- << ""
- << true;
-
- QTest::newRow("test-else-test")
- << "foo\nelse: bar"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition)
- /* 10 */ << H(TokBranch)
- /* 11 */ /* then branch */ << I(0)
- /* 13 */ /* else branch */ << I(11)
- /* 15 */ << H(TokLine) << H(2)
- /* 17 */ << H(TokHashLiteral) << HS(L"bar")
- /* 24 */ << H(TokCondition)
- /* 25 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("function-else-test")
- << "foo()\nelse: bar"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokTestCall)
- /* 10 */ << H(TokFuncTerminator)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(0)
- /* 14 */ /* else branch */ << I(11)
- /* 16 */ << H(TokLine) << H(2)
- /* 18 */ << H(TokHashLiteral) << HS(L"bar")
- /* 25 */ << H(TokCondition)
- /* 26 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("test-AND-test-else-test")
- << "foo:bar\nelse: baz"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition)
- /* 10 */ << H(TokAnd)
- /* 11 */ << H(TokHashLiteral) << HS(L"bar")
- /* 18 */ << H(TokCondition)
- /* 19 */ << H(TokBranch)
- /* 20 */ /* then branch */ << I(0)
- /* 22 */ /* else branch */ << I(11)
- /* 24 */ << H(TokLine) << H(2)
- /* 26 */ << H(TokHashLiteral) << HS(L"baz")
- /* 33 */ << H(TokCondition)
- /* 34 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("test-AND-test-else-test-else-test-function")
- << "foo:bar\nelse: baz\nelse: bak\nbuzz()"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition)
- /* 10 */ << H(TokAnd)
- /* 11 */ << H(TokHashLiteral) << HS(L"bar")
- /* 18 */ << H(TokCondition)
- /* 19 */ << H(TokBranch)
- /* 20 */ /* then branch */ << I(0)
- /* 22 */ /* else branch */ << I(27)
- /* 24 */ << H(TokLine) << H(2)
- /* 26 */ << H(TokHashLiteral) << HS(L"baz")
- /* 33 */ << H(TokCondition)
- /* 34 */ << H(TokBranch)
- /* 35 */ /* then branch */ << I(0)
- /* 37 */ /* else branch */ << I(11)
- /* 39 */ << H(TokLine) << H(3)
- /* 41 */ << H(TokHashLiteral) << HS(L"bak")
- /* 48 */ << H(TokCondition)
- /* 49 */ << H(TokTerminator)
- /* 50 */ << H(TokTerminator)
- /* 51 */ << H(TokLine) << H(4)
- /* 53 */ << H(TokHashLiteral) << HS(L"buzz")
- /* 61 */ << H(TokTestCall)
- /* 62 */ << H(TokFuncTerminator))
- << ""
- << true;
-
- QTest::newRow("test-assignment-else-assignment")
- << "foo: VAR =\nelse: VAR="
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition)
- /* 10 */ << H(TokBranch)
- /* 11 */ /* then branch */ << I(11)
- /* 13 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 20 */ << H(TokAssign) << H(0)
- /* 22 */ << H(TokValueTerminator)
- /* 23 */ << H(TokTerminator)
- /* 24 */ /* else branch */ << I(13)
- /* 26 */ << H(TokLine) << H(2)
- /* 28 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 35 */ << H(TokAssign) << H(0)
- /* 37 */ << H(TokValueTerminator)
- /* 38 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("test-else-test-assignment")
- << "foo\nelse: bar: VAR ="
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition)
- /* 10 */ << H(TokBranch)
- /* 11 */ /* then branch */ << I(0)
- /* 13 */ /* else branch */ << I(27)
- /* 15 */ << H(TokLine) << H(2)
- /* 17 */ << H(TokHashLiteral) << HS(L"bar")
- /* 24 */ << H(TokCondition)
- /* 25 */ << H(TokBranch)
- /* 26 */ /* then branch */ << I(11)
- /* 28 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 35 */ << H(TokAssign) << H(0)
- /* 37 */ << H(TokValueTerminator)
- /* 38 */ << H(TokTerminator)
- /* 39 */ /* else branch */ << I(0)
- /* 41 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("one function")
- << "foo()"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokTestCall)
- /* 10 */ << H(TokFuncTerminator))
- << ""
- << true;
-
- QTest::newRow("one function (with spaces)")
- << " foo( ) "
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokTestCall)
- /* 10 */ << H(TokFuncTerminator))
- << ""
- << true;
-
- QTest::newRow("unterminated function call")
- << "foo(\nfoo"
- << TS()
- << "in:1: Missing closing parenthesis in function call"
- << false;
-
- QTest::newRow("function with arguments")
- << "foo(blah, hi ho)"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokTestCall)
- /* 10 */ << H(TokLiteral | TokNewStr) << S(L"blah")
- /* 16 */ << H(TokArgSeparator)
- /* 17 */ << H(TokLiteral | TokNewStr) << S(L"hi")
- /* 21 */ << H(TokLiteral | TokNewStr) << S(L"ho")
- /* 25 */ << H(TokFuncTerminator))
- << ""
- << true;
-
- QTest::newRow("function with empty arguments")
- << "foo(,)"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokTestCall)
- /* 10 */ << H(TokArgSeparator)
- /* 11 */ << H(TokFuncTerminator))
- << ""
- << true;
-
- QTest::newRow("function with funny arguments")
- << "foo(blah\\, \"hi , \\ho\" ,uh\\ ,\\oh ,, )"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokTestCall)
- /* 10 */ << H(TokLiteral | TokNewStr) << S(L"blah\\")
- /* 17 */ << H(TokArgSeparator)
- /* 18 */ << H(TokLiteral | TokNewStr) << S(L"hi , \\ho")
- /* 29 */ << H(TokArgSeparator)
- /* 30 */ << H(TokLiteral | TokNewStr) << S(L"uh\\")
- /* 35 */ << H(TokArgSeparator)
- /* 36 */ << H(TokLiteral | TokNewStr) << S(L"\\oh")
- /* 41 */ << H(TokArgSeparator)
- /* 42 */ << H(TokArgSeparator)
- /* 43 */ << H(TokFuncTerminator))
- << "WARNING: in:1: Unescaped backslashes are deprecated\n"
- "WARNING: in:1: Unescaped backslashes are deprecated\n"
- "WARNING: in:1: Unescaped backslashes are deprecated\n"
- "WARNING: in:1: Unescaped backslashes are deprecated"
- << true;
-
- QTest::newRow("function with nested call")
- << "foo($$blah(hi ho))"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokTestCall)
- /* 10 */ << H(TokFuncName | TokNewStr) << HS(L"blah")
- /* 18 */ << H(TokLiteral | TokNewStr) << S(L"hi")
- /* 22 */ << H(TokLiteral | TokNewStr) << S(L"ho")
- /* 26 */ << H(TokFuncTerminator)
- /* 27 */ << H(TokFuncTerminator))
- << ""
- << true;
-
- QTest::newRow("stand-alone parentheses")
- << "()"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokTestCall)
- /* 3 */ << H(TokFuncTerminator))
- << "in:1: Opening parenthesis without prior test name."
- << false;
-
- QTest::newRow("bogus test and function")
- << "foo bar()"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokTestCall)
- /* 3 */ << H(TokFuncTerminator))
- << "in:1: Extra characters after test expression."
- << false;
-
- // This is a rather questionable "feature"
- QTest::newRow("two functions")
- << "foo() bar()"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokTestCall)
- /* 10 */ << H(TokFuncTerminator)
- /* 11 */ << H(TokHashLiteral) << HS(L"bar")
- /* 18 */ << H(TokTestCall)
- /* 19 */ << H(TokFuncTerminator))
- << ""
- << true;
-
- QTest::newRow("function-AND-test")
- << "foo():bar"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokTestCall)
- /* 10 */ << H(TokFuncTerminator)
- /* 11 */ << H(TokAnd)
- /* 12 */ << H(TokHashLiteral) << HS(L"bar")
- /* 19 */ << H(TokCondition))
- << ""
- << true;
-
- QTest::newRow("test-AND-function")
- << "foo:bar()"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition)
- /* 10 */ << H(TokAnd)
- /* 11 */ << H(TokHashLiteral) << HS(L"bar")
- /* 18 */ << H(TokTestCall)
- /* 19 */ << H(TokFuncTerminator))
- << ""
- << true;
-
- QTest::newRow("NOT-function-AND-test")
- << "!foo():bar"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokNot)
- /* 3 */ << H(TokHashLiteral) << HS(L"foo")
- /* 10 */ << H(TokTestCall)
- /* 11 */ << H(TokFuncTerminator)
- /* 12 */ << H(TokAnd)
- /* 13 */ << H(TokHashLiteral) << HS(L"bar")
- /* 20 */ << H(TokCondition))
- << ""
- << true;
-
- QTest::newRow("test-AND-NOT-function")
- << "foo:!bar()"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"foo")
- /* 9 */ << H(TokCondition)
- /* 10 */ << H(TokAnd)
- /* 11 */ << H(TokNot)
- /* 12 */ << H(TokHashLiteral) << HS(L"bar")
- /* 19 */ << H(TokTestCall)
- /* 20 */ << H(TokFuncTerminator))
- << ""
- << true;
-
- // Control statements
-
- QTest::newRow("for(VAR, LIST) loop")
- << "for(VAR, LIST)"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokForLoop) << HS(L"VAR")
- /* 9 */ /* iterator */ << I(7)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"LIST")
- /* 17 */ << H(TokValueTerminator)
- /* 18 */ /* body */ << I(1)
- /* 20 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("for(ever) loop")
- << "for(ever)"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokForLoop) << HS(L"")
- /* 6 */ /* iterator */ << I(9)
- /* 8 */ << H(TokHashLiteral) << HS(L"ever")
- /* 16 */ << H(TokValueTerminator)
- /* 17 */ /* body */ << I(1)
- /* 19 */ << H(TokTerminator))
- << ""
- << true;
-
- // This is a rather questionable "feature"
- QTest::newRow("for($$blub) loop")
- << "for($$blub)"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokForLoop) << HS(L"")
- /* 6 */ /* iterator */ << I(9)
- /* 8 */ << H(TokVariable | TokNewStr) << HS(L"blub")
- /* 16 */ << H(TokValueTerminator)
- /* 17 */ /* body */ << I(1)
- /* 19 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("test-for-test-else-test")
- << "true:for(VAR, LIST): true\nelse: true"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(31)
- /* 14 */ << H(TokForLoop) << HS(L"VAR")
- /* 21 */ /* iterator */ << I(7)
- /* 23 */ << H(TokLiteral | TokNewStr) << S(L"LIST")
- /* 29 */ << H(TokValueTerminator)
- /* 30 */ /* body */ << I(12)
- /* 32 */ << H(TokLine) << H(1)
- /* 34 */ << H(TokHashLiteral) << HS(L"true")
- /* 42 */ << H(TokCondition)
- /* 43 */ << H(TokTerminator)
- /* 44 */ << H(TokTerminator)
- /* 45 */ /* else branch */ << I(12)
- /* 47 */ << H(TokLine) << H(2)
- /* 49 */ << H(TokHashLiteral) << HS(L"true")
- /* 57 */ << H(TokCondition)
- /* 58 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("next()")
- << "for(ever): next()"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokForLoop) << HS(L"")
- /* 6 */ /* iterator */ << I(9)
- /* 8 */ << H(TokHashLiteral) << HS(L"ever")
- /* 16 */ << H(TokValueTerminator)
- /* 17 */ /* body */ << I(4)
- /* 19 */ << H(TokLine) << H(1)
- /* 21 */ << H(TokNext)
- /* 22 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("break()")
- << "for(ever): break()"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokForLoop) << HS(L"")
- /* 6 */ /* iterator */ << I(9)
- /* 8 */ << H(TokHashLiteral) << HS(L"ever")
- /* 16 */ << H(TokValueTerminator)
- /* 17 */ /* body */ << I(4)
- /* 19 */ << H(TokLine) << H(1)
- /* 21 */ << H(TokBreak)
- /* 22 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("top-level return()")
- << "return()"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokReturn))
- << ""
- << true;
-
- QTest::newRow("else")
- << "else"
- << TS()
- << "in:1: Unexpected 'else'."
- << false;
-
- QTest::newRow("test-{else}")
- << "test { else }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"test")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(1)
- /* 14 */ << H(TokTerminator)
- /* 15 */ /* else branch */ << I(0))
- << "in:1: Unexpected 'else'."
- << false;
-
- QTest::newRow("defineTest-{else}")
- << "defineTest(fn) { else }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokTestDef) << HS(L"fn")
- /* 8 */ /* body */ << I(1)
- /* 10 */ << H(TokTerminator))
- << "in:1: Unexpected 'else'."
- << false;
-
- QTest::newRow("for-else")
- << "for(ever) { else }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokForLoop) << HS(L"")
- /* 6 */ /* iterator */ << I(9)
- /* 8 */ << H(TokHashLiteral) << HS(L"ever")
- /* 16 */ << H(TokValueTerminator)
- /* 17 */ /* body */ << I(1)
- /* 19 */ << H(TokTerminator))
- << "in:1: Unexpected 'else'."
- << false;
-
- // Braces
-
- QTest::newRow("{}")
- << "{ }"
- << TS()
- << ""
- << true;
-
- QTest::newRow("{}-newlines")
- << "\n\n{ }\n\n"
- << TS()
- << ""
- << true;
-
- QTest::newRow("{")
- << "{"
- << TS()
- << "in:2: Missing closing brace(s)."
- << false;
-
- QTest::newRow("test {")
- << "test {"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"test")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(1)
- /* 14 */ << H(TokTerminator)
- /* 15 */ /* else branch */ << I(0))
- << "in:2: Missing closing brace(s)."
- << false;
-
- QTest::newRow("}")
- << "}"
- << TS()
- << "in:1: Excess closing brace."
- << false;
-
- QTest::newRow("{test}")
- << "{ true }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition))
- << ""
- << true;
-
- QTest::newRow("{test-newlines}")
- << "{\ntrue\n}"
- << TS(
- /* 0 */ << H(TokLine) << H(2)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition))
- << ""
- << true;
-
- QTest::newRow("{assignment-test}-test")
- << "{ VAR = { foo } bar } true"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 9 */ << H(TokAssign) << H(4)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"{")
- /* 14 */ << H(TokLiteral | TokNewStr) << S(L"foo")
- /* 19 */ << H(TokLiteral | TokNewStr) << S(L"}")
- /* 22 */ << H(TokLiteral | TokNewStr) << S(L"bar")
- /* 27 */ << H(TokValueTerminator)
- /* 28 */ << H(TokHashLiteral) << HS(L"true")
- /* 36 */ << H(TokCondition))
- << ""
- << true;
-
- QTest::newRow("assignment with excess opening brace")
- << "VAR = { { foo }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 9 */ << H(TokAssign) << H(4)
- /* 11 */ << H(TokLiteral | TokNewStr) << S(L"{")
- /* 14 */ << H(TokLiteral | TokNewStr) << S(L"{")
- /* 17 */ << H(TokLiteral | TokNewStr) << S(L"foo")
- /* 22 */ << H(TokLiteral | TokNewStr) << S(L"}")
- /* 25 */ << H(TokValueTerminator))
- << "WARNING: in:1: Possible braces mismatch"
- << true;
-
- QTest::newRow("test-{}")
- << "true {}"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(1)
- /* 14 */ << H(TokTerminator)
- /* 15 */ /* else branch */ << I(0))
- << ""
- << true;
-
- QTest::newRow("test-{newlines}")
- << "true {\n}"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(1)
- /* 14 */ << H(TokTerminator)
- /* 15 */ /* else branch */ << I(0))
- << ""
- << true;
-
- QTest::newRow("test-{test}")
- << "true { true }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(10)
- /* 14 */ << H(TokHashLiteral) << HS(L"true")
- /* 22 */ << H(TokCondition)
- /* 23 */ << H(TokTerminator)
- /* 24 */ /* else branch */ << I(0))
- << ""
- << true;
-
- QTest::newRow("test:-{test}")
- << "true: { true }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(10)
- /* 14 */ << H(TokHashLiteral) << HS(L"true")
- /* 22 */ << H(TokCondition)
- /* 23 */ << H(TokTerminator)
- /* 24 */ /* else branch */ << I(0))
- << "WARNING: in:1: Excess colon in front of opening brace."
- << true;
-
- QTest::newRow("test-{test-newlines}")
- << "true {\ntrue\n}"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(12)
- /* 14 */ << H(TokLine) << H(2)
- /* 16 */ << H(TokHashLiteral) << HS(L"true")
- /* 24 */ << H(TokCondition)
- /* 25 */ << H(TokTerminator)
- /* 26 */ /* else branch */ << I(0))
- << ""
- << true;
-
- QTest::newRow("test:-{test-newlines}")
- << "true: {\ntrue\n}"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(12)
- /* 14 */ << H(TokLine) << H(2)
- /* 16 */ << H(TokHashLiteral) << HS(L"true")
- /* 24 */ << H(TokCondition)
- /* 25 */ << H(TokTerminator)
- /* 26 */ /* else branch */ << I(0))
- << "WARNING: in:1: Excess colon in front of opening brace."
- << true;
-
- QTest::newRow("test-{assignment}")
- << "true { VAR = {foo} }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(18)
- /* 14 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 21 */ << H(TokAssign) << H(0)
- /* 23 */ << H(TokLiteral | TokNewStr) << S(L"{foo}")
- /* 30 */ << H(TokValueTerminator)
- /* 31 */ << H(TokTerminator)
- /* 32 */ /* else branch */ << I(0))
- << ""
- << true;
-
- QTest::newRow("test-{test-assignment}")
- << "true { true: VAR = {foo} }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(33)
- /* 14 */ << H(TokHashLiteral) << HS(L"true")
- /* 22 */ << H(TokCondition)
- /* 23 */ << H(TokBranch)
- /* 24 */ /* then branch */ << I(18)
- /* 26 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 33 */ << H(TokAssign) << H(0)
- /* 35 */ << H(TokLiteral | TokNewStr) << S(L"{foo}")
- /* 42 */ << H(TokValueTerminator)
- /* 43 */ << H(TokTerminator)
- /* 44 */ /* else branch */ << I(0)
- /* 46 */ << H(TokTerminator)
- /* 47 */ /* else branch */ << I(0))
- << ""
- << true;
-
- QTest::newRow("test-{assignment-newlines}")
- << "true {\nVAR = {foo}\n}"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(20)
- /* 14 */ << H(TokLine) << H(2)
- /* 16 */ << H(TokHashLiteral) << HS(L"VAR")
- /* 23 */ << H(TokAssign) << H(0)
- /* 25 */ << H(TokLiteral | TokNewStr) << S(L"{foo}")
- /* 32 */ << H(TokValueTerminator)
- /* 33 */ << H(TokTerminator)
- /* 34 */ /* else branch */ << I(0))
- << ""
- << true;
-
- QTest::newRow("test-{}-else-test-{}")
- << "true {} else: true {}"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(1)
- /* 14 */ << H(TokTerminator)
- /* 15 */ /* else branch */ << I(18)
- /* 17 */ << H(TokLine) << H(1)
- /* 19 */ << H(TokHashLiteral) << HS(L"true")
- /* 27 */ << H(TokCondition)
- /* 28 */ << H(TokBranch)
- /* 29 */ /* then branch */ << I(1)
- /* 31 */ << H(TokTerminator)
- /* 32 */ /* else branch */ << I(0)
- /* 34 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("test-{}-else-test-{}-newlines")
- << "true {\n}\nelse: true {\n}"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(1)
- /* 14 */ << H(TokTerminator)
- /* 15 */ /* else branch */ << I(18)
- /* 17 */ << H(TokLine) << H(3)
- /* 19 */ << H(TokHashLiteral) << HS(L"true")
- /* 27 */ << H(TokCondition)
- /* 28 */ << H(TokBranch)
- /* 29 */ /* then branch */ << I(1)
- /* 31 */ << H(TokTerminator)
- /* 32 */ /* else branch */ << I(0)
- /* 34 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("test-{test}-else-test-{}-newlines")
- << "true {\ntrue\n}\nelse: true {\n}"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(12)
- /* 14 */ << H(TokLine) << H(2)
- /* 16 */ << H(TokHashLiteral) << HS(L"true")
- /* 24 */ << H(TokCondition)
- /* 25 */ << H(TokTerminator)
- /* 26 */ /* else branch */ << I(18)
- /* 28 */ << H(TokLine) << H(4)
- /* 30 */ << H(TokHashLiteral) << HS(L"true")
- /* 38 */ << H(TokCondition)
- /* 39 */ << H(TokBranch)
- /* 40 */ /* then branch */ << I(1)
- /* 42 */ << H(TokTerminator)
- /* 43 */ /* else branch */ << I(0)
- /* 45 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("for-{next}")
- << "for(ever) { next() }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokForLoop) << HS(L"")
- /* 6 */ /* iterator */ << I(9)
- /* 8 */ << H(TokHashLiteral) << HS(L"ever")
- /* 16 */ << H(TokValueTerminator)
- /* 17 */ /* body */ << I(4)
- /* 19 */ << H(TokLine) << H(1)
- /* 21 */ << H(TokNext)
- /* 22 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("for:-{next}")
- << "for(ever): { next() }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokForLoop) << HS(L"")
- /* 6 */ /* iterator */ << I(9)
- /* 8 */ << H(TokHashLiteral) << HS(L"ever")
- /* 16 */ << H(TokValueTerminator)
- /* 17 */ /* body */ << I(4)
- /* 19 */ << H(TokLine) << H(1)
- /* 21 */ << H(TokNext)
- /* 22 */ << H(TokTerminator))
- << "WARNING: in:1: Excess colon in front of opening brace."
- << true;
-
- QTest::newRow("test-for-{test-else-test-newlines}")
- << "true:for(VAR, LIST) {\ntrue\nelse: true\n}"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(48)
- /* 14 */ << H(TokForLoop) << HS(L"VAR")
- /* 21 */ /* iterator */ << I(7)
- /* 23 */ << H(TokLiteral | TokNewStr) << S(L"LIST")
- /* 29 */ << H(TokValueTerminator)
- /* 30 */ /* body */ << I(29)
- /* 32 */ << H(TokLine) << H(2)
- /* 34 */ << H(TokHashLiteral) << HS(L"true")
- /* 42 */ << H(TokCondition)
- /* 43 */ << H(TokBranch)
- /* 44 */ /* then branch */ << I(0)
- /* 46 */ /* else branch */ << I(12)
- /* 48 */ << H(TokLine) << H(3)
- /* 50 */ << H(TokHashLiteral) << HS(L"true")
- /* 58 */ << H(TokCondition)
- /* 59 */ << H(TokTerminator)
- /* 60 */ << H(TokTerminator)
- /* 61 */ << H(TokTerminator)
- /* 62 */ /* else branch */ << I(0))
- << ""
- << true;
-
- QTest::newRow("test-for-{test-else-test}")
- << "true:for(VAR, LIST) { true\nelse: true }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"true")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(48)
- /* 14 */ << H(TokForLoop) << HS(L"VAR")
- /* 21 */ /* iterator */ << I(7)
- /* 23 */ << H(TokLiteral | TokNewStr) << S(L"LIST")
- /* 29 */ << H(TokValueTerminator)
- /* 30 */ /* body */ << I(29)
- /* 32 */ << H(TokLine) << H(1)
- /* 34 */ << H(TokHashLiteral) << HS(L"true")
- /* 42 */ << H(TokCondition)
- /* 43 */ << H(TokBranch)
- /* 44 */ /* then branch */ << I(0)
- /* 46 */ /* else branch */ << I(12)
- /* 48 */ << H(TokLine) << H(2)
- /* 50 */ << H(TokHashLiteral) << HS(L"true")
- /* 58 */ << H(TokCondition)
- /* 59 */ << H(TokTerminator)
- /* 60 */ << H(TokTerminator)
- /* 61 */ << H(TokTerminator)
- /* 62 */ /* else branch */ << I(0))
- << ""
- << true;
-
- // Custom functions
-
- QTest::newRow("defineTest-{newlines}")
- << "defineTest(test) {\n}"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokTestDef) << HS(L"test")
- /* 10 */ /* body */ << I(1)
- /* 12 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("defineTest:-test")
- << "defineTest(test): test"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokTestDef) << HS(L"test")
- /* 10 */ /* body */ << I(12)
- /* 12 */ << H(TokLine) << H(1)
- /* 14 */ << H(TokHashLiteral) << HS(L"test")
- /* 22 */ << H(TokCondition)
- /* 23 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("defineTest-{test}")
- << "defineTest(test) { test }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokTestDef) << HS(L"test")
- /* 10 */ /* body */ << I(12)
- /* 12 */ << H(TokLine) << H(1)
- /* 14 */ << H(TokHashLiteral) << HS(L"test")
- /* 22 */ << H(TokCondition)
- /* 23 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("defineTest-{return}")
- << "defineTest(test) { return() }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokTestDef) << HS(L"test")
- /* 10 */ /* body */ << I(4)
- /* 12 */ << H(TokLine) << H(1)
- /* 14 */ << H(TokReturn)
- /* 15 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("defineReplace-{return-stuff}")
- << "defineReplace(stuff) { return(foo bar) }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokReplaceDef) << HS(L"stuff")
- /* 11 */ /* body */ << I(14)
- /* 13 */ << H(TokLine) << H(1)
- /* 15 */ << H(TokLiteral | TokNewStr) << S(L"foo")
- /* 20 */ << H(TokLiteral | TokNewStr) << S(L"bar")
- /* 25 */ << H(TokReturn)
- /* 26 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("test-AND-defineTest-{}")
- << "test: defineTest(test) {}"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"test")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokAnd)
- /* 12 */ << H(TokTestDef) << HS(L"test")
- /* 20 */ /* body */ << I(1)
- /* 22 */ << H(TokTerminator))
- << ""
- << true;
-
- QTest::newRow("test-OR-defineTest-{}")
- << "test| defineTest(test) {}"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"test")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokOr)
- /* 12 */ << H(TokTestDef) << HS(L"test")
- /* 20 */ /* body */ << I(1)
- /* 22 */ << H(TokTerminator))
- << ""
- << true;
-
- // Operator abuse
-
- QTest::newRow("!")
- << ""
- << TS()
- << ""
- << true;
-
- QTest::newRow("|")
- << ""
- << TS()
- << ""
- << true;
-
- QTest::newRow(":")
- << ""
- << TS()
- << ""
- << true;
-
- QTest::newRow("NOT-assignment")
- << "!VAR ="
- << TS()
- << "in:1: Unexpected NOT operator in front of assignment."
- << false;
-
- QTest::newRow("NOT-{}")
- << "!{}"
- << TS()
- << "in:1: Unexpected NOT operator in front of opening brace."
- << false;
-
- QTest::newRow("NOT-else")
- << "test\n!else {}"
- << TS()
- << "in:2: Unexpected NOT operator in front of else."
- << false;
-
- QTest::newRow("NOT-for-{}")
- << "!for(ever) {}"
- << TS()
- << "in:1: Unexpected NOT operator in front of for()."
- << false;
-
- QTest::newRow("NOT-defineTest-{}")
- << "!defineTest(test) {}"
- << TS()
- << "in:1: Unexpected NOT operator in front of function definition."
- << false;
-
- QTest::newRow("AND-test")
- << ":test"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"test")
- /* 10 */ << H(TokCondition))
- << "in:1: AND operator without prior condition."
- << false;
-
- QTest::newRow("test-AND-else")
- << "test:else"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"test")
- /* 10 */ << H(TokCondition))
- << "in:1: Unexpected AND operator in front of else."
- << false;
-
- QTest::newRow("test-AND-AND-test")
- << "test::test"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"test")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokAnd)
- /* 12 */ << H(TokHashLiteral) << HS(L"test")
- /* 20 */ << H(TokCondition))
- << "WARNING: in:1: Stray AND operator in front of AND operator."
- << true;
-
- QTest::newRow("test-AND-OR-test")
- << "test:|test"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"test")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokOr)
- /* 12 */ << H(TokHashLiteral) << HS(L"test")
- /* 20 */ << H(TokCondition))
- << "WARNING: in:1: Stray AND operator in front of OR operator."
- << true;
-
- QTest::newRow("test-{AND-test}")
- << "test { :test }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"test")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(10)
- /* 14 */ << H(TokHashLiteral) << HS(L"test")
- /* 22 */ << H(TokCondition)
- /* 23 */ << H(TokTerminator)
- /* 24 */ /* else branch */ << I(0))
- << "in:1: AND operator without prior condition."
- << false;
-
- QTest::newRow("test-OR-assignment")
- << "foo| VAR ="
- << TS()
- << "in:1: Unexpected OR operator in front of assignment."
- << false;
-
- QTest::newRow("test-OR-{}")
- << "foo|{}"
- << TS()
- << "in:1: Unexpected OR operator in front of opening brace."
- << false;
-
- QTest::newRow("test-OR-for")
- << "foo|for(ever) {}"
- << TS()
- << "in:1: Unexpected OR operator in front of for()."
- << false;
-
- QTest::newRow("OR-test")
- << "|test"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"test")
- /* 10 */ << H(TokCondition))
- << "in:1: OR operator without prior condition."
- << false;
-
- QTest::newRow("test-OR-else")
- << "test|else"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"test")
- /* 10 */ << H(TokCondition))
- << "in:1: Unexpected OR operator in front of else."
- << false;
-
- QTest::newRow("test-OR-OR-test")
- << "test||test"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"test")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokOr)
- /* 12 */ << H(TokHashLiteral) << HS(L"test")
- /* 20 */ << H(TokCondition))
- << "WARNING: in:1: Stray OR operator in front of OR operator."
- << true;
-
- QTest::newRow("test-OR-AND-test")
- << "test|:test"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"test")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokAnd)
- /* 12 */ << H(TokHashLiteral) << HS(L"test")
- /* 20 */ << H(TokCondition))
- << "WARNING: in:1: Stray OR operator in front of AND operator."
- << true;
-
- QTest::newRow("test-{OR-test}")
- << "test { |test }"
- << TS(
- /* 0 */ << H(TokLine) << H(1)
- /* 2 */ << H(TokHashLiteral) << HS(L"test")
- /* 10 */ << H(TokCondition)
- /* 11 */ << H(TokBranch)
- /* 12 */ /* then branch */ << I(10)
- /* 14 */ << H(TokHashLiteral) << HS(L"test")
- /* 22 */ << H(TokCondition)
- /* 23 */ << H(TokTerminator)
- /* 24 */ /* else branch */ << I(0))
- << "in:1: OR operator without prior condition."
- << false;
-
- // option() (these produce no tokens)
-
- QTest::newRow("option(host_build)")
- << "option(host_build)"
- << TS()
- << ""
- << true;
-
- QTest::newRow("option()")
- << "option()"
- << TS()
- << "in:1: option() requires one literal argument."
- << false;
-
- QTest::newRow("option(host_build magic)")
- << "option(host_build magic)"
- << TS()
- << "in:1: option() requires one literal argument."
- << false;
-
- QTest::newRow("option(host_build, magic)")
- << "option(host_build, magic)"
- << TS()
- << "in:1: option() requires one literal argument."
- << false;
-
- QTest::newRow("option($$OPTION)")
- << "option($$OPTION)"
- << TS()
- << "in:1: option() requires one literal argument."
- << false;
-
- QTest::newRow("{option(host_build)}")
- << "{option(host_build)}"
- << TS()
- << "in:1: option() must appear outside any control structures."
- << false;
+ QString pfx = ((type & QMakeParserHandler::CategoryMask) == QMakeParserHandler::WarningMessage)
+ ? QString::fromLatin1("WARNING: ") : QString();
+ if (lineNo)
+ doPrint(QStringLiteral("%1%2:%3: %4").arg(pfx, fileName, QString::number(lineNo), msg));
+ else
+ doPrint(QStringLiteral("%1%2").arg(pfx, msg));
}
-void tst_qmakelib::proParser()
+void QMakeTestHandler::doPrint(const QString &msg)
{
- QFETCH(QString, in);
- QFETCH(QString, out);
- QFETCH(QString, msgs);
- QFETCH(bool, ok);
-
- bool verified = true;
- QMakeHandler handler;
- handler.setExpectedMessages(msgs.split('\n', QString::SkipEmptyParts));
- QMakeVfs vfs;
- QMakeParser parser(0, &vfs, &handler);
- ProFile *pro = parser.parsedProBlock(in, "in", 1, QMakeParser::FullGrammar);
- if (handler.printedMessages()) {
- qWarning("Got unexpected message(s)");
- verified = false;
- }
- QStringList missingMsgs = handler.expectedMessages();
- if (!missingMsgs.isEmpty()) {
- foreach (const QString &msg, missingMsgs)
- qWarning("Missing message: %s", qPrintable(msg));
- verified = false;
- }
- if (pro->isOk() != ok) {
- static const char * const lbl[] = { "failure", "success" };
- qWarning("Expected %s, got %s", lbl[int(ok)], lbl[1 - int(ok)]);
- verified = false;
- }
- if (pro->items() != out && (ok || !out.isEmpty())) {
- qWarning("Bytecode mismatch.\nActual:%s\nExpected:%s",
- qPrintable(QMakeParser::formatProBlock(pro->items())),
- qPrintable(QMakeParser::formatProBlock(out)));
- verified = false;
+ if (!expected.isEmpty() && expected.first() == msg) {
+ expected.removeAt(0);
+ } else {
+ qWarning("%s", qPrintable(msg));
+ printed = true;
}
- pro->deref();
- QVERIFY(verified);
}
QTEST_MAIN(tst_qmakelib)
-#include "tst_qmakelib.moc"
diff --git a/tests/auto/tools/qmakelib/tst_qmakelib.h b/tests/auto/tools/qmakelib/tst_qmakelib.h
new file mode 100644
index 0000000000..c4716ca65e
--- /dev/null
+++ b/tests/auto/tools/qmakelib/tst_qmakelib.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qmakeevaluator.h>
+
+#include <QObject>
+#include <QProcessEnvironment>
+#include <QtTest/QtTest>
+
+class tst_qmakelib : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_qmakelib() {}
+ virtual ~tst_qmakelib() {}
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void quoteArgUnix_data();
+ void quoteArgUnix();
+ void quoteArgWin_data();
+ void quoteArgWin();
+ void pathUtils();
+
+ void proString();
+ void proStringList();
+
+ void proParser_data();
+ void proParser();
+
+ void proEval_data();
+ void proEval();
+
+private:
+ void addParseOperators();
+ void addParseValues();
+ void addParseConditions();
+ void addParseControlStatements();
+ void addParseBraces();
+ void addParseCustomFunctions();
+ void addParseAbuse();
+
+ void addAssignments();
+ void addExpansions();
+ void addControlStructs();
+ void addReplaceFunctions(const QString &qindir);
+ void addTestFunctions(const QString &qindir);
+
+ QProcessEnvironment m_env;
+ QHash<ProKey, ProString> m_prop;
+ QString m_indir, m_outdir;
+};
+
+class QMakeTestHandler : public QMakeHandler {
+public:
+ QMakeTestHandler() : QMakeHandler(), printed(false) {}
+ virtual void message(int type, const QString &msg, const QString &fileName, int lineNo)
+ { print(fileName, lineNo, type, msg); }
+
+ virtual void fileMessage(const QString &msg)
+ { doPrint(msg); }
+
+ virtual void aboutToEval(ProFile *, ProFile *, EvalFileType) {}
+ virtual void doneWithEval(ProFile *) {}
+
+ void setExpectedMessages(const QStringList &msgs) { expected = msgs; }
+ QStringList expectedMessages() const { return expected; }
+
+ bool printedMessages() const { return printed; }
+
+private:
+ void print(const QString &fileName, int lineNo, int type, const QString &msg);
+ void doPrint(const QString &msg);
+
+ QStringList expected;
+ bool printed;
+};
+