diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/css/css-values/round-function.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-values/round-function.html')
-rw-r--r-- | testing/web-platform/tests/css/css-values/round-function.html | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-values/round-function.html b/testing/web-platform/tests/css/css-values/round-function.html new file mode 100644 index 0000000000..bc8734b011 --- /dev/null +++ b/testing/web-platform/tests/css/css-values/round-function.html @@ -0,0 +1,97 @@ +<!doctype html> +<title>round() function</title> +<meta charset=utf-8> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../support/numeric-testcommon.js"></script> + +<meta name=author content="Tab Atkins-Bittner"> +<link rel=help href="https://drafts.csswg.org/css-values-4/#round-func"> + +<div id=target></div> +<script> +// No-op round should be same as nearest +test_math_used("round(23px, 10px)", "20px"); +test_math_used("round(18px, 10px)", "20px"); +test_math_used("round(15px, 10px)", "20px"); +test_math_used("round(13px, 10px)", "10px"); +test_math_used("round(-13px, 10px)", "-10px"); +test_math_used("round(-18px, 10px)", "-20px"); + +// Test nearest +test_math_used("round(nearest, 23px, 10px)", "20px"); +test_math_used("round(nearest, 18px, 10px)", "20px"); +test_math_used("round(nearest, 15px, 10px)", "20px"); +test_math_used("round(nearest, 13px, 10px)", "10px"); +test_math_used("round(nearest, -13px, 10px)", "-10px"); +test_math_used("round(nearest, -18px, 10px)", "-20px"); + +// Test down +test_math_used("round(down, 23px, 10px)", "20px"); +test_math_used("round(down, 18px, 10px)", "10px"); +test_math_used("round(down, 15px, 10px)", "10px"); +test_math_used("round(down, 13px, 10px)", "10px"); +test_math_used("round(down, -13px, 10px)", "-20px"); +test_math_used("round(down, -18px, 10px)", "-20px"); + +// Test up +test_math_used("round(up, 23px, 10px)", "30px"); +test_math_used("round(up, 18px, 10px)", "20px"); +test_math_used("round(up, 15px, 10px)", "20px"); +test_math_used("round(up, 13px, 10px)", "20px"); +test_math_used("round(up, -13px, 10px)", "-10px"); +test_math_used("round(up, -18px, 10px)", "-10px"); + +// Test to-zero +test_math_used("round(to-zero, 23px, 10px)", "20px"); +test_math_used("round(to-zero, 18px, 10px)", "10px"); +test_math_used("round(to-zero, 15px, 10px)", "10px"); +test_math_used("round(to-zero, 13px, 10px)", "10px"); +test_math_used("round(to-zero, -13px, 10px)", "-10px"); +test_math_used("round(to-zero, -18px, 10px)", "-10px"); + +// Test a negative step +test_math_used("round(23px, -10px)", "20px"); +test_math_used("round(18px, -10px)", "20px"); +test_math_used("round(15px, -10px)", "20px"); +test_math_used("round(13px, -10px)", "10px"); +test_math_used("round(-13px, -10px)", "-10px"); +test_math_used("round(-18px, -10px)", "-20px"); + +// Extreme cases: + +// 0 step is NaN +test_nan("round(5, 0)"); +// both infinite is NaN +test_nan("round(infinity, infinity)"); +test_nan("round(infinity, -infinity)"); +test_nan("round(-infinity, infinity)"); +test_nan("round(-infinity, -infinity)"); + +// infinite value with finite step is the same infinity +test_plus_infinity("round(infinity, 5)"); +test_plus_infinity("round(infinity, -5)"); +test_minus_infinity("round(-infinity, 5)"); +test_minus_infinity("round(-infinity, -5)"); + +// Finite value with infinite step depends on rounding strategy. +// 'nearest' and 'to-zero': pos and +0 go to +0, neg and -0 go to -0 +test_plus_zero("round(5, infinity)"); +test_plus_zero("round(5, -infinity)"); +test_minus_zero("round(-5, infinity)"); +test_minus_zero("round(-5, -infinity)"); +test_plus_zero("round(to-zero, 5, infinity)"); +test_plus_zero("round(to-zero, 5, -infinity)"); +test_minus_zero("round(to-zero, -5, infinity)"); +test_minus_zero("round(to-zero, -5, -infinity)"); +// 'up': pos goes to +inf, 0+ goes to 0+, else 0- +test_plus_infinity("round(up, 1, infinity)"); +test_plus_zero("round(up, 0, infinity)"); +test_minus_zero("round(up, -1 * 0, infinity)"); +test_minus_zero("round(up, -1, infinity)"); +// 'down': neg goes to -inf, -0 goes to -0, else 0+ +test_minus_infinity("round(down, -1, infinity)"); +test_minus_zero("round(down, -1 * 0, infinity)"); +test_plus_zero("round(down, 0, infinity)"); +test_plus_zero("round(down, 1, infinity)"); +</script>
\ No newline at end of file |