Fix round() with negative step returning incorrect value

Differential Revision: https://phabricator.services.mozilla.com/D197011

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1867908
gecko-commit: 789ecd85405c566d7fae17d2f53dcd06e9125b72
gecko-reviewers: emilio
diff --git a/css/css-values/round-function.html b/css/css-values/round-function.html
index d21f56d..29ec60e 100644
--- a/css/css-values/round-function.html
+++ b/css/css-values/round-function.html
@@ -18,6 +18,13 @@
 test_math_used("round(-13px, 10px)", "-10px");
 test_math_used("round(-18px, 10px)", "-20px");
 
+test_math_used("round(23, 10)", "20", { type: "integer" });
+test_math_used("round(18, 10)", "20", { type: "integer" });
+test_math_used("round(15, 10)", "20", { type: "integer" });
+test_math_used("round(13, 10)", "10", { type: "integer" });
+test_math_used("round(-13, 10)", "-10", { type: "integer" });
+test_math_used("round(-18, 10)", "-20", { type: "integer" });
+
 // Test nearest
 test_math_used("round(nearest, 23px, 10px)", "20px");
 test_math_used("round(nearest, 18px, 10px)", "20px");
@@ -26,6 +33,13 @@
 test_math_used("round(nearest, -13px, 10px)", "-10px");
 test_math_used("round(nearest, -18px, 10px)", "-20px");
 
+test_math_used("round(nearest, 23, 10)", "20", { type: "integer" });
+test_math_used("round(nearest, 18, 10)", "20", { type: "integer" });
+test_math_used("round(nearest, 15, 10)", "20", { type: "integer" });
+test_math_used("round(nearest, 13, 10)", "10", { type: "integer" });
+test_math_used("round(nearest, -13, 10)", "-10", { type: "integer" });
+test_math_used("round(nearest, -18, 10)", "-20", { type: "integer" });
+
 // Test down
 test_math_used("round(down, 23px, 10px)", "20px");
 test_math_used("round(down, 18px, 10px)", "10px");
@@ -34,6 +48,13 @@
 test_math_used("round(down, -13px, 10px)", "-20px");
 test_math_used("round(down, -18px, 10px)", "-20px");
 
+test_math_used("round(down, 23, 10)", "20", { type: "integer" });
+test_math_used("round(down, 18, 10)", "10", { type: "integer" });
+test_math_used("round(down, 15, 10)", "10", { type: "integer" });
+test_math_used("round(down, 13, 10)", "10", { type: "integer" });
+test_math_used("round(down, -13, 10)", "-20", { type: "integer" });
+test_math_used("round(down, -18, 10)", "-20", { type: "integer" });
+
 // Test up
 test_math_used("round(up, 23px, 10px)", "30px");
 test_math_used("round(up, 18px, 10px)", "20px");
@@ -42,6 +63,13 @@
 test_math_used("round(up, -13px, 10px)", "-10px");
 test_math_used("round(up, -18px, 10px)", "-10px");
 
+test_math_used("round(up, 23, 10)", "30", { type: "integer" });
+test_math_used("round(up, 18, 10)", "20", { type: "integer" });
+test_math_used("round(up, 15, 10)", "20", { type: "integer" });
+test_math_used("round(up, 13, 10)", "20", { type: "integer" });
+test_math_used("round(up, -13, 10)", "-10", { type: "integer" });
+test_math_used("round(up, -18, 10)", "-10", { type: "integer" });
+
 // Test to-zero
 test_math_used("round(to-zero, 23px, 10px)", "20px");
 test_math_used("round(to-zero, 18px, 10px)", "10px");
@@ -50,6 +78,13 @@
 test_math_used("round(to-zero, -13px, 10px)", "-10px");
 test_math_used("round(to-zero, -18px, 10px)", "-10px");
 
+test_math_used("round(to-zero, 23, 10)", "20", { type: "integer" });
+test_math_used("round(to-zero, 18, 10)", "10", { type: "integer" });
+test_math_used("round(to-zero, 15, 10)", "10", { type: "integer" });
+test_math_used("round(to-zero, 13, 10)", "10", { type: "integer" });
+test_math_used("round(to-zero, -13, 10)", "-10", { type: "integer" });
+test_math_used("round(to-zero, -18, 10)", "-10", { type: "integer" });
+
 // Test a negative step
 test_math_used("round(23px, -10px)", "20px");
 test_math_used("round(18px, -10px)", "20px");
@@ -58,6 +93,13 @@
 test_math_used("round(-13px, -10px)", "-10px");
 test_math_used("round(-18px, -10px)", "-20px");
 
+test_math_used("round(23, -10)", "20", { type: "integer" });
+test_math_used("round(18, -10)", "20", { type: "integer" });
+test_math_used("round(15, -10)", "20", { type: "integer" });
+test_math_used("round(13, -10)", "10", { type: "integer" });
+test_math_used("round(-13, -10)", "-10", { type: "integer" });
+test_math_used("round(-18, -10)", "-20", { type: "integer" });
+
 // Test with value that is an exact multiple of step
 test_math_used("round(10px, 5px)", "10px");
 test_math_used("round(nearest, 10px, 5px)", "10px");
@@ -65,12 +107,24 @@
 test_math_used("round(up, 10px, 5px)", "10px");
 test_math_used("round(to-zero, 10px, 5px)", "10px");
 
+test_math_used("round(10, 5)", "10", { type: "integer" });
+test_math_used("round(nearest, 10, 5)", "10", { type: "integer" });
+test_math_used("round(down, 10, 5)", "10", { type: "integer" });
+test_math_used("round(up, 10, 5)", "10", { type: "integer" });
+test_math_used("round(to-zero, 10, 5)", "10", { type: "integer" });
+
 test_math_used("round(-10px, 5px)", "-10px");
 test_math_used("round(nearest, -10px, 5px)", "-10px");
 test_math_used("round(down, -10px, 5px)", "-10px");
 test_math_used("round(up, -10px, 5px)", "-10px");
 test_math_used("round(to-zero, -10px, 5px)", "-10px");
 
+test_math_used("round(-10, 5)", "-10", { type: "integer" });
+test_math_used("round(nearest, -10, 5)", "-10", { type: "integer" });
+test_math_used("round(down, -10, 5)", "-10", { type: "integer" });
+test_math_used("round(up, -10, 5)", "-10", { type: "integer" });
+test_math_used("round(to-zero, -10, 5)", "-10", { type: "integer" });
+
 // Test negation of the round operation
 test_math_used("calc(0px - round(23px, 10px))", "-20px");
 test_math_used("calc(0px - round(18px, 10px))", "-20px");
@@ -79,6 +133,13 @@
 test_math_used("calc(0px - round(-13px, 10px))", "10px");
 test_math_used("calc(0px - round(-18px, 10px))", "20px");
 
+test_math_used("calc(0 - round(23, 10))", "-20", { type: "integer" });
+test_math_used("calc(0 - round(18, 10))", "-20", { type: "integer" });
+test_math_used("calc(0 - round(15, 10))", "-20", { type: "integer" });
+test_math_used("calc(0 - round(13, 10))", "-10", { type: "integer" });
+test_math_used("calc(0 - round(-13, 10))", "10", { type: "integer" });
+test_math_used("calc(0 - round(-18, 10))", "20", { type: "integer" });
+
 // Test negation of nearest
 test_math_used("calc(0px - round(nearest, 23px, 10px))", "-20px");
 test_math_used("calc(0px - round(nearest, 18px, 10px))", "-20px");
@@ -87,6 +148,13 @@
 test_math_used("calc(0px - round(nearest, -13px, 10px))", "10px");
 test_math_used("calc(0px - round(nearest, -18px, 10px))", "20px");
 
+test_math_used("calc(0 - round(nearest, 23, 10))", "-20", { type: "integer" });
+test_math_used("calc(0 - round(nearest, 18, 10))", "-20", { type: "integer" });
+test_math_used("calc(0 - round(nearest, 15, 10))", "-20", { type: "integer" });
+test_math_used("calc(0 - round(nearest, 13, 10))", "-10", { type: "integer" });
+test_math_used("calc(0 - round(nearest, -13, 10))", "10", { type: "integer" });
+test_math_used("calc(0 - round(nearest, -18, 10))", "20", { type: "integer" });
+
 // Test negation of down
 test_math_used("calc(0px - round(down, 23px, 10px))", "-20px");
 test_math_used("calc(0px - round(down, 18px, 10px))", "-10px");
@@ -95,6 +163,13 @@
 test_math_used("calc(0px - round(down, -13px, 10px))", "20px");
 test_math_used("calc(0px - round(down, -18px, 10px))", "20px");
 
+test_math_used("calc(0 - round(down, 23, 10))", "-20", { type: "integer" });
+test_math_used("calc(0 - round(down, 18, 10))", "-10", { type: "integer" });
+test_math_used("calc(0 - round(down, 15, 10))", "-10", { type: "integer" });
+test_math_used("calc(0 - round(down, 13, 10))", "-10", { type: "integer" });
+test_math_used("calc(0 - round(down, -13, 10))", "20", { type: "integer" });
+test_math_used("calc(0 - round(down, -18, 10))", "20", { type: "integer" });
+
 // Test negation of up
 test_math_used("calc(0px - round(up, 23px, 10px))", "-30px");
 test_math_used("calc(0px - round(up, 18px, 10px))", "-20px");
@@ -103,6 +178,13 @@
 test_math_used("calc(0px - round(up, -13px, 10px))", "10px");
 test_math_used("calc(0px - round(up, -18px, 10px))", "10px");
 
+test_math_used("calc(0 - round(up, 23, 10))", "-30", { type: "integer" });
+test_math_used("calc(0 - round(up, 18, 10))", "-20", { type: "integer" });
+test_math_used("calc(0 - round(up, 15, 10))", "-20", { type: "integer" });
+test_math_used("calc(0 - round(up, 13, 10))", "-20", { type: "integer" });
+test_math_used("calc(0 - round(up, -13, 10))", "10", { type: "integer" });
+test_math_used("calc(0 - round(up, -18, 10))", "10", { type: "integer" });
+
 // Test negation of to-zero
 test_math_used("calc(0px - round(to-zero, 23px, 10px))", "-20px");
 test_math_used("calc(0px - round(to-zero, 18px, 10px))", "-10px");
@@ -111,6 +193,13 @@
 test_math_used("calc(0px - round(to-zero, -13px, 10px))", "10px");
 test_math_used("calc(0px - round(to-zero, -18px, 10px))", "10px");
 
+test_math_used("calc(0 - round(to-zero, 23, 10))", "-20", { type: "integer" });
+test_math_used("calc(0 - round(to-zero, 18, 10))", "-10", { type: "integer" });
+test_math_used("calc(0 - round(to-zero, 15, 10))", "-10", { type: "integer" });
+test_math_used("calc(0 - round(to-zero, 13, 10))", "-10", { type: "integer" });
+test_math_used("calc(0 - round(to-zero, -13, 10))", "10", { type: "integer" });
+test_math_used("calc(0 - round(to-zero, -18, 10))", "10", { type: "integer" });
+
 // Extreme cases:
 
 // 0 step is NaN