Skip to content

Commit

Permalink
Fix the unit tests to make use of local ToCss
Browse files Browse the repository at this point in the history
  • Loading branch information
wafflespeanut committed Nov 7, 2016
1 parent 6061985 commit 5ac1c11
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 15 deletions.
17 changes: 9 additions & 8 deletions tests/unit/style/parsing/basic_shape.rs
Expand Up @@ -5,6 +5,7 @@
use parsing::parse;
use style::parser::Parse;
use style::values::specified::basic_shape::*;
use style_traits::ToCss;

// Ensure that basic-shape sub-functions parse as both basic shapes
// and their individual components
Expand All @@ -21,14 +22,14 @@ macro_rules! assert_border_radius_values {
let input = parse(BorderRadius::parse, $input)
.expect(&format!("Failed parsing {} as border radius",
$input));
assert_eq!(::cssparser::ToCss::to_css_string(&input.top_left.0.width), $tlw);
assert_eq!(::cssparser::ToCss::to_css_string(&input.top_right.0.width), $trw);
assert_eq!(::cssparser::ToCss::to_css_string(&input.bottom_right.0.width), $brw);
assert_eq!(::cssparser::ToCss::to_css_string(&input.bottom_left.0.width), $blw);
assert_eq!(::cssparser::ToCss::to_css_string(&input.top_left.0.height), $tlh);
assert_eq!(::cssparser::ToCss::to_css_string(&input.top_right.0.height), $trh);
assert_eq!(::cssparser::ToCss::to_css_string(&input.bottom_right.0.height), $brh);
assert_eq!(::cssparser::ToCss::to_css_string(&input.bottom_left.0.height), $blh);
assert_eq!(::style_traits::ToCss::to_css_string(&input.top_left.0.width), $tlw);
assert_eq!(::style_traits::ToCss::to_css_string(&input.top_right.0.width), $trw);
assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_right.0.width), $brw);
assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_left.0.width), $blw);
assert_eq!(::style_traits::ToCss::to_css_string(&input.top_left.0.height), $tlh);
assert_eq!(::style_traits::ToCss::to_css_string(&input.top_right.0.height), $trh);
assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_right.0.height), $brh);
assert_eq!(::style_traits::ToCss::to_css_string(&input.bottom_left.0.height), $blh);
}
}

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/style/parsing/font.rs
Expand Up @@ -9,6 +9,7 @@ use style::properties::longhands::font_feature_settings;
use style::properties::longhands::font_feature_settings::computed_value;
use style::properties::longhands::font_feature_settings::computed_value::FeatureTagValue;
use style::stylesheets::Origin;
use style_traits::ToCss;
use url::Url;

#[test]
Expand Down Expand Up @@ -100,7 +101,7 @@ fn font_language_override_should_parse_properly() {
#[test]
#[should_panic]
fn font_language_override_should_fail_on_empty_str() {
use style::properties::longhands::font_language_override::{self, SpecifiedValue};
use style::properties::longhands::font_language_override;

parse_longhand!(font_language_override, "");
}
1 change: 1 addition & 0 deletions tests/unit/style/parsing/image.rs
Expand Up @@ -7,6 +7,7 @@ use media_queries::CSSErrorReporterTest;
use style::parser::ParserContext;
use style::stylesheets::Origin;
use style::values::specified::image::*;
use style_traits::ToCss;
use url::Url;

#[test]
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/style/parsing/mod.rs
Expand Up @@ -21,12 +21,12 @@ macro_rules! assert_roundtrip {
($fun:expr, $input:expr, $output:expr) => {
let parsed = $crate::parsing::parse($fun, $input)
.expect(&format!("Failed to parse {}", $input));
let serialized = ::cssparser::ToCss::to_css_string(&parsed);
let serialized = ToCss::to_css_string(&parsed);
assert_eq!(serialized, $output);

let re_parsed = $crate::parsing::parse($fun, &serialized)
.expect(&format!("Failed to parse serialization {}", $input));
let re_serialized = ::cssparser::ToCss::to_css_string(&re_parsed);
let re_serialized = ToCss::to_css_string(&re_parsed);
assert_eq!(serialized, re_serialized);
}
}
Expand All @@ -41,13 +41,13 @@ macro_rules! assert_roundtrip_with_context {
let mut parser = Parser::new($input);
let parsed = $fun(&context, &mut parser)
.expect(&format!("Failed to parse {}", $input));
let serialized = ::cssparser::ToCss::to_css_string(&parsed);
let serialized = ToCss::to_css_string(&parsed);
assert_eq!(serialized, $output);

let mut parser = Parser::new(&serialized);
let re_parsed = $fun(&context, &mut parser)
.expect(&format!("Failed to parse {}", $input));
let re_serialized = ::cssparser::ToCss::to_css_string(&re_parsed);
let re_serialized = ToCss::to_css_string(&re_parsed);
assert_eq!(serialized, re_serialized);
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/unit/style/parsing/position.rs
Expand Up @@ -4,6 +4,7 @@

use parsing::parse;
use style::values::specified::position::*;
use style_traits::ToCss;

#[test]
fn test_position() {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/style/parsing/selectors.rs
Expand Up @@ -2,7 +2,7 @@
* 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 cssparser::Parser;
use cssparser::{Parser, ToCss};
use selectors::parser::{Selector, ParserContext, parse_selector_list};
use style::selector_impl::TheSelectorImpl;

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/style/properties/serialization.rs
Expand Up @@ -2,7 +2,6 @@
* 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/. */

pub use cssparser::ToCss;
pub use std::sync::Arc;
pub use style::computed_values::display::T::inline_block;
pub use style::properties::{DeclaredValue, PropertyDeclaration, PropertyDeclarationBlock, Importance};
Expand All @@ -11,6 +10,7 @@ pub use style::values::specified::{LengthOrPercentage, LengthOrPercentageOrAuto,
pub use style::properties::longhands::outline_color::computed_value::T as ComputedColor;
pub use style::values::RGBA;
pub use style::values::specified::UrlExtraData;
pub use style_traits::ToCss;
pub use url::Url;

#[test]
Expand Down
1 change: 1 addition & 0 deletions tests/unit/stylo/lib.rs
Expand Up @@ -11,6 +11,7 @@ extern crate libc;
#[macro_use] extern crate log;
extern crate parking_lot;
extern crate style;
extern crate style_traits;
extern crate url;

mod sanity_checks;
Expand Down

0 comments on commit 5ac1c11

Please sign in to comment.