diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-06-15 15:34:33 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-06-15 15:35:05 (GMT) |
commit | 9d6069f32962128f737b83a4bf7d7e7309983023 (patch) | |
tree | d5c37af610ffceeb76ad9878a2039112be917193 /tests/auto/qscriptable/tst_qscriptable.cpp | |
parent | b8231cb61129964dfecaf862b6ef5fecb6753c01 (diff) | |
download | Qt-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/qscriptable/tst_qscriptable.cpp')
-rw-r--r-- | tests/auto/qscriptable/tst_qscriptable.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/auto/qscriptable/tst_qscriptable.cpp b/tests/auto/qscriptable/tst_qscriptable.cpp index 5eabbee..1dd975a 100644 --- a/tests/auto/qscriptable/tst_qscriptable.cpp +++ b/tests/auto/qscriptable/tst_qscriptable.cpp @@ -49,7 +49,7 @@ //TESTED_CLASS= //TESTED_FILES= -class MyScriptable : public QObject, protected QScriptable +class MyScriptable : public QObject, public QScriptable { Q_OBJECT Q_PROPERTY(int baz READ baz WRITE setBaz) @@ -87,6 +87,7 @@ public slots: QObject *zab(); QObject *setZab(QObject *); QScriptValue getArguments(); + int getArgumentCount(); signals: void sig(int); @@ -128,6 +129,11 @@ QScriptValue MyScriptable::getArguments() return context()->argumentsObject(); } +int MyScriptable::getArgumentCount() +{ + return context()->argumentCount(); +} + void MyScriptable::foo() { m_lastEngine = engine(); @@ -224,6 +230,8 @@ void tst_QScriptable::cleanupTestCase() void tst_QScriptable::engine() { + QCOMPARE(m_scriptable.engine(), (QScriptEngine*)0); + QCOMPARE(m_scriptable.context(), (QScriptContext*)0); QCOMPARE(m_scriptable.lastEngine(), (QScriptEngine *)0); // reading property @@ -360,6 +368,14 @@ void tst_QScriptable::arguments() QVERIFY(args.property("1").strictlyEquals(QScriptValue(&m_engine, 20))); QVERIFY(args.property("2").strictlyEquals(QScriptValue(&m_engine, 30))); QVERIFY(args.property("3").strictlyEquals(QScriptValue(&m_engine, "hi"))); + + QScriptValue argc = m_engine.evaluate("scriptable.getArgumentCount(1, 2, 3)"); + QVERIFY(argc.isNumber()); + QCOMPARE(argc.toInt32(), 3); + + QCOMPARE(m_scriptable.argumentCount(), -1); + QVERIFY(!m_scriptable.argument(-1).isValid()); + QVERIFY(!m_scriptable.argument(0).isValid()); } void tst_QScriptable::throwError() |