increase code coverage

This commit is contained in:
Connor Skees 2022-12-29 17:56:22 -05:00
parent 593f14e1c0
commit 753c4960ca
7 changed files with 84 additions and 1 deletions

View File

@ -54,7 +54,7 @@ pub(crate) trait StylesheetParser<'a>: BaseParser<'a> + Sized {
| None => Ok(()),
_ => {
self.expect_char(';')?;
Ok(())
unreachable!();
}
}
}

View File

@ -1972,6 +1972,11 @@ error!(
}",
"Error: complex selectors may not be extended."
);
error!(
extend_at_root_of_document,
"@extend a;",
"Error: @extend may only be used within style rules."
);
// todo: extend_loop (massive test)
// todo: extend tests in folders

View File

@ -208,3 +208,11 @@ fn member_import_precedence_top_level() {
&grass::from_string(input.to_string(), &grass::Options::default().fs(&fs)).expect(input)
);
}
error!(
after_style_rule,
r#"
a {}
@forward "foo";
"#,
"Error: @forward rules must be written before any other rules."
);

View File

@ -581,6 +581,42 @@ test!(
}",
""
);
test!(
query_is_identifier_and_not_parens,
"@media screen and not (foo) {
a {
color: red;
}
}",
"@media screen and not (foo) {\n a {\n color: red;\n }\n}\n"
);
test!(
query_is_identifier_identifier_and_parens,
"@media only screen and (foo) {
a {
color: red;
}
}",
"@media only screen and (foo) {\n a {\n color: red;\n }\n}\n"
);
test!(
query_is_paren_and_paren,
"@media (foo) and (bar) {
a {
color: red;
}
}",
"@media (foo) and (bar) {\n a {\n color: red;\n }\n}\n"
);
test!(
query_is_paren_or_paren,
"@media (foo) or (bar) {
a {
color: red;
}
}",
"@media (foo) or (bar) {\n a {\n color: red;\n }\n}\n"
);
error!(
media_query_has_quoted_closing_paren,
r#"@media ('a)'w) {

View File

@ -647,6 +647,24 @@ test!(
}"#,
".environment-locality {\n var: before;\n var: before;\n}\n"
);
test!(
parses_extend_inside_mixin_not_in_style_rule,
"@mixin foo {
@extend a;
}",
""
);
error!(
parses_extend_inside_content_block_not_in_style_rule,
"@mixin foo {
@content;
}
@include foo {
@extend a;
}",
"Error: @extend may only be used within style rules."
);
error!(
mixin_in_function,
"@function foo() {

View File

@ -157,6 +157,12 @@ error!(
"Error: Sass variables aren't allowed in plain CSS.",
grass::Options::default().input_syntax(InputSyntax::Css)
);
error!(
disallows_variable_decl,
"$bar: red;",
"Error: Sass variables aren't allowed in plain CSS.",
grass::Options::default().input_syntax(InputSyntax::Css)
);
error!(
disallows_parent_selector_expr,
"a {

View File

@ -93,6 +93,16 @@ a
"a {\n color: red;\n}\n",
grass::Options::default().input_syntax(InputSyntax::Sass)
);
test!(
style_rule_begins_with_plus,
r#"
a
+ b
color: red
"#,
"a + b {\n color: red;\n}\n",
grass::Options::default().input_syntax(InputSyntax::Sass)
);
error!(
multiline_comment_in_value_position,
r#"