From 0a4579306706f1fbe91d8b54734491376cb92093 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Mon, 27 Jul 2009 19:07:08 +0200 Subject: The line number is correctly reported for exception Enable the tests checking the line number of exception. Add a lower bound on the lineNumber of QScriptEngin::evaluate() --- src/script/api/qscriptengine.cpp | 1 + tests/auto/qscriptengine/tst_qscriptengine.cpp | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index fbc65d6..5cbb8d7 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2055,6 +2055,7 @@ 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 997eb25..fed5a4c 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -1302,7 +1302,6 @@ void tst_QScriptEngine::uncaughtException() { QScriptValue ret = eng.evaluate("a = 10;\nb = 20;\n0 = 0;\n", /*fileName=*/QString(), /*lineNumber=*/x); QVERIFY(eng.hasUncaughtException()); - QEXPECT_FAIL("", "Exception line number is wrong", Continue); QCOMPARE(eng.uncaughtExceptionLineNumber(), x+2); QVERIFY(eng.uncaughtException().strictlyEquals(ret)); (void)ret.toString(); @@ -1310,7 +1309,6 @@ void tst_QScriptEngine::uncaughtException() QVERIFY(eng.uncaughtException().strictlyEquals(ret)); QVERIFY(fun.call().isNull()); QVERIFY(eng.hasUncaughtException()); - QEXPECT_FAIL("", "Exception line number is wrong", Continue); QCOMPARE(eng.uncaughtExceptionLineNumber(), x+2); QVERIFY(eng.uncaughtException().strictlyEquals(ret)); eng.clearExceptions(); @@ -1324,7 +1322,6 @@ void tst_QScriptEngine::uncaughtException() QScriptValue ret2 = throwFun.call(); QVERIFY(ret2.isError()); QVERIFY(eng.hasUncaughtException()); - QEXPECT_FAIL("", "", Continue); QVERIFY(eng.uncaughtException().strictlyEquals(ret2)); QEXPECT_FAIL("", "Exception line number is wrong", Continue); QCOMPARE(eng.uncaughtExceptionLineNumber(), -1); @@ -1348,7 +1345,6 @@ void tst_QScriptEngine::uncaughtException() eng.globalObject().setProperty("throwFun", throwFun); eng.evaluate("1;\nthrowFun();"); QVERIFY(eng.hasUncaughtException()); - QEXPECT_FAIL("", "", Continue); QCOMPARE(eng.uncaughtExceptionLineNumber(), 2); eng.clearExceptions(); QVERIFY(!eng.hasUncaughtException()); @@ -1765,7 +1761,6 @@ void tst_QScriptEngine::importExtension() { QScriptEngine eng; QScriptValue ret = eng.importExtension("this.extension.does.not.exist"); - QEXPECT_FAIL("", "", Continue); QCOMPARE(eng.hasUncaughtException(), true); QCOMPARE(ret.isError(), true); QCOMPARE(ret.toString(), QString::fromLatin1("Error: Unable to import this.extension.does.not.exist: no such extension")); @@ -2048,7 +2043,6 @@ void tst_QScriptEngine::collectGarbage() QScriptValue v = eng.newQObject(ptr, QScriptEngine::ScriptOwnership); } eng.collectGarbage(); - QEXPECT_FAIL("", "", Continue); QVERIFY(ptr == 0); } -- cgit v0.12