Centralize ParserContext for tests

To simplify adding additional data to `ParserContext`, this moves test usages to
a few shared locations, instead of being spread across many tests.

MozReview-Commit-ID: 1OahV797eq
This commit is contained in:
J. Ryan Stinnett 2017-04-13 14:53:59 +08:00
parent f7896fd80b
commit 0936dd24d0
27 changed files with 248 additions and 513 deletions

View file

@ -3,13 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::{Parser, ToCss};
use media_queries::CSSErrorReporterTest;
use selectors::parser::SelectorList;
use style::parser::ParserContext;
use style::selector_parser::{SelectorImpl, SelectorParser};
use style::stylesheets::{CssRuleType, Origin, Namespaces};
use style::stylesheets::{Origin, Namespaces};
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SelectorList<SelectorImpl>, ()> {
fn parse_selector(input: &mut Parser) -> Result<SelectorList<SelectorImpl>, ()> {
let mut ns = Namespaces::default();
ns.prefixes.insert("svg".into(), ns!(svg));
let parser = SelectorParser {
@ -21,8 +19,8 @@ fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SelectorList<Se
#[test]
fn test_selectors() {
assert_roundtrip_with_context!(parse, "div");
assert_roundtrip_with_context!(parse, "svg|circle");
assert_roundtrip_with_context!(parse, "p:before", "p::before");
assert_roundtrip_with_context!(parse, "[border = \"0\"]:-servo-nonzero-border ~ ::-servo-details-summary");
assert_roundtrip!(parse_selector, "div");
assert_roundtrip!(parse_selector, "svg|circle");
assert_roundtrip!(parse_selector, "p:before", "p::before");
assert_roundtrip!(parse_selector, "[border = \"0\"]:-servo-nonzero-border ~ ::-servo-details-summary");
}