aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-09-24 18:48:25 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-09-26 23:51:08 +0800
commit384a65f660b5eb030e9f4fd2c5edf144b1de4964 (patch)
tree331ef88f22077d87d067e158cc520fc270817e4c /test/libsolidity
parent2c860b7d7403fdec27442b617e9d01e610d06502 (diff)
downloaddexon-solidity-384a65f660b5eb030e9f4fd2c5edf144b1de4964.tar.gz
dexon-solidity-384a65f660b5eb030e9f4fd2c5edf144b1de4964.tar.zst
dexon-solidity-384a65f660b5eb030e9f4fd2c5edf144b1de4964.zip
Be more strict about values in the optimizer block in StandardJSON
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/StandardCompiler.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp
index d34bacda..1570a9d2 100644
--- a/test/libsolidity/StandardCompiler.cpp
+++ b/test/libsolidity/StandardCompiler.cpp
@@ -225,6 +225,71 @@ BOOST_AUTO_TEST_CASE(smoke_test)
BOOST_CHECK(containsAtMostWarnings(result));
}
+BOOST_AUTO_TEST_CASE(optimizer_enabled_not_boolean)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "settings": {
+ "optimizer": {
+ "enabled": "wrong"
+ }
+ },
+ "sources": {
+ "empty": {
+ "content": ""
+ }
+ }
+ }
+ )";
+ Json::Value result = compile(input);
+ BOOST_CHECK(containsError(result, "JSONError", "The \"enabled\" setting must be a boolean."));
+}
+
+BOOST_AUTO_TEST_CASE(optimizer_runs_not_a_number)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "settings": {
+ "optimizer": {
+ "enabled": true,
+ "runs": "not a number"
+ }
+ },
+ "sources": {
+ "empty": {
+ "content": ""
+ }
+ }
+ }
+ )";
+ Json::Value result = compile(input);
+ BOOST_CHECK(containsError(result, "JSONError", "The \"runs\" setting must be an unsigned number."));
+}
+
+BOOST_AUTO_TEST_CASE(optimizer_runs_not_an_unsigned_number)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "settings": {
+ "optimizer": {
+ "enabled": true,
+ "runs": -1
+ }
+ },
+ "sources": {
+ "empty": {
+ "content": ""
+ }
+ }
+ }
+ )";
+ Json::Value result = compile(input);
+ BOOST_CHECK(containsError(result, "JSONError", "The \"runs\" setting must be an unsigned number."));
+}
+
BOOST_AUTO_TEST_CASE(basic_compilation)
{
char const* input = R"(