From e35304444d6413d00c2090fab5d8173e6b6b7f26 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Wed, 12 May 2010 12:18:54 +0200 Subject: QScriptValue autotest generator modification. Generator shouldn't leave whitespace at the end of line in the generated code. Reviewed-by: Kent Hansen --- tests/auto/qscriptvalue/testgen/testgenerator.cpp | 41 ++++++++++++++--------- 1 file 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 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.second)); - valueSet.append(QString::fromAscii(", ")); } return result.arg(name, typeName(), @@ -301,18 +303,21 @@ QString generateToXXXDef(const QString& name, const QList 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(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 >& 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 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.second)); - valueSet.append(QString::fromAscii(", ")); } return result.arg(typeName(), tagSet.join(QString()), valueSet.join(QString()), QString::number(list.count())); } @@ -429,17 +436,19 @@ QString generateCastDef(const QList >& 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 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(t.second)); - valueSet.append(QString::fromAscii(", ")); } return result.arg(typeName(), tagSet.join(QString()), -- cgit v0.12