diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-08-17 22:04:18 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-08-17 22:20:37 +0200 |
| commit | 594809e35b9e768f1a50926cf5e7a9df41ba7d16 (patch) | |
| tree | 488f201599a67329d7916b9b3ecb73dd27ad24d7 /tests | |
| parent | c53d98a22f367a9eecfb45d1b22f1be5c6cf908d (diff) | |
Library functions behave more imperatively
- Templates scope state changes
- State-modifying function operate in place instead of returning a template
- Internal template representation contains actual owned nodes instead of a pointer to a syntax tree + an expression map
- No more wide calls
Diffstat (limited to 'tests')
27 files changed, 138 insertions, 172 deletions
diff --git a/tests/ref/code/call.png b/tests/ref/code/call.png Binary files differindex 1839c5d8..a6a7940b 100644 --- a/tests/ref/code/call.png +++ b/tests/ref/code/call.png diff --git a/tests/ref/code/ops.png b/tests/ref/code/ops.png Binary files differindex 4421edb4..82e49c8f 100644 --- a/tests/ref/code/ops.png +++ b/tests/ref/code/ops.png diff --git a/tests/ref/layout/page.png b/tests/ref/layout/page.png Binary files differindex dfe6f8cd..42bcbe11 100644 --- a/tests/ref/layout/page.png +++ b/tests/ref/layout/page.png diff --git a/tests/typ/code/call.typ b/tests/typ/code/call.typ index 92ac17ae..ffd91769 100644 --- a/tests/typ/code/call.typ +++ b/tests/typ/code/call.typ @@ -5,7 +5,7 @@ // Ref: true // Ommitted space. -#font(weight:bold)[Bold] +[#font(weight:bold)Bold] // Call return value of function with body. #let f(x, body) = (y) => [#x] + body + [#y] @@ -21,35 +21,6 @@ #f([A]) --- -// Ref: true - -// Test multiple wide calls in separate expressions inside a template. -[ - #font!(fill: eastern) - First - #font!(fill: forest) - Second -] - -// Test wide call in heading. -= A #align!(right) B -C - ---- -// Test wide call in expression. - -// Error: 2-4 wide calls are only allowed directly in templates -{f!()} - -// Error: 5-7 wide calls are only allowed directly in templates -#g!(f!()) - ---- -// Test wide call evaluation semantics. -#let x = 1 -#let f(x, body) = test(x, 1) -#f!(x) -{ x = 2 } - ---- // Trailing comma. #test(1 + 1, 2,) @@ -90,9 +61,6 @@ C #f[1](2) --- -// Error: 7 expected argument list -#func! - // Error: 7-8 expected expression, found colon #func(:) diff --git a/tests/typ/code/ops.typ b/tests/typ/code/ops.typ index d77c7503..201f86da 100644 --- a/tests/typ/code/ops.typ +++ b/tests/typ/code/ops.typ @@ -4,7 +4,7 @@ --- // Test template addition. // Ref: true -{[*Hello ] + [world!*]} +{[*Hello ] + [world!]} --- // Test math operators. diff --git a/tests/typ/coma.typ b/tests/typ/coma.typ index fdf6ab54..8f47a749 100644 --- a/tests/typ/coma.typ +++ b/tests/typ/coma.typ @@ -1,5 +1,5 @@ // Configuration with `page` and `font` functions. -#page!(width: 450pt, margins: 1cm) +#page(width: 450pt, margins: 1cm) // There are variables and they can take normal values like strings, ... #let city = "Berlin" diff --git a/tests/typ/insert/circle.typ b/tests/typ/insert/circle.typ index 41e0c40d..c46d37e4 100644 --- a/tests/typ/insert/circle.typ +++ b/tests/typ/insert/circle.typ @@ -5,23 +5,24 @@ Auto-sized circle. \ #circle(fill: rgb("eb5278"))[ - #align!(center, center) + #align(center, center) But, soft! ] Center-aligned rect in auto-sized circle. #circle(fill: forest)[ - #align!(center, center) - #rect!(fill: conifer) - #pad!(5pt) - But, soft! + #align(center, center) + #rect(fill: conifer, pad(5pt)[ + But, soft! + ]) ] 100%-width rect in auto-sized circle. \ -#circle(fill: forest)[ - #rect!(width: 100%, fill: conifer) - But, soft! what light through yonder window breaks? -] +#circle(fill: forest, + rect(width: 100%, fill: conifer)[ + But, soft! what light through yonder window breaks? + ] +) Expanded by height. #circle(fill: conifer)[A \ B \ C] @@ -29,8 +30,8 @@ Expanded by height. --- // Test relative sizing. #rect(width: 100%, height: 50pt, fill: rgb("aaa"))[ - #align!(center, center) - #font!(fill: white) + #align(center, center) + #font(fill: white) #circle(radius: 10pt, fill: eastern)[A] #circle(height: 60%, fill: eastern)[B] #circle(width: 20% + 20pt, fill: eastern)[C] diff --git a/tests/typ/insert/ellipse.typ b/tests/typ/insert/ellipse.typ index 5044219d..33ba727f 100644 --- a/tests/typ/insert/ellipse.typ +++ b/tests/typ/insert/ellipse.typ @@ -2,12 +2,14 @@ --- 100% rect in 100% ellipse in fixed rect. \ -#rect(width: 3cm, height: 2cm, fill: rgb("2a631a"))[ - #ellipse!(width: 100%, height: 100%, fill: forest) - #rect!(width: 100%, height: 100%, fill: conifer) - #align!(center, center) - Stuff inside an ellipse! -] +#rect(width: 3cm, height: 2cm, fill: rgb("2a631a"), + ellipse(width: 100%, height: 100%, fill: forest, + rect(width: 100%, height: 100%, fill: conifer)[ + #align(center, center) + Stuff inside an ellipse! + ] + ) +) Auto-sized ellipse. \ #ellipse(fill: conifer)[ diff --git a/tests/typ/insert/image.typ b/tests/typ/insert/image.typ index 9d9c6d46..6359c4bb 100644 --- a/tests/typ/insert/image.typ +++ b/tests/typ/insert/image.typ @@ -17,7 +17,10 @@ #image("../../res/rhino.png") // Fit to height of page. -#page(height: 40pt, image("../../res/rhino.png")) +[ + #page(height: 40pt) + #image("../../res/rhino.png") +] // Set width explicitly. #image("../../res/rhino.png", width: 50pt) @@ -29,7 +32,8 @@ #image("../../res/rhino.png", width: 25pt, height: 50pt) // Make sure the bounding-box of the image is correct. -#align(bottom, right, image("../../res/tiger.jpg", width: 60pt)) +#align(bottom, right) +#image("../../res/tiger.jpg", width: 60pt) --- // Error: 8-29 file not found diff --git a/tests/typ/insert/rect.typ b/tests/typ/insert/rect.typ index 7f6bb899..4824095a 100644 --- a/tests/typ/insert/rect.typ +++ b/tests/typ/insert/rect.typ @@ -3,7 +3,7 @@ --- // Test the `rect` function. -#page!(width: 150pt) +#page(width: 150pt) // Fit to text. #rect(fill: conifer)[Textbox] diff --git a/tests/typ/insert/square.typ b/tests/typ/insert/square.typ index dd20ca62..1c856d4f 100644 --- a/tests/typ/insert/square.typ +++ b/tests/typ/insert/square.typ @@ -3,22 +3,21 @@ --- Auto-sized square. \ #square(fill: eastern)[ - #align!(center) - #pad!(5pt) - #font!(fill: white, weight: bold) - Typst + #font(fill: white, weight: bold) + #align(center) + #pad(5pt)[Typst] ] --- // Test height overflow. -#page!(width: 75pt, height: 100pt) +#page(width: 75pt, height: 100pt) #square(fill: conifer)[ But, soft! what light through yonder window breaks? ] --- // Test width overflow. -#page!(width: 100pt, height: 75pt) +#page(width: 100pt, height: 75pt) #square(fill: conifer)[ But, soft! what light through yonder window breaks? ] diff --git a/tests/typ/layout/containers.typ b/tests/typ/layout/containers.typ index 75e2617b..b2835b5e 100644 --- a/tests/typ/layout/containers.typ +++ b/tests/typ/layout/containers.typ @@ -12,7 +12,7 @@ Apart --- // Test block over multiple pages. -#page!(height: 60pt) +#page(height: 60pt) First! #block[ diff --git a/tests/typ/layout/grid-1.typ b/tests/typ/layout/grid-1.typ index 1b66bab4..92a1b990 100644 --- a/tests/typ/layout/grid-1.typ +++ b/tests/typ/layout/grid-1.typ @@ -3,7 +3,7 @@ --- #let rect(width, fill) = rect(width: width, height: 2cm, fill: fill) -#page!(width: 100pt, height: 140pt) +#page(width: 100pt, height: 140pt) #grid( columns: (auto, 1fr, 3fr, 0.25cm, 3%, 2mm + 10%), rect(0.5cm, rgb("2a631a")), @@ -33,7 +33,7 @@ ) --- -#page!(height: 3cm, width: 2cm) +#page(height: 3cm, width: 2cm) #grid( columns: (1fr, 1cm, 1fr, 1fr), column-dir: ttb, @@ -46,8 +46,8 @@ ) --- -#page!(height: 3cm, margins: 0pt) -#align!(center) +#page(height: 3cm, margins: 0pt) +#align(center) #grid( columns: (1fr,), rows: (1fr, auto, 2fr), diff --git a/tests/typ/layout/grid-2.typ b/tests/typ/layout/grid-2.typ index fcb7037e..164801ae 100644 --- a/tests/typ/layout/grid-2.typ +++ b/tests/typ/layout/grid-2.typ @@ -1,7 +1,7 @@ // Test using the `grid` function to create a finance table. --- -#page!(width: 12cm, height: 2.5cm) +#page(width: 12cm, height: 2.5cm) #grid( columns: 5, gutter-columns: (2fr, 1fr, 1fr), diff --git a/tests/typ/layout/grid-3.typ b/tests/typ/layout/grid-3.typ index 7e66eb2e..59abd5c7 100644 --- a/tests/typ/layout/grid-3.typ +++ b/tests/typ/layout/grid-3.typ @@ -1,7 +1,7 @@ // Test grid cells that overflow to the next region. --- -#page!(width: 5cm, height: 3cm) +#page(width: 5cm, height: 3cm) #grid( columns: 2, gutter-rows: 3 * (8pt,), @@ -18,7 +18,7 @@ --- // Test a column that starts overflowing right after another row/column did // that. -#page!(width: 5cm, height: 2cm) +#page(width: 5cm, height: 2cm) #grid( columns: 4 * (1fr,), gutter-rows: (10pt,), @@ -32,7 +32,7 @@ --- // Test two columns in the same row overflowing by a different amount. -#page!(width: 5cm, height: 2cm) +#page(width: 5cm, height: 2cm) #grid( columns: 3 * (1fr,), gutter-rows: (8pt,), @@ -48,7 +48,7 @@ --- // Test grid within a grid, overflowing. -#page!(width: 5cm, height: 2.25cm) +#page(width: 5cm, height: 2.25cm) #grid( columns: 4 * (1fr,), gutter-rows: (10pt,), @@ -62,7 +62,7 @@ --- // Test partition of `fr` units before and after multi-region layout. -#page!(width: 5cm, height: 4cm) +#page(width: 5cm, height: 4cm) #grid( columns: 2 * (1fr,), rows: (1fr, 2fr, auto, 1fr, 1cm), diff --git a/tests/typ/layout/pad.typ b/tests/typ/layout/pad.typ index eba68af2..bce13d42 100644 --- a/tests/typ/layout/pad.typ +++ b/tests/typ/layout/pad.typ @@ -5,10 +5,11 @@ #pad(left: 10pt, [Indented!]) // All sides together. -#rect(fill: conifer)[ - #pad!(10pt, right: 20pt) - #rect(width: 20pt, height: 20pt, fill: rgb("eb5278")) -] +#rect(fill: conifer, + pad(10pt, right: 20pt, + rect(width: 20pt, height: 20pt, fill: rgb("eb5278")) + ) +) Hi #box(pad(left: 10pt)[]) there @@ -27,7 +28,7 @@ Hi #box(pad(left: 10pt)[]) there --- // Test that the pad node doesn't consume the whole region. -#page!(height: 6cm) +#page(height: 6cm) #align(left)[Before] #pad(10pt, image("../../res/tiger.jpg")) diff --git a/tests/typ/layout/page.typ b/tests/typ/layout/page.typ index 80a644fb..0de397f3 100644 --- a/tests/typ/layout/page.typ +++ b/tests/typ/layout/page.typ @@ -2,44 +2,45 @@ --- // Set width and height. -#page!(width: 120pt, height: 120pt) -#page(width: 40pt)[High] -#page(height: 40pt)[Wide] +#page(width: 120pt, height: 120pt) +[#page(width: 40pt) High] +[#page(height: 40pt) Wide] // Set all margins at once. -#page(margins: 30pt)[ +[ + #page(margins: 30pt) #align(top, left)[TL] #align(bottom, right)[BR] ] // Set individual margins. -#page!(height: 40pt) -#page(left: 0pt, align(left)[Left]) -#page(right: 0pt, align(right)[Right]) -#page(top: 0pt, align(top)[Top]) -#page(bottom: 0pt, align(bottom)[Bottom]) +#page(height: 40pt) +[#page(left: 0pt) #align(left) Left] +[#page(right: 0pt) #align(right) Right] +[#page(top: 0pt) #align(top) Top] +[#page(bottom: 0pt) #align(bottom) Bottom] // Ensure that specific margins override general margins. -#page(margins: 0pt, left: 20pt)[Overriden] +[#page(margins: 0pt, left: 20pt) Overriden] // Flipped predefined paper. -#page("a11", flip: true)[Flipped A11] +[#page("a11", flip: true) Flipped A11] // Flipped custom page size. -#page!(width: 40pt, height: 120pt) -#page!(flip: true) +#page(width: 40pt, height: 120pt) +#page(flip: true) Wide --- // Test a combination of pages with bodies and normal content. -#page!(height: 50pt) +#page(height: 50pt) -#page[First] -#page[Second] +[#page() First] +[#page() Second] #pagebreak() #pagebreak() Fourth -#page[] +[#page(height: 25pt)] Sixth -#page[Seventh and last] +[#page() Seventh and last] diff --git a/tests/typ/layout/pagebreak.typ b/tests/typ/layout/pagebreak.typ index 20962a71..ab591c87 100644 --- a/tests/typ/layout/pagebreak.typ +++ b/tests/typ/layout/pagebreak.typ @@ -3,7 +3,7 @@ --- First of two #pagebreak() -#page!(height: 40pt) +#page(height: 40pt) --- // Make sure that you can't do page related stuff in a container. @@ -11,7 +11,7 @@ A #box[ B #pagebreak() - #page("a4")[] + #page("a4") ] C diff --git a/tests/typ/text/basic.typ b/tests/typ/text/basic.typ index 6e36a210..d5f0de05 100644 --- a/tests/typ/text/basic.typ +++ b/tests/typ/text/basic.typ @@ -1,7 +1,7 @@ // Test simple text. --- -#page!(width: 250pt, height: 110pt) +#page(width: 250pt, height: 110pt) 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 diff --git a/tests/typ/text/bidi.typ b/tests/typ/text/bidi.typ index 0aab9079..078cb1f9 100644 --- a/tests/typ/text/bidi.typ +++ b/tests/typ/text/bidi.typ @@ -3,54 +3,54 @@ --- // Test reordering with different top-level paragraph directions. #let text = [Text טֶקסט] -#font!("EB Garamond", "Noto Serif Hebrew") -#lang!("he") {text} -#lang!("de") {text} +#font("EB Garamond", "Noto Serif Hebrew") +#lang("he") {text} +#lang("de") {text} --- // Test that consecutive, embedded LTR runs stay LTR. // Here, we have two runs: "A" and italic "B". #let text = [أنت A_B_مطرC] -#font!("EB Garamond", "Noto Sans Arabic") -#lang!("ar") {text} -#lang!("de") {text} +#font("EB Garamond", "Noto Sans Arabic") +#lang("ar") {text} +#lang("de") {text} --- // Test that consecutive, embedded RTL runs stay RTL. // Here, we have three runs: "גֶ", bold "שֶׁ", and "ם". #let text = [Aגֶ*שֶׁ*םB] -#font!("EB Garamond", "Noto Serif Hebrew") -#lang!("he") {text} -#lang!("de") {text} +#font("EB Garamond", "Noto Serif Hebrew") +#lang("he") {text} +#lang("de") {text} --- // Test embedding up to level 4 with isolates. -#font!("EB Garamond", "Noto Serif Hebrew", "Twitter Color Emoji") -#lang!(dir: rtl) +#font("EB Garamond", "Noto Serif Hebrew", "Twitter Color Emoji") +#lang(dir: rtl) א\u{2066}A\u{2067}Bב\u{2069}? --- // Test hard line break (leads to two paragraphs in unicode-bidi). -#font!("Noto Sans Arabic", "EB Garamond") -#lang!("ar") +#font("Noto Sans Arabic", "EB Garamond") +#lang("ar") Life المطر هو الحياة \ الحياة تمطر is rain. --- // Test spacing. -#font!("EB Garamond", "Noto Serif Hebrew") +#font("EB Garamond", "Noto Serif Hebrew") L #h(1cm) ריווחR \ Lריווח #h(1cm) R --- // Test inline object. -#font!("Noto Serif Hebrew", "EB Garamond") -#lang!("he") +#font("Noto Serif Hebrew", "EB Garamond") +#lang("he") קרנפיםRh#image("../../res/rhino.png", height: 11pt)inoחיים --- // Test the `lang` function. // Ref: false -// Error: 13-16 must be horizontal -#lang!(dir: ttb) +// Error: 12-15 must be horizontal +#lang(dir: ttb) diff --git a/tests/typ/text/chinese.typ b/tests/typ/text/chinese.typ index b6c3b3f9..0800a220 100644 --- a/tests/typ/text/chinese.typ +++ b/tests/typ/text/chinese.typ @@ -1,7 +1,7 @@ // Test chinese text from Wikipedia. --- -#font!("Noto Serif CJK SC") +#font("Noto Serif CJK SC") 是美国广播公司电视剧《迷失》第3季的第22和23集,也是全剧的第71集和72集 由执行制作人戴蒙·林道夫和卡尔顿·库斯编剧,导演则是另一名执行制作人杰克·本德 diff --git a/tests/typ/text/decorations.typ b/tests/typ/text/decorations.typ index 83b04650..bbda3de6 100644 --- a/tests/typ/text/decorations.typ +++ b/tests/typ/text/decorations.typ @@ -1,19 +1,19 @@ // Test text decorations. --- +#let red = rgb("fc0030") + // Basic strikethrough. -#strike[ - Statements dreamt up by the utterly deranged. -] +#strike[Statements dreamt up by the utterly deranged.] // Move underline down. #underline(offset: 5pt)[Further below.] // Different color. -#underline(rgb("fc0030"))[Critical information is conveyed here.] +#underline(red)[Critical information is conveyed here.] // Inherits font color. -#font(fill: rgb("fc0030"), underline[Change with the wind.]) +[#font(fill: red) #underline[Change with the wind.]] // Both over- and underline. #overline(underline[Running amongst the wolves.]) diff --git a/tests/typ/text/font.typ b/tests/typ/text/font.typ index 1d28c331..fbb999f8 100644 --- a/tests/typ/text/font.typ +++ b/tests/typ/text/font.typ @@ -2,42 +2,43 @@ --- // Set same font size in three different ways. -#font(22pt)[A] -#font(200%)[A] -#font(size: 16.5pt + 50%)[A] +[#font(22pt) A] +[#font(200%) A] +[#font(size: 16.5pt + 50%) A] // Do nothing. -#font[Normal] +[#font() Normal] // Set style (is available). -#font(style: italic)[Italic] +[#font(style: italic) Italic] // Set weight (is available). -#font(weight: bold)[Bold] +[#font(weight: bold) Bold] // Set stretch (not available, matching closest). -#font(stretch: 50%)[Condensed] +[#font(stretch: 50%) Condensed] // Set family. -#font(family: "PT Sans")[Sans serif] +[#font(family: "PT Sans") Sans serif] // Emoji. Emoji: 🐪, 🌋, 🏞 // Math. -#font("Latin Modern Math")[ - ∫ 𝛼 + 3𝛽 d𝑡 -] +[#font("Latin Modern Math") ∫ 𝛼 + 3𝛽 d𝑡] // Colors. -#font(fill: eastern)[This is #font(fill: rgb("FA644B"))[way more] colorful.] +[ + #font(fill: eastern) + This is [#font(fill: rgb("FA644B")) way more] colorful. +] --- // Test top and bottom edge. -#page!(width: 170pt) +#page(width: 170pt) #let try(top, bottom) = rect(fill: conifer)[ - #font!(top-edge: top, bottom-edge: bottom) + #font(top-edge: top, bottom-edge: bottom) `From `#top` to `#bottom ] @@ -48,31 +49,31 @@ Emoji: 🐪, 🌋, 🏞 --- // Test class definitions. -#font!(sans-serif: "PT Sans") -#font(family: sans-serif)[Sans-serif.] \ -#font(monospace)[Monospace.] \ -#font(monospace, monospace: ("Nope", "Latin Modern Math"))[Math.] +#font(sans-serif: "PT Sans") +[#font(family: sans-serif) Sans-serif.] \ +[#font(monospace) Monospace.] \ +[#font(monospace, monospace: ("Nope", "Latin Modern Math")) Math.] --- // Error: 7-12 unexpected argument -#font(false)[] +#font(false) --- // Error: 14-18 expected font style, found font weight -#font(style: bold, weight: "thin")[] +#font(style: bold, weight: "thin") --- // Error: 14-15 expected string or array of strings, found integer -#font(serif: 0)[] +#font(serif: 0) --- // Error: 19-23 unexpected argument -#font(size: 10pt, 12pt)[] +#font(size: 10pt, 12pt) --- // Error: 28-35 unexpected argument -#font(family: "Helvetica", "Arial")[] +#font(family: "Helvetica", "Arial") --- // Error: 7-27 unexpected argument -#font(something: "invalid")[] +#font(something: "invalid") diff --git a/tests/typ/text/par.typ b/tests/typ/text/par.typ index 0c776c70..8f8d3946 100644 --- a/tests/typ/text/par.typ +++ b/tests/typ/text/par.typ @@ -1,7 +1,7 @@ // Test configuring paragraph properties. --- -#par!(spacing: 10pt, leading: 25%) +#par(spacing: 10pt, leading: 25%) But, soft! what light through yonder window breaks? It is the east, and Juliet is the sun. diff --git a/tests/typ/text/shaping.typ b/tests/typ/text/shaping.typ index 23156aa4..ba543e71 100644 --- a/tests/typ/text/shaping.typ +++ b/tests/typ/text/shaping.typ @@ -7,11 +7,11 @@ Le fira // This should just shape nicely. -#font!("Noto Sans Arabic") +#font("Noto Sans Arabic") دع النص يمطر عليك // This should form a three-member family. -#font!("Twitter Color Emoji") +#font("Twitter Color Emoji") 👩👩👦 🤚🏿 // These two shouldn't be affected by a zero-width joiner. @@ -20,7 +20,7 @@ Le fira --- // Test font fallback. -#font!("EB Garamond", "Noto Sans Arabic", "Twitter Color Emoji") +#font("EB Garamond", "Noto Sans Arabic", "Twitter Color Emoji") // Font fallback for emoji. A😀B @@ -40,6 +40,6 @@ A🐈中文B --- // Test reshaping. -#font!("Noto Serif Hebrew") -#lang!("he") +#font("Noto Serif Hebrew") +#lang("he") ס \ טֶ diff --git a/tests/typ/text/whitespace.typ b/tests/typ/text/whitespace.typ index c81513fa..7d5b1a68 100644 --- a/tests/typ/text/whitespace.typ +++ b/tests/typ/text/whitespace.typ @@ -30,11 +30,11 @@ A #for _ in (none,) {"B"}C --- // Test that a run consisting only of whitespace isn't trimmed. -A#font("PT Sans")[ ]B +A[#font("PT Sans") ]B --- // Test font change after space. -Left #font("PT Sans")[Right]. +Left [#font("PT Sans")Right]. --- // Test that space at start of line is not trimmed. diff --git a/tests/typeset.rs b/tests/typeset.rs index a489a3ec..d30d4d7d 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -10,15 +10,14 @@ use ttf_parser::{GlyphId, OutlineBuilder}; use walkdir::WalkDir; use typst::color::Color; -use typst::diag::{Error, TypResult}; -use typst::eval::{eval, Value}; -use typst::exec::{exec, State}; +use typst::diag::Error; +use typst::eval::{State, Value}; use typst::geom::{self, Length, PathElement, Point, Sides, Size}; use typst::image::ImageId; use typst::layout::{layout, Element, Frame, Geometry, LayoutTree, Paint, Text}; use typst::loading::FsLoader; -use typst::parse::{parse, Scanner}; -use typst::source::{SourceFile, SourceId}; +use typst::parse::Scanner; +use typst::source::SourceFile; use typst::syntax::{Pos, Span}; use typst::Context; @@ -225,11 +224,10 @@ fn test_part( let compare_ref = local_compare_ref.unwrap_or(compare_ref); let mut ok = true; + let (frames, mut errors) = match ctx.execute(id) { + Ok(tree) => { + let mut frames = layout(ctx, &tree); - let result = typeset(ctx, id); - let (frames, mut errors) = match result { - #[allow(unused_variables)] - Ok((tree, mut frames)) => { #[cfg(feature = "layout-cache")] (ok &= test_incremental(ctx, i, &tree, &frames)); @@ -274,15 +272,6 @@ fn test_part( (ok, compare_ref, frames) } -fn typeset(ctx: &mut Context, id: SourceId) -> TypResult<(LayoutTree, Vec<Rc<Frame>>)> { - let source = ctx.sources.get(id); - let ast = parse(source)?; - let module = eval(ctx, id, Rc::new(ast))?; - let tree = exec(ctx, &module.template); - let frames = layout(ctx, &tree); - Ok((tree, frames)) -} - #[cfg(feature = "layout-cache")] fn test_incremental( ctx: &mut Context, |
