summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-07-01 17:24:01 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-07-01 17:24:01 (GMT)
commit745ecfd8925716d962c97a4415881377faf6bdd5 (patch)
treec4f78b3bd143af52372064cd3ba5c0ae440813c5 /tests/benchmarks
parentbda164303570629e44185e8baa52908ced6da301 (diff)
parent8968c79c575755cdb52d5e615ed19e4529047464 (diff)
downloadQt-745ecfd8925716d962c97a4415881377faf6bdd5.zip
Qt-745ecfd8925716d962c97a4415881377faf6bdd5.tar.gz
Qt-745ecfd8925716d962c97a4415881377faf6bdd5.tar.bz2
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts: bin/syncqt src/gui/text/qtextlayout.cpp tools/assistant/tools/assistant/helpviewer_qwv.cpp tools/assistant/tools/assistant/helpviewer_qwv.h tools/configure/configureapp.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"