style: Smoke-test the dependency tracking logic.

MozReview-Commit-ID: J5HWdS1H49s
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
Emilio Cobos Álvarez 2017-04-12 22:12:12 +08:00
parent 9e33cd5643
commit a0c2bdf775
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 64 additions and 11 deletions

View file

@ -1164,7 +1164,7 @@ pub mod tests {
impl SelectorMethods for PseudoClass {
type Impl = DummySelectorImpl;
fn visit<V>(&self, visitor: &mut V) -> bool
fn visit<V>(&self, _visitor: &mut V) -> bool
where V: SelectorVisitor<Impl = Self::Impl> { true }
}
@ -1501,4 +1501,26 @@ pub mod tests {
specificity: specificity(1, 1, 0),
}))));
}
struct TestVisitor {
seen: Vec<String>,
}
impl SelectorVisitor for TestVisitor {
type Impl = DummySelectorImpl;
fn visit_simple_selector(&mut self, s: &SimpleSelector<DummySelectorImpl>) -> bool {
let mut dest = String::new();
s.to_css(&mut dest).unwrap();
self.seen.push(dest);
true
}
}
#[test]
fn visitor() {
let mut test_visitor = TestVisitor { seen: vec![], };
parse(":not(:hover) ~ label").unwrap().0[0].visit(&mut test_visitor);
assert!(test_visitor.seen.contains(&":hover".into()));
}
}