Skip to content

Commit

Permalink
Add a test to check the size of PropertyDeclaration
Browse files Browse the repository at this point in the history
  • Loading branch information
canova authored and SimonSapin committed Feb 9, 2017
1 parent 9eaf96b commit 9204f2a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/unit/style/lib.rs
Expand Up @@ -32,6 +32,7 @@ mod owning_handle;
mod parsing;
mod properties;
mod rule_tree;
mod size_of;
mod str;
mod stylesheets;
mod stylist;
Expand Down
24 changes: 24 additions & 0 deletions 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::<PropertyDeclaration>();
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)
}
}

0 comments on commit 9204f2a

Please sign in to comment.