ident addition chaining

This commit is contained in:
ConnorSkees 2020-03-01 07:42:12 -05:00
parent 547ac7415a
commit 286f67b984
2 changed files with 8 additions and 2 deletions

View File

@ -48,7 +48,7 @@ impl Add for Value {
Self::Null => Value::Ident(c.to_string(), QuoteKind::None), Self::Null => Value::Ident(c.to_string(), QuoteKind::None),
_ => return Err(format!("Undefined operation \"{} + {}\".", c, other).into()), _ => return Err(format!("Undefined operation \"{} + {}\".", c, other).into()),
}, },
// Self::BinaryOp(..) => todo!(), Self::BinaryOp(..) | Self::Paren(..) => self.eval()?,
// Self::Paren(..) => todo!(), // Self::Paren(..) => todo!(),
Self::Ident(s1, quotes1) => match other { Self::Ident(s1, quotes1) => match other {
Self::Ident(s2, quotes2) => { Self::Ident(s2, quotes2) => {
@ -82,7 +82,8 @@ impl Add for Value {
}; };
Value::Ident(format!("{}{}", s1, c), quotes) Value::Ident(format!("{}{}", s1, c), quotes)
} }
_ => todo!(), Self::BinaryOp(..) | Self::Paren(..) => return Self::Ident(s1, quotes1) + other.eval()?,
Self::List(..) => todo!(),
}, },
_ => todo!(), _ => todo!(),
}) })

View File

@ -52,6 +52,11 @@ test!(
"a {\n color: (foo);\n}\n", "a {\n color: (foo);\n}\n",
"a {\n color: foo;\n}\n" "a {\n color: foo;\n}\n"
); );
test!(
chain_ident_addition,
"a {\n color: a + b + c + d + e + f;\n}\n",
"a {\n color: abcdef;\n}\n"
);
test!( test!(
removes_paren_around_space_list, removes_paren_around_space_list,
"a {\n color: (foo bar);\n}\n", "a {\n color: (foo bar);\n}\n",