diff --git a/tests/unit/style/lib.rs b/tests/unit/style/lib.rs index 26d242b26b8..e9b0133538f 100644 --- a/tests/unit/style/lib.rs +++ b/tests/unit/style/lib.rs @@ -32,6 +32,7 @@ mod owning_handle; mod parsing; mod properties; mod rule_tree; +mod size_of; mod str; mod stylesheets; mod stylist; diff --git a/tests/unit/style/size_of.rs b/tests/unit/style/size_of.rs new file mode 100644 index 00000000000..5da4463db30 --- /dev/null +++ b/tests/unit/style/size_of.rs @@ -0,0 +1,24 @@ +/* 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/. */ + +use std::mem::size_of; +use style::properties::PropertyDeclaration; + +#[test] +fn size_of_property_declaration() { + let old = 240; + let new = size_of::(); + if new < old { + panic!("Your changes have decreased the stack size of PropertyDeclaration enum from {} to {}. \ + Good work! Please update the size in tests/unit/style/size_of.rs.", + old, new) + } else if new > old { + panic!("Your changes have increased the stack size of PropertyDeclaration enum from {} to {}. \ + These enum is present in large quantities in the style, and increasing the size \ + may dramatically affect our memory footprint. Please consider using `boxed=\"True\"` in \ + the longhand If you feel that the increase is necessary, update to the new size in \ + tests/unit/style/size_of.rs.", + old, new) + } +}