forked from mirrors/gecko-dev
		
	 4b702fa50d
			
		
	
	
		4b702fa50d
		
	
	
	
	
		
			
			First step of https://bugzilla.mozilla.org/show_bug.cgi?id=1364148 Source-Repo: https://github.com/servo/servo Source-Revision: ababebcced62d3a9bd09f002f1bf27b1b2691ea6 --HG-- rename : servo/components/script_plugins/Cargo.toml => servo/components/size_of_test/Cargo.toml extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 21e3290fdf61d275d2bef0b0703280d8a8f15937
		
			
				
	
	
		
			28 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
| /* This Source Code Form is subject to the terms of the Mozilla Public
 | |
|  * License, v. 2.0. If a copy of the MPL was not distributed with this
 | |
|  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 | |
| 
 | |
| #[macro_export]
 | |
| macro_rules! size_of_test {
 | |
|     ($testname: ident, $t: ty, $expected_size: expr) => {
 | |
|         #[test]
 | |
|         fn $testname() {
 | |
|             let new = ::std::mem::size_of::<$t>();
 | |
|             let old = $expected_size;
 | |
|             if new < old {
 | |
|                 panic!(
 | |
|                     "Your changes have decreased the stack size of {} from {} to {}. \
 | |
|                      Good work! Please update the expected size in {}.",
 | |
|                     stringify!($t), old, new, file!()
 | |
|                 )
 | |
|             } else if new > old {
 | |
|                 panic!(
 | |
|                     "Your changes have increased the stack size of {} from {} to {}. \
 | |
|                      Please consider choosing a design which avoids this increase. \
 | |
|                      If you feel that the increase is necessary, update the size in {}.",
 | |
|                     stringify!($t), old, new, file!()
 | |
|                 )
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |