diff options
Diffstat (limited to 'tests/auto/qml/qv4mm/tst_qv4mm.cpp')
-rw-r--r-- | tests/auto/qml/qv4mm/tst_qv4mm.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/tests/auto/qml/qv4mm/tst_qv4mm.cpp index 578a47d5fa..b57b716ed6 100644 --- a/tests/auto/qml/qv4mm/tst_qv4mm.cpp +++ b/tests/auto/qml/qv4mm/tst_qv4mm.cpp @@ -33,6 +33,7 @@ #include <private/qv4mm_p.h> #include <private/qv4qobjectwrapper_p.h> +#include <private/qjsvalue_p.h> #include "../../shared/util.h" @@ -46,6 +47,7 @@ private slots: void gcStats(); void multiWrappedQObjects(); void accessParentOnDestruction(); + void clearICParent(); }; void tst_qv4mm::gcStats() @@ -108,6 +110,30 @@ void tst_qv4mm::accessParentOnDestruction() QCOMPARE(obj->property("destructions").toInt(), 100); } +void tst_qv4mm::clearICParent() +{ + QJSEngine engine; + QJSValue value = engine.evaluate( + "(function() {\n" + " var test = Object.create(null);\n" + " for (var i = 0; i < 100; i++)\n" + " test[(\"key_\"+i)] = true;\n" + " for (var i = 0; i < 100; i++)\n" + " delete test[\"key_\" + i];\n" + " return test;\n" + "})();" + ); + engine.collectGarbage(); + QV4::Value *v4Value = QJSValuePrivate::getValue(&value); + QVERIFY(v4Value); + QV4::Heap::Object *v4Object = v4Value->toObject(engine.handle()); + QVERIFY(v4Object); + + // It should garbage collect the parents of the internalClass, + // as those aren't used anywhere else. + QCOMPARE(v4Object->internalClass->parent, nullptr); +} + QTEST_MAIN(tst_qv4mm) #include "tst_qv4mm.moc" |