summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-14 14:43:09 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-14 14:44:26 (GMT)
commitd7b24639a40706f75071640eefa11adf5902e0ed (patch)
treedf212377dc2dd9614355eb9b1abbdea2b70d083b
parentb1574e4845d657673e178b892ba57e398984e0b3 (diff)
downloadQt-d7b24639a40706f75071640eefa11adf5902e0ed.zip
Qt-d7b24639a40706f75071640eefa11adf5902e0ed.tar.gz
Qt-d7b24639a40706f75071640eefa11adf5902e0ed.tar.bz2
More polishing on the backtrace
change the coding style of function from foo (arg=text) to foo(arg = 'text')
-rw-r--r--src/script/api/qscriptcontext.cpp10
-rw-r--r--tests/auto/qscriptcontext/tst_qscriptcontext.cpp36
2 files changed, 25 insertions, 21 deletions
diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp
index 01ccb6d..689ad66 100644
--- a/src/script/api/qscriptcontext.cpp
+++ b/src/script/api/qscriptcontext.cpp
@@ -631,17 +631,21 @@ QString QScriptContext::toString() const
}
QStringList parameterNames = info.functionParameterNames();
- result.append(QLatin1String(" ("));
+ result.append(QLatin1Char('('));
for (int i = 0; i < argumentCount(); ++i) {
if (i > 0)
result.append(QLatin1String(", "));
if (i < parameterNames.count()) {
result.append(parameterNames.at(i));
- result.append(QLatin1Char('='));
+ result.append(QLatin1String(" = "));
}
QScriptValue arg = argument(i);
-// result.append(safeValueToString(arg)); ###
+ if (arg.isString())
+ result.append(QLatin1Char('\''));
result.append(arg.toString());
+ if (arg.isString())
+ result.append(QLatin1Char('\''));
+
}
result.append(QLatin1Char(')'));
diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
index 43938b6..c72594c 100644
--- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
+++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
@@ -563,9 +563,9 @@ void tst_QScriptContext::backtrace_data()
{
QStringList expected;
- expected << "<native> (123) at -1"
- << "foo ([object Object], [object global]) at testfile:2" //### object instead of 'hello'
- << "<global> () at testfile:4";
+ expected << "<native>(123) at -1"
+ << "foo([object Object], [object global]) at testfile:2" //### object instead of 'hello'
+ << "<global>() at testfile:4";
QString source(
"function foo() {\n"
@@ -585,10 +585,10 @@ void tst_QScriptContext::backtrace_data()
"foo('hello', 456)"
).arg("\\n \\n bt('hey'); \\n");
- expected << "<native> (hey) at -1"
- << "<native> () at 3" //### <native> should be <eval>
- << "foo (arg1=hello, arg2=456) at testfile:-1" //### line number should be 2
- << "<global> () at testfile:4";
+ expected << "<native>('hey') at -1"
+ << "<native>() at 3" //### <native> should be <eval>
+ << "foo(arg1 = 'hello', arg2 = 456) at testfile:-1" //### line number should be 2
+ << "<global>() at testfile:4";
QTest::newRow("eval") << source << expected;
}
@@ -607,12 +607,12 @@ void tst_QScriptContext::backtrace_data()
).arg(eval_code);
QStringList expected;
- expected << "<native> (m) at -1"
- << "bar (a=b) at eval.js:2"
- << "<native> () at eval.js:4" //### should be <eval>
- << QString("<native> (%1, eval.js) at -1").arg(eval_code.replace("\\n", "\n"))
- << "foo () at testfile:2"
- << "<global> () at testfile:4";
+ expected << "<native>('m') at -1"
+ << "bar(a = 'b') at eval.js:2"
+ << "<native>() at eval.js:4" //### should be <eval>
+ << QString("<native>('%1', 'eval.js') at -1").arg(eval_code.replace("\\n", "\n"))
+ << "foo() at testfile:2"
+ << "<global>() at testfile:4";
QTest::newRow("custom_eval") << source << expected;
}
@@ -626,10 +626,10 @@ void tst_QScriptContext::backtrace_data()
).arg(f);
QStringList expected;
- expected << "<native> (b) at -1"
- << "<anonymous> (a=b) at testfile:5"
- << QString("foo (f=%1) at testfile:2").arg(f)
- << "<global> () at testfile:6";
+ expected << "<native>('b') at -1"
+ << "<anonymous>(a = 'b') at testfile:5"
+ << QString("foo(f = %1) at testfile:2").arg(f)
+ << "<global>() at testfile:6";
QTest::newRow("closure") << source << expected;
}
@@ -870,7 +870,7 @@ void tst_QScriptContext::toString()
" return parentContextToString();\n"
"}; foo(1, 2, 3)", "script.qs");
QVERIFY(ret.isString());
- QCOMPARE(ret.toString(), QString::fromLatin1("foo (first=1, second=2, third=3) at script.qs:2"));
+ QCOMPARE(ret.toString(), QString::fromLatin1("foo(first = 1, second = 2, third = 3) at script.qs:2"));
}
static QScriptValue storeCalledAsConstructor(QScriptContext *ctx, QScriptEngine *eng)