diff options
author | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2010-05-12 10:18:54 (GMT) |
---|---|---|
committer | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2010-05-12 12:52:14 (GMT) |
commit | e35304444d6413d00c2090fab5d8173e6b6b7f26 (patch) | |
tree | 6ff0410191afe6c1cb969ad54368fa6d5aa16aad /tests | |
parent | 10f6220cc37207dbc35bd013af727552fb3799f7 (diff) | |
download | Qt-e35304444d6413d00c2090fab5d8173e6b6b7f26.zip Qt-e35304444d6413d00c2090fab5d8173e6b6b7f26.tar.gz Qt-e35304444d6413d00c2090fab5d8173e6b6b7f26.tar.bz2 |
QScriptValue autotest generator modification.
Generator shouldn't leave whitespace at the end of line in the generated
code.
Reviewed-by: Kent Hansen
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qscriptvalue/testgen/testgenerator.cpp | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/tests/auto/qscriptvalue/testgen/testgenerator.cpp b/tests/auto/qscriptvalue/testgen/testgenerator.cpp index a291110..8e6d8e1 100644 --- a/tests/auto/qscriptvalue/testgen/testgenerator.cpp +++ b/tests/auto/qscriptvalue/testgen/testgenerator.cpp @@ -238,17 +238,19 @@ static QString generateToXXXDef(const QString& name, const QList<QPair<QString, QStringList tagSet, valueSet; tagSet.reserve(list.count()); valueSet.reserve(list.count()); - int tmp = -1; - for(; i != list.constEnd(); ++i) { + for(int lineBreaker = 0; i != list.constEnd(); ++i) { QPair<QString, T> t = *i; t.first = escape(t.first); tagSet.append(QString("\n \"")); tagSet.append(t.first); tagSet.append(QString::fromAscii("\",")); - if (!((++tmp)%2)) + if (!valueSet.isEmpty()) + valueSet.append(QString(",")); + if (!((lineBreaker++)%2)) valueSet.append(QString("\n ")); + else + valueSet.append(QString::fromAscii(" ")); valueSet.append(prepareToInsert<T>(t.second)); - valueSet.append(QString::fromAscii(", ")); } return result.arg(name, typeName<T>(), @@ -301,18 +303,21 @@ QString generateToXXXDef<qsreal>(const QString& name, const QList<QPair<QString, QStringList tagSet, valueSet; tagSet.reserve(list.count()); valueSet.reserve(list.count()); - int tmp = -1; - for(; i != list.constEnd(); ++i) { + for(int lineBreaker = 0; i != list.constEnd(); ++i) { QPair<QString, qsreal> t = *i; t.first = escape(t.first); tagSet.append(QString("\n \"")); tagSet.append(t.first); tagSet.append(QString::fromAscii("\",")); - if (!((++tmp)%10)) + if (!valueSet.isEmpty()) + valueSet.append(QString(",")); + if (!((lineBreaker++)%10)) valueSet.append(QString("\n ")); + else + valueSet.append(QString::fromAscii(" ")); 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; if (name == "toNumber") { @@ -367,17 +372,19 @@ static QString generateCastDef(const QList<QPair<QString, T> >& list) QStringList tagSet, valueSet; tagSet.reserve(list.count()); valueSet.reserve(list.count()); - int tmp = -1; - for(; i != list.constEnd(); ++i) { + for(int lineBreaker = 0; i != list.constEnd(); ++i) { QPair<QString, T> t = *i; t.first = escape(t.first); tagSet.append(QString("\n \"")); tagSet.append(t.first); tagSet.append(QString::fromAscii("\",")); - if (!((++tmp)%2)) + if (!valueSet.isEmpty()) + valueSet.append(QString(",")); + if (!((lineBreaker++)%2)) valueSet.append(QString("\n ")); + else + valueSet.append(QString::fromAscii(" ")); valueSet.append(prepareToInsert<T>(t.second)); - valueSet.append(QString::fromAscii(", ")); } return result.arg(typeName<T>(), tagSet.join(QString()), valueSet.join(QString()), QString::number(list.count())); } @@ -429,17 +436,19 @@ QString generateCastDef<qsreal>(const QList<QPair<QString, qsreal> >& list) QStringList tagSet, valueSet; tagSet.reserve(list.count()); valueSet.reserve(list.count()); - int tmp = -1; - for(; i != list.constEnd(); ++i) { + for(int lineBreaker = 0; i != list.constEnd(); ++i) { QPair<QString, qsreal> t = *i; t.first = escape(t.first); tagSet.append(QString("\n \"")); tagSet.append(t.first); tagSet.append(QString::fromAscii("\",")); - if (!((++tmp)%10)) + if (!valueSet.isEmpty()) + valueSet.append(QString(",")); + if (!((lineBreaker++)%10)) valueSet.append(QString("\n ")); + else + valueSet.append(QString::fromAscii(" ")); valueSet.append(prepareToInsert<qsreal>(t.second)); - valueSet.append(QString::fromAscii(", ")); } return result.arg(typeName<qsreal>(), tagSet.join(QString()), |