aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-06-24 00:36:56 +0800
committerchriseth <chris@ethereum.org>2017-06-26 22:30:22 +0800
commitd2445dfdced2d4e1fccdd873963e02663c0116c1 (patch)
treef32669cd4d997672164500efdc3aa3d64449a0b6 /test
parent751ba701bca0fbcae6d74cfdc23a4ac4a1c3dfab (diff)
downloaddexon-solidity-d2445dfdced2d4e1fccdd873963e02663c0116c1.tar
dexon-solidity-d2445dfdced2d4e1fccdd873963e02663c0116c1.tar.gz
dexon-solidity-d2445dfdced2d4e1fccdd873963e02663c0116c1.tar.bz2
dexon-solidity-d2445dfdced2d4e1fccdd873963e02663c0116c1.tar.lz
dexon-solidity-d2445dfdced2d4e1fccdd873963e02663c0116c1.tar.xz
dexon-solidity-d2445dfdced2d4e1fccdd873963e02663c0116c1.tar.zst
dexon-solidity-d2445dfdced2d4e1fccdd873963e02663c0116c1.zip
Tests for comparison of non-comparable types.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index a6027812..0c56e585 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -554,6 +554,40 @@ BOOST_AUTO_TEST_CASE(comparison_bitop_precedence)
CHECK_SUCCESS(text);
}
+BOOST_AUTO_TEST_CASE(comparison_of_function_types)
+{
+ char const* text = R"(
+ contract C {
+ function f() returns (bool ret) {
+ return this.f < this.f;
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Operator < not compatible");
+ text = R"(
+ contract C {
+ function f() returns (bool ret) {
+ return f < f;
+ }
+ }
+ )";
+ CHECK_SUCCESS(text);
+}
+
+BOOST_AUTO_TEST_CASE(comparison_of_mapping_types)
+{
+ char const* text = R"(
+ contract C {
+ mapping(uint => uint) x;
+ function f() returns (bool ret) {
+ var y = x;
+ return x == y;
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Operator == not compatible");
+}
+
BOOST_AUTO_TEST_CASE(function_no_implementation)
{
ASTPointer<SourceUnit> sourceUnit;