diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-03-07 13:56:33 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-03 09:52:41 +0200 |
commit | b9ccb579c4c93f23e6ceeea26b07d418ad4e5562 (patch) | |
tree | e4def9e28c2b6a612531d698b31e2ec99ea451f1 /tests | |
parent | 51b3e8e7ef5af9ff6c40027daa3a04c58b6a4bd2 (diff) |
Remove QJS exception API
This API has been deprecated for a while. It's legacy stuff from
QtScript.
Until someone proves that QJSValue::isError() isn't sufficient to
handle JavaScript exceptions, we won't provide any additional API
for that.
Also removed QJSValuePrivate::lessThan(), which was using the
exception mechanism, but the function itself wasn't used anymore
(another remnant from the QtScript days).
Change-Id: I3dffc6a7835874153f90d25ae2a72c93ea6db39a
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qjsengine/tst_qjsengine.cpp | 32 | ||||
-rw-r--r-- | tests/auto/qml/qjsvalue/tst_qjsvalue.cpp | 32 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 6 | ||||
-rw-r--r-- | tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp | 9 |
4 files changed, 17 insertions, 62 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 5ebc42a453..bf76adbf6d 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -2114,13 +2114,13 @@ void tst_QJSEngine::evaluate() ret = eng.evaluate(code, /*fileName =*/QString(), lineNumber); else ret = eng.evaluate(code); - QCOMPARE(eng.hasUncaughtException(), expectHadError); + QCOMPARE(ret.isError(), expectHadError); #if 0 // ###FIXME: No support for the line number of an uncaught exception QEXPECT_FAIL("f()", "SyntaxError do not report line number", Continue); QEXPECT_FAIL("duplicateLabel: { duplicateLabel: ; }", "SyntaxError do not report line number", Continue); QCOMPARE(eng.uncaughtExceptionLineNumber(), expectErrorLineNumber); #endif - if (eng.hasUncaughtException() && ret.isError()) { + if (ret.isError()) { QEXPECT_FAIL("", "we have no more lineNumber property ", Continue); QVERIFY(ret.property("lineNumber").strictlyEquals(eng.toScriptValue(expectErrorLineNumber))); } else { @@ -3089,7 +3089,7 @@ void tst_QJSEngine::gcWithNestedDataStructure() // The GC must be able to traverse deeply nested objects, otherwise this // test would crash. QJSEngine eng; - eng.evaluate( + QJSValue ret = eng.evaluate( "function makeList(size)" "{" " var head = { };" @@ -3101,10 +3101,10 @@ void tst_QJSEngine::gcWithNestedDataStructure() " l.next = null;" " return head;" "}"); - QCOMPARE(eng.hasUncaughtException(), false); + QVERIFY(!ret.isError()); const int size = 200; QJSValue head = eng.evaluate(QString::fromLatin1("makeList(%0)").arg(size)); - QCOMPARE(eng.hasUncaughtException(), false); + QVERIFY(!head.isError()); for (int x = 0; x < 2; ++x) { if (x == 1) eng.evaluate("gc()"); @@ -3294,14 +3294,8 @@ void tst_QJSEngine::stacktrace() QJSEngine eng; QJSValue result = eng.evaluate(script, fileName); - QVERIFY(eng.hasUncaughtException()); QVERIFY(result.isError()); - // QEXPECT_FAIL("", "QTBUG-6139: uncaughtExceptionBacktrace() doesn't give the full backtrace", Abort); - // ###FIXME: no uncahgutExceptionBacktrace: QCOMPARE(eng.uncaughtExceptionBacktrace(), backtrace); - QVERIFY(eng.hasUncaughtException()); - QVERIFY(result.strictlyEquals(eng.uncaughtException())); - // FIXME? it is not standard. //QCOMPARE(result.property("fileName").toString(), fileName); //QCOMPARE(result.property("lineNumber").toInt(), 9); @@ -3344,7 +3338,6 @@ void tst_QJSEngine::stacktrace() // } // throw something that isn't an Error object - eng.clearExceptions(); // ###FIXME: No uncaughtExceptionBacktrace: QVERIFY(eng.uncaughtExceptionBacktrace().isEmpty()); QString script2 = QString::fromLatin1( "function foo(counter) {\n" @@ -3361,16 +3354,8 @@ void tst_QJSEngine::stacktrace() "foo(0);"); QJSValue result2 = eng.evaluate(script2, fileName); - QVERIFY(eng.hasUncaughtException()); QVERIFY(!result2.isError()); QVERIFY(result2.isString()); - - // ###FIXME: No uncaughtExceptionBacktrace: QCOMPARE(eng.uncaughtExceptionBacktrace(), backtrace); - QVERIFY(eng.hasUncaughtException()); - - eng.clearExceptions(); - QVERIFY(!eng.hasUncaughtException()); - // ###FIXME: No uncaughtExceptionBacktrace: QVERIFY(eng.uncaughtExceptionBacktrace().isEmpty()); } void tst_QJSEngine::numberParsing_data() @@ -3949,8 +3934,6 @@ void tst_QJSEngine::errorConstructors() code += name + QLatin1String("()"); QJSValue ret = eng.evaluate(code); QVERIFY(ret.isError()); - QCOMPARE(eng.hasUncaughtException(), x == 0); - eng.clearExceptions(); QVERIFY(ret.toString().startsWith(name)); //QTBUG-6138: JSC doesn't assign lineNumber when errors are not thrown QEXPECT_FAIL("", "we have no more lineNumber property ", Continue); @@ -4797,7 +4780,6 @@ void tst_QJSEngine::jsThrowInsideWithStatement() QVERIFY(ret.toString().contains(QString::fromLatin1("ReferenceError"))); } { - eng.clearExceptions(); QJSValue ret = eng.evaluate( "o = { bug : \"no bug\" };" "with (o) {" @@ -4807,12 +4789,11 @@ void tst_QJSEngine::jsThrowInsideWithStatement() " bug;" " }" "}"); + QVERIFY(!ret.isError()); QVERIFY(ret.isNumber()); QCOMPARE(ret.toInt(), 123); - QVERIFY(eng.hasUncaughtException()); } { - eng.clearExceptions(); QJSValue ret = eng.evaluate( "o = { bug : \"no bug\" };" "with (o) {" @@ -6337,7 +6318,6 @@ void tst_QJSEngine::functionPrototypeExtensions() // No properties should appear in for-in statements. QJSValue props = eng.evaluate("props = []; for (var p in Function.prototype) props.push(p); props"); - QVERIFY(!eng.hasUncaughtException()); QVERIFY(props.isArray()); QCOMPARE(props.property("length").toInt(), 0); } diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index 3522f22ca2..6393ae5182 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -382,22 +382,17 @@ void tst_QJSValue::toString() " return o;" "})()"); QCOMPARE(objectObject.toString(), QLatin1String("Error: toString")); - QVERIFY(eng.hasUncaughtException()); - QCOMPARE(eng.uncaughtException().toString(), QLatin1String("Error: toString")); } { - eng.clearExceptions(); QJSValue objectObject = eng.evaluate( "(function(){" " var f = function() {};" " f.prototype = Date;" " return new f;" "})()"); - QVERIFY(!eng.hasUncaughtException()); + QVERIFY(!objectObject.isError()); QVERIFY(objectObject.isObject()); QCOMPARE(objectObject.toString(), QString::fromLatin1("TypeError: Function.prototype.toString is not generic")); - QVERIFY(eng.hasUncaughtException()); - eng.clearExceptions(); } QJSValue inv = QJSValue(); @@ -1690,17 +1685,15 @@ void tst_QJSValue::getSetProperty_gettersAndSettersThrowErrorJS() "o.__defineGetter__('foo', function() { throw new Error('get foo') }); " "o.__defineSetter__('foo', function() { throw new Error('set foo') }); "); QJSValue object = eng.evaluate("o"); - QVERIFY(!eng.hasUncaughtException()); + QVERIFY(!object.isError()); QJSValue ret = object.property("foo"); QVERIFY(ret.isError()); - QVERIFY(eng.hasUncaughtException()); - QVERIFY(ret.strictlyEquals(eng.uncaughtException())); QCOMPARE(ret.toString(), QLatin1String("Error: get foo")); - eng.evaluate("Object"); // clear exception state... - QVERIFY(!eng.hasUncaughtException()); + QVERIFY(!eng.evaluate("Object").isError()); // clear exception state... object.setProperty("foo", str); - QVERIFY(eng.hasUncaughtException()); - QCOMPARE(eng.uncaughtException().toString(), QLatin1String("Error: set foo")); +// ### No way to check whether setProperty() threw an exception +// QVERIFY(eng.hasUncaughtException()); +// QCOMPARE(eng.uncaughtException().toString(), QLatin1String("Error: set foo")); } void tst_QJSValue::getSetProperty_gettersAndSettersOnNative() @@ -2041,8 +2034,6 @@ void tst_QJSValue::getSetPrototype_evalCyclicPrototype() { QJSEngine eng; QJSValue ret = eng.evaluate("o = { }; p = { }; o.__proto__ = p; p.__proto__ = o"); - QCOMPARE(eng.hasUncaughtException(), true); - QVERIFY(ret.strictlyEquals(eng.uncaughtException())); QCOMPARE(ret.isError(), true); QCOMPARE(ret.toString(), QLatin1String("Error: Cyclic __proto__ value")); } @@ -2051,7 +2042,6 @@ void tst_QJSValue::getSetPrototype_eval() { QJSEngine eng; QJSValue ret = eng.evaluate("p = { }; p.__proto__ = { }"); - QCOMPARE(eng.hasUncaughtException(), false); QCOMPARE(ret.isError(), false); } @@ -2499,13 +2489,11 @@ void tst_QJSValue::call() { QJSValue fun = eng.evaluate("(function() { throw new Error('foo'); })"); QCOMPARE(fun.isCallable(), true); - QVERIFY(!eng.hasUncaughtException()); + QVERIFY(!fun.isError()); { QJSValue result = fun.call(); QCOMPARE(result.isError(), true); - QCOMPARE(eng.hasUncaughtException(), true); - QVERIFY(result.strictlyEquals(eng.uncaughtException())); } } #if 0 // FIXME: No c-style callbacks @@ -2828,8 +2816,6 @@ void tst_QJSValue::construct_throw() QCOMPARE(fun.isCallable(), true); QJSValue ret = fun.callAsConstructor(); QCOMPARE(ret.isError(), true); - QCOMPARE(eng.hasUncaughtException(), true); - QVERIFY(ret.strictlyEquals(eng.uncaughtException())); } #if 0 // FIXME: The feature of interpreting an array as argument list has been removed from the API @@ -2896,9 +2882,7 @@ void tst_QJSValue::construct_constructorThrowsPrimitive() QJSValue ret = fun.callAsConstructor(); QVERIFY(ret.isNumber()); QCOMPARE(ret.toNumber(), 123.0); - QVERIFY(eng.hasUncaughtException()); - QVERIFY(ret.strictlyEquals(eng.uncaughtException())); - eng.clearExceptions(); + QVERIFY(!ret.isError()); } #if 0 // FIXME: The feature of interpreting an array as argument list has been removed from the API // construct(QJSValue) diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 30914977d8..4e7f1a255c 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -3391,7 +3391,7 @@ void tst_qqmlecmascript::signalWithJSValueInVariant() QVERIFY(object != 0); QJSValue value = engine.evaluate(expression); - QVERIFY(!engine.hasUncaughtException()); + QVERIFY(!value.isError()); object->setProperty("expression", expression); object->setProperty("compare", compare); object->setProperty("pass", false); @@ -3416,7 +3416,7 @@ void tst_qqmlecmascript::signalWithJSValueInVariant_twoEngines() QJSEngine engine2; QJSValue value = engine2.evaluate(expression); - QVERIFY(!engine2.hasUncaughtException()); + QVERIFY(!value.isError()); object->setProperty("expression", expression); object->setProperty("compare", compare); object->setProperty("pass", false); @@ -3441,7 +3441,7 @@ void tst_qqmlecmascript::signalWithQJSValue() QVERIFY(object != 0); QJSValue value = engine.evaluate(expression); - QVERIFY(!engine.hasUncaughtException()); + QVERIFY(!value.isError()); object->setProperty("expression", expression); object->setProperty("compare", compare); object->setProperty("pass", false); diff --git a/tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp b/tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp index 5713eb2f2e..7bf4bd2396 100644 --- a/tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp +++ b/tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp @@ -74,7 +74,6 @@ private slots: void connectAndDisconnect(); #endif void globalObject(); - void hasUncaughtException(); #if 0 // no is Evaluating for now void isEvaluating(); #endif @@ -271,14 +270,6 @@ void tst_QJSEngine::globalObject() } } -void tst_QJSEngine::hasUncaughtException() -{ - newEngine(); - QBENCHMARK { - m_engine->hasUncaughtException(); - } -} - #if 0 void tst_QJSEngine::isEvaluating() { |