diff options
Diffstat (limited to 'tests/suite/layout')
| -rw-r--r-- | tests/suite/layout/container.typ | 6 | ||||
| -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 | ||||
| -rw-r--r-- | tests/suite/layout/grid/grid.typ | 4 | ||||
| -rw-r--r-- | tests/suite/layout/grid/headers.typ | 6 | ||||
| -rw-r--r-- | tests/suite/layout/grid/rowspan.typ | 2 | ||||
| -rw-r--r-- | tests/suite/layout/inline/hyphenate.typ | 4 | ||||
| -rw-r--r-- | tests/suite/layout/page.typ | 12 | ||||
| -rw-r--r-- | tests/suite/layout/place.typ | 253 |
12 files changed, 240 insertions, 293 deletions
diff --git a/tests/suite/layout/container.typ b/tests/suite/layout/container.typ index 2c68099a..9ce3dc7d 100644 --- a/tests/suite/layout/container.typ +++ b/tests/suite/layout/container.typ @@ -98,15 +98,15 @@ Paragraph #set page(height: 100pt) #set align(center) -#lorem(10) +#lines(3) #block(width: 80%, height: 60pt, fill: aqua) -#lorem(6) +#lines(2) #block( breakable: false, width: 100%, inset: 4pt, fill: aqua, - lorem(8) + colbreak(), + lines(3) + colbreak(), ) --- block-consistent-width --- 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. diff --git a/tests/suite/layout/grid/grid.typ b/tests/suite/layout/grid/grid.typ index d35adca5..e56299e7 100644 --- a/tests/suite/layout/grid/grid.typ +++ b/tests/suite/layout/grid/grid.typ @@ -247,8 +247,8 @@ --- issue-grid-skip-list --- #set page(height: 60pt) -#lorem(5) -- #lorem(5) +#lines(2) +- #lines(2) --- issue-grid-double-skip --- // Ensure that the list does not jump to the third page. diff --git a/tests/suite/layout/grid/headers.typ b/tests/suite/layout/grid/headers.typ index c3b92997..cb263376 100644 --- a/tests/suite/layout/grid/headers.typ +++ b/tests/suite/layout/grid/headers.typ @@ -186,7 +186,7 @@ [*Hello*], [*World*] ), - table.cell(rowspan: 3, lorem(40)) + table.cell(rowspan: 3, lines(15)) ) --- grid-header-and-rowspan-non-contiguous-2 --- @@ -201,7 +201,7 @@ [*Hello*], [*World*] ), - table.cell(rowspan: 3, lorem(40)) + table.cell(rowspan: 3, lines(15)) ) --- grid-header-and-rowspan-non-contiguous-3 --- @@ -215,7 +215,7 @@ [*Hello*], [*World*] ), - table.cell(rowspan: 3, lorem(40)) + table.cell(rowspan: 3, lines(15)) ) --- grid-header-lack-of-space --- diff --git a/tests/suite/layout/grid/rowspan.typ b/tests/suite/layout/grid/rowspan.typ index e5c8bbc8..88aa34c6 100644 --- a/tests/suite/layout/grid/rowspan.typ +++ b/tests/suite/layout/grid/rowspan.typ @@ -194,7 +194,7 @@ --- grid-rowspan-unbreakable-2 --- // Test cell breakability #show grid.cell: it => { - assert.eq(it.breakable, (it.x, it.y) != (0, 6) and (it.y in (2, 5, 6) or (it.x, it.y) in ((0, 1), (2, 3), (1, 7)))) + test(it.breakable, (it.x, it.y) != (0, 6) and (it.y in (2, 5, 6) or (it.x, it.y) in ((0, 1), (2, 3), (1, 7)))) it.breakable } #grid( diff --git a/tests/suite/layout/inline/hyphenate.typ b/tests/suite/layout/inline/hyphenate.typ index debce1da..2324ba64 100644 --- a/tests/suite/layout/inline/hyphenate.typ +++ b/tests/suite/layout/inline/hyphenate.typ @@ -164,6 +164,4 @@ el objetivo de protegerle de las patrullas de milicianos. --- costs-access --- #set text(costs: (hyphenation: 1%, runt: 2%)) #set text(costs: (widow: 3%)) -#context { - assert.eq(text.costs, (hyphenation: 1%, runt: 2%, widow: 3%, orphan: 100%)) -} +#context test(text.costs, (hyphenation: 1%, runt: 2%, widow: 3%, orphan: 100%)) diff --git a/tests/suite/layout/page.typ b/tests/suite/layout/page.typ index a4abaec7..b9f41269 100644 --- a/tests/suite/layout/page.typ +++ b/tests/suite/layout/page.typ @@ -152,16 +152,10 @@ } ) -But, soft! what light through yonder window breaks? It is the east, and Juliet -is the sun. Arise, fair sun, and kill the envious moon, Who is already sick and -pale with grief, That thou her maid art far more fair than she: Be not her maid, -since she is envious; Her vestal livery is but sick and green And none but fools -do wear it; cast it off. It is my lady, O, it is my love! O, that she knew she -were! She speaks yet she says nothing: what of that? Her eye discourses; I will -answer it. +#align(center, lines(20)) #set page(header: none, height: auto, margin: (top: 15pt, bottom: 25pt)) -The END. +Z --- page-number-align-top-right --- #set page( @@ -189,7 +183,7 @@ The END. --- page-numbering-pdf-label --- #set page(margin: (bottom: 20pt, rest: 10pt)) -#let filler = lorem(20) +#let filler = lines(7) // (i) - (ii). No style opt. because of suffix. #set page(numbering: "(i)") diff --git a/tests/suite/layout/place.typ b/tests/suite/layout/place.typ deleted file mode 100644 index c29d2ddd..00000000 --- a/tests/suite/layout/place.typ +++ /dev/null @@ -1,253 +0,0 @@ -// Test the `place` function. - ---- place-basic --- -#set page("a8") -#place(bottom + center)[© Typst] - -= Placement -#place(right, image("/assets/images/tiger.jpg", width: 1.8cm)) -Hi there. This is \ -a placed element. \ -Unfortunately, \ -the line breaks still had to be inserted manually. - -#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)[Hello] - #place(center, dx: 7pt, dy: 5pt)[Hello] - Hello #h(1fr) Hello - ] -) - ---- 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-background --- -#set page(paper: "a10", flipped: true) -#set text(fill: white) -#place( - dx: -10pt, - dy: -10pt, - image( - "/assets/images/tiger.jpg", - fit: "cover", - width: 100% + 20pt, - height: 100% + 20pt, - ) -) -#align(bottom + right)[ - _Welcome to_ #underline[*Tigerland*] -] - ---- place-float --- -#set page(height: 140pt) -#set place(clearance: 5pt) -#place(auto, float: true, rect[A]) -#place(auto, float: true, rect[B]) -#lorem(6) -#place(auto, float: true, rect[C]) -#place(auto, float: true, rect[D]) - ---- 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] - ---- place-float-columns --- -// LARGE -#set page(height: 200pt, width: 300pt) -#show: columns.with(2) - -= Introduction -#figure( - placement: bottom, - caption: [A glacier], - image("/assets/images/glacier.jpg", width: 50%), -) -#lorem(45) -#figure( - placement: top, - caption: [A rectangle], - rect[Hello!], -) -#lorem(20) - ---- place-float-figure --- -// LARGE -#set page(height: 250pt, width: 150pt) - -= Introduction -#lorem(10) #footnote[Lots of Latin] - -#figure( - placement: bottom, - caption: [A glacier #footnote[Lots of Ice]], - image("/assets/images/glacier.jpg", width: 80%), -) - -#lorem(40) - -#figure( - placement: top, - caption: [An important], - image("/assets/images/diagram.svg", width: 80%), -) - ---- place-float-flush --- -#set page(height: 150pt, width: 150pt) - -#let floater = place(auto, float: true, rect(width: 100%, height: 90pt, text(size: 24pt)[I float!])) - -Some introductory text. - -#floater #floater #floater #floater - -Some additional text. - -#place.flush() - -Some conclusive text. // Should appear after all the floating figures - ---- place-figure-flush --- - -#set page(height: 165pt, width: 150pt) - -Some introductory text: #lorem(15) - -#figure(placement: auto, caption: [A self-describing figure], rect(width: 100%, height: 64pt, [I float with a caption!])) - -#place.flush() - -Some conclusive text that must occur after the figure. - ---- 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. - ---- issue-2595-float-overlap --- -#set page(height: 80pt) - -Start. - -#place(auto, float: true, [ - #block(height: 100%, width: 100%, fill: aqua) -]) - -#place(auto, float: true, [ - #block(height: 100%, width: 100%, fill: red) -]) - -#lorem(20) - ---- issue-2715-float-order --- -#set page(height: 180pt) -#set figure(placement: auto) - -#figure( - rect(height: 60pt), - caption: [Rectangle I], -) - -#figure( - rect(height: 50pt), - caption: [Rectangle II], -) - -#figure( - circle(), - caption: [Circle], -) - -#lorem(20) |
