mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Added meaningful exception types.
This commit is contained in:
parent
de155c13ef
commit
35383f9b88
@ -26,6 +26,7 @@
|
||||
#include <libsolidity/Scanner.h>
|
||||
#include <libsolidity/Parser.h>
|
||||
#include <libsolidity/NameAndTypeResolver.h>
|
||||
#include <libsolidity/Exceptions.h>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
namespace dev {
|
||||
@ -60,7 +61,7 @@ BOOST_AUTO_TEST_CASE(double_stateVariable_declaration)
|
||||
" uint256 variable;\n"
|
||||
" uint128 variable;\n"
|
||||
"}\n";
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(text), std::exception);
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(text), DeclarationError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(double_function_declaration)
|
||||
@ -69,7 +70,7 @@ BOOST_AUTO_TEST_CASE(double_function_declaration)
|
||||
" function fun() { var x; }\n"
|
||||
" function fun() { var x; }\n"
|
||||
"}\n";
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(text), std::exception);
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(text), DeclarationError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(double_variable_declaration)
|
||||
@ -77,7 +78,7 @@ BOOST_AUTO_TEST_CASE(double_variable_declaration)
|
||||
char const* text = "contract test {\n"
|
||||
" function f() { uint256 x; if (true) { uint256 x; } }\n"
|
||||
"}\n";
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(text), std::exception);
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(text), DeclarationError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(name_shadowing)
|
||||
@ -104,7 +105,7 @@ BOOST_AUTO_TEST_CASE(undeclared_name)
|
||||
" uint256 variable;\n"
|
||||
" function f(uint256 arg) { f(notfound); }"
|
||||
"}\n";
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(text), std::exception);
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(text), DeclarationError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <libdevcore/Log.h>
|
||||
#include <libsolidity/Scanner.h>
|
||||
#include <libsolidity/Parser.h>
|
||||
#include <libsolidity/Exceptions.h>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
namespace dev {
|
||||
@ -54,8 +55,7 @@ BOOST_AUTO_TEST_CASE(missing_variable_name_in_declaration)
|
||||
char const* text = "contract test {\n"
|
||||
" uint256 ;\n"
|
||||
"}\n";
|
||||
cwarn << "The next error is expected.";
|
||||
BOOST_CHECK_THROW(parseText(text), std::exception);
|
||||
BOOST_CHECK_THROW(parseText(text), ParserError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(empty_function)
|
||||
|
Loading…
Reference in New Issue
Block a user