diff options
Diffstat (limited to 'tests/auto/qscriptengine/tst_qscriptengine.cpp')
-rw-r--r-- | tests/auto/qscriptengine/tst_qscriptengine.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index b1b416c..514d29a 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -250,6 +250,7 @@ private slots: void stringListFromArrayWithEmptyElement(); void collectQObjectWithCachedWrapper_data(); void collectQObjectWithCachedWrapper(); + void pushContext_noInheritedScope(); }; tst_QScriptEngine::tst_QScriptEngine() @@ -6218,5 +6219,31 @@ void tst_QScriptEngine::collectQObjectWithCachedWrapper() QCOMPARE(ptr == 0, shouldBeCollected); } +// QTBUG-18188 +void tst_QScriptEngine::pushContext_noInheritedScope() +{ + QScriptEngine eng; + eng.globalObject().setProperty("foo", 123); + + QScriptContext *ctx1 = eng.pushContext(); + QCOMPARE(ctx1->scopeChain().size(), 2); + ctx1->activationObject().setProperty("foo", 456); + QCOMPARE(eng.evaluate("foo").toInt32(), 456); + + QScriptContext *ctx2 = eng.pushContext(); + // The parent context's scope should not be inherited. + QCOMPARE(ctx2->scopeChain().size(), 2); + QCOMPARE(eng.evaluate("foo").toInt32(), 123); + + ctx2->activationObject().setProperty("foo", 789); + QCOMPARE(eng.evaluate("foo").toInt32(), 789); + + eng.popContext(); + QCOMPARE(eng.evaluate("foo").toInt32(), 456); + + eng.popContext(); + QCOMPARE(eng.evaluate("foo").toInt32(), 123); +} + QTEST_MAIN(tst_QScriptEngine) #include "tst_qscriptengine.moc" |