summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-10 19:38:06 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-10 19:38:06 (GMT)
commit71caeca273d4b76d9ca9b490bf444443d6875c54 (patch)
treeeed6ce92bdaf64e25cf9084f640447fd557ec874 /tests
parent9e002a6e98f9dac8bd2a5787ca92fa857ec8323f (diff)
downloadQt-71caeca273d4b76d9ca9b490bf444443d6875c54.zip
Qt-71caeca273d4b76d9ca9b490bf444443d6875c54.tar.gz
Qt-71caeca273d4b76d9ca9b490bf444443d6875c54.tar.bz2
more tests for the QScriptContext::argumentsObject
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qscriptcontext/tst_qscriptcontext.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
index 8dd2fc7..ca062ca 100644
--- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
+++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
@@ -218,11 +218,17 @@ void tst_QScriptContext::arguments()
{
QScriptValue result = eng.evaluate(prefix+"get_argumentsObject(123)");
+ eng.evaluate("function nestedArg(x,y,z) { var w = get_argumentsObject('ABC' , x+y+z); return w; }");
+ QScriptValue result2 = eng.evaluate("nestedArg(1, 'a', 2)");
QCOMPARE(result.isArray(), false);
QVERIFY(result.isObject());
QCOMPARE(result.property("length").toUInt32(), quint32(1));
QCOMPARE(result.property("0").isNumber(), true);
QCOMPARE(result.property("0").toNumber(), 123.0);
+ QVERIFY(result2.isObject());
+ QCOMPARE(result2.property("length").toUInt32(), quint32(2));
+ QCOMPARE(result2.property("0").toString(), QString::fromLatin1("ABC"));
+ QCOMPARE(result2.property("1").toString(), QString::fromLatin1("1a2"));
}
{
@@ -842,7 +848,7 @@ void tst_QScriptContext::calledAsConstructor()
}
-static QScriptValue argumentsObjectInNative_test1(QScriptContext *ctx, QScriptEngine *)
+static QScriptValue argumentsObjectInNative_test1(QScriptContext *ctx, QScriptEngine *eng)
{
#define VERIFY(statement) \
do {\
@@ -854,6 +860,10 @@ static QScriptValue argumentsObjectInNative_test1(QScriptContext *ctx, QScriptEn
VERIFY(obj.isObject());
VERIFY(obj.property(0).toUInt32() == 123);
VERIFY(obj.property(1).toString() == QString::fromLatin1("456"));
+
+ obj.setProperty(0, "abc");
+ VERIFY(eng->evaluate("arguments[0]").toString() == QString::fromLatin1("abc") );
+
return QString::fromLatin1("success");
#undef VERIFY
}
@@ -870,9 +880,6 @@ void tst_QScriptContext::argumentsObjectInNative()
QVERIFY(!eng.hasUncaughtException());
QCOMPARE(result.toString(), QString::fromLatin1("success"));
}
-
-
-
{
QScriptEngine eng;
QScriptValue fun = eng.newFunction(argumentsObjectInNative_test1);