diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-01-18 14:01:39 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-20 23:35:18 +0100 |
commit | 174ee897edbea436046cfe0ea02f4185e1e0de34 (patch) | |
tree | 5ec724de6413a6ff4aaf196489cec39f8739956c /tests/auto/declarative/qjsvalue | |
parent | 95cee5d6e514891aab160c8e1fc4814c147ab3a6 (diff) |
Add QJSValue::callWithInstance() function
With the deprecated call() overload, it was confusing what the first
argument was (the this-object or an actual argument passed to the
function). Introduce a dedicated function for the
"explicit this-object" case. This makes code more readable, and
eliminates the need to pass a "dummy" this-object to call() in the
quite common case where you don't care about the this-object.
Task-number: QTBUG-23604
Change-Id: I18f8be6592a848436351516bea266fc7e9195777
Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qjsvalue')
-rw-r--r-- | tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp index 48a65dc4fe..7fb096397f 100644 --- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp @@ -2827,7 +2827,7 @@ void tst_QJSValue::call_object() QJSEngine eng; QJSValue Object = eng.evaluate("Object"); QCOMPARE(Object.isCallable(), true); - QJSValue result = Object.call(Object); + QJSValue result = Object.callWithInstance(Object); QCOMPARE(result.isObject(), true); } @@ -2840,7 +2840,7 @@ void tst_QJSValue::call_newObjects() QCOMPARE(Object.isCallable(), true); QJSValueList args; args << QJSValue(&eng, 123); - QJSValue result = Number.call(Object, args); + QJSValue result = Number.callWithInstance(Object, args); QCOMPARE(result.strictlyEquals(args.at(0)), true); } @@ -2852,7 +2852,7 @@ void tst_QJSValue::call_this() QCOMPARE(fun.isCallable(), true); QJSValue numberObject = QJSValue(&eng, 123.0).toObject(); - QJSValue result = fun.call(numberObject); + QJSValue result = fun.callWithInstance(numberObject); QCOMPARE(result.isObject(), true); QCOMPARE(result.toNumber(), 123.0); } @@ -2865,13 +2865,13 @@ void tst_QJSValue::call_arguments() QJSValue fun = eng.evaluate("(function() { return arguments[0]; })"); QCOMPARE(fun.isCallable(), true); { - QJSValue result = fun.call(eng.undefinedValue()); + QJSValue result = fun.callWithInstance(eng.undefinedValue()); QCOMPARE(result.isUndefined(), true); } { QJSValueList args; args << QJSValue(&eng, 123.0); - QJSValue result = fun.call(eng.undefinedValue(), args); + QJSValue result = fun.callWithInstance(eng.undefinedValue(), args); QCOMPARE(result.isNumber(), true); QCOMPARE(result.toNumber(), 123.0); } @@ -2879,7 +2879,7 @@ void tst_QJSValue::call_arguments() { QJSValueList args; args << QJSValue(123.0); - QJSValue result = fun.call(eng.undefinedValue(), args); + QJSValue result = fun.callWithInstance(eng.undefinedValue(), args); QCOMPARE(result.isNumber(), true); QCOMPARE(result.toNumber(), 123.0); } @@ -2887,7 +2887,7 @@ void tst_QJSValue::call_arguments() { QJSValue args = eng.newArray(); args.setProperty(0, 123); - QJSValue result = fun.call(eng.undefinedValue(), args); + QJSValue result = fun.callWithInstance(eng.undefinedValue(), args); QVERIFY(result.isNumber()); QCOMPARE(result.toNumber(), 123.0); } @@ -2904,7 +2904,7 @@ void tst_QJSValue::call() { QJSValueList args; args << QJSValue(&eng, 123.0) << QJSValue(&eng, 456.0); - QJSValue result = fun.call(eng.undefinedValue(), args); + QJSValue result = fun.callWithInstance(eng.undefinedValue(), args); QCOMPARE(result.isNumber(), true); QCOMPARE(result.toNumber(), 456.0); } @@ -2913,7 +2913,7 @@ void tst_QJSValue::call() QJSValue args = eng.newArray(); args.setProperty(0, 123); args.setProperty(1, 456); - QJSValue result = fun.call(eng.undefinedValue(), args); + QJSValue result = fun.callWithInstance(eng.undefinedValue(), args); QVERIFY(result.isNumber()); QCOMPARE(result.toNumber(), 456.0); } @@ -2938,7 +2938,7 @@ void tst_QJSValue::call() { QJSValueList args; args << QJSValue(&eng, 123.0); - QJSValue result = fun.call(eng.undefinedValue(), args); + QJSValue result = fun.callWithInstance(eng.undefinedValue(), args); QVERIFY(!eng.hasUncaughtException()); QCOMPARE(result.isNumber(), true); QCOMPARE(result.toNumber(), 123.0); @@ -2947,7 +2947,7 @@ void tst_QJSValue::call() { QJSValueList args; args << QJSValue(123.0); - QJSValue result = fun.call(eng.undefinedValue(), args); + QJSValue result = fun.callWithInstance(eng.undefinedValue(), args); QCOMPARE(result.isNumber(), true); QCOMPARE(result.toNumber(), 123.0); } @@ -2955,7 +2955,7 @@ void tst_QJSValue::call() { QJSValue args = eng.newArray(); args.setProperty(0, 123); - QJSValue result = fun.call(eng.undefinedValue(), args); + QJSValue result = fun.callWithInstance(eng.undefinedValue(), args); QVERIFY(result.isNumber()); QCOMPARE(result.toNumber(), 123.0); } @@ -2966,7 +2966,7 @@ void tst_QJSValue::call() { QJSValueList args; args << QJSValue(&eng, 123.0); - QJSValue result = fun.call(eng.undefinedValue(), args); + QJSValue result = fun.callWithInstance(eng.undefinedValue(), args); QVERIFY(!eng.hasUncaughtException()); QCOMPARE(result.isNumber(), true); QCOMPARE(result.toNumber(), 123.0); @@ -2985,7 +2985,7 @@ void tst_QJSValue::call_invalidArguments() { QJSValueList args; args << QJSValue(); - QJSValue ret = fun.call(args); + QJSValue ret = fun.callWithInstance(args); QVERIFY(!eng.hasUncaughtException()); QCOMPARE(ret.isValid(), true); QCOMPARE(ret.isUndefined(), true); @@ -3040,7 +3040,7 @@ void tst_QJSValue::call_twoEngines() QTest::ignoreMessage(QtWarningMsg, "QJSValue::call() failed: " "cannot call function with thisObject created in " "a different engine"); - QCOMPARE(fun.call(object).isValid(), false); + QCOMPARE(fun.callWithInstance(object).isValid(), false); QTest::ignoreMessage(QtWarningMsg, "QJSValue::call() failed: " "cannot call function with argument created in " "a different engine"); |