From 261f387535ebe3b784d69893027d8edac01e1ba9 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 17 Feb 2022 18:12:13 +0100 Subject: Accept closures for heading styling --- tests/ref/style/closure.png | Bin 0 -> 7567 bytes tests/typ/style/closure.typ | 48 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/ref/style/closure.png create mode 100644 tests/typ/style/closure.typ (limited to 'tests') diff --git a/tests/ref/style/closure.png b/tests/ref/style/closure.png new file mode 100644 index 00000000..77d88d0c Binary files /dev/null and b/tests/ref/style/closure.png differ diff --git a/tests/typ/style/closure.typ b/tests/typ/style/closure.typ new file mode 100644 index 00000000..2c9edd81 --- /dev/null +++ b/tests/typ/style/closure.typ @@ -0,0 +1,48 @@ +// Test styles with closure. + +--- +#set heading( + size: 10pt, + fill: lvl => if even(lvl) { red } else { blue }, +) + += Heading 1 +== Heading 2 +=== Heading 3 +==== Heading 4 + +--- +// Test in constructor. +#heading( + level: 3, + size: 10pt, + strong: lvl => { + assert(lvl == 3) + false + } +)[Level 3] + +--- +// Error: 22-26 expected font family or auto or function, found length +#set heading(family: 10pt) += Heading + +--- +// Error: 29-38 cannot add integer and string +#set heading(strong: lvl => lvl + "2") += Heading + +--- +// Error: 22-34 expected font family or auto, found boolean +#set heading(family: lvl => false) += Heading + +--- +// Error: 22-37 missing argument: b +#set heading(family: (a, b) => a + b) += Heading + +--- +// Error: 22-30 unexpected argument +#set heading(family: () => {}) += Heading -- cgit v1.2.3