Add tests for variable scoping
This commit is contained in:
parent
eaf1e8eb96
commit
4114cc6f9d
15
src/main.rs
15
src/main.rs
@ -719,6 +719,11 @@ mod css_variables {
|
|||||||
"a {\n b {\n $c: red;\n }\n color: red;\n}\n",
|
"a {\n b {\n $c: red;\n }\n color: red;\n}\n",
|
||||||
"a {\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)]
|
#[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",
|
"@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"
|
"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"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,6 @@ impl Mixin {
|
|||||||
|
|
||||||
pub fn eval(&mut self, super_selector: &Selector, scope: &mut Scope) -> Vec<Stmt> {
|
pub fn eval(&mut self, super_selector: &Selector, scope: &mut Scope) -> Vec<Stmt> {
|
||||||
let mut stmts = Vec::new();
|
let mut stmts = Vec::new();
|
||||||
// dbg!(&scope);
|
|
||||||
while let Ok(expr) = eat_expr(&mut self.body, scope, super_selector) {
|
while let Ok(expr) = eat_expr(&mut self.body, scope, super_selector) {
|
||||||
match expr {
|
match expr {
|
||||||
Expr::Style(s) => stmts.push(Stmt::Style(s)),
|
Expr::Style(s) => stmts.push(Stmt::Style(s)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user