Merge branch 'big-int-code-coverage'

This commit is contained in:
ConnorSkees 2020-05-25 15:53:38 -04:00
commit 55c91d5e04
3 changed files with 43 additions and 1 deletions

View File

@ -229,7 +229,10 @@ from_smaller_integer!(u8);
impl fmt::Debug for Number {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Number {{ {} }}", self)
match self {
Self::Machine(..) => write!(f, "Number::Machine( {} )", self),
Self::Big(..) => write!(f, "Number::Big( {} )", self),
}
}
}

View File

@ -38,6 +38,11 @@ test!(
"a {\n color: floor(10.6px);\n}\n",
"a {\n color: 10px;\n}\n"
);
test!(
floor_big_int,
"a {\n color: floor(1.000000000000000001);\n}\n",
"a {\n color: 1;\n}\n"
);
test!(
ceil_below_pt_5,
"a {\n color: ceil(10.4px);\n}\n",
@ -48,6 +53,11 @@ test!(
"a {\n color: ceil(10.6px);\n}\n",
"a {\n color: 11px;\n}\n"
);
test!(
ceil_big_int,
"a {\n color: ceil(1.000000000000000001);\n}\n",
"a {\n color: 2;\n}\n"
);
test!(
abs_positive,
"a {\n color: abs(10);\n}\n",
@ -93,3 +103,13 @@ test!(
"a {\n color: comparable($number1: 1, $number2: 2);\n}\n",
"a {\n color: true;\n}\n"
);
test!(
random_limit_one,
"a {\n color: random(1);\n}\n",
"a {\n color: 1;\n}\n"
);
test!(
random_limit_big_one,
"a {\n color: random(1000000000000000001 - 1000000000000000000);\n}\n",
"a {\n color: 1;\n}\n"
);

View File

@ -168,3 +168,22 @@ error!(
scientific_notation_ident_char_after_dash,
"a {\n color: 1e-a;\n}\n", "Error: Expected digit."
);
test!(
number_overflow_from_addition,
"a {\n color: 999999999999999999
+ 999999999999999999
+ 999999999999999999
+ 999999999999999999
+ 999999999999999999
+ 999999999999999999
+ 999999999999999999
+ 999999999999999999
+ 999999999999999999
+ 999999999999999999;\n}\n",
"a {\n color: 9999999999999999990;\n}\n"
);
test!(
number_overflow_from_multiplication,
"a {\n color: 999999999999999999 * 10;\n}\n",
"a {\n color: 9999999999999999990;\n}\n"
);