summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/qmakelib/evaltest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/tools/qmakelib/evaltest.cpp')
-rw-r--r--tests/auto/tools/qmakelib/evaltest.cpp161
1 files changed, 159 insertions, 2 deletions
diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp
index aaa4bb3724..4cefa906d3 100644
--- a/tests/auto/tools/qmakelib/evaltest.cpp
+++ b/tests/auto/tools/qmakelib/evaltest.cpp
@@ -718,6 +718,49 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir)
<< "##:2: member() argument 2 (start) '4..foo' invalid."
<< true;
+ // The argument processing is shared with $$member(), so some tests are skipped.
+ QTest::newRow("$$str_member(): empty")
+ << "VAR = $$str_member()"
+ << "VAR ="
+ << ""
+ << true;
+
+ QTest::newRow("$$str_member(): too short")
+ << "VAR = $$str_member(string_value, 7, 12)"
+ << "VAR =" // this is actually kinda stupid
+ << ""
+ << true;
+
+ QTest::newRow("$$str_member(): ok")
+ << "VAR = $$str_member(string_value, 7, 11)"
+ << "VAR = value"
+ << ""
+ << true;
+
+ QTest::newRow("$$str_member(): ok (default start)")
+ << "VAR = $$str_member(string_value)"
+ << "VAR = s"
+ << ""
+ << true;
+
+ QTest::newRow("$$str_member(): ok (default end)")
+ << "VAR = $$str_member(string_value, 7)"
+ << "VAR = v"
+ << ""
+ << true;
+
+ QTest::newRow("$$str_member(): negative")
+ << "VAR = $$str_member(string_value, -5, -3)"
+ << "VAR = val"
+ << ""
+ << true;
+
+ QTest::newRow("$$str_member(): inverse")
+ << "VAR = $$str_member(string_value, -2, 1)"
+ << "VAR = ulav_gnirt"
+ << ""
+ << true;
+
QTest::newRow("$$first(): empty")
<< "IN = \nVAR = $$first(IN)"
<< "VAR ="
@@ -742,6 +785,30 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir)
<< "##:1: first(var) requires one argument."
<< true;
+ QTest::newRow("$$take_first(): empty")
+ << "IN = \nVAR = $$take_first(IN)"
+ << "VAR =\nIN ="
+ << ""
+ << true;
+
+ QTest::newRow("$$take_first(): one")
+ << "IN = one\nVAR = $$take_first(IN)"
+ << "VAR = one\nIN ="
+ << ""
+ << true;
+
+ QTest::newRow("$$take_first(): multiple")
+ << "IN = one two three\nVAR = $$take_first(IN)"
+ << "VAR = one\nIN = two three"
+ << ""
+ << true;
+
+ QTest::newRow("$$take_first(): bad number of arguments")
+ << "VAR = $$take_first(1, 2)"
+ << "VAR ="
+ << "##:1: take_first(var) requires one argument."
+ << true;
+
QTest::newRow("$$last(): empty")
<< "IN = \nVAR = $$last(IN)"
<< "VAR ="
@@ -766,6 +833,30 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir)
<< "##:1: last(var) requires one argument."
<< true;
+ QTest::newRow("$$take_last(): empty")
+ << "IN = \nVAR = $$take_last(IN)"
+ << "VAR =\nIN ="
+ << ""
+ << true;
+
+ QTest::newRow("$$take_last(): one")
+ << "IN = one\nVAR = $$take_last(IN)"
+ << "VAR = one\nIN ="
+ << ""
+ << true;
+
+ QTest::newRow("$$take_last(): multiple")
+ << "IN = one two three\nVAR = $$take_last(IN)"
+ << "VAR = three\nIN = one two"
+ << ""
+ << true;
+
+ QTest::newRow("$$take_last(): bad number of arguments")
+ << "VAR = $$take_last(1, 2)"
+ << "VAR ="
+ << "##:1: take_last(var) requires one argument."
+ << true;
+
QTest::newRow("$$size()")
<< "IN = one two three\nVAR = $$size(IN)"
<< "VAR = 3"
@@ -778,6 +869,18 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir)
<< "##:1: size(var) requires one argument."
<< true;
+ QTest::newRow("$$str_size()")
+ << "VAR = $$str_size(one two three)"
+ << "VAR = 13"
+ << ""
+ << true;
+
+ QTest::newRow("$$str_size(): bad number of arguments")
+ << "VAR = $$str_size(1, 2)"
+ << "VAR ="
+ << "##:1: str_size(str) requires one argument."
+ << true;
+
QTest::newRow("$$fromfile(): right var")
<< "VAR = $$fromfile(" + qindir + "/fromfile/infile.prx, DEFINES)"
<< "VAR = QT_DLL"
@@ -906,6 +1009,48 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir)
<< "##:1: format_number(): invalid format option foo=bar."
<< true;
+ QTest::newRow("$$num_add(): one")
+ << "VAR = $$num_add(10)"
+ << "VAR = 10"
+ << ""
+ << true;
+
+ QTest::newRow("$$num_add(): two")
+ << "VAR = $$num_add(1, 2)"
+ << "VAR = 3"
+ << ""
+ << true;
+
+ QTest::newRow("$$num_add(): three")
+ << "VAR = $$num_add(1, 3, 5)"
+ << "VAR = 9"
+ << ""
+ << true;
+
+ QTest::newRow("$$num_add(): negative")
+ << "VAR = $$num_add(7, -13)"
+ << "VAR = -6"
+ << ""
+ << true;
+
+ QTest::newRow("$$num_add(): bad number of arguments")
+ << "VAR = $$num_add()"
+ << "VAR = "
+ << "##:1: num_add(num, ...) requires at least one argument."
+ << true;
+
+ QTest::newRow("$$num_add(): bad number: float")
+ << "VAR = $$num_add(1.1)"
+ << "VAR ="
+ << "##:1: num_add(): floats are currently not supported."
+ << true;
+
+ QTest::newRow("$$num_add(): bad number: malformed")
+ << "VAR = $$num_add(fail)"
+ << "VAR ="
+ << "##:1: num_add(): malformed number fail."
+ << true;
+
QTest::newRow("$$join(): empty")
<< "IN = \nVAR = $$join(IN, //)"
<< "VAR ="
@@ -1101,6 +1246,18 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir)
<< "##:1: unique(var) requires one argument."
<< true;
+ QTest::newRow("$$sorted()")
+ << "IN = one two three\nVAR = $$sorted(IN)"
+ << "VAR = one three two"
+ << ""
+ << true;
+
+ QTest::newRow("$$sorted(): bad number of arguments")
+ << "VAR = $$sorted(1, 2)"
+ << "VAR ="
+ << "##:1: sorted(var) requires one argument."
+ << true;
+
QTest::newRow("$$reverse()")
<< "IN = one two three\nVAR = $$reverse(IN)"
<< "VAR = three two one"
@@ -2477,12 +2634,12 @@ void tst_qmakelib::proEval()
globals.environment = m_env;
globals.setProperties(m_prop);
globals.setDirectories(m_indir, m_outdir);
- ProFile *outPro = parser.parsedProBlock(out, "out", 1, QMakeParser::FullGrammar);
+ ProFile *outPro = parser.parsedProBlock(QStringRef(&out), "out", 1, QMakeParser::FullGrammar);
if (!outPro->isOk()) {
qWarning("Expected output is malformed");
verified = false;
}
- ProFile *pro = parser.parsedProBlock(in, infile, 1, QMakeParser::FullGrammar);
+ ProFile *pro = parser.parsedProBlock(QStringRef(&in), infile, 1, QMakeParser::FullGrammar);
QMakeEvaluator visitor(&globals, &parser, &vfs, &handler);
visitor.setOutputDir(m_outdir);
#ifdef Q_OS_WIN