aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-01-17 09:12:10 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-01 08:37:49 +0100
commitbe46366689eb2ed26c00b516c17b42d12c12070e (patch)
treef667331cd66eab1641cd0221d444718dedeaf927 /tests/auto/declarative
parent3a017cc96292dbda4ca9fd2ca5ac7cf8b39cd43e (diff)
Remove QJSValue::instanceOf() function
Rationale: This is a remnant from QtScript. There is no good reason for providing this type of low-level "prototype inheritance chain" checks in this high-level QJSValue class. If you want to check if an object is of the "right type", you can check if it has the properties you require using property(). Task-number: QTBUG-23604 Change-Id: I3a274212cc57c38228fab73423af481e1b95d8a5 Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qjsengine/tst_qjsengine.cpp1
-rw-r--r--tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp45
-rw-r--r--tests/auto/declarative/qjsvalue/tst_qjsvalue.h2
3 files changed, 2 insertions, 46 deletions
diff --git a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
index b24aad864c..2aed67aad1 100644
--- a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
@@ -4090,7 +4090,6 @@ void tst_QJSEngine::jsNumberClass()
QVERIFY(ctor.property("POSITIVE_INFINITY").isNumber());
QCOMPARE(ctor.propertyFlags("POSITIVE_INFINITY"), flags);
}
- QVERIFY(proto.instanceOf(eng.globalObject().property("Object")));
QCOMPARE(proto.toNumber(), qreal(0));
QVERIFY(proto.property("constructor").strictlyEquals(ctor));
diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp
index c7396c9c28..88be29c1c2 100644
--- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp
+++ b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp
@@ -1242,47 +1242,6 @@ void tst_QJSValue::toRegExp()
QVERIFY(qjsvalue_cast<QRegExp>(eng.undefinedValue()).isEmpty());
}
-void tst_QJSValue::instanceOf_twoEngines()
-{
- QJSEngine eng;
- QJSValue obj = eng.newObject();
- QJSEngine otherEngine;
- QTest::ignoreMessage(QtWarningMsg, "QJSValue::instanceof: cannot perform operation on a value created in a different engine");
- QCOMPARE(obj.instanceOf(otherEngine.globalObject().property("Object")), false);
-}
-
-void tst_QJSValue::instanceOf()
-{
- QJSEngine eng;
- QJSValue obj = eng.newObject();
- QCOMPARE(obj.instanceOf(eng.evaluate("Object.prototype")), false);
- QCOMPARE(obj.instanceOf(eng.evaluate("Array.prototype")), false);
- QCOMPARE(obj.instanceOf(eng.evaluate("Function.prototype")), false);
- QCOMPARE(obj.instanceOf(eng.evaluate("QObject.prototype")), false);
- QCOMPARE(obj.instanceOf(QJSValue(&eng, 123)), false);
- QCOMPARE(obj.instanceOf(eng.undefinedValue()), false);
- QCOMPARE(obj.instanceOf(eng.nullValue()), false);
- QCOMPARE(obj.instanceOf(QJSValue()), false);
-
- QCOMPARE(obj.instanceOf(eng.evaluate("Object")), true);
- QCOMPARE(obj.instanceOf(eng.evaluate("Array")), false);
- QCOMPARE(obj.instanceOf(eng.evaluate("Function")), false);
- QCOMPARE(obj.instanceOf(eng.evaluate("QObject")), false);
-
- QJSValue arr = eng.newArray();
- QVERIFY(arr.isArray());
- QCOMPARE(arr.instanceOf(eng.evaluate("Object.prototype")), false);
- QCOMPARE(arr.instanceOf(eng.evaluate("Array.prototype")), false);
- QCOMPARE(arr.instanceOf(eng.evaluate("Function.prototype")), false);
- QCOMPARE(arr.instanceOf(eng.evaluate("QObject.prototype")), false);
- QCOMPARE(arr.instanceOf(eng.evaluate("Object")), true);
- QCOMPARE(arr.instanceOf(eng.evaluate("Array")), true);
- QCOMPARE(arr.instanceOf(eng.evaluate("Function")), false);
- QCOMPARE(arr.instanceOf(eng.evaluate("QObject")), false);
-
- QCOMPARE(QJSValue().instanceOf(arr), false);
-}
-
void tst_QJSValue::isArray_data()
{
newEngine();
@@ -2823,7 +2782,7 @@ void tst_QJSValue::construct_simple()
QVERIFY(fun.isCallable());
QJSValue ret = fun.callAsConstructor();
QVERIFY(ret.isObject());
- QVERIFY(ret.instanceOf(fun));
+ QVERIFY(ret.prototype().strictlyEquals(fun.property("prototype")));
QCOMPARE(ret.property("foo").toInt(), 123);
}
@@ -2835,7 +2794,7 @@ void tst_QJSValue::construct_newObjectJS()
QVERIFY(fun.isCallable());
QJSValue ret = fun.callAsConstructor();
QVERIFY(ret.isObject());
- QVERIFY(!ret.instanceOf(fun));
+ QVERIFY(!ret.prototype().strictlyEquals(fun.property("prototype")));
QCOMPARE(ret.property("bar").toInt(), 456);
}
diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.h b/tests/auto/declarative/qjsvalue/tst_qjsvalue.h
index b008377170..5fcd768e96 100644
--- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.h
+++ b/tests/auto/declarative/qjsvalue/tst_qjsvalue.h
@@ -91,8 +91,6 @@ private slots:
void toQObject();
void toDateTime();
void toRegExp();
- void instanceOf_twoEngines();
- void instanceOf();
void isArray_data();
void isArray();
void isDate();