From d21cb2cf5e522b8232f14c71a3185aa6e67ee9ec Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 10 Oct 2024 17:51:48 +0200 Subject: Fix scales for unit conversion (#5169) --- tests/ref/gradient-presets.png | Bin 17311 -> 17315 bytes tests/suite/layout/length.typ | 38 ++++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/ref/gradient-presets.png b/tests/ref/gradient-presets.png index de496894..7fdb235c 100644 Binary files a/tests/ref/gradient-presets.png and b/tests/ref/gradient-presets.png differ diff --git a/tests/suite/layout/length.typ b/tests/suite/layout/length.typ index c40752f7..5ba70072 100644 --- a/tests/suite/layout/length.typ +++ b/tests/suite/layout/length.typ @@ -9,24 +9,26 @@ --- length-to-unit --- // Test length unit conversions. -#test((500.934pt).pt(), 500.934) -#test((3.3453cm).cm(), 3.3453) -#test((4.3452mm).mm(), 4.3452) -#test((5.345in).inches(), 5.345) -#test((500.333666999pt).pt(), 500.333666999) -#test((3.5234354cm).cm(), 3.5234354) -#test((4.12345678mm).mm(), 4.12345678) -#test((5.333666999in).inches(), 5.333666999) -#test((4.123456789123456mm).mm(), 4.123456789123456) -#test((254cm).mm(), 2540.0) -#test(calc.round((254cm).inches(), digits: 2), 100.0) -#test((2540mm).cm(), 254.0) -#test(calc.round((2540mm).inches(), digits: 2), 100.0) -#test((100in).pt(), 7200.0) -#test(calc.round((100in).cm(), digits: 2), 254.0) -#test(calc.round((100in).mm(), digits: 2), 2540.0) -#test(5em.abs.cm(), 0.0) -#test((5em + 6in).abs.inches(), 6.0) +#let t(a, b) = assert(calc.abs(a - b) < 1e-6) + +#t((500.934pt).pt(), 500.934) +#t((3.3453cm).cm(), 3.3453) +#t((4.3452mm).mm(), 4.3452) +#t((5.345in).inches(), 5.345) +#t((500.333666999pt).pt(), 500.333666999) +#t((3.523435cm).cm(), 3.523435) +#t((4.12345678mm).mm(), 4.12345678) +#t((5.333666999in).inches(), 5.333666999) +#t((4.123456789123456mm).mm(), 4.123456789123456) +#t((254cm).mm(), 2540.0) +#t((254cm).inches(), 100.0) +#t((2540mm).cm(), 254.0) +#t((2540mm).inches(), 100.0) +#t((100in).pt(), 7200.0) +#t((100in).cm(), 254.0) +#t((100in).mm(), 2540.0) +#t(5em.abs.cm(), 0.0) +#t((5em + 6in).abs.inches(), 6.0) --- length-to-absolute --- // Test length `to-absolute` method. -- cgit v1.2.3