diff --git a/src/parse/stylesheet.rs b/src/parse/stylesheet.rs index 8e6808e..2f5e1e4 100644 --- a/src/parse/stylesheet.rs +++ b/src/parse/stylesheet.rs @@ -54,7 +54,7 @@ pub(crate) trait StylesheetParser<'a>: BaseParser<'a> + Sized { | None => Ok(()), _ => { self.expect_char(';')?; - Ok(()) + unreachable!(); } } } diff --git a/tests/extend.rs b/tests/extend.rs index 6765f9d..759a549 100644 --- a/tests/extend.rs +++ b/tests/extend.rs @@ -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 diff --git a/tests/forward.rs b/tests/forward.rs index d35b8fa..622f062 100644 --- a/tests/forward.rs +++ b/tests/forward.rs @@ -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." +); \ No newline at end of file diff --git a/tests/media.rs b/tests/media.rs index 59fa1da..7f2b3f6 100644 --- a/tests/media.rs +++ b/tests/media.rs @@ -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) { diff --git a/tests/mixins.rs b/tests/mixins.rs index 8625513..561488a 100644 --- a/tests/mixins.rs +++ b/tests/mixins.rs @@ -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() { diff --git a/tests/plain-css.rs b/tests/plain-css.rs index e792226..c3ad180 100644 --- a/tests/plain-css.rs +++ b/tests/plain-css.rs @@ -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 { diff --git a/tests/sass.rs b/tests/sass.rs index b1c0845..71be04f 100644 --- a/tests/sass.rs +++ b/tests/sass.rs @@ -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#"