diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-08-17 07:21:03 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-08-18 19:04:48 (GMT) |
commit | 94958cf9ff173830fbed66cf4b4158c51df1df7c (patch) | |
tree | d37e4a7e4dc24f46e48691bd0f71970593d4696b /tests | |
parent | 93f017401ce8bb73415f88955e928a90c6759fc0 (diff) | |
download | Qt-94958cf9ff173830fbed66cf4b4158c51df1df7c.zip Qt-94958cf9ff173830fbed66cf4b4158c51df1df7c.tar.gz Qt-94958cf9ff173830fbed66cf4b4158c51df1df7c.tar.bz2 |
Fix the QScriptContext::argumentsObject and QScriptContext::argument for js functions
On js functions, if the number of arguments is different from the number
of expected arguments, they are located in different place in the
stackframe. We need to call the JSC functions that take that into account.
Test is the backtrace test
Reviewed-by: Kent Hansen
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qscriptcontext/tst_qscriptcontext.cpp | 53 |
1 files changed, 48 insertions, 5 deletions
diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp index e5d26a3..a0c56ed 100644 --- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp +++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp @@ -565,11 +565,6 @@ void tst_QScriptContext::backtrace_data() QTest::addColumn<QStringList>("expectedbacktrace"); { - QStringList expected; - expected << "<native>(123) at -1" - << "foo([object Object], [object global]) at testfile:2" //### object instead of 'hello' - << "<global>() at testfile:4"; - QString source( "function foo() {\n" " return bt(123);\n" @@ -577,6 +572,12 @@ void tst_QScriptContext::backtrace_data() "foo('hello', { })\n" "var r = 0;"); + QStringList expected; + expected << "<native>(123) at -1" + << "foo('hello', [object Object]) at testfile:2" + << "<global>() at testfile:4"; + + QTest::newRow("simple") << source << expected; } @@ -639,6 +640,48 @@ void tst_QScriptContext::backtrace_data() QTest::newRow("closure") << source << expected; } + + { + QStringList expected; + QString source = QString( + "var o = new Object;\n" + "o.foo = function plop() {\n" + " return eval(\"%1\");\n" + "}\n" + "o.foo('hello', 456)\n" + ).arg("\\n \\n bt('hey'); \\n"); + + expected << "<native>('hey') at -1" + << "<eval>() at 3" + //### line number should be 3 but the line number information is not kept for eval call + << "plop('hello', 456) at testfile:-1" + << "<global>() at testfile:5"; + + QTest::newRow("eval in member") << source << expected; + } + + { + QString source( + "function foo(a) {\n" + " return bt(123);\n" + "}\n" + "function bar() {\n" + " var v = foo('arg', 4);\n" + " return v;\n" + "}\n" + "bar('hello', { });\n"); + + QStringList expected; + expected << "<native>(123) at -1" + << "foo(a = 'arg', 4) at testfile:2" + << "bar('hello', [object Object]) at testfile:5" + << "<global>() at testfile:8"; + + + QTest::newRow("two function") << source << expected; + } + + } |