diff options
| author | PgBiel <9021226+PgBiel@users.noreply.github.com> | 2024-10-14 13:14:06 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-14 16:14:06 +0000 |
| commit | 382787d7995775cc85052419896e308a2de8de28 (patch) | |
| tree | 64e4ce35a218a101ea442f4553b95ecbdd1434b3 /tests | |
| parent | 03a766444a2770246a847f71980aebe71964e3af (diff) | |
(Re-)implement rounding with negative digits (#5198)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/suite/foundations/calc.typ | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/tests/suite/foundations/calc.typ b/tests/suite/foundations/calc.typ index 4cf7ab2a..5726dafa 100644 --- a/tests/suite/foundations/calc.typ +++ b/tests/suite/foundations/calc.typ @@ -4,18 +4,23 @@ #test(type(calc.round(3.1415, digits: 2)), float) #test(type(calc.round(5, digits: 2)), int) #test(type(calc.round(decimal("3.1415"), digits: 2)), decimal) +#test(type(calc.round(314.15, digits: -2)), float) +#test(type(calc.round(523, digits: -2)), int) +#test(type(calc.round(decimal("314.15"), digits: -2)), decimal) --- calc-round-large-inputs --- #test(calc.round(31114, digits: 4000000000), 31114) #test(calc.round(9223372036854775807, digits: 12), 9223372036854775807) +#test(calc.round(9223372036854775807, digits: -20), 0) #test(calc.round(238959235.129590203, digits: 4000000000), 238959235.129590203) #test(calc.round(1.7976931348623157e+308, digits: 12), 1.7976931348623157e+308) +#test(calc.round(1.7976931348623157e+308, digits: -308), float.inf) +#test(calc.round(-1.7976931348623157e+308, digits: -308), -float.inf) +#test(calc.round(12.34, digits: -312), 0.0) #test(calc.round(decimal("238959235.129590203"), digits: 4000000000), decimal("238959235.129590203")) #test(calc.round(decimal("79228162514264337593543950335"), digits: 12), decimal("79228162514264337593543950335")) - ---- calc-round-negative-digits --- -// Error: 29-31 number must be at least zero -#calc.round(243.32, digits: -2) +#test(calc.round(decimal("79228162514264337593543950335"), digits: -50), decimal("0")) +#test(calc.round(decimal("-79228162514264337593543950335"), digits: -2), decimal("-79228162514264337593543950300")) --- calc-abs --- // Test the `abs` function. @@ -331,6 +336,22 @@ // Error: 2-47 the result is too large #calc.floor(decimal("-9223372036854775809.5")) +--- calc-round-int-too-large --- +// Error: 2-45 the result is too large +#calc.round(9223372036854775807, digits: -1) + +--- calc-round-int-negative-too-large --- +// Error: 2-46 the result is too large +#calc.round(-9223372036854775807, digits: -1) + +--- calc-round-decimal-too-large --- +// Error: 2-66 the result is too large +#calc.round(decimal("79228162514264337593543950335"), digits: -1) + +--- calc-round-decimal-negative-too-large --- +// Error: 2-67 the result is too large +#calc.round(decimal("-79228162514264337593543950335"), digits: -1) + --- calc-min-nothing --- // Error: 2-12 expected at least one value #calc.min() |
