type-of(!important) returns 'string'
This commit is contained in:
parent
68d2bc7e17
commit
e6f2c26bc6
@ -24,6 +24,8 @@ pub(crate) enum Value {
|
|||||||
BinaryOp(Box<Value>, Op, Box<Value>),
|
BinaryOp(Box<Value>, Op, Box<Value>),
|
||||||
Paren(Box<Value>),
|
Paren(Box<Value>),
|
||||||
Ident(String, QuoteKind),
|
Ident(String, QuoteKind),
|
||||||
|
// Returned by `get-function()`
|
||||||
|
// Function(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Value {
|
impl Display for Value {
|
||||||
@ -109,7 +111,7 @@ impl Value {
|
|||||||
pub fn is_true(&self) -> SassResult<bool> {
|
pub fn is_true(&self) -> SassResult<bool> {
|
||||||
match self {
|
match self {
|
||||||
Value::Null | Value::False => Ok(false),
|
Value::Null | Value::False => Ok(false),
|
||||||
Self::BinaryOp(..) => self.clone().eval()?.is_true(),
|
Self::BinaryOp(..) | Self::Paren(..) | Self::UnaryOp(..) => self.clone().eval()?.is_true(),
|
||||||
_ => Ok(true),
|
_ => Ok(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,15 +125,14 @@ impl Value {
|
|||||||
|
|
||||||
pub fn kind(&self) -> SassResult<&'static str> {
|
pub fn kind(&self) -> SassResult<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
Value::Color(..) => Ok("color"),
|
Self::Color(..) => Ok("color"),
|
||||||
Value::Ident(..) => Ok("string"),
|
Self::Ident(..) | Self::Important => Ok("string"),
|
||||||
Value::Dimension(..) => Ok("number"),
|
Self::Dimension(..) => Ok("number"),
|
||||||
Value::List(..) => Ok("list"),
|
Self::List(..) => Ok("list"),
|
||||||
// Value::Function(..) => Ok("function"),
|
// Self::Function(..) => Ok("function"),
|
||||||
Value::True | Value::False => Ok("bool"),
|
Self::True | Self::False => Ok("bool"),
|
||||||
Value::Null => Ok("null"),
|
Self::Null => Ok("null"),
|
||||||
Value::BinaryOp(..) => self.clone().eval()?.kind(),
|
Self::BinaryOp(..) | Self::Paren(..) | Self::UnaryOp(..) => self.clone().eval()?.kind(),
|
||||||
_ => Ok("unknown"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,6 +139,11 @@ test!(
|
|||||||
"a {\n color: type-of(1 2 3)\n}\n",
|
"a {\n color: type-of(1 2 3)\n}\n",
|
||||||
"a {\n color: list;\n}\n"
|
"a {\n color: list;\n}\n"
|
||||||
);
|
);
|
||||||
|
test!(
|
||||||
|
type_of_important,
|
||||||
|
"a {\n color: type-of(!important)\n}\n",
|
||||||
|
"a {\n color: string;\n}\n"
|
||||||
|
);
|
||||||
test!(
|
test!(
|
||||||
type_of_true,
|
type_of_true,
|
||||||
"a {\n color: type-of(true)\n}\n",
|
"a {\n color: type-of(true)\n}\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user