summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qscriptvalue/tst_qscriptvalue.cpp')
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index e5af792..eee2a6e 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -1635,17 +1635,29 @@ void tst_QScriptValue::instanceOf()
QCOMPARE(obj.instanceOf(otherEngine.globalObject().property("Object")), false);
}
+void tst_QScriptValue::isArray_data()
+{
+ newEngine();
+
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("array");
+
+ QTest::newRow("[]") << engine->evaluate("[]") << true;
+ QTest::newRow("{}") << engine->evaluate("{}") << false;
+ QTest::newRow("globalObject") << engine->globalObject() << false;
+ QTest::newRow("invalid") << QScriptValue() << false;
+ QTest::newRow("number") << QScriptValue(123) << false;
+ QTest::newRow("bool") << QScriptValue(false) << false;
+ QTest::newRow("null") << engine->nullValue() << false;
+ QTest::newRow("undefined") << engine->undefinedValue() << false;
+}
+
void tst_QScriptValue::isArray()
{
- QScriptEngine eng;
- QVERIFY(eng.evaluate("[]").isArray());
- QVERIFY(!eng.evaluate("{}").isArray());
- QVERIFY(!eng.globalObject().isArray());
- QVERIFY(!QScriptValue().isArray());
- QVERIFY(!QScriptValue(123).isArray());
- QVERIFY(!QScriptValue(false).isArray());
- QVERIFY(!eng.nullValue().isArray());
- QVERIFY(!eng.undefinedValue().isArray());
+ QFETCH(QScriptValue, value);
+ QFETCH(bool, array);
+
+ QCOMPARE(value.isArray(), array);
}
void tst_QScriptValue::isDate()