Commit fbc82d3f authored by hjk's avatar hjk

Debugger: Fix dumping of numeric QJsonValue inside arrays

Task-number: QTCREATORBUG-16313
Change-Id: I544e89fc964cd404652d8ea0c8df127e51235292
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent 98214c5a
......@@ -2645,7 +2645,10 @@ def qdumpHelper__QJsonValue(d, data, base, pv):
if t == 2:
d.putType("QJsonValue (Number)")
if latinOrIntValue:
d.putValue(v)
w = toInteger(v)
if w >= 0x4000000:
w -= 0x8000000
d.putValue(w)
else:
data = base + v;
d.putValue(d.extractBlob(data, 8).extractDouble())
......@@ -2746,10 +2749,12 @@ def qdump__QJsonValue(d, value):
d.putType("QJsonValue (Bool)")
v = toInteger(value["b"])
d.putValue("true" if v else "false")
d.putNumChild(0)
return
if t == 2:
d.putType("QJsonValue (Number)")
d.putValue(value["dbl"])
d.putNumChild(0)
return
if t == 3:
d.putType("QJsonValue (String)")
......
......@@ -5989,6 +5989,18 @@ void tst_Dumpers::dumper_data()
"b.append(a);\n"
"b.append(QJsonValue(2));\n"
"\n"
"QJsonArray c;\n"
"for (unsigned int i = 0; i < 32; ++i) {\n"
" c.append(QJsonValue(qint64(1u << i) - 1));\n"
" c.append(QJsonValue(qint64(1u << i)));\n"
" c.append(QJsonValue(qint64(1u << i) + 1));\n"
"}\n"
"for (unsigned int i = 0; i < 32; ++i) {\n"
" c.append(QJsonValue(-qint64(1u << i) + 1));\n"
" c.append(QJsonValue(-qint64(1u << i)));\n"
" c.append(QJsonValue(-qint64(1u << i) - 1));\n"
"}\n"
"\n"
"unused(&ob,&b,&a);\n")
+ Cxx11Profile()
+ Check("a", "<6 items>", "@QJsonArray")
......@@ -6013,6 +6025,17 @@ void tst_Dumpers::dumper_data()
+ Check("b.1.4", "[4]", "true", "QJsonValue (Bool)")
+ Check("b.1.5", "[5]", "<5 items>", "QJsonValue (Object)")
+ Check("b.2", "[2]", "2", "QJsonValue (Number)")
+ Check("c", "c", "<192 items>", "@QJsonArray")
+ Check("c.0", "[0]", "0.0", "QJsonValue (Number)")
+ Check("c.1", "[1]", "1", "QJsonValue (Number)")
+ Check("c.78", "[78]", "67108863", "QJsonValue (Number)")
+ Check("c.79", "[79]", "67108864.0", "QJsonValue (Number)")
+ Check("c.94", "[94]", "2147483648.0", "QJsonValue (Number)")
+ Check("c.95", "[95]", "2147483649.0", "QJsonValue (Number)")
+ Check("c.96", "[96]", "0.0", "QJsonValue (Number)")
+ Check("c.97", "[97]", "-1", "QJsonValue (Number)")
+ Check("c.174", "[174]", "-67108863", "QJsonValue (Number)")
+ Check("c.175", "[175]", "-67108864.0", "QJsonValue (Number)")
+ Check("ob", "ob", "<5 items>", "@QJsonObject")
+ Check("ob.0", "\"a\"", "1", "QJsonValue (Number)")
+ Check("ob.1", "\"bb\"", "2", "QJsonValue (Number)")
......
......@@ -185,6 +185,9 @@ void dummyStatement(...) {}
#include <QXmlAttributes>
#include <QHostAddress>
#include <QJsonArray>
#include <QJsonObject>
#include <QJsonValue>
#include <QNetworkRequest>
#include <array>
......@@ -6009,6 +6012,41 @@ namespace qscript {
} // namespace script
namespace qjson {
void testQJson()
{
QJsonObject obj {
{"-1", -1},
{"3", 3},
{"0x3fffff (4194303)", 4194303},
{"0x400000 (4194304)", 4194304},
{"0x800000 (8388608)", 8388608},
{"0x1000000 (16777216)", 16777216},
{"-0x3fffff (-4194303)", -4194303},
{"-0x400000 (-4194304)", -4194304},
{"-0x800000 (-8388608)", -8388608}
};
QJsonArray arr;
for (unsigned int i = 0; i < 32; ++i) {
arr.append(QJsonValue(qint64(1u << i) - 1));
arr.append(QJsonValue(qint64(1u << i)));
arr.append(QJsonValue(qint64(1u << i) + 1));
}
for (unsigned int i = 0; i < 32; ++i) {
arr.append(QJsonValue(-qint64(1u << i) + 1));
arr.append(QJsonValue(-qint64(1u << i)));
arr.append(QJsonValue(-qint64(1u << i) - 1));
}
BREAK_HERE;
// Check v -1 QJsonValue.
// Check obj "foo" -1 QJsonValue.
// Continue.
}
} // namespace json
namespace webkit {
void testWTFString()
......@@ -7182,6 +7220,7 @@ int main(int argc, char *argv[])
qregexp::testQRegExp();
qregion::testQRegion();
qscript::testQScript();
qjson::testQJson();
qset::testQSet();
qsharedpointer::testQSharedPointer();
qstack::testQStack();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment