summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptcontext
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-07-09 11:40:52 +0200
committerKent Hansen <khansen@trolltech.com>2009-07-09 11:40:52 +0200
commitd8cde61540b94e36a759d9d6a5adbb432f3625ea (patch)
tree3b580b65bffa2fa21b28d77729e52cf5e65770b7 /tests/auto/qscriptcontext
parentbbe31f2e8842e032139fde0f58740cd181eeacd9 (diff)
make arguments object work for native functions
There's an off-by-one issue that we just work around for now.
Diffstat (limited to 'tests/auto/qscriptcontext')
-rw-r--r--tests/auto/qscriptcontext/tst_qscriptcontext.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
index 8a640075e1..3fc60df18b 100644
--- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
+++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
@@ -209,6 +209,10 @@ void tst_QScriptContext::arguments()
QScriptValue replacedLength(&eng, 456);
result.setProperty("length", replacedLength);
QVERIFY(result.property("length").equals(replacedLength));
+ result.setProperty("callee", QScriptValue());
+ QVERIFY(!result.property("callee").isValid());
+ result.setProperty("length", QScriptValue());
+ QVERIFY(!result.property("length").isValid());
}
{
@@ -231,6 +235,28 @@ void tst_QScriptContext::arguments()
QCOMPARE(result.property("2").toBoolean(), true);
QCOMPARE(result.property("3").isUndefined(), true);
}
+
+ // arguments object returned from script
+ {
+ QScriptValue result = eng.evaluate("(function() { return arguments; })(123)");
+ 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);
+ }
+
+ {
+ QScriptValue result = eng.evaluate("(function() { return arguments; })('ciao', null, true, undefined)");
+ QCOMPARE(result.isArray(), false);
+ QCOMPARE(result.property("length").toUInt32(), quint32(4));
+ QCOMPARE(result.property("0").isString(), true);
+ QCOMPARE(result.property("0").toString(), QString("ciao"));
+ QCOMPARE(result.property("1").isNull(), true);
+ QCOMPARE(result.property("2").isBoolean(), true);
+ QCOMPARE(result.property("2").toBoolean(), true);
+ QCOMPARE(result.property("3").isUndefined(), true);
+ }
}
}