diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-09-16 16:41:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-16 14:41:18 +0000 |
| commit | 16e67f8bea7e6891e954420e2e005976fb48a528 (patch) | |
| tree | b1de8e17f184d10894447a602da1722a71dd23a9 /tests/suite/layout/flow | |
| parent | db71a178bef7f1525d732a190ac75a1a6d56f24b (diff) | |
Shrink tests (#4967)
Diffstat (limited to 'tests/suite/layout/flow')
| -rw-r--r-- | tests/suite/layout/flow/flow.typ | 15 | ||||
| -rw-r--r-- | tests/suite/layout/flow/orphan.typ | 19 | ||||
| -rw-r--r-- | tests/suite/layout/flow/place-float.typ | 83 | ||||
| -rw-r--r-- | tests/suite/layout/flow/place-flush.typ | 29 | ||||
| -rw-r--r-- | tests/suite/layout/flow/place.typ | 100 |
5 files changed, 227 insertions, 19 deletions
diff --git a/tests/suite/layout/flow/flow.typ b/tests/suite/layout/flow/flow.typ index 7c8ade14..88075c5b 100644 --- a/tests/suite/layout/flow/flow.typ +++ b/tests/suite/layout/flow/flow.typ @@ -11,11 +11,8 @@ // the rest moved down. The reason was that the second block resulted in // overlarge frames because the region wasn't finished properly. #set page(height: 70pt) -#block[This file tests a bug where an almost empty page occurs.] -#block[ - The text in this second block was torn apart and split up for - some reason beyond my knowledge. -] +#block(lines(3)) +#block(lines(5)) --- issue-flow-trailing-leading --- // In this bug, the first part of the paragraph moved down to the second page @@ -48,13 +45,13 @@ // This bug caused an index-out-of-bounds panic when layouting paragraphs needed // multiple reorderings. #set page(height: 200pt) -#lorem(30) +#lines(10) #figure(placement: auto, block(height: 100%)) -#lorem(10) +#lines(3) -#lorem(10) +#lines(3) --- issue-3641-float-loop --- // Flow layout should terminate! @@ -64,7 +61,7 @@ #set page(height: 40pt) = Heading -#lorem(6) +#lines(2) --- issue-3355-metadata-weak-spacing --- #set page(height: 50pt) diff --git a/tests/suite/layout/flow/orphan.typ b/tests/suite/layout/flow/orphan.typ index bd938d96..7674b107 100644 --- a/tests/suite/layout/flow/orphan.typ +++ b/tests/suite/layout/flow/orphan.typ @@ -2,38 +2,37 @@ --- flow-heading-no-orphan --- #set page(height: 100pt) -#lorem(12) +#lines(4) = Introduction -This is the start and it goes on. +A --- flow-par-no-orphan-and-widow-lines --- -// LARGE -#set page("a8", height: 140pt) +#set page(width: 60pt, height: 140pt) #set text(weight: 700) // Fits fully onto the first page. #set text(blue) -#lorem(27) +#lines(8) // The first line would fit, but is moved to the second page. -#lorem(20) +#lines(6, "1") // The second-to-last line is moved to the third page so that the last is isn't // as lonely. #set text(maroon) -#lorem(11) +#lines(4) -#lorem(13) +#lines(4, "1") // All three lines go to the next page. #set text(olive) -#lorem(10) +#lines(3) --- flow-widow-forced --- // Ensure that a widow is allowed when the three lines don't all fit. #set page(height: 50pt) -#lorem(10) +#lines(3) --- issue-1445-widow-orphan-unnecessary-skip --- // Ensure that widow/orphan prevention doesn't unnecessarily move things diff --git a/tests/suite/layout/flow/place-float.typ b/tests/suite/layout/flow/place-float.typ new file mode 100644 index 00000000..50a8a112 --- /dev/null +++ b/tests/suite/layout/flow/place-float.typ @@ -0,0 +1,83 @@ +--- place-float-flow-around --- +#set page(height: 80pt) +#set place(float: true) +#place(bottom + center, rect(height: 20pt)) +#lines(4) + +--- place-float-queued --- +#set page(height: 180pt) +#set figure(placement: auto) + +#figure(rect(height: 60pt), caption: [I]) +#figure(rect(height: 40pt), caption: [II]) +#figure(rect(), caption: [III]) +#figure(rect(), caption: [IV]) +A + +--- place-float-align-auto --- +#set page(height: 140pt) +#set place(clearance: 5pt) +#set place(auto, float: true) + +#place(rect[A]) +#place(rect[B]) +1 \ 2 +#place(rect[C]) +#place(rect[D]) + +--- place-float-in-column-align-auto --- +#set page(height: 150pt, columns: 2) +#set place(auto, float: true, clearance: 10pt) +#set rect(width: 75%) + +#place(rect[I]) +#place(rect[II]) +#place(rect[III]) +#place(rect[IV]) + +#lines(6) + +#place(rect[V]) + +--- place-float-in-column-queued --- +#set page(height: 100pt, columns: 2) +#set place(float: true, clearance: 10pt) +#set rect(width: 75%) +#set text(costs: (widow: 0%, orphan: 0%)) + +#lines(3) + +#place(top, rect[I]) +#place(top, rect[II]) +#place(bottom, rect[III]) + +#lines(3) + +--- place-float-missing --- +// Error: 2-20 automatic positioning is only available for floating placement +// Hint: 2-20 you can enable floating placement with `place(float: true, ..)` +#place(auto)[Hello] + +--- place-float-center-horizon --- +// Error: 2-45 floating placement must be `auto`, `top`, or `bottom` +#place(center + horizon, float: true)[Hello] + +--- place-float-horizon --- +// Error: 2-36 floating placement must be `auto`, `top`, or `bottom` +#place(horizon, float: true)[Hello] + +--- place-float-default --- +// Error: 2-27 floating placement must be `auto`, `top`, or `bottom` +#place(float: true)[Hello] + +--- place-float-right --- +// Error: 2-34 floating placement must be `auto`, `top`, or `bottom` +#place(right, float: true)[Hello] + +--- issue-2595-float-overlap --- +#set page(height: 80pt) + +1 +#place(auto, float: true, block(height: 100%, width: 100%, fill: aqua)) +#place(auto, float: true, block(height: 100%, width: 100%, fill: red)) +#lines(7) diff --git a/tests/suite/layout/flow/place-flush.typ b/tests/suite/layout/flow/place-flush.typ new file mode 100644 index 00000000..8f55a6fd --- /dev/null +++ b/tests/suite/layout/flow/place-flush.typ @@ -0,0 +1,29 @@ +--- place-flush --- +#set page(height: 120pt) +#let floater(align, height) = place( + align, + float: true, + rect(width: 100%, height: height), +) + +#floater(top, 30pt) +A + +#floater(bottom, 50pt) +#place.flush() +B // Should be on the second page. + +--- place-flush-figure --- +#set page(height: 120pt) +#let floater(align, height, caption) = figure( + placement: align, + caption: caption, + rect(width: 100%, height: height), +) + +#floater(top, 30pt)[I] +A + +#floater(bottom, 50pt)[II] +#place.flush() +B // Should be on the second page. diff --git a/tests/suite/layout/flow/place.typ b/tests/suite/layout/flow/place.typ new file mode 100644 index 00000000..f3231735 --- /dev/null +++ b/tests/suite/layout/flow/place.typ @@ -0,0 +1,100 @@ +// Test the `place` function. + +--- place-basic --- +#set page("a8") +#place(bottom + center)[E] + += A +#place(right, rect(width: 1.8cm)) +#lines(5) + +#stack( + rect(fill: eastern, height: 10pt, width: 100%), + place(right, dy: 1.5pt)[ABC], + rect(fill: conifer, height: 10pt, width: 80%), + rect(fill: forest, height: 10pt, width: 100%), + 10pt, + block[ + #place(center, dx: -7pt, dy: -5pt)[A] + #place(center, dx: 7pt, dy: 5pt)[B] + C #h(1fr) D + ] +) + +--- place-block-spacing --- +// Test how the placed element interacts with paragraph spacing around it. +#set page("a8", height: 60pt) + +First + +#place(bottom + right)[Placed] + +Second + +--- place-bottom-in-box --- +#box( + fill: aqua, + width: 30pt, + height: 30pt, + place(bottom, + place(line(start: (0pt, 0pt), end: (20pt, 0pt), stroke: red + 3pt)) + ) +) + +--- place-horizon-in-boxes --- +#box( + fill: aqua, + width: 30pt, + height: 30pt, + { + box(fill: yellow, { + [Hello] + place(horizon, line(start: (0pt, 0pt), end: (20pt, 0pt), stroke: red + 2pt)) + }) + place(horizon, line(start: (0pt, 0pt), end: (20pt, 0pt), stroke: green + 3pt)) + } +) + +--- place-bottom-right-in-box --- +#box(fill: aqua)[ + #place(bottom + right)[Hi] + Hello World \ + How are \ + you? +] + +--- place-top-left-in-box --- +#box(fill: aqua)[ + #place(top + left, dx: 50%, dy: 50%)[Hi] + #v(30pt) + #line(length: 50pt) +] + +--- issue-place-base --- +// Test that placement is relative to container and not itself. +#set page(height: 80pt, margin: 0pt) +#place(right, dx: -70%, dy: 20%, [First]) +#place(left, dx: 20%, dy: 60%, [Second]) +#place(center + horizon, dx: 25%, dy: 25%, [Third]) + +--- issue-1368-place-pagebreak --- +// Test placing on an already full page. +// It shouldn't result in a page break. +#set page(height: 40pt) +#block(height: 100%) +#place(bottom + right)[Hello world] + +--- issue-2199-place-spacing-bottom --- +// Test that placed elements don't add extra block spacing. +#show figure: set block(spacing: 4em) + +Paragraph before float. +#figure(rect(), placement: bottom) +Paragraph after float. + +--- issue-2199-place-spacing-default --- +#show place: set block(spacing: 4em) + +Paragraph before place. +#place(rect()) +Paragraph after place. |
