From 84328f0e2cd2c113cab285284cfc7611440a1dd7 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Tue, 23 Jun 2020 04:15:26 -0400 Subject: [PATCH] add remaining selector-unify tests --- src/selector/simple.rs | 4 --- tests/selector-unify.rs | 70 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/src/selector/simple.rs b/src/selector/simple.rs index bcb6a5d..2568468 100644 --- a/src/selector/simple.rs +++ b/src/selector/simple.rs @@ -418,9 +418,7 @@ pub(crate) struct Pseudo { impl PartialEq for Pseudo { fn eq(&self, other: &Pseudo) -> bool { self.name == other.name - && self.normalized_name == other.normalized_name && self.is_class == other.is_class - && self.is_syntactic_class == other.is_syntactic_class && self.argument == other.argument && self.selector == other.selector } @@ -431,9 +429,7 @@ impl Eq for Pseudo {} impl Hash for Pseudo { fn hash(&self, state: &mut H) { self.name.hash(state); - self.normalized_name.hash(state); self.is_class.hash(state); - self.is_syntactic_class.hash(state); self.argument.hash(state); self.selector.hash(state); } diff --git a/tests/selector-unify.rs b/tests/selector-unify.rs index c4fdcc9..6ddd176 100644 --- a/tests/selector-unify.rs +++ b/tests/selector-unify.rs @@ -600,3 +600,73 @@ error!( "a {\n color: selector-unify(\"c\", 1);\n}\n", "Error: $selector2: 1 is not a valid selector: it must be a string, a list of strings, or a list of lists of strings." ); +test!( + simple_pseudo_no_arg_class_same, + "a {\n color: selector-unify(\":c\", \":c\");\n}\n", + "a {\n color: :c;\n}\n" +); +test!( + simple_pseudo_no_arg_class_different, + "a {\n color: selector-unify(\":c\", \":d\");\n}\n", + "a {\n color: :c:d;\n}\n" +); +test!( + simple_pseudo_no_arg_element_same, + "a {\n color: selector-unify(\"::c\", \"::c\");\n}\n", + "a {\n color: ::c;\n}\n" +); +test!( + simple_pseudo_no_arg_element_different, + "a {\n color: inspect(selector-unify(\"::c\", \"::d\"));\n}\n", + "a {\n color: null;\n}\n" +); +test!( + simple_pseudo_no_arg_element_and_class_same_before, + "a {\n color: selector-unify(\":before\", \"::before\");\n}\n", + "a {\n color: :before;\n}\n" +); +test!( + simple_pseudo_no_arg_element_and_class_same_after, + "a {\n color: selector-unify(\":after\", \"::after\");\n}\n", + "a {\n color: :after;\n}\n" +); +test!( + simple_pseudo_no_arg_element_and_class_same_first_line, + "a {\n color: selector-unify(\":first-line\", \"::first-line\");\n}\n", + "a {\n color: :first-line;\n}\n" +); +test!( + simple_pseudo_no_arg_element_and_class_same_first_letter, + "a {\n color: selector-unify(\":first-letter\", \"::first-letter\");\n}\n", + "a {\n color: :first-letter;\n}\n" +); +test!( + simple_pseudo_arg_class_same, + "a {\n color: selector-unify(\":c(@#$)\", \":c(@#$)\");\n}\n", + "a {\n color: :c(@#$);\n}\n" +); +test!( + simple_pseudo_arg_class_different_arg, + "a {\n color: selector-unify(\":c(@#$)\", \":c(*&^)\");\n}\n", + "a {\n color: :c(@#$):c(*&^);\n}\n" +); +test!( + simple_pseudo_arg_element_same, + "a {\n color: selector-unify(\"::c(@#$)\", \"::c(@#$)\");\n}\n", + "a {\n color: ::c(@#$);\n}\n" +); +test!( + simple_pseudo_arg_element_different_arg, + "a {\n color: inspect(selector-unify(\"::c(@#$)\", \"::c(*&^)\"));\n}\n", + "a {\n color: null;\n}\n" +); +test!( + simple_pseudo_arg_matches_same_selector_arg, + "a {\n color: selector-unify(\":matches(.c)\", \":matches(.c)\");\n}\n", + "a {\n color: :matches(.c);\n}\n" +); +test!( + simple_pseudo_arg_matches_different_selector_arg, + "a {\n color: selector-unify(\":matches(.c)\", \":matches(.d)\");\n}\n", + "a {\n color: :matches(.c):matches(.d);\n}\n" +);