mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Some more tests.
This commit is contained in:
		
							parent
							
								
									7ea3d950d7
								
							
						
					
					
						commit
						e6b6e27bd7
					
				| @ -6710,6 +6710,31 @@ BOOST_AUTO_TEST_CASE(internal_library_function_bound) | ||||
| 	BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(2))); | ||||
| } | ||||
| 
 | ||||
| BOOST_AUTO_TEST_CASE(internal_library_function_return_var_size) | ||||
| { | ||||
| 	char const* sourceCode = R"( | ||||
| 		library L { | ||||
| 			struct S { uint[] data; } | ||||
| 			function f(S _s) internal returns (uint[]) { | ||||
| 				_s.data[3] = 2; | ||||
| 				return _s.data; | ||||
| 			} | ||||
| 		} | ||||
| 		contract C { | ||||
| 			using L for L.S; | ||||
| 			function f() returns (uint) { | ||||
| 				L.S memory x; | ||||
| 				x.data = new uint[](7); | ||||
| 				x.data[3] = 8; | ||||
| 				return x.f()[3]; | ||||
| 			} | ||||
| 		} | ||||
| 	)"; | ||||
| 	// This has to work without linking, because everything will be inlined.
 | ||||
| 	compileAndRun(sourceCode, 0, "C"); | ||||
| 	BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(2))); | ||||
| } | ||||
| 
 | ||||
| BOOST_AUTO_TEST_SUITE_END() | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -3257,6 +3257,20 @@ BOOST_AUTO_TEST_CASE(library_functions_do_not_have_value) | ||||
| 	BOOST_CHECK(!success(text)); | ||||
| } | ||||
| 
 | ||||
| BOOST_AUTO_TEST_CASE(library_instances_cannot_be_used) | ||||
| { | ||||
| 	char const* text = R"( | ||||
| 		library L { function l() {} } | ||||
| 		contract test { | ||||
| 			function f() { | ||||
| 				L x; | ||||
| 				x.l(); | ||||
| 			} | ||||
| 		} | ||||
| 	)"; | ||||
| 	BOOST_CHECK(!success(text)); | ||||
| } | ||||
| 
 | ||||
| BOOST_AUTO_TEST_CASE(invalid_fixed_type_long) | ||||
| { | ||||
| 	char const* text = R"( | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user