mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Move size of tests to compile-time tests in the style crate
Same reasoning as the previous commit. Differential Revision: https://phabricator.services.mozilla.com/D146104
This commit is contained in:
parent
50d31686be
commit
f48b95e2e3
13 changed files with 53 additions and 49 deletions
|
@ -1,34 +0,0 @@
|
|||
/* 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 https://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!()
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue