summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-06-28 01:01:19 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-06-28 01:01:19 (GMT)
commitbb8fcc568f63ea1ba2107ebbba3845073f378d94 (patch)
tree83da43a476510c874c92110ccc72c18f7214e900 /tests/benchmarks
parent43697c982237f634f89ce661b1b363b8bfa383a7 (diff)
parent59c58576efd3ceff7add46a359fd99e56a2fb279 (diff)
downloadQt-bb8fcc568f63ea1ba2107ebbba3845073f378d94.zip
Qt-bb8fcc568f63ea1ba2107ebbba3845073f378d94.tar.gz
Qt-bb8fcc568f63ea1ba2107ebbba3845073f378d94.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt into 4.7
Conflicts: src/declarative/qml/qdeclarativeglobalscriptclass.cpp
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/script/qscriptengine/tst_qscriptengine.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/benchmarks/script/qscriptengine/tst_qscriptengine.cpp b/tests/benchmarks/script/qscriptengine/tst_qscriptengine.cpp
index 35e2f28..4610046 100644
--- a/tests/benchmarks/script/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/benchmarks/script/qscriptengine/tst_qscriptengine.cpp
@@ -42,6 +42,8 @@
#include <qtest.h>
#include <QtScript>
+#include <QtScript/private/qscriptdeclarativeclass_p.h>
+
//TESTED_FILES=
class tst_QScriptEngine : public QObject
@@ -74,6 +76,8 @@ private slots:
void nativeCall();
void translation_data();
void translation();
+ void readScopeProperty_data();
+ void readScopeProperty();
};
tst_QScriptEngine::tst_QScriptEngine()
@@ -288,5 +292,53 @@ void tst_QScriptEngine::translation()
}
}
+void tst_QScriptEngine::readScopeProperty_data()
+{
+ QTest::addColumn<bool>("staticScope");
+ QTest::addColumn<bool>("nestedScope");
+ QTest::newRow("single dynamic scope") << false << false;
+ QTest::newRow("single static scope") << true << false;
+ QTest::newRow("double dynamic scope") << false << true;
+ QTest::newRow("double static scope") << true << true;
+}
+
+void tst_QScriptEngine::readScopeProperty()
+{
+ QFETCH(bool, staticScope);
+ QFETCH(bool, nestedScope);
+
+ QScriptEngine engine;
+ QScriptContext *ctx = engine.pushContext();
+
+ QScriptValue scope;
+ if (staticScope)
+ scope = QScriptDeclarativeClass::newStaticScopeObject(&engine);
+ else
+ scope = engine.newObject();
+ scope.setProperty("foo", 123);
+ ctx->pushScope(scope);
+
+ if (nestedScope) {
+ QScriptValue scope2;
+ if (staticScope)
+ scope2 = QScriptDeclarativeClass::newStaticScopeObject(&engine);
+ else
+ scope2 = engine.newObject();
+ scope2.setProperty("bar", 456); // ensure a miss in inner scope
+ ctx->pushScope(scope2);
+ }
+
+ QScriptValue fun = engine.evaluate("(function() {\n"
+ " for (var i = 0; i < 10000; ++i) {\n"
+ " foo; foo; foo; foo; foo; foo; foo; foo;\n"
+ " }\n"
+ "})");
+ engine.popContext();
+ QVERIFY(fun.isFunction());
+ QBENCHMARK {
+ fun.call();
+ }
+}
+
QTEST_MAIN(tst_QScriptEngine)
#include "tst_qscriptengine.moc"