diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-12-20 14:18:29 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-12-21 00:20:24 +0100 |
| commit | 11565a40b315212474f52eb576a9fd92b11f1132 (patch) | |
| tree | c6b7afb35103065bc92b407094ca905bb75cfc73 /tests/typ | |
| parent | 958f74f77707340f34ee36d09492bdb74523aa2a (diff) | |
Set Rules Episode IX: The Rise of Testing
Diffstat (limited to 'tests/typ')
| -rw-r--r-- | tests/typ/layout/box-block.typ (renamed from tests/typ/layout/containers.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/layout/image.typ (renamed from tests/typ/elements/image.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/layout/place-background.typ (renamed from tests/typ/layout/background.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/layout/place.typ (renamed from tests/typ/layout/placed.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/layout/shape-aspect.typ (renamed from tests/typ/layout/aspect.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/layout/shape-circle.typ (renamed from tests/typ/elements/circle.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/layout/shape-ellipse.typ (renamed from tests/typ/elements/ellipse.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/layout/shape-fill-stroke.typ (renamed from tests/typ/elements/fill-stroke.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/layout/shape-rect.typ (renamed from tests/typ/elements/rect.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/layout/shape-square.typ (renamed from tests/typ/elements/square.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/layout/spacing.typ | 12 | ||||
| -rw-r--r-- | tests/typ/markup/heading.typ | 9 | ||||
| -rw-r--r-- | tests/typ/style/set-block.typ | 10 | ||||
| -rw-r--r-- | tests/typ/style/set-site.typ | 30 | ||||
| -rw-r--r-- | tests/typ/style/set-toggle.typ | 10 | ||||
| -rw-r--r-- | tests/typ/text/em.typ | 17 | ||||
| -rw-r--r-- | tests/typ/text/par.typ | 10 | ||||
| -rw-r--r-- | tests/typ/text/whitespace.typ | 41 |
18 files changed, 114 insertions, 25 deletions
diff --git a/tests/typ/layout/containers.typ b/tests/typ/layout/box-block.typ index 14258c1e..14258c1e 100644 --- a/tests/typ/layout/containers.typ +++ b/tests/typ/layout/box-block.typ diff --git a/tests/typ/elements/image.typ b/tests/typ/layout/image.typ index 8817713f..8817713f 100644 --- a/tests/typ/elements/image.typ +++ b/tests/typ/layout/image.typ diff --git a/tests/typ/layout/background.typ b/tests/typ/layout/place-background.typ index f64bf0ee..f64bf0ee 100644 --- a/tests/typ/layout/background.typ +++ b/tests/typ/layout/place-background.typ diff --git a/tests/typ/layout/placed.typ b/tests/typ/layout/place.typ index 527e0559..527e0559 100644 --- a/tests/typ/layout/placed.typ +++ b/tests/typ/layout/place.typ diff --git a/tests/typ/layout/aspect.typ b/tests/typ/layout/shape-aspect.typ index 2c3e9b0c..2c3e9b0c 100644 --- a/tests/typ/layout/aspect.typ +++ b/tests/typ/layout/shape-aspect.typ diff --git a/tests/typ/elements/circle.typ b/tests/typ/layout/shape-circle.typ index 8b795830..8b795830 100644 --- a/tests/typ/elements/circle.typ +++ b/tests/typ/layout/shape-circle.typ diff --git a/tests/typ/elements/ellipse.typ b/tests/typ/layout/shape-ellipse.typ index 154144c4..154144c4 100644 --- a/tests/typ/elements/ellipse.typ +++ b/tests/typ/layout/shape-ellipse.typ diff --git a/tests/typ/elements/fill-stroke.typ b/tests/typ/layout/shape-fill-stroke.typ index 3ae5f987..3ae5f987 100644 --- a/tests/typ/elements/fill-stroke.typ +++ b/tests/typ/layout/shape-fill-stroke.typ diff --git a/tests/typ/elements/rect.typ b/tests/typ/layout/shape-rect.typ index add39b80..add39b80 100644 --- a/tests/typ/elements/rect.typ +++ b/tests/typ/layout/shape-rect.typ diff --git a/tests/typ/elements/square.typ b/tests/typ/layout/shape-square.typ index c4ece778..c4ece778 100644 --- a/tests/typ/elements/square.typ +++ b/tests/typ/layout/shape-square.typ diff --git a/tests/typ/layout/spacing.typ b/tests/typ/layout/spacing.typ index 98a6100c..37aa8eaa 100644 --- a/tests/typ/layout/spacing.typ +++ b/tests/typ/layout/spacing.typ @@ -18,7 +18,17 @@ Add #h(10pt) #h(10pt) up | #h(1fr) | #h(2fr) | #h(1fr) | --- -// Test that spacing has style properties. +// Test spacing collapsing with parbreaks. +#v(0pt) +A +#v(0pt) +B +#v(0pt) + +C #parbreak() D + +--- +// Test that spacing can carry paragraph and page style properties. A[#set par(align: right);#h(1cm)]B [#set page(height: 20pt);#v(1cm)] diff --git a/tests/typ/markup/heading.typ b/tests/typ/markup/heading.typ index cb022617..2ae97aa8 100644 --- a/tests/typ/markup/heading.typ +++ b/tests/typ/markup/heading.typ @@ -39,3 +39,12 @@ is not. = A { "B" } + +--- +// Test styling. += Heading + +#set heading(family: "Roboto", fill: eastern) + +===== Heading 🌍 +#heading(level: 5)[Heading] diff --git a/tests/typ/style/set-block.typ b/tests/typ/style/set-block.typ new file mode 100644 index 00000000..f260acdc --- /dev/null +++ b/tests/typ/style/set-block.typ @@ -0,0 +1,10 @@ +// Test set in code blocks. + +--- +// Test that template in block is not affected by set +// rule in block ... +A{set text(fill: eastern); [B]}C + +--- +// ... no matter the order. +A{[B]; set text(fill: eastern)}C diff --git a/tests/typ/style/set-site.typ b/tests/typ/style/set-site.typ new file mode 100644 index 00000000..97a5672d --- /dev/null +++ b/tests/typ/style/set-site.typ @@ -0,0 +1,30 @@ +// Test that set affects the instantiation site and not the +// definition site of a template. + +--- +// Test that text is affected by instantion-site bold. +#let x = [World] +Hello *{x}* + +--- +// Test that lists are affected by correct indents. +#set par(spacing: 4pt) +#let fruit = [ + - Apple + - Orange + #set list(body-indent: 10pt) + - Pear +] + +- Fruit +[#set list(label-indent: 10pt) + #fruit] +- No more fruit + +--- +// Test that that par spacing and text style are respected from +// the outside, but the more specific fill is respected. +#set par(spacing: 4pt) +#set text(style: "italic", fill: eastern) +#let x = [And the forest #parbreak() lay silent!] +#text(fill: forest, x) diff --git a/tests/typ/style/set-toggle.typ b/tests/typ/style/set-toggle.typ new file mode 100644 index 00000000..9f26bdf7 --- /dev/null +++ b/tests/typ/style/set-toggle.typ @@ -0,0 +1,10 @@ +// Test set rules for toggleable booleans. + +--- +// Test toggling and untoggling. +*AB_C*DE +*_* + +--- +// Test toggling and nested templates. +*A[B*[_C]]D*E diff --git a/tests/typ/text/em.typ b/tests/typ/text/em.typ new file mode 100644 index 00000000..d9b00f06 --- /dev/null +++ b/tests/typ/text/em.typ @@ -0,0 +1,17 @@ +// Test font-relative sizing. + +--- +#set text(size: 5pt) +A // 5pt +[ + #set text(size: 200%) + B // 10pt + [ + #set text(size: 150% + 1pt) + C // 16pt + #text(size: 200%)[D] // 32pt + E // 16pt + ] + F // 10pt +] +G // 5pt diff --git a/tests/typ/text/par.typ b/tests/typ/text/par.typ index 771a6218..8bd43deb 100644 --- a/tests/typ/text/par.typ +++ b/tests/typ/text/par.typ @@ -16,6 +16,16 @@ To the right! Where the sunlight peeks behind the mountain. Third --- +// Test that paragraph spacing uses correct set rule. +Hello + +#set par(spacing: 100pt) +World +#set par(spacing: 0pt) + +You + +--- // Test that paragraph break due to incompatibility respects // spacing defined by the two adjacent paragraphs. #let a = [#set par(spacing: 40pt);Hello] diff --git a/tests/typ/text/whitespace.typ b/tests/typ/text/whitespace.typ index 4c3d4db5..831a5543 100644 --- a/tests/typ/text/whitespace.typ +++ b/tests/typ/text/whitespace.typ @@ -1,32 +1,21 @@ // Test whitespace handling. --- -// Spacing around let. +// Spacing around code constructs. A#let x = 1;B #test(x, 1) \ -A #let x = 2;B #test(x, 2) \ -A#let x = 3; B #test(x, 3) +C #let x = 2;D #test(x, 2) \ +E#if true [F]G \ +H #if true{"I"} J \ +K #if true [L] else []M \ +#let c = true; N#while c [{c = false}O] P \ +#let c = true; Q #while c { c = false; "R" } S \ +T#for _ in (none,) {"U"}V --- -// Spacing around if-else. -A#if true [B]C \ -A#if true [B] C \ -A #if true{"B"}C \ -A #if true{"B"} C \ -A#if false [] else [B]C \ -A#if true [B] else [] C - ---- -// Spacing around while loop. -#let c = true; A#while c [{c = false}B]C \ -#let c = true; A#while c [{c = false}B] C \ -#let c = true; A #while c { c = false; "B" }C \ -#let c = true; A #while c { c = false; "B" } C - ---- -// Spacing around for loop. -A#for _ in (none,) [B]C \ -A#for _ in (none,) [B] C \ -A #for _ in (none,) {"B"}C +// Test spacing with comments. +A/**/B/**/C \ +A /**/ B/**/C \ +A /**/B/**/ C --- // Test that a run consisting only of whitespace isn't trimmed. @@ -37,7 +26,11 @@ A[#set text(serif); ]B Left [#set text(serif);Right]. --- -// Test that space at start of line is not trimmed. +// Test that linebreak consumed surrounding spaces. +#align(center)[A \ B \ C] + +--- +// Test that space at start of non-backslash-linebreak line isn't trimmed. A{"\n"} B --- |
