add tests for nan in unary ops

This commit is contained in:
Connor Skees 2020-08-19 03:52:45 -04:00
parent ff52e56600
commit cb1eecde74
2 changed files with 15 additions and 1 deletions

View File

@ -121,7 +121,6 @@ impl<'a, 'b: 'a> ValueVisitor<'a, 'b> {
Value::Dimension(Some(n), u, should_divide) => {
Value::Dimension(Some(-n), u, should_divide)
}
// todo: NaN test
Value::Dimension(None, u, should_divide) => Value::Dimension(None, u, should_divide),
v => Value::String(format!("-{}", v.to_css_string(self.span)?), QuoteKind::None),
})

View File

@ -159,3 +159,18 @@ error!(
"@use \"sass:math\";\na {\n color: set-nth([a], math.acos(2), b);\n}\n",
"Error: $n: NaNdeg is not an int."
);
test!(
nan_unary_negative,
"a {\n color: -(0/0);\n}\n",
"a {\n color: NaN;\n}\n"
);
test!(
nan_unary_plus,
"a {\n color: +(0/0);\n}\n",
"a {\n color: NaN;\n}\n"
);
test!(
nan_unary_div,
"a {\n color: /(0/0);\n}\n",
"a {\n color: /NaN;\n}\n"
);