diff options
author | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2010-10-29 13:12:05 (GMT) |
---|---|---|
committer | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2010-11-01 07:58:35 (GMT) |
commit | 2b8c26f9f3fbba75463a818797b6d83cd409c74f (patch) | |
tree | 7401d7aff4e32cb0e0974d3297c5a35d34f5baff /tests/auto | |
parent | 21a4759ba82212097a0d76dcf341b5e8e497d057 (diff) | |
download | Qt-2b8c26f9f3fbba75463a818797b6d83cd409c74f.zip Qt-2b8c26f9f3fbba75463a818797b6d83cd409c74f.tar.gz Qt-2b8c26f9f3fbba75463a818797b6d83cd409c74f.tar.bz2 |
Refactor tst_QScriptValue::isError
The test should use _data function. It should be easier to maintain that
code.
Reviewed-by: Kent Hansen
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 37 | ||||
-rw-r--r-- | tests/auto/qscriptvalue/tst_qscriptvalue.h | 2 |
2 files changed, 31 insertions, 8 deletions
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 47ff9d7..0dd219b 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -1686,7 +1686,7 @@ void tst_QScriptValue::isDate() QCOMPARE(value.isDate(), date); } -void tst_QScriptValue::isError() +void tst_QScriptValue::isError_propertiesOfGlobalObject() { QStringList errors; errors << "Error" @@ -1702,13 +1702,34 @@ void tst_QScriptValue::isError() QVERIFY(ctor.isFunction()); QVERIFY(ctor.property("prototype").isError()); } - QVERIFY(!eng.globalObject().isError()); - QVERIFY(!QScriptValue().isError()); - QVERIFY(!QScriptValue(123).isError()); - QVERIFY(!QScriptValue(false).isError()); - QVERIFY(!eng.nullValue().isError()); - QVERIFY(!eng.undefinedValue().isError()); - QVERIFY(!eng.evaluate("new Object()").isError()); +} + +void tst_QScriptValue::isError_data() +{ + newEngine(); + + QTest::addColumn<QScriptValue>("value"); + QTest::addColumn<bool>("error"); + + QTest::newRow("syntax error") << engine->evaluate("%fsdg's") << 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; + QTest::newRow("newObject") << engine->newObject() << false; + QTest::newRow("new Object") << engine->evaluate("new Object()") << false; +} + +void tst_QScriptValue::isError() +{ + QFETCH(QScriptValue, value); + QFETCH(bool, error); + + QCOMPARE(value.isError(), error); } void tst_QScriptValue::isRegExp_data() diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.h b/tests/auto/qscriptvalue/tst_qscriptvalue.h index 300ce61..b6274f4 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.h +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.h @@ -99,6 +99,8 @@ private slots: void isArray(); void isDate(); void isDate_data(); + void isError_propertiesOfGlobalObject(); + void isError_data(); void isError(); void isRegExp_data(); void isRegExp(); |