[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 11:31:00 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 153fdf145c2519a658586b41dce2ac30eeb43ee1
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jul 27 22:16:09 2010 +0000
2010-07-27 Jedrzej Nowacki <jedrzej.nowacki at nokia.com>
Reviewed by Kenneth Rohde Christiansen.
Update the QScriptValue autotests suite.
QScriptValue generated files were updated, changes are:
- More tested values (for example QSE::newObject() and QSE::newArray())
- Tested values are recreated before each test and are not reused.
The change implies better code coverage and some expected result changes.
- A new test to check copy and assign functions.
- Tests are using standard QTestLib interface, without any custom macros.
[Qt] Improve test coverage for the QScriptValue
https://bugs.webkit.org/show_bug.cgi?id=42366
* tests/qscriptvalue/tst_qscriptvalue.cpp:
(tst_QScriptValue::tst_QScriptValue):
(tst_QScriptValue::~tst_QScriptValue):
(tst_QScriptValue::assignAndCopyConstruct_data):
(tst_QScriptValue::assignAndCopyConstruct):
* tests/qscriptvalue/tst_qscriptvalue.h:
* tests/qscriptvalue/tst_qscriptvalue_generated_comparison.cpp:
(tst_QScriptValue::equals_data):
(tst_QScriptValue::equals):
(tst_QScriptValue::strictlyEquals_data):
(tst_QScriptValue::strictlyEquals):
(tst_QScriptValue::instanceOf_data):
(tst_QScriptValue::instanceOf):
* tests/qscriptvalue/tst_qscriptvalue_generated_init.cpp:
(tst_QScriptValue::initScriptValues):
* tests/qscriptvalue/tst_qscriptvalue_generated_istype.cpp:
(tst_QScriptValue::isValid_data):
(tst_QScriptValue::isValid):
(tst_QScriptValue::isBool_data):
(tst_QScriptValue::isBool):
(tst_QScriptValue::isBoolean_data):
(tst_QScriptValue::isBoolean):
(tst_QScriptValue::isNumber_data):
(tst_QScriptValue::isNumber):
(tst_QScriptValue::isFunction_data):
(tst_QScriptValue::isFunction):
(tst_QScriptValue::isNull_data):
(tst_QScriptValue::isNull):
(tst_QScriptValue::isString_data):
(tst_QScriptValue::isString):
(tst_QScriptValue::isUndefined_data):
(tst_QScriptValue::isUndefined):
(tst_QScriptValue::isObject_data):
(tst_QScriptValue::isObject):
(tst_QScriptValue::isArray_data):
(tst_QScriptValue::isArray):
(tst_QScriptValue::isError_data):
(tst_QScriptValue::isError):
* tests/qscriptvalue/tst_qscriptvalue_generated_totype.cpp:
(tst_QScriptValue::toString_data):
(tst_QScriptValue::toString):
(tst_QScriptValue::toNumber_data):
(tst_QScriptValue::toNumber):
(tst_QScriptValue::toBool_data):
(tst_QScriptValue::toBool):
(tst_QScriptValue::toBoolean_data):
(tst_QScriptValue::toBoolean):
(tst_QScriptValue::toInteger_data):
(tst_QScriptValue::toInteger):
(tst_QScriptValue::toInt32_data):
(tst_QScriptValue::toInt32):
(tst_QScriptValue::toUInt32_data):
(tst_QScriptValue::toUInt32):
(tst_QScriptValue::toUInt16_data):
(tst_QScriptValue::toUInt16):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64165 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/qt/ChangeLog b/JavaScriptCore/qt/ChangeLog
index 5f71af5..e80493b 100644
--- a/JavaScriptCore/qt/ChangeLog
+++ b/JavaScriptCore/qt/ChangeLog
@@ -1,3 +1,75 @@
+2010-07-27 Jedrzej Nowacki <jedrzej.nowacki at nokia.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Update the QScriptValue autotests suite.
+
+ QScriptValue generated files were updated, changes are:
+ - More tested values (for example QSE::newObject() and QSE::newArray())
+ - Tested values are recreated before each test and are not reused.
+ The change implies better code coverage and some expected result changes.
+ - A new test to check copy and assign functions.
+ - Tests are using standard QTestLib interface, without any custom macros.
+
+ [Qt] Improve test coverage for the QScriptValue
+ https://bugs.webkit.org/show_bug.cgi?id=42366
+
+ * tests/qscriptvalue/tst_qscriptvalue.cpp:
+ (tst_QScriptValue::tst_QScriptValue):
+ (tst_QScriptValue::~tst_QScriptValue):
+ (tst_QScriptValue::assignAndCopyConstruct_data):
+ (tst_QScriptValue::assignAndCopyConstruct):
+ * tests/qscriptvalue/tst_qscriptvalue.h:
+ * tests/qscriptvalue/tst_qscriptvalue_generated_comparison.cpp:
+ (tst_QScriptValue::equals_data):
+ (tst_QScriptValue::equals):
+ (tst_QScriptValue::strictlyEquals_data):
+ (tst_QScriptValue::strictlyEquals):
+ (tst_QScriptValue::instanceOf_data):
+ (tst_QScriptValue::instanceOf):
+ * tests/qscriptvalue/tst_qscriptvalue_generated_init.cpp:
+ (tst_QScriptValue::initScriptValues):
+ * tests/qscriptvalue/tst_qscriptvalue_generated_istype.cpp:
+ (tst_QScriptValue::isValid_data):
+ (tst_QScriptValue::isValid):
+ (tst_QScriptValue::isBool_data):
+ (tst_QScriptValue::isBool):
+ (tst_QScriptValue::isBoolean_data):
+ (tst_QScriptValue::isBoolean):
+ (tst_QScriptValue::isNumber_data):
+ (tst_QScriptValue::isNumber):
+ (tst_QScriptValue::isFunction_data):
+ (tst_QScriptValue::isFunction):
+ (tst_QScriptValue::isNull_data):
+ (tst_QScriptValue::isNull):
+ (tst_QScriptValue::isString_data):
+ (tst_QScriptValue::isString):
+ (tst_QScriptValue::isUndefined_data):
+ (tst_QScriptValue::isUndefined):
+ (tst_QScriptValue::isObject_data):
+ (tst_QScriptValue::isObject):
+ (tst_QScriptValue::isArray_data):
+ (tst_QScriptValue::isArray):
+ (tst_QScriptValue::isError_data):
+ (tst_QScriptValue::isError):
+ * tests/qscriptvalue/tst_qscriptvalue_generated_totype.cpp:
+ (tst_QScriptValue::toString_data):
+ (tst_QScriptValue::toString):
+ (tst_QScriptValue::toNumber_data):
+ (tst_QScriptValue::toNumber):
+ (tst_QScriptValue::toBool_data):
+ (tst_QScriptValue::toBool):
+ (tst_QScriptValue::toBoolean_data):
+ (tst_QScriptValue::toBoolean):
+ (tst_QScriptValue::toInteger_data):
+ (tst_QScriptValue::toInteger):
+ (tst_QScriptValue::toInt32_data):
+ (tst_QScriptValue::toInt32):
+ (tst_QScriptValue::toUInt32_data):
+ (tst_QScriptValue::toUInt32):
+ (tst_QScriptValue::toUInt16_data):
+ (tst_QScriptValue::toUInt16):
+
2010-07-27 Caio Marcelo de Oliveira Filho <caio.oliveira at openbossa.org>
Reviewed by Kenneth Rohde Christiansen.
diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp
index a82347e..e04d3e9 100644
--- a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp
+++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp
@@ -21,40 +21,15 @@
#include <QtCore/qnumeric.h>
tst_QScriptValue::tst_QScriptValue()
- : engine(0)
+ : m_engine(0)
{
}
tst_QScriptValue::~tst_QScriptValue()
{
- delete engine;
+ delete m_engine;
}
-void tst_QScriptValue::dataHelper(InitDataFunction init, DefineDataFunction define)
-{
- QTest::addColumn<QString>("__expression__");
- (this->*init)();
- QHash<QString, QScriptValue>::const_iterator it;
- for (it = m_values.constBegin(); it != m_values.constEnd(); ++it) {
- m_currentExpression = it.key();
- (this->*define)(it.key().toLatin1());
- }
- m_currentExpression = QString();
-}
-
-QTestData& tst_QScriptValue::newRow(const char* tag)
-{
- return QTest::newRow(tag) << m_currentExpression;
-}
-
-void tst_QScriptValue::testHelper(TestFunction fun)
-{
- QFETCH(QString, __expression__);
- QScriptValue value = m_values.value(__expression__);
- (this->*fun)(__expression__.toLatin1(), value);
-}
-
-
void tst_QScriptValue::ctor()
{
QScriptEngine eng;
@@ -1285,4 +1260,37 @@ void tst_QScriptValue::globalObjectChanges()
QVERIFY(!object.property("foo", QScriptValue::ResolveLocal).isValid());
}
+void tst_QScriptValue::assignAndCopyConstruct_data()
+{
+ QTest::addColumn<QScriptValue>("value");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine;
+ // Copy & assign code is the same for all types, so it is enough to check only a few value.
+ for (unsigned i = 0; i < 10; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second;
+ }
+}
+
+void tst_QScriptValue::assignAndCopyConstruct()
+{
+ QFETCH(QScriptValue, value);
+ QScriptValue copy(value);
+ QEXPECT_FAIL("QScriptValue(QScriptValue::NullValue)", "FIXME: WebKit bug 43038", Abort);
+ QEXPECT_FAIL("QScriptValue(QScriptValue::UndefinedValue)", "FIXME: WebKit bug 43038", Abort);
+ QCOMPARE(copy.strictlyEquals(value), !value.isNumber() || !qIsNaN(value.toNumber()));
+ QCOMPARE(copy.engine(), value.engine());
+
+ QScriptValue assigned = copy;
+ QCOMPARE(assigned.strictlyEquals(value), !copy.isNumber() || !qIsNaN(copy.toNumber()));
+ QCOMPARE(assigned.engine(), assigned.engine());
+
+ QScriptValue other(!value.toBool());
+ assigned = other;
+ QVERIFY(!assigned.strictlyEquals(copy));
+ QVERIFY(assigned.strictlyEquals(other));
+ QCOMPARE(assigned.engine(), other.engine());
+}
+
QTEST_MAIN(tst_QScriptValue)
diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h
index 41b99cd..7b7d9bc 100644
--- a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h
+++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h
@@ -29,6 +29,8 @@
Q_DECLARE_METATYPE(QScriptValue*);
Q_DECLARE_METATYPE(QScriptValue);
+typedef QPair<QString, QScriptValue> QPairQStringAndQScriptValue;
+Q_DECLARE_METATYPE(QPairQStringAndQScriptValue);
class tst_QScriptValue : public QObject {
Q_OBJECT
@@ -61,14 +63,22 @@ private slots:
void propertyFlag_data();
void propertyFlag();
void globalObjectChanges();
+ void assignAndCopyConstruct_data();
+ void assignAndCopyConstruct();
// Generated test functions.
+ void isArray_data();
+ void isArray();
+
void isBool_data();
void isBool();
void isBoolean_data();
void isBoolean();
+ void isError_data();
+ void isError();
+
void isNumber_data();
void isNumber();
@@ -124,108 +134,10 @@ private slots:
void instanceOf();
private:
- typedef void (tst_QScriptValue::*InitDataFunction)();
- typedef void (tst_QScriptValue::*DefineDataFunction)(const char*);
- void dataHelper(InitDataFunction init, DefineDataFunction define);
- QTestData& newRow(const char* tag);
-
- typedef void (tst_QScriptValue::*TestFunction)(const char*, const QScriptValue&);
- void testHelper(TestFunction fun);
-
- // Generated functions
-
- void initScriptValues();
-
- void isBool_initData();
- void isBool_makeData(const char* expr);
- void isBool_test(const char* expr, const QScriptValue& value);
-
- void isBoolean_initData();
- void isBoolean_makeData(const char* expr);
- void isBoolean_test(const char* expr, const QScriptValue& value);
-
- void isNumber_initData();
- void isNumber_makeData(const char* expr);
- void isNumber_test(const char* expr, const QScriptValue&);
-
- void isFunction_initData();
- void isFunction_makeData(const char* expr);
- void isFunction_test(const char* expr, const QScriptValue& value);
-
- void isNull_initData();
- void isNull_makeData(const char* expr);
- void isNull_test(const char* expr, const QScriptValue& value);
-
- void isObject_initData();
- void isObject_makeData(const char* expr);
- void isObject_test(const char* expr, const QScriptValue& value);
-
- void isString_initData();
- void isString_makeData(const char* expr);
- void isString_test(const char* expr, const QScriptValue& value);
-
- void isUndefined_initData();
- void isUndefined_makeData(const char* expr);
- void isUndefined_test(const char* expr, const QScriptValue& value);
-
- void isValid_initData();
- void isValid_makeData(const char* expr);
- void isValid_test(const char* expr, const QScriptValue& value);
-
- void toString_initData();
- void toString_makeData(const char*);
- void toString_test(const char*, const QScriptValue&);
+ // Generated function
+ QPair<QString, QScriptValue> initScriptValues(uint idx);
- void toNumber_initData();
- void toNumber_makeData(const char*);
- void toNumber_test(const char*, const QScriptValue&);
-
- void toBool_initData();
- void toBool_makeData(const char*);
- void toBool_test(const char*, const QScriptValue&);
-
- void toBoolean_initData();
- void toBoolean_makeData(const char*);
- void toBoolean_test(const char*, const QScriptValue&);
-
- void toInteger_initData();
- void toInteger_makeData(const char*);
- void toInteger_test(const char*, const QScriptValue&);
-
- void toInt32_initData();
- void toInt32_makeData(const char*);
- void toInt32_test(const char*, const QScriptValue&);
-
- void toUInt32_initData();
- void toUInt32_makeData(const char*);
- void toUInt32_test(const char*, const QScriptValue&);
-
- void toUInt16_initData();
- void toUInt16_makeData(const char*);
- void toUInt16_test(const char*, const QScriptValue&);
-
- void equals_initData();
- void equals_makeData(const char*);
- void equals_test(const char*, const QScriptValue&);
-
- void strictlyEquals_initData();
- void strictlyEquals_makeData(const char*);
- void strictlyEquals_test(const char*, const QScriptValue&);
-
- void instanceOf_initData();
- void instanceOf_makeData(const char*);
- void instanceOf_test(const char*, const QScriptValue&);
-
-private:
- QScriptEngine* engine;
- QHash<QString, QScriptValue> m_values;
- QString m_currentExpression;
+ QScriptEngine* m_engine;
};
-#define DEFINE_TEST_FUNCTION(name) \
-void tst_QScriptValue::name##_data() { dataHelper(&tst_QScriptValue::name##_initData, &tst_QScriptValue::name##_makeData); } \
-void tst_QScriptValue::name() { testHelper(&tst_QScriptValue::name##_test); }
-
-
-
#endif // tst_qscriptvalue_h
diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_comparison.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_comparison.cpp
index 7586b15..3209530 100644
--- a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_comparison.cpp
+++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_comparison.cpp
@@ -23,14 +23,7 @@
#include "tst_qscriptvalue.h"
-void tst_QScriptValue::equals_initData()
-{
- QTest::addColumn<QScriptValue>("other");
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-static QString equals_array[] = {
+static const QString equals_array[] = {
"QScriptValue() <=> QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue) <=> QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::UndefinedValue) <=> QScriptValue(QScriptValue::NullValue)",
@@ -84,6 +77,7 @@ static QString equals_array[] = {
"QScriptValue(false) <=> engine->evaluate(\"0.0\")",
"QScriptValue(false) <=> engine->evaluate(\"''\")",
"QScriptValue(false) <=> engine->evaluate(\"'0'\")",
+ "QScriptValue(false) <=> engine->newArray()",
"QScriptValue(int(122)) <=> QScriptValue(int(122))",
"QScriptValue(int(122)) <=> QScriptValue(0, int(122))",
"QScriptValue(int(122)) <=> QScriptValue(engine, int(122))",
@@ -118,6 +112,7 @@ static QString equals_array[] = {
"QScriptValue(0) <=> engine->evaluate(\"0.0\")",
"QScriptValue(0) <=> engine->evaluate(\"''\")",
"QScriptValue(0) <=> engine->evaluate(\"'0'\")",
+ "QScriptValue(0) <=> engine->newArray()",
"QScriptValue(0.0) <=> QScriptValue(false)",
"QScriptValue(0.0) <=> QScriptValue(0)",
"QScriptValue(0.0) <=> QScriptValue(0.0)",
@@ -144,6 +139,7 @@ static QString equals_array[] = {
"QScriptValue(0.0) <=> engine->evaluate(\"0.0\")",
"QScriptValue(0.0) <=> engine->evaluate(\"''\")",
"QScriptValue(0.0) <=> engine->evaluate(\"'0'\")",
+ "QScriptValue(0.0) <=> engine->newArray()",
"QScriptValue(123.0) <=> QScriptValue(123.0)",
"QScriptValue(123.0) <=> QScriptValue(QString(\"123\"))",
"QScriptValue(123.0) <=> QScriptValue(0, 123.0)",
@@ -239,6 +235,7 @@ static QString equals_array[] = {
"QScriptValue(QString(\"\")) <=> engine->evaluate(\"0\")",
"QScriptValue(QString(\"\")) <=> engine->evaluate(\"0.0\")",
"QScriptValue(QString(\"\")) <=> engine->evaluate(\"''\")",
+ "QScriptValue(QString(\"\")) <=> engine->newArray()",
"QScriptValue(QString()) <=> QScriptValue(false)",
"QScriptValue(QString()) <=> QScriptValue(0)",
"QScriptValue(QString()) <=> QScriptValue(0.0)",
@@ -261,6 +258,7 @@ static QString equals_array[] = {
"QScriptValue(QString()) <=> engine->evaluate(\"0\")",
"QScriptValue(QString()) <=> engine->evaluate(\"0.0\")",
"QScriptValue(QString()) <=> engine->evaluate(\"''\")",
+ "QScriptValue(QString()) <=> engine->newArray()",
"QScriptValue(QString(\"0\")) <=> QScriptValue(false)",
"QScriptValue(QString(\"0\")) <=> QScriptValue(0)",
"QScriptValue(QString(\"0\")) <=> QScriptValue(0.0)",
@@ -339,6 +337,7 @@ static QString equals_array[] = {
"QScriptValue(0, false) <=> engine->evaluate(\"0.0\")",
"QScriptValue(0, false) <=> engine->evaluate(\"''\")",
"QScriptValue(0, false) <=> engine->evaluate(\"'0'\")",
+ "QScriptValue(0, false) <=> engine->newArray()",
"QScriptValue(0, int(122)) <=> QScriptValue(int(122))",
"QScriptValue(0, int(122)) <=> QScriptValue(0, int(122))",
"QScriptValue(0, int(122)) <=> QScriptValue(engine, int(122))",
@@ -373,6 +372,7 @@ static QString equals_array[] = {
"QScriptValue(0, 0) <=> engine->evaluate(\"0.0\")",
"QScriptValue(0, 0) <=> engine->evaluate(\"''\")",
"QScriptValue(0, 0) <=> engine->evaluate(\"'0'\")",
+ "QScriptValue(0, 0) <=> engine->newArray()",
"QScriptValue(0, 0.0) <=> QScriptValue(false)",
"QScriptValue(0, 0.0) <=> QScriptValue(0)",
"QScriptValue(0, 0.0) <=> QScriptValue(0.0)",
@@ -399,6 +399,7 @@ static QString equals_array[] = {
"QScriptValue(0, 0.0) <=> engine->evaluate(\"0.0\")",
"QScriptValue(0, 0.0) <=> engine->evaluate(\"''\")",
"QScriptValue(0, 0.0) <=> engine->evaluate(\"'0'\")",
+ "QScriptValue(0, 0.0) <=> engine->newArray()",
"QScriptValue(0, 123.0) <=> QScriptValue(123.0)",
"QScriptValue(0, 123.0) <=> QScriptValue(QString(\"123\"))",
"QScriptValue(0, 123.0) <=> QScriptValue(0, 123.0)",
@@ -494,6 +495,7 @@ static QString equals_array[] = {
"QScriptValue(0, QString(\"\")) <=> engine->evaluate(\"0\")",
"QScriptValue(0, QString(\"\")) <=> engine->evaluate(\"0.0\")",
"QScriptValue(0, QString(\"\")) <=> engine->evaluate(\"''\")",
+ "QScriptValue(0, QString(\"\")) <=> engine->newArray()",
"QScriptValue(0, QString()) <=> QScriptValue(false)",
"QScriptValue(0, QString()) <=> QScriptValue(0)",
"QScriptValue(0, QString()) <=> QScriptValue(0.0)",
@@ -516,6 +518,7 @@ static QString equals_array[] = {
"QScriptValue(0, QString()) <=> engine->evaluate(\"0\")",
"QScriptValue(0, QString()) <=> engine->evaluate(\"0.0\")",
"QScriptValue(0, QString()) <=> engine->evaluate(\"''\")",
+ "QScriptValue(0, QString()) <=> engine->newArray()",
"QScriptValue(0, QString(\"0\")) <=> QScriptValue(false)",
"QScriptValue(0, QString(\"0\")) <=> QScriptValue(0)",
"QScriptValue(0, QString(\"0\")) <=> QScriptValue(0.0)",
@@ -593,6 +596,7 @@ static QString equals_array[] = {
"QScriptValue(engine, false) <=> engine->evaluate(\"0.0\")",
"QScriptValue(engine, false) <=> engine->evaluate(\"''\")",
"QScriptValue(engine, false) <=> engine->evaluate(\"'0'\")",
+ "QScriptValue(engine, false) <=> engine->newArray()",
"QScriptValue(engine, int(122)) <=> QScriptValue(int(122))",
"QScriptValue(engine, int(122)) <=> QScriptValue(0, int(122))",
"QScriptValue(engine, int(122)) <=> QScriptValue(engine, int(122))",
@@ -627,6 +631,7 @@ static QString equals_array[] = {
"QScriptValue(engine, 0) <=> engine->evaluate(\"0.0\")",
"QScriptValue(engine, 0) <=> engine->evaluate(\"''\")",
"QScriptValue(engine, 0) <=> engine->evaluate(\"'0'\")",
+ "QScriptValue(engine, 0) <=> engine->newArray()",
"QScriptValue(engine, 0.0) <=> QScriptValue(false)",
"QScriptValue(engine, 0.0) <=> QScriptValue(0)",
"QScriptValue(engine, 0.0) <=> QScriptValue(0.0)",
@@ -653,6 +658,7 @@ static QString equals_array[] = {
"QScriptValue(engine, 0.0) <=> engine->evaluate(\"0.0\")",
"QScriptValue(engine, 0.0) <=> engine->evaluate(\"''\")",
"QScriptValue(engine, 0.0) <=> engine->evaluate(\"'0'\")",
+ "QScriptValue(engine, 0.0) <=> engine->newArray()",
"QScriptValue(engine, 123.0) <=> QScriptValue(123.0)",
"QScriptValue(engine, 123.0) <=> QScriptValue(QString(\"123\"))",
"QScriptValue(engine, 123.0) <=> QScriptValue(0, 123.0)",
@@ -748,6 +754,7 @@ static QString equals_array[] = {
"QScriptValue(engine, QString(\"\")) <=> engine->evaluate(\"0\")",
"QScriptValue(engine, QString(\"\")) <=> engine->evaluate(\"0.0\")",
"QScriptValue(engine, QString(\"\")) <=> engine->evaluate(\"''\")",
+ "QScriptValue(engine, QString(\"\")) <=> engine->newArray()",
"QScriptValue(engine, QString()) <=> QScriptValue(false)",
"QScriptValue(engine, QString()) <=> QScriptValue(0)",
"QScriptValue(engine, QString()) <=> QScriptValue(0.0)",
@@ -770,6 +777,7 @@ static QString equals_array[] = {
"QScriptValue(engine, QString()) <=> engine->evaluate(\"0\")",
"QScriptValue(engine, QString()) <=> engine->evaluate(\"0.0\")",
"QScriptValue(engine, QString()) <=> engine->evaluate(\"''\")",
+ "QScriptValue(engine, QString()) <=> engine->newArray()",
"QScriptValue(engine, QString(\"0\")) <=> QScriptValue(false)",
"QScriptValue(engine, QString(\"0\")) <=> QScriptValue(0)",
"QScriptValue(engine, QString(\"0\")) <=> QScriptValue(0.0)",
@@ -810,7 +818,6 @@ static QString equals_array[] = {
"engine->evaluate(\"[]\") <=> QScriptValue(engine, 0.0)",
"engine->evaluate(\"[]\") <=> QScriptValue(engine, QString(\"\"))",
"engine->evaluate(\"[]\") <=> QScriptValue(engine, QString())",
- "engine->evaluate(\"[]\") <=> engine->evaluate(\"[]\")",
"engine->evaluate(\"[]\") <=> engine->evaluate(\"false\")",
"engine->evaluate(\"[]\") <=> engine->evaluate(\"0\")",
"engine->evaluate(\"[]\") <=> engine->evaluate(\"0.0\")",
@@ -854,11 +861,6 @@ static QString equals_array[] = {
"engine->evaluate(\"Array\") <=> engine->evaluate(\"Array\")",
"engine->evaluate(\"Number\") <=> engine->evaluate(\"Number\")",
"engine->evaluate(\"Function\") <=> engine->evaluate(\"Function\")",
- "engine->evaluate(\"(function() { return 1; })\") <=> engine->evaluate(\"(function() { return 1; })\")",
- "engine->evaluate(\"(function() { return 'ciao'; })\") <=> engine->evaluate(\"(function() { return 'ciao'; })\")",
- "engine->evaluate(\"(function() { throw new Error('foo' })\") <=> engine->evaluate(\"(function() { throw new Error('foo' })\")",
- "engine->evaluate(\"/foo/\") <=> engine->evaluate(\"/foo/\")",
- "engine->evaluate(\"new Object()\") <=> engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\") <=> QScriptValue(false)",
"engine->evaluate(\"new Array()\") <=> QScriptValue(0)",
"engine->evaluate(\"new Array()\") <=> QScriptValue(0.0)",
@@ -874,17 +876,11 @@ static QString equals_array[] = {
"engine->evaluate(\"new Array()\") <=> QScriptValue(engine, 0.0)",
"engine->evaluate(\"new Array()\") <=> QScriptValue(engine, QString(\"\"))",
"engine->evaluate(\"new Array()\") <=> QScriptValue(engine, QString())",
- "engine->evaluate(\"new Array()\") <=> engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Array()\") <=> engine->evaluate(\"false\")",
"engine->evaluate(\"new Array()\") <=> engine->evaluate(\"0\")",
"engine->evaluate(\"new Array()\") <=> engine->evaluate(\"0.0\")",
"engine->evaluate(\"new Array()\") <=> engine->evaluate(\"''\")",
- "engine->evaluate(\"new Error()\") <=> engine->evaluate(\"new Error()\")",
- "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\") <=> engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
- "engine->evaluate(\"Undefined\") <=> engine->evaluate(\"Undefined\")",
- "engine->evaluate(\"Null\") <=> engine->evaluate(\"Null\")",
- "engine->evaluate(\"True\") <=> engine->evaluate(\"True\")",
- "engine->evaluate(\"False\") <=> engine->evaluate(\"False\")",
+ "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\") <=> engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"undefined\") <=> QScriptValue(QScriptValue::UndefinedValue)",
"engine->evaluate(\"undefined\") <=> QScriptValue(QScriptValue::NullValue)",
"engine->evaluate(\"undefined\") <=> QScriptValue(0, QScriptValue::UndefinedValue)",
@@ -937,6 +933,7 @@ static QString equals_array[] = {
"engine->evaluate(\"false\") <=> engine->evaluate(\"0.0\")",
"engine->evaluate(\"false\") <=> engine->evaluate(\"''\")",
"engine->evaluate(\"false\") <=> engine->evaluate(\"'0'\")",
+ "engine->evaluate(\"false\") <=> engine->newArray()",
"engine->evaluate(\"122\") <=> QScriptValue(int(122))",
"engine->evaluate(\"122\") <=> QScriptValue(0, int(122))",
"engine->evaluate(\"122\") <=> QScriptValue(engine, int(122))",
@@ -971,6 +968,7 @@ static QString equals_array[] = {
"engine->evaluate(\"0\") <=> engine->evaluate(\"0.0\")",
"engine->evaluate(\"0\") <=> engine->evaluate(\"''\")",
"engine->evaluate(\"0\") <=> engine->evaluate(\"'0'\")",
+ "engine->evaluate(\"0\") <=> engine->newArray()",
"engine->evaluate(\"0.0\") <=> QScriptValue(false)",
"engine->evaluate(\"0.0\") <=> QScriptValue(0)",
"engine->evaluate(\"0.0\") <=> QScriptValue(0.0)",
@@ -997,6 +995,7 @@ static QString equals_array[] = {
"engine->evaluate(\"0.0\") <=> engine->evaluate(\"0.0\")",
"engine->evaluate(\"0.0\") <=> engine->evaluate(\"''\")",
"engine->evaluate(\"0.0\") <=> engine->evaluate(\"'0'\")",
+ "engine->evaluate(\"0.0\") <=> engine->newArray()",
"engine->evaluate(\"123.0\") <=> QScriptValue(123.0)",
"engine->evaluate(\"123.0\") <=> QScriptValue(QString(\"123\"))",
"engine->evaluate(\"123.0\") <=> QScriptValue(0, 123.0)",
@@ -1068,6 +1067,7 @@ static QString equals_array[] = {
"engine->evaluate(\"''\") <=> engine->evaluate(\"0\")",
"engine->evaluate(\"''\") <=> engine->evaluate(\"0.0\")",
"engine->evaluate(\"''\") <=> engine->evaluate(\"''\")",
+ "engine->evaluate(\"''\") <=> engine->newArray()",
"engine->evaluate(\"'0'\") <=> QScriptValue(false)",
"engine->evaluate(\"'0'\") <=> QScriptValue(0)",
"engine->evaluate(\"'0'\") <=> QScriptValue(0.0)",
@@ -1115,41 +1115,73 @@ static QString equals_array[] = {
"engine->undefinedValue() <=> engine->evaluate(\"undefined\")",
"engine->undefinedValue() <=> engine->evaluate(\"null\")",
"engine->undefinedValue() <=> engine->nullValue()",
- "engine->undefinedValue() <=> engine->undefinedValue()"};
+ "engine->undefinedValue() <=> engine->undefinedValue()",
+ "engine->newArray() <=> QScriptValue(false)",
+ "engine->newArray() <=> QScriptValue(0)",
+ "engine->newArray() <=> QScriptValue(0.0)",
+ "engine->newArray() <=> QScriptValue(QString(\"\"))",
+ "engine->newArray() <=> QScriptValue(QString())",
+ "engine->newArray() <=> QScriptValue(0, false)",
+ "engine->newArray() <=> QScriptValue(0, 0)",
+ "engine->newArray() <=> QScriptValue(0, 0.0)",
+ "engine->newArray() <=> QScriptValue(0, QString(\"\"))",
+ "engine->newArray() <=> QScriptValue(0, QString())",
+ "engine->newArray() <=> QScriptValue(engine, false)",
+ "engine->newArray() <=> QScriptValue(engine, 0)",
+ "engine->newArray() <=> QScriptValue(engine, 0.0)",
+ "engine->newArray() <=> QScriptValue(engine, QString(\"\"))",
+ "engine->newArray() <=> QScriptValue(engine, QString())",
+ "engine->newArray() <=> engine->evaluate(\"false\")",
+ "engine->newArray() <=> engine->evaluate(\"0\")",
+ "engine->newArray() <=> engine->evaluate(\"0.0\")",
+ "engine->newArray() <=> engine->evaluate(\"''\")"};
-void tst_QScriptValue::equals_makeData(const char *expr)
+void tst_QScriptValue::equals_data()
{
- static QSet<QString> equals;
- if (equals.isEmpty()) {
- equals.reserve(1085);
- for (unsigned i = 0; i < 1085; ++i)
- equals.insert(equals_array[i]);
- }
- QHash<QString, QScriptValue>::const_iterator it;
- for (it = m_values.constBegin(); it != m_values.constEnd(); ++it) {
- QString tag = QString::fromLatin1("%20 <=> %21").arg(expr).arg(it.key());
- newRow(tag.toLatin1()) << it.value() << equals.contains(tag);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<QScriptValue>("other");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QSet<QString> equals;
+ equals.reserve(1111);
+ for (unsigned i = 0; i < 1111; ++i)
+ equals.insert(equals_array[i]);
+ for (unsigned i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> value1 = initScriptValues(i);
+ for (unsigned j = 0; j < 135; ++j) {
+ QPair<QString, QScriptValue> value2 = initScriptValues(j);
+ QString tag = QString::fromLatin1("%20 <=> %21").arg(value1.first, value2.first);
+ QTest::newRow(tag.toAscii().constData()) << value1.second << value2.second << equals.contains(tag); }
}
}
-void tst_QScriptValue::equals_test(const char *, const QScriptValue& value)
+void tst_QScriptValue::equals()
{
+ QFETCH(QScriptValue, value);
QFETCH(QScriptValue, other);
QFETCH(bool, expected);
+ QEXPECT_FAIL("QScriptValue(qInf()) <=> QScriptValue(\"-Infinity\")", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(qInf()) <=> QScriptValue(0, \"-Infinity\")", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(-qInf()) <=> QScriptValue(\"-Infinity\")", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(-qInf()) <=> QScriptValue(0, \"-Infinity\")", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(\"-Infinity\") <=> QScriptValue(qInf())", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(\"-Infinity\") <=> QScriptValue(-qInf())", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(\"-Infinity\") <=> QScriptValue(0, qInf())", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(\"-Infinity\") <=> QScriptValue(0, -qInf())", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, qInf()) <=> QScriptValue(\"-Infinity\")", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, qInf()) <=> QScriptValue(0, \"-Infinity\")", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, -qInf()) <=> QScriptValue(\"-Infinity\")", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, -qInf()) <=> QScriptValue(0, \"-Infinity\")", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, \"-Infinity\") <=> QScriptValue(qInf())", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, \"-Infinity\") <=> QScriptValue(-qInf())", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, \"-Infinity\") <=> QScriptValue(0, qInf())", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, \"-Infinity\") <=> QScriptValue(0, -qInf())", "FIXME: WebKit bug 43038", Continue);
QCOMPARE(value.equals(other), expected);
}
-DEFINE_TEST_FUNCTION(equals)
-
-
-void tst_QScriptValue::strictlyEquals_initData()
-{
- QTest::addColumn<QScriptValue>("other");
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-static QString strictlyEquals_array[] = {
+static const QString strictlyEquals_array[] = {
"QScriptValue() <=> QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue) <=> QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::UndefinedValue) <=> QScriptValue(0, QScriptValue::UndefinedValue)",
@@ -1515,7 +1547,6 @@ static QString strictlyEquals_array[] = {
"QScriptValue(engine, QString(\"123\")) <=> QScriptValue(engine, QString(\"123\"))",
"QScriptValue(engine, QString(\"123\")) <=> engine->evaluate(\"'123'\")",
"QScriptValue(engine, QString(\"1.23\")) <=> QScriptValue(engine, QString(\"1.23\"))",
- "engine->evaluate(\"[]\") <=> engine->evaluate(\"[]\")",
"engine->evaluate(\"{}\") <=> QScriptValue(QScriptValue::UndefinedValue)",
"engine->evaluate(\"{}\") <=> QScriptValue(0, QScriptValue::UndefinedValue)",
"engine->evaluate(\"{}\") <=> QScriptValue(engine, QScriptValue::UndefinedValue)",
@@ -1531,18 +1562,7 @@ static QString strictlyEquals_array[] = {
"engine->evaluate(\"Array\") <=> engine->evaluate(\"Array\")",
"engine->evaluate(\"Number\") <=> engine->evaluate(\"Number\")",
"engine->evaluate(\"Function\") <=> engine->evaluate(\"Function\")",
- "engine->evaluate(\"(function() { return 1; })\") <=> engine->evaluate(\"(function() { return 1; })\")",
- "engine->evaluate(\"(function() { return 'ciao'; })\") <=> engine->evaluate(\"(function() { return 'ciao'; })\")",
- "engine->evaluate(\"(function() { throw new Error('foo' })\") <=> engine->evaluate(\"(function() { throw new Error('foo' })\")",
- "engine->evaluate(\"/foo/\") <=> engine->evaluate(\"/foo/\")",
- "engine->evaluate(\"new Object()\") <=> engine->evaluate(\"new Object()\")",
- "engine->evaluate(\"new Array()\") <=> engine->evaluate(\"new Array()\")",
- "engine->evaluate(\"new Error()\") <=> engine->evaluate(\"new Error()\")",
- "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\") <=> engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
- "engine->evaluate(\"Undefined\") <=> engine->evaluate(\"Undefined\")",
- "engine->evaluate(\"Null\") <=> engine->evaluate(\"Null\")",
- "engine->evaluate(\"True\") <=> engine->evaluate(\"True\")",
- "engine->evaluate(\"False\") <=> engine->evaluate(\"False\")",
+ "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\") <=> engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"undefined\") <=> QScriptValue(QScriptValue::UndefinedValue)",
"engine->evaluate(\"undefined\") <=> QScriptValue(0, QScriptValue::UndefinedValue)",
"engine->evaluate(\"undefined\") <=> QScriptValue(engine, QScriptValue::UndefinedValue)",
@@ -1654,39 +1674,66 @@ static QString strictlyEquals_array[] = {
"engine->undefinedValue() <=> engine->evaluate(\"undefined\")",
"engine->undefinedValue() <=> engine->undefinedValue()"};
-void tst_QScriptValue::strictlyEquals_makeData(const char* expr)
+void tst_QScriptValue::strictlyEquals_data()
{
- static QSet<QString> equals;
- if (equals.isEmpty()) {
- equals.reserve(503);
- for (unsigned i = 0; i < 503; ++i)
- equals.insert(strictlyEquals_array[i]);
- }
- QHash<QString, QScriptValue>::const_iterator it;
- for (it = m_values.constBegin(); it != m_values.constEnd(); ++it) {
- QString tag = QString::fromLatin1("%20 <=> %21").arg(expr).arg(it.key());
- newRow(tag.toLatin1()) << it.value() << equals.contains(tag);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<QScriptValue>("other");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QSet<QString> equals;
+ equals.reserve(491);
+ for (unsigned i = 0; i < 491; ++i)
+ equals.insert(strictlyEquals_array[i]);
+ for (unsigned i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> value1 = initScriptValues(i);
+ for (unsigned j = 0; j < 135; ++j) {
+ QPair<QString, QScriptValue> value2 = initScriptValues(j);
+ QString tag = QString::fromLatin1("%20 <=> %21").arg(value1.first, value2.first);
+ QTest::newRow(tag.toAscii().constData()) << value1.second << value2.second << equals.contains(tag); }
}
}
-void tst_QScriptValue::strictlyEquals_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::strictlyEquals()
{
+ QFETCH(QScriptValue, value);
QFETCH(QScriptValue, other);
QFETCH(bool, expected);
+ QEXPECT_FAIL("QScriptValue(QScriptValue::UndefinedValue) <=> QScriptValue(QScriptValue::UndefinedValue)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(QScriptValue::UndefinedValue) <=> QScriptValue(0, QScriptValue::UndefinedValue)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(QScriptValue::UndefinedValue) <=> QScriptValue(engine, QScriptValue::UndefinedValue)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(QScriptValue::UndefinedValue) <=> engine->evaluate(\"{}\")", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(QScriptValue::UndefinedValue) <=> engine->evaluate(\"undefined\")", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(QScriptValue::UndefinedValue) <=> engine->undefinedValue()", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(QScriptValue::NullValue) <=> QScriptValue(QScriptValue::NullValue)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(QScriptValue::NullValue) <=> QScriptValue(0, QScriptValue::NullValue)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(QScriptValue::NullValue) <=> QScriptValue(engine, QScriptValue::NullValue)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(QScriptValue::NullValue) <=> engine->evaluate(\"null\")", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(QScriptValue::NullValue) <=> engine->nullValue()", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(true) <=> QScriptValue(true)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(true) <=> QScriptValue(0, true)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(false) <=> QScriptValue(false)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(false) <=> QScriptValue(0, false)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, QScriptValue::UndefinedValue) <=> QScriptValue(QScriptValue::UndefinedValue)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, QScriptValue::UndefinedValue) <=> QScriptValue(0, QScriptValue::UndefinedValue)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, QScriptValue::UndefinedValue) <=> QScriptValue(engine, QScriptValue::UndefinedValue)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, QScriptValue::UndefinedValue) <=> engine->evaluate(\"{}\")", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, QScriptValue::UndefinedValue) <=> engine->evaluate(\"undefined\")", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, QScriptValue::UndefinedValue) <=> engine->undefinedValue()", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, QScriptValue::NullValue) <=> QScriptValue(QScriptValue::NullValue)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, QScriptValue::NullValue) <=> QScriptValue(0, QScriptValue::NullValue)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, QScriptValue::NullValue) <=> QScriptValue(engine, QScriptValue::NullValue)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, QScriptValue::NullValue) <=> engine->evaluate(\"null\")", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, QScriptValue::NullValue) <=> engine->nullValue()", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, true) <=> QScriptValue(true)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, true) <=> QScriptValue(0, true)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, false) <=> QScriptValue(false)", "FIXME: WebKit bug 43038", Continue);
+ QEXPECT_FAIL("QScriptValue(0, false) <=> QScriptValue(0, false)", "FIXME: WebKit bug 43038", Continue);
QCOMPARE(value.strictlyEquals(other), expected);
}
-DEFINE_TEST_FUNCTION(strictlyEquals)
-
-
-void tst_QScriptValue::instanceOf_initData()
-{
- QTest::addColumn<QScriptValue>("other");
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-static QString instanceOf_array[] = {
+static const QString instanceOf_array[] = {
"engine->evaluate(\"[]\") <=> engine->evaluate(\"Object\")",
"engine->evaluate(\"[]\") <=> engine->evaluate(\"Array\")",
"engine->evaluate(\"Date.prototype\") <=> engine->evaluate(\"Object\")",
@@ -1705,38 +1752,48 @@ static QString instanceOf_array[] = {
"engine->evaluate(\"(function() { return 1; })\") <=> engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 'ciao'; })\") <=> engine->evaluate(\"Object\")",
"engine->evaluate(\"(function() { return 'ciao'; })\") <=> engine->evaluate(\"Function\")",
- "engine->evaluate(\"(function() { throw new Error('foo' })\") <=> engine->evaluate(\"Object\")",
+ "engine->evaluate(\"(function() { throw new Error('foo'); })\") <=> engine->evaluate(\"Object\")",
+ "engine->evaluate(\"(function() { throw new Error('foo'); })\") <=> engine->evaluate(\"Function\")",
"engine->evaluate(\"/foo/\") <=> engine->evaluate(\"Object\")",
"engine->evaluate(\"new Object()\") <=> engine->evaluate(\"Object\")",
"engine->evaluate(\"new Array()\") <=> engine->evaluate(\"Object\")",
"engine->evaluate(\"new Array()\") <=> engine->evaluate(\"Array\")",
"engine->evaluate(\"new Error()\") <=> engine->evaluate(\"Object\")",
- "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\") <=> engine->evaluate(\"Object\")",
"engine->evaluate(\"Undefined\") <=> engine->evaluate(\"Object\")",
"engine->evaluate(\"Null\") <=> engine->evaluate(\"Object\")",
"engine->evaluate(\"True\") <=> engine->evaluate(\"Object\")",
- "engine->evaluate(\"False\") <=> engine->evaluate(\"Object\")"};
+ "engine->evaluate(\"False\") <=> engine->evaluate(\"Object\")",
+ "engine->newObject() <=> engine->evaluate(\"Object\")",
+ "engine->newArray() <=> engine->evaluate(\"Object\")",
+ "engine->newArray() <=> engine->evaluate(\"Array\")",
+ "engine->newArray(10) <=> engine->evaluate(\"Object\")",
+ "engine->newArray(10) <=> engine->evaluate(\"Array\")"};
-void tst_QScriptValue::instanceOf_makeData(const char *expr)
+void tst_QScriptValue::instanceOf_data()
{
- static QSet<QString> equals;
- if (equals.isEmpty()) {
- equals.reserve(29);
- for (unsigned i = 0; i < 29; ++i)
- equals.insert(instanceOf_array[i]);
- }
- QHash<QString, QScriptValue>::const_iterator it;
- for (it = m_values.constBegin(); it != m_values.constEnd(); ++it) {
- QString tag = QString::fromLatin1("%20 <=> %21").arg(expr).arg(it.key());
- newRow(tag.toLatin1()) << it.value() << equals.contains(tag);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<QScriptValue>("other");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QSet<QString> equals;
+ equals.reserve(34);
+ for (unsigned i = 0; i < 34; ++i)
+ equals.insert(instanceOf_array[i]);
+ for (unsigned i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> value1 = initScriptValues(i);
+ for (unsigned j = 0; j < 135; ++j) {
+ QPair<QString, QScriptValue> value2 = initScriptValues(j);
+ QString tag = QString::fromLatin1("%20 <=> %21").arg(value1.first, value2.first);
+ QTest::newRow(tag.toAscii().constData()) << value1.second << value2.second << equals.contains(tag); }
}
}
-void tst_QScriptValue::instanceOf_test(const char *, const QScriptValue& value)
+void tst_QScriptValue::instanceOf()
{
+ QFETCH(QScriptValue, value);
QFETCH(QScriptValue, other);
QFETCH(bool, expected);
QCOMPARE(value.instanceOf(other), expected);
}
-
-DEFINE_TEST_FUNCTION(instanceOf)
diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_init.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_init.cpp
index b68aaf2..4c97dd4 100644
--- a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_init.cpp
+++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_init.cpp
@@ -24,142 +24,146 @@
#include "tst_qscriptvalue.h"
-void tst_QScriptValue::initScriptValues()
+QPair<QString, QScriptValue> tst_QScriptValue::initScriptValues(uint idx)
{
- m_values.clear();
- if (engine)
- delete engine;
- engine = new QScriptEngine;
- DEFINE_TEST_VALUE(QScriptValue());
- DEFINE_TEST_VALUE(QScriptValue(QScriptValue::UndefinedValue));
- DEFINE_TEST_VALUE(QScriptValue(QScriptValue::NullValue));
- DEFINE_TEST_VALUE(QScriptValue(true));
- DEFINE_TEST_VALUE(QScriptValue(false));
- DEFINE_TEST_VALUE(QScriptValue(int(122)));
- DEFINE_TEST_VALUE(QScriptValue(uint(124)));
- DEFINE_TEST_VALUE(QScriptValue(0));
- DEFINE_TEST_VALUE(QScriptValue(0.0));
- DEFINE_TEST_VALUE(QScriptValue(123.0));
- DEFINE_TEST_VALUE(QScriptValue(6.37e-8));
- DEFINE_TEST_VALUE(QScriptValue(-6.37e-8));
- DEFINE_TEST_VALUE(QScriptValue(0x43211234));
- DEFINE_TEST_VALUE(QScriptValue(0x10000));
- DEFINE_TEST_VALUE(QScriptValue(0x10001));
- DEFINE_TEST_VALUE(QScriptValue(qSNaN()));
- DEFINE_TEST_VALUE(QScriptValue(qQNaN()));
- DEFINE_TEST_VALUE(QScriptValue(qInf()));
- DEFINE_TEST_VALUE(QScriptValue(-qInf()));
- DEFINE_TEST_VALUE(QScriptValue("NaN"));
- DEFINE_TEST_VALUE(QScriptValue("Infinity"));
- DEFINE_TEST_VALUE(QScriptValue("-Infinity"));
- DEFINE_TEST_VALUE(QScriptValue("ciao"));
- DEFINE_TEST_VALUE(QScriptValue(QString::fromLatin1("ciao")));
- DEFINE_TEST_VALUE(QScriptValue(QString("")));
- DEFINE_TEST_VALUE(QScriptValue(QString()));
- DEFINE_TEST_VALUE(QScriptValue(QString("0")));
- DEFINE_TEST_VALUE(QScriptValue(QString("123")));
- DEFINE_TEST_VALUE(QScriptValue(QString("12.4")));
- DEFINE_TEST_VALUE(QScriptValue(0, QScriptValue::UndefinedValue));
- DEFINE_TEST_VALUE(QScriptValue(0, QScriptValue::NullValue));
- DEFINE_TEST_VALUE(QScriptValue(0, true));
- DEFINE_TEST_VALUE(QScriptValue(0, false));
- DEFINE_TEST_VALUE(QScriptValue(0, int(122)));
- DEFINE_TEST_VALUE(QScriptValue(0, uint(124)));
- DEFINE_TEST_VALUE(QScriptValue(0, 0));
- DEFINE_TEST_VALUE(QScriptValue(0, 0.0));
- DEFINE_TEST_VALUE(QScriptValue(0, 123.0));
- DEFINE_TEST_VALUE(QScriptValue(0, 6.37e-8));
- DEFINE_TEST_VALUE(QScriptValue(0, -6.37e-8));
- DEFINE_TEST_VALUE(QScriptValue(0, 0x43211234));
- DEFINE_TEST_VALUE(QScriptValue(0, 0x10000));
- DEFINE_TEST_VALUE(QScriptValue(0, 0x10001));
- DEFINE_TEST_VALUE(QScriptValue(0, qSNaN()));
- DEFINE_TEST_VALUE(QScriptValue(0, qQNaN()));
- DEFINE_TEST_VALUE(QScriptValue(0, qInf()));
- DEFINE_TEST_VALUE(QScriptValue(0, -qInf()));
- DEFINE_TEST_VALUE(QScriptValue(0, "NaN"));
- DEFINE_TEST_VALUE(QScriptValue(0, "Infinity"));
- DEFINE_TEST_VALUE(QScriptValue(0, "-Infinity"));
- DEFINE_TEST_VALUE(QScriptValue(0, "ciao"));
- DEFINE_TEST_VALUE(QScriptValue(0, QString::fromLatin1("ciao")));
- DEFINE_TEST_VALUE(QScriptValue(0, QString("")));
- DEFINE_TEST_VALUE(QScriptValue(0, QString()));
- DEFINE_TEST_VALUE(QScriptValue(0, QString("0")));
- DEFINE_TEST_VALUE(QScriptValue(0, QString("123")));
- DEFINE_TEST_VALUE(QScriptValue(0, QString("12.3")));
- DEFINE_TEST_VALUE(QScriptValue(engine, QScriptValue::UndefinedValue));
- DEFINE_TEST_VALUE(QScriptValue(engine, QScriptValue::NullValue));
- DEFINE_TEST_VALUE(QScriptValue(engine, true));
- DEFINE_TEST_VALUE(QScriptValue(engine, false));
- DEFINE_TEST_VALUE(QScriptValue(engine, int(122)));
- DEFINE_TEST_VALUE(QScriptValue(engine, uint(124)));
- DEFINE_TEST_VALUE(QScriptValue(engine, 0));
- DEFINE_TEST_VALUE(QScriptValue(engine, 0.0));
- DEFINE_TEST_VALUE(QScriptValue(engine, 123.0));
- DEFINE_TEST_VALUE(QScriptValue(engine, 6.37e-8));
- DEFINE_TEST_VALUE(QScriptValue(engine, -6.37e-8));
- DEFINE_TEST_VALUE(QScriptValue(engine, 0x43211234));
- DEFINE_TEST_VALUE(QScriptValue(engine, 0x10000));
- DEFINE_TEST_VALUE(QScriptValue(engine, 0x10001));
- DEFINE_TEST_VALUE(QScriptValue(engine, qSNaN()));
- DEFINE_TEST_VALUE(QScriptValue(engine, qQNaN()));
- DEFINE_TEST_VALUE(QScriptValue(engine, qInf()));
- DEFINE_TEST_VALUE(QScriptValue(engine, -qInf()));
- DEFINE_TEST_VALUE(QScriptValue(engine, "NaN"));
- DEFINE_TEST_VALUE(QScriptValue(engine, "Infinity"));
- DEFINE_TEST_VALUE(QScriptValue(engine, "-Infinity"));
- DEFINE_TEST_VALUE(QScriptValue(engine, "ciao"));
- DEFINE_TEST_VALUE(QScriptValue(engine, QString::fromLatin1("ciao")));
- DEFINE_TEST_VALUE(QScriptValue(engine, QString("")));
- DEFINE_TEST_VALUE(QScriptValue(engine, QString()));
- DEFINE_TEST_VALUE(QScriptValue(engine, QString("0")));
- DEFINE_TEST_VALUE(QScriptValue(engine, QString("123")));
- DEFINE_TEST_VALUE(QScriptValue(engine, QString("1.23")));
- DEFINE_TEST_VALUE(engine->evaluate("[]"));
- DEFINE_TEST_VALUE(engine->evaluate("{}"));
- DEFINE_TEST_VALUE(engine->evaluate("Object.prototype"));
- DEFINE_TEST_VALUE(engine->evaluate("Date.prototype"));
- DEFINE_TEST_VALUE(engine->evaluate("Array.prototype"));
- DEFINE_TEST_VALUE(engine->evaluate("Function.prototype"));
- DEFINE_TEST_VALUE(engine->evaluate("Error.prototype"));
- DEFINE_TEST_VALUE(engine->evaluate("Object"));
- DEFINE_TEST_VALUE(engine->evaluate("Array"));
- DEFINE_TEST_VALUE(engine->evaluate("Number"));
- DEFINE_TEST_VALUE(engine->evaluate("Function"));
- DEFINE_TEST_VALUE(engine->evaluate("(function() { return 1; })"));
- DEFINE_TEST_VALUE(engine->evaluate("(function() { return 'ciao'; })"));
- DEFINE_TEST_VALUE(engine->evaluate("(function() { throw new Error('foo' })"));
- DEFINE_TEST_VALUE(engine->evaluate("/foo/"));
- DEFINE_TEST_VALUE(engine->evaluate("new Object()"));
- DEFINE_TEST_VALUE(engine->evaluate("new Array()"));
- DEFINE_TEST_VALUE(engine->evaluate("new Error()"));
- DEFINE_TEST_VALUE(engine->evaluate("a = new Object( a.foo = 22; a.foo"));
- DEFINE_TEST_VALUE(engine->evaluate("Undefined"));
- DEFINE_TEST_VALUE(engine->evaluate("Null"));
- DEFINE_TEST_VALUE(engine->evaluate("True"));
- DEFINE_TEST_VALUE(engine->evaluate("False"));
- DEFINE_TEST_VALUE(engine->evaluate("undefined"));
- DEFINE_TEST_VALUE(engine->evaluate("null"));
- DEFINE_TEST_VALUE(engine->evaluate("true"));
- DEFINE_TEST_VALUE(engine->evaluate("false"));
- DEFINE_TEST_VALUE(engine->evaluate("122"));
- DEFINE_TEST_VALUE(engine->evaluate("124"));
- DEFINE_TEST_VALUE(engine->evaluate("0"));
- DEFINE_TEST_VALUE(engine->evaluate("0.0"));
- DEFINE_TEST_VALUE(engine->evaluate("123.0"));
- DEFINE_TEST_VALUE(engine->evaluate("6.37e-8"));
- DEFINE_TEST_VALUE(engine->evaluate("-6.37e-8"));
- DEFINE_TEST_VALUE(engine->evaluate("0x43211234"));
- DEFINE_TEST_VALUE(engine->evaluate("0x10000"));
- DEFINE_TEST_VALUE(engine->evaluate("0x10001"));
- DEFINE_TEST_VALUE(engine->evaluate("NaN"));
- DEFINE_TEST_VALUE(engine->evaluate("Infinity"));
- DEFINE_TEST_VALUE(engine->evaluate("-Infinity"));
- DEFINE_TEST_VALUE(engine->evaluate("'ciao'"));
- DEFINE_TEST_VALUE(engine->evaluate("''"));
- DEFINE_TEST_VALUE(engine->evaluate("'0'"));
- DEFINE_TEST_VALUE(engine->evaluate("'123'"));
- DEFINE_TEST_VALUE(engine->evaluate("'12.4'"));
- DEFINE_TEST_VALUE(engine->nullValue());
- DEFINE_TEST_VALUE(engine->undefinedValue());
+ QScriptEngine* engine = m_engine;
+ switch (idx) {
+ case 0: return QPair<QString, QScriptValue>("QScriptValue()", QScriptValue());
+ case 1: return QPair<QString, QScriptValue>("QScriptValue(QScriptValue::UndefinedValue)", QScriptValue(QScriptValue::UndefinedValue));
+ case 2: return QPair<QString, QScriptValue>("QScriptValue(QScriptValue::NullValue)", QScriptValue(QScriptValue::NullValue));
+ case 3: return QPair<QString, QScriptValue>("QScriptValue(true)", QScriptValue(true));
+ case 4: return QPair<QString, QScriptValue>("QScriptValue(false)", QScriptValue(false));
+ case 5: return QPair<QString, QScriptValue>("QScriptValue(int(122))", QScriptValue(int(122)));
+ case 6: return QPair<QString, QScriptValue>("QScriptValue(uint(124))", QScriptValue(uint(124)));
+ case 7: return QPair<QString, QScriptValue>("QScriptValue(0)", QScriptValue(0));
+ case 8: return QPair<QString, QScriptValue>("QScriptValue(0.0)", QScriptValue(0.0));
+ case 9: return QPair<QString, QScriptValue>("QScriptValue(123.0)", QScriptValue(123.0));
+ case 10: return QPair<QString, QScriptValue>("QScriptValue(6.37e-8)", QScriptValue(6.37e-8));
+ case 11: return QPair<QString, QScriptValue>("QScriptValue(-6.37e-8)", QScriptValue(-6.37e-8));
+ case 12: return QPair<QString, QScriptValue>("QScriptValue(0x43211234)", QScriptValue(0x43211234));
+ case 13: return QPair<QString, QScriptValue>("QScriptValue(0x10000)", QScriptValue(0x10000));
+ case 14: return QPair<QString, QScriptValue>("QScriptValue(0x10001)", QScriptValue(0x10001));
+ case 15: return QPair<QString, QScriptValue>("QScriptValue(qSNaN())", QScriptValue(qSNaN()));
+ case 16: return QPair<QString, QScriptValue>("QScriptValue(qQNaN())", QScriptValue(qQNaN()));
+ case 17: return QPair<QString, QScriptValue>("QScriptValue(qInf())", QScriptValue(qInf()));
+ case 18: return QPair<QString, QScriptValue>("QScriptValue(-qInf())", QScriptValue(-qInf()));
+ case 19: return QPair<QString, QScriptValue>("QScriptValue(\"NaN\")", QScriptValue("NaN"));
+ case 20: return QPair<QString, QScriptValue>("QScriptValue(\"Infinity\")", QScriptValue("Infinity"));
+ case 21: return QPair<QString, QScriptValue>("QScriptValue(\"-Infinity\")", QScriptValue("-Infinity"));
+ case 22: return QPair<QString, QScriptValue>("QScriptValue(\"ciao\")", QScriptValue("ciao"));
+ case 23: return QPair<QString, QScriptValue>("QScriptValue(QString::fromLatin1(\"ciao\"))", QScriptValue(QString::fromLatin1("ciao")));
+ case 24: return QPair<QString, QScriptValue>("QScriptValue(QString(\"\"))", QScriptValue(QString("")));
+ case 25: return QPair<QString, QScriptValue>("QScriptValue(QString())", QScriptValue(QString()));
+ case 26: return QPair<QString, QScriptValue>("QScriptValue(QString(\"0\"))", QScriptValue(QString("0")));
+ case 27: return QPair<QString, QScriptValue>("QScriptValue(QString(\"123\"))", QScriptValue(QString("123")));
+ case 28: return QPair<QString, QScriptValue>("QScriptValue(QString(\"12.4\"))", QScriptValue(QString("12.4")));
+ case 29: return QPair<QString, QScriptValue>("QScriptValue(0, QScriptValue::UndefinedValue)", QScriptValue(0, QScriptValue::UndefinedValue));
+ case 30: return QPair<QString, QScriptValue>("QScriptValue(0, QScriptValue::NullValue)", QScriptValue(0, QScriptValue::NullValue));
+ case 31: return QPair<QString, QScriptValue>("QScriptValue(0, true)", QScriptValue(0, true));
+ case 32: return QPair<QString, QScriptValue>("QScriptValue(0, false)", QScriptValue(0, false));
+ case 33: return QPair<QString, QScriptValue>("QScriptValue(0, int(122))", QScriptValue(0, int(122)));
+ case 34: return QPair<QString, QScriptValue>("QScriptValue(0, uint(124))", QScriptValue(0, uint(124)));
+ case 35: return QPair<QString, QScriptValue>("QScriptValue(0, 0)", QScriptValue(0, 0));
+ case 36: return QPair<QString, QScriptValue>("QScriptValue(0, 0.0)", QScriptValue(0, 0.0));
+ case 37: return QPair<QString, QScriptValue>("QScriptValue(0, 123.0)", QScriptValue(0, 123.0));
+ case 38: return QPair<QString, QScriptValue>("QScriptValue(0, 6.37e-8)", QScriptValue(0, 6.37e-8));
+ case 39: return QPair<QString, QScriptValue>("QScriptValue(0, -6.37e-8)", QScriptValue(0, -6.37e-8));
+ case 40: return QPair<QString, QScriptValue>("QScriptValue(0, 0x43211234)", QScriptValue(0, 0x43211234));
+ case 41: return QPair<QString, QScriptValue>("QScriptValue(0, 0x10000)", QScriptValue(0, 0x10000));
+ case 42: return QPair<QString, QScriptValue>("QScriptValue(0, 0x10001)", QScriptValue(0, 0x10001));
+ case 43: return QPair<QString, QScriptValue>("QScriptValue(0, qSNaN())", QScriptValue(0, qSNaN()));
+ case 44: return QPair<QString, QScriptValue>("QScriptValue(0, qQNaN())", QScriptValue(0, qQNaN()));
+ case 45: return QPair<QString, QScriptValue>("QScriptValue(0, qInf())", QScriptValue(0, qInf()));
+ case 46: return QPair<QString, QScriptValue>("QScriptValue(0, -qInf())", QScriptValue(0, -qInf()));
+ case 47: return QPair<QString, QScriptValue>("QScriptValue(0, \"NaN\")", QScriptValue(0, "NaN"));
+ case 48: return QPair<QString, QScriptValue>("QScriptValue(0, \"Infinity\")", QScriptValue(0, "Infinity"));
+ case 49: return QPair<QString, QScriptValue>("QScriptValue(0, \"-Infinity\")", QScriptValue(0, "-Infinity"));
+ case 50: return QPair<QString, QScriptValue>("QScriptValue(0, \"ciao\")", QScriptValue(0, "ciao"));
+ case 51: return QPair<QString, QScriptValue>("QScriptValue(0, QString::fromLatin1(\"ciao\"))", QScriptValue(0, QString::fromLatin1("ciao")));
+ case 52: return QPair<QString, QScriptValue>("QScriptValue(0, QString(\"\"))", QScriptValue(0, QString("")));
+ case 53: return QPair<QString, QScriptValue>("QScriptValue(0, QString())", QScriptValue(0, QString()));
+ case 54: return QPair<QString, QScriptValue>("QScriptValue(0, QString(\"0\"))", QScriptValue(0, QString("0")));
+ case 55: return QPair<QString, QScriptValue>("QScriptValue(0, QString(\"123\"))", QScriptValue(0, QString("123")));
+ case 56: return QPair<QString, QScriptValue>("QScriptValue(0, QString(\"12.3\"))", QScriptValue(0, QString("12.3")));
+ case 57: return QPair<QString, QScriptValue>("QScriptValue(engine, QScriptValue::UndefinedValue)", QScriptValue(engine, QScriptValue::UndefinedValue));
+ case 58: return QPair<QString, QScriptValue>("QScriptValue(engine, QScriptValue::NullValue)", QScriptValue(engine, QScriptValue::NullValue));
+ case 59: return QPair<QString, QScriptValue>("QScriptValue(engine, true)", QScriptValue(engine, true));
+ case 60: return QPair<QString, QScriptValue>("QScriptValue(engine, false)", QScriptValue(engine, false));
+ case 61: return QPair<QString, QScriptValue>("QScriptValue(engine, int(122))", QScriptValue(engine, int(122)));
+ case 62: return QPair<QString, QScriptValue>("QScriptValue(engine, uint(124))", QScriptValue(engine, uint(124)));
+ case 63: return QPair<QString, QScriptValue>("QScriptValue(engine, 0)", QScriptValue(engine, 0));
+ case 64: return QPair<QString, QScriptValue>("QScriptValue(engine, 0.0)", QScriptValue(engine, 0.0));
+ case 65: return QPair<QString, QScriptValue>("QScriptValue(engine, 123.0)", QScriptValue(engine, 123.0));
+ case 66: return QPair<QString, QScriptValue>("QScriptValue(engine, 6.37e-8)", QScriptValue(engine, 6.37e-8));
+ case 67: return QPair<QString, QScriptValue>("QScriptValue(engine, -6.37e-8)", QScriptValue(engine, -6.37e-8));
+ case 68: return QPair<QString, QScriptValue>("QScriptValue(engine, 0x43211234)", QScriptValue(engine, 0x43211234));
+ case 69: return QPair<QString, QScriptValue>("QScriptValue(engine, 0x10000)", QScriptValue(engine, 0x10000));
+ case 70: return QPair<QString, QScriptValue>("QScriptValue(engine, 0x10001)", QScriptValue(engine, 0x10001));
+ case 71: return QPair<QString, QScriptValue>("QScriptValue(engine, qSNaN())", QScriptValue(engine, qSNaN()));
+ case 72: return QPair<QString, QScriptValue>("QScriptValue(engine, qQNaN())", QScriptValue(engine, qQNaN()));
+ case 73: return QPair<QString, QScriptValue>("QScriptValue(engine, qInf())", QScriptValue(engine, qInf()));
+ case 74: return QPair<QString, QScriptValue>("QScriptValue(engine, -qInf())", QScriptValue(engine, -qInf()));
+ case 75: return QPair<QString, QScriptValue>("QScriptValue(engine, \"NaN\")", QScriptValue(engine, "NaN"));
+ case 76: return QPair<QString, QScriptValue>("QScriptValue(engine, \"Infinity\")", QScriptValue(engine, "Infinity"));
+ case 77: return QPair<QString, QScriptValue>("QScriptValue(engine, \"-Infinity\")", QScriptValue(engine, "-Infinity"));
+ case 78: return QPair<QString, QScriptValue>("QScriptValue(engine, \"ciao\")", QScriptValue(engine, "ciao"));
+ case 79: return QPair<QString, QScriptValue>("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", QScriptValue(engine, QString::fromLatin1("ciao")));
+ case 80: return QPair<QString, QScriptValue>("QScriptValue(engine, QString(\"\"))", QScriptValue(engine, QString("")));
+ case 81: return QPair<QString, QScriptValue>("QScriptValue(engine, QString())", QScriptValue(engine, QString()));
+ case 82: return QPair<QString, QScriptValue>("QScriptValue(engine, QString(\"0\"))", QScriptValue(engine, QString("0")));
+ case 83: return QPair<QString, QScriptValue>("QScriptValue(engine, QString(\"123\"))", QScriptValue(engine, QString("123")));
+ case 84: return QPair<QString, QScriptValue>("QScriptValue(engine, QString(\"1.23\"))", QScriptValue(engine, QString("1.23")));
+ case 85: return QPair<QString, QScriptValue>("engine->evaluate(\"[]\")", engine->evaluate("[]"));
+ case 86: return QPair<QString, QScriptValue>("engine->evaluate(\"{}\")", engine->evaluate("{}"));
+ case 87: return QPair<QString, QScriptValue>("engine->evaluate(\"Object.prototype\")", engine->evaluate("Object.prototype"));
+ case 88: return QPair<QString, QScriptValue>("engine->evaluate(\"Date.prototype\")", engine->evaluate("Date.prototype"));
+ case 89: return QPair<QString, QScriptValue>("engine->evaluate(\"Array.prototype\")", engine->evaluate("Array.prototype"));
+ case 90: return QPair<QString, QScriptValue>("engine->evaluate(\"Function.prototype\")", engine->evaluate("Function.prototype"));
+ case 91: return QPair<QString, QScriptValue>("engine->evaluate(\"Error.prototype\")", engine->evaluate("Error.prototype"));
+ case 92: return QPair<QString, QScriptValue>("engine->evaluate(\"Object\")", engine->evaluate("Object"));
+ case 93: return QPair<QString, QScriptValue>("engine->evaluate(\"Array\")", engine->evaluate("Array"));
+ case 94: return QPair<QString, QScriptValue>("engine->evaluate(\"Number\")", engine->evaluate("Number"));
+ case 95: return QPair<QString, QScriptValue>("engine->evaluate(\"Function\")", engine->evaluate("Function"));
+ case 96: return QPair<QString, QScriptValue>("engine->evaluate(\"(function() { return 1; })\")", engine->evaluate("(function() { return 1; })"));
+ case 97: return QPair<QString, QScriptValue>("engine->evaluate(\"(function() { return 'ciao'; })\")", engine->evaluate("(function() { return 'ciao'; })"));
+ case 98: return QPair<QString, QScriptValue>("engine->evaluate(\"(function() { throw new Error('foo'); })\")", engine->evaluate("(function() { throw new Error('foo'); })"));
+ case 99: return QPair<QString, QScriptValue>("engine->evaluate(\"/foo/\")", engine->evaluate("/foo/"));
+ case 100: return QPair<QString, QScriptValue>("engine->evaluate(\"new Object()\")", engine->evaluate("new Object()"));
+ case 101: return QPair<QString, QScriptValue>("engine->evaluate(\"new Array()\")", engine->evaluate("new Array()"));
+ case 102: return QPair<QString, QScriptValue>("engine->evaluate(\"new Error()\")", engine->evaluate("new Error()"));
+ case 103: return QPair<QString, QScriptValue>("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", engine->evaluate("a = new Object(); a.foo = 22; a.foo"));
+ case 104: return QPair<QString, QScriptValue>("engine->evaluate(\"Undefined\")", engine->evaluate("Undefined"));
+ case 105: return QPair<QString, QScriptValue>("engine->evaluate(\"Null\")", engine->evaluate("Null"));
+ case 106: return QPair<QString, QScriptValue>("engine->evaluate(\"True\")", engine->evaluate("True"));
+ case 107: return QPair<QString, QScriptValue>("engine->evaluate(\"False\")", engine->evaluate("False"));
+ case 108: return QPair<QString, QScriptValue>("engine->evaluate(\"undefined\")", engine->evaluate("undefined"));
+ case 109: return QPair<QString, QScriptValue>("engine->evaluate(\"null\")", engine->evaluate("null"));
+ case 110: return QPair<QString, QScriptValue>("engine->evaluate(\"true\")", engine->evaluate("true"));
+ case 111: return QPair<QString, QScriptValue>("engine->evaluate(\"false\")", engine->evaluate("false"));
+ case 112: return QPair<QString, QScriptValue>("engine->evaluate(\"122\")", engine->evaluate("122"));
+ case 113: return QPair<QString, QScriptValue>("engine->evaluate(\"124\")", engine->evaluate("124"));
+ case 114: return QPair<QString, QScriptValue>("engine->evaluate(\"0\")", engine->evaluate("0"));
+ case 115: return QPair<QString, QScriptValue>("engine->evaluate(\"0.0\")", engine->evaluate("0.0"));
+ case 116: return QPair<QString, QScriptValue>("engine->evaluate(\"123.0\")", engine->evaluate("123.0"));
+ case 117: return QPair<QString, QScriptValue>("engine->evaluate(\"6.37e-8\")", engine->evaluate("6.37e-8"));
+ case 118: return QPair<QString, QScriptValue>("engine->evaluate(\"-6.37e-8\")", engine->evaluate("-6.37e-8"));
+ case 119: return QPair<QString, QScriptValue>("engine->evaluate(\"0x43211234\")", engine->evaluate("0x43211234"));
+ case 120: return QPair<QString, QScriptValue>("engine->evaluate(\"0x10000\")", engine->evaluate("0x10000"));
+ case 121: return QPair<QString, QScriptValue>("engine->evaluate(\"0x10001\")", engine->evaluate("0x10001"));
+ case 122: return QPair<QString, QScriptValue>("engine->evaluate(\"NaN\")", engine->evaluate("NaN"));
+ case 123: return QPair<QString, QScriptValue>("engine->evaluate(\"Infinity\")", engine->evaluate("Infinity"));
+ case 124: return QPair<QString, QScriptValue>("engine->evaluate(\"-Infinity\")", engine->evaluate("-Infinity"));
+ case 125: return QPair<QString, QScriptValue>("engine->evaluate(\"'ciao'\")", engine->evaluate("'ciao'"));
+ case 126: return QPair<QString, QScriptValue>("engine->evaluate(\"''\")", engine->evaluate("''"));
+ case 127: return QPair<QString, QScriptValue>("engine->evaluate(\"'0'\")", engine->evaluate("'0'"));
+ case 128: return QPair<QString, QScriptValue>("engine->evaluate(\"'123'\")", engine->evaluate("'123'"));
+ case 129: return QPair<QString, QScriptValue>("engine->evaluate(\"'12.4'\")", engine->evaluate("'12.4'"));
+ case 130: return QPair<QString, QScriptValue>("engine->nullValue()", engine->nullValue());
+ case 131: return QPair<QString, QScriptValue>("engine->undefinedValue()", engine->undefinedValue());
+ case 132: return QPair<QString, QScriptValue>("engine->newObject()", engine->newObject());
+ case 133: return QPair<QString, QScriptValue>("engine->newArray()", engine->newArray());
+ case 134: return QPair<QString, QScriptValue>("engine->newArray(10)", engine->newArray(10));
+ }
+ Q_ASSERT(false);
+ return qMakePair(QString(), QScriptValue());
}
diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_istype.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_istype.cpp
index f1de77d..433597f 100644
--- a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_istype.cpp
+++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_istype.cpp
@@ -25,13 +25,7 @@
#include "tst_qscriptvalue.h"
-void tst_QScriptValue::isValid_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-static QString isValid_array[] = {
+static const QString isValid_array[] = {
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
"QScriptValue(true)",
@@ -129,12 +123,12 @@ static QString isValid_array[] = {
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
- "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
- "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
@@ -162,36 +156,37 @@ static QString isValid_array[] = {
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
- "engine->undefinedValue()"};
+ "engine->undefinedValue()",
+ "engine->newObject()",
+ "engine->newArray()",
+ "engine->newArray(10)"};
-void tst_QScriptValue::isValid_makeData(const char* expr)
+void tst_QScriptValue::isValid_data()
{
- static QSet<QString> isValid;
- if (isValid.isEmpty()) {
- isValid.reserve(131);
- for (unsigned i = 0; i < 131; ++i)
- isValid.insert(isValid_array[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QSet<QString> expectedValue;
+ expectedValue.reserve(134);
+ for (uint i = 0; i < 134; ++i)
+ expectedValue.insert(isValid_array[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue.contains(testcase.first);
}
- newRow(expr) << isValid.contains(expr);
}
-void tst_QScriptValue::isValid_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::isValid()
{
+ QFETCH(QScriptValue, value);
QFETCH(bool, expected);
QCOMPARE(value.isValid(), expected);
QCOMPARE(value.isValid(), expected);
}
-DEFINE_TEST_FUNCTION(isValid)
-
-
-void tst_QScriptValue::isBool_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-static QString isBool_array[] = {
+static const QString isBool_array[] = {
"QScriptValue(true)",
"QScriptValue(false)",
"QScriptValue(0, true)",
@@ -201,34 +196,32 @@ static QString isBool_array[] = {
"engine->evaluate(\"true\")",
"engine->evaluate(\"false\")"};
-void tst_QScriptValue::isBool_makeData(const char* expr)
+void tst_QScriptValue::isBool_data()
{
- static QSet<QString> isBool;
- if (isBool.isEmpty()) {
- isBool.reserve(8);
- for (unsigned i = 0; i < 8; ++i)
- isBool.insert(isBool_array[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QSet<QString> expectedValue;
+ expectedValue.reserve(8);
+ for (uint i = 0; i < 8; ++i)
+ expectedValue.insert(isBool_array[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue.contains(testcase.first);
}
- newRow(expr) << isBool.contains(expr);
}
-void tst_QScriptValue::isBool_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::isBool()
{
+ QFETCH(QScriptValue, value);
QFETCH(bool, expected);
QCOMPARE(value.isBool(), expected);
QCOMPARE(value.isBool(), expected);
}
-DEFINE_TEST_FUNCTION(isBool)
-
-
-void tst_QScriptValue::isBoolean_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-static QString isBoolean_array[] = {
+static const QString isBoolean_array[] = {
"QScriptValue(true)",
"QScriptValue(false)",
"QScriptValue(0, true)",
@@ -238,34 +231,32 @@ static QString isBoolean_array[] = {
"engine->evaluate(\"true\")",
"engine->evaluate(\"false\")"};
-void tst_QScriptValue::isBoolean_makeData(const char* expr)
+void tst_QScriptValue::isBoolean_data()
{
- static QSet<QString> isBoolean;
- if (isBoolean.isEmpty()) {
- isBoolean.reserve(8);
- for (unsigned i = 0; i < 8; ++i)
- isBoolean.insert(isBoolean_array[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QSet<QString> expectedValue;
+ expectedValue.reserve(8);
+ for (uint i = 0; i < 8; ++i)
+ expectedValue.insert(isBoolean_array[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue.contains(testcase.first);
}
- newRow(expr) << isBoolean.contains(expr);
}
-void tst_QScriptValue::isBoolean_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::isBoolean()
{
+ QFETCH(QScriptValue, value);
QFETCH(bool, expected);
QCOMPARE(value.isBoolean(), expected);
QCOMPARE(value.isBoolean(), expected);
}
-DEFINE_TEST_FUNCTION(isBoolean)
-
-
-void tst_QScriptValue::isNumber_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-static QString isNumber_array[] = {
+static const QString isNumber_array[] = {
"QScriptValue(int(122))",
"QScriptValue(uint(124))",
"QScriptValue(0)",
@@ -308,6 +299,7 @@ static QString isNumber_array[] = {
"QScriptValue(engine, qQNaN())",
"QScriptValue(engine, qInf())",
"QScriptValue(engine, -qInf())",
+ "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"122\")",
"engine->evaluate(\"124\")",
"engine->evaluate(\"0\")",
@@ -322,34 +314,32 @@ static QString isNumber_array[] = {
"engine->evaluate(\"Infinity\")",
"engine->evaluate(\"-Infinity\")"};
-void tst_QScriptValue::isNumber_makeData(const char* expr)
+void tst_QScriptValue::isNumber_data()
{
- static QSet<QString> isNumber;
- if (isNumber.isEmpty()) {
- isNumber.reserve(55);
- for (unsigned i = 0; i < 55; ++i)
- isNumber.insert(isNumber_array[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QSet<QString> expectedValue;
+ expectedValue.reserve(56);
+ for (uint i = 0; i < 56; ++i)
+ expectedValue.insert(isNumber_array[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue.contains(testcase.first);
}
- newRow(expr) << isNumber.contains(expr);
}
-void tst_QScriptValue::isNumber_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::isNumber()
{
+ QFETCH(QScriptValue, value);
QFETCH(bool, expected);
QCOMPARE(value.isNumber(), expected);
QCOMPARE(value.isNumber(), expected);
}
-DEFINE_TEST_FUNCTION(isNumber)
-
-
-void tst_QScriptValue::isFunction_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-static QString isFunction_array[] = {
+static const QString isFunction_array[] = {
"engine->evaluate(\"Function.prototype\")",
"engine->evaluate(\"Object\")",
"engine->evaluate(\"Array\")",
@@ -357,70 +347,67 @@ static QString isFunction_array[] = {
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")"};
-void tst_QScriptValue::isFunction_makeData(const char* expr)
+void tst_QScriptValue::isFunction_data()
{
- static QSet<QString> isFunction;
- if (isFunction.isEmpty()) {
- isFunction.reserve(8);
- for (unsigned i = 0; i < 8; ++i)
- isFunction.insert(isFunction_array[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QSet<QString> expectedValue;
+ expectedValue.reserve(9);
+ for (uint i = 0; i < 9; ++i)
+ expectedValue.insert(isFunction_array[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue.contains(testcase.first);
}
- newRow(expr) << isFunction.contains(expr);
}
-void tst_QScriptValue::isFunction_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::isFunction()
{
+ QFETCH(QScriptValue, value);
QFETCH(bool, expected);
QCOMPARE(value.isFunction(), expected);
QCOMPARE(value.isFunction(), expected);
}
-DEFINE_TEST_FUNCTION(isFunction)
-
-
-void tst_QScriptValue::isNull_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-static QString isNull_array[] = {
+static const QString isNull_array[] = {
"QScriptValue(QScriptValue::NullValue)",
"QScriptValue(0, QScriptValue::NullValue)",
"QScriptValue(engine, QScriptValue::NullValue)",
"engine->evaluate(\"null\")",
"engine->nullValue()"};
-void tst_QScriptValue::isNull_makeData(const char* expr)
+void tst_QScriptValue::isNull_data()
{
- static QSet<QString> isNull;
- if (isNull.isEmpty()) {
- isNull.reserve(5);
- for (unsigned i = 0; i < 5; ++i)
- isNull.insert(isNull_array[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QSet<QString> expectedValue;
+ expectedValue.reserve(5);
+ for (uint i = 0; i < 5; ++i)
+ expectedValue.insert(isNull_array[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue.contains(testcase.first);
}
- newRow(expr) << isNull.contains(expr);
}
-void tst_QScriptValue::isNull_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::isNull()
{
+ QFETCH(QScriptValue, value);
QFETCH(bool, expected);
QCOMPARE(value.isNull(), expected);
QCOMPARE(value.isNull(), expected);
}
-DEFINE_TEST_FUNCTION(isNull)
-
-
-void tst_QScriptValue::isString_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-static QString isString_array[] = {
+static const QString isString_array[] = {
"QScriptValue(\"NaN\")",
"QScriptValue(\"Infinity\")",
"QScriptValue(\"-Infinity\")",
@@ -457,34 +444,32 @@ static QString isString_array[] = {
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")"};
-void tst_QScriptValue::isString_makeData(const char* expr)
+void tst_QScriptValue::isString_data()
{
- static QSet<QString> isString;
- if (isString.isEmpty()) {
- isString.reserve(35);
- for (unsigned i = 0; i < 35; ++i)
- isString.insert(isString_array[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QSet<QString> expectedValue;
+ expectedValue.reserve(35);
+ for (uint i = 0; i < 35; ++i)
+ expectedValue.insert(isString_array[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue.contains(testcase.first);
}
- newRow(expr) << isString.contains(expr);
}
-void tst_QScriptValue::isString_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::isString()
{
+ QFETCH(QScriptValue, value);
QFETCH(bool, expected);
QCOMPARE(value.isString(), expected);
QCOMPARE(value.isString(), expected);
}
-DEFINE_TEST_FUNCTION(isString)
-
-
-void tst_QScriptValue::isUndefined_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-static QString isUndefined_array[] = {
+static const QString isUndefined_array[] = {
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(0, QScriptValue::UndefinedValue)",
"QScriptValue(engine, QScriptValue::UndefinedValue)",
@@ -492,37 +477,35 @@ static QString isUndefined_array[] = {
"engine->evaluate(\"undefined\")",
"engine->undefinedValue()"};
-void tst_QScriptValue::isUndefined_makeData(const char* expr)
+void tst_QScriptValue::isUndefined_data()
{
- static QSet<QString> isUndefined;
- if (isUndefined.isEmpty()) {
- isUndefined.reserve(6);
- for (unsigned i = 0; i < 6; ++i)
- isUndefined.insert(isUndefined_array[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QSet<QString> expectedValue;
+ expectedValue.reserve(6);
+ for (uint i = 0; i < 6; ++i)
+ expectedValue.insert(isUndefined_array[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue.contains(testcase.first);
}
- newRow(expr) << isUndefined.contains(expr);
}
-void tst_QScriptValue::isUndefined_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::isUndefined()
{
+ QFETCH(QScriptValue, value);
QFETCH(bool, expected);
QCOMPARE(value.isUndefined(), expected);
QCOMPARE(value.isUndefined(), expected);
}
-DEFINE_TEST_FUNCTION(isUndefined)
-
-
-void tst_QScriptValue::isObject_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-static QString isObject_array[] = {
+static const QString isObject_array[] = {
"engine->evaluate(\"[]\")",
"engine->evaluate(\"Object.prototype\")",
"engine->evaluate(\"Date.prototype\")",
@@ -535,33 +518,105 @@ static QString isObject_array[] = {
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
- "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
- "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
- "engine->evaluate(\"False\")"};
+ "engine->evaluate(\"False\")",
+ "engine->newObject()",
+ "engine->newArray()",
+ "engine->newArray(10)"};
-void tst_QScriptValue::isObject_makeData(const char* expr)
+void tst_QScriptValue::isObject_data()
{
- static QSet<QString> isObject;
- if (isObject.isEmpty()) {
- isObject.reserve(22);
- for (unsigned i = 0; i < 22; ++i)
- isObject.insert(isObject_array[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QSet<QString> expectedValue;
+ expectedValue.reserve(24);
+ for (uint i = 0; i < 24; ++i)
+ expectedValue.insert(isObject_array[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue.contains(testcase.first);
}
- newRow(expr) << isObject.contains(expr);
}
-void tst_QScriptValue::isObject_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::isObject()
{
+ QFETCH(QScriptValue, value);
QFETCH(bool, expected);
QCOMPARE(value.isObject(), expected);
QCOMPARE(value.isObject(), expected);
}
-DEFINE_TEST_FUNCTION(isObject)
+static const QString isArray_array[] = {
+ "engine->evaluate(\"[]\")",
+ "engine->evaluate(\"Array.prototype\")",
+ "engine->evaluate(\"new Array()\")",
+ "engine->newArray()",
+ "engine->newArray(10)"};
+
+void tst_QScriptValue::isArray_data()
+{
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QSet<QString> expectedValue;
+ expectedValue.reserve(5);
+ for (uint i = 0; i < 5; ++i)
+ expectedValue.insert(isArray_array[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue.contains(testcase.first);
+ }
+}
+
+void tst_QScriptValue::isArray()
+{
+ QFETCH(QScriptValue, value);
+ QFETCH(bool, expected);
+ QCOMPARE(value.isArray(), expected);
+ QCOMPARE(value.isArray(), expected);
+}
+
+static const QString isError_array[] = {
+ "engine->evaluate(\"Error.prototype\")",
+ "engine->evaluate(\"new Error()\")",
+ "engine->evaluate(\"Undefined\")",
+ "engine->evaluate(\"Null\")",
+ "engine->evaluate(\"True\")",
+ "engine->evaluate(\"False\")"};
+
+void tst_QScriptValue::isError_data()
+{
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QSet<QString> expectedValue;
+ expectedValue.reserve(6);
+ for (uint i = 0; i < 6; ++i)
+ expectedValue.insert(isError_array[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue.contains(testcase.first);
+ }
+}
+
+void tst_QScriptValue::isError()
+{
+ QFETCH(QScriptValue, value);
+ QFETCH(bool, expected);
+ QCOMPARE(value.isError(), expected);
+ QCOMPARE(value.isError(), expected);
+}
diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_totype.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_totype.cpp
index a946aef..eaa5d14 100644
--- a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_totype.cpp
+++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_totype.cpp
@@ -23,15 +23,7 @@
#include "tst_qscriptvalue.h"
-
-
-void tst_QScriptValue::toString_initData()
-{
- QTest::addColumn<QString>("expected");
- initScriptValues();
-}
-
-static QString toString_tagArray[] = {
+static const QString toString_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
@@ -130,12 +122,12 @@ static QString toString_tagArray[] = {
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
- "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
- "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
@@ -163,9 +155,12 @@ static QString toString_tagArray[] = {
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
- "engine->undefinedValue()"};
+ "engine->undefinedValue()",
+ "engine->newObject()",
+ "engine->newArray()",
+ "engine->newArray(10)"};
-static QString toString_valueArray[] = {
+static const QString toString_valueArray[] = {
"", "undefined",
"null", "true",
"false", "122",
@@ -215,9 +210,9 @@ static QString toString_valueArray[] = {
"function Object() {\n [native code]\n}", "function Array() {\n [native code]\n}",
"function Number() {\n [native code]\n}", "function Function() {\n [native code]\n}",
"function () { return 1; }", "function () { return 'ciao'; }",
- "SyntaxError: Parse error", "/foo/",
+ "function () { throw new Error('foo'); }", "/foo/",
"[object Object]", "",
- "Error: Unknown error", "SyntaxError: Parse error",
+ "Error: Unknown error", "22",
"ReferenceError: Can't find variable: Undefined", "ReferenceError: Can't find variable: Null",
"ReferenceError: Can't find variable: True", "ReferenceError: Can't find variable: False",
"undefined", "null",
@@ -231,36 +226,36 @@ static QString toString_valueArray[] = {
"-Infinity", "ciao",
"", "0",
"123", "12.4",
- "null", "undefined"};
+ "null", "undefined",
+ "[object Object]", "",
+ ",,,,,,,,,"};
-void tst_QScriptValue::toString_makeData(const char* expr)
+void tst_QScriptValue::toString_data()
{
- static QHash<QString, QString> toString;
- if (toString.isEmpty()) {
- toString.reserve(132);
- for (unsigned i = 0; i < 132; ++i)
- toString.insert(toString_tagArray[i], toString_valueArray[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<QString>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QHash<QString, QString> expectedValue;
+ expectedValue.reserve(135);
+ for (uint i = 0; i < 135; ++i)
+ expectedValue.insert(toString_tagArray[i], toString_valueArray[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue[testcase.first];
}
- newRow(expr) << toString.value(expr);
}
-void tst_QScriptValue::toString_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::toString()
{
+ QFETCH(QScriptValue, value);
QFETCH(QString, expected);
QCOMPARE(value.toString(), expected);
QCOMPARE(value.toString(), expected);
}
-DEFINE_TEST_FUNCTION(toString)
-
-
-void tst_QScriptValue::toNumber_initData()
-{
- QTest::addColumn<qsreal>("expected");
- initScriptValues();
-}
-
-static QString toNumber_tagArray[] = {
+static const QString toNumber_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
@@ -359,12 +354,12 @@ static QString toNumber_tagArray[] = {
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
- "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
- "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
@@ -392,8 +387,12 @@ static QString toNumber_tagArray[] = {
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
- "engine->undefinedValue()"};
-static qsreal toNumber_valueArray[] = {
+ "engine->undefinedValue()",
+ "engine->newObject()",
+ "engine->newArray()",
+ "engine->newArray(10)"};
+
+static const qsreal toNumber_valueArray[] = {
0, qQNaN(), 0, 1, 0, 122, 124, 0, 0, 123,
6.369999999999999e-08, -6.369999999999999e-08, 1126240820, 65536, 65537, qQNaN(), qQNaN(), qInf(), qInf(), qQNaN(),
qInf(), qInf(), qQNaN(), qQNaN(), 0, 0, 0, 123, 12.4, qQNaN(),
@@ -404,23 +403,31 @@ static qsreal toNumber_valueArray[] = {
65537, qQNaN(), qQNaN(), qInf(), qInf(), qQNaN(), qInf(), qInf(), qQNaN(), qQNaN(),
0, 0, 0, 123, 1.23, 0, qQNaN(), qQNaN(), qQNaN(), 0,
qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(),
- qQNaN(), 0, qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), 0,
+ qQNaN(), 0, qQNaN(), 22, qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), 0,
1, 0, 122, 124, 0, 0, 123, 6.369999999999999e-08, -6.369999999999999e-08, 1126240820,
65536, 65537, qQNaN(), qInf(), qInf(), qQNaN(), 0, 0, 123, 12.4,
- 0, qQNaN()};
-void tst_QScriptValue::toNumber_makeData(const char* expr)
+ 0, qQNaN(), qQNaN(), 0, qQNaN()};
+
+void tst_QScriptValue::toNumber_data()
{
- static QHash<QString, qsreal> toNumber;
- if (toNumber.isEmpty()) {
- toNumber.reserve(132);
- for (unsigned i = 0; i < 132; ++i)
- toNumber.insert(toNumber_tagArray[i], toNumber_valueArray[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<qsreal>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QHash<QString, qsreal> expectedValue;
+ expectedValue.reserve(135);
+ for (uint i = 0; i < 135; ++i)
+ expectedValue.insert(toNumber_tagArray[i], toNumber_valueArray[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue[testcase.first];
}
- newRow(expr) << toNumber.value(expr);
}
-void tst_QScriptValue::toNumber_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::toNumber()
{
+ QFETCH(QScriptValue, value);
QFETCH(qsreal, expected);
if (qIsNaN(expected)) {
QVERIFY(qIsNaN(value.toNumber()));
@@ -435,16 +442,7 @@ void tst_QScriptValue::toNumber_test(const char*, const QScriptValue& value)
QCOMPARE(value.toNumber(), expected);
}
-DEFINE_TEST_FUNCTION(toNumber)
-
-
-void tst_QScriptValue::toBool_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-static QString toBool_tagArray[] = {
+static const QString toBool_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
@@ -543,12 +541,12 @@ static QString toBool_tagArray[] = {
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
- "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
- "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
@@ -576,9 +574,12 @@ static QString toBool_tagArray[] = {
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
- "engine->undefinedValue()"};
+ "engine->undefinedValue()",
+ "engine->newObject()",
+ "engine->newArray()",
+ "engine->newArray(10)"};
-static bool toBool_valueArray[] = {
+static const bool toBool_valueArray[] = {
false, false,
false, true,
false, true,
@@ -644,36 +645,36 @@ static bool toBool_valueArray[] = {
true, true,
false, true,
true, true,
- false, false};
+ false, false,
+ true, true,
+ true};
-void tst_QScriptValue::toBool_makeData(const char* expr)
+void tst_QScriptValue::toBool_data()
{
- static QHash<QString, bool> toBool;
- if (toBool.isEmpty()) {
- toBool.reserve(132);
- for (unsigned i = 0; i < 132; ++i)
- toBool.insert(toBool_tagArray[i], toBool_valueArray[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QHash<QString, bool> expectedValue;
+ expectedValue.reserve(135);
+ for (uint i = 0; i < 135; ++i)
+ expectedValue.insert(toBool_tagArray[i], toBool_valueArray[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue[testcase.first];
}
- newRow(expr) << toBool.value(expr);
}
-void tst_QScriptValue::toBool_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::toBool()
{
+ QFETCH(QScriptValue, value);
QFETCH(bool, expected);
QCOMPARE(value.toBool(), expected);
QCOMPARE(value.toBool(), expected);
}
-DEFINE_TEST_FUNCTION(toBool)
-
-
-void tst_QScriptValue::toBoolean_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-static QString toBoolean_tagArray[] = {
+static const QString toBoolean_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
@@ -772,12 +773,12 @@ static QString toBoolean_tagArray[] = {
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
- "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
- "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
@@ -805,9 +806,12 @@ static QString toBoolean_tagArray[] = {
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
- "engine->undefinedValue()"};
+ "engine->undefinedValue()",
+ "engine->newObject()",
+ "engine->newArray()",
+ "engine->newArray(10)"};
-static bool toBoolean_valueArray[] = {
+static const bool toBoolean_valueArray[] = {
false, false,
false, true,
false, true,
@@ -873,36 +877,36 @@ static bool toBoolean_valueArray[] = {
true, true,
false, true,
true, true,
- false, false};
+ false, false,
+ true, true,
+ true};
-void tst_QScriptValue::toBoolean_makeData(const char* expr)
+void tst_QScriptValue::toBoolean_data()
{
- static QHash<QString, bool> toBoolean;
- if (toBoolean.isEmpty()) {
- toBoolean.reserve(132);
- for (unsigned i = 0; i < 132; ++i)
- toBoolean.insert(toBoolean_tagArray[i], toBoolean_valueArray[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<bool>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QHash<QString, bool> expectedValue;
+ expectedValue.reserve(135);
+ for (uint i = 0; i < 135; ++i)
+ expectedValue.insert(toBoolean_tagArray[i], toBoolean_valueArray[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue[testcase.first];
}
- newRow(expr) << toBoolean.value(expr);
}
-void tst_QScriptValue::toBoolean_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::toBoolean()
{
+ QFETCH(QScriptValue, value);
QFETCH(bool, expected);
QCOMPARE(value.toBoolean(), expected);
QCOMPARE(value.toBoolean(), expected);
}
-DEFINE_TEST_FUNCTION(toBoolean)
-
-
-void tst_QScriptValue::toInteger_initData()
-{
- QTest::addColumn<qsreal>("expected");
- initScriptValues();
-}
-
-static QString toInteger_tagArray[] = {
+static const QString toInteger_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
@@ -1001,12 +1005,12 @@ static QString toInteger_tagArray[] = {
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
- "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
- "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
@@ -1034,8 +1038,12 @@ static QString toInteger_tagArray[] = {
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
- "engine->undefinedValue()"};
-static qsreal toInteger_valueArray[] = {
+ "engine->undefinedValue()",
+ "engine->newObject()",
+ "engine->newArray()",
+ "engine->newArray(10)"};
+
+static const qsreal toInteger_valueArray[] = {
0, 0, 0, 1, 0, 122, 124, 0, 0, 123,
0, 0, 1126240820, 65536, 65537, 0, 0, qInf(), qInf(), 0,
qInf(), qInf(), 0, 0, 0, 0, 0, 123, 12, 0,
@@ -1046,23 +1054,31 @@ static qsreal toInteger_valueArray[] = {
65537, 0, 0, qInf(), qInf(), 0, qInf(), qInf(), 0, 0,
0, 0, 0, 123, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 22, 0, 0, 0, 0, 0, 0,
1, 0, 122, 124, 0, 0, 123, 0, 0, 1126240820,
65536, 65537, 0, qInf(), qInf(), 0, 0, 0, 123, 12,
- 0, 0};
-void tst_QScriptValue::toInteger_makeData(const char* expr)
+ 0, 0, 0, 0, 0};
+
+void tst_QScriptValue::toInteger_data()
{
- static QHash<QString, qsreal> toInteger;
- if (toInteger.isEmpty()) {
- toInteger.reserve(132);
- for (unsigned i = 0; i < 132; ++i)
- toInteger.insert(toInteger_tagArray[i], toInteger_valueArray[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<qsreal>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QHash<QString, qsreal> expectedValue;
+ expectedValue.reserve(135);
+ for (uint i = 0; i < 135; ++i)
+ expectedValue.insert(toInteger_tagArray[i], toInteger_valueArray[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue[testcase.first];
}
- newRow(expr) << toInteger.value(expr);
}
-void tst_QScriptValue::toInteger_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::toInteger()
{
+ QFETCH(QScriptValue, value);
QFETCH(qsreal, expected);
if (qIsInf(expected)) {
QVERIFY(qIsInf(value.toInteger()));
@@ -1073,16 +1089,7 @@ void tst_QScriptValue::toInteger_test(const char*, const QScriptValue& value)
QCOMPARE(value.toInteger(), expected);
}
-DEFINE_TEST_FUNCTION(toInteger)
-
-
-void tst_QScriptValue::toInt32_initData()
-{
- QTest::addColumn<qint32>("expected");
- initScriptValues();
-}
-
-static QString toInt32_tagArray[] = {
+static const QString toInt32_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
@@ -1181,12 +1188,12 @@ static QString toInt32_tagArray[] = {
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
- "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
- "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
@@ -1214,9 +1221,12 @@ static QString toInt32_tagArray[] = {
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
- "engine->undefinedValue()"};
+ "engine->undefinedValue()",
+ "engine->newObject()",
+ "engine->newArray()",
+ "engine->newArray(10)"};
-static qint32 toInt32_valueArray[] = {
+static const qint32 toInt32_valueArray[] = {
0, 0,
0, 1,
0, 122,
@@ -1268,7 +1278,7 @@ static qint32 toInt32_valueArray[] = {
0, 0,
0, 0,
0, 0,
- 0, 0,
+ 0, 22,
0, 0,
0, 0,
0, 0,
@@ -1282,36 +1292,36 @@ static qint32 toInt32_valueArray[] = {
0, 0,
0, 0,
123, 12,
- 0, 0};
+ 0, 0,
+ 0, 0,
+ 0};
-void tst_QScriptValue::toInt32_makeData(const char* expr)
+void tst_QScriptValue::toInt32_data()
{
- static QHash<QString, qint32> toInt32;
- if (toInt32.isEmpty()) {
- toInt32.reserve(132);
- for (unsigned i = 0; i < 132; ++i)
- toInt32.insert(toInt32_tagArray[i], toInt32_valueArray[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<qint32>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QHash<QString, qint32> expectedValue;
+ expectedValue.reserve(135);
+ for (uint i = 0; i < 135; ++i)
+ expectedValue.insert(toInt32_tagArray[i], toInt32_valueArray[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue[testcase.first];
}
- newRow(expr) << toInt32.value(expr);
}
-void tst_QScriptValue::toInt32_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::toInt32()
{
+ QFETCH(QScriptValue, value);
QFETCH(qint32, expected);
QCOMPARE(value.toInt32(), expected);
QCOMPARE(value.toInt32(), expected);
}
-DEFINE_TEST_FUNCTION(toInt32)
-
-
-void tst_QScriptValue::toUInt32_initData()
-{
- QTest::addColumn<quint32>("expected");
- initScriptValues();
-}
-
-static QString toUInt32_tagArray[] = {
+static const QString toUInt32_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
@@ -1410,12 +1420,12 @@ static QString toUInt32_tagArray[] = {
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
- "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
- "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
@@ -1443,9 +1453,12 @@ static QString toUInt32_tagArray[] = {
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
- "engine->undefinedValue()"};
+ "engine->undefinedValue()",
+ "engine->newObject()",
+ "engine->newArray()",
+ "engine->newArray(10)"};
-static quint32 toUInt32_valueArray[] = {
+static const quint32 toUInt32_valueArray[] = {
0, 0,
0, 1,
0, 122,
@@ -1497,7 +1510,7 @@ static quint32 toUInt32_valueArray[] = {
0, 0,
0, 0,
0, 0,
- 0, 0,
+ 0, 22,
0, 0,
0, 0,
0, 0,
@@ -1511,36 +1524,36 @@ static quint32 toUInt32_valueArray[] = {
0, 0,
0, 0,
123, 12,
- 0, 0};
+ 0, 0,
+ 0, 0,
+ 0};
-void tst_QScriptValue::toUInt32_makeData(const char* expr)
+void tst_QScriptValue::toUInt32_data()
{
- static QHash<QString, quint32> toUInt32;
- if (toUInt32.isEmpty()) {
- toUInt32.reserve(132);
- for (unsigned i = 0; i < 132; ++i)
- toUInt32.insert(toUInt32_tagArray[i], toUInt32_valueArray[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<quint32>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QHash<QString, quint32> expectedValue;
+ expectedValue.reserve(135);
+ for (uint i = 0; i < 135; ++i)
+ expectedValue.insert(toUInt32_tagArray[i], toUInt32_valueArray[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue[testcase.first];
}
- newRow(expr) << toUInt32.value(expr);
}
-void tst_QScriptValue::toUInt32_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::toUInt32()
{
+ QFETCH(QScriptValue, value);
QFETCH(quint32, expected);
QCOMPARE(value.toUInt32(), expected);
QCOMPARE(value.toUInt32(), expected);
}
-DEFINE_TEST_FUNCTION(toUInt32)
-
-
-void tst_QScriptValue::toUInt16_initData()
-{
- QTest::addColumn<quint16>("expected");
- initScriptValues();
-}
-
-static QString toUInt16_tagArray[] = {
+static const QString toUInt16_tagArray[] = {
"QScriptValue()",
"QScriptValue(QScriptValue::UndefinedValue)",
"QScriptValue(QScriptValue::NullValue)",
@@ -1639,12 +1652,12 @@ static QString toUInt16_tagArray[] = {
"engine->evaluate(\"Function\")",
"engine->evaluate(\"(function() { return 1; })\")",
"engine->evaluate(\"(function() { return 'ciao'; })\")",
- "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo'); })\")",
"engine->evaluate(\"/foo/\")",
"engine->evaluate(\"new Object()\")",
"engine->evaluate(\"new Array()\")",
"engine->evaluate(\"new Error()\")",
- "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")",
"engine->evaluate(\"Undefined\")",
"engine->evaluate(\"Null\")",
"engine->evaluate(\"True\")",
@@ -1672,9 +1685,12 @@ static QString toUInt16_tagArray[] = {
"engine->evaluate(\"'123'\")",
"engine->evaluate(\"'12.4'\")",
"engine->nullValue()",
- "engine->undefinedValue()"};
+ "engine->undefinedValue()",
+ "engine->newObject()",
+ "engine->newArray()",
+ "engine->newArray(10)"};
-static quint16 toUInt16_valueArray[] = {
+static const quint16 toUInt16_valueArray[] = {
0, 0,
0, 1,
0, 122,
@@ -1726,7 +1742,7 @@ static quint16 toUInt16_valueArray[] = {
0, 0,
0, 0,
0, 0,
- 0, 0,
+ 0, 22,
0, 0,
0, 0,
0, 0,
@@ -1740,24 +1756,31 @@ static quint16 toUInt16_valueArray[] = {
0, 0,
0, 0,
123, 12,
- 0, 0};
+ 0, 0,
+ 0, 0,
+ 0};
-void tst_QScriptValue::toUInt16_makeData(const char* expr)
+void tst_QScriptValue::toUInt16_data()
{
- static QHash<QString, quint16> toUInt16;
- if (toUInt16.isEmpty()) {
- toUInt16.reserve(132);
- for (unsigned i = 0; i < 132; ++i)
- toUInt16.insert(toUInt16_tagArray[i], toUInt16_valueArray[i]);
+ QTest::addColumn<QScriptValue>("value");
+ QTest::addColumn<quint16>("expected");
+ if (m_engine)
+ delete m_engine;
+ m_engine = new QScriptEngine();
+ QHash<QString, quint16> expectedValue;
+ expectedValue.reserve(135);
+ for (uint i = 0; i < 135; ++i)
+ expectedValue.insert(toUInt16_tagArray[i], toUInt16_valueArray[i]);
+ for (uint i = 0; i < 135; ++i) {
+ QPair<QString, QScriptValue> testcase = initScriptValues(i);
+ QTest::newRow(testcase.first.toAscii().constData()) << testcase.second << expectedValue[testcase.first];
}
- newRow(expr) << toUInt16.value(expr);
}
-void tst_QScriptValue::toUInt16_test(const char*, const QScriptValue& value)
+void tst_QScriptValue::toUInt16()
{
+ QFETCH(QScriptValue, value);
QFETCH(quint16, expected);
QCOMPARE(value.toUInt16(), expected);
QCOMPARE(value.toUInt16(), expected);
}
-
-DEFINE_TEST_FUNCTION(toUInt16)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list