aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-10-21 09:50:27 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-29 10:38:55 +0100
commite0284ab41f7a1889f28e719212df66e942959f4c (patch)
treedfbd27e96968c07d49372c6ed06f0b51f2c6c8b8 /tests/auto/qml/qqmlecmascript
parent59cc901d3d15079b3666e5902b4c8b1a83ff1fd2 (diff)
Properly propagate parse errors
Replace all try/catch statements used when parsing with checks for engine->hasException. Change-Id: I4493cb600d5a3eb095c2003bb88bd031403e47c9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp73
1 files changed, 41 insertions, 32 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index e764ae783c..5caf5722af 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -2257,15 +2257,16 @@ static inline bool evaluate_error(QV8Engine *engine, const QV4::ValueRef o, cons
QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current;
QV4::Scope scope(ctx);
- try {
- QV4::Scoped<QV4::FunctionObject> function(scope, program.run());
- if (!function)
- return false;
- QV4::ScopedCallData d(scope, 1);
- d->args[0] = o;
- d->thisObject = engine->global();
- function->call(d);
- } catch (...) {
+ QV4::Scoped<QV4::FunctionObject> function(scope, program.run());
+ if (scope.engine->hasException) {
+ ctx->catchException();
+ return true;
+ }
+ QV4::ScopedCallData d(scope, 1);
+ d->args[0] = o;
+ d->thisObject = engine->global();
+ function->call(d);
+ if (scope.engine->hasException) {
ctx->catchException();
return true;
}
@@ -2284,21 +2285,24 @@ static inline bool evaluate_value(QV8Engine *engine, const QV4::ValueRef o,
QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current;
QV4::Scope scope(ctx);
- try {
- QV4::Scoped<QV4::FunctionObject> function(scope, program.run());
- if (!function)
- return false;
-
- QV4::ScopedValue value(scope);
- QV4::ScopedCallData d(scope, 1);
- d->args[0] = o;
- d->thisObject = engine->global();
- value = function->call(d);
- return __qmljs_strict_equal(value, result);
- } catch (...) {
+ QV4::Scoped<QV4::FunctionObject> function(scope, program.run());
+ if (scope.engine->hasException) {
ctx->catchException();
+ return false;
}
- return false;
+ if (!function)
+ return false;
+
+ QV4::ScopedValue value(scope);
+ QV4::ScopedCallData d(scope, 1);
+ d->args[0] = o;
+ d->thisObject = engine->global();
+ value = function->call(d);
+ if (scope.engine->hasException) {
+ ctx->catchException();
+ return false;
+ }
+ return __qmljs_strict_equal(value, result);
}
static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::ValueRef o,
@@ -2312,18 +2316,23 @@ static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::ValueRef
QV4::Script program(QV8Engine::getV4(engine)->rootContext, functionSource);
program.inheritContext = true;
- try {
- QV4::Scoped<QV4::FunctionObject> function(scope, program.run());
- if (!function)
- return QV4::Encode::undefined();
- QV4::ScopedCallData d(scope, 1);
- d->args[0] = o;
- d->thisObject = engine->global();
- return function->call(d);
- } catch (...) {
+
+ QV4::Scoped<QV4::FunctionObject> function(scope, program.run());
+ if (scope.engine->hasException) {
+ ctx->catchException();
+ return QV4::Encode::undefined();
+ }
+ if (!function)
+ return QV4::Encode::undefined();
+ QV4::ScopedCallData d(scope, 1);
+ d->args[0] = o;
+ d->thisObject = engine->global();
+ QV4::ScopedValue result(scope, function->call(d));
+ if (scope.engine->hasException) {
ctx->catchException();
+ return QV4::Encode::undefined();
}
- return QV4::Encode::undefined();
+ return result.asReturnedValue();
}
#define EVALUATE_ERROR(source) evaluate_error(engine, object, source)