summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2010-11-09 11:06:31 (GMT)
committerKent Hansen <kent.hansen@nokia.com>2010-11-09 11:09:50 (GMT)
commite1bcbc5bcf3d6015cacc717c31f96d2230890e88 (patch)
tree4cf04b1ec46d76d64f6e369e04aa19c39192dd2b /tests/auto
parent2d1839e850ac632a13ff0ac3096d8419bff5082d (diff)
downloadQt-e1bcbc5bcf3d6015cacc717c31f96d2230890e88.zip
Qt-e1bcbc5bcf3d6015cacc717c31f96d2230890e88.tar.gz
Qt-e1bcbc5bcf3d6015cacc717c31f96d2230890e88.tar.bz2
Add autotests for setting non-Object as prototype value
Currently it's possible to set the prototype to be any value, but this doesn't make sense; see QTBUG-15154. Mark test as expected failure until it's fixed.
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp48
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.h2
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index be51cf2..528b20e 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -2332,6 +2332,54 @@ void tst_QScriptValue::getSetPrototype_twoEngines()
}
+void tst_QScriptValue::getSetPrototype_null()
+{
+ QScriptEngine eng;
+ QScriptValue object = eng.newObject();
+ object.setPrototype(QScriptValue(QScriptValue::NullValue));
+ QVERIFY(object.prototype().isNull());
+
+ QScriptValue newProto = eng.newObject();
+ object.setPrototype(newProto);
+ QVERIFY(object.prototype().equals(newProto));
+
+ object.setPrototype(QScriptValue(&eng, QScriptValue::NullValue));
+ QVERIFY(object.prototype().isNull());
+}
+
+void tst_QScriptValue::getSetPrototype_notObjectOrNull()
+{
+ QScriptEngine eng;
+ QScriptValue object = eng.newObject();
+ QScriptValue originalProto = object.prototype();
+
+ QEXPECT_FAIL("", "QTBUG-15154: QScriptValue::setPrototype() allows a non-Object value to be set as prototype", Abort);
+
+ // bool
+ object.setPrototype(true);
+ QVERIFY(object.prototype().equals(originalProto));
+ object.setPrototype(QScriptValue(&eng, true));
+ QVERIFY(object.prototype().equals(originalProto));
+
+ // number
+ object.setPrototype(123);
+ QVERIFY(object.prototype().equals(originalProto));
+ object.setPrototype(QScriptValue(&eng, 123));
+ QVERIFY(object.prototype().equals(originalProto));
+
+ // string
+ object.setPrototype("foo");
+ QVERIFY(object.prototype().equals(originalProto));
+ object.setPrototype(QScriptValue(&eng, "foo"));
+ QVERIFY(object.prototype().equals(originalProto));
+
+ // undefined
+ object.setPrototype(QScriptValue(QScriptValue::UndefinedValue));
+ QVERIFY(object.prototype().equals(originalProto));
+ object.setPrototype(QScriptValue(&eng, QScriptValue::UndefinedValue));
+ QVERIFY(object.prototype().equals(originalProto));
+}
+
void tst_QScriptValue::getSetPrototype()
{
QScriptEngine eng;
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.h b/tests/auto/qscriptvalue/tst_qscriptvalue.h
index 45a109e..c6b2202 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.h
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.h
@@ -115,6 +115,8 @@ private slots:
void getSetPrototype_eval();
void getSetPrototype_invalidPrototype();
void getSetPrototype_twoEngines();
+ void getSetPrototype_null();
+ void getSetPrototype_notObjectOrNull();
void getSetPrototype();
void getSetScope();
void getSetProperty_HooliganTask162051();