mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Tests for invalid cleanup and missing bool conversion code.
This commit is contained in:
		
							parent
							
								
									e3c5418543
								
							
						
					
					
						commit
						a09583a2a4
					
				| @ -6775,6 +6775,24 @@ BOOST_AUTO_TEST_CASE(iszero_bnot_correct) | |||||||
| 	BOOST_CHECK(callContractFunction("f()") == encodeArgs(true)); | 	BOOST_CHECK(callContractFunction("f()") == encodeArgs(true)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(cleanup_bytes_types) | ||||||
|  | { | ||||||
|  | 	// Checks that bytesXX types are properly cleaned before they are compared.
 | ||||||
|  | 	char const* sourceCode = R"( | ||||||
|  | 		contract C { | ||||||
|  | 			function f(bytes2 a, uint16 x) returns (uint) { | ||||||
|  | 				if (a != "ab") return 1; | ||||||
|  | 				if (x != 0x0102) return 2; | ||||||
|  | 				if (bytes3(x) != 0x0102) return 3; | ||||||
|  | 				return 0; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	)"; | ||||||
|  | 	compileAndRun(sourceCode, 0, "C"); | ||||||
|  | 	// We input longer data on purpose.
 | ||||||
|  | 	BOOST_CHECK(callContractFunction("f(bytes2,uint16)", string("abc"), u256(0x040102)) == encodeArgs(0)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -3683,6 +3683,18 @@ BOOST_AUTO_TEST_CASE(zero_handling) | |||||||
| 	BOOST_CHECK(success(text)); | 	BOOST_CHECK(success(text)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(missing_bool_conversion) | ||||||
|  | { | ||||||
|  | 	char const* text = R"( | ||||||
|  | 		contract test { | ||||||
|  | 			function b(uint a) { | ||||||
|  | 				bool(a == 1); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	)"; | ||||||
|  | 	BOOST_CHECK(success(text)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| BOOST_AUTO_TEST_CASE(integer_and_fixed_interaction) | BOOST_AUTO_TEST_CASE(integer_and_fixed_interaction) | ||||||
| { | { | ||||||
| 	char const* text = R"( | 	char const* text = R"( | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user