diff options
Diffstat (limited to 'tests')
62 files changed, 528 insertions, 136 deletions
diff --git a/tests/ref/block-fr-height-auto-width.png b/tests/ref/block-fr-height-auto-width.png Binary files differnew file mode 100644 index 00000000..21cd3f51 --- /dev/null +++ b/tests/ref/block-fr-height-auto-width.png diff --git a/tests/ref/block-fr-height-first-child.png b/tests/ref/block-fr-height-first-child.png Binary files differnew file mode 100644 index 00000000..0a179576 --- /dev/null +++ b/tests/ref/block-fr-height-first-child.png diff --git a/tests/ref/block-fr-height-multiple.png b/tests/ref/block-fr-height-multiple.png Binary files differnew file mode 100644 index 00000000..f502343c --- /dev/null +++ b/tests/ref/block-fr-height-multiple.png diff --git a/tests/ref/block-fr-height.png b/tests/ref/block-fr-height.png Binary files differnew file mode 100644 index 00000000..657cb43a --- /dev/null +++ b/tests/ref/block-fr-height.png diff --git a/tests/ref/block-sticky-alone.png b/tests/ref/block-sticky-alone.png Binary files differnew file mode 100644 index 00000000..74e30b3b --- /dev/null +++ b/tests/ref/block-sticky-alone.png diff --git a/tests/ref/block-sticky-colbreak.png b/tests/ref/block-sticky-colbreak.png Binary files differnew file mode 100644 index 00000000..a56b25d9 --- /dev/null +++ b/tests/ref/block-sticky-colbreak.png diff --git a/tests/ref/block-sticky-many.png b/tests/ref/block-sticky-many.png Binary files differnew file mode 100644 index 00000000..cdcf291d --- /dev/null +++ b/tests/ref/block-sticky-many.png diff --git a/tests/ref/block-sticky.png b/tests/ref/block-sticky.png Binary files differnew file mode 100644 index 00000000..4f236c89 --- /dev/null +++ b/tests/ref/block-sticky.png diff --git a/tests/ref/box-width-fr.png b/tests/ref/box-fr-width.png Binary files differindex 30d48163..30d48163 100644 --- a/tests/ref/box-width-fr.png +++ b/tests/ref/box-fr-width.png diff --git a/tests/ref/colbreak-weak.png b/tests/ref/colbreak-weak.png Binary files differnew file mode 100644 index 00000000..e2ce5b96 --- /dev/null +++ b/tests/ref/colbreak-weak.png diff --git a/tests/ref/figure-placement.png b/tests/ref/figure-placement.png Binary files differnew file mode 100644 index 00000000..c9ebd2ba --- /dev/null +++ b/tests/ref/figure-placement.png diff --git a/tests/ref/footnote-block-at-end.png b/tests/ref/footnote-block-at-end.png Binary files differnew file mode 100644 index 00000000..86416c48 --- /dev/null +++ b/tests/ref/footnote-block-at-end.png diff --git a/tests/ref/footnote-break-across-pages-block.png b/tests/ref/footnote-break-across-pages-block.png Binary files differnew file mode 100644 index 00000000..ae27b41a --- /dev/null +++ b/tests/ref/footnote-break-across-pages-block.png diff --git a/tests/ref/footnote-break-across-pages-float.png b/tests/ref/footnote-break-across-pages-float.png Binary files differnew file mode 100644 index 00000000..eb5f6f5d --- /dev/null +++ b/tests/ref/footnote-break-across-pages-float.png diff --git a/tests/ref/footnote-break-across-pages-nested.png b/tests/ref/footnote-break-across-pages-nested.png Binary files differnew file mode 100644 index 00000000..49061844 --- /dev/null +++ b/tests/ref/footnote-break-across-pages-nested.png diff --git a/tests/ref/footnote-break-across-pages.png b/tests/ref/footnote-break-across-pages.png Binary files differindex 73a483b2..8e5deabc 100644 --- a/tests/ref/footnote-break-across-pages.png +++ b/tests/ref/footnote-break-across-pages.png diff --git a/tests/ref/footnote-float-priority.png b/tests/ref/footnote-float-priority.png Binary files differnew file mode 100644 index 00000000..26797331 --- /dev/null +++ b/tests/ref/footnote-float-priority.png diff --git a/tests/ref/footnote-in-list.png b/tests/ref/footnote-in-list.png Binary files differnew file mode 100644 index 00000000..504c3578 --- /dev/null +++ b/tests/ref/footnote-in-list.png diff --git a/tests/ref/footnote-in-place.png b/tests/ref/footnote-in-place.png Binary files differnew file mode 100644 index 00000000..d41316db --- /dev/null +++ b/tests/ref/footnote-in-place.png diff --git a/tests/ref/footnote-in-table.png b/tests/ref/footnote-in-table.png Binary files differindex 3f8f50ca..7aa2bbf4 100644 --- a/tests/ref/footnote-in-table.png +++ b/tests/ref/footnote-in-table.png diff --git a/tests/ref/footnote-multiple-in-one-line.png b/tests/ref/footnote-multiple-in-one-line.png Binary files differnew file mode 100644 index 00000000..6f60b609 --- /dev/null +++ b/tests/ref/footnote-multiple-in-one-line.png diff --git a/tests/ref/footnote-nested-same-frame.png b/tests/ref/footnote-nested-same-frame.png Binary files differdeleted file mode 100644 index b22276d5..00000000 --- a/tests/ref/footnote-nested-same-frame.png +++ /dev/null diff --git a/tests/ref/footnote-nested.png b/tests/ref/footnote-nested.png Binary files differindex fecf2e8d..50cc2637 100644 --- a/tests/ref/footnote-nested.png +++ b/tests/ref/footnote-nested.png diff --git a/tests/ref/issue-2213-align-fr.png b/tests/ref/issue-2213-align-fr.png Binary files differnew file mode 100644 index 00000000..66f56d76 --- /dev/null +++ b/tests/ref/issue-2213-align-fr.png diff --git a/tests/ref/issue-3481-cite-location.png b/tests/ref/issue-3481-cite-location.png Binary files differindex cfc13db5..63388bd2 100644 --- a/tests/ref/issue-3481-cite-location.png +++ b/tests/ref/issue-3481-cite-location.png diff --git a/tests/ref/issue-3641-float-loop.png b/tests/ref/issue-3641-float-loop.png Binary files differindex c898d54e..c294c1e4 100644 --- a/tests/ref/issue-3641-float-loop.png +++ b/tests/ref/issue-3641-float-loop.png diff --git a/tests/ref/issue-3866-block-migration.png b/tests/ref/issue-3866-block-migration.png Binary files differnew file mode 100644 index 00000000..6e48f486 --- /dev/null +++ b/tests/ref/issue-3866-block-migration.png diff --git a/tests/ref/issue-footnotes-skip-first-page.png b/tests/ref/issue-footnotes-skip-first-page.png Binary files differindex d24387e3..fd973af7 100644 --- a/tests/ref/issue-footnotes-skip-first-page.png +++ b/tests/ref/issue-footnotes-skip-first-page.png diff --git a/tests/ref/issue-multiple-footnote-in-one-line.png b/tests/ref/issue-multiple-footnote-in-one-line.png Binary files differdeleted file mode 100644 index cdb83af2..00000000 --- a/tests/ref/issue-multiple-footnote-in-one-line.png +++ /dev/null diff --git a/tests/ref/place-float-block-backlog.png b/tests/ref/place-float-block-backlog.png Binary files differnew file mode 100644 index 00000000..c212717e --- /dev/null +++ b/tests/ref/place-float-block-backlog.png diff --git a/tests/ref/place-float-clearance-empty.png b/tests/ref/place-float-clearance-empty.png Binary files differnew file mode 100644 index 00000000..f170df34 --- /dev/null +++ b/tests/ref/place-float-clearance-empty.png diff --git a/tests/ref/place-float-column-align-auto.png b/tests/ref/place-float-column-align-auto.png Binary files differnew file mode 100644 index 00000000..a1dc9203 --- /dev/null +++ b/tests/ref/place-float-column-align-auto.png diff --git a/tests/ref/place-float-in-column-queued.png b/tests/ref/place-float-column-queued.png Binary files differindex 3eeb13dd..3eeb13dd 100644 --- a/tests/ref/place-float-in-column-queued.png +++ b/tests/ref/place-float-column-queued.png diff --git a/tests/ref/place-float-counter.png b/tests/ref/place-float-counter.png Binary files differnew file mode 100644 index 00000000..aa669521 --- /dev/null +++ b/tests/ref/place-float-counter.png diff --git a/tests/ref/place-float-delta.png b/tests/ref/place-float-delta.png Binary files differnew file mode 100644 index 00000000..578d9301 --- /dev/null +++ b/tests/ref/place-float-delta.png diff --git a/tests/ref/place-float-flow-size-alone.png b/tests/ref/place-float-flow-size-alone.png Binary files differnew file mode 100644 index 00000000..e1b6adac --- /dev/null +++ b/tests/ref/place-float-flow-size-alone.png diff --git a/tests/ref/place-float-flow-size.png b/tests/ref/place-float-flow-size.png Binary files differnew file mode 100644 index 00000000..60bbc7cd --- /dev/null +++ b/tests/ref/place-float-flow-size.png diff --git a/tests/ref/place-float-fr.png b/tests/ref/place-float-fr.png Binary files differnew file mode 100644 index 00000000..83d31054 --- /dev/null +++ b/tests/ref/place-float-fr.png diff --git a/tests/ref/place-float-in-column-align-auto.png b/tests/ref/place-float-in-column-align-auto.png Binary files differdeleted file mode 100644 index 58ba9741..00000000 --- a/tests/ref/place-float-in-column-align-auto.png +++ /dev/null diff --git a/tests/ref/place-float-rel-sizing.png b/tests/ref/place-float-rel-sizing.png Binary files differnew file mode 100644 index 00000000..1b4e44b2 --- /dev/null +++ b/tests/ref/place-float-rel-sizing.png diff --git a/tests/ref/place-float-threecolumn-block-backlog.png b/tests/ref/place-float-threecolumn-block-backlog.png Binary files differnew file mode 100644 index 00000000..768d4eda --- /dev/null +++ b/tests/ref/place-float-threecolumn-block-backlog.png diff --git a/tests/ref/place-float-threecolumn.png b/tests/ref/place-float-threecolumn.png Binary files differnew file mode 100644 index 00000000..65ad88ac --- /dev/null +++ b/tests/ref/place-float-threecolumn.png diff --git a/tests/ref/place-float-twocolumn-align-auto.png b/tests/ref/place-float-twocolumn-align-auto.png Binary files differnew file mode 100644 index 00000000..5d9932a3 --- /dev/null +++ b/tests/ref/place-float-twocolumn-align-auto.png diff --git a/tests/ref/place-float-twocolumn-fits-not.png b/tests/ref/place-float-twocolumn-fits-not.png Binary files differnew file mode 100644 index 00000000..e533daf9 --- /dev/null +++ b/tests/ref/place-float-twocolumn-fits-not.png diff --git a/tests/ref/place-float-twocolumn-fits.png b/tests/ref/place-float-twocolumn-fits.png Binary files differnew file mode 100644 index 00000000..07e4c25f --- /dev/null +++ b/tests/ref/place-float-twocolumn-fits.png diff --git a/tests/ref/place-float-twocolumn-queued.png b/tests/ref/place-float-twocolumn-queued.png Binary files differnew file mode 100644 index 00000000..e5fa387d --- /dev/null +++ b/tests/ref/place-float-twocolumn-queued.png diff --git a/tests/ref/place-float-twocolumn.png b/tests/ref/place-float-twocolumn.png Binary files differnew file mode 100644 index 00000000..3ed2f729 --- /dev/null +++ b/tests/ref/place-float-twocolumn.png diff --git a/tests/ref/query-running-header.png b/tests/ref/query-running-header.png Binary files differindex 210c7810..1dd04418 100644 --- a/tests/ref/query-running-header.png +++ b/tests/ref/query-running-header.png diff --git a/tests/skip.txt b/tests/skip.txt new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/skip.txt diff --git a/tests/src/collect.rs b/tests/src/collect.rs index 4dae0b70..cc3ff736 100644 --- a/tests/src/collect.rs +++ b/tests/src/collect.rs @@ -5,6 +5,7 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use ecow::{eco_format, EcoString}; +use once_cell::sync::Lazy; use typst::syntax::package::PackageVersion; use typst::syntax::{is_id_continue, is_ident, is_newline, FileId, Source, VirtualPath}; use unscanny::Scanner; @@ -389,6 +390,18 @@ impl<'a> Parser<'a> { /// Whether a test is within the selected set to run. fn selected(name: &str, abs: PathBuf) -> bool { + static SKIPPED: Lazy<HashSet<&'static str>> = Lazy::new(|| { + String::leak(std::fs::read_to_string(crate::SKIP_PATH).unwrap()) + .lines() + .map(|line| line.trim()) + .filter(|line| !line.is_empty() && !line.starts_with("//")) + .collect() + }); + + if SKIPPED.contains(name) { + return false; + } + let paths = &crate::ARGS.path; if !paths.is_empty() && !paths.iter().any(|path| abs.starts_with(path)) { return false; diff --git a/tests/src/tests.rs b/tests/src/tests.rs index a2d85fec..58bd7cf7 100644 --- a/tests/src/tests.rs +++ b/tests/src/tests.rs @@ -30,6 +30,9 @@ const STORE_PATH: &str = "tests/store"; /// The directory where the reference images are stored. const REF_PATH: &str = "tests/ref"; +/// The file where the skipped tests are stored. +const SKIP_PATH: &str = "tests/skip.txt"; + /// The maximum size of reference images that aren't marked as `// LARGE`. const REF_LIMIT: usize = 20 * 1024; diff --git a/tests/suite/introspection/query.typ b/tests/suite/introspection/query.typ index b078863e..ddb518f5 100644 --- a/tests/suite/introspection/query.typ +++ b/tests/suite/introspection/query.typ @@ -25,10 +25,10 @@ #outline() = Introduction -#v(1cm) +#lines(1) = Background -#v(2cm) +#lines(2) = Approach diff --git a/tests/suite/layout/align.typ b/tests/suite/layout/align.typ index 61b79975..c4ed9ab9 100644 --- a/tests/suite/layout/align.typ +++ b/tests/suite/layout/align.typ @@ -140,3 +140,11 @@ To the right! Where the sunlight peeks behind the mountain. // Test right-aligning a line and a rectangle. #align(right, line(length: 30%)) #align(right, rect()) + +--- issue-2213-align-fr --- +// Test a mix of alignment and fr units (fr wins). +#set page(height: 80pt) +A +#v(1fr) +B +#align(bottom + right)[C] diff --git a/tests/suite/layout/columns.typ b/tests/suite/layout/columns.typ index 87a9f773..b86b798b 100644 --- a/tests/suite/layout/columns.typ +++ b/tests/suite/layout/columns.typ @@ -122,3 +122,10 @@ Hallo = B Text ] + +--- colbreak-weak --- +#set page(columns: 2) +#colbreak(weak: true) +A +#colbreak(weak: true) +B diff --git a/tests/suite/layout/container.typ b/tests/suite/layout/container.typ index 9ce3dc7d..508f1a36 100644 --- a/tests/suite/layout/container.typ +++ b/tests/suite/layout/container.typ @@ -18,10 +18,41 @@ Apart #block(width: 50%, height: 60%, fill: blue) ] ---- box-width-fr --- +--- box-fr-width --- // Test fr box. Hello #box(width: 1fr, rect(height: 0.7em, width: 100%)) World +--- block-fr-height --- +#set page(height: 100pt) +#rect(height: 10pt, width: 100%) +#align(center, block(height: 1fr, width: 20pt, stroke: 1pt)) +#rect(height: 10pt, width: 100%) + +--- block-fr-height-auto-width --- +// Test that the fr block can also expand its parent. +#set page(height: 100pt) +#set align(center) +#block(inset: 5pt, stroke: green)[ + #rect(height: 10pt) + #block(height: 1fr, stroke: 1pt, inset: 5pt)[ + #set align(center + horizon) + I am the widest + ] + #rect(height: 10pt) +] + +--- block-fr-height-first-child --- +// Test that block spacing is not trimmed if only an fr block precedes it. +#set page(height: 100pt) +#rect(height: 1fr) +#rect() + +--- block-fr-height-multiple --- +#set page(height: 100pt) +#rect(height: 1fr) +#rect() +#block(height: 1fr, line(length: 100%, angle: 90deg)) + --- block-multiple-pages --- // Test block over multiple pages. #set page(height: 60pt) @@ -121,6 +152,34 @@ Paragraph #show bibliography: none #bibliography("/assets/bib/works.bib") +--- block-sticky --- +#set page(height: 100pt) +#lines(3) +#block(sticky: true)[D] +#block(sticky: true)[E] +F + +--- block-sticky-alone --- +#set page(height: 50pt) +#block(sticky: true)[A] + +--- block-sticky-many --- +#set page(height: 80pt) +#set block(sticky: true) +#block[A] +#block[B] +#block[C] +#block[D] +E +#block[F] +#block[G] + +--- block-sticky-colbreak --- +A +#block(sticky: true)[B] +#colbreak() +C + --- box-clip-rect --- // Test box clipping with a rectangle Hello #box(width: 1em, height: 1em, clip: false)[#rect(width: 3em, height: 3em, fill: red)] diff --git a/tests/suite/layout/flow/flow.typ b/tests/suite/layout/flow/flow.typ index 88075c5b..fcbc005b 100644 --- a/tests/suite/layout/flow/flow.typ +++ b/tests/suite/layout/flow/flow.typ @@ -55,9 +55,6 @@ --- issue-3641-float-loop --- // Flow layout should terminate! -// -// This is not yet ideal: The heading should not move to the second page, but -// that's a separate bug and not a regression. #set page(height: 40pt) = Heading @@ -69,3 +66,13 @@ #metadata(none) #v(10pt, weak: true) Hi + +--- issue-3866-block-migration --- +#set page(height: 120pt) +#set text(costs: (widow: 0%, orphan: 0%)) +#v(50pt) +#columns(2)[ + #lines(6) + #block(rect(width: 80%, height: 80pt), breakable: false) + #lines(6) +] diff --git a/tests/suite/model/footnote.typ b/tests/suite/layout/flow/footnote.typ index 41091228..f7722e15 100644 --- a/tests/suite/model/footnote.typ +++ b/tests/suite/layout/flow/footnote.typ @@ -9,16 +9,12 @@ A#footnote[A] \ A #footnote[A] --- footnote-nested --- -// Test nested footnotes. -First \ -Second #footnote[A, #footnote[B, #footnote[C]]] \ -Third #footnote[D, #footnote[E]] \ -Fourth - ---- footnote-nested-same-frame --- // Currently, numbers a bit out of order if a nested footnote ends up in the // same frame as another one. :( -#footnote[A, #footnote[B]], #footnote[C] +First \ +Second #footnote[A, #footnote[B, #footnote[C]]] +Third #footnote[D, #footnote[E]] \ +Fourth #footnote[F] --- footnote-entry --- // Test customization. @@ -48,18 +44,94 @@ Beautiful footnotes. #footnote[Wonderful, aren't they?] #lines(6) #footnote[V] // 5 ---- footnote-in-columns --- -// Test footnotes in columns, even those that are not enabled via `set page`. +--- footnote-break-across-pages-block --- +#set page(height: 100pt) +#block[ + #lines(3) #footnote(lines(6, "1")) + #footnote[Y] + #footnote[Z] +] + +--- footnote-break-across-pages-float --- +#set page(height: 180pt) + +#lines(5) + +#place( + bottom, + float: true, + rect(height: 50pt, width: 100%, { + footnote(lines(6, "1")) + footnote(lines(2, "I")) + }) +) + +#lines(5) + +--- footnote-break-across-pages-nested --- #set page(height: 120pt) -#align(center, strong[Title]) +#block[ + #lines(4) + #footnote[ + #lines(6, "1") + #footnote(lines(3, "I")) + ] +] + +--- footnote-in-columns --- +#set page(height: 120pt, columns: 2) + +#place( + top + center, + float: true, + scope: "page", + clearance: 12pt, + strong[Title], +) -#show: columns.with(2) #lines(3) #footnote(lines(4, "1")) #lines(2) #footnote(lines(2, "1")) +--- footnote-in-list --- +#set page(height: 120pt) + +- A #footnote[a] +- B #footnote[b] +- C #footnote[c] +- D #footnote[d] +- E #footnote[e] +- F #footnote[f] +- G #footnote[g] + +--- footnote-block-at-end --- +#set page(height: 50pt) +A +#block(footnote[hello]) + +--- footnote-float-priority --- +#set page(height: 100pt) + +#lines(3) + +#place( + top, + float: true, + rect(height: 40pt) +) + +#block[ + V + #footnote[1] + #footnote[2] + #footnote[3] + #footnote[4] +] + +#lines(5) + --- footnote-in-caption --- // Test footnote in caption. Read the docs #footnote[https://typst.app/docs]! @@ -71,6 +143,15 @@ Read the docs #footnote[https://typst.app/docs]! ) More #footnote[just for ...] footnotes #footnote[... testing. :)] +--- footnote-in-place --- +A +#place(top + right, footnote[A]) +#figure( + placement: bottom, + caption: footnote[B], + rect(), +) + --- footnote-duplicate --- // Test duplicate footnotes. #let lang = footnote[Languages.] @@ -105,6 +186,10 @@ A #footnote(lines(6, "1")) A footnote #footnote[Hi]<fn> \ A reference to it @fn +--- footnote-self-ref --- +// Error: 2-16 footnote cannot reference itself +#footnote(<fn>) <fn> + --- footnote-ref-multiple --- // Multiple footnotes are refs First #footnote[A]<fn1> \ @@ -163,10 +248,7 @@ Ref @fn .map(v => upper(v) + footnote(v)) ) ---- issue-multiple-footnote-in-one-line --- -// Test that the logic that keeps footnote entry together with -// their markers also works for multiple footnotes in a single -// line. +--- footnote-multiple-in-one-line --- #set page(height: 100pt) #v(50pt) A #footnote[a] diff --git a/tests/suite/layout/flow/place-float.typ b/tests/suite/layout/flow/place-float.typ deleted file mode 100644 index 50a8a112..00000000 --- a/tests/suite/layout/flow/place-float.typ +++ /dev/null @@ -1,83 +0,0 @@ ---- 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 deleted file mode 100644 index 8f55a6fd..00000000 --- a/tests/suite/layout/flow/place-flush.typ +++ /dev/null @@ -1,29 +0,0 @@ ---- 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 index f3231735..dc655ec5 100644 --- a/tests/suite/layout/flow/place.typ +++ b/tests/suite/layout/flow/place.typ @@ -70,6 +70,288 @@ Second #line(length: 50pt) ] +--- 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]) +A +#figure(rect(), caption: [IV]) + +--- place-float-align-auto --- +#set page(height: 140pt) +#set place(auto, float: true, clearance: 5pt) + +#place(rect[A]) +#place(rect[B]) +1 \ 2 +#place(rect[C]) +#place(rect[D]) + +--- place-float-delta --- +#place(top + center, float: true, dx: 10pt, rect[I]) +A +#place(bottom + center, float: true, dx: -10pt, rect[II]) + +--- place-float-flow-size --- +#set page(width: auto, height: auto) +#set place(float: true, clearance: 5pt) + +#place(bottom, rect(width: 80pt, height: 10pt)) +#place(top + center, rect(height: 20pt)) +#align(center)[A] +#pagebreak() +#align(center)[B] +#place(bottom, scope: "page", rect(height: 10pt)) + +--- place-float-flow-size-alone --- +#set page(width: auto, height: auto) +#set place(float: true, clearance: 5pt) +#place(auto)[A] + +--- place-float-fr --- +#set page(height: 120pt, columns: 2) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +#place(top + center, rect[I]) +#place(bottom + center, scope: "page", rect[II]) + +A +#v(1fr) +B +#colbreak() +C +#align(bottom)[D] + +--- place-float-rel-sizing --- +#set page(height: 100pt, columns: 2) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +#place(top + center, scope: "page", rect[I]) +#place(top + center, rect[II]) + +// This test result is not ideal: The first column takes 30% of the full page, +// while the second takes 30% of the remaining space since there is no concept +// of `full` for followup pages. +#set align(bottom) +#rect(width: 100%, height: 30%) +#rect(width: 100%, height: 30%) + +--- place-float-block-backlog --- +#set page(height: 100pt) +#v(60pt) +#place(top, float: true, rect()) +#list(.."ABCDEFGHIJ".clusters()) + +--- place-float-clearance-empty --- +// Check that we don't require space for clearance if there is no content. +#set page(height: 100pt) +#v(1fr) +#table( + columns: (1fr, 1fr), + lines(2), + [], + lines(8), + place(auto, float: true, block(width: 100%, height: 100%, fill: aqua)) +) + + +--- place-float-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(rect[VI]) + +--- place-float-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-twocolumn --- +#set page(height: 100pt, columns: 2) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +#place(top + center, scope: "page", rect[I]) +#place(top + center, rect[II]) +#lines(4) +#place(top + center, rect[III]) +#block(width: 100%, height: 70pt, fill: conifer) +#place(bottom + center, scope: "page", rect[IV]) +#place(bottom + center, rect[V]) +#v(1pt, weak: true) +#block(width: 100%, height: 60pt, fill: aqua) + +--- place-float-twocolumn-queued --- +#set page(height: 100pt, columns: 2) +#set place(float: true, scope: "page", clearance: 10pt) +#let t(align, fill) = place(top + align, rect(fill: fill, height: 25pt)) + +#t(left, aqua) +#t(center, forest) +#t(right, conifer) +#lines(7) + +--- place-float-twocolumn-align-auto --- +#set page(height: 100pt, columns: 2) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +#place(auto, scope: "page", rect[I]) // Should end up `top` +#lines(4) +#place(auto, scope: "page", rect[II]) // Should end up `bottom` +#lines(4) + +--- place-float-twocolumn-fits --- +#set page(height: 100pt, columns: 2) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +#lines(6) +#place(auto, scope: "page", rect[I]) +#lines(12, "1") + +--- place-float-twocolumn-fits-not --- +#set page(height: 100pt, columns: 2) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +#lines(10) +#place(auto, scope: "page", rect[I]) +#lines(10, "1") + +--- place-float-threecolumn --- +#set page(height: 100pt, columns: 3) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +#place(bottom + center, scope: "page", rect[I]) +#lines(21) +#place(top + center, scope: "page", rect[II]) + +--- place-float-threecolumn-block-backlog --- +#set page(height: 100pt, columns: 3) +#set place(float: true, clearance: 10pt) +#set rect(width: 70%) + +// The most important part of this test is that we get the backlog of the +// conifer (green) block right. +#place(top + center, scope: "page", rect[I]) +#block(fill: aqua, width: 100%, height: 70pt) +#block(fill: conifer, width: 100%, height: 160pt) +#place(bottom + center, scope: "page", rect[II]) +#place(top, rect(height: 40%)[III]) +#block(fill: yellow, width: 100%, height: 60pt) + +--- place-float-counter --- +#let c = counter("c") +#let cd = context c.display() + +#set page( + height: 100pt, + margin: (y: 20pt), + header: [H: #cd], + footer: [F: #cd], + columns: 2, +) + +#let t(align, scope: "column", n) = place( + align, + float: true, + scope: scope, + clearance: 10pt, + line(length: 100%) + c.update(n), +) + +#t(bottom, 6) +#cd +#t(top, 3) +#colbreak() +#cd +#t(scope: "page", bottom, 11) +#colbreak() +#cd +#t(top, 12) + +--- 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 vertical floating placement must be `auto`, `top`, or `bottom` +#place(center + horizon, float: true)[Hello] + +--- place-float-horizon --- +// Error: 2-36 vertical floating placement must be `auto`, `top`, or `bottom` +#place(horizon, float: true)[Hello] + +--- place-float-default --- +// Error: 2-27 vertical floating placement must be `auto`, `top`, or `bottom` +#place(float: true)[Hello] + +--- place-float-right --- +// Error: 2-34 vertical floating placement must be `auto`, `top`, or `bottom` +#place(right, float: true)[Hello] + +--- 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. + --- issue-place-base --- // Test that placement is relative to container and not itself. #set page(height: 80pt, margin: 0pt) @@ -98,3 +380,11 @@ Paragraph after float. Paragraph before place. #place(rect()) Paragraph after place. + +--- 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/model/cite.typ b/tests/suite/model/cite.typ index ffbd3b52..f69fe9f4 100644 --- a/tests/suite/model/cite.typ +++ b/tests/suite/model/cite.typ @@ -102,8 +102,7 @@ B #cite(<netwok>) #cite(<arrgh>). // Everything moves to the second page because we want to keep the line and // its footnotes together. -#footnote[@netwok] -#footnote[A] +#footnote[@netwok \ A] #show bibliography: none #bibliography("/assets/bib/works.bib") diff --git a/tests/suite/model/figure.typ b/tests/suite/model/figure.typ index 13e94481..d71d92e3 100644 --- a/tests/suite/model/figure.typ +++ b/tests/suite/model/figure.typ @@ -41,6 +41,42 @@ We can clearly see that @fig-cylinder and caption: "A table containing images." ) <fig-image-in-table> +--- figure-placement --- +#set page(height: 160pt, columns: 2) +#set place(clearance: 10pt) + +#lines(4) + +#figure( + placement: auto, + scope: "page", + caption: [I], + rect(height: 15pt, width: 80%), +) + +#figure( + placement: bottom, + caption: [II], + rect(height: 15pt, width: 80%), +) + +#lines(2) + +#figure( + placement: bottom, + caption: [III], + rect(height: 25pt, width: 80%), +) + +#figure( + placement: auto, + scope: "page", + caption: [IV], + rect(width: 80%), +) + +#lines(15) + --- figure-theorem --- // Testing show rules with figures with a simple theorem display #show figure.where(kind: "theorem"): it => { |
