diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-19 22:28:49 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-19 22:39:19 +0100 |
| commit | ab43bd802eafe33977a91893907e67553e099569 (patch) | |
| tree | af4dead92b143348f52e2e8f869df3f7dfd7322a /tests | |
| parent | d6aaae0cea1e79eecd85dc94ab85b9ad8eff48e8 (diff) | |
Renaming and refactoring
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ref/compiler/show-node.png | bin | 24387 -> 24545 bytes | |||
| -rw-r--r-- | tests/ref/layout/place.png | bin | 44401 -> 44724 bytes | |||
| -rw-r--r-- | tests/src/tests.rs | 22 | ||||
| -rw-r--r-- | tests/typ/compiler/construct.typ | 2 | ||||
| -rw-r--r-- | tests/typ/compiler/content-field.typ | 16 | ||||
| -rw-r--r-- | tests/typ/compiler/field.typ | 10 | ||||
| -rw-r--r-- | tests/typ/compiler/show-node.typ | 12 | ||||
| -rw-r--r-- | tests/typ/compute/construct.typ | 4 | ||||
| -rw-r--r-- | tests/typ/layout/list-marker.typ | 2 | ||||
| -rw-r--r-- | tests/typ/layout/pad.typ | 2 | ||||
| -rw-r--r-- | tests/typ/layout/par-bidi.typ | 2 | ||||
| -rw-r--r-- | tests/typ/layout/place.typ | 4 | ||||
| -rw-r--r-- | tests/typ/meta/counter.typ | 2 | ||||
| -rw-r--r-- | tests/typ/meta/document.typ | 8 | ||||
| -rw-r--r-- | tests/typ/meta/query.typ | 4 | ||||
| -rw-r--r-- | tests/typ/meta/state.typ | 6 | ||||
| -rw-r--r-- | tests/typ/text/features.typ | 2 | ||||
| -rw-r--r-- | tests/typ/text/symbol.typ | 2 |
18 files changed, 50 insertions, 50 deletions
diff --git a/tests/ref/compiler/show-node.png b/tests/ref/compiler/show-node.png Binary files differindex 014c45bf..cae9b932 100644 --- a/tests/ref/compiler/show-node.png +++ b/tests/ref/compiler/show-node.png diff --git a/tests/ref/layout/place.png b/tests/ref/layout/place.png Binary files differindex 10686ab5..968e613c 100644 --- a/tests/ref/layout/place.png +++ b/tests/ref/layout/place.png diff --git a/tests/src/tests.rs b/tests/src/tests.rs index 9e6d94a3..07312c5c 100644 --- a/tests/src/tests.rs +++ b/tests/src/tests.rs @@ -12,15 +12,15 @@ 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, Meta}; +use typst::doc::{Document, Frame, FrameItem, Meta}; use typst::eval::{func, Library, Value}; use typst::font::{Font, FontBook}; use typst::geom::{Abs, Color, RgbaColor, Sides, Smart}; use typst::syntax::{Source, SourceId, Span, SyntaxNode}; use typst::util::{Buffer, PathExt}; use typst::World; -use typst_library::layout::PageNode; -use typst_library::text::{TextNode, TextSize}; +use typst_library::layout::PageElem; +use typst_library::text::{TextElem, TextSize}; use unscanny::Scanner; use walkdir::WalkDir; @@ -179,12 +179,12 @@ fn library() -> Library { // exactly 100pt wide. Page height is unbounded and font size is 10pt so // that it multiplies to nice round numbers. lib.styles - .set(PageNode::set_width(Smart::Custom(Abs::pt(120.0).into()))); - lib.styles.set(PageNode::set_height(Smart::Auto)); - lib.styles.set(PageNode::set_margin(Sides::splat(Some(Smart::Custom( + .set(PageElem::set_width(Smart::Custom(Abs::pt(120.0).into()))); + lib.styles.set(PageElem::set_height(Smart::Auto)); + lib.styles.set(PageElem::set_margin(Sides::splat(Some(Smart::Custom( Abs::pt(10.0).into(), ))))); - lib.styles.set(TextNode::set_size(TextSize(Abs::pt(10.0).into()))); + lib.styles.set(TextElem::set_size(TextSize(Abs::pt(10.0).into()))); // Hook up helpers into the global scope. lib.global.scope_mut().define("test", test); @@ -732,14 +732,14 @@ fn render(frames: &[Frame]) -> sk::Pixmap { /// Draw extra boxes for links so we can see whether they are there. fn render_links(canvas: &mut sk::Pixmap, ts: sk::Transform, frame: &Frame) { - for (pos, element) in frame.elements() { + for (pos, item) in frame.items() { let ts = ts.pre_translate(pos.x.to_pt() as f32, pos.y.to_pt() as f32); - match *element { - Element::Group(ref group) => { + match *item { + FrameItem::Group(ref group) => { let ts = ts.pre_concat(group.transform.into()); render_links(canvas, ts, &group.frame); } - Element::Meta(Meta::Link(_), size) => { + FrameItem::Meta(Meta::Link(_), size) => { let w = size.x.to_pt() as f32; let h = size.y.to_pt() as f32; let rect = sk::Rect::from_xywh(0.0, 0.0, w, h).unwrap(); diff --git a/tests/typ/compiler/construct.typ b/tests/typ/compiler/construct.typ index 53fcfefb..da077e7e 100644 --- a/tests/typ/compiler/construct.typ +++ b/tests/typ/compiler/construct.typ @@ -1,4 +1,4 @@ -// Test node functions. +// Test constructors. --- // Ensure that constructor styles aren't passed down the tree. diff --git a/tests/typ/compiler/content-field.typ b/tests/typ/compiler/content-field.typ index b67c090d..031a65b8 100644 --- a/tests/typ/compiler/content-field.typ +++ b/tests/typ/compiler/content-field.typ @@ -2,10 +2,10 @@ #let compute(equation, ..vars) = { let vars = vars.named() - let f(node) = { - let func = node.func() + let f(elem) = { + let func = elem.func() if func == text { - let text = node.text + let text = elem.text if regex("^\d+$") in text { int(text) } else if text in vars { @@ -14,13 +14,13 @@ panic("unknown math variable: " + text) } } else if func == math.attach { - let value = f(node.base) - if node.has("top") { - value = calc.pow(value, f(node.top)) + let value = f(elem.base) + if elem.has("top") { + value = calc.pow(value, f(elem.top)) } value - } else if node.has("children") { - node + } else if elem.has("children") { + elem .children .filter(v => v != [ ]) .split[+] diff --git a/tests/typ/compiler/field.typ b/tests/typ/compiler/field.typ index 49ffca04..7529cd85 100644 --- a/tests/typ/compiler/field.typ +++ b/tests/typ/compiler/field.typ @@ -13,9 +13,9 @@ } --- -// Test field on node. -#show list: node => { - test(node.children.len(), 3) +// Test fields on elements. +#show list: it => { + test(it.children.len(), 3) } - A @@ -31,8 +31,8 @@ #false.ok --- -// Error: 29-32 content does not contain field "fun" -#show heading: node => node.fun +// Error: 25-28 content does not contain field "fun" +#show heading: it => it.fun = A --- diff --git a/tests/typ/compiler/show-node.typ b/tests/typ/compiler/show-node.typ index 0c1c1f52..99a4364e 100644 --- a/tests/typ/compiler/show-node.typ +++ b/tests/typ/compiler/show-node.typ @@ -1,4 +1,4 @@ -// Test node show rules. +// Test show rules. --- // Override lists. @@ -83,12 +83,12 @@ Another text. = Heading --- -// Error: 7-12 this function is not selectable -#show upper: it => {} +#show text: none +Hey --- -// Error: 7-11 to select text, please use a string or regex instead -#show text: it => {} +// Error: 7-12 only element functions can be used as selectors +#show upper: it => {} --- // Error: 16-20 expected content or function, found integer @@ -96,7 +96,7 @@ Another text. = Heading --- -// Error: 7-10 expected string, label, function, regular expression, or selector, found color +// Error: 7-10 expected function, label, string, regular expression, or selector, found color #show red: [] --- diff --git a/tests/typ/compute/construct.typ b/tests/typ/compute/construct.typ index 80fa9a2b..dc146719 100644 --- a/tests/typ/compute/construct.typ +++ b/tests/typ/compute/construct.typ @@ -21,11 +21,11 @@ --- // Error for values that are out of range. -// Error: 11-14 must be between 0 and 255 +// Error: 11-14 number must be between 0 and 255 #test(rgb(-30, 15, 50)) --- -// Error: 6-11 string contains non-hexadecimal letters +// Error: 6-11 color string contains non-hexadecimal letters #rgb("lol") --- diff --git a/tests/typ/layout/list-marker.typ b/tests/typ/layout/list-marker.typ index 0d223b58..97d1ce91 100644 --- a/tests/typ/layout/list-marker.typ +++ b/tests/typ/layout/list-marker.typ @@ -30,5 +30,5 @@ - a bad marker --- -// Error: 19-21 must contain at least one marker +// Error: 19-21 array must contain at least one marker #set list(marker: ()) diff --git a/tests/typ/layout/pad.typ b/tests/typ/layout/pad.typ index 2cc4d4ee..88e8510f 100644 --- a/tests/typ/layout/pad.typ +++ b/tests/typ/layout/pad.typ @@ -19,7 +19,7 @@ Hi #box(pad(left: 10pt)[A]) there #pad(left: 10pt, right: 10pt)[PL #h(1fr) PR] --- -// Test that the pad node doesn't consume the whole region. +// Test that the pad element doesn't consume the whole region. #set page(height: 6cm) #align(left)[Before] #pad(10pt, image("/tiger.jpg")) diff --git a/tests/typ/layout/par-bidi.typ b/tests/typ/layout/par-bidi.typ index d8c05d23..90c6a55e 100644 --- a/tests/typ/layout/par-bidi.typ +++ b/tests/typ/layout/par-bidi.typ @@ -51,5 +51,5 @@ Lריווח #h(1cm) R // Test setting a vertical direction. // Ref: false -// Error: 16-19 must be horizontal +// Error: 16-19 text direction must be horizontal #set text(dir: ttb) diff --git a/tests/typ/layout/place.typ b/tests/typ/layout/place.typ index 18f7642d..f0ffaf57 100644 --- a/tests/typ/layout/place.typ +++ b/tests/typ/layout/place.typ @@ -7,7 +7,7 @@ = Placement #place(right, image("/tiger.jpg", width: 1.8cm)) Hi there. This is \ -a placed node. \ +a placed element. \ Unfortunately, \ the line breaks still had to be inserted manually. @@ -25,7 +25,7 @@ the line breaks still had to be inserted manually. ) --- -// Test how the placed node interacts with paragraph spacing around it. +// Test how the placed element interacts with paragraph spacing around it. #set page("a8", height: 60pt) First diff --git a/tests/typ/meta/counter.typ b/tests/typ/meta/counter.typ index c3b97629..a3814216 100644 --- a/tests/typ/meta/counter.typ +++ b/tests/typ/meta/counter.typ @@ -41,7 +41,7 @@ In #counter(heading).display(). At Beta, it was #locate(loc => { let it = query(heading, loc).find(it => it.body == [Beta]) - numbering(it.numbering, ..counter(heading).at(it.id())) + numbering(it.numbering, ..counter(heading).at(it.location())) }) --- diff --git a/tests/typ/meta/document.typ b/tests/typ/meta/document.typ index f2c7a8bb..bc9d4908 100644 --- a/tests/typ/meta/document.typ +++ b/tests/typ/meta/document.typ @@ -19,23 +19,23 @@ What's up? --- Hello -// Error: 2-30 must appear before any content +// Error: 2-30 document set rules must appear before any content #set document(title: "Hello") --- #box[ - // Error: 4-32 not allowed here + // Error: 4-32 document set rules are not allowed inside of containers #set document(title: "Hello") ] --- #box[ - // Error: 4-18 not allowed here + // Error: 4-18 page configuration is not allowed inside of containers #set page("a4") ] --- #box[ - // Error: 4-15 not allowed here + // Error: 4-15 pagebreaks are not allowed inside of containers #pagebreak() ] diff --git a/tests/typ/meta/query.typ b/tests/typ/meta/query.typ index 38eadfab..8f8dcd3d 100644 --- a/tests/typ/meta/query.typ +++ b/tests/typ/meta/query.typ @@ -47,10 +47,10 @@ for it in elements [ Figure #numbering(it.numbering, - ..counter(figure).at(it.id())): + ..counter(figure).at(it.location())): #it.caption #box(width: 1fr, repeat[.]) - #counter(page).at(it.id()).first() \ + #counter(page).at(it.location()).first() \ ] }) diff --git a/tests/typ/meta/state.typ b/tests/typ/meta/state.typ index 8dfab05b..a7c3d26a 100644 --- a/tests/typ/meta/state.typ +++ b/tests/typ/meta/state.typ @@ -10,9 +10,9 @@ $ 2 + 3 $ #s.update(double) Is: #s.display(), -Was: #locate(id => { - let it = query(math.equation, id).first() - s.at(it.id()) +Was: #locate(location => { + let it = query(math.equation, location).first() + s.at(it.location()) }). --- diff --git a/tests/typ/text/features.typ b/tests/typ/text/features.typ index 360e8a11..69a7064f 100644 --- a/tests/typ/text/features.typ +++ b/tests/typ/text/features.typ @@ -47,7 +47,7 @@ fi vs. #text(features: (liga: 0))[No fi] #set text(stylistic-set: false) --- -// Error: 26-28 must be between 1 and 20 +// Error: 26-28 stylistic set must be between 1 and 20 #set text(stylistic-set: 25) --- diff --git a/tests/typ/text/symbol.typ b/tests/typ/text/symbol.typ index 949f82d2..f7179449 100644 --- a/tests/typ/text/symbol.typ +++ b/tests/typ/text/symbol.typ @@ -14,5 +14,5 @@ #sym.arrow.r;this and this#sym.arrow.l; --- -// Error: 13-20 unknown modifier +// Error: 13-20 unknown symbol modifier #emoji.face.garbage |
