Introduce a script::test module to expose the APIs needed for unit tests.

This commit is contained in:
Ms2ger 2016-06-08 11:55:47 +02:00
parent b843be4975
commit 86d59212fe
5 changed files with 68 additions and 22 deletions

View file

@ -2,25 +2,16 @@
* 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 script::dom::characterdata::CharacterData;
use script::dom::element::Element;
use script::dom::eventtarget::EventTarget;
use script::dom::htmldivelement::HTMLDivElement;
use script::dom::htmlelement::HTMLElement;
use script::dom::htmlspanelement::HTMLSpanElement;
use script::dom::node::Node;
use script::dom::text::Text;
use script::layout_wrapper::ServoThreadSafeLayoutNode;
use std::mem::size_of;
use script::test::size_of;
// Macro so that we can stringify type names
// I'd really prefer the tests themselves to be run at plugin time,
// however rustc::middle doesn't have access to the full type data
macro_rules! sizeof_checker (
($testname: ident, $t:ty, $known_size:expr) => (
($testname: ident, $t: ident, $known_size: expr) => (
#[test]
fn $testname() {
let new = size_of::<$t>();
let new = size_of::$t();
let old = $known_size;
if new < old {
panic!("Your changes have decreased the stack size of commonly used DOM struct {} from {} to {}. \