diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-07-09 09:40:52 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-07-09 09:40:52 (GMT) |
commit | d8cde61540b94e36a759d9d6a5adbb432f3625ea (patch) | |
tree | 3b580b65bffa2fa21b28d77729e52cf5e65770b7 /tests/auto/qscriptcontext | |
parent | bbe31f2e8842e032139fde0f58740cd181eeacd9 (diff) | |
download | Qt-d8cde61540b94e36a759d9d6a5adbb432f3625ea.zip Qt-d8cde61540b94e36a759d9d6a5adbb432f3625ea.tar.gz Qt-d8cde61540b94e36a759d9d6a5adbb432f3625ea.tar.bz2 |
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.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp index 8a64007..3fc60df 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); + } } } |