aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/ASTJSON.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-09-06 18:25:04 +0800
committerGitHub <noreply@github.com>2016-09-06 18:25:04 +0800
commit171c74843bb231c4663ec0fe7f4252ac03266f53 (patch)
treece79c2ec2342ec658f625c8e5bf4cc3b80957308 /test/libsolidity/ASTJSON.cpp
parent3713cee49d65fd0dee508a4371147c4769367bfa (diff)
parent43c28c1ede33a80b6c259988dde6059f493a41a9 (diff)
downloaddexon-solidity-171c74843bb231c4663ec0fe7f4252ac03266f53.tar
dexon-solidity-171c74843bb231c4663ec0fe7f4252ac03266f53.tar.gz
dexon-solidity-171c74843bb231c4663ec0fe7f4252ac03266f53.tar.bz2
dexon-solidity-171c74843bb231c4663ec0fe7f4252ac03266f53.tar.lz
dexon-solidity-171c74843bb231c4663ec0fe7f4252ac03266f53.tar.xz
dexon-solidity-171c74843bb231c4663ec0fe7f4252ac03266f53.tar.zst
dexon-solidity-171c74843bb231c4663ec0fe7f4252ac03266f53.zip
Merge pull request #995 from chriseth/fixutf8astjson
Do not emit non-utf8 strings for ast json.
Diffstat (limited to 'test/libsolidity/ASTJSON.cpp')
-rw-r--r--test/libsolidity/ASTJSON.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp
index 882496d9..a0fc5dd7 100644
--- a/test/libsolidity/ASTJSON.cpp
+++ b/test/libsolidity/ASTJSON.cpp
@@ -195,6 +195,22 @@ BOOST_AUTO_TEST_CASE(placeholder_statement)
BOOST_CHECK_EQUAL(placeholder["src"], "26:1:1");
}
+BOOST_AUTO_TEST_CASE(non_utf8)
+{
+ CompilerStack c;
+ c.addSource("a", "contract C { function f() { var x = hex\"ff\"; } }");
+ c.parse();
+ map<string, unsigned> sourceIndices;
+ sourceIndices["a"] = 1;
+ Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json();
+ Json::Value literal = astJson["children"][0]["children"][0]["children"][2]["children"][0]["children"][1];
+ BOOST_CHECK_EQUAL(literal["name"], "Literal");
+ BOOST_CHECK_EQUAL(literal["attributes"]["hexvalue"], "ff");
+ BOOST_CHECK_EQUAL(literal["attributes"]["token"], Json::nullValue);
+ BOOST_CHECK_EQUAL(literal["attributes"]["value"], Json::nullValue);
+ BOOST_CHECK(literal["attributes"]["type"].asString().find("invalid") != string::npos);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}