summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk@theqtcompany.com>2016-05-24 12:19:26 +0200
committerhjk <hjk@theqtcompany.com>2016-05-24 13:09:19 +0000
commitfbc82d3f88a736710474a95614767646a24077b2 (patch)
tree4be56783c208d8335c9d7b0e8da20a4a4ef5ea87
parent98214c5a0fb2f5363ac92bf930d11b2fbb468902 (diff)
downloadqt-creator-fbc82d3f88a736710474a95614767646a24077b2.tar.gz
Debugger: Fix dumping of numeric QJsonValue inside arrays
Task-number: QTCREATORBUG-16313 Change-Id: I544e89fc964cd404652d8ea0c8df127e51235292 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--share/qtcreator/debugger/qttypes.py7
-rw-r--r--tests/auto/debugger/tst_dumpers.cpp23
-rw-r--r--tests/manual/debugger/simple/simple_test_app.cpp39
3 files changed, 68 insertions, 1 deletions
diff --git a/share/qtcreator/debugger/qttypes.py b/share/qtcreator/debugger/qttypes.py
index 774147cfac..b62e5bfe0d 100644
--- a/share/qtcreator/debugger/qttypes.py
+++ b/share/qtcreator/debugger/qttypes.py
@@ -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)")
diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp
index a1b9fac79c..b6b1524a1e 100644
--- a/tests/auto/debugger/tst_dumpers.cpp
+++ b/tests/auto/debugger/tst_dumpers.cpp
@@ -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)")
diff --git a/tests/manual/debugger/simple/simple_test_app.cpp b/tests/manual/debugger/simple/simple_test_app.cpp
index a1902e89e4..49ed7f510c 100644
--- a/tests/manual/debugger/simple/simple_test_app.cpp
+++ b/tests/manual/debugger/simple/simple_test_app.cpp
@@ -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();