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.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index 44318b4..47ff9d7 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -1711,18 +1711,30 @@ void tst_QScriptValue::isError()
QVERIFY(!eng.evaluate("new Object()").isError());
}
+void tst_QScriptValue::isRegExp_data()
+{
+ newEngine();
+
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("regexp");
+
+ QTest::newRow("/foo/") << engine->evaluate("/foo/") << true;
+ QTest::newRow("[]") << engine->evaluate("[]") << false;
+ 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::isRegExp()
{
- QScriptEngine eng;
- QVERIFY(eng.evaluate("/foo/").isRegExp());
- QVERIFY(!eng.evaluate("[]").isRegExp());
- QVERIFY(!eng.evaluate("{}").isRegExp());
- QVERIFY(!eng.globalObject().isRegExp());
- QVERIFY(!QScriptValue().isRegExp());
- QVERIFY(!QScriptValue(123).isRegExp());
- QVERIFY(!QScriptValue(false).isRegExp());
- QVERIFY(!eng.nullValue().isRegExp());
- QVERIFY(!eng.undefinedValue().isRegExp());
+ QFETCH(QScriptValue, value);
+ QFETCH(bool, regexp);
+
+ QCOMPARE(value.isRegExp(), regexp);
}
static QScriptValue getter(QScriptContext *ctx, QScriptEngine *)