mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
Fix too many parens in @supports serialization.
This commit is contained in:
parent
dbc35f4360
commit
b5d9210f16
3 changed files with 49 additions and 11 deletions
|
@ -39,6 +39,25 @@ macro_rules! assert_roundtrip_with_context {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! assert_roundtrip {
|
||||
($fun:expr, $string:expr) => {
|
||||
assert_roundtrip!($fun, $string, $string);
|
||||
};
|
||||
($fun:expr,$input:expr, $output:expr) => {
|
||||
let mut parser = Parser::new($input);
|
||||
let parsed = $fun(&mut parser)
|
||||
.expect(&format!("Failed to parse {}", $input));
|
||||
let serialized = ToCss::to_css_string(&parsed);
|
||||
assert_eq!(serialized, $output);
|
||||
|
||||
let mut parser = Parser::new(&serialized);
|
||||
let re_parsed = $fun(&mut parser)
|
||||
.expect(&format!("Failed to parse serialization {}", $input));
|
||||
let re_serialized = ToCss::to_css_string(&re_parsed);
|
||||
assert_eq!(serialized, re_serialized);
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! parse_longhand {
|
||||
($name:ident, $s:expr) => {{
|
||||
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
|
||||
|
@ -58,3 +77,4 @@ mod inherited_text;
|
|||
mod mask;
|
||||
mod position;
|
||||
mod selectors;
|
||||
mod supports;
|
||||
|
|
14
tests/unit/style/parsing/supports.rs
Normal file
14
tests/unit/style/parsing/supports.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* 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 cssparser::Parser;
|
||||
use style::supports::SupportsCondition;
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[test]
|
||||
fn test_supports_condition() {
|
||||
assert_roundtrip!(SupportsCondition::parse, "(margin: 1px)");
|
||||
assert_roundtrip!(SupportsCondition::parse, "not (--be: to be)");
|
||||
assert_roundtrip!(SupportsCondition::parse, "(color: blue) and future-extension(4)");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue