aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Kundt <bitshift@posteo.org>2018-04-09 23:30:39 +0800
committerDaniel Kirchner <daniel@ekpyron.org>2018-04-13 03:14:50 +0800
commit6c656a93911d92bc8de7191087e9854eac4d69a4 (patch)
tree7fcc841426f2b1cf874c74136a028d7dce9e6463
parent34da3e634f564d4aa994801ff54a61c80b0f463b (diff)
downloaddexon-solidity-6c656a93911d92bc8de7191087e9854eac4d69a4.tar.gz
dexon-solidity-6c656a93911d92bc8de7191087e9854eac4d69a4.tar.zst
dexon-solidity-6c656a93911d92bc8de7191087e9854eac4d69a4.zip
Adds unit test that covers long typeDescription and renames suite.
-rw-r--r--test/libsolidity/ASTJSON.cpp28
-rw-r--r--test/libsolidity/ASTLegacyJSON.cpp (renamed from test/libsolidity/ASTJSONLegacy.cpp)2
2 files changed, 29 insertions, 1 deletions
diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp
index d22db18d..5d5b14e8 100644
--- a/test/libsolidity/ASTJSON.cpp
+++ b/test/libsolidity/ASTJSON.cpp
@@ -71,6 +71,34 @@ BOOST_AUTO_TEST_CASE(short_type_name_ref)
BOOST_CHECK_EQUAL(varDecl["typeName"]["typeDescriptions"]["typeString"], "uint256[][]");
}
+BOOST_AUTO_TEST_CASE(long_type_name_binary_operation)
+{
+ CompilerStack c;
+ c.addSource("a", "contract c { function f() public { uint a = 2 + 3; } }");
+ 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]["initialValue"]["commonType"];
+ BOOST_CHECK_EQUAL(varDecl["typeIdentifier"], "t_rational_5_by_1");
+ BOOST_CHECK_EQUAL(varDecl["typeString"], "int_const 5");
+}
+
+BOOST_AUTO_TEST_CASE(long_type_name_identifier)
+{
+ CompilerStack c;
+ c.addSource("a", "contract c { uint[] a; function f() public { uint[] b = a; } }");
+ 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"][1]["body"]["statements"][0]["initialValue"];
+ BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeIdentifier"], "t_array$_t_uint256_$dyn_storage");
+ BOOST_CHECK_EQUAL(varDecl["typeDescriptions"]["typeString"], "uint256[] storage ref");
+}
+
BOOST_AUTO_TEST_CASE(documentation)
{
CompilerStack c;
diff --git a/test/libsolidity/ASTJSONLegacy.cpp b/test/libsolidity/ASTLegacyJSON.cpp
index ebe1b007..13148682 100644
--- a/test/libsolidity/ASTJSONLegacy.cpp
+++ b/test/libsolidity/ASTLegacyJSON.cpp
@@ -39,7 +39,7 @@ namespace solidity
namespace test
{
-BOOST_AUTO_TEST_SUITE(SolidityASTJSONLegacy)
+BOOST_AUTO_TEST_SUITE(SolidityASTLegacyJSON)
BOOST_AUTO_TEST_CASE(smoke_test)
{