aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/v8/qjsvalue.cpp50
-rw-r--r--src/declarative/qml/v8/qjsvalue.h1
-rw-r--r--src/declarative/qml/v8/qjsvalue_impl_p.h8
-rw-r--r--src/declarative/qml/v8/qjsvalue_p.h6
-rw-r--r--tests/auto/declarative/qjsengine/tst_qjsengine.cpp44
-rw-r--r--tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp42
6 files changed, 81 insertions, 70 deletions
diff --git a/src/declarative/qml/v8/qjsvalue.cpp b/src/declarative/qml/v8/qjsvalue.cpp
index cee5dfaa02..cd0bed3472 100644
--- a/src/declarative/qml/v8/qjsvalue.cpp
+++ b/src/declarative/qml/v8/qjsvalue.cpp
@@ -73,7 +73,7 @@
Function objects (objects for which isCallable()) returns true) can
be invoked by calling call(). Constructor functions can be used to
- construct new objects by calling construct().
+ construct new objects by calling callAsConstructor().
Use equals() or strictlyEquals() to compare a QJSValue to another.
@@ -710,7 +710,7 @@ QVariant QJSValue::toVariant() const
QJSEngine::hasUncaughtException() to determine if an exception
occurred.
- \sa isCallable(), callWithInstance()
+ \sa isCallable(), callWithInstance(), callAsConstructor()
*/
QJSValue QJSValue::call(const QJSValueList &args)
{
@@ -738,8 +738,6 @@ QJSValue QJSValue::call(const QJSValueList &args)
QJSEngine::hasUncaughtException() to determine if an exception
occurred.
- \snippet doc/src/snippets/code/src_script_qjsvalue.cpp 1
-
\sa call()
*/
QJSValue QJSValue::callWithInstance(const QJSValue &instance, const QJSValueList &args)
@@ -750,6 +748,31 @@ QJSValue QJSValue::callWithInstance(const QJSValue &instance, const QJSValueList
}
/*!
+ Creates a new \c{Object} and calls this QJSValue as a
+ constructor, using the created object as the `this' object and
+ passing \a args as arguments. If the return value from the
+ constructor call is an object, then that object is returned;
+ otherwise the default constructed object is returned.
+
+ If this QJSValue is not a function, callAsConstructor() does
+ nothing and returns an undefined QJSValue.
+
+ Calling this function can cause an exception to occur in the
+ script engine; in that case, the value that was thrown
+ (typically an \c{Error} object) is returned. You can call
+ QJSEngine::hasUncaughtException() to determine if an exception
+ occurred.
+
+ \sa call(), QJSEngine::newObject()
+*/
+QJSValue QJSValue::callAsConstructor(const QJSValueList &args)
+{
+ Q_D(QJSValue);
+ QScriptIsolate api(d->engine());
+ return QJSValuePrivate::get(d->callAsConstructor(args));
+}
+
+/*!
\obsolete
Use callWithInstance() instead.
@@ -762,28 +785,15 @@ QJSValue QJSValue::call(const QJSValue& thisObject, const QJSValueList& args)
}
/*!
- Creates a new \c{Object} and calls this QJSValue as a
- constructor, using the created object as the `this' object and
- passing \a args as arguments. If the return value from the
- constructor call is an object, then that object is returned;
- otherwise the default constructed object is returned.
-
- If this QJSValue is not a function, construct() does nothing
- and returns an invalid QJSValue.
-
- Calling construct() can cause an exception to occur in the script
- engine; in that case, construct() returns the value that was thrown
- (typically an \c{Error} object). You can call
- QJSEngine::hasUncaughtException() to determine if an exception
- occurred.
+ \obsolete
- \sa call(), QJSEngine::newObject()
+ Use callAsConstructor() instead.
*/
QJSValue QJSValue::construct(const QJSValueList &args)
{
Q_D(QJSValue);
QScriptIsolate api(d->engine());
- return QJSValuePrivate::get(d->construct(args));
+ return QJSValuePrivate::get(d->callAsConstructor(args));
}
/*!
diff --git a/src/declarative/qml/v8/qjsvalue.h b/src/declarative/qml/v8/qjsvalue.h
index f3988d1819..b6e8e6a416 100644
--- a/src/declarative/qml/v8/qjsvalue.h
+++ b/src/declarative/qml/v8/qjsvalue.h
@@ -143,6 +143,7 @@ public:
bool isCallable() const;
QJSValue call(const QJSValueList &args);
QJSValue callWithInstance(const QJSValue &instance, const QJSValueList &args = QJSValueList());
+ QJSValue callAsConstructor(const QJSValueList &args = QJSValueList());
QJSValue call(const QJSValue &thisObject = QJSValue(),
const QJSValueList &args = QJSValueList());
QJSValue construct(const QJSValueList &args = QJSValueList());
diff --git a/src/declarative/qml/v8/qjsvalue_impl_p.h b/src/declarative/qml/v8/qjsvalue_impl_p.h
index 6e1cc4bbaf..9fad4c2be3 100644
--- a/src/declarative/qml/v8/qjsvalue_impl_p.h
+++ b/src/declarative/qml/v8/qjsvalue_impl_p.h
@@ -974,7 +974,7 @@ QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::call(QJSValuePrivate* thisO
return new QJSValuePrivate(e, result);
}
-inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::construct(int argc, v8::Handle<v8::Value> *argv)
+inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::callAsConstructor(int argc, v8::Handle<v8::Value> *argv)
{
QV8Engine *e = engine();
@@ -995,7 +995,7 @@ inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::construct(int argc,
return new QJSValuePrivate(e, result);
}
-inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::construct(const QJSValueList& args)
+inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::callAsConstructor(const QJSValueList& args)
{
if (!isCallable())
return InvalidValue();
@@ -1006,11 +1006,11 @@ inline QScriptPassPointer<QJSValuePrivate> QJSValuePrivate::construct(const QJSV
int argc = args.size();
QVarLengthArray<v8::Handle<v8::Value>, 8> argv(argc);
if (!prepareArgumentsForCall(argv.data(), args)) {
- qWarning("QJSValue::construct() failed: cannot construct function with argument created in a different engine");
+ qWarning("QJSValue::callAsConstructor() failed: cannot construct function with argument created in a different engine");
return InvalidValue();
}
- return construct(argc, argv.data());
+ return callAsConstructor(argc, argv.data());
}
/*! \internal
diff --git a/src/declarative/qml/v8/qjsvalue_p.h b/src/declarative/qml/v8/qjsvalue_p.h
index c3677e351d..87bcfda62a 100644
--- a/src/declarative/qml/v8/qjsvalue_p.h
+++ b/src/declarative/qml/v8/qjsvalue_p.h
@@ -138,9 +138,9 @@ public:
inline QScriptPassPointer<QJSValuePrivate> call(QJSValuePrivate* thisObject, const QJSValueList& args);
inline QScriptPassPointer<QJSValuePrivate> call(QJSValuePrivate* thisObject, const QJSValue& arguments);
inline QScriptPassPointer<QJSValuePrivate> call(QJSValuePrivate* thisObject, int argc, v8::Handle< v8::Value >* argv);
- inline QScriptPassPointer<QJSValuePrivate> construct(int argc, v8::Handle<v8::Value> *argv);
- inline QScriptPassPointer<QJSValuePrivate> construct(const QJSValueList& args);
- inline QScriptPassPointer<QJSValuePrivate> construct(const QJSValue& arguments);
+ inline QScriptPassPointer<QJSValuePrivate> callAsConstructor(int argc, v8::Handle<v8::Value> *argv);
+ inline QScriptPassPointer<QJSValuePrivate> callAsConstructor(const QJSValueList& args);
+ inline QScriptPassPointer<QJSValuePrivate> callAsConstructor(const QJSValue& arguments);
inline bool assignEngine(QV8Engine *engine);
inline QV8Engine *engine() const;
diff --git a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
index 68c197486d..638e739073 100644
--- a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
@@ -453,7 +453,7 @@ void tst_QJSEngine::newFunction()
QCOMPARE(fun.prototype().strictlyEquals(eng.evaluate("Function.prototype")), true);
QCOMPARE(fun.call().isNull(), true);
- QCOMPARE(fun.construct().isObject(), true);
+ QCOMPARE(fun.callAsConstructor().isObject(), true);
}
}
@@ -478,7 +478,7 @@ void tst_QJSEngine::newFunctionWithArg()
QCOMPARE(fun.prototype().strictlyEquals(eng.evaluate("Function.prototype")), true);
QCOMPARE(fun.call().isNull(), true);
- QCOMPARE(fun.construct().isObject(), true);
+ QCOMPARE(fun.callAsConstructor().isObject(), true);
}
}
@@ -502,7 +502,7 @@ void tst_QJSEngine::newFunctionWithProto()
QCOMPARE(proto.propertyFlags("constructor"), QScriptValue::SkipInEnumeration);
QCOMPARE(fun.call().isNull(), true);
- QCOMPARE(fun.construct().isObject(), true);
+ QCOMPARE(fun.callAsConstructor().isObject(), true);
}
// whether the return value is correct
{
@@ -841,7 +841,7 @@ void tst_QJSEngine::jsRegExp()
QJSValue r4 = rxCtor.call(QJSValueList() << "foo" << "gim");
QVERIFY(r4.isRegExp());
- QJSValue r5 = rxCtor.construct(QJSValueList() << r);
+ QJSValue r5 = rxCtor.callAsConstructor(QJSValueList() << r);
QVERIFY(r5.isRegExp());
QCOMPARE(r5.toString(), QString::fromLatin1("/foo/gim"));
// In JSC, constructing a RegExp from another produces the same identical object.
@@ -849,7 +849,7 @@ void tst_QJSEngine::jsRegExp()
QVERIFY(!r5.strictlyEquals(r));
QEXPECT_FAIL("", "V8 and jsc ignores invalid flags", Continue); //https://bugs.webkit.org/show_bug.cgi?id=41614
- QJSValue r6 = rxCtor.construct(QJSValueList() << "foo" << "bar");
+ QJSValue r6 = rxCtor.callAsConstructor(QJSValueList() << "foo" << "bar");
QVERIFY(r6.isError());
// QVERIFY(r6.toString().contains(QString::fromLatin1("SyntaxError"))); // Invalid regular expression flag
@@ -865,15 +865,15 @@ void tst_QJSEngine::jsRegExp()
QVERIFY(r8.isRegExp());
QCOMPARE(r8.toString(), QString::fromLatin1("/foo/gim"));
- QJSValue r9 = rxCtor.construct();
+ QJSValue r9 = rxCtor.callAsConstructor();
QVERIFY(r9.isRegExp());
QCOMPARE(r9.toString(), QString::fromLatin1("/(?:)/"));
- QJSValue r10 = rxCtor.construct(QJSValueList() << "" << "gim");
+ QJSValue r10 = rxCtor.callAsConstructor(QJSValueList() << "" << "gim");
QVERIFY(r10.isRegExp());
QCOMPARE(r10.toString(), QString::fromLatin1("/(?:)/gim"));
- QJSValue r11 = rxCtor.construct(QJSValueList() << "{1.*}" << "g");
+ QJSValue r11 = rxCtor.callAsConstructor(QJSValueList() << "{1.*}" << "g");
QVERIFY(r11.isRegExp());
QCOMPARE(r11.toString(), QString::fromLatin1("/{1.*}/g"));
}
@@ -1208,14 +1208,14 @@ void tst_QJSEngine::newQMetaObject()
QCOMPARE(qclass.prototype().isObject(), true);
QCOMPARE(qclass2.prototype().isObject(), true);
- QScriptValue instance = qclass.construct();
+ QScriptValue instance = qclass.callAsConstructor();
QCOMPARE(instance.isQObject(), true);
QCOMPARE(instance.toQObject()->metaObject(), qclass.toQMetaObject());
QEXPECT_FAIL("", "FIXME: newQMetaObject not implemented properly yet", Abort);
QVERIFY(instance.instanceOf(qclass));
QVERIFY(instanceofJS(instance, qclass).strictlyEquals(true));
- QScriptValue instance2 = qclass2.construct();
+ QScriptValue instance2 = qclass2.callAsConstructor();
QCOMPARE(instance2.isQObject(), true);
QCOMPARE(instance2.toQObject()->metaObject(), qclass2.toQMetaObject());
QVERIFY(instance2.instanceOf(qclass2));
@@ -1225,7 +1225,7 @@ void tst_QJSEngine::newQMetaObject()
QScriptValueList args;
args << instance;
- QScriptValue instance3 = qclass.construct(args);
+ QScriptValue instance3 = qclass.callAsConstructor(args);
QCOMPARE(instance3.isQObject(), true);
QCOMPARE(instance3.toQObject()->parent(), instance.toQObject());
QVERIFY(instance3.instanceOf(qclass));
@@ -1272,7 +1272,7 @@ void tst_QJSEngine::newQMetaObject()
QVERIFY(instanceofJS(ret, qclass).strictlyEquals(false));
}
{
- QScriptValue ret = qclass3.construct();
+ QScriptValue ret = qclass3.callAsConstructor();
QVERIFY(ret.isObject());
QVERIFY(ret.property("isCalledAsConstructor").isBool());
QVERIFY(ret.property("isCalledAsConstructor").toBool());
@@ -1283,14 +1283,14 @@ void tst_QJSEngine::newQMetaObject()
}
// subclassing
- qclass2.setProperty("prototype", qclass.construct());
- QVERIFY(qclass2.construct().instanceOf(qclass));
- QVERIFY(instanceofJS(qclass2.construct(), qclass).strictlyEquals(true));
+ qclass2.setProperty("prototype", qclass.callAsConstructor());
+ QVERIFY(qclass2.callAsConstructor().instanceOf(qclass));
+ QVERIFY(instanceofJS(qclass2.callAsConstructor(), qclass).strictlyEquals(true));
// with meta-constructor
QScriptValue qclass4 = eng.newQMetaObject(&QObject::staticMetaObject);
{
- QScriptValue inst = qclass4.construct();
+ QScriptValue inst = qclass4.callAsConstructor();
QVERIFY(inst.isQObject());
QVERIFY(inst.toQObject() != 0);
QCOMPARE(inst.toQObject()->parent(), (QObject*)0);
@@ -1300,7 +1300,7 @@ void tst_QJSEngine::newQMetaObject()
QVERIFY(instanceofJS(inst, qclass3).strictlyEquals(false));
}
{
- QScriptValue inst = qclass4.construct(QScriptValueList() << eng.newQObject(this));
+ QScriptValue inst = qclass4.callAsConstructor(QScriptValueList() << eng.newQObject(this));
QVERIFY(inst.isQObject());
QVERIFY(inst.toQObject() != 0);
QCOMPARE(inst.toQObject()->parent(), (QObject*)this);
@@ -2896,7 +2896,7 @@ static QScriptValue recurse(QScriptContext *ctx, QScriptEngine *eng)
static QScriptValue recurse2(QScriptContext *ctx, QScriptEngine *eng)
{
Q_UNUSED(eng);
- return ctx->callee().construct();
+ return ctx->callee().callAsConstructor();
}
void tst_QJSEngine::infiniteRecursion()
@@ -2920,7 +2920,7 @@ void tst_QJSEngine::infiniteRecursion()
}
{
QScriptValue fun = eng.newFunction(recurse2);
- QScriptValue ret = fun.construct();
+ QScriptValue ret = fun.callAsConstructor();
QCOMPARE(ret.isError(), true);
QCOMPARE(ret.toString(), stackOverflowError);
}
@@ -3236,7 +3236,7 @@ void tst_QJSEngine::processEventsWhileRunning_function()
QCOMPARE(eng.processEventsInterval(), 100);
if (x) script.call();
- else script.construct();
+ else script.callAsConstructor();
QVERIFY(!eng.hasUncaughtException());
QVERIFY(receiver.received);
@@ -6456,13 +6456,13 @@ void tst_QJSEngine::scriptValueFromQMetaObject()
QCOMPARE(meta.toQMetaObject(), &QScriptEngine::staticMetaObject);
// Because of missing Q_SCRIPT_DECLARE_QMETAOBJECT() for QScriptEngine.
QEXPECT_FAIL("", "FIXME: because construct never returns invalid values", Continue);
- QVERIFY(!meta.construct().isValid());
+ QVERIFY(!meta.callAsConstructor().isValid());
}
{
QScriptValue meta = eng.scriptValueFromQMetaObject<QStandardItemModel>();
QVERIFY(meta.isQMetaObject());
QCOMPARE(meta.toQMetaObject(), &QStandardItemModel::staticMetaObject);
- QScriptValue obj = meta.construct(QScriptValueList() << eng.newQObject(&eng));
+ QScriptValue obj = meta.callAsConstructor(QScriptValueList() << eng.newQObject(&eng));
QVERIFY(obj.isQObject());
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(obj.toQObject());
QVERIFY(model != 0);
diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp
index 7fb096397f..5ac3e77b16 100644
--- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp
+++ b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp
@@ -3164,7 +3164,7 @@ void tst_QJSValue::construct_nonFunction_data()
void tst_QJSValue::construct_nonFunction()
{
QFETCH(QJSValue, value);
- QVERIFY(!value.construct().isValid());
+ QVERIFY(!value.callAsConstructor().isValid());
}
void tst_QJSValue::construct_simple()
@@ -3172,7 +3172,7 @@ void tst_QJSValue::construct_simple()
QJSEngine eng;
QJSValue fun = eng.evaluate("(function () { this.foo = 123; })");
QVERIFY(fun.isCallable());
- QJSValue ret = fun.construct();
+ QJSValue ret = fun.callAsConstructor();
QVERIFY(ret.isObject());
QVERIFY(ret.instanceOf(fun));
QCOMPARE(ret.property("foo").toInt(), 123);
@@ -3184,7 +3184,7 @@ void tst_QJSValue::construct_newObjectJS()
// returning a different object overrides the default-constructed one
QJSValue fun = eng.evaluate("(function () { return { bar: 456 }; })");
QVERIFY(fun.isCallable());
- QJSValue ret = fun.construct();
+ QJSValue ret = fun.callAsConstructor();
QVERIFY(ret.isObject());
QVERIFY(!ret.instanceOf(fun));
QCOMPARE(ret.property("bar").toInt(), 456);
@@ -3195,7 +3195,7 @@ void tst_QJSValue::construct_undefined()
{
QScriptEngine eng;
QJSValue fun = eng.newFunction(ctorReturningUndefined);
- QJSValue ret = fun.construct();
+ QJSValue ret = fun.callAsConstructor();
QVERIFY(ret.isObject());
QVERIFY(ret.instanceOf(fun));
QCOMPARE(ret.property("foo").toInt(), 123);
@@ -3205,7 +3205,7 @@ void tst_QJSValue::construct_newObjectCpp()
{
QScriptEngine eng;
QJSValue fun = eng.newFunction(ctorReturningNewObject);
- QJSValue ret = fun.construct();
+ QJSValue ret = fun.callAsConstructor();
QVERIFY(ret.isObject());
QVERIFY(!ret.instanceOf(fun));
QCOMPARE(ret.property("bar").toInt(), 456);
@@ -3219,7 +3219,7 @@ void tst_QJSValue::construct_arg()
QCOMPARE(Number.isCallable(), true);
QJSValueList args;
args << QJSValue(&eng, 123);
- QJSValue ret = Number.construct(args);
+ QJSValue ret = Number.callAsConstructor(args);
QCOMPARE(ret.isObject(), true);
QCOMPARE(ret.toNumber(), args.at(0).toNumber());
}
@@ -3231,7 +3231,7 @@ void tst_QJSValue::construct_proto()
QJSValue fun = eng.evaluate("(function() { return this.__proto__; })");
QCOMPARE(fun.isCallable(), true);
QCOMPARE(fun.property("prototype").isObject(), true);
- QJSValue ret = fun.construct();
+ QJSValue ret = fun.callAsConstructor();
QCOMPARE(fun.property("prototype").strictlyEquals(ret), true);
}
@@ -3241,7 +3241,7 @@ void tst_QJSValue::construct_returnInt()
// test that we return the new object even if a non-object value is returned from the function
QJSValue fun = eng.evaluate("(function() { return 123; })");
QCOMPARE(fun.isCallable(), true);
- QJSValue ret = fun.construct();
+ QJSValue ret = fun.callAsConstructor();
QCOMPARE(ret.isObject(), true);
}
@@ -3250,7 +3250,7 @@ void tst_QJSValue::construct_throw()
QJSEngine eng;
QJSValue fun = eng.evaluate("(function() { throw new Error('foo'); })");
QCOMPARE(fun.isCallable(), true);
- QJSValue ret = fun.construct();
+ QJSValue ret = fun.callAsConstructor();
QCOMPARE(ret.isError(), true);
QCOMPARE(eng.hasUncaughtException(), true);
QVERIFY(ret.strictlyEquals(eng.uncaughtException()));
@@ -3267,7 +3267,7 @@ void tst_QJSValue::construct()
array.setProperty(1, QJSValue(&eng, 456.0));
array.setProperty(2, QJSValue(&eng, 789.0));
// construct with single array object as arguments
- QJSValue ret = fun.construct(array);
+ QJSValue ret = fun.callAsConstructor(array);
QVERIFY(!eng.hasUncaughtException());
QVERIFY(ret.isValid());
QVERIFY(ret.isObject());
@@ -3275,25 +3275,25 @@ void tst_QJSValue::construct()
QCOMPARE(ret.property(1).strictlyEquals(array.property(1)), true);
QCOMPARE(ret.property(2).strictlyEquals(array.property(2)), true);
// construct with arguments object as arguments
- QJSValue ret2 = fun.construct(ret);
+ QJSValue ret2 = fun.callAsConstructor(ret);
QCOMPARE(ret2.property(0).strictlyEquals(ret.property(0)), true);
QCOMPARE(ret2.property(1).strictlyEquals(ret.property(1)), true);
QCOMPARE(ret2.property(2).strictlyEquals(ret.property(2)), true);
// construct with null as arguments
- QJSValue ret3 = fun.construct(eng.nullValue());
+ QJSValue ret3 = fun.callAsConstructor(eng.nullValue());
QCOMPARE(ret3.isError(), false);
QCOMPARE(ret3.property("length").isNumber(), true);
QCOMPARE(ret3.property("length").toNumber(), 0.0);
// construct with undefined as arguments
- QJSValue ret4 = fun.construct(eng.undefinedValue());
+ QJSValue ret4 = fun.callAsConstructor(eng.undefinedValue());
QCOMPARE(ret4.isError(), false);
QCOMPARE(ret4.property("length").isNumber(), true);
QCOMPARE(ret4.property("length").toNumber(), 0.0);
// construct with something else as arguments
- QJSValue ret5 = fun.construct(QJSValue(&eng, 123.0));
+ QJSValue ret5 = fun.callAsConstructor(QJSValue(&eng, 123.0));
QCOMPARE(ret5.isError(), true);
// construct with a non-array object as arguments
- QJSValue ret6 = fun.construct(eng.globalObject());
+ QJSValue ret6 = fun.callAsConstructor(eng.globalObject());
QVERIFY(ret6.isError());
QCOMPARE(ret6.toString(), QString::fromLatin1("TypeError: Arguments must be an array"));
}
@@ -3305,10 +3305,10 @@ void tst_QJSValue::construct_twoEngines()
QJSEngine otherEngine;
QJSValue ctor = engine.evaluate("(function (a, b) { this.foo = 123; })");
QJSValue arg(&otherEngine, 124567);
- QTest::ignoreMessage(QtWarningMsg, "QJSValue::construct() failed: cannot construct function with argument created in a different engine");
- QVERIFY(!ctor.construct(QJSValueList() << arg).isValid());
- QTest::ignoreMessage(QtWarningMsg, "QJSValue::construct() failed: cannot construct function with argument created in a different engine");
- QVERIFY(!ctor.construct(QJSValueList() << arg << otherEngine.newObject()).isValid());
+ QTest::ignoreMessage(QtWarningMsg, "QJSValue::callAsConstructor() failed: cannot construct function with argument created in a different engine");
+ QVERIFY(!ctor.callAsConstructor(QJSValueList() << arg).isValid());
+ QTest::ignoreMessage(QtWarningMsg, "QJSValue::callAsConstructor() failed: cannot construct function with argument created in a different engine");
+ QVERIFY(!ctor.callAsConstructor(QJSValueList() << arg << otherEngine.newObject()).isValid());
}
void tst_QJSValue::construct_constructorThrowsPrimitive()
@@ -3318,7 +3318,7 @@ void tst_QJSValue::construct_constructorThrowsPrimitive()
QVERIFY(fun.isCallable());
// construct(QJSValueList)
{
- QJSValue ret = fun.construct();
+ QJSValue ret = fun.callAsConstructor();
QVERIFY(ret.isNumber());
QCOMPARE(ret.toNumber(), 123.0);
QVERIFY(eng.hasUncaughtException());
@@ -3328,7 +3328,7 @@ void tst_QJSValue::construct_constructorThrowsPrimitive()
#if 0 // FIXME: The feature of interpreting an array as argument list has been removed from the API
// construct(QJSValue)
{
- QJSValue ret = fun.construct(eng.newArray());
+ QJSValue ret = fun.callAsConstructor(eng.newArray());
QVERIFY(ret.isNumber());
QCOMPARE(ret.toNumber(), 123.0);
QVERIFY(eng.hasUncaughtException());