summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/layout/containers.pngbin0 -> 6258 bytes
-rw-r--r--tests/ref/layout/fixed.pngbin1389 -> 0 bytes
-rw-r--r--tests/ref/layout/pad.pngbin44396 -> 53197 bytes
-rw-r--r--tests/typ/coma.typ6
-rw-r--r--tests/typ/layout/containers.typ42
-rw-r--r--tests/typ/layout/fixed.typ14
-rw-r--r--tests/typ/layout/pad.typ19
-rw-r--r--tests/typ/layout/pagebreak.typ4
-rw-r--r--tests/typ/markup/emph.typ2
-rw-r--r--tests/typ/markup/heading.typ2
-rw-r--r--tests/typ/markup/strong.typ2
-rw-r--r--tests/typ/text/align.typ4
-rw-r--r--tests/typeset.rs5
13 files changed, 72 insertions, 28 deletions
diff --git a/tests/ref/layout/containers.png b/tests/ref/layout/containers.png
new file mode 100644
index 00000000..4548e2f5
--- /dev/null
+++ b/tests/ref/layout/containers.png
Binary files differ
diff --git a/tests/ref/layout/fixed.png b/tests/ref/layout/fixed.png
deleted file mode 100644
index 5ee9c4ff..00000000
--- a/tests/ref/layout/fixed.png
+++ /dev/null
Binary files differ
diff --git a/tests/ref/layout/pad.png b/tests/ref/layout/pad.png
index 645c8db4..fa877d52 100644
--- a/tests/ref/layout/pad.png
+++ b/tests/ref/layout/pad.png
Binary files differ
diff --git a/tests/typ/coma.typ b/tests/typ/coma.typ
index 810d61b8..b1eefc9f 100644
--- a/tests/typ/coma.typ
+++ b/tests/typ/coma.typ
@@ -10,10 +10,10 @@
#let university = [*Technische Universität {city}*]
#let faculty = [*Fakultät II, Institut for Mathematik*]
-// The `rect` function just places content into a rectangular container. When
+// The `box` function just places content into a rectangular container. When
// the only argument to a function is a template, the parentheses can be omitted
// (i.e. `f[a]` is the same as `f([a])`).
-#rect[
+#box[
// Backslash adds a forced line break.
#university \
#faculty \
@@ -21,7 +21,7 @@
Dr. Max Mustermann \
Ola Nordmann, John Doe
]
-#align(right, rect[*WiSe 2019/2020* \ Woche 3])
+#align(right, box[*WiSe 2019/2020* \ Woche 3])
// Adds vertical spacing.
#v(6mm)
diff --git a/tests/typ/layout/containers.typ b/tests/typ/layout/containers.typ
new file mode 100644
index 00000000..b2835b5e
--- /dev/null
+++ b/tests/typ/layout/containers.typ
@@ -0,0 +1,42 @@
+// Test the `box` and `block` containers.
+
+---
+// Test box in paragraph.
+A #box[B \ C] D.
+
+// Test box with height.
+Spaced \
+#box(height: 0.5cm) \
+Apart
+
+---
+// Test block over multiple pages.
+
+#page(height: 60pt)
+
+First!
+#block[
+ But, soft! what light through yonder window breaks? It is the east, and Juliet
+ is the sun.
+]
+
+---
+// Test shrink-to-fit vs expand.
+
+// Top-level paragraph fills page
+L #align(right)[R]
+
+// Block also fills page.
+#block[
+ L #align(right)[R]
+]
+
+// Boxed paragraph respects width.
+#box(width: 50pt)[
+ L #align(right)[R]
+]
+
+// Boxed paragraph without width doesn't expand.
+#box[
+ L #align(right)[R]
+]
diff --git a/tests/typ/layout/fixed.typ b/tests/typ/layout/fixed.typ
deleted file mode 100644
index 51646eaa..00000000
--- a/tests/typ/layout/fixed.typ
+++ /dev/null
@@ -1,14 +0,0 @@
-// Test shrink-to-fit vs expand.
-
----
-#let right(body) = align(right, body)
-#let pad(body) = pad(left: 10pt, right: 10pt, body)
-
-// Top-level paragraph fills page, boxed paragraph only when the width is set.
-L #right[R] \
-#rect(width: 50pt)[L #right[R]] \
-#rect[L #right[R]]
-
-// Pad inherits expansion behaviour.
-#rect(pad[PL #right[PR]])
-#pad[PL #right[PR]]
diff --git a/tests/typ/layout/pad.typ b/tests/typ/layout/pad.typ
index 8c23549a..142ae4a9 100644
--- a/tests/typ/layout/pad.typ
+++ b/tests/typ/layout/pad.typ
@@ -11,13 +11,26 @@
]
]
-// Error: 14-24 missing argument: body
-Hi #rect(pad(left: 10pt)) there
+// Error: 13-23 missing argument: body
+Hi #box(pad(left: 10pt)) there
+
+---
+#let pad(body) = pad(left: 10pt, right: 10pt, body)
+
+// Pad inherits expansion behaviour from stack ....
+#pad[PL #align(right)[PR]]
+
+// ... block ...
+#block(pad[PL #align(right)[PR]])
+
+// ... and box.
+#box(pad[PL #align(right)[PR]])
---
// Test that the pad node doesn't consume the whole region.
-#page(width: 4cm, height: 5cm)
+#page(height: 6cm)
+
#align(left)[Before]
#pad(10pt, image("../../res/tiger.jpg"))
#align(right)[After]
diff --git a/tests/typ/layout/pagebreak.typ b/tests/typ/layout/pagebreak.typ
index bb7013ab..dedf1ce6 100644
--- a/tests/typ/layout/pagebreak.typ
+++ b/tests/typ/layout/pagebreak.typ
@@ -6,9 +6,9 @@ First of two
#page(height: 40pt)
---
-// Make sure that you can't do page related stuff in a shape.
+// Make sure that you can't do page related stuff in a container.
A
-#rect[
+#box[
B
// Error: 16 cannot modify page from here
#pagebreak()
diff --git a/tests/typ/markup/emph.typ b/tests/typ/markup/emph.typ
index 048097a1..77ac2c72 100644
--- a/tests/typ/markup/emph.typ
+++ b/tests/typ/markup/emph.typ
@@ -8,4 +8,4 @@ _Emphasized!_
Partly em_phas_ized.
// Scoped to body.
-#rect[_Scoped] to body.
+#box[_Scoped] to body.
diff --git a/tests/typ/markup/heading.typ b/tests/typ/markup/heading.typ
index cffa6ed4..8787d959 100644
--- a/tests/typ/markup/heading.typ
+++ b/tests/typ/markup/heading.typ
@@ -18,7 +18,7 @@
// Parsed as headings if at start of the context.
/**/ # Level 1
{[## Level 2]}
-#rect[### Level 3]
+#box[### Level 3]
// Not at the start of the context.
No # heading
diff --git a/tests/typ/markup/strong.typ b/tests/typ/markup/strong.typ
index 36695c48..d396cc2d 100644
--- a/tests/typ/markup/strong.typ
+++ b/tests/typ/markup/strong.typ
@@ -8,4 +8,4 @@
Partly str*ength*ened.
// Scoped to body.
-#rect[*Scoped] to body.
+#box[*Scoped] to body.
diff --git a/tests/typ/text/align.typ b/tests/typ/text/align.typ
index 27c650a4..2ffe1b4c 100644
--- a/tests/typ/text/align.typ
+++ b/tests/typ/text/align.typ
@@ -2,7 +2,7 @@
---
// Test that alignment depends on the paragraph's full width.
-#rect[
+#box[
Hello World \
#align(right)[World]
]
@@ -10,7 +10,7 @@
---
// Test that a line with multiple alignments respects the paragraph's full
// width.
-#rect[
+#box[
Hello #align(center)[World] \
Hello from the World
]
diff --git a/tests/typeset.rs b/tests/typeset.rs
index 8fc7712a..c5f31e61 100644
--- a/tests/typeset.rs
+++ b/tests/typeset.rs
@@ -224,6 +224,9 @@ fn test_part(
state.page.size = Size::new(Length::pt(120.0), Length::inf());
state.page.margins = Sides::splat(Some(Length::pt(10.0).into()));
+ // Clear cache between tests (for now).
+ cache.layout.clear();
+
let mut pass = typst::typeset(loader, cache, Some(src_path), &src, &scope, state);
if !compare_ref {
@@ -315,7 +318,7 @@ fn register_helpers(scope: &mut Scope, panics: Rc<RefCell<Vec<Panic>>>) {
pub fn args(_: &mut EvalContext, args: &mut FuncArgs) -> Value {
let repr = typst::pretty::pretty(args);
args.items.clear();
- Value::template("args", move |ctx| {
+ Value::template(move |ctx| {
let snapshot = ctx.state.clone();
ctx.set_monospace();
ctx.push_text(&repr);