diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-08-10 16:11:03 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-08-10 16:11:03 (GMT) |
commit | 8ad989ca2a9ccd9c7fb62a50197e87d59218fe20 (patch) | |
tree | d54667e9a7eca57a87ebb853bb2abcb0ab71dfe2 /tests/auto/qscriptcontext | |
parent | 336f0bf740842ab8defdbf482a7f043de95857e4 (diff) | |
download | Qt-8ad989ca2a9ccd9c7fb62a50197e87d59218fe20.zip Qt-8ad989ca2a9ccd9c7fb62a50197e87d59218fe20.tar.gz Qt-8ad989ca2a9ccd9c7fb62a50197e87d59218fe20.tar.bz2 |
make QScriptContext::setScope() fail for object created in other engine
Also fix some autotest failures, improve the descriptions of failures,
and make the tests run to completion.
Diffstat (limited to 'tests/auto/qscriptcontext')
-rw-r--r-- | tests/auto/qscriptcontext/tst_qscriptcontext.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp index 1bc375a..8dd2fc7 100644 --- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp +++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp @@ -575,8 +575,8 @@ void tst_QScriptContext::scopeChain() QScriptEngine eng; { QScriptValueList ret = eng.currentContext()->scopeChain(); - QEXPECT_FAIL("", "", Continue); - QCOMPARE(ret.size(), 0); // we aren't evaluating code + QCOMPARE(ret.size(), 1); + QVERIFY(ret.at(0).strictlyEquals(eng.globalObject())); } { eng.globalObject().setProperty("getScopeChain", eng.newFunction(getScopeChain)); @@ -587,7 +587,7 @@ void tst_QScriptContext::scopeChain() { eng.evaluate("function foo() { function bar() { return getScopeChain(); } return bar() }"); QScriptValueList ret = qscriptvalue_cast<QScriptValueList>(eng.evaluate("foo()")); - QEXPECT_FAIL("", "", Abort); + QEXPECT_FAIL("", "Number of items in returned scope chain is incorrect", Abort); QCOMPARE(ret.size(), 3); QVERIFY(ret.at(2).strictlyEquals(eng.globalObject())); QCOMPARE(ret.at(1).toString(), QString::fromLatin1("activation")); @@ -618,16 +618,18 @@ void tst_QScriptContext::pushAndPopScope() { QScriptEngine eng; QScriptContext *ctx = eng.currentContext(); - QEXPECT_FAIL("", "", Abort); - QVERIFY(ctx->scopeChain().isEmpty()); + QCOMPARE(ctx->scopeChain().size(), 1); + QVERIFY(ctx->scopeChain().at(0).strictlyEquals(eng.globalObject())); QScriptValue obj = eng.newObject(); ctx->pushScope(obj); - QCOMPARE(ctx->scopeChain().size(), 1); + QCOMPARE(ctx->scopeChain().size(), 2); QVERIFY(ctx->scopeChain().at(0).strictlyEquals(obj)); + QVERIFY(ctx->scopeChain().at(1).strictlyEquals(eng.globalObject())); QVERIFY(ctx->popScope().strictlyEquals(obj)); - QVERIFY(ctx->scopeChain().isEmpty()); + QCOMPARE(ctx->scopeChain().size(), 1); + QVERIFY(ctx->scopeChain().at(0).strictlyEquals(eng.globalObject())); { QScriptValue ret = eng.evaluate("x"); @@ -665,11 +667,14 @@ void tst_QScriptContext::pushAndPopScope() ctx->pushScope(QScriptValue()); QCOMPARE(ctx->scopeChain().size(), 1); + qWarning("Popping the top-level scope causes crash"); +#if 0 QVERIFY(ctx->popScope().strictlyEquals(eng.globalObject())); QVERIFY(ctx->scopeChain().isEmpty()); +#endif ctx->pushScope(obj); - QCOMPARE(ctx->scopeChain().size(), 1); + QCOMPARE(ctx->scopeChain().size(), 2); QVERIFY(ctx->scopeChain().at(0).strictlyEquals(obj)); QVERIFY(!obj.property("foo").isValid()); eng.evaluate("function foo() {}"); @@ -683,8 +688,10 @@ void tst_QScriptContext::pushAndPopScope() ctx->pushScope(obj2); QVERIFY(ctx->popScope().strictlyEquals(obj)); + QEXPECT_FAIL("", "This should work once the above crash issue has been fixed", Continue); QVERIFY(ctx->scopeChain().isEmpty()); + QSKIP("Crashes", SkipAll); QVERIFY(!ctx->popScope().isValid()); } |