summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-01-20 08:35:06 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-20 23:35:18 +0100
commit46426bdbe62eaeeb144c3702dd1c78d131a39d73 (patch)
tree204c58e1e527ec542323f8c4f4b915fdde19e7b9 /tests/benchmarks
parent5d78efa25fd3b720eca536936d45602c8f5b0fa4 (diff)
Don't use deprecated functions in QJS benchmarks
Remove benchmarks for functions that are going away. Task-number: QTBUG-23604 Change-Id: Ia65c7981652011f89f2131ff14f63aae410013cf Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp82
-rw-r--r--tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp136
2 files changed, 34 insertions, 184 deletions
diff --git a/tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp b/tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp
index 67847837ff..bdbf339b55 100644
--- a/tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp
+++ b/tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp
@@ -81,7 +81,6 @@ private slots:
void newArray_data();
void newArray();
void newDate();
- void newDateFromMs();
void newObject();
#if 0 // No ScriptClass
void newObjectWithScriptClass();
@@ -94,9 +93,7 @@ private slots:
void newFunction();
#endif
void newRegExp();
- void newRegExpFromString();
void newVariant();
- void nullValue();
void undefinedValue();
void collectGarbage();
#if 0 // No extensions
@@ -107,8 +104,6 @@ private slots:
void currentContext();
void pushAndPopContext();
#endif
- void toObject_data();
- void toObject();
#if 0 // no stringhandle
void toStringHandle();
#endif
@@ -319,15 +314,7 @@ void tst_QJSEngine::newDate()
newEngine();
QDateTime dt = QDateTime::currentDateTime();
QBENCHMARK {
- m_engine->newDate(dt);
- }
-}
-
-void tst_QJSEngine::newDateFromMs()
-{
- newEngine();
- QBENCHMARK {
- m_engine->newDate(0);
+ m_engine->toScriptValue(dt);
}
}
@@ -386,42 +373,25 @@ void tst_QJSEngine::newRegExp()
newEngine();
QRegExp re = QRegExp("foo");
QBENCHMARK {
- m_engine->newRegExp(re);
- }
-}
-
-void tst_QJSEngine::newRegExpFromString()
-{
- newEngine();
- QString pattern("foo");
- QString flags("gim");
- QBENCHMARK {
- m_engine->newRegExp(pattern, flags);
+ m_engine->toScriptValue(re);
}
}
void tst_QJSEngine::newVariant()
{
newEngine();
- QVariant var(123);
+ QVariant var(QPoint(10, 20));
QBENCHMARK {
- (void)m_engine->newVariant(var);
- }
-}
-
-void tst_QJSEngine::nullValue()
-{
- newEngine();
- QBENCHMARK {
- m_engine->nullValue();
+ (void)m_engine->toScriptValue(var);
}
}
void tst_QJSEngine::undefinedValue()
{
newEngine();
+ QVariant var;
QBENCHMARK {
- m_engine->undefinedValue();
+ m_engine->toScriptValue(var);
}
}
@@ -468,46 +438,6 @@ void tst_QJSEngine::pushAndPopContext()
}
#endif
-void tst_QJSEngine::toObject_data()
-{
- newEngine();
- QTest::addColumn<QJSValue>("val");
- QTest::newRow("bool") << m_engine->evaluate("true");
- QTest::newRow("number") << m_engine->evaluate("123");
- QTest::newRow("string") << m_engine->evaluate("'ciao'");
- QTest::newRow("null") << m_engine->evaluate("null");
- QTest::newRow("undefined") << m_engine->evaluate("undefined");
- QTest::newRow("object") << m_engine->evaluate("({foo:123})");
- QTest::newRow("array") << m_engine->evaluate("[10,20,30]");
- QTest::newRow("function") << m_engine->evaluate("(function foo(a, b, c) { return a + b + c; })");
- QTest::newRow("date") << m_engine->evaluate("new Date");
- QTest::newRow("regexp") << m_engine->evaluate("new RegExp('foo')");
- QTest::newRow("error") << m_engine->evaluate("new Error");
-
- QTest::newRow("qobject") << m_engine->newQObject(this);
-#if 0 // no QMetaObject
- QTest::newRow("qmetaobject") << m_engine->newQMetaObject(&QJSEngine::staticMetaObject);
-#endif
- QTest::newRow("variant") << m_engine->newVariant(123);
-#if 0 //no classes
- QTest::newRow("qscriptclassobject") << m_engine->newObject(new QScriptClass(m_engine));
-#endif
- QTest::newRow("invalid") << QJSValue();
- QTest::newRow("bool-no-engine") << QJSValue(true);
- QTest::newRow("number-no-engine") << QJSValue(123.0);
- QTest::newRow("string-no-engine") << QJSValue(QString::fromLatin1("hello"));
- QTest::newRow("null-no-engine") << QJSValue(QJSValue::NullValue);
- QTest::newRow("undefined-no-engine") << QJSValue(QJSValue::UndefinedValue);
-}
-
-void tst_QJSEngine::toObject()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- m_engine->toObject(val);
- }
-}
-
#if 0
void tst_QJSEngine::toStringHandle()
{
diff --git a/tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp b/tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp
index a81e576d30..4747d13bd4 100644
--- a/tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp
+++ b/tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp
@@ -68,7 +68,6 @@ private slots:
void floatConstructorWithEngine();
void intConstructorWithEngine();
void stringConstructorWithEngine();
- void nullConstructorWithEngine();
void undefinedConstructorWithEngine();
void copyConstructor_data();
void copyConstructor();
@@ -82,8 +81,6 @@ private slots:
void data_noData_data();
void data_noData();
#endif
- void engine_data();
- void engine();
void equalsSelf_data();
void equalsSelf();
#if 0 // no less then
@@ -92,7 +89,6 @@ private slots:
#endif
void strictlyEqualsSelf_data();
void strictlyEqualsSelf();
- void instanceOf();
void isArray_data();
void isArray();
void isBool_data();
@@ -101,8 +97,8 @@ private slots:
void isDate();
void isError_data();
void isError();
- void isFunction_data();
- void isFunction();
+ void isCallable_data();
+ void isCallable();
void isNull_data();
void isNull();
void isNumber_data();
@@ -121,28 +117,22 @@ private slots:
void isString();
void isUndefined_data();
void isUndefined();
- void isValid_data();
- void isValid();
void isVariant_data();
void isVariant();
void toBool_data();
void toBool();
void toDateTime_data();
void toDateTime();
- void toInt32_data();
- void toInt32();
- void toInteger_data();
- void toInteger();
+ void toInt_data();
+ void toInt();
void toNumber_data();
void toNumber();
void toRegExp_data();
void toRegExp();
void toString_data();
void toString();
- void toUInt16_data();
- void toUInt16();
- void toUInt32_data();
- void toUInt32();
+ void toUInt_data();
+ void toUInt();
#if 0 // no qmetaobject
void toQMetaObject_data();
void toQMetaObject();
@@ -260,7 +250,7 @@ void tst_QJSValue::boolConstructorWithEngine()
{
newEngine();
QBENCHMARK {
- QJSValue val(m_engine, true);
+ m_engine->toScriptValue(true);
}
}
@@ -268,7 +258,7 @@ void tst_QJSValue::floatConstructorWithEngine()
{
newEngine();
QBENCHMARK {
- QJSValue val(m_engine, 123.0);
+ m_engine->toScriptValue(123.0);
}
}
@@ -276,7 +266,7 @@ void tst_QJSValue::intConstructorWithEngine()
{
newEngine();
QBENCHMARK {
- (void)QJSValue(m_engine, 123);
+ m_engine->toScriptValue(123);
}
}
@@ -285,23 +275,16 @@ void tst_QJSValue::stringConstructorWithEngine()
newEngine();
QString str = QString::fromLatin1("ciao");
QBENCHMARK {
- (void)QJSValue(m_engine, str);
- }
-}
-
-void tst_QJSValue::nullConstructorWithEngine()
-{
- newEngine();
- QBENCHMARK {
- QJSValue val(m_engine, QJSValue::NullValue);
+ m_engine->toScriptValue(str);
}
}
void tst_QJSValue::undefinedConstructorWithEngine()
{
newEngine();
+ QVariant var;
QBENCHMARK {
- QJSValue val(m_engine, QJSValue::UndefinedValue);
+ m_engine->toScriptValue(var);
}
}
@@ -331,7 +314,7 @@ void tst_QJSValue::call()
{
QFETCH(QString, code);
QJSValue fun = m_engine->evaluate(code);
- QVERIFY(fun.isFunction());
+ QVERIFY(fun.isCallable());
QBENCHMARK {
(void)fun.call();
}
@@ -349,9 +332,9 @@ void tst_QJSValue::construct()
{
QFETCH(QString, code);
QJSValue fun = m_engine->evaluate(code);
- QVERIFY(fun.isFunction());
+ QVERIFY(fun.isCallable());
QBENCHMARK {
- (void)fun.construct();
+ (void)fun.callAsConstructor();
}
}
@@ -391,19 +374,6 @@ void tst_QJSValue::data_noData()
}
#endif
-void tst_QJSValue::engine_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::engine()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.engine();
- }
-}
-
void tst_QJSValue::equalsSelf_data()
{
defineStandardTestValues();
@@ -445,17 +415,6 @@ void tst_QJSValue::strictlyEqualsSelf()
}
}
-void tst_QJSValue::instanceOf()
-{
- newEngine();
- QJSValue arrayCtor = m_engine->globalObject().property("Array");
- QJSValue array = arrayCtor.construct();
- QVERIFY(array.instanceOf(arrayCtor));
- QBENCHMARK {
- array.instanceOf(arrayCtor);
- }
-}
-
void tst_QJSValue::isArray_data()
{
defineStandardTestValues();
@@ -508,16 +467,16 @@ void tst_QJSValue::isError()
}
}
-void tst_QJSValue::isFunction_data()
+void tst_QJSValue::isCallable_data()
{
defineStandardTestValues();
}
-void tst_QJSValue::isFunction()
+void tst_QJSValue::isCallable()
{
QFETCH(QJSValue, val);
QBENCHMARK {
- val.isFunction();
+ val.isCallable();
}
}
@@ -627,19 +586,6 @@ void tst_QJSValue::isUndefined()
}
}
-void tst_QJSValue::isValid_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::isValid()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.isValid();
- }
-}
-
void tst_QJSValue::isVariant_data()
{
defineStandardTestValues();
@@ -679,29 +625,16 @@ void tst_QJSValue::toDateTime()
}
}
-void tst_QJSValue::toInt32_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::toInt32()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.toInt32();
- }
-}
-
-void tst_QJSValue::toInteger_data()
+void tst_QJSValue::toInt_data()
{
defineStandardTestValues();
}
-void tst_QJSValue::toInteger()
+void tst_QJSValue::toInt()
{
QFETCH(QJSValue, val);
QBENCHMARK {
- val.toInteger();
+ val.toInt();
}
}
@@ -727,7 +660,7 @@ void tst_QJSValue::toRegExp()
{
QFETCH(QJSValue, val);
QBENCHMARK {
- val.toRegExp();
+ qjsvalue_cast<QRegExp>(val);
}
}
@@ -772,29 +705,16 @@ void tst_QJSValue::toQObject()
}
}
-void tst_QJSValue::toUInt16_data()
-{
- defineStandardTestValues();
-}
-
-void tst_QJSValue::toUInt16()
-{
- QFETCH(QJSValue, val);
- QBENCHMARK {
- val.toUInt16();
- }
-}
-
-void tst_QJSValue::toUInt32_data()
+void tst_QJSValue::toUInt_data()
{
defineStandardTestValues();
}
-void tst_QJSValue::toUInt32()
+void tst_QJSValue::toUInt()
{
QFETCH(QJSValue, val);
QBENCHMARK {
- val.toUInt32();
+ val.toUInt();
}
}
@@ -869,9 +789,9 @@ void tst_QJSValue::setProperty_data()
QTest::addColumn<QString>("propertyName");
QTest::addColumn<QJSValue>("val");
QTest::newRow("foo") << QString::fromLatin1("foo") << QJSValue(123);
- QTest::newRow("bar") << QString::fromLatin1("bar") << QJSValue(m_engine, 123);
+ QTest::newRow("bar") << QString::fromLatin1("bar") << m_engine->toScriptValue(123);
QTest::newRow("baz") << QString::fromLatin1("baz") << QJSValue();
- QTest::newRow("toString") << QString::fromLatin1("toString") << QJSValue(m_engine, true);
+ QTest::newRow("toString") << QString::fromLatin1("toString") << m_engine->toScriptValue(true);
}
void tst_QJSValue::setProperty()
@@ -1042,7 +962,7 @@ void tst_QJSValue::defineStandardTestValues()
#if 0 // no qmetaobject
QTest::newRow("qmetaobject") << m_engine->newQMetaObject(&QJSEngine::staticMetaObject);
#endif
- QTest::newRow("variant") << m_engine->newVariant(123);
+ QTest::newRow("variant") << m_engine->toScriptValue(QPoint(10, 20));
#if 0 // no classess
QTest::newRow("qscriptclassobject") << m_engine->newObject(new QJSClass(m_engine));
#endif