From 3aeb150c95f9ae55ded7233b86108be18c3028db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20d=27Herbais=20de=20Thun?= Date: Wed, 3 Jan 2024 10:43:08 +0100 Subject: Added `to-absolute` method to length. (#3117) Co-authored-by: Laurenz --- tests/typ/compiler/methods.typ | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/typ') diff --git a/tests/typ/compiler/methods.typ b/tests/typ/compiler/methods.typ index f3ec4434..262f1497 100644 --- a/tests/typ/compiler/methods.typ +++ b/tests/typ/compiler/methods.typ @@ -81,6 +81,23 @@ #test(5em.abs.cm(), 0.0) #test((5em + 6in).abs.inches(), 6.0) +--- +// Test length `to-absolute` method. + +#set text(size: 12pt) +#style(styles => { + test((6pt).to-absolute(styles), 6pt) + test((6pt + 10em).to-absolute(styles), 126pt) + test((10em).to-absolute(styles), 120pt) +}) + +#set text(size: 64pt) +#style(styles => { + test((6pt).to-absolute(styles), 6pt) + test((6pt + 10em).to-absolute(styles), 646pt) + test((10em).to-absolute(styles), 640pt) +}) + --- // Error: 2-21 cannot convert a length with non-zero em units (`-6pt + 10.5em`) to pt // Hint: 2-21 use `length.abs.pt()` instead to ignore its em component -- cgit v1.2.3