summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-04-30 14:12:28 +0200
committerLaurenz <laurmaedje@gmail.com>2022-04-30 14:12:28 +0200
commitf9e115daf54c29358f890b137f50a33a781af680 (patch)
tree496de52246629ea8039db6beea94eb779ed2851d /tests
parentf7c67cde72e6a67f45180856b332bae9863243bd (diff)
New block spacing model
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/code/include.pngbin47947 -> 47545 bytes
-rw-r--r--tests/ref/coma.pngbin84510 -> 85923 bytes
-rw-r--r--tests/ref/layout/align.pngbin7832 -> 7901 bytes
-rw-r--r--tests/ref/layout/pad.pngbin53957 -> 53637 bytes
-rw-r--r--tests/ref/layout/place.pngbin44083 -> 43337 bytes
-rw-r--r--tests/ref/layout/stack-1.pngbin1076 -> 1522 bytes
-rw-r--r--tests/ref/math/basic.pngbin3619 -> 3639 bytes
-rw-r--r--tests/ref/structure/attach.pngbin0 -> 10993 bytes
-rw-r--r--tests/ref/structure/heading.pngbin23257 -> 22641 bytes
-rw-r--r--tests/ref/structure/list.pngbin22839 -> 20169 bytes
-rw-r--r--tests/ref/style/set-site.pngbin12569 -> 12397 bytes
-rw-r--r--tests/ref/style/show.pngbin19940 -> 19486 bytes
-rw-r--r--tests/ref/text/bidi.pngbin25815 -> 25981 bytes
-rw-r--r--tests/ref/text/indent.pngbin37966 -> 46160 bytes
-rw-r--r--tests/ref/text/par.pngbin11738 -> 30068 bytes
-rw-r--r--tests/ref/text/raw.pngbin22255 -> 22841 bytes
-rw-r--r--tests/typ/code/ops-invalid.typ4
-rw-r--r--tests/typ/code/ops.typ2
-rw-r--r--tests/typ/coma.typ7
-rw-r--r--tests/typ/graphics/transform.typ6
-rw-r--r--tests/typ/layout/pagebreak.typ12
-rw-r--r--tests/typ/layout/place.typ12
-rw-r--r--tests/typ/layout/spacing.typ4
-rw-r--r--tests/typ/layout/stack-1.typ32
-rw-r--r--tests/typ/structure/attach.typ56
-rw-r--r--tests/typ/structure/enum.typ3
-rw-r--r--tests/typ/structure/heading.typ9
-rw-r--r--tests/typ/structure/list.typ11
-rw-r--r--tests/typ/style/closure.typ1
-rw-r--r--tests/typ/style/set-site.typ4
-rw-r--r--tests/typ/style/show.typ2
-rw-r--r--tests/typ/text/indent.typ10
-rw-r--r--tests/typ/text/knuth.typ5
-rw-r--r--tests/typ/text/link.typ4
-rw-r--r--tests/typ/text/par.typ45
-rw-r--r--tests/typ/text/raw.typ12
-rw-r--r--tests/typ/utility/blind.typ8
37 files changed, 165 insertions, 84 deletions
diff --git a/tests/ref/code/include.png b/tests/ref/code/include.png
index 001d7d1e..d3d66032 100644
--- a/tests/ref/code/include.png
+++ b/tests/ref/code/include.png
Binary files differ
diff --git a/tests/ref/coma.png b/tests/ref/coma.png
index f9d30890..817c756a 100644
--- a/tests/ref/coma.png
+++ b/tests/ref/coma.png
Binary files differ
diff --git a/tests/ref/layout/align.png b/tests/ref/layout/align.png
index 5dde0cef..9b6e268c 100644
--- a/tests/ref/layout/align.png
+++ b/tests/ref/layout/align.png
Binary files differ
diff --git a/tests/ref/layout/pad.png b/tests/ref/layout/pad.png
index c2906cef..7c27bd26 100644
--- a/tests/ref/layout/pad.png
+++ b/tests/ref/layout/pad.png
Binary files differ
diff --git a/tests/ref/layout/place.png b/tests/ref/layout/place.png
index 7900f95f..6fc11706 100644
--- a/tests/ref/layout/place.png
+++ b/tests/ref/layout/place.png
Binary files differ
diff --git a/tests/ref/layout/stack-1.png b/tests/ref/layout/stack-1.png
index 106cc791..167fd84c 100644
--- a/tests/ref/layout/stack-1.png
+++ b/tests/ref/layout/stack-1.png
Binary files differ
diff --git a/tests/ref/math/basic.png b/tests/ref/math/basic.png
index 2c1dd324..381e92c4 100644
--- a/tests/ref/math/basic.png
+++ b/tests/ref/math/basic.png
Binary files differ
diff --git a/tests/ref/structure/attach.png b/tests/ref/structure/attach.png
new file mode 100644
index 00000000..7082a475
--- /dev/null
+++ b/tests/ref/structure/attach.png
Binary files differ
diff --git a/tests/ref/structure/heading.png b/tests/ref/structure/heading.png
index 693ae763..3e12b2cf 100644
--- a/tests/ref/structure/heading.png
+++ b/tests/ref/structure/heading.png
Binary files differ
diff --git a/tests/ref/structure/list.png b/tests/ref/structure/list.png
index ac90f4b2..7a60e1e5 100644
--- a/tests/ref/structure/list.png
+++ b/tests/ref/structure/list.png
Binary files differ
diff --git a/tests/ref/style/set-site.png b/tests/ref/style/set-site.png
index 408e44bf..024f7c3e 100644
--- a/tests/ref/style/set-site.png
+++ b/tests/ref/style/set-site.png
Binary files differ
diff --git a/tests/ref/style/show.png b/tests/ref/style/show.png
index 0f1a16a3..9539e496 100644
--- a/tests/ref/style/show.png
+++ b/tests/ref/style/show.png
Binary files differ
diff --git a/tests/ref/text/bidi.png b/tests/ref/text/bidi.png
index f31bdf0a..6f4c8acb 100644
--- a/tests/ref/text/bidi.png
+++ b/tests/ref/text/bidi.png
Binary files differ
diff --git a/tests/ref/text/indent.png b/tests/ref/text/indent.png
index 42f05cfb..09d8e68d 100644
--- a/tests/ref/text/indent.png
+++ b/tests/ref/text/indent.png
Binary files differ
diff --git a/tests/ref/text/par.png b/tests/ref/text/par.png
index 19f28b81..ae00ab45 100644
--- a/tests/ref/text/par.png
+++ b/tests/ref/text/par.png
Binary files differ
diff --git a/tests/ref/text/raw.png b/tests/ref/text/raw.png
index 64402dae..e13293a6 100644
--- a/tests/ref/text/raw.png
+++ b/tests/ref/text/raw.png
Binary files differ
diff --git a/tests/typ/code/ops-invalid.typ b/tests/typ/code/ops-invalid.typ
index 1506d9c4..4e7fdb04 100644
--- a/tests/typ/code/ops-invalid.typ
+++ b/tests/typ/code/ops-invalid.typ
@@ -30,6 +30,10 @@
{30% + 1pt <= 40%}
---
+// Error: 2-13 cannot apply '<=' to length and length
+{1em <= 10pt}
+
+---
// Special messages for +, -, * and /.
// Error: 03-10 cannot add integer and string
{(1 + "2", 40% - 1)}
diff --git a/tests/typ/code/ops.typ b/tests/typ/code/ops.typ
index 53cf488e..1f2867bc 100644
--- a/tests/typ/code/ops.typ
+++ b/tests/typ/code/ops.typ
@@ -151,6 +151,8 @@
#test(45deg < 1rad, true)
#test(10% < 20%, true)
#test(50% < 40% + 0pt, false)
+#test(40% + 0pt < 50% + 0pt, true)
+#test(1em < 2em, true)
---
// Test assignment operators.
diff --git a/tests/typ/coma.typ b/tests/typ/coma.typ
index 92d5695f..0e228d14 100644
--- a/tests/typ/coma.typ
+++ b/tests/typ/coma.typ
@@ -6,10 +6,11 @@ Sekretariat MA \
Dr. Max Mustermann \
Ola Nordmann, John Doe
-#v(2mm)
+#v(3mm)
#align(center)[
- ==== 3. Übungsblatt Computerorientierte Mathematik II #v(1mm)
- *Abgabe: 03.05.2019* (bis 10:10 Uhr in MA 001) #v(1mm)
+ #set par(leading: 3mm)
+ #text(1.2em)[*3. Übungsblatt Computerorientierte Mathematik II*] \
+ *Abgabe: 03.05.2019* (bis 10:10 Uhr in MA 001) \
*Alle Antworten sind zu beweisen.*
]
diff --git a/tests/typ/graphics/transform.typ b/tests/typ/graphics/transform.typ
index 82ee1390..e0679306 100644
--- a/tests/typ/graphics/transform.typ
+++ b/tests/typ/graphics/transform.typ
@@ -6,7 +6,7 @@
#let tex = [{
[T]
h(-0.14 * size)
- move(y: 0.22 * size)[E]
+ move(dy: 0.22 * size)[E]
h(-0.12 * size)
[X]
}]
@@ -14,11 +14,11 @@
#let xetex = {
[X]
h(-0.14 * size)
- scale(x: -100%, move(y: 0.26 * size)[E])
+ scale(x: -100%, move(dy: 0.26 * size)[E])
h(-0.14 * size)
[T]
h(-0.14 * size)
- move(y: 0.26 * size)[E]
+ move(dy: 0.26 * size)[E]
h(-0.12 * size)
[X]
}
diff --git a/tests/typ/layout/pagebreak.typ b/tests/typ/layout/pagebreak.typ
index df3b0423..349a2fc2 100644
--- a/tests/typ/layout/pagebreak.typ
+++ b/tests/typ/layout/pagebreak.typ
@@ -13,14 +13,14 @@
#pagebreak()
---
-// Two text bodies separated with and surrounded by soft pagebreaks.
+// Two text bodies separated with and surrounded by weak pagebreaks.
// Should result in two aqua-colored pages.
#set page(fill: aqua)
-#pagebreak(soft: true)
+#pagebreak(weak: true)
First
-#pagebreak(soft: true)
+#pagebreak(weak: true)
Second
-#pagebreak(soft: true)
+#pagebreak(weak: true)
---
// Test a combination of pagebreaks, styled pages and pages with bodies.
@@ -34,12 +34,12 @@ Third
Fif[#set page();th]
---
-// Test hard and soft pagebreak followed by page with body.
+// Test hard and weak pagebreak followed by page with body.
// Should result in three navy-colored pages.
#set page(fill: navy)
#set text(fill: white)
First
#pagebreak()
#page[Second]
-#pagebreak(soft: true)
+#pagebreak(weak: true)
#page[Third]
diff --git a/tests/typ/layout/place.typ b/tests/typ/layout/place.typ
index 527e0559..95049bdc 100644
--- a/tests/typ/layout/place.typ
+++ b/tests/typ/layout/place.typ
@@ -16,14 +16,14 @@ the line breaks still had to be inserted manually.
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
+ ]
)
-#block[
- #place(center, dx: -7pt, dy: -5pt)[Hello]
- #place(center, dx: 7pt, dy: 5pt)[Hello]
- Hello #h(1fr) Hello
-]
-
---
// Test how the placed node interacts with paragraph spacing around it.
#set page("a8", height: 60pt)
diff --git a/tests/typ/layout/spacing.typ b/tests/typ/layout/spacing.typ
index 378c11b8..eb0bd39e 100644
--- a/tests/typ/layout/spacing.typ
+++ b/tests/typ/layout/spacing.typ
@@ -1,8 +1,8 @@
// Test the `h` and `v` functions.
---
-// Linebreak and v(0pt) are equivalent.
-#box[A \ B] #box[A #v(0pt) B]
+// Linebreak and leading-sized weak spacing are equivalent.
+#box[A \ B] #box[A #v(0.65em, weak: true) B]
// Eating up soft spacing.
Inv#h(0pt)isible
diff --git a/tests/typ/layout/stack-1.typ b/tests/typ/layout/stack-1.typ
index eee1f4d1..19a00de5 100644
--- a/tests/typ/layout/stack-1.typ
+++ b/tests/typ/layout/stack-1.typ
@@ -19,24 +19,16 @@
#stack(dir: btt, ..items)
---
-// Test RTL alignment.
-#set page(width: 50pt, margins: 5pt)
-#set text(8pt)
-#stack(dir: rtl,
- align(center, [A]),
- align(left, [B]),
- [C],
-)
-
----
// Test spacing.
#set page(width: 50pt, margins: 0pt)
-#set par(leading: 5pt)
#let x = square(size: 10pt, fill: eastern)
-#stack(dir: rtl, spacing: 5pt, x, x, x)
-#stack(dir: ltr, x, 20%, x, 20%, x)
-#stack(dir: ltr, spacing: 5pt, x, x, 7pt, 3pt, x)
+#stack(
+ spacing: 5pt,
+ stack(dir: rtl, spacing: 5pt, x, x, x),
+ stack(dir: ltr, x, 20%, x, 20%, x),
+ stack(dir: ltr, spacing: 5pt, x, x, 7pt, 3pt, x),
+)
---
// Test overflow.
@@ -45,3 +37,15 @@
rect(width: 40pt, height: 20pt, fill: conifer),
rect(width: 30pt, height: 13pt, fill: forest),
))
+
+---
+// Test aligning things in RTL stack with align function & fr units.
+#set page(width: 50pt, margins: 5pt)
+#set text(8pt)
+#stack(dir: rtl, 1fr, [A], 1fr, [B], [C])
+#v(5pt)
+#stack(dir: rtl,
+ align(center, [A]),
+ align(left, [B]),
+ [C],
+)
diff --git a/tests/typ/structure/attach.typ b/tests/typ/structure/attach.typ
new file mode 100644
index 00000000..c6d3c28c
--- /dev/null
+++ b/tests/typ/structure/attach.typ
@@ -0,0 +1,56 @@
+// Test list attaching.
+
+---
+// Test basic attached list.
+Attached to:
+- the bottom
+- of the paragraph
+
+Next paragraph.
+
+---
+// Test attached list without parbreak after it.
+// Ensures the par spacing is used below by setting
+// super high around spacing.
+#set list(around: 100pt)
+Hello
+- A
+World
+- B
+
+---
+// Test non-attached list followed by attached list,
+// separated by only word.
+Hello
+
+- A
+
+World
+- B
+
+---
+// Test not-attached tight list.
+#set list(around: 15pt)
+Hello
+- A
+World
+
+- B
+- C
+
+More.
+
+---
+// Test that wide lists cannot be attached ...
+#set list(around: 15pt, spacing: 15pt)
+Hello
+- A
+
+- B
+World
+
+---
+// ... unless really forced to.
+Hello
+#list(attached: true, tight: false)[A][B]
+World
diff --git a/tests/typ/structure/enum.typ b/tests/typ/structure/enum.typ
index c4d178ce..b1045ee2 100644
--- a/tests/typ/structure/enum.typ
+++ b/tests/typ/structure/enum.typ
@@ -39,7 +39,8 @@
// Test label closure.
#enum(
start: 4,
- spacing: -3pt,
+ spacing: 0.65em - 3pt,
+ tight: false,
label: n => text(fill: (red, green, blue)(mod(n, 3)), [#upper(letter(n))]),
[Red], [Green], [Blue],
)
diff --git a/tests/typ/structure/heading.typ b/tests/typ/structure/heading.typ
index f4ba5f33..de95c35b 100644
--- a/tests/typ/structure/heading.typ
+++ b/tests/typ/structure/heading.typ
@@ -1,14 +1,13 @@
// Test headings.
---
-// Different number of hashtags.
+// Different number of equals signs.
-// Valid levels.
= Level 1
-=== Level 2
-====== Level 6
+== Level 2
+=== Level 3
-// At some point, it should stop shrinking.
+// After three, it stops shrinking.
=========== Level 11
---
diff --git a/tests/typ/structure/list.typ b/tests/typ/structure/list.typ
index 52cd51be..77e153c7 100644
--- a/tests/typ/structure/list.typ
+++ b/tests/typ/structure/list.typ
@@ -2,21 +2,16 @@
---
_Shopping list_
-#list[Apples][Potatoes][Juice]
-
----
-Tightly
-- surrounded
-- by two
-paragraphs.
+#list(attached: true)[Apples][Potatoes][Juice]
---
- First level.
- Second level.
-
There are multiple paragraphs.
+
- Third level.
+
Still the same bullet point.
- Still level 2.
diff --git a/tests/typ/style/closure.typ b/tests/typ/style/closure.typ
index 22626472..cd1f87df 100644
--- a/tests/typ/style/closure.typ
+++ b/tests/typ/style/closure.typ
@@ -3,6 +3,7 @@
---
#set heading(
size: 10pt,
+ around: 0.65em,
fill: lvl => if even(lvl) { red } else { blue },
)
diff --git a/tests/typ/style/set-site.typ b/tests/typ/style/set-site.typ
index 8ee8a5fd..b49d1027 100644
--- a/tests/typ/style/set-site.typ
+++ b/tests/typ/style/set-site.typ
@@ -11,7 +11,7 @@ Hello *{x}*
#let fruit = [
- Apple
- Orange
- #list(body-indent: 10pt, [Pear])
+ #list(body-indent: 20pt, [Pear])
]
- Fruit
@@ -22,7 +22,7 @@ Hello *{x}*
---
// Test that that par spacing and text style are respected from
// the outside, but the more specific fill is respected.
-#set par(spacing: 0pt)
+#set par(spacing: 4pt)
#set text(style: "italic", fill: eastern)
#let x = [And the forest #parbreak() lay silent!]
#text(fill: forest, x)
diff --git a/tests/typ/style/show.typ b/tests/typ/style/show.typ
index 9aabfb34..a71b8df2 100644
--- a/tests/typ/style/show.typ
+++ b/tests/typ/style/show.typ
@@ -29,7 +29,7 @@ Some more text.
Another text.
---
-#set heading(size: 1em, strong: false, block: false)
+#set heading(size: 1em, strong: false, around: none)
#show _: heading as [B]
A [= Heading] C
diff --git a/tests/typ/text/indent.typ b/tests/typ/text/indent.typ
index 1b48851b..897e360c 100644
--- a/tests/typ/text/indent.typ
+++ b/tests/typ/text/indent.typ
@@ -1,7 +1,7 @@
// Test paragraph indent.
---
-#set par(indent: 12pt, leading: 5pt, spacing: 0pt)
+#set par(indent: 12pt, leading: 5pt)
#set heading(size: 10pt, above: 8pt)
The first paragraph has no indent.
@@ -26,3 +26,11 @@ starts a paragraph without indent.
دع النص يمطر عليك
ثم يصبح النص رطبًا وقابل للطرق ويبدو المستند رائعًا.
+
+
+---
+// This is madness.
+#set par(indent: 12pt, spacing-and-indent: true)
+Why would anybody ever ...
+
+... want spacing and indent?
diff --git a/tests/typ/text/knuth.typ b/tests/typ/text/knuth.typ
index 5adeee91..59349738 100644
--- a/tests/typ/text/knuth.typ
+++ b/tests/typ/text/knuth.typ
@@ -15,8 +15,9 @@
#let column(title, linebreaks, hyphenate) = {
rect(width: 132pt, fill: rgb("eee"))[
- #strong(title)
- #par(linebreaks: linebreaks, text(hyphenate: hyphenate, story))
+ #set par(linebreaks: linebreaks)
+ #set text(hyphenate: hyphenate)
+ #strong(title) \ #story
]
}
diff --git a/tests/typ/text/link.typ b/tests/typ/text/link.typ
index 99037ee3..ad538187 100644
--- a/tests/typ/text/link.typ
+++ b/tests/typ/text/link.typ
@@ -25,11 +25,11 @@ You could also make the
#set page(height: 60pt)
#set link(underline: false)
#let mylink = link("https://typst.app/")[LINK]
-My cool #move(x: 0.7cm, y: 0.7cm, rotate(10deg, scale(200%, mylink)))
+My cool #move(dx: 0.7cm, dy: 0.7cm, rotate(10deg, scale(200%, mylink)))
---
// Link containing a block.
#link("https://example.com/", underline: false, block[
My cool rhino
- #move(x: 10pt, image("../../res/rhino.png", width: 1cm))
+ #move(dx: 10pt, image("../../res/rhino.png", width: 1cm))
])
diff --git a/tests/typ/text/par.typ b/tests/typ/text/par.typ
index 6b7c0f59..64a2dd17 100644
--- a/tests/typ/text/par.typ
+++ b/tests/typ/text/par.typ
@@ -6,35 +6,44 @@
To the right! Where the sunlight peeks behind the mountain.
---
-// Test that explicit paragraph break respects active styles.
-#set par(spacing: 0pt)
-[#set par(spacing: 100pt);First]
+// Test changing leading and spacing.
+#set par(spacing: 1em, leading: 2pt)
+But, soft! what light through yonder window breaks?
-[#set par(spacing: 100pt);Second]
-#set par(spacing: 13.5pt)
+It is the east, and Juliet is the sun.
+---
+// Test that largest paragraph spacing wins.
+#set par(spacing: 2.5pt)
+[#set par(spacing: 15pt);First]
+[#set par(spacing: 7.5pt);Second]
Third
+Fourth
+
---
-// Test that paragraph spacing uses correct set rule.
+// Test that paragraph spacing loses against block spacing.
+#set par(spacing: 100pt)
+#set table(around: 5pt)
Hello
+#table(columns: 4, secondary: silver)[A][B][C][D]
-#set par(spacing: 100pt)
-World
-#set par(spacing: 0pt, leading: 0pt)
+---
+// While we're at it, test the larger block spacing wins.
+#set raw(around: 15pt)
+#set math(around: 7.5pt)
+#set list(around: 2.5pt)
+#set par(spacing: 0pt)
-You
+```rust
+fn main() {}
+```
----
-// Test that paragraphs break due to incompatibility has correct spacing.
-A #set par(spacing: 0pt, leading: 0pt); B #parbreak() C
+$[ x + y = z ]$
----
-// Test weird metrics.
-#set par(spacing: 1em, leading: 0pt)
-But, soft! what light through yonder window breaks?
+- List
-It is the east, and Juliet is the sun.
+Paragraph
---
// Error: 17-20 must be horizontal
diff --git a/tests/typ/text/raw.typ b/tests/typ/text/raw.typ
index 0e053a9b..33b08568 100644
--- a/tests/typ/text/raw.typ
+++ b/tests/typ/text/raw.typ
@@ -6,17 +6,17 @@
---
// Typst syntax inside.
-`#let x = 1` \
-`#f(1)`
+```typ #let x = 1``` \
+```typ #f(1)```
---
// Multiline block splits paragraphs.
-First
+Text
+```rust
+fn code() {}
```
-Second
-```
-Third
+Text
---
// Lots of backticks inside.
diff --git a/tests/typ/utility/blind.typ b/tests/typ/utility/blind.typ
index 7d1cb969..17452dec 100644
--- a/tests/typ/utility/blind.typ
+++ b/tests/typ/utility/blind.typ
@@ -2,14 +2,14 @@
---
// Test basic call.
-#lipsum(19)
+#lorem(19)
---
// Test custom paragraphs with user code.
#set text(8pt)
{
- let sentences = lipsum(59)
+ let sentences = lorem(59)
.split(".")
.filter(s => s != "")
.map(s => s + ".")
@@ -28,5 +28,5 @@
}
---
-// Error: 8-10 missing argument: number of words
-#lipsum()
+// Error: 7-9 missing argument: number of words
+#lorem()