From 99ae3ae30a456a9bc0f6fd1261432801683ca58d Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Thu, 23 Apr 2020 19:44:20 -0400 Subject: [PATCH] test for multiline comments in subtraction --- src/atrule/if_rule.rs | 3 ++- src/utils/comment_whitespace.rs | 4 ++-- tests/subtraction.rs | 5 +++++ tests/unary.rs | 7 ++++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/atrule/if_rule.rs b/src/atrule/if_rule.rs index f08bcbb..c63ea12 100644 --- a/src/atrule/if_rule.rs +++ b/src/atrule/if_rule.rs @@ -8,7 +8,8 @@ use crate::error::SassResult; use crate::scope::Scope; use crate::selector::Selector; use crate::utils::{ - devour_whitespace, eat_ident, read_until_closing_curly_brace, read_until_open_curly_brace, devour_whitespace_or_comment + devour_whitespace, devour_whitespace_or_comment, eat_ident, read_until_closing_curly_brace, + read_until_open_curly_brace, }; use crate::value::Value; use crate::{Stmt, Token}; diff --git a/src/utils/comment_whitespace.rs b/src/utils/comment_whitespace.rs index 97ca64e..7e4f8e0 100644 --- a/src/utils/comment_whitespace.rs +++ b/src/utils/comment_whitespace.rs @@ -52,8 +52,8 @@ pub(crate) fn devour_whitespace_or_comment>( '/' => read_until_newline(toks), _ => { toks.reset_view(); - return Ok(found_whitespace) - }, + return Ok(found_whitespace); + } }; found_whitespace = true; continue; diff --git a/tests/subtraction.rs b/tests/subtraction.rs index 2d5ed03..de68079 100644 --- a/tests/subtraction.rs +++ b/tests/subtraction.rs @@ -204,3 +204,8 @@ test!( "a {\n plus-after-minus: 1 - + 2;\n}\n", "a {\n plus-after-minus: -1;\n}\n" ); +test!( + multiline_comments_between_operands, + "a {\n color: 1/**/-/**/1;\n}\n", + "a {\n color: 0;\n}\n" +); diff --git a/tests/unary.rs b/tests/unary.rs index d7bb646..541a8b8 100644 --- a/tests/unary.rs +++ b/tests/unary.rs @@ -17,10 +17,15 @@ test!( ); test!(unary_pos_color, "a {\n color: +\"foo\";\n}\n"); test!( - unary_pos_number, + unary_pos_number_unit, "a {\n color: +1px;\n}\n", "a {\n color: 1px;\n}\n" ); +test!( + unary_pos_number, + "a {\n color: +10;\n}\n", + "a {\n color: 10;\n}\n" +); test!( unary_pos_in_list, "a {\n color: bar,+ \"bar\" - foo;\n}\n",