diff --git a/tests/ref/bibliography-full.png b/tests/ref/bibliography-full.png index 1da15d16..6d71f0e7 100644 Binary files a/tests/ref/bibliography-full.png and b/tests/ref/bibliography-full.png differ diff --git a/tests/ref/block-fixed-height.png b/tests/ref/block-fixed-height.png index 95c3be1e..70fe002a 100644 Binary files a/tests/ref/block-fixed-height.png and b/tests/ref/block-fixed-height.png differ diff --git a/tests/ref/counter-page.png b/tests/ref/counter-page.png index be1653eb..7058a98e 100644 Binary files a/tests/ref/counter-page.png and b/tests/ref/counter-page.png differ diff --git a/tests/ref/flow-heading-no-orphan.png b/tests/ref/flow-heading-no-orphan.png index 87789ea1..16b20205 100644 Binary files a/tests/ref/flow-heading-no-orphan.png and b/tests/ref/flow-heading-no-orphan.png differ diff --git a/tests/ref/flow-par-no-orphan-and-widow-lines.png b/tests/ref/flow-par-no-orphan-and-widow-lines.png index cace5d44..2444269f 100644 Binary files a/tests/ref/flow-par-no-orphan-and-widow-lines.png and b/tests/ref/flow-par-no-orphan-and-widow-lines.png differ diff --git a/tests/ref/flow-widow-forced.png b/tests/ref/flow-widow-forced.png index 98a953af..ed25d05d 100644 Binary files a/tests/ref/flow-widow-forced.png and b/tests/ref/flow-widow-forced.png differ diff --git a/tests/ref/footnote-break-across-pages.png b/tests/ref/footnote-break-across-pages.png index 8ec55418..73a483b2 100644 Binary files a/tests/ref/footnote-break-across-pages.png and b/tests/ref/footnote-break-across-pages.png differ diff --git a/tests/ref/footnote-in-columns.png b/tests/ref/footnote-in-columns.png index e16b4ebc..169fa196 100644 Binary files a/tests/ref/footnote-in-columns.png and b/tests/ref/footnote-in-columns.png differ diff --git a/tests/ref/footnote-invariant.png b/tests/ref/footnote-invariant.png index c49c268d..8efb0066 100644 Binary files a/tests/ref/footnote-invariant.png and b/tests/ref/footnote-invariant.png differ diff --git a/tests/ref/gradient-repr.png b/tests/ref/gradient-repr.png deleted file mode 100644 index 04908e59..00000000 Binary files a/tests/ref/gradient-repr.png and /dev/null differ diff --git a/tests/ref/grid-header-and-rowspan-non-contiguous-1.png b/tests/ref/grid-header-and-rowspan-non-contiguous-1.png index d5088a12..1a573f24 100644 Binary files a/tests/ref/grid-header-and-rowspan-non-contiguous-1.png and b/tests/ref/grid-header-and-rowspan-non-contiguous-1.png differ diff --git a/tests/ref/grid-header-and-rowspan-non-contiguous-2.png b/tests/ref/grid-header-and-rowspan-non-contiguous-2.png index 4894d141..335e559b 100644 Binary files a/tests/ref/grid-header-and-rowspan-non-contiguous-2.png and b/tests/ref/grid-header-and-rowspan-non-contiguous-2.png differ diff --git a/tests/ref/grid-header-and-rowspan-non-contiguous-3.png b/tests/ref/grid-header-and-rowspan-non-contiguous-3.png index 36e9a3c3..eb3f3791 100644 Binary files a/tests/ref/grid-header-and-rowspan-non-contiguous-3.png and b/tests/ref/grid-header-and-rowspan-non-contiguous-3.png differ diff --git a/tests/ref/image-jpg.png b/tests/ref/image-jpg.png new file mode 100644 index 00000000..4f9bd201 Binary files /dev/null and b/tests/ref/image-jpg.png differ diff --git a/tests/ref/image-png.png b/tests/ref/image-png.png new file mode 100644 index 00000000..d39374eb Binary files /dev/null and b/tests/ref/image-png.png differ diff --git a/tests/ref/image-rgba-png-and-jpeg.png b/tests/ref/image-rgba-png-and-jpeg.png deleted file mode 100644 index 08372281..00000000 Binary files a/tests/ref/image-rgba-png-and-jpeg.png and /dev/null differ diff --git a/tests/ref/include-file.png b/tests/ref/include-file.png index 57c3aca1..b4ba39d7 100644 Binary files a/tests/ref/include-file.png and b/tests/ref/include-file.png differ diff --git a/tests/ref/issue-1050-terms-indent.png b/tests/ref/issue-1050-terms-indent.png index ca0521c7..1d6a9dfe 100644 Binary files a/tests/ref/issue-1050-terms-indent.png and b/tests/ref/issue-1050-terms-indent.png differ diff --git a/tests/ref/issue-1597-cite-footnote.png b/tests/ref/issue-1597-cite-footnote.png index bdd9f225..d5abf2b0 100644 Binary files a/tests/ref/issue-1597-cite-footnote.png and b/tests/ref/issue-1597-cite-footnote.png differ diff --git a/tests/ref/issue-2595-float-overlap.png b/tests/ref/issue-2595-float-overlap.png index 4b460579..f8b054cf 100644 Binary files a/tests/ref/issue-2595-float-overlap.png and b/tests/ref/issue-2595-float-overlap.png differ diff --git a/tests/ref/issue-2715-float-order.png b/tests/ref/issue-2715-float-order.png deleted file mode 100644 index 01599d25..00000000 Binary files a/tests/ref/issue-2715-float-order.png and /dev/null differ diff --git a/tests/ref/issue-3641-float-loop.png b/tests/ref/issue-3641-float-loop.png index 4490d30a..c898d54e 100644 Binary files a/tests/ref/issue-3641-float-loop.png and b/tests/ref/issue-3641-float-loop.png differ diff --git a/tests/ref/issue-785-cite-locate.png b/tests/ref/issue-785-cite-locate.png index bcdcc968..5c3efe43 100644 Binary files a/tests/ref/issue-785-cite-locate.png and b/tests/ref/issue-785-cite-locate.png differ diff --git a/tests/ref/issue-flow-layout-index-out-of-bounds.png b/tests/ref/issue-flow-layout-index-out-of-bounds.png index 8746cbfc..4f3c3cc4 100644 Binary files a/tests/ref/issue-flow-layout-index-out-of-bounds.png and b/tests/ref/issue-flow-layout-index-out-of-bounds.png differ diff --git a/tests/ref/issue-flow-overlarge-frames.png b/tests/ref/issue-flow-overlarge-frames.png index 016af525..e68688db 100644 Binary files a/tests/ref/issue-flow-overlarge-frames.png and b/tests/ref/issue-flow-overlarge-frames.png differ diff --git a/tests/ref/issue-grid-skip-list.png b/tests/ref/issue-grid-skip-list.png index bd674337..8bc07fcc 100644 Binary files a/tests/ref/issue-grid-skip-list.png and b/tests/ref/issue-grid-skip-list.png differ diff --git a/tests/ref/numbering-chinese.png b/tests/ref/numbering-chinese.png deleted file mode 100644 index 06b31334..00000000 Binary files a/tests/ref/numbering-chinese.png and /dev/null differ diff --git a/tests/ref/numbering-hebrew.png b/tests/ref/numbering-hebrew.png deleted file mode 100644 index d7614225..00000000 Binary files a/tests/ref/numbering-hebrew.png and /dev/null differ diff --git a/tests/ref/numbering-japanese-aiueo.png b/tests/ref/numbering-japanese-aiueo.png deleted file mode 100644 index b06d5c69..00000000 Binary files a/tests/ref/numbering-japanese-aiueo.png and /dev/null differ diff --git a/tests/ref/numbering-japanese-iroha.png b/tests/ref/numbering-japanese-iroha.png deleted file mode 100644 index 2018802f..00000000 Binary files a/tests/ref/numbering-japanese-iroha.png and /dev/null differ diff --git a/tests/ref/numbering-korean.png b/tests/ref/numbering-korean.png deleted file mode 100644 index 281f2ec2..00000000 Binary files a/tests/ref/numbering-korean.png and /dev/null differ diff --git a/tests/ref/numbering-latin.png b/tests/ref/numbering-latin.png deleted file mode 100644 index e154735a..00000000 Binary files a/tests/ref/numbering-latin.png and /dev/null differ diff --git a/tests/ref/numbering-symbol-and-roman.png b/tests/ref/numbering-symbol-and-roman.png deleted file mode 100644 index 979f3b90..00000000 Binary files a/tests/ref/numbering-symbol-and-roman.png and /dev/null differ diff --git a/tests/ref/outline-bookmark.png b/tests/ref/outline-bookmark.png new file mode 100644 index 00000000..e0f2a841 Binary files /dev/null and b/tests/ref/outline-bookmark.png differ diff --git a/tests/ref/outline-indent-numbering.png b/tests/ref/outline-indent-numbering.png index 6c936827..d59c5c6b 100644 Binary files a/tests/ref/outline-indent-numbering.png and b/tests/ref/outline-indent-numbering.png differ diff --git a/tests/ref/outline-styled-text.png b/tests/ref/outline-styled-text.png new file mode 100644 index 00000000..e673b148 Binary files /dev/null and b/tests/ref/outline-styled-text.png differ diff --git a/tests/ref/outline.png b/tests/ref/outline.png index c0d22969..e81eda5c 100644 Binary files a/tests/ref/outline.png and b/tests/ref/outline.png differ diff --git a/tests/ref/page-marginals.png b/tests/ref/page-marginals.png index cab886b3..25746003 100644 Binary files a/tests/ref/page-marginals.png and b/tests/ref/page-marginals.png differ diff --git a/tests/ref/page-numbering-pdf-label.png b/tests/ref/page-numbering-pdf-label.png index a1cae720..7ee3e8ed 100644 Binary files a/tests/ref/page-numbering-pdf-label.png and b/tests/ref/page-numbering-pdf-label.png differ diff --git a/tests/ref/place-background.png b/tests/ref/place-background.png deleted file mode 100644 index e528445e..00000000 Binary files a/tests/ref/place-background.png and /dev/null differ diff --git a/tests/ref/place-basic.png b/tests/ref/place-basic.png index 07845b7d..ae776428 100644 Binary files a/tests/ref/place-basic.png and b/tests/ref/place-basic.png differ diff --git a/tests/ref/place-figure-flush.png b/tests/ref/place-figure-flush.png deleted file mode 100644 index 2e6e0310..00000000 Binary files a/tests/ref/place-figure-flush.png and /dev/null differ diff --git a/tests/ref/place-float-align-auto.png b/tests/ref/place-float-align-auto.png new file mode 100644 index 00000000..e192f26a Binary files /dev/null and b/tests/ref/place-float-align-auto.png differ diff --git a/tests/ref/place-float-columns.png b/tests/ref/place-float-columns.png deleted file mode 100644 index 5bc50c46..00000000 Binary files a/tests/ref/place-float-columns.png and /dev/null differ diff --git a/tests/ref/place-float-figure.png b/tests/ref/place-float-figure.png deleted file mode 100644 index be207154..00000000 Binary files a/tests/ref/place-float-figure.png and /dev/null differ diff --git a/tests/ref/place-float-flow-around.png b/tests/ref/place-float-flow-around.png new file mode 100644 index 00000000..ca53ce22 Binary files /dev/null and b/tests/ref/place-float-flow-around.png differ diff --git a/tests/ref/place-float-flush.png b/tests/ref/place-float-flush.png deleted file mode 100644 index 67c01c2c..00000000 Binary files a/tests/ref/place-float-flush.png and /dev/null differ diff --git a/tests/ref/place-float-in-column-align-auto.png b/tests/ref/place-float-in-column-align-auto.png new file mode 100644 index 00000000..58ba9741 Binary files /dev/null and b/tests/ref/place-float-in-column-align-auto.png differ diff --git a/tests/ref/place-float-in-column-queued.png b/tests/ref/place-float-in-column-queued.png new file mode 100644 index 00000000..3eeb13dd Binary files /dev/null and b/tests/ref/place-float-in-column-queued.png differ diff --git a/tests/ref/place-float-queued.png b/tests/ref/place-float-queued.png new file mode 100644 index 00000000..0f1446d3 Binary files /dev/null and b/tests/ref/place-float-queued.png differ diff --git a/tests/ref/place-float.png b/tests/ref/place-float.png deleted file mode 100644 index ddd49c47..00000000 Binary files a/tests/ref/place-float.png and /dev/null differ diff --git a/tests/ref/place-flush-figure.png b/tests/ref/place-flush-figure.png new file mode 100644 index 00000000..625c370b Binary files /dev/null and b/tests/ref/place-flush-figure.png differ diff --git a/tests/ref/place-flush.png b/tests/ref/place-flush.png new file mode 100644 index 00000000..bee684f5 Binary files /dev/null and b/tests/ref/place-flush.png differ diff --git a/tests/ref/query-and-or.png b/tests/ref/query-and-or.png deleted file mode 100644 index 39cfd076..00000000 Binary files a/tests/ref/query-and-or.png and /dev/null differ diff --git a/tests/ref/query-before-after.png b/tests/ref/query-before-after.png deleted file mode 100644 index 32b59573..00000000 Binary files a/tests/ref/query-before-after.png and /dev/null differ diff --git a/tests/ref/quote-block-spacing.png b/tests/ref/quote-block-spacing.png index 3efae5ab..f02c6519 100644 Binary files a/tests/ref/quote-block-spacing.png and b/tests/ref/quote-block-spacing.png differ diff --git a/tests/ref/raw-align-default.png b/tests/ref/raw-align-default.png index 84c51229..9c24ac35 100644 Binary files a/tests/ref/raw-align-default.png and b/tests/ref/raw-align-default.png differ diff --git a/tests/ref/raw-align-specified.png b/tests/ref/raw-align-specified.png index 18b48dec..d1be8677 100644 Binary files a/tests/ref/raw-align-specified.png and b/tests/ref/raw-align-specified.png differ diff --git a/tests/ref/raw-highlight-cpp.png b/tests/ref/raw-highlight-cpp.png new file mode 100644 index 00000000..f043f9cf Binary files /dev/null and b/tests/ref/raw-highlight-cpp.png differ diff --git a/tests/ref/raw-highlight-html.png b/tests/ref/raw-highlight-html.png new file mode 100644 index 00000000..e20fba12 Binary files /dev/null and b/tests/ref/raw-highlight-html.png differ diff --git a/tests/ref/raw-highlight-py.png b/tests/ref/raw-highlight-py.png new file mode 100644 index 00000000..32c3dd75 Binary files /dev/null and b/tests/ref/raw-highlight-py.png differ diff --git a/tests/ref/raw-highlight-rust.png b/tests/ref/raw-highlight-rust.png new file mode 100644 index 00000000..0576a6d5 Binary files /dev/null and b/tests/ref/raw-highlight-rust.png differ diff --git a/tests/ref/raw-highlight-typ.png b/tests/ref/raw-highlight-typ.png index f80bbf89..7f9cd093 100644 Binary files a/tests/ref/raw-highlight-typ.png and b/tests/ref/raw-highlight-typ.png differ diff --git a/tests/ref/raw-highlight-typc.png b/tests/ref/raw-highlight-typc.png new file mode 100644 index 00000000..25f5b25c Binary files /dev/null and b/tests/ref/raw-highlight-typc.png differ diff --git a/tests/ref/raw-highlight-typm.png b/tests/ref/raw-highlight-typm.png new file mode 100644 index 00000000..016a3e7a Binary files /dev/null and b/tests/ref/raw-highlight-typm.png differ diff --git a/tests/ref/raw-highlight.png b/tests/ref/raw-highlight.png deleted file mode 100644 index 2f99b450..00000000 Binary files a/tests/ref/raw-highlight.png and /dev/null differ diff --git a/tests/ref/repr-color.png b/tests/ref/repr-color.png deleted file mode 100644 index 3425f7d4..00000000 Binary files a/tests/ref/repr-color.png and /dev/null differ diff --git a/tests/ref/repr-literals.png b/tests/ref/repr-literals.png deleted file mode 100644 index 1e8e85a4..00000000 Binary files a/tests/ref/repr-literals.png and /dev/null differ diff --git a/tests/ref/repr-misc.png b/tests/ref/repr-misc.png deleted file mode 100644 index 699cb561..00000000 Binary files a/tests/ref/repr-misc.png and /dev/null differ diff --git a/tests/ref/repr-numerical.png b/tests/ref/repr-numerical.png deleted file mode 100644 index 1c109a22..00000000 Binary files a/tests/ref/repr-numerical.png and /dev/null differ diff --git a/tests/ref/show-bare-basic.png b/tests/ref/show-bare-basic.png index e389b506..1ce34671 100644 Binary files a/tests/ref/show-bare-basic.png and b/tests/ref/show-bare-basic.png differ diff --git a/tests/ref/smartquote-de-ch.png b/tests/ref/smartquote-de-ch.png new file mode 100644 index 00000000..eed0f1dd Binary files /dev/null and b/tests/ref/smartquote-de-ch.png differ diff --git a/tests/ref/smartquote-de.png b/tests/ref/smartquote-de.png new file mode 100644 index 00000000..d287887b Binary files /dev/null and b/tests/ref/smartquote-de.png differ diff --git a/tests/ref/smartquote-es-mx.png b/tests/ref/smartquote-es-mx.png new file mode 100644 index 00000000..e6b6ecb3 Binary files /dev/null and b/tests/ref/smartquote-es-mx.png differ diff --git a/tests/ref/smartquote-es.png b/tests/ref/smartquote-es.png new file mode 100644 index 00000000..c44fa6bd Binary files /dev/null and b/tests/ref/smartquote-es.png differ diff --git a/tests/ref/smartquote-fi.png b/tests/ref/smartquote-fi.png new file mode 100644 index 00000000..39bb1787 Binary files /dev/null and b/tests/ref/smartquote-fi.png differ diff --git a/tests/ref/smartquote-fr.png b/tests/ref/smartquote-fr.png new file mode 100644 index 00000000..9decdcf7 Binary files /dev/null and b/tests/ref/smartquote-fr.png differ diff --git a/tests/ref/smartquote-gr.png b/tests/ref/smartquote-gr.png new file mode 100644 index 00000000..c612d6d5 Binary files /dev/null and b/tests/ref/smartquote-gr.png differ diff --git a/tests/ref/smartquote-he.png b/tests/ref/smartquote-he.png new file mode 100644 index 00000000..65aa0127 Binary files /dev/null and b/tests/ref/smartquote-he.png differ diff --git a/tests/ref/smartquote-it.png b/tests/ref/smartquote-it.png new file mode 100644 index 00000000..2aea5609 Binary files /dev/null and b/tests/ref/smartquote-it.png differ diff --git a/tests/ref/smartquote-la.png b/tests/ref/smartquote-la.png new file mode 100644 index 00000000..6bcafcb4 Binary files /dev/null and b/tests/ref/smartquote-la.png differ diff --git a/tests/ref/smartquote-ro.png b/tests/ref/smartquote-ro.png new file mode 100644 index 00000000..ac15e8d9 Binary files /dev/null and b/tests/ref/smartquote-ro.png differ diff --git a/tests/ref/smartquote-ru.png b/tests/ref/smartquote-ru.png new file mode 100644 index 00000000..62a1f619 Binary files /dev/null and b/tests/ref/smartquote-ru.png differ diff --git a/tests/ref/smartquote.png b/tests/ref/smartquote.png index 4adf3185..45968e2a 100644 Binary files a/tests/ref/smartquote.png and b/tests/ref/smartquote.png differ diff --git a/tests/ref/state-nested.png b/tests/ref/state-nested.png index cc701600..ac0e6635 100644 Binary files a/tests/ref/state-nested.png and b/tests/ref/state-nested.png differ diff --git a/tests/src/args.rs b/tests/src/args.rs index b3441e90..786733cc 100644 --- a/tests/src/args.rs +++ b/tests/src/args.rs @@ -75,4 +75,6 @@ impl CliArguments { pub enum Command { /// Clears the on-disk test artifact store. Clean, + /// Deletes all dangling reference images. + Undangle, } diff --git a/tests/src/collect.rs b/tests/src/collect.rs index f10f4a2e..4dae0b70 100644 --- a/tests/src/collect.rs +++ b/tests/src/collect.rs @@ -408,8 +408,8 @@ fn selected(name: &str, abs: PathBuf) -> bool { /// An error in a test file. pub struct TestParseError { - pos: FilePos, - message: String, + pub pos: FilePos, + pub message: String, } impl Display for TestParseError { diff --git a/tests/src/run.rs b/tests/src/run.rs index f356f0d0..b09b3eaf 100644 --- a/tests/src/run.rs +++ b/tests/src/run.rs @@ -431,7 +431,7 @@ fn skippable_frame(frame: &Frame) -> bool { }) } -/// Whether to pixel images are approximately equal. +/// Whether two pixel images are approximately equal. fn approx_equal(a: &sk::Pixmap, b: &sk::Pixmap) -> bool { a.width() == b.width() && a.height() == b.height() diff --git a/tests/src/tests.rs b/tests/src/tests.rs index 8558abb6..a2d85fec 100644 --- a/tests/src/tests.rs +++ b/tests/src/tests.rs @@ -38,7 +38,8 @@ fn main() { match &ARGS.command { None => test(), - Some(Command::Clean) => std::fs::remove_dir_all(STORE_PATH).unwrap(), + Some(Command::Clean) => clean(), + Some(Command::Undangle) => undangle(), } } @@ -120,3 +121,21 @@ fn test() { std::process::exit(1); } } + +fn clean() { + std::fs::remove_dir_all(STORE_PATH).unwrap(); +} + +fn undangle() { + match crate::collect::collect() { + Ok(_) => eprintln!("no danging reference images"), + Err(errors) => { + for error in errors { + if error.message == "dangling reference image" { + std::fs::remove_file(&error.pos.path).unwrap(); + eprintln!("✅ deleted {}", error.pos.path.display()); + } + } + } + } +} diff --git a/tests/src/world.rs b/tests/src/world.rs index 799527fa..f5e49ba6 100644 --- a/tests/src/world.rs +++ b/tests/src/world.rs @@ -3,13 +3,19 @@ use std::collections::HashMap; use std::fs; use std::io::Write; use std::path::{Path, PathBuf}; +use std::str::FromStr; use std::sync::OnceLock; +use comemo::Tracked; use parking_lot::Mutex; -use typst::diag::{bail, FileError, FileResult, StrResult}; -use typst::foundations::{func, Bytes, Datetime, NoneValue, Repr, Smart, Value}; +use typst::diag::{bail, At, FileError, FileResult, SourceResult, StrResult}; +use typst::engine::Engine; +use typst::foundations::{ + func, Array, Bytes, Context, Datetime, IntoValue, NoneValue, Repr, Smart, Value, +}; use typst::layout::{Abs, Margin, PageElem}; -use typst::syntax::{FileId, Source}; +use typst::model::{Numbering, NumberingPattern}; +use typst::syntax::{FileId, Source, Span}; use typst::text::{Font, FontBook, TextElem, TextSize}; use typst::utils::{singleton, LazyHash}; use typst::visualize::Color; @@ -176,40 +182,11 @@ fn library() -> Library { // that it multiplies to nice round numbers. let mut lib = Library::default(); - #[func] - fn test(lhs: Value, rhs: Value) -> StrResult { - if lhs != rhs { - bail!("Assertion failed: {} != {}", lhs.repr(), rhs.repr()); - } - Ok(NoneValue) - } - - #[func] - fn test_repr(lhs: Value, rhs: Value) -> StrResult { - if lhs.repr() != rhs.repr() { - bail!("Assertion failed: {} != {}", lhs.repr(), rhs.repr()); - } - Ok(NoneValue) - } - - #[func] - fn print(#[variadic] values: Vec) -> NoneValue { - let mut out = std::io::stdout().lock(); - write!(out, "> ").unwrap(); - for (i, value) in values.into_iter().enumerate() { - if i > 0 { - write!(out, ", ").unwrap(); - } - write!(out, "{value:?}").unwrap(); - } - writeln!(out).unwrap(); - NoneValue - } - // Hook up helpers into the global scope. lib.global.scope_mut().define_func::(); lib.global.scope_mut().define_func::(); lib.global.scope_mut().define_func::(); + lib.global.scope_mut().define_func::(); lib.global .scope_mut() .define("conifer", Color::from_u8(0x9f, 0xEB, 0x52, 0xFF)); @@ -228,3 +205,50 @@ fn library() -> Library { lib } + +#[func] +fn test(lhs: Value, rhs: Value) -> StrResult { + if lhs != rhs { + bail!("Assertion failed: {} != {}", lhs.repr(), rhs.repr()); + } + Ok(NoneValue) +} + +#[func] +fn test_repr(lhs: Value, rhs: Value) -> StrResult { + if lhs.repr() != rhs.repr() { + bail!("Assertion failed: {} != {}", lhs.repr(), rhs.repr()); + } + Ok(NoneValue) +} + +#[func] +fn print(#[variadic] values: Vec) -> NoneValue { + let mut out = std::io::stdout().lock(); + write!(out, "> ").unwrap(); + for (i, value) in values.into_iter().enumerate() { + if i > 0 { + write!(out, ", ").unwrap(); + } + write!(out, "{value:?}").unwrap(); + } + writeln!(out).unwrap(); + NoneValue +} + +/// Generates `count` lines of text based on the numbering. +#[func] +fn lines( + engine: &mut Engine, + context: Tracked, + span: Span, + count: usize, + #[default(Numbering::Pattern(NumberingPattern::from_str("A").unwrap()))] + numbering: Numbering, +) -> SourceResult { + (1..=count) + .map(|n| numbering.apply(engine, context, &[n])) + .collect::>()? + .join(Some('\n'.into_value()), None) + .at(span) +} diff --git a/tests/suite/foundations/dict.typ b/tests/suite/foundations/dict.typ index d75b9162..c1cf3f21 100644 --- a/tests/suite/foundations/dict.typ +++ b/tests/suite/foundations/dict.typ @@ -176,10 +176,10 @@ #let c = "value" #let d = "conflict" -#assert.eq(((a): b), ("hello": "world")) -#assert.eq(((a): 1, (a): 2), ("hello": 2)) -#assert.eq((hello: 1, (a): 2), ("hello": 2)) -#assert.eq((a + b: c, (a + b): d, (a): "value2", a: "value3"), ("helloworld": "conflict", "hello": "value2", "a": "value3")) +#test(((a): b), ("hello": "world")) +#test(((a): 1, (a): 2), ("hello": 2)) +#test((hello: 1, (a): 2), ("hello": 2)) +#test((a + b: c, (a + b): d, (a): "value2", a: "value3"), ("helloworld": "conflict", "hello": "value2", "a": "value3")) --- issue-1338-dictionary-underscore --- #let foo = "foo" diff --git a/tests/suite/foundations/repr.typ b/tests/suite/foundations/repr.typ index 7f03209b..36823e98 100644 --- a/tests/suite/foundations/repr.typ +++ b/tests/suite/foundations/repr.typ @@ -1,57 +1,90 @@ --- repr --- -#test(repr(ltr), "ltr") -#test(repr((1, 2, false, )), "(1, 2, false)") +#let t(a, b) = test(repr(a), b.text) ---- repr-literals --- // Literal values. -#auto \ -#none (empty) \ -#true \ -#false +#t(auto, `auto`) +#t(true, `true`) +#t(false, `false`) ---- repr-numerical --- // Numerical values. -#1 \ -#1.0e-4 \ -#3.15 \ -#1e-10 \ -#50.368% \ -#0.0000012345pt \ -#4.5cm \ -#12e1pt \ -#2.5rad \ -#45deg \ -#1.7em \ -#(1cm + 0em) \ -#(2em + 10pt) \ -#(100% + (2em + 2pt)) \ -#(100% + 0pt) \ -#(100% - 2em + 2pt) \ -#(100% - 2pt) \ -#2.3fr - ---- repr-misc --- -// Colors and strokes. -#set text(0.8em) -#rgb("f7a205") \ -#(2pt + rgb("f7a205")) +#t(12.0, `12.0`) +#t(3.14, `3.14`) +#t(1234567890.0, `1234567890.0`) +#t(0123456789.0, `123456789.0`) +#t(0.0, `0.0`) +#t(-0.0, `-0.0`) +#t(-1.0, `-1.0`) +#t(-9876543210.0, `-9876543210.0`) +#t(-0987654321.0, `-987654321.0`) +#t(-3.14, `-3.14`) +#t(4.0 - 8.0, `-4.0`) +#t(float.inf, `float.inf`) +#t(-float.inf, `-float.inf`) +#t(float.nan, `float.nan`) // Strings and escaping. -#raw(repr("hi"), lang: "typc") -#repr("a\n[]\"\u{1F680}string") +#t("hi", `"hi"`) +#t("a\n[]\"\u{1F680}string", `"a\n[]\"🚀string"`) -// Content. -#raw(lang: "typc", repr[*Hey*]) \ -#raw(lang: "typc", repr[A _sequence_]) \ -#raw(lang: "typc", repr[A _longer_ *sequence*!]) +// Array and dictionary. +#t((1, 2, false, ), `(1, 2, false)`) +#t((a: 1, b: "2"), `(a: 1, b: "2")`) // Functions. #let f(x) = x -#f \ -#rect \ -#(() => none) +#t(f, `f`) +#t(rect , `rect`) +#t(() => none, `(..) => ..`) // Types. -#int \ -#type("hi") \ -#type((a: 1)) +#t(int, `integer`) +#t(type("hi"), `string`) +#t(type((a: 1)), `dictionary`) + +// Constants. +#t(ltr, `ltr`) +#t(left, `left`) + +// Content. +#t([*Hey*], `strong(body: [Hey])`) +#t([A _sequence_], `sequence([A], [ ], emph(body: [sequence]))`) +#t([A _longer_ *sequence*!], ``` +sequence( + [A], + [ ], + emph(body: [longer]), + [ ], + strong(body: [sequence]), + [!], +) +```) + +// Colors and strokes. +#t(rgb("f7a205"), `rgb("#f7a205")`) +#t(2pt + rgb("f7a205"), `2pt + rgb("#f7a205")`) +#t(blue, `rgb("#0074d9")`) +#t(color.linear-rgb(blue), `color.linear-rgb(0%, 17.46%, 69.39%)`) +#t(oklab(blue), `oklab(56.22%, -0.05, -0.17)`) +#t(oklch(blue), `oklch(56.22%, 0.177, 253.71deg)`) +#t(cmyk(blue), `cmyk(100%, 46.54%, 0%, 14.9%)`) +#t(color.hsl(blue), `color.hsl(207.93deg, 100%, 42.55%)`) +#t(color.hsv(blue), `color.hsv(207.93deg, 100%, 85.1%)`) +#t(luma(blue), `luma(45.53%)`) + +// Gradients. +#t( + gradient.linear(blue, red), + `gradient.linear((rgb("#0074d9"), 0%), (rgb("#ff4136"), 100%))`, +) +#t( + gradient.linear(blue, red, dir: ttb), + `gradient.linear(dir: rtl, (rgb("#0074d9"), 0%), (rgb("#ff4136"), 100%))`, +) +#t( + gradient.linear(blue, red, relative: "self", angle: 45deg), + `gradient.linear(angle: 45deg, relative: "self", (rgb("#0074d9"), 0%), (rgb("#ff4136"), 100%))`, +) +#t( + gradient.linear(blue, red, space: rgb, angle: 45deg), + `gradient.linear(angle: 45deg, space: rgb, (rgb("#0074d9"), 0%), (rgb("#ff4136"), 100%))`, +) diff --git a/tests/suite/introspection/counter.typ b/tests/suite/introspection/counter.typ index 8cae32a4..e97f05dd 100644 --- a/tests/suite/introspection/counter.typ +++ b/tests/suite/introspection/counter.typ @@ -54,13 +54,13 @@ At Beta, it was #context { --- counter-page --- #set page(height: 50pt, margin: (bottom: 20pt, rest: 10pt)) -#lorem(12) +#lines(4) #set page(numbering: "(i)") -#lorem(6) +#lines(2) #pagebreak() #set page(numbering: "1 / 1") #counter(page).update(1) -#lorem(20) +#lines(7) --- counter-page-footer-before-set-page --- #set page(numbering: "1", margin: (bottom: 20pt)) diff --git a/tests/suite/introspection/query.typ b/tests/suite/introspection/query.typ index 3d71529e..b078863e 100644 --- a/tests/suite/introspection/query.typ +++ b/tests/suite/introspection/query.typ @@ -72,80 +72,11 @@ caption: [Tetrahedron], ) ---- query-before-after --- -// LARGE -#set page( - paper: "a7", - numbering: "1 / 1", - margin: (bottom: 1cm, rest: 0.5cm), -) - -#show heading.where(level: 1, outlined: true): it => [ - #it - - #set text(size: 12pt, weight: "regular") - #outline( - title: none, - indent: true, - target: heading - .where(level: 1) - .or(heading.where(level: 2)) - .after(it.location(), inclusive: true) - .before( - heading - .where(level: 1, outlined: true) - .after(it.location(), inclusive: false), - inclusive: false, - ) - ) -] - -#set heading(outlined: true, numbering: "1.") - -= Section 1 -== Subsection 1 -== Subsection 2 -=== Subsubsection 1 -=== Subsubsection 2 -== Subsection 3 - -= Section 2 -== Subsection 1 -== Subsection 2 - -= Section 3 -== Subsection 1 -== Subsection 2 -=== Subsubsection 1 -=== Subsubsection 2 -=== Subsubsection 3 -== Subsection 3 - ---- query-and-or --- -#set page( - paper: "a7", - numbering: "1 / 1", - margin: (bottom: 1cm, rest: 0.5cm), -) - -#set heading(outlined: true, numbering: "1.") - -#context [ - Non-outlined elements: - #(query(selector(heading).and(heading.where(outlined: false))) - .map(it => it.body).join(", ")) -] - -#heading("A", outlined: false) -#heading("B", outlined: true) -#heading("C", outlined: true) -#heading("D", outlined: false) - --- query-complex --- = A == B #figure([Cat], kind: "cat", supplement: [Other]) -=== D +#heading(level: 3, outlined: false)[D] = E #figure([Frog], kind: "frog", supplement: none) #figure([Giraffe], kind: "giraffe", supplement: none) @@ -164,6 +95,11 @@ ([A], [D], [E], [H]), ) +#test-selector( + selector(heading).and(heading.where(outlined: false)), + ([D],) +) + #test-selector( heading.where(level: 1).or( heading.where(level: 3), diff --git a/tests/suite/introspection/state.typ b/tests/suite/introspection/state.typ index 208a4ea2..bb5f1a41 100644 --- a/tests/suite/introspection/state.typ +++ b/tests/suite/introspection/state.typ @@ -28,7 +28,7 @@ Was: #context { #set page(width: 200pt) #set text(8pt) -#let ls = state("lorem", lorem(1000).split(".")) +#let ls = state("lorem", lorem(30).split(" ")) #let loremum(count) = { context ls.get().slice(0, count).join(".").trim() + "." ls.update(list => list.slice(count)) 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) diff --git a/tests/suite/model/bibliography.typ b/tests/suite/model/bibliography.typ index 18c62620..20eb8acd 100644 --- a/tests/suite/model/bibliography.typ +++ b/tests/suite/model/bibliography.typ @@ -44,9 +44,8 @@ Now we have multiple bibliographies containing @glacier-melt @keshav2007read #bibliography("/assets/bib/works.bib") --- bibliography-full --- -// LARGE -#set page(paper: "a6", height: 170mm) -#bibliography("/assets/bib/works.bib", full: true) +#set page(paper: "a6", height: auto) +#bibliography("/assets/bib/works_too.bib", full: true) --- bibliography-math --- #set page(width: 200pt) diff --git a/tests/suite/model/cite.typ b/tests/suite/model/cite.typ index 750db38b..ffbd3b52 100644 --- a/tests/suite/model/cite.typ +++ b/tests/suite/model/cite.typ @@ -52,10 +52,10 @@ A @netwok @arrgh @quark, B. --- issue-785-cite-locate --- // Test citation in other introspection. #set page(width: 180pt) -#set heading(numbering: "1") +#set heading(numbering: "1.") #outline( - title: [List of Figures], + title: [Figures], target: figure.where(kind: image), ) @@ -63,20 +63,20 @@ A @netwok @arrgh @quark, B. = Introduction #figure( - rect[-- PIRATE --], + rect(height: 10pt), caption: [A pirate @arrgh in @intro], ) #context [Citation @distress on page #here().page()] -#pagebreak() +#show bibliography: none #bibliography("/assets/bib/works.bib", style: "chicago-notes") --- issue-1597-cite-footnote --- // Tests that when a citation footnote is pushed to next page, things still // work as expected. #set page(height: 60pt) -#lorem(4) +A #footnote[@netwok] #show bibliography: none diff --git a/tests/suite/model/footnote.typ b/tests/suite/model/footnote.typ index 99372551..41091228 100644 --- a/tests/suite/model/footnote.typ +++ b/tests/suite/model/footnote.typ @@ -34,28 +34,31 @@ Fourth Beautiful footnotes. #footnote[Wonderful, aren't they?] --- footnote-break-across-pages --- -// LARGE #set page(height: 200pt) -#lorem(5) +#lines(2) #footnote[ // 1 - A simple footnote. - #footnote[Well, not that simple ...] // 2 + I + #footnote[II ...] // 2 ] -#lorem(15) -#footnote[Another footnote: #lorem(30)] // 3 -#lorem(15) -#footnote[My fourth footnote: #lorem(50)] // 4 -#lorem(15) -#footnote[And a final footnote.] // 5 +#lines(6) +#footnote[III: #lines(8, "1")] // 3 +#lines(6) +#footnote[IV: #lines(15, "1")] // 4 +#lines(6) +#footnote[V] // 5 --- footnote-in-columns --- // Test footnotes in columns, even those that are not enabled via `set page`. #set page(height: 120pt) #align(center, strong[Title]) + #show: columns.with(2) -#lorem(3) #footnote(lorem(6)) -Hello there #footnote(lorem(2)) +#lines(3) +#footnote(lines(4, "1")) + +#lines(2) +#footnote(lines(2, "1")) --- footnote-in-caption --- // Test footnote in caption. @@ -93,9 +96,9 @@ More #footnote[just for ...] footnotes #footnote[... testing. :)] // always end up on the same page. #set page(height: 120pt) -#lorem(13) +#lines(5) -There #footnote(lorem(20)) +A #footnote(lines(6, "1")) --- footnote-ref --- // Test references to footnotes. diff --git a/tests/suite/model/numbering.typ b/tests/suite/model/numbering.typ index 55c24f65..93c9e1b3 100644 --- a/tests/suite/model/numbering.typ +++ b/tests/suite/model/numbering.typ @@ -1,120 +1,58 @@ // Test integrated numbering patterns. ---- numbering-symbol-and-roman --- -#for i in range(0, 9) { - numbering("*", i) - [ and ] - numbering("I.a", i, i) - [ for #i \ ] +--- numbering --- +#let t(pat: "1", step: 1, ..vals) = { + let num = 0 + for val in vals.pos() { + if type(val) == int { + num = val + } else { + test(numbering(pat, num), val) + num += step + } + } } ---- numbering-latin --- -#for i in range(0, 4) { - numbering("A", i) - [ for #i \ ] -} -... \ -#for i in range(26, 30) { - numbering("A", i) - [ for #i \ ] -} -... \ -#for i in range(702, 706) { - numbering("A", i) - [ for #i \ ] -} +// Arabic. +#t(pat: "1", "0", "1", "2", "3", "4", "5", "6", 107, "107", "108") ---- numbering-hebrew --- -#set text(lang: "he") -#for i in range(9, 21, step: 2) { - numbering("א.", i) - [ עבור #i \ ] -} +// Symbols. +#t(pat: "*", "-", "*", "†", "‡", "§", "¶", "‖", "**") ---- numbering-chinese --- -#set text(lang: "zh", font: ("Linux Libertine", "Noto Serif CJK SC")) -#for i in range(9, 21, step: 2){ - numbering("一", i) - [ and ] - numbering("壹", i) - [ for #i \ ] -} +// Hebrew. +#t(pat: "א", step: 2, 9, "ט׳", "י״א", "י״ג") ---- numbering-japanese-iroha --- -#set text(lang: "ja", font: ("Linux Libertine", "Noto Serif CJK JP")) -#for i in range(0, 4) { - numbering("イ", i) - [ (or ] - numbering("い", i) - [) for #i \ ] -} -... \ -#for i in range(47, 51) { - numbering("イ", i) - [ (or ] - numbering("い", i) - [) for #i \ ] -} -... \ -#for i in range(2256, 2260) { - numbering("イ", i) - [ for #i \ ] -} +// Chinese. +#t(pat: "一", step: 2, 9, "九", "十一", "十三", "十五", "十七", "十九") +#t(pat: "壹", step: 2, 9, "玖", "拾壹", "拾叁", "拾伍", "拾柒", "拾玖") ---- numbering-korean --- -#set text(lang: "ko", font: ("Linux Libertine", "Noto Serif CJK KR")) -#for i in range(0, 4) { - numbering("가", i) - [ (or ] - numbering("ㄱ", i) - [) for #i \ ] -} -... \ -#for i in range(47, 51) { - numbering("가", i) - [ (or ] - numbering("ㄱ", i) - [) for #i \ ] -} -... \ -#for i in range(2256, 2260) { - numbering("ㄱ", i) - [ for #i \ ] -} +// Japanese. +#t(pat: "イ", "-", "イ", "ロ", "ハ", 47, "ス", "イイ", "イロ", "イハ", 2256, "スス", "イイイ") +#t(pat: "い", "-", "い", "ろ", "は", 47, "す", "いい", "いろ", "いは") +#t(pat: "あ", "-", "あ", "い", "う", "え", "お", "か", "き", "く") +#t(pat: "ア", "-", "ア", "イ", "ウ", "エ", "オ", "カ", "キ", "ク") ---- numbering-japanese-aiueo --- -#set text(lang: "jp", font: ("Linux Libertine", "Noto Serif CJK JP")) -#for i in range(0, 9) { - numbering("あ", i) - [ and ] - numbering("I.あ", i, i) - [ for #i \ ] -} +// Korean. +#t(pat: "가", "-", "가", "나", "다", 47, "다마", "다바", "다사", "다아") +#t(pat: "ㄱ", "-", "ㄱ", "ㄴ", "ㄷ", 47, "ㄷㅁ") -#for i in range(0, 9) { - numbering("ア", i) - [ and ] - numbering("I.ア", i, i) - [ for #i \ ] -} +// Arabic Indic. +#t(pat: "\u{0661}", 1475, "١٤٧٥") +#t(pat: "\u{06F1}", 1475, "۱۴۷۵") ---- numbering-arabic-indic --- -#assert.eq(numbering("\u{0661}", 1475), "١٤٧٥") -#assert.eq(numbering("\u{06F1}", 1475), "۱۴۷۵") +// Devanagari. +#t(pat: "\u{0967}", 1, "१") +#t(pat: "\u{0967}", 10, "१०") +#t(pat: "\u{0967}", 123456789, "१२३४५६७८९") ---- numbering-devanagari-number --- -#assert.eq(numbering("\u{0967}", 1), "१") -#assert.eq(numbering("\u{0967}", 10), "१०") -#assert.eq(numbering("\u{0967}", 123456789), "१२३४५६७८९") +// Circled number. +#t(pat: "①", 1, "①") +#t(pat: "①", 50, "㊿") + +// Double-circled number. +#t(pat: "⓵", 1, "⓵") +#t(pat: "⓵", 10, "⓾") --- numbering-negative --- // Error: 17-19 number must be at least zero #numbering("1", -1) - ---- numbering-circled-number --- -#assert.eq(numbering("①", 1), "①") -#assert.eq(numbering("①", 50), "㊿") - ---- numbering-double-circled-number --- -#assert.eq(numbering("⓵", 1), "⓵") -#assert.eq(numbering("⓵", 10), "⓾") diff --git a/tests/suite/model/outline.typ b/tests/suite/model/outline.typ index 2409dbbe..3c134760 100644 --- a/tests/suite/model/outline.typ +++ b/tests/suite/model/outline.typ @@ -1,53 +1,41 @@ --- outline --- -// LARGE -#set page("a7", margin: 20pt, numbering: "1") +#set page(height: 200pt, margin: (bottom: 20pt), numbering: "1") #set heading(numbering: "(1/a)") #show heading.where(level: 1): set text(12pt) #show heading.where(level: 2): set text(10pt) -#set math.equation(numbering: "1") -#outline() -#outline(title: [Figures], target: figure) -#outline(title: [Equations], target: math.equation) +#outline(fill: none) -= Introduction -#lorem(12) - -= Analysis -#lorem(10) += A += B +#lines(3) +// This heading is right at the start of the page, so that we can test +// whether the tag migrates properly. #[ #set heading(outlined: false) - == Methodology - #lorem(6) + == C ] -== Math -$x$ is a very useful constant. See it in action: -$ x = x $ +A -== Interesting figures -#figure(rect[CENSORED], kind: image, caption: [A picture showing a programmer at work.]) -#figure(table[1x1], caption: [A very small table.]) +== D +== F +==== G -== Programming -```rust -fn main() { - panic!("in the disco"); -} -``` +--- outline-styled-text --- +#outline(title: none) -==== Deep Stuff -Ok ... += #text(blue)[He]llo + +--- outline-bookmark --- +#outline(title: none, fill: none) // Ensure 'bookmarked' option doesn't affect the outline #set heading(numbering: "(I)", bookmarked: false) - -= #text(blue)[Sum]mary -#lorem(10) += A --- outline-indent-numbering --- -// LARGE // With heading numbering #set page(width: 200pt) #set heading(numbering: "1.a.") @@ -62,11 +50,11 @@ Ok ... #outline(indent: 2em) #outline(indent: n => ([-], [], [==], [====]).at(n)) -= About ACME Corp. -== History -== Products -=== Categories -==== General += A +== B +== C +=== D +==== E --- outline-indent-no-numbering --- // Without heading numbering diff --git a/tests/suite/model/quote.typ b/tests/suite/model/quote.typ index d71eeeab..2c93f92c 100644 --- a/tests/suite/model/quote.typ +++ b/tests/suite/model/quote.typ @@ -20,9 +20,9 @@ And I quote: #quote(attribution: [René Descartes])[cogito, ergo sum]. #set quote(block: true) #set text(8pt) -#lorem(10) -#quote(lorem(10)) -#lorem(10) +#lines(3) +#quote(lines(3)) +#lines(3) --- quote-inline --- // Inline citation diff --git a/tests/suite/model/terms.typ b/tests/suite/model/terms.typ index 6a08b923..07aa827d 100644 --- a/tests/suite/model/terms.typ +++ b/tests/suite/model/terms.typ @@ -60,17 +60,17 @@ Not in list / Hello --- issue-1050-terms-indent --- -#set page(width: 200pt) +#set page(width: 110pt) #set par(first-line-indent: 0.5cm) -- #lorem(10) -- #lorem(10) +- #lorem(5) +- #lorem(5) -+ #lorem(10) -+ #lorem(10) ++ #lorem(5) ++ #lorem(5) -/ Term 1: #lorem(10) -/ Term 2: #lorem(10) +/ S: #lorem(5) +/ XXXL: #lorem(5) --- issue-2530-term-item-panic --- // Term item (pre-emptive) diff --git a/tests/suite/scripting/import.typ b/tests/suite/scripting/import.typ index 8e2bc4b5..95214db7 100644 --- a/tests/suite/scripting/import.typ +++ b/tests/suite/scripting/import.typ @@ -52,7 +52,7 @@ #import "module.typ": chap2, chap2.name, chap2.chap1, chap2.chap1.name as othername #test(chap2, orig-chap2) #test(chap1, orig-chap1) -#test(name, "Klaus") +#test(name, "Peter") #test(othername, "Klaus") --- import-items-parenthesized --- diff --git a/tests/suite/scripting/include.typ b/tests/suite/scripting/include.typ index e4da6d19..f5c4a5ba 100644 --- a/tests/suite/scripting/include.typ +++ b/tests/suite/scripting/include.typ @@ -3,8 +3,6 @@ --- include-file --- #set page(width: 200pt) -= Document - // Include a file #include "modules/chap1.typ" diff --git a/tests/suite/scripting/modules/chap1.typ b/tests/suite/scripting/modules/chap1.typ index 13d0acf8..c5dc1cf6 100644 --- a/tests/suite/scripting/modules/chap1.typ +++ b/tests/suite/scripting/modules/chap1.typ @@ -2,7 +2,4 @@ #let name = "Klaus" == Chapter 1 -#name stood in a field of wheat. There was nothing of particular interest about -the field #name just casually surveyed for any paths on which the corn would not -totally ruin his semi-new outdorsy jacket but then again, most of us spend -considerable time in non-descript environments. +#name stood in a field of wheat. diff --git a/tests/suite/scripting/modules/chap2.typ b/tests/suite/scripting/modules/chap2.typ index f1a886d6..3649cb58 100644 --- a/tests/suite/scripting/modules/chap2.typ +++ b/tests/suite/scripting/modules/chap2.typ @@ -1,11 +1,6 @@ // SKIP #import "chap1.typ" -#let name = "Klaus" +#let name = "Peter" == Chapter 2 -Their motivations, however, were pretty descript, so to speak. #name had not yet -conceptualized their consequences, but that should change pretty quickly. #name -approached the center of the field and picked up a 4-foot long disk made from -what could only be cow manure. The hair on the back of #name' neck bristled as -he stared at the unusual sight. After studying the object for a while, he -promptly popped the question, "How much?" +#name had not yet conceptualized their consequences. diff --git a/tests/suite/styling/show.typ b/tests/suite/styling/show.typ index 05f545c6..e8ddf553 100644 --- a/tests/suite/styling/show.typ +++ b/tests/suite/styling/show.typ @@ -113,9 +113,7 @@ Hey ] #show: columns.with(2) -Great typography is at the essence of great storytelling. It is the medium that -transports meaning from parchment to reader, the wave that sparks a flame -in booklovers and the great fulfiller of human need. +#lines(16) --- show-bare-content-block --- // Test bare show in content block. diff --git a/tests/suite/text/raw.typ b/tests/suite/text/raw.typ index 0de34962..d6f6978e 100644 --- a/tests/suite/text/raw.typ +++ b/tests/suite/text/raw.typ @@ -127,8 +127,6 @@ Year Month Day #set page(width: 180pt) #set text(6pt) -#lorem(20) - ```py def something(x): return x @@ -137,28 +135,47 @@ a = 342395823859823958329 b = 324923 ``` -#lorem(20) - --- raw-align-specified --- // Text inside raw block should follow the specified alignment. #set page(width: 180pt) #set text(6pt) -#lorem(20) #align(center, raw( lang: "typ", block: true, align: right, "#let f(x) = x\n#align(center, line(length: 1em))", )) -#lorem(20) --- raw-align-invalid --- // Error: 17-20 expected `start`, `left`, `center`, `right`, or `end`, found top #set raw(align: top) +--- raw-inline-multiline --- +#set page(width: 180pt) +#set text(6pt) +#set raw(lang:"python") + +Inline raws, multiline e.g. `for i in range(10): + # Only this line is a comment. + print(i)` or otherwise e.g. `print(j)`, are colored properly. + +Inline raws, multiline e.g. ` +# Appears blocky due to linebreaks at the boundary. +for i in range(10): + print(i) +` or otherwise e.g. `print(j)`, are colored properly. + --- raw-highlight-typ --- -// LARGE +```typ += Chapter 1 +#lorem(100) + +#let hi = "Hello World" +#show heading: emph +``` + +--- raw-highlight-typc --- #set page(width: auto) ```typ @@ -184,45 +201,35 @@ b = 324923 #{ hello } #{ hello() } #{ hello.world() } -$ hello $ -$ hello() $ -$ box[] $ -$ hello.world $ -$ hello.world() $ -$ hello.my.world() $ -$ f_zeta(x), f_zeta(x)/1 $ -$ emph(hello.my.world()) $ -$ emph(hello.my().world) $ -$ emph(hello.my().world()) $ -$ #hello $ -$ #hello() $ -$ #hello.world $ -$ #hello.world() $ -$ #box[] $ #if foo [] ``` ---- raw-highlight --- -#set page(width: 180pt) -#set text(6pt) -#show raw: it => rect( - width: 100%, - inset: (x: 4pt, y: 5pt), - radius: 4pt, - fill: rgb(239, 241, 243), - place(right, text(luma(110), it.lang)) + it, -) - -```typ -= Chapter 1 -#lorem(100) - -#let hi = "Hello World" -#show heading: emph +--- raw-highlight-typm --- +#set page(width: auto) +```typm +1 + 2/3 +a^b +hello +hello() +box[] +hello.world +hello.world() +hello.my.world() +f_zeta(x), f_zeta(x)/1 +emph(hello.my.world()) +emph(hello.my().world) +emph(hello.my().world()) +#hello +#hello() +#hello.world +#hello.world() +#box[] ``` +--- raw-highlight-rust --- +#set page(width: auto) ```rust -/// A carefully designed state machine. +/// A state machine. #[derive(Debug)] enum State<'a> { A(u8), B(&'a str) } @@ -231,6 +238,9 @@ fn advance(state: State<'_>) -> State<'_> { } ``` +--- raw-highlight-py --- +#set page(width: auto) + ```py import this @@ -238,6 +248,9 @@ def hi(): print("Hi!") ``` +--- raw-highlight-cpp --- +#set page(width: auto) + ```cpp #include @@ -246,47 +259,27 @@ int main() { } ``` -```julia -# Add two numbers -function add(x, y) - return x * y -end +--- raw-highlight-html --- +#set page(width: auto) + +```html + + + + + + +

Topic

+

The Hypertext Markup Language.

+ + + ``` - // Try with some indent. - ```html - - - - - - -

Topic

-

The Hypertext Markup Language.

- - - - ``` - ---- raw-inline-multiline --- -#set page(width: 180pt) -#set text(6pt) -#set raw(lang:"python") - -Inline raws, multiline e.g. `for i in range(10): - # Only this line is a comment. - print(i)` or otherwise e.g. `print(j)`, are colored properly. - -Inline raws, multiline e.g. ` -# Appears blocky due to linebreaks at the boundary. -for i in range(10): - print(i) -` or otherwise e.g. `print(j)`, are colored properly. - --- raw-blocky --- // Test various raw parsing edge cases. #let empty = ( @@ -448,8 +441,8 @@ test ) #for c in cases { - assert.eq(c.text, c.input.text, message: "in point " + c.name + ", expect " + repr(c.text) + ", got " + repr(c.input.text) + "") let block = c.at("block", default: false) + assert.eq(c.text, c.input.text, message: "in point " + c.name + ", expect " + repr(c.text) + ", got " + repr(c.input.text) + "") assert.eq(block, c.input.block, message: "in point " + c.name + ", expect " + repr(block) + ", got " + repr(c.input.block) + "") } diff --git a/tests/suite/text/smartquote.typ b/tests/suite/text/smartquote.typ index 04a82036..f5442ffd 100644 --- a/tests/suite/text/smartquote.typ +++ b/tests/suite/text/smartquote.typ @@ -1,48 +1,55 @@ --- smartquote --- -// LARGE -#set page(width: 250pt) - -// Test simple quotations in various languages. #set text(lang: "en") "The horse eats no cucumber salad" was the first sentence ever uttered on the 'telephone.' +--- smartquote-de --- #set text(lang: "de") "Das Pferd frisst keinen Gurkensalat" war der erste jemals am 'Fernsprecher' gesagte Satz. +--- smartquote-de-ch --- #set text(lang: "de", region: "CH") "Das Pferd frisst keinen Gurkensalat" war der erste jemals am 'Fernsprecher' gesagte Satz. +--- smartquote-es --- #set text(lang: "es", region: none) "El caballo no come ensalada de pepino" fue la primera frase pronunciada por 'teléfono'. +--- smartquote-es-mx --- #set text(lang: "es", region: "MX") "El caballo no come ensalada de pepino" fue la primera frase pronunciada por 'teléfono'. -#set text(lang: "fr", region: none) +--- smartquote-fr --- +#set text(lang: "fr") "Le cheval ne mange pas de salade de concombres" est la première phrase jamais prononcée au 'téléphone'. +--- smartquote-fi --- #set text(lang: "fi") "Hevonen ei syö kurkkusalaattia" oli ensimmäinen koskaan 'puhelimessa' lausuttu lause. +--- smartquote-gr --- #set text(lang: "gr") "Το άλογο δεν τρώει αγγουροσαλάτα" ήταν η πρώτη πρόταση που ειπώθηκε στο 'τηλέφωνο'. +--- smartquote-he --- #set text(lang: "he") "הסוס לא אוכל סלט מלפפונים" היה המשפט ההראשון שנאמר ב'טלפון'. +--- smartquote-ro --- #set text(lang: "ro") "Calul nu mănâncă salată de castraveți" a fost prima propoziție rostită vreodată la 'telefon'. +--- smartquote-ru --- #set text(lang: "ru") "Лошадь не ест салат из огурцов" - это была первая фраза, сказанная по 'телефону'. +--- smartquote-it --- #set text(lang: "it") "Il cavallo non mangia insalata di cetrioli" è stata la prima frase pronunciata al 'telefono'. +--- smartquote-la --- #set text(lang: "la") #set smartquote(alternative: true) "Equus cucumeris sem non edit" prima sententia in 'telephono' prolata fuit. -#set smartquote(alternative: false) --- smartquote-empty --- // Test single pair of quotes. diff --git a/tests/suite/visualize/color.typ b/tests/suite/visualize/color.typ index bc8f8be5..f7eccdf3 100644 --- a/tests/suite/visualize/color.typ +++ b/tests/suite/visualize/color.typ @@ -160,12 +160,12 @@ let are-equal((a, b)) = { let to-float(x) = if type(x) == angle { x.rad() } else { float(x) } let epsilon = 1e-4 // The maximum error between both numbers - assert.eq(type(a), type(b)) + test(type(a), type(b)) calc.abs(to-float(a) - to-float(b)) < epsilon } let ref-without-alpha = if has-alpha { ref.slice(0, -1) } else { ref } - assert.eq(col.components().len(), ref.len()) + test(col.components().len(), ref.len()) assert(col.components().zip(ref).all(are-equal)) assert(col.components(alpha: false).zip(ref-without-alpha).all(are-equal)) } @@ -317,19 +317,6 @@ #test-repr(luma(100%, 50%).opacify(-50%), luma(100%, 25%)) #test-repr(luma(100%, 0%).opacify(0%), luma(100%, 0%)) ---- repr-color --- -// Colors -#set page(width: 400pt) -#set text(0.8em) -#blue \ -#color.linear-rgb(blue) \ -#oklab(blue) \ -#oklch(blue) \ -#cmyk(blue) \ -#color.hsl(blue) \ -#color.hsv(blue) \ -#luma(blue) - --- issue-color-mix-luma --- // When mixing luma colors, we accidentally used the wrong component. #rect(fill: gradient.linear(black, silver, space: luma)) diff --git a/tests/suite/visualize/gradient.typ b/tests/suite/visualize/gradient.typ index 61f6b6d0..ff1aef3a 100644 --- a/tests/suite/visualize/gradient.typ +++ b/tests/suite/visualize/gradient.typ @@ -613,15 +613,6 @@ $ A = mat( ((red, 0%), (green, 25%), (blue, 50%), (green, 75%), (red, 100%)) ) ---- gradient-repr --- -// Gradients -#set page(width: 400pt) -#set text(0.8em) -#gradient.linear(blue, red) \ -#gradient.linear(blue, red, dir: ttb) \ -#gradient.linear(blue, red, angle: 45deg, relative: "self") \ -#gradient.linear(blue, red, angle: 45deg, space: rgb) - --- issue-2902-gradient-oklch-panic --- // Minimal reproduction of #2902 #set page(width: 15cm, height: auto, margin: 1em) diff --git a/tests/suite/visualize/image.typ b/tests/suite/visualize/image.typ index 3bda8d0e..846650c6 100644 --- a/tests/suite/visualize/image.typ +++ b/tests/suite/visualize/image.typ @@ -1,11 +1,10 @@ // Test the `image` function. ---- image-rgba-png-and-jpeg --- -// Test loading different image formats. - +--- image-png --- // Load an RGBA PNG image. #image("/assets/images/rhino.png") +--- image-jpg --- // Load an RGB JPEG image. #set page(height: 60pt) #image("/assets/images/tiger.jpg") diff --git a/tests/suite/visualize/stroke.typ b/tests/suite/visualize/stroke.typ index b03c96c5..387e88cb 100644 --- a/tests/suite/visualize/stroke.typ +++ b/tests/suite/visualize/stroke.typ @@ -2,18 +2,18 @@ --- stroke-constructor --- // Converting to stroke -#assert.eq(stroke(red).paint, red) -#assert.eq(stroke(red).thickness, auto) -#assert.eq(stroke(2pt).paint, auto) -#assert.eq(stroke((cap: "round", paint: blue)).cap, "round") -#assert.eq(stroke((cap: auto, paint: blue)).cap, auto) -#assert.eq(stroke((cap: auto, paint: blue)).thickness, auto) +#test(stroke(red).paint, red) +#test(stroke(red).thickness, auto) +#test(stroke(2pt).paint, auto) +#test(stroke((cap: "round", paint: blue)).cap, "round") +#test(stroke((cap: auto, paint: blue)).cap, auto) +#test(stroke((cap: auto, paint: blue)).thickness, auto) // Constructing with named arguments -#assert.eq(stroke(paint: blue, thickness: 8pt), 8pt + blue) -#assert.eq(stroke(thickness: 2pt), stroke(2pt)) -#assert.eq(stroke(cap: "round").thickness, auto) -#assert.eq(stroke(cap: "round", thickness: auto).thickness, auto) +#test(stroke(paint: blue, thickness: 8pt), 8pt + blue) +#test(stroke(thickness: 2pt), stroke(2pt)) +#test(stroke(cap: "round").thickness, auto) +#test(stroke(cap: "round", thickness: auto).thickness, auto) --- stroke-constructor-unknown-key --- // Error: 9-21 unexpected key "foo", valid keys are "paint", "thickness", "cap", "join", "dash", and "miter-limit"