summaryrefslogtreecommitdiff
path: root/tests/suite
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-10-10 17:51:48 +0200
committerLaurenz <laurmaedje@gmail.com>2024-10-15 15:06:36 +0200
commitd21cb2cf5e522b8232f14c71a3185aa6e67ee9ec (patch)
treeaf8cb95a8f9f4d47fe65f7cc35e4a1f2d6d9de2e /tests/suite
parent250223c997541459621ce9bcf27e4b93536ee900 (diff)
Fix scales for unit conversion (#5169)
Diffstat (limited to 'tests/suite')
-rw-r--r--tests/suite/layout/length.typ38
1 files changed, 20 insertions, 18 deletions
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.