diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-07-29 13:22:44 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-07-29 14:23:11 (GMT) |
commit | 13a76f28e11d85353f799f31d2e0b75ffe2f7956 (patch) | |
tree | 3e5ca1c9e7fa76f6b88342197700f13a1b3b7ca0 /tests/auto/qscriptengine | |
parent | a8ea6dc6357049847eab361328a611b42f681c2a (diff) | |
download | Qt-13a76f28e11d85353f799f31d2e0b75ffe2f7956.zip Qt-13a76f28e11d85353f799f31d2e0b75ffe2f7956.tar.gz Qt-13a76f28e11d85353f799f31d2e0b75ffe2f7956.tar.bz2 |
test that vars are stored in custom global object
Diffstat (limited to 'tests/auto/qscriptengine')
-rw-r--r-- | tests/auto/qscriptengine/tst_qscriptengine.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index ab398e9..830cfc7 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -893,6 +893,35 @@ void tst_QScriptEngine::getSetGlobalObject() QVERIFY(eng.globalObject().strictlyEquals(obj)); QVERIFY(eng.currentContext()->thisObject().strictlyEquals(obj)); QVERIFY(eng.currentContext()->activationObject().strictlyEquals(obj)); + + QVERIFY(!obj.property("foo").isValid()); + eng.evaluate("var foo = 123"); + { + QScriptValue ret = obj.property("foo"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt32(), 123); + } + + QVERIFY(!obj.property("bar").isValid()); + eng.evaluate("bar = 456"); + { + QScriptValue ret = obj.property("bar"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt32(), 456); + } + + QVERIFY(!obj.property("baz").isValid()); + eng.evaluate("this['baz'] = 789"); + { + QScriptValue ret = obj.property("baz"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt32(), 789); + } + + { + QScriptValue ret = eng.evaluate("(function() { return this; })()"); + QVERIFY(ret.strictlyEquals(obj)); + } } void tst_QScriptEngine::checkSyntax_data() |