summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-19 12:55:16 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-08-19 12:55:16 (GMT)
commit5bca43cca3ac90429e3f9263d0d7ea8c9eb164d4 (patch)
tree73c64b7cf83a5777d28dc9305390cd579f2c05ed /tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
parent8a9c91c77be0482e5f94f6976a4b5f59a64c4188 (diff)
downloadQt-5bca43cca3ac90429e3f9263d0d7ea8c9eb164d4.zip
Qt-5bca43cca3ac90429e3f9263d0d7ea8c9eb164d4.tar.gz
Qt-5bca43cca3ac90429e3f9263d0d7ea8c9eb164d4.tar.bz2
make QScriptEngine::isEvaluating() work for top-level evaluation
Since QScriptEngine::evaluate() doesn't create a new stack frame anymore, we need to use a dedicated variable to keep track of whether the engine is currently evaluating or not.
Diffstat (limited to 'tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp')
-rw-r--r--tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
index 0637297..7bfac62 100644
--- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
+++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
@@ -103,6 +103,7 @@ private slots:
void syntaxError();
void extension_invoctaion();
void extension();
+ void isEvaluatingInExtension();
private:
double m_testProperty;
@@ -2126,5 +2127,28 @@ void tst_QScriptEngineAgent::extension()
delete spy;
}
+class TestIsEvaluatingAgent : public QScriptEngineAgent
+{
+public:
+ TestIsEvaluatingAgent(QScriptEngine *engine)
+ : QScriptEngineAgent(engine), wasEvaluating(false)
+ { engine->setAgent(this); }
+ bool supportsExtension(Extension ext) const
+ { return ext == DebuggerInvocationRequest; }
+ QVariant extension(Extension, const QVariant &)
+ { wasEvaluating = engine()->isEvaluating(); return QVariant(); }
+
+ bool wasEvaluating;
+};
+
+void tst_QScriptEngineAgent::isEvaluatingInExtension()
+{
+ QScriptEngine eng;
+ TestIsEvaluatingAgent *spy = new TestIsEvaluatingAgent(&eng);
+ QVERIFY(!spy->wasEvaluating);
+ eng.evaluate("debugger");
+ QVERIFY(spy->wasEvaluating);
+}
+
QTEST_MAIN(tst_QScriptEngineAgent)
#include "tst_qscriptengineagent.moc"