From 6d26e15fbe9a91bcae9cc98fab0743ca75c41ea7 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 30 Sep 2021 19:07:06 +0200 Subject: Support `else if` --- tests/typ/code/if.typ | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests/typ/code/if.typ') diff --git a/tests/typ/code/if.typ b/tests/typ/code/if.typ index 36fd3d0f..3b3164fc 100644 --- a/tests/typ/code/if.typ +++ b/tests/typ/code/if.typ @@ -45,6 +45,33 @@ if "template" == type [Nope] else [ve.] } +#let i = 3 +#if i < 2 [ + Five. +] else if i < 4 [ + Six. +] else [ + Seven. +] + +--- +// Test else if. +// Ref: false + +#let nth(n) = { + str(n) + (if n == 1 { "st" } + else if n == 2 { "nd" } + else if n == 3 { "rd" } + else { "th" }) +} + +#test(nth(1), "1st") +#test(nth(2), "2nd") +#test(nth(3), "3rd") +#test(nth(4), "4th") +#test(nth(5), "5th") + --- // Value of if expressions. // Ref: false -- cgit v1.2.3