diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-29 13:37:25 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-29 14:18:13 +0100 |
| commit | 0efe669278a5e1c3f2985eba2f3360e91159c54a (patch) | |
| tree | 502712857c48f0decb5e698257c0a96d358a436e /tests/typ/style | |
| parent | 836692e73cff0356e409a9ba5b4887b86809d4ca (diff) | |
Reorganize library and tests
Diffstat (limited to 'tests/typ/style')
| -rw-r--r-- | tests/typ/style/construct.typ | 31 | ||||
| -rw-r--r-- | tests/typ/style/document.typ | 30 | ||||
| -rw-r--r-- | tests/typ/style/label.typ | 58 | ||||
| -rw-r--r-- | tests/typ/style/set.typ | 66 | ||||
| -rw-r--r-- | tests/typ/style/show-bare.typ | 33 | ||||
| -rw-r--r-- | tests/typ/style/show-node.typ | 104 | ||||
| -rw-r--r-- | tests/typ/style/show-recursive.typ | 51 | ||||
| -rw-r--r-- | tests/typ/style/show-selector.typ | 36 | ||||
| -rw-r--r-- | tests/typ/style/show-text.typ | 59 |
9 files changed, 0 insertions, 468 deletions
diff --git a/tests/typ/style/construct.typ b/tests/typ/style/construct.typ deleted file mode 100644 index f535184c..00000000 --- a/tests/typ/style/construct.typ +++ /dev/null @@ -1,31 +0,0 @@ -// Test node functions. - ---- -// Ensure that constructor styles aren't passed down the tree. -// The inner list should have no extra indent. -#set par(leading: 2pt) -#list(body-indent: 20pt, [First], list[A][B]) - ---- -// Ensure that constructor styles win, but not over outer styles. -// The outer paragraph should be right-aligned, -// but the B should be center-aligned. -#set par(align: center) -#par(align: right)[ - A #rect(width: 2cm, fill: conifer, inset: 4pt)[B] -] - ---- -// The inner rectangle should also be yellow here. -// (and therefore invisible) -[#set rect(fill: yellow);#text(1em, rect(inset: 5pt, rect()))] - ---- -// The inner rectangle should not be yellow here. -A #rect(fill: yellow, inset: 5pt, rect()) B - ---- -// The constructor property should still work -// when there are recursive show rules. -#show list: set text(blue) -#list(label: "(a)", [A], list[B]) diff --git a/tests/typ/style/document.typ b/tests/typ/style/document.typ deleted file mode 100644 index 1fcb8109..00000000 --- a/tests/typ/style/document.typ +++ /dev/null @@ -1,30 +0,0 @@ -// Test document and page-level styles. - ---- -// This is okay. -// Ref: false -#set document(title: "Hello") - ---- -Hello - -// Error: 1-30 must appear before any content -#set document(title: "Hello") - ---- -#box[ - // Error: 3-32 not allowed here - #set document(title: "Hello") -] - ---- -#box[ - // Error: 3-18 not allowed here - #set page("a4") -] - ---- -#box[ - // Error: 3-15 not allowed here - #pagebreak() -] diff --git a/tests/typ/style/label.typ b/tests/typ/style/label.typ deleted file mode 100644 index 795c0435..00000000 --- a/tests/typ/style/label.typ +++ /dev/null @@ -1,58 +0,0 @@ -// Test labels. - ---- -// Test labelled headings. -#show heading: set text(10pt) -#show heading.where(label: <intro>): underline - -= Introduction <intro> -The beginning. - -= Conclusion -The end. - ---- -// Test label after expression. -#show strong.where(label: <v>): set text(red) - -#let a = [*A*] -#let b = [*B*] -#a <v> #b - ---- -// Test labelled text. -#show "t": it => { - set text(blue) if it.label == <last> - it -} - -This is a thing [that <last>] happened. - ---- -// Test abusing dynamic labels for styling. -#show <red>: set text(red) -#show <blue>: set text(blue) - -*A* *B* <red> *C* #label("bl" + "ue") *D* - ---- -// Test that label ignores parbreak. -#show <hide>: none - -_Hidden_ -<hide> - -_Hidden_ - -<hide> -_Visible_ - ---- -// Test that label only works within one content block. -#show <strike>: strike -*This is* [<strike>] *protected.* -*This is not.* <strike> - ---- -// Test that incomplete label is text. -1 < 2 is #if 1 < 2 [not] a label. diff --git a/tests/typ/style/set.typ b/tests/typ/style/set.typ deleted file mode 100644 index fc5053b1..00000000 --- a/tests/typ/style/set.typ +++ /dev/null @@ -1,66 +0,0 @@ -// General tests for set. - ---- -// Test that text is affected by instantiation-site bold. -#let x = [World] -Hello *{x}* - ---- -// Test that lists are affected by correct indents. -#let fruit = [ - - Apple - - Orange - #list(body-indent: 20pt, [Pear]) -] - -- Fruit -[#set list(indent: 10pt) - #fruit] -- No more fruit - ---- -// Test that that block spacing and text style are respected from -// the outside, but the more specific fill is respected. -#set block(spacing: 4pt) -#set text(style: "italic", fill: eastern) -#let x = [And the forest #parbreak() lay silent!] -#text(fill: forest, x) - ---- -// Test that scoping works as expected. -{ - if true { - set text(blue) - [Blue ] - } - [Not blue] -} - ---- -// Test relative path resolving in layout phase. -#let choice = ("monkey.svg", "rhino.png", "tiger.jpg") -#set enum(label: n => { - let path = "../../res/" + choice(n - 1) - move(dy: -0.15em, image(path, width: 1em, height: 1em)) -}) - -+ Monkey -+ Rhino -+ Tiger - ---- -// Test conditional set. -#show ref: it => { - set text(red) if it.target == "unknown" - it -} - -@hello from the @unknown - ---- -// Error: 19-24 expected boolean, found integer -#set text(red) if 1 + 2 - ---- -// Error: 11-25 set is only allowed directly in code and content blocks -{ let x = set text(blue) } diff --git a/tests/typ/style/show-bare.typ b/tests/typ/style/show-bare.typ deleted file mode 100644 index 8b8d0852..00000000 --- a/tests/typ/style/show-bare.typ +++ /dev/null @@ -1,33 +0,0 @@ -// Test bare show without selector. - ---- -#set page(height: 130pt) -#set text(0.7em) - -#align(center)[ - #text(1.3em)[*Essay on typography*] \ - T. Ypst -] - -#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. - ---- -// Test bare show in content block. -A [_B #show c => [*#c*]; C_] D - ---- -// Test style precedence. -#set text(fill: eastern, size: 1.5em) -#show text.with(fill: forest) -Forest - ---- -#show [Shown] -Ignored - ---- -// Error: 4-18 show is only allowed directly in code and content blocks -{ (show body => 2) * body } diff --git a/tests/typ/style/show-node.typ b/tests/typ/style/show-node.typ deleted file mode 100644 index 98f36f13..00000000 --- a/tests/typ/style/show-node.typ +++ /dev/null @@ -1,104 +0,0 @@ -// Test node show rules. - ---- -// Override lists. -#show list: it => "(" + it.items.join(", ") + ")" - -- A - - B - - C -- D -- E - ---- -// Test full reset. -#show heading: [B] -#show heading: set text(size: 10pt, weight: 400) -A [= Heading] C - ---- -// Test full removal. -#show heading: none - -Where is -= There are no headings around here! -my heading? - ---- -// Test integrated example. -#show heading: it => block({ - set text(10pt) - move(dy: -1pt)[📖] - h(5pt) - if it.level == 1 { - underline(text(1.25em, blue, it.body)) - } else { - text(red, it.body) - } -}) - -= Task 1 -Some text. - -== Subtask -Some more text. - -= Task 2 -Another text. - ---- -// Test set and show in code blocks. -#show heading: it => { - set text(red) - show "ding": [🛎] - it.body -} - -= Heading - ---- -// Test that scoping works as expected. -{ - let world = [ World ] - show "W": strong - world - { - set text(blue) - show it => { - show "o": "Ø" - it - } - world - } - world -} - ---- -#show heading: [1234] -= Heading - ---- -// Error: 25-29 unknown field "page" -#show heading: it => it.page -= Heading - ---- -// Error: 7-12 this function is not selectable -#show upper: it => {} - ---- -// Error: 7-11 to select text, please use a string or regex instead -#show text: it => {} - ---- -// Error: 16-20 expected content or function, found integer -#show heading: 1234 -= Heading - ---- -// Error: 7-10 expected selector, found color -#show red: [] - ---- -// Error: 7-25 show is only allowed directly in code and content blocks -{ 1 + show heading: none } diff --git a/tests/typ/style/show-recursive.typ b/tests/typ/style/show-recursive.typ deleted file mode 100644 index 91a295f2..00000000 --- a/tests/typ/style/show-recursive.typ +++ /dev/null @@ -1,51 +0,0 @@ -// Test recursive show rules. - ---- -// Test basic identity. -#show heading: it => it -= Heading - ---- -// Test more recipes down the chain. -#show list: scale.with(origin: left, x: 80%) -#show heading: [] -#show enum: [] -- Actual -- Tight -- List -= Nope - ---- -// Test show rule in function. -#let starwars(body) = { - show list: it => block({ - stack(dir: ltr, - text(red, it), - 1fr, - scale(x: -100%, text(blue, it)), - ) - }) - body -} - -- Normal list - -#starwars[ - - Star - - Wars - - List -] - -- Normal list - ---- -// Test multi-recursion with nested lists. -#set rect(inset: 3pt) -#show list: rect.with(stroke: blue) -#show list: rect.with(stroke: red) -#show list: block - -- List - - Nested - - List -- Recursive! diff --git a/tests/typ/style/show-selector.typ b/tests/typ/style/show-selector.typ deleted file mode 100644 index 0e9823a5..00000000 --- a/tests/typ/style/show-selector.typ +++ /dev/null @@ -1,36 +0,0 @@ -// Test show rule patterns. - ---- -// Inline code. -#show raw.where(block: false): rect.with( - radius: 2pt, - outset: (y: 3pt), - inset: (x: 3pt), - fill: luma(230), -) - -// Code blocks. -#show raw.where(block: true): rect.with( - outset: -3pt, - inset: 11pt, - fill: luma(230), - stroke: (left: 1.5pt + luma(180)), -) - -#set page(margin: (top: 12pt)) -#set par(justify: true) - -This code tests `code` -with selectors and justification. - -```rs -code!("it"); -``` - ---- -#show heading.where(level: 1): set text(red) -#show heading.where(level: 2): set text(blue) -#show heading: set text(green) -= Red -== Blue -=== Green diff --git a/tests/typ/style/show-text.typ b/tests/typ/style/show-text.typ deleted file mode 100644 index 124d2ed2..00000000 --- a/tests/typ/style/show-text.typ +++ /dev/null @@ -1,59 +0,0 @@ -// Test text replacement show rules. - ---- -// Test classic example. -#set text("Roboto") -#show "Der Spiegel": smallcaps -Die Zeitung Der Spiegel existiert. - ---- -// Another classic example. -#show "TeX": [T#h(-0.145em)#move(dy: 0.233em)[E]#h(-0.135em)X] -#show regex("(Lua)?(La)?TeX"): name => box(text("Latin Modern Roman")[#name]) - -TeX, LaTeX, LuaTeX and LuaLaTeX! - ---- -// Test that replacements happen exactly once. -#show "A": [BB] -#show "B": [CC] -AA (8) - ---- -// Test caseless match and word boundaries. -#show regex("(?i)\bworld\b"): [🌍] - -Treeworld, the World of worlds, is a world. - ---- -// This is a fun one. -#set par(justify: true) -#show regex("\S"): letter => rect(inset: 2pt)[#upper(letter)] -#lorem(5) - ---- -// See also: https://github.com/mTvare6/hello-world.rs -#show regex("(?i)rust"): it => [#it (🚀)] -Rust is memory-safe and blazingly fast. Let's rewrite everything in rust. - ---- -// Test accessing the string itself. -#show "hello": it => it.text.split("").map(upper).join("|") -Oh, hello there! - ---- -// Replace worlds but only in lists. -#show list: it => [ - #show "World": [🌎] - #it -] - -World -- World - ---- -// Test absolute path in layout phase. - -#show "GRAPH": image("/res/graph.png") - -The GRAPH has nodes. |
