From f3927de84b509a1be3f06182327e3c4cdea23b70 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 28 Jul 2009 13:04:11 +0200 Subject: Fix tst_QScriptEngine::uncaughtException The test used to test that passing 0 as line number works. There is no reason to impose the lineNumber to be >= 1, this is an arbitrary limitation. It even works when passing negative value, but as -1 is a magic number, an error on line '-1' will not have lineNumber Reviewed-by: Kent Hansen --- src/3rdparty/webkit/JavaScriptCore/parser/SourceCode.h | 8 ++++++++ src/script/api/qscriptengine.cpp | 1 - tests/auto/qscriptengine/tst_qscriptengine.cpp | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/webkit/JavaScriptCore/parser/SourceCode.h b/src/3rdparty/webkit/JavaScriptCore/parser/SourceCode.h index 84360b8..305b804 100644 --- a/src/3rdparty/webkit/JavaScriptCore/parser/SourceCode.h +++ b/src/3rdparty/webkit/JavaScriptCore/parser/SourceCode.h @@ -47,7 +47,11 @@ namespace JSC { : m_provider(provider) , m_startChar(0) , m_endChar(m_provider->length()) +#ifdef QT_BUILD_SCRIPT_LIB + , m_firstLine(firstLine) +#else , m_firstLine(std::max(firstLine, 1)) +#endif { } @@ -55,7 +59,11 @@ namespace JSC { : m_provider(provider) , m_startChar(start) , m_endChar(end) +#ifdef QT_BUILD_SCRIPT_LIB + , m_firstLine(firstLine) +#else , m_firstLine(std::max(firstLine, 1)) +#endif { } diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 61bf271..01cf50b 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2184,7 +2184,6 @@ QScriptSyntaxCheckResult QScriptEnginePrivate::checkSyntax(const QString &progra QScriptValue QScriptEngine::evaluate(const QString &program, const QString &fileName, int lineNumber) { Q_D(QScriptEngine); - lineNumber = qMax(lineNumber, 1); JSC::JSLock lock(false); // ### hmmm diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 768fe3c..5c8aaf8 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -1290,7 +1290,7 @@ void tst_QScriptEngine::uncaughtException() QScriptEngine eng; QScriptValue fun = eng.newFunction(myFunction); QScriptValue throwFun = eng.newFunction(myThrowingFunction); - for (int x = 0; x < 2; ++x) { + for (int x = -1; x < 2; ++x) { { QScriptValue ret = eng.evaluate("a = 10;\nb = 20;\n0 = 0;\n", /*fileName=*/QString(), /*lineNumber=*/x); QVERIFY(eng.hasUncaughtException()); -- cgit v0.12