From bd3cd571ac061b0ed0e8c001c90c4edeafae67d7 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 28 Aug 2009 15:45:58 +0200 Subject: Make it possible for autotests to check if JIT is enabled or not Currently there are some differences in behavior and availability of information between the interpreter and the JIT. This is now documented as expected failures in the relevant autotests. --- src/script/api/qscriptengine.cpp | 11 +++++++++ tests/auto/qscriptcontext/tst_qscriptcontext.cpp | 24 +++++++++++--------- .../qscriptengineagent/tst_qscriptengineagent.cpp | 26 ++++++++++++++++++++++ 3 files changed, 51 insertions(+), 10 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 29044a9..46c6abb 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -3789,4 +3789,15 @@ QScriptSyntaxCheckResult &QScriptSyntaxCheckResult::operator=(const QScriptSynta return *this; } +#ifdef QT_BUILD_INTERNAL +Q_AUTOTEST_EXPORT bool qt_script_isJITEnabled() +{ +#if ENABLE(JIT) + return true; +#else + return false; +#endif +} +#endif + QT_END_NAMESPACE diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp index a85c0bd..a09d314 100644 --- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp +++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp @@ -50,6 +50,10 @@ Q_DECLARE_METATYPE(QScriptValueList) +QT_BEGIN_NAMESPACE +extern bool qt_script_isJITEnabled(); +QT_END_NAMESPACE + class tst_QScriptContext : public QObject { Q_OBJECT @@ -598,11 +602,10 @@ void tst_QScriptContext::backtrace_data() expected << "('hey') at -1" << "() at 3" -#ifdef ENABLE_JIT - << "foo(arg1 = 'hello', arg2 = 456) at testfile:2" -#else //### interpreter unfortunately does store information about line number for eval() - << "foo(arg1 = 'hello', arg2 = 456) at testfile:-1" -#endif + << QString::fromLatin1("foo(arg1 = 'hello', arg2 = 456) at testfile:%0") + // interpreter unfortunately doesn't provide line number for eval() + .arg(qt_script_isJITEnabled() ? 2 : -1); + expected << "() at testfile:4"; QTest::newRow("eval") << source << expected; @@ -661,11 +664,10 @@ void tst_QScriptContext::backtrace_data() expected << "('hey') at -1" << "() at 3" -#ifdef ENABLE_JIT - << "plop('hello', 456) at testfile:3" -#else //### interpreter unfortunately does store information about line number for eval() - << "plop('hello', 456) at testfile:-1" -#endif + << QString::fromLatin1("plop('hello', 456) at testfile:%0") + // interpreter unfortunately doesn't provide line number for eval() + .arg(qt_script_isJITEnabled() ? 3 : -1); + expected << "() at testfile:5"; QTest::newRow("eval in member") << source << expected; @@ -1009,6 +1011,8 @@ void tst_QScriptContext::calledAsConstructor() eng.evaluate("test();"); QVERIFY(!fun3.property("calledAsConstructor").toBool()); eng.evaluate("new test();"); + if (qt_script_isJITEnabled()) + QEXPECT_FAIL("", "calledAsConstructor is not correctly set for JS functions when JIT is enabled", Continue); QVERIFY(fun3.property("calledAsConstructor").toBool()); } diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp index 886c70b..f515304 100644 --- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp +++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp @@ -49,6 +49,10 @@ //TESTED_CLASS= //TESTED_FILES= +QT_BEGIN_NAMESPACE +extern bool qt_script_isJITEnabled(); +QT_END_NAMESPACE + class tst_QScriptEngineAgent : public QObject { Q_OBJECT @@ -557,6 +561,8 @@ void tst_QScriptEngineAgent::functionEntryAndExit_functionCall() spy->clear(); QVERIFY(eng.evaluate("(function() { return 123; } )()").toNumber()==123); + if (qt_script_isJITEnabled()) + QEXPECT_FAIL("", "functionExit() is not called for JS functions when JIT is enabled", Abort); QCOMPARE(spy->count(), 4); // evaluate() entry @@ -592,6 +598,8 @@ void tst_QScriptEngineAgent::functionEntryAndExit_functionCallWithoutReturn() spy->clear(); eng.evaluate("(function() { var a = 123; } )()"); + if (qt_script_isJITEnabled()) + QEXPECT_FAIL("", "functionExit() is not called for JS functions when JIT is enabled", Abort); QCOMPARE(spy->count(), 4); // evaluate() entry @@ -634,6 +642,8 @@ void tst_QScriptEngineAgent::functionEntryAndExit_functionDefinition() QVERIFY(spy->at(1).value.isUndefined()); eng.evaluate("foo()"); + if (qt_script_isJITEnabled()) + QEXPECT_FAIL("", "functionExit() is not called for JS functions when JIT is enabled", Abort); QCOMPARE(spy->count(), 6); // evaluate() entry @@ -709,6 +719,8 @@ void tst_QScriptEngineAgent::functionEntryAndExit_native2() spy->clear(); eng.evaluate("nativeFunctionCallingArg(function() { return 123; })"); + if (qt_script_isJITEnabled()) + QEXPECT_FAIL("", "functionExit() is not called for JS functions when JIT is enabled", Abort); QCOMPARE(spy->count(), 6); // evaluate() entry @@ -797,6 +809,8 @@ void tst_QScriptEngineAgent::functionEntryAndExit_builtin() spy->clear(); eng.evaluate("'ciao'.toString()"); + if (qt_script_isJITEnabled()) + QEXPECT_FAIL("", "Some events are missing when JIT is enabled", Abort); QCOMPARE(spy->count(), 4); // evaluate() entry @@ -1021,6 +1035,8 @@ void tst_QScriptEngineAgent::functionEntryAndExit_call() spy->clear(); fun.call(); + if (qt_script_isJITEnabled()) + QEXPECT_FAIL("", "functionExit() is not called for JS functions when JIT is enabled", Abort); QCOMPARE(spy->count(), 2); // entry @@ -1575,6 +1591,8 @@ void tst_QScriptEngineAgent::exceptionThrowAndCatch() { spy->clear(); eng.evaluate("try { throw new Error('ciao'); } catch (e) { }"); + if (qt_script_isJITEnabled()) + QEXPECT_FAIL("", "Some events are missing when JIT is enabled", Abort); QCOMPARE(spy->count(), 2); QCOMPARE(spy->at(0).type, ScriptEngineEvent::ExceptionThrow); @@ -1632,6 +1650,8 @@ void tst_QScriptEngineAgent::eventOrder_functionDefinition() QCOMPARE(spy->at(2).type, ScriptEngineEvent::FunctionExit); eng.evaluate("foo(123)"); + if (qt_script_isJITEnabled()) + QEXPECT_FAIL("", "Some events are missing when JIT is enabled", Abort); QCOMPARE(spy->count(), 13); // load QCOMPARE(spy->at(3).type, ScriptEngineEvent::ScriptLoad); @@ -1708,6 +1728,8 @@ void tst_QScriptEngineAgent::eventOrder_throwAndCatch() { spy->clear(); eng.evaluate("try { throw new Error('ciao') } catch (e) { void(e); }"); + if (qt_script_isJITEnabled()) + QEXPECT_FAIL("", "One event is missing when JIT is enabled", Abort); QCOMPARE(spy->count(), 12); // load QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad); @@ -1752,6 +1774,8 @@ void tst_QScriptEngineAgent::eventOrder_functions() QCOMPARE(spy->count(), 6); eng.evaluate("foo(123)"); + if (qt_script_isJITEnabled()) + QEXPECT_FAIL("", "Some events are missing when JIT is enabled", Abort); QCOMPARE(spy->count(), 21); // load @@ -1876,6 +1900,8 @@ void tst_QScriptEngineAgent::eventOrder_throwCatchFinally() { spy->clear(); eng.evaluate("try { throw 1; } catch(e) { i = e; } finally { i = 2; }"); + if (qt_script_isJITEnabled()) + QEXPECT_FAIL("", "One event is missing when JIT is enabled", Abort); QCOMPARE(spy->count(), 9); // load -- cgit v0.12