From 439b67e019fe6a27dfb5c430803b7d569bc0107c Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 18 Jul 2017 20:21:21 +0100 Subject: Add test for compileJSONCallback --- test/libsolidity/JSONCompiler.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test/libsolidity/JSONCompiler.cpp b/test/libsolidity/JSONCompiler.cpp index a6a7bc5b..eb079744 100644 --- a/test/libsolidity/JSONCompiler.cpp +++ b/test/libsolidity/JSONCompiler.cpp @@ -36,6 +36,7 @@ extern "C" extern char const* version(); extern char const* license(); extern char const* compileJSONMulti(char const* _input, bool _optimize); +extern char const* compileJSONCallback(char const* _input, bool _optimize, void* _readCallback); } namespace dev @@ -48,9 +49,13 @@ namespace test namespace { -Json::Value compile(string const& _input) +Json::Value compileMulti(string const& _input, bool _callback) { - string output(compileJSONMulti(_input.c_str(), dev::test::Options::get().optimize)); + string output( + _callback ? + compileJSONCallback(_input.c_str(), dev::test::Options::get().optimize, NULL) : + compileJSONMulti(_input.c_str(), dev::test::Options::get().optimize) + ); Json::Value ret; BOOST_REQUIRE(Json::Reader().parse(output, ret, false)); return ret; @@ -81,8 +86,15 @@ BOOST_AUTO_TEST_CASE(basic_compilation) } } )"; - Json::Value result = compile(input); + Json::Value result = compileMulti(input, false); BOOST_CHECK(result.isObject()); + + // Compare with compileJSONCallback + BOOST_CHECK_EQUAL( + dev::jsonCompactPrint(result), + dev::jsonCompactPrint(compileMulti(input, true)) + ); + BOOST_CHECK(result["contracts"].isObject()); BOOST_CHECK(result["contracts"]["fileA:A"].isObject()); Json::Value contract = result["contracts"]["fileA:A"]; @@ -119,6 +131,7 @@ BOOST_AUTO_TEST_CASE(basic_compilation) "\"src\":\"0:14:0\"}],\"id\":2,\"name\":\"SourceUnit\",\"src\":\"0:14:0\"}" ); } + BOOST_AUTO_TEST_SUITE_END() } -- cgit