From 4114cc6f9d1ba9cd865e52d9a7b3634f24735628 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Fri, 17 Jan 2020 21:15:38 -0500 Subject: [PATCH] Add tests for variable scoping --- src/main.rs | 15 +++++++++++++++ src/mixin.rs | 1 - 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 72706c5..8335e6f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -719,6 +719,11 @@ mod css_variables { "a {\n b {\n $c: red;\n }\n color: red;\n}\n", "a {\n color: red;\n}\n" ); + test!( + variable_changes_through_new_ruleset, + "a {\n $c: red;\nb {\n $c: blue;\n }\n color: $c;\n}\n", + "a {\n color: blue;\n}\n" + ); } #[cfg(test)] @@ -1097,4 +1102,14 @@ mod css_mixins { "@mixin a {\n b {\n c {\n color: red;\n}\n}\n}\nd {\n @include a;\n}\n", "d b c {\n color: red;\n}\n" ); + test!( + mixin_removes_empty_ruleset, + "@mixin a {\n color:red; b {\n}\n}\nd {\n @include a;\n}\n", + "d {\n color: red;\n}\n" + ); + test!( + mixin_variable_scope_one_ruleset, + "@mixin a {\n $a: blue;\nb {\n $a: red;\n} color: $a\n}\nd {\n @include a;\n}\n", + "d {\n color: red;\n}\n" + ); } diff --git a/src/mixin.rs b/src/mixin.rs index 0f6b00e..a174808 100644 --- a/src/mixin.rs +++ b/src/mixin.rs @@ -41,7 +41,6 @@ impl Mixin { pub fn eval(&mut self, super_selector: &Selector, scope: &mut Scope) -> Vec { let mut stmts = Vec::new(); - // dbg!(&scope); while let Ok(expr) = eat_expr(&mut self.body, scope, super_selector) { match expr { Expr::Style(s) => stmts.push(Stmt::Style(s)),