diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-07-27 19:24:18 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-07-28 09:23:16 (GMT) |
commit | 9e9f896312edf68584bea5c9b70ec0f1205a11ab (patch) | |
tree | e456f43d6a0701460ca58f3322cc190269804306 /tests/auto/qscriptengine | |
parent | a10d523c5010e46b86a74d111342b1b26891cbdf (diff) | |
download | Qt-9e9f896312edf68584bea5c9b70ec0f1205a11ab.zip Qt-9e9f896312edf68584bea5c9b70ec0f1205a11ab.tar.gz Qt-9e9f896312edf68584bea5c9b70ec0f1205a11ab.tar.bz2 |
Make the 'arguments' object working when calling eval from native functions
The 'arguments' is not handled by JavaScriptCore for native function. We
have to do that manually
Reviewed-by: Kent Hansen
Diffstat (limited to 'tests/auto/qscriptengine')
-rw-r--r-- | tests/auto/qscriptengine/tst_qscriptengine.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index b52051f..768fe3c 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -2723,6 +2723,14 @@ void tst_QScriptEngine::errorConstructors() } } +static QScriptValue argumentsProperty_fun(QScriptContext *, QScriptEngine *eng) +{ + eng->evaluate("var a = arguments[0];"); + eng->evaluate("arguments[0] = 200;"); + return eng->evaluate("a + arguments[0]"); +} + + void tst_QScriptEngine::argumentsProperty() { { @@ -2751,6 +2759,15 @@ void tst_QScriptEngine::argumentsProperty() QEXPECT_FAIL("", "", Continue); QVERIFY(eng.evaluate("arguments").isUndefined()); } + + { + QScriptEngine eng; + QScriptValue fun = eng.newFunction(argumentsProperty_fun); + eng.globalObject().setProperty("fun", eng.newFunction(argumentsProperty_fun)); + QScriptValue result = eng.evaluate("fun(18)"); + QVERIFY(result.isNumber()); + QCOMPARE(result.toInt32(), 218); + } } void tst_QScriptEngine::numberClass() |