summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptcontext
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-06-15 15:34:33 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-06-15 15:35:05 (GMT)
commit9d6069f32962128f737b83a4bf7d7e7309983023 (patch)
treed5c37af610ffceeb76ad9878a2039112be917193 /tests/auto/qscriptcontext
parentb8231cb61129964dfecaf862b6ef5fecb6753c01 (diff)
downloadQt-9d6069f32962128f737b83a4bf7d7e7309983023.zip
Qt-9d6069f32962128f737b83a4bf7d7e7309983023.tar.gz
Qt-9d6069f32962128f737b83a4bf7d7e7309983023.tar.bz2
add a bunch of qtscript autotests
Get that code coverage up.
Diffstat (limited to 'tests/auto/qscriptcontext')
-rw-r--r--tests/auto/qscriptcontext/tst_qscriptcontext.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
index bfcd6ee..e2eb8cf0 100644
--- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
+++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
@@ -72,6 +72,7 @@ private slots:
void scopeChain();
void pushAndPopScope();
void getSetActivationObject();
+ void toString();
};
tst_QScriptContext::tst_QScriptContext()
@@ -438,6 +439,7 @@ void tst_QScriptContext::pushAndPopContext()
QCOMPARE(ctx->isCalledAsConstructor(), false);
QCOMPARE(ctx->argumentCount(), 0);
QCOMPARE(ctx->argument(0).isUndefined(), true);
+ QVERIFY(!ctx->argument(-1).isValid());
QCOMPARE(ctx->argumentsObject().isObject(), true);
QCOMPARE(ctx->activationObject().isObject(), true);
QCOMPARE(ctx->callee().isValid(), false);
@@ -687,5 +689,21 @@ void tst_QScriptContext::getSetActivationObject()
}
}
+static QScriptValue parentContextToString(QScriptContext *ctx, QScriptEngine *)
+{
+ return ctx->parentContext()->toString();
+}
+
+void tst_QScriptContext::toString()
+{
+ QScriptEngine eng;
+ eng.globalObject().setProperty("parentContextToString", eng.newFunction(parentContextToString));
+ QScriptValue ret = eng.evaluate("function foo(first, second, third) {\n"
+ " return parentContextToString();\n"
+ "}; foo(1, 2, 3)", "script.qs");
+ QVERIFY(ret.isString());
+ QCOMPARE(ret.toString(), QString::fromLatin1("foo (first=1, second=2, third=3) at script.qs:2"));
+}
+
QTEST_MAIN(tst_QScriptContext)
#include "tst_qscriptcontext.moc"