summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptvalue
diff options
context:
space:
mode:
authorJedrzej Nowacki <jedrzej.nowacki@nokia.com>2010-03-04 13:27:06 (GMT)
committerJedrzej Nowacki <jedrzej.nowacki@nokia.com>2010-03-04 14:42:34 (GMT)
commit22a54680149d8fe5170f16e6aba7aff645b43da2 (patch)
tree4d5e2fa47c8d98c0da59ff51a7704e19e0d62c81 /tests/auto/qscriptvalue
parentf2ff0521dfae47f63c9334cbc78b4070aa9c9d7d (diff)
downloadQt-22a54680149d8fe5170f16e6aba7aff645b43da2.zip
Qt-22a54680149d8fe5170f16e6aba7aff645b43da2.tar.gz
Qt-22a54680149d8fe5170f16e6aba7aff645b43da2.tar.bz2
Optimize QScriptValue autotest generator.
QScriptValue autotest suite compile 24 minutes on MSVS2008 which is unacceptable. Modification tries to reduce the compilation time. Temples were changed to use static arrays of data; instead of inserting values directly, they are inserted in a loop (less code to optimize). Generated code were separated into several files (better usage of distributed compiling). Reviewed-by: Kent Hansen
Diffstat (limited to 'tests/auto/qscriptvalue')
-rw-r--r--tests/auto/qscriptvalue/testgen/main.cpp2
-rw-r--r--tests/auto/qscriptvalue/testgen/testgenerator.cpp401
-rw-r--r--tests/auto/qscriptvalue/testgen/testgenerator.h15
3 files changed, 245 insertions, 173 deletions
diff --git a/tests/auto/qscriptvalue/testgen/main.cpp b/tests/auto/qscriptvalue/testgen/main.cpp
index fe35de9..0672635 100644
--- a/tests/auto/qscriptvalue/testgen/main.cpp
+++ b/tests/auto/qscriptvalue/testgen/main.cpp
@@ -50,7 +50,7 @@ int main(int argc, char *argv[])
QCoreApplication a(argc, argv);
if (argc != 2) {
- qWarning() << "./prog outputfile";
+ qWarning() << "./prog outputdir";
exit(1);
}
diff --git a/tests/auto/qscriptvalue/testgen/testgenerator.cpp b/tests/auto/qscriptvalue/testgen/testgenerator.cpp
index 4376c42..a291110 100644
--- a/tests/auto/qscriptvalue/testgen/testgenerator.cpp
+++ b/tests/auto/qscriptvalue/testgen/testgenerator.cpp
@@ -50,10 +50,17 @@
#include <QtCore/qvariant.h>
#include <QtScript/qscriptvalue.h>
-void TestGenerator::save(const QString& data)
+void TestGenerator::save(const QHash<QString, QString>& data)
{
- QTextStream out(&m_ofile);
- out << data;
+ foreach(const QString& name, data.keys()) {
+ QFile ofile(m_opath + "tst_qscriptvalue_generated_" + name + ".cpp");
+ if (!ofile.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ qWarning() << "Can't open output file: " << ofile.fileName();
+ exit(2);
+ }
+ QTextStream out(&ofile);
+ out << data[name];
+ }
}
static QString escape(QString txt)
@@ -98,6 +105,55 @@ QString typeName<bool>() {return "bool";}
template<>
QString typeName<QString>() {return "QString";}
+static QString generateLicence()
+{
+ return "/****************************************************************************\n"
+ "**\n"
+ "** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).\n"
+ "** All rights reserved.\n"
+ "** Contact: Nokia Corporation (qt-info@nokia.com)\n"
+ "**\n"
+ "** This file is part of the test suite of the Qt Toolkit.\n"
+ "**\n"
+ "** $QT_BEGIN_LICENSE:LGPL$\n"
+ "** No Commercial Usage\n"
+ "** This file contains pre-release code and may not be distributed.\n"
+ "** You may use this file in accordance with the terms and conditions\n"
+ "** contained in the Technology Preview License Agreement accompanying\n"
+ "** this package.\n"
+ "**\n"
+ "** GNU Lesser General Public License Usage\n"
+ "** Alternatively, this file may be used under the terms of the GNU Lesser\n"
+ "** General Public License version 2.1 as published by the Free Software\n"
+ "** Foundation and appearing in the file LICENSE.LGPL included in the\n"
+ "** packaging of this file. Please review the following information to\n"
+ "** ensure the GNU Lesser General Public License version 2.1 requirements\n"
+ "** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.\n"
+ "**\n"
+ "** In addition, as a special exception, Nokia gives you certain additional\n"
+ "** rights. These rights are described in the Nokia Qt LGPL Exception\n"
+ "** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.\n"
+ "**\n"
+ "** If you have questions regarding the use of this file, please contact\n"
+ "** Nokia at qt-info@nokia.com.\n"
+ "**\n"
+ "**\n"
+ "**\n"
+ "**\n"
+ "**\n"
+ "**\n"
+ "**\n"
+ "**\n"
+ "** $QT_END_LICENSE$\n"
+ "**\n"
+ "****************************************************************************/\n"
+ "\n"\
+ "/****************************************************************************\n"\
+ "*************** This file has been generated. DO NOT MODIFY! ****************\n"
+ "****************************************************************************/\n\n"\
+ "#include \"tst_qscriptvalue.h\"\n\n";
+}
+
static QString generateIsXXXDef(const QString& name, const QList<QString>& list)
{
static const QString templ("void tst_QScriptValue::%1_initData()\n"\
@@ -106,11 +162,14 @@ static QString generateIsXXXDef(const QString& name, const QList<QString>& list)
" initScriptValues();\n"\
"}\n"\
"\n"\
+ "static QString %1_array [] = {%2};\n\n"\
"void tst_QScriptValue::%1_makeData(const char* expr)\n"\
"{\n"\
" static QSet<QString> %1;\n"\
" if (%1.isEmpty()) {\n"\
- " %1%2\n"\
+ " %1.reserve(%3);\n"\
+ " for (unsigned i = 0; i < %3; ++i)\n"\
+ " %1.insert(%1_array[i]);\n"\
" }\n"\
" newRow(expr) << %1.contains(expr);\n"\
"}\n"\
@@ -132,16 +191,14 @@ static QString generateIsXXXDef(const QString& name, const QList<QString>& list)
QString result = templ;
QStringList set;
- foreach(QString t, list) {
- t = escape(t);
- t.append('\"');
- t.prepend('\"');
- set.append(QString(" << "));
- set.append(t);
- set.append("\n ");
+ set.reserve(3 * list.count());
+ foreach(const QString& t, list) {
+ set.append("\n \"");
+ set.append(escape(t));
+ set.append("\",");
}
- set.append(";");
- return result.arg(name, set.join(QString()));
+
+ return result.arg(name, set.join(QString()), QString::number(list.count()));
}
template<typename T>
@@ -154,11 +211,15 @@ static QString generateToXXXDef(const QString& name, const QList<QPair<QString,
" initScriptValues();\n"\
"}\n"\
"\n"\
+ "static QString %1_tagArray [] = {%4};\n\n"\
+ "static %2 %1_valueArray [] = {%5};\n\n"\
"void tst_QScriptValue::%1_makeData(const char* expr)\n"\
"{\n"\
" static QHash<QString, %2> %1;\n"\
" if (%1.isEmpty()) {\n"\
- "%3"\
+ " %1.reserve(%3);\n"\
+ " for (unsigned i = 0; i < %3; ++i)\n"\
+ " %1.insert(%1_tagArray[i], %1_valueArray[i]);\n"\
" }\n"\
" newRow(expr) << %1.value(expr);\n"\
"}\n"\
@@ -174,19 +235,26 @@ static QString generateToXXXDef(const QString& name, const QList<QPair<QString,
QString result = templ;
typename QList<QPair<QString, T> >::const_iterator i = list.constBegin();
- QStringList set;
+ QStringList tagSet, valueSet;
+ tagSet.reserve(list.count());
+ valueSet.reserve(list.count());
+ int tmp = -1;
for(; i != list.constEnd(); ++i) {
QPair<QString, T> t = *i;
t.first = escape(t.first);
- set.append(QString(" "));
- set.append(name);
- set.append(".insert(\"");
- set.append(t.first);
- set.append(QString::fromAscii("\", "));
- set.append(prepareToInsert<T>(t.second));
- set.append(QString::fromAscii(");\n"));
+ tagSet.append(QString("\n \""));
+ tagSet.append(t.first);
+ tagSet.append(QString::fromAscii("\","));
+ if (!((++tmp)%2))
+ valueSet.append(QString("\n "));
+ valueSet.append(prepareToInsert<T>(t.second));
+ valueSet.append(QString::fromAscii(", "));
}
- return result.arg(name, typeName<T>(), set.join(QString()));
+ return result.arg(name,
+ typeName<T>(),
+ QString::number(list.count()),
+ tagSet.join(QString()),
+ valueSet.join(QString()));
}
@@ -200,11 +268,15 @@ QString generateToXXXDef<qsreal>(const QString& name, const QList<QPair<QString,
" initScriptValues();\n"\
"}\n"\
"\n"\
+ "static QString %1_tagArray [] = {%3};\n"\
+ "static %2 %1_valueArray [] = {%4};\n"\
"void tst_QScriptValue::%1_makeData(const char* expr)\n"\
"{\n"\
" static QHash<QString, %2> %1;\n"\
" if (%1.isEmpty()) {\n"\
- "%3"\
+ " %1.reserve(%5);\n"\
+ " for (unsigned i = 0; i < %5; ++i)\n"\
+ " %1.insert(%1_tagArray[i], %1_valueArray[i]);\n"\
" }\n"\
" newRow(expr) << %1.value(expr);\n"\
"}\n"\
@@ -226,17 +298,20 @@ QString generateToXXXDef<qsreal>(const QString& name, const QList<QPair<QString,
QString result = templ;
QList<QPair<QString, qsreal> >::const_iterator i = list.constBegin();
- QStringList set;
+ QStringList tagSet, valueSet;
+ tagSet.reserve(list.count());
+ valueSet.reserve(list.count());
+ int tmp = -1;
for(; i != list.constEnd(); ++i) {
QPair<QString, qsreal> t = *i;
t.first = escape(t.first);
- set.append(QString(" "));
- set.append(name);
- set.append(".insert(\"");
- set.append(t.first);
- set.append(QString::fromAscii("\", "));
- set.append(prepareToInsert<qsreal>(t.second));
- set.append(QString::fromAscii(");\n"));
+ tagSet.append(QString("\n \""));
+ tagSet.append(t.first);
+ tagSet.append(QString::fromAscii("\","));
+ if (!((++tmp)%10))
+ valueSet.append(QString("\n "));
+ valueSet.append(prepareToInsert<qsreal>(t.second));
+ valueSet.append(QString::fromAscii(", "));
}
// toInteger shouldn't return NaN, so it would be nice to catch the case.
QString hook;
@@ -247,105 +322,129 @@ QString generateToXXXDef<qsreal>(const QString& name, const QList<QPair<QString,
" return;\n"\
" }\n";
}
- return result.arg(name, typeName<qsreal>(), set.join(QString()), hook);
+ return result.arg(name,
+ typeName<qsreal>(),
+ tagSet.join(QString()),
+ valueSet.join(QString()),
+ QString::number(list.count()),
+ hook);
}
template<typename T>
static QString generateCastDef(const QList<QPair<QString, T> >& list)
{
static const QString templ = "\n"\
- "void tst_QScriptValue::qscriptvalue_cast%2_initData()\n"\
+ "void tst_QScriptValue::qscriptvalue_cast%1_initData()\n"\
"{\n"\
- " QTest::addColumn<%2>(\"expected\");\n"\
+ " QTest::addColumn<%1>(\"expected\");\n"\
" initScriptValues();\n"\
"}\n"\
"\n"\
- "void tst_QScriptValue::qscriptvalue_cast%2_makeData(const char* expr)\n"\
+ "static QString qscriptvalue_cast%1_tagArray [] = {%2};\n"\
+ "static %1 qscriptvalue_cast%1_valueArray [] = {%3};\n"\
+ "void tst_QScriptValue::qscriptvalue_cast%1_makeData(const char* expr)\n"\
"{\n"\
- " static QHash<QString, %2> value;\n"\
+ " static QHash<QString, %1> value;\n"\
" if (value.isEmpty()) {\n"\
- "%3"\
+ " value.reserve(%4);\n"\
+ " for (unsigned i = 0; i < %4; ++i)\n"\
+ " value.insert(qscriptvalue_cast%1_tagArray[i], qscriptvalue_cast%1_valueArray[i]);\n"\
" }\n"\
" newRow(expr) << value.value(expr);\n"\
"}\n"\
"\n"\
- "void tst_QScriptValue::qscriptvalue_cast%2_test(const char*, const QScriptValue& value)\n"\
+ "void tst_QScriptValue::qscriptvalue_cast%1_test(const char*, const QScriptValue& value)\n"\
"{\n"\
- " QFETCH(%2, expected);\n"\
- " QCOMPARE(qscriptvalue_cast<%2>(value), expected);\n"\
- " QCOMPARE(qscriptvalue_cast<%2>(value), expected);\n"\
+ " QFETCH(%1, expected);\n"\
+ " QCOMPARE(qscriptvalue_cast<%1>(value), expected);\n"\
+ " QCOMPARE(qscriptvalue_cast<%1>(value), expected);\n"\
"}\n"\
"\n"\
- "DEFINE_TEST_FUNCTION(qscriptvalue_cast%2)\n";
+ "DEFINE_TEST_FUNCTION(qscriptvalue_cast%1)\n";
QString result = templ;
typename QList<QPair<QString, T> >::const_iterator i = list.constBegin();
- QStringList set;
+ QStringList tagSet, valueSet;
+ tagSet.reserve(list.count());
+ valueSet.reserve(list.count());
+ int tmp = -1;
for(; i != list.constEnd(); ++i) {
QPair<QString, T> t = *i;
t.first = escape(t.first);
- set.append(QString(" "));
- set.append("value.insert(\"");
- set.append(t.first);
- set.append(QString::fromAscii("\", "));
- set.append(prepareToInsert<T>(t.second));
- set.append(QString::fromAscii(");\n"));
+ tagSet.append(QString("\n \""));
+ tagSet.append(t.first);
+ tagSet.append(QString::fromAscii("\","));
+ if (!((++tmp)%2))
+ valueSet.append(QString("\n "));
+ valueSet.append(prepareToInsert<T>(t.second));
+ valueSet.append(QString::fromAscii(", "));
}
- return result.arg(typeName<T>(), set.join(QString()));
+ return result.arg(typeName<T>(), tagSet.join(QString()), valueSet.join(QString()), QString::number(list.count()));
}
template<>
QString generateCastDef<qsreal>(const QList<QPair<QString, qsreal> >& list)
{
static const QString templ = "\n"\
- "void tst_QScriptValue::qscriptvalue_cast%2_initData()\n"\
+ "void tst_QScriptValue::qscriptvalue_cast%1_initData()\n"\
"{\n"\
- " QTest::addColumn<%2>(\"expected\");\n"\
+ " QTest::addColumn<%1>(\"expected\");\n"\
" initScriptValues();\n"\
"}\n"\
"\n"\
- "void tst_QScriptValue::qscriptvalue_cast%2_makeData(const char* expr)\n"\
+ "static QString qscriptvalue_cast%1_tagArray [] = {%2};\n"\
+ "static %1 qscriptvalue_cast%1_valueArray [] = {%3};\n"\
+ "void tst_QScriptValue::qscriptvalue_cast%1_makeData(const char* expr)\n"\
"{\n"\
- " static QHash<QString, %2> value;\n"\
+ " static QHash<QString, %1> value;\n"\
" if (value.isEmpty()) {\n"\
- "%3"\
+ " value.reserve(%4);\n"\
+ " for (unsigned i = 0; i < %4; ++i)\n"\
+ " value.insert(qscriptvalue_cast%1_tagArray[i], qscriptvalue_cast%1_valueArray[i]);\n"\
" }\n"\
" newRow(expr) << value.value(expr);\n"\
"}\n"\
"\n"\
- "void tst_QScriptValue::qscriptvalue_cast%2_test(const char*, const QScriptValue& value)\n"\
+ "void tst_QScriptValue::qscriptvalue_cast%1_test(const char*, const QScriptValue& value)\n"\
"{\n"\
- " QFETCH(%2, expected);\n"\
+ " QFETCH(%1, expected);\n"\
" if (qIsNaN(expected)) {\n"
- " QVERIFY(qIsNaN(qscriptvalue_cast<%2>(value)));\n"
- " QVERIFY(qIsNaN(qscriptvalue_cast<%2>(value)));\n"
+ " QVERIFY(qIsNaN(qscriptvalue_cast<%1>(value)));\n"
+ " QVERIFY(qIsNaN(qscriptvalue_cast<%1>(value)));\n"
" return;\n"
" }\n"\
" if (qIsInf(expected)) {\n"
- " QVERIFY(qIsInf(qscriptvalue_cast<%2>(value)));\n"
- " QVERIFY(qIsInf(qscriptvalue_cast<%2>(value)));\n"
+ " QVERIFY(qIsInf(qscriptvalue_cast<%1>(value)));\n"
+ " QVERIFY(qIsInf(qscriptvalue_cast<%1>(value)));\n"
" return;\n"
" }\n"
- " QCOMPARE(qscriptvalue_cast<%2>(value), expected);\n"\
- " QCOMPARE(qscriptvalue_cast<%2>(value), expected);\n"\
+ " QCOMPARE(qscriptvalue_cast<%1>(value), expected);\n"\
+ " QCOMPARE(qscriptvalue_cast<%1>(value), expected);\n"\
"}\n"\
"\n"\
- "DEFINE_TEST_FUNCTION(qscriptvalue_cast%2)\n";
+ "DEFINE_TEST_FUNCTION(qscriptvalue_cast%1)\n";
QString result = templ;
QList<QPair<QString, qsreal> >::const_iterator i = list.constBegin();
- QStringList set;
+ QStringList tagSet, valueSet;
+ tagSet.reserve(list.count());
+ valueSet.reserve(list.count());
+ int tmp = -1;
for(; i != list.constEnd(); ++i) {
QPair<QString, qsreal> t = *i;
t.first = escape(t.first);
- set.append(QString(" "));
- set.append("value.insert(\"");
- set.append(t.first);
- set.append(QString::fromAscii("\", "));
- set.append(prepareToInsert<qsreal>(t.second));
- set.append(QString::fromAscii(");\n"));
+ tagSet.append(QString("\n \""));
+ tagSet.append(t.first);
+ tagSet.append(QString::fromAscii("\","));
+ if (!((++tmp)%10))
+ valueSet.append(QString("\n "));
+ valueSet.append(prepareToInsert<qsreal>(t.second));
+ valueSet.append(QString::fromAscii(", "));
}
- return result.arg(typeName<qsreal>(), set.join(QString()));
+ return result.arg(typeName<qsreal>(),
+ tagSet.join(QString()),
+ valueSet.join(QString()),
+ QString::number(list.count()));
}
static QString generateCompareDef(const QString& comparisionType, const QList<QString> tags)
@@ -358,11 +457,14 @@ static QString generateCompareDef(const QString& comparisionType, const QList<QS
" initScriptValues();\n"\
"}\n"\
"\n"\
+ "static QString %1_array [] = {%2};\n\n"\
"void tst_QScriptValue::%1_makeData(const char *expr)\n"\
"{\n"\
" static QSet<QString> equals;\n"\
" if (equals.isEmpty()) {\n"\
- "%2\n"\
+ " equals.reserve(%3);\n"\
+ " for (unsigned i = 0; i < %3; ++i)\n"\
+ " equals.insert(%1_array[i]);\n"\
" }\n"\
" QHash<QString, QScriptValue>::const_iterator it;\n"\
" for (it = m_values.constBegin(); it != m_values.constEnd(); ++it) {\n"\
@@ -386,59 +488,16 @@ static QString generateCompareDef(const QString& comparisionType, const QList<QS
QString result = templ;
QStringList set;
+ set.reserve(tags.count());
foreach(const QString& tmp, tags) {
- set.append(" equals.insert(\"" + escape(tmp) + "\");");
+ set.append("\n \"" + escape(tmp) + "\",");
}
- return result.arg(comparisionType, set.join("\n"));
+ return result.arg(comparisionType, set.join(""), QString::number(tags.count()));
}
static QString generateInitDef(const QVector<QString>& allDataTags)
{
- static const QString templ = "/****************************************************************************\n"
- "**\n"
- "** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).\n"
- "** All rights reserved.\n"
- "** Contact: Nokia Corporation (qt-info@nokia.com)\n"
- "**\n"
- "** This file is part of the test suite of the Qt Toolkit.\n"
- "**\n"
- "** $QT_BEGIN_LICENSE:LGPL$\n"
- "** No Commercial Usage\n"
- "** This file contains pre-release code and may not be distributed.\n"
- "** You may use this file in accordance with the terms and conditions\n"
- "** contained in the Technology Preview License Agreement accompanying\n"
- "** this package.\n"
- "**\n"
- "** GNU Lesser General Public License Usage\n"
- "** Alternatively, this file may be used under the terms of the GNU Lesser\n"
- "** General Public License version 2.1 as published by the Free Software\n"
- "** Foundation and appearing in the file LICENSE.LGPL included in the\n"
- "** packaging of this file. Please review the following information to\n"
- "** ensure the GNU Lesser General Public License version 2.1 requirements\n"
- "** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.\n"
- "**\n"
- "** In addition, as a special exception, Nokia gives you certain additional\n"
- "** rights. These rights are described in the Nokia Qt LGPL Exception\n"
- "** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.\n"
- "**\n"
- "** If you have questions regarding the use of this file, please contact\n"
- "** Nokia at qt-info@nokia.com.\n"
- "**\n"
- "**\n"
- "**\n"
- "**\n"
- "**\n"
- "**\n"
- "**\n"
- "**\n"
- "** $QT_END_LICENSE$\n"
- "**\n"
- "****************************************************************************/\n"
- "\n"\
- "#include \"tst_qscriptvalue.h\"\n\n"\
- "#define DEFINE_TEST_VALUE(expr) m_values.insert(QString::fromLatin1(#expr), expr)\n"\
- "\n"\
- "void tst_QScriptValue::initScriptValues()\n"\
+ static const QString templ = "void tst_QScriptValue::initScriptValues()\n"\
"{\n"\
" m_values.clear();\n"\
" if (engine) \n"\
@@ -463,7 +522,7 @@ static void squashTags(QString dataTag, const QVector<bool>& results, QList<QStr
}
-QString TestGenerator::generateTest()
+QHash<QString, QString> TestGenerator::generateTest()
{
// All data tags keept in one place.
QVector<QString> dataTags;
@@ -643,47 +702,63 @@ QString TestGenerator::generateTest()
Q_ASSERT(in.atEnd());
// Generate.
- QStringList result;
- result.append(generateInitDef(dataTags));
- result.append(generateIsXXXDef("isValid", isValidList));
- result.append(generateIsXXXDef("isBool", isBoolList));
- result.append(generateIsXXXDef("isBoolean", isBooleanList));
- result.append(generateIsXXXDef("isNumber", isNumberList));
- result.append(generateIsXXXDef("isFunction", isFunctionList));
- result.append(generateIsXXXDef("isNull", isNullList));
- result.append(generateIsXXXDef("isString", isStringList));
- result.append(generateIsXXXDef("isUndefined", isUndefinedList));
- result.append(generateIsXXXDef("isVariant", isVariantList));
- result.append(generateIsXXXDef("isQObject", isQObjectList));
- result.append(generateIsXXXDef("isQMetaObject", isQMetaObjectList));
- result.append(generateIsXXXDef("isObject", isObjectList));
- result.append(generateIsXXXDef("isDate", isDateList));
- result.append(generateIsXXXDef("isRegExp", isRegExpList));
- result.append(generateIsXXXDef("isArray", isArrayList));
- result.append(generateIsXXXDef("isError", isErrorList));
-
- result.append(generateToXXXDef<QString>("toString", toStringList));
- result.append(generateToXXXDef<qsreal>("toNumber", toNumberList));
- result.append(generateToXXXDef<bool>("toBool", toBoolList));
- result.append(generateToXXXDef<bool>("toBoolean", toBooleanList));
- result.append(generateToXXXDef<qsreal>("toInteger", toIntegerList));
- result.append(generateToXXXDef<qint32>("toInt32", toInt32List));
- result.append(generateToXXXDef<quint32>("toUInt32", toUInt32List));
- result.append(generateToXXXDef<quint16>("toUInt16", toUInt16List));
-
- result.append(generateCompareDef("equals", equalsList));
- result.append(generateCompareDef("strictlyEquals", strictlyEqualsList));
- result.append(generateCompareDef("lessThan", lessThanList));
- result.append(generateCompareDef("instanceOf", instanceOfList));
-
- result.append(generateCastDef(castStringList));
- result.append(generateCastDef(castSRealList));
- result.append(generateCastDef(castBoolList));
- result.append(generateCastDef(castInt32List));
- result.append(generateCastDef(castUInt32List));
- result.append(generateCastDef(castUInt16List));
-
- return result.join("\n");
+ QHash<QString, QString> result;
+ QStringList tmp;
+ tmp.append(generateLicence());
+ tmp.append(generateInitDef(dataTags));
+ result.insert("init", tmp.join("\n"));
+ tmp.clear();
+
+ tmp.append(generateLicence());
+ tmp.append(generateIsXXXDef("isValid", isValidList));
+ tmp.append(generateIsXXXDef("isBool", isBoolList));
+ tmp.append(generateIsXXXDef("isBoolean", isBooleanList));
+ tmp.append(generateIsXXXDef("isNumber", isNumberList));
+ tmp.append(generateIsXXXDef("isFunction", isFunctionList));
+ tmp.append(generateIsXXXDef("isNull", isNullList));
+ tmp.append(generateIsXXXDef("isString", isStringList));
+ tmp.append(generateIsXXXDef("isUndefined", isUndefinedList));
+ tmp.append(generateIsXXXDef("isVariant", isVariantList));
+ tmp.append(generateIsXXXDef("isQObject", isQObjectList));
+ tmp.append(generateIsXXXDef("isQMetaObject", isQMetaObjectList));
+ tmp.append(generateIsXXXDef("isObject", isObjectList));
+ tmp.append(generateIsXXXDef("isDate", isDateList));
+ tmp.append(generateIsXXXDef("isRegExp", isRegExpList));
+ tmp.append(generateIsXXXDef("isArray", isArrayList));
+ tmp.append(generateIsXXXDef("isError", isErrorList));
+ result.insert("isXXX", tmp.join("\n"));
+ tmp.clear();
+
+ tmp.append(generateLicence());
+ tmp.append(generateToXXXDef<QString>("toString", toStringList));
+ tmp.append(generateToXXXDef<qsreal>("toNumber", toNumberList));
+ tmp.append(generateToXXXDef<bool>("toBool", toBoolList));
+ tmp.append(generateToXXXDef<bool>("toBoolean", toBooleanList));
+ tmp.append(generateToXXXDef<qsreal>("toInteger", toIntegerList));
+ tmp.append(generateToXXXDef<qint32>("toInt32", toInt32List));
+ tmp.append(generateToXXXDef<quint32>("toUInt32", toUInt32List));
+ tmp.append(generateToXXXDef<quint16>("toUInt16", toUInt16List));
+ result.insert("toXXX", tmp.join("\n"));
+ tmp.clear();
+
+ tmp.append(generateLicence());
+ tmp.append(generateCompareDef("equals", equalsList));
+ tmp.append(generateCompareDef("strictlyEquals", strictlyEqualsList));
+ tmp.append(generateCompareDef("lessThan", lessThanList));
+ tmp.append(generateCompareDef("instanceOf", instanceOfList));
+ result.insert("comparison", tmp.join("\n"));
+ tmp.clear();
+
+ tmp.append(generateLicence());
+ tmp.append(generateCastDef(castStringList));
+ tmp.append(generateCastDef(castSRealList));
+ tmp.append(generateCastDef(castBoolList));
+ tmp.append(generateCastDef(castInt32List));
+ tmp.append(generateCastDef(castUInt32List));
+ tmp.append(generateCastDef(castUInt16List));
+ result.insert("cast", tmp.join("\n"));
+
+ return result;
}
diff --git a/tests/auto/qscriptvalue/testgen/testgenerator.h b/tests/auto/qscriptvalue/testgen/testgenerator.h
index 8f4a357..1c61fc5 100644
--- a/tests/auto/qscriptvalue/testgen/testgenerator.h
+++ b/tests/auto/qscriptvalue/testgen/testgenerator.h
@@ -49,13 +49,10 @@
class TestGenerator {
public:
TestGenerator(QString& outputpath)
- : m_ofile(outputpath)
+ : m_opath(outputpath)
{
- // Open output file
- if (!m_ofile.open(QIODevice::WriteOnly | QIODevice::Text)) {
- qWarning() << "Can't open output file: " << outputpath;
- exit(2);
- }
+ if (!m_opath.endsWith('/'))
+ m_opath.append('/');
m_tempFile.open();
}
@@ -67,10 +64,10 @@ public:
}
void prepareData();
- QString generateTest();
- void save(const QString& data);
+ QHash<QString, QString> generateTest();
+ void save(const QHash<QString, QString>& data);
private:
- QFile m_ofile;
+ QString m_opath;
QTemporaryFile m_tempFile;
};