summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptengine/tst_qscriptengine.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-24 07:54:07 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-24 07:57:20 (GMT)
commit351870317388ac7479b39015263f1db440cc6587 (patch)
tree002db88e8f3a1c52c4fa19431b2f8e13eae7c78d /tests/auto/qscriptengine/tst_qscriptengine.cpp
parentf737db46ba81ce0b15cd7e7b2060863c9973b26c (diff)
downloadQt-351870317388ac7479b39015263f1db440cc6587.zip
Qt-351870317388ac7479b39015263f1db440cc6587.tar.gz
Qt-351870317388ac7479b39015263f1db440cc6587.tar.bz2
QScriptValue: No need to create the activation object for call or construct
It is uneeded and add useless overhead
Diffstat (limited to 'tests/auto/qscriptengine/tst_qscriptengine.cpp')
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp32
1 files changed, 23 insertions, 9 deletions
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 85cee28..0c67987 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -1518,15 +1518,29 @@ static QScriptValue eval_nested(QScriptContext *ctx, QScriptEngine *eng)
void tst_QScriptEngine::nestedEvaluate()
{
QScriptEngine eng;
- eng.globalObject().setProperty("fun", eng.newFunction(eval_nested));
- QScriptValue result = eng.evaluate("o = { id:'foo'}; o.fun = fun; o.fun()");
- QCOMPARE(result.property("local_bar").toString(), QString("local"));
- QCOMPARE(result.property("thisObjectIdBefore").toString(), QString("foo"));
- QCOMPARE(result.property("thisObjectIdAfter").toString(), QString("foo"));
- QCOMPARE(result.property("evaluatedThisObjectId").toString(), QString("foo"));
- QScriptValue bar = eng.evaluate("bar");
- QVERIFY(bar.isError());
- QCOMPARE(bar.toString(), QString::fromLatin1("ReferenceError: Can't find variable: bar"));
+ QScriptValue fun = eng.newFunction(eval_nested);
+ eng.globalObject().setProperty("fun", fun);
+ {
+ QScriptValue result = eng.evaluate("o = { id:'foo'}; o.fun = fun; o.fun()");
+ QCOMPARE(result.property("local_bar").toString(), QString("local"));
+ QCOMPARE(result.property("thisObjectIdBefore").toString(), QString("foo"));
+ QCOMPARE(result.property("thisObjectIdAfter").toString(), QString("foo"));
+ QCOMPARE(result.property("evaluatedThisObjectId").toString(), QString("foo"));
+ QScriptValue bar = eng.evaluate("bar");
+ QVERIFY(bar.isError());
+ QCOMPARE(bar.toString(), QString::fromLatin1("ReferenceError: Can't find variable: bar"));
+ }
+
+ {
+ QScriptValue result = fun.call(eng.evaluate("p = { id:'foo' }") , QScriptValueList() );
+ QCOMPARE(result.property("local_bar").toString(), QString("local"));
+ QCOMPARE(result.property("thisObjectIdBefore").toString(), QString("foo"));
+ QCOMPARE(result.property("thisObjectIdAfter").toString(), QString("foo"));
+ QCOMPARE(result.property("evaluatedThisObjectId").toString(), QString("foo"));
+ QScriptValue bar = eng.evaluate("bar");
+ QVERIFY(bar.isError());
+ QCOMPARE(bar.toString(), QString::fromLatin1("ReferenceError: Can't find variable: bar"));
+ }
}
void tst_QScriptEngine::uncaughtException()