mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	[yul-phaser] Move stripWhitespace() from Program tests to Common
This commit is contained in:
		
							parent
							
								
									71dcbf9df5
								
							
						
					
					
						commit
						837ea96da7
					
				| @ -19,6 +19,8 @@ | ||||
| 
 | ||||
| #include <libyul/optimiser/Suite.h> | ||||
| 
 | ||||
| #include <regex> | ||||
| 
 | ||||
| using namespace std; | ||||
| using namespace solidity; | ||||
| using namespace solidity::yul; | ||||
| @ -32,3 +34,9 @@ map<string, size_t> phaser::test::enumerateOptmisationSteps() | ||||
| 
 | ||||
| 	return stepIndices; | ||||
| } | ||||
| 
 | ||||
| string phaser::test::stripWhitespace(string const& input) | ||||
| { | ||||
| 	regex whitespaceRegex("\\s+"); | ||||
| 	return regex_replace(input, whitespaceRegex, ""); | ||||
| } | ||||
|  | ||||
| @ -42,6 +42,11 @@ namespace solidity::phaser::test | ||||
| /// integers.
 | ||||
| std::map<std::string, size_t> enumerateOptmisationSteps(); | ||||
| 
 | ||||
| // STRING UTILITIES
 | ||||
| 
 | ||||
| /// Returns the input string with all the whitespace characters (spaces, line endings, etc.) removed.
 | ||||
| std::string stripWhitespace(std::string const& input); | ||||
| 
 | ||||
| // STATISTICAL UTILITIES
 | ||||
| 
 | ||||
| /// Calculates the mean value of a series of samples given in a vector.
 | ||||
|  | ||||
| @ -51,6 +51,20 @@ BOOST_AUTO_TEST_CASE(enumerateOptimisationSteps_should_assing_indices_to_all_ava | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| BOOST_AUTO_TEST_CASE(stripWhitespace_should_remove_all_whitespace_characters_from_a_string) | ||||
| { | ||||
| 	BOOST_TEST(stripWhitespace("") == ""); | ||||
| 	BOOST_TEST(stripWhitespace(" ") == ""); | ||||
| 	BOOST_TEST(stripWhitespace(" \n\t\v ") == ""); | ||||
| 
 | ||||
| 	BOOST_TEST(stripWhitespace("abc") == "abc"); | ||||
| 	BOOST_TEST(stripWhitespace(" abc") == "abc"); | ||||
| 	BOOST_TEST(stripWhitespace("abc ") == "abc"); | ||||
| 	BOOST_TEST(stripWhitespace(" a b c ") == "abc"); | ||||
| 	BOOST_TEST(stripWhitespace(" a b\tc\n") == "abc"); | ||||
| 	BOOST_TEST(stripWhitespace("   a   b \n\n  c \n\t\v") == "abc"); | ||||
| } | ||||
| 
 | ||||
| BOOST_AUTO_TEST_CASE(mean_should_calculate_statistical_mean) | ||||
| { | ||||
| 	BOOST_TEST(mean<int>({0}) == 0.0); | ||||
|  | ||||
| @ -15,6 +15,8 @@ | ||||
| 	along with solidity.  If not, see <http://www.gnu.org/licenses/>.
 | ||||
| */ | ||||
| 
 | ||||
| #include <test/yulPhaser/Common.h> | ||||
| 
 | ||||
| #include <tools/yulPhaser/Exceptions.h> | ||||
| #include <tools/yulPhaser/Program.h> | ||||
| 
 | ||||
| @ -30,7 +32,6 @@ | ||||
| #include <boost/test/unit_test.hpp> | ||||
| 
 | ||||
| #include <cassert> | ||||
| #include <regex> | ||||
| #include <string> | ||||
| 
 | ||||
| using namespace std; | ||||
| @ -51,12 +52,6 @@ namespace | ||||
| 		else | ||||
| 			return _block; | ||||
| 	} | ||||
| 
 | ||||
| 	string stripWhitespace(string const& input) | ||||
| 	{ | ||||
| 		regex whitespaceRegex("\\s+"); | ||||
| 		return regex_replace(input, whitespaceRegex, ""); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| namespace solidity::phaser::test | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user