diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-26 23:42:40 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-26 23:52:01 +0100 |
| commit | 6bafc6391061d4b589dea835705a08b25a4df9f8 (patch) | |
| tree | 4add85f17fc56da341acfb58a223ea20d80c280a /tests/src | |
| parent | 0579fd4409375aaa9fd8e87a06fd59097b5fcd97 (diff) | |
Document metadata
Diffstat (limited to 'tests/src')
| -rw-r--r-- | tests/src/benches.rs | 4 | ||||
| -rw-r--r-- | tests/src/tests.rs | 13 |
2 files changed, 9 insertions, 8 deletions
diff --git a/tests/src/benches.rs b/tests/src/benches.rs index 754f80a9..1ae012eb 100644 --- a/tests/src/benches.rs +++ b/tests/src/benches.rs @@ -94,8 +94,8 @@ fn bench_compile(iai: &mut Iai) { fn bench_render(iai: &mut Iai) { let world = BenchWorld::new(); - let frames = typst::compile(&world, &world.source).unwrap(); - iai.run(|| typst::export::render(&frames[0], 1.0)) + let document = typst::compile(&world, &world.source).unwrap(); + iai.run(|| typst::export::render(&document.pages[0], 1.0)) } struct BenchWorld { diff --git a/tests/src/tests.rs b/tests/src/tests.rs index f96c651b..215d7fe7 100644 --- a/tests/src/tests.rs +++ b/tests/src/tests.rs @@ -12,8 +12,8 @@ use elsa::FrozenVec; use once_cell::unsync::OnceCell; use tiny_skia as sk; use typst::diag::{bail, FileError, FileResult}; +use typst::doc::{Document, Element, Frame, Metadata}; use typst::font::{Font, FontBook}; -use typst::frame::{Element, Frame}; use typst::geom::{Abs, RgbaColor, Sides}; use typst::model::{Library, Smart, Value}; use typst::syntax::{Source, SourceId, SyntaxNode}; @@ -349,20 +349,21 @@ fn test( line += part.lines().count() + 1; } + let document = Document { pages: frames, metadata: Metadata::default() }; if compare_ever { if let Some(pdf_path) = pdf_path { - let pdf_data = typst::export::pdf(&frames); + let pdf_data = typst::export::pdf(&document); fs::create_dir_all(&pdf_path.parent().unwrap()).unwrap(); fs::write(pdf_path, pdf_data).unwrap(); } if world.print.frames { - for frame in &frames { + for frame in &document.pages { println!("Frame:\n{:#?}\n", frame); } } - let canvas = render(&frames); + let canvas = render(&document.pages); fs::create_dir_all(&png_path.parent().unwrap()).unwrap(); canvas.save_png(png_path).unwrap(); @@ -378,7 +379,7 @@ fn test( println!(" Does not match reference image. ❌"); ok = false; } - } else if !frames.is_empty() { + } else if !document.pages.is_empty() { println!(" Failed to open reference image. ❌"); ok = false; } @@ -425,7 +426,7 @@ fn test_part( } let (mut frames, errors) = match typst::compile(world, source) { - Ok(frames) => (frames, vec![]), + Ok(document) => (document.pages, vec![]), Err(errors) => (vec![], *errors), }; |
