Merge pull request #2583 from ethereum/soljson-license

Export license in jsonCompiler and add tests
This commit is contained in:
Alex Beregszaszi 2017-07-18 17:02:44 +02:00 committed by GitHub
commit 0eab808ece
3 changed files with 17 additions and 1 deletions

View File

@ -1,6 +1,7 @@
### 0.4.14 (unreleased)
Features:
* C API (``jsonCompiler``): Export the ``license`` method.
* Inline Assembly: Show useful error message if trying to access calldata variables.
* Inline Assembly: Support variable declaration without initial value (defaults to 0).
* Type Checker: Disallow value transfers to contracts without a payable fallback function.

View File

@ -18,7 +18,7 @@ else()
endif()
if (EMSCRIPTEN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s EXPORTED_FUNCTIONS='[\"_compileJSON\",\"_version\",\"_compileJSONMulti\",\"_compileJSONCallback\",\"_compileStandard\"]' -s RESERVED_FUNCTION_POINTERS=20")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s EXPORTED_FUNCTIONS='[\"_compileJSON\",\"_license\",\"_version\",\"_compileJSONMulti\",\"_compileJSONCallback\",\"_compileStandard\"]' -s RESERVED_FUNCTION_POINTERS=20")
add_executable(soljson jsonCompiler.cpp ${HEADERS})
eth_use(soljson REQUIRED Solidity::solidity)
else()

View File

@ -24,6 +24,7 @@
#include <regex>
#include <boost/test/unit_test.hpp>
#include <libdevcore/JSON.h>
#include <libsolidity/interface/Version.h>
#include "../Metadata.h"
#include "../TestHelper.h"
@ -32,6 +33,8 @@ using namespace std;
extern "C"
{
extern char const* version();
extern char const* license();
extern char const* compileJSONMulti(char const* _input, bool _optimize);
}
@ -57,6 +60,18 @@ Json::Value compile(string const& _input)
BOOST_AUTO_TEST_SUITE(JSONCompiler)
BOOST_AUTO_TEST_CASE(read_version)
{
string output(version());
BOOST_CHECK(output.find(VersionString) == 0);
}
BOOST_AUTO_TEST_CASE(read_license)
{
string output(license());
BOOST_CHECK(output.find("GNU GENERAL PUBLIC LICENSE") != string::npos);
}
BOOST_AUTO_TEST_CASE(basic_compilation)
{
char const* input = R"(