aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/ASTJSON.cpp
diff options
context:
space:
mode:
authorErik Kundt <bitshift@posteo.org>2018-03-21 23:40:19 +0800
committerDaniel Kirchner <daniel@ekpyron.org>2018-04-13 03:14:50 +0800
commit8935c0dd2f47a20ed7cc2d1b6e11fa7cdd978b79 (patch)
tree671c1476992ceae819bab76f1a8f99f4050185a0 /test/libsolidity/ASTJSON.cpp
parent7054defdd6c202d0943c11cb87ac2748b9bdc62b (diff)
downloaddexon-solidity-8935c0dd2f47a20ed7cc2d1b6e11fa7cdd978b79.tar
dexon-solidity-8935c0dd2f47a20ed7cc2d1b6e11fa7cdd978b79.tar.gz
dexon-solidity-8935c0dd2f47a20ed7cc2d1b6e11fa7cdd978b79.tar.bz2
dexon-solidity-8935c0dd2f47a20ed7cc2d1b6e11fa7cdd978b79.tar.lz
dexon-solidity-8935c0dd2f47a20ed7cc2d1b6e11fa7cdd978b79.tar.xz
dexon-solidity-8935c0dd2f47a20ed7cc2d1b6e11fa7cdd978b79.tar.zst
dexon-solidity-8935c0dd2f47a20ed7cc2d1b6e11fa7cdd978b79.zip
Uses short string representation of TypePointer
Diffstat (limited to 'test/libsolidity/ASTJSON.cpp')
-rw-r--r--test/libsolidity/ASTJSON.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp
index b44dd331..b585d13f 100644
--- a/test/libsolidity/ASTJSON.cpp
+++ b/test/libsolidity/ASTJSON.cpp
@@ -181,6 +181,36 @@ BOOST_AUTO_TEST_CASE(array_type_name)
BOOST_CHECK_EQUAL(array["src"], "13:6:1");
}
+BOOST_AUTO_TEST_CASE(short_type_name)
+{
+ CompilerStack c;
+ c.addSource("a", "contract c { function f() { uint[] memory x; } }");
+ c.setEVMVersion(dev::test::Options::get().evmVersion());
+ c.parseAndAnalyze();
+ map<string, unsigned> sourceIndices;
+ sourceIndices["a"] = 1;
+ Json::Value astJson = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
+ Json::Value varDecl = astJson["nodes"][0]["nodes"][0]["body"]["statements"][0]["declarations"][0];
+ BOOST_CHECK_EQUAL(varDecl["storageLocation"], "memory");
+ BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeIdentifier"], "t_array$_t_uint256_$dyn_memory_ptr");
+ BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeString"], "uint256[]");
+}
+
+BOOST_AUTO_TEST_CASE(short_type_name_ref)
+{
+ CompilerStack c;
+ c.addSource("a", "contract c { function f() { uint[][] memory rows; } }");
+ c.setEVMVersion(dev::test::Options::get().evmVersion());
+ c.parseAndAnalyze();
+ map<string, unsigned> sourceIndices;
+ sourceIndices["a"] = 1;
+ Json::Value astJson = ASTJsonConverter(false, sourceIndices).toJson(c.ast("a"));
+ Json::Value varDecl = astJson["nodes"][0]["nodes"][0]["body"]["statements"][0]["declarations"][0];
+ BOOST_CHECK_EQUAL(varDecl["storageLocation"], "memory");
+ BOOST_CHECK_EQUAL(varDecl["typeName"]["typeDescriptions"]["typeIdentifier"], "t_array$_t_array$_t_uint256_$dyn_storage_$dyn_storage_ptr");
+ BOOST_CHECK_EQUAL(varDecl["typeName"]["typeDescriptions"]["typeString"], "uint256[][]");
+}
+
BOOST_AUTO_TEST_CASE(placeholder_statement)
{
CompilerStack c;