summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-11-17 17:09:19 +0100
committerLaurenz <laurmaedje@gmail.com>2021-11-17 17:09:19 +0100
commit89f2e71852e96062ea9b756bf92fbf4e894871b1 (patch)
tree836099ebd17adf30a24fc62464dfdd3d9c248480 /tests
parent9a800daa82833c57eee04e92c701ca9a05a67d3b (diff)
Align node
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/code/ops.pngbin1211 -> 689 bytes
-rw-r--r--tests/ref/elements/circle.pngbin12498 -> 12818 bytes
-rw-r--r--tests/ref/layout/align.pngbin0 -> 1355 bytes
-rw-r--r--tests/ref/layout/containers.pngbin5804 -> 5201 bytes
-rw-r--r--tests/ref/layout/pad.pngbin52010 -> 52011 bytes
-rw-r--r--tests/ref/text/align.pngbin3021 -> 0 bytes
-rw-r--r--tests/typ/code/ops.typ10
-rw-r--r--tests/typ/coma.typ25
-rw-r--r--tests/typ/elements/circle.typ21
-rw-r--r--tests/typ/elements/ellipse.typ9
-rw-r--r--tests/typ/elements/image.typ3
-rw-r--r--tests/typ/elements/square.typ3
-rw-r--r--tests/typ/layout/align.typ21
-rw-r--r--tests/typ/layout/containers.typ21
-rw-r--r--tests/typ/layout/grid-1.typ3
-rw-r--r--tests/typ/layout/grid-3.typ4
-rw-r--r--tests/typ/layout/grid-5.typ13
-rw-r--r--tests/typ/layout/page.typ8
-rw-r--r--tests/typ/text/align.typ28
19 files changed, 63 insertions, 106 deletions
diff --git a/tests/ref/code/ops.png b/tests/ref/code/ops.png
index a5e06379..b16ed1de 100644
--- a/tests/ref/code/ops.png
+++ b/tests/ref/code/ops.png
Binary files differ
diff --git a/tests/ref/elements/circle.png b/tests/ref/elements/circle.png
index efc0b8ec..f5c0b05a 100644
--- a/tests/ref/elements/circle.png
+++ b/tests/ref/elements/circle.png
Binary files differ
diff --git a/tests/ref/layout/align.png b/tests/ref/layout/align.png
new file mode 100644
index 00000000..57945d5c
--- /dev/null
+++ b/tests/ref/layout/align.png
Binary files differ
diff --git a/tests/ref/layout/containers.png b/tests/ref/layout/containers.png
index 1ade1243..f8977f1d 100644
--- a/tests/ref/layout/containers.png
+++ b/tests/ref/layout/containers.png
Binary files differ
diff --git a/tests/ref/layout/pad.png b/tests/ref/layout/pad.png
index 6ce4016a..4fd2ca47 100644
--- a/tests/ref/layout/pad.png
+++ b/tests/ref/layout/pad.png
Binary files differ
diff --git a/tests/ref/text/align.png b/tests/ref/text/align.png
deleted file mode 100644
index bde57923..00000000
--- a/tests/ref/text/align.png
+++ /dev/null
Binary files differ
diff --git a/tests/typ/code/ops.typ b/tests/typ/code/ops.typ
index 61d1ce38..04a72e72 100644
--- a/tests/typ/code/ops.typ
+++ b/tests/typ/code/ops.typ
@@ -163,7 +163,6 @@
---
// Test with operator.
-// Ref: true
// Apply positional arguments.
#let add(x, y) = x + y
@@ -175,6 +174,9 @@
#test(f(4), 6)
// Make sure that named arguments are overridable.
-#let align with (horizontal: right)
-#align[Right] \
-#align(horizontal: left)[Left]
+#let inc(x, y: 1) = x + y
+#test(inc(1), 2)
+
+#let inc with (y: 2)
+#test(inc(2), 4)
+#test(inc(2, y: 4), 6)
diff --git a/tests/typ/coma.typ b/tests/typ/coma.typ
index 54f80cf6..45d28f9a 100644
--- a/tests/typ/coma.typ
+++ b/tests/typ/coma.typ
@@ -1,35 +1,19 @@
-// Configuration with `page` and `font` functions.
#page(width: 450pt, margins: 1cm)
-// There are variables and they can take normal values like strings, ...
-#let city = "Berlin"
-
-// ... but also "template" values. While these contain markup,
-// they are also values and can be summed, stored in arrays etc.
-// There are also more standard control flow structures, like #if and #for.
-#let university = [*Technische Universität {city}*]
-#let faculty = [*Fakultät II, Institut for Mathematik*]
-
-// Backslashs add forced line breaks.
-#university #align(right)[*WiSe 2019/2020*] \
-#faculty #align(right)[Woche 3] \
+*Technische Universität Berlin* #h(1fr) *WiSe 2019/2020* \
+*Fakultät II, Institut for Mathematik* #h(1fr) Woche 3 \
Sekretariat MA \
Dr. Max Mustermann \
Ola Nordmann, John Doe
-// Adds vertical spacing.
#v(6mm)
-
-// If the last argument to a function is a template, we can also place it behind
-// the parentheses.
#align(center)[
- // Markdown-like syntax for headings.
==== 3. Übungsblatt Computerorientierte Mathematik II #v(4mm)
*Abgabe: 03.05.2019* (bis 10:10 Uhr in MA 001) #v(4mm)
*Alle Antworten sind zu beweisen.*
]
-*1. Aufgabe* #align(right)[(1 + 1 + 2 Punkte)]
+*1. Aufgabe* #h(1fr) (1 + 1 + 2 Punkte)
Ein _Binärbaum_ ist ein Wurzelbaum, in dem jeder Knoten ≤ 2 Kinder hat.
Die Tiefe eines Knotens _v_ ist die Länge des eindeutigen Weges von der Wurzel
@@ -37,7 +21,4 @@ zu _v_, und die Höhe von _v_ ist die Länge eines längsten (absteigenden) Wege
von _v_ zu einem Blatt. Die Höhe des Baumes ist die Höhe der Wurzel.
#v(6mm)
-
-// The `image` function returns a "template" value of the same type as
-// the `[...]` literals.
#align(center, image("../res/graph.png", width: 75%))
diff --git a/tests/typ/elements/circle.typ b/tests/typ/elements/circle.typ
index 4413d0d9..5be9cf56 100644
--- a/tests/typ/elements/circle.typ
+++ b/tests/typ/elements/circle.typ
@@ -9,8 +9,7 @@
Auto-sized circle. \
#circle(fill: rgb("eb5278"))[
- #align(center, center)
- But, soft!
+ #align(center, center)[But, soft!]
]
Center-aligned rect in auto-sized circle.
@@ -31,14 +30,18 @@ Expanded by height.
#circle(fill: conifer)[A \ B \ C]
---
+// Ensure circle directly in rect works.
+#rect(width: 40pt, height: 30pt, circle(fill: forest))
+
+---
// Test relative sizing.
-#rect(width: 100pt, height: 50pt, fill: rgb("aaa"))[
- #align(center, center)
- #font(fill: white)
- #circle(radius: 10pt, fill: eastern)[A] // D=20pt
- #circle(height: 60%, fill: eastern)[B] // D=30pt
- #circle(width: 20% + 20pt, fill: eastern)[C] // D=40pt
-]
+#let centered(body) = align(center, center, body)
+#font(fill: white)
+#rect(width: 100pt, height: 50pt, fill: rgb("aaa"), centered[
+ #circle(radius: 10pt, fill: eastern, centered[A]) // D=20pt
+ #circle(height: 60%, fill: eastern, centered[B]) // D=30pt
+ #circle(width: 20% + 20pt, fill: eastern, centered[C]) // D=40pt
+])
---
// Radius wins over width and height.
diff --git a/tests/typ/elements/ellipse.typ b/tests/typ/elements/ellipse.typ
index 3c8572b1..9c36fb1c 100644
--- a/tests/typ/elements/ellipse.typ
+++ b/tests/typ/elements/ellipse.typ
@@ -8,10 +8,11 @@
Rect in ellipse in fixed rect. \
#rect(width: 3cm, height: 2cm, fill: rgb("2a631a"),
ellipse(fill: forest,
- rect(fill: conifer)[
- #align(center, center)
- Stuff inside an ellipse!
- ]
+ rect(fill: conifer,
+ align(center, center)[
+ Stuff inside an ellipse!
+ ]
+ )
)
)
diff --git a/tests/typ/elements/image.typ b/tests/typ/elements/image.typ
index 43f93baf..84260a28 100644
--- a/tests/typ/elements/image.typ
+++ b/tests/typ/elements/image.typ
@@ -21,8 +21,7 @@
#image("../../res/tiger.jpg", width: 100%, height: 20pt, fit: "stretch")
// Make sure the bounding-box of the image is correct.
-#align(bottom, right)
-#image("../../res/tiger.jpg", width: 40pt)
+#align(bottom, right, image("../../res/tiger.jpg", width: 40pt))
---
// Test all three fit modes.
diff --git a/tests/typ/elements/square.typ b/tests/typ/elements/square.typ
index 3686debb..3163f872 100644
--- a/tests/typ/elements/square.typ
+++ b/tests/typ/elements/square.typ
@@ -9,8 +9,7 @@
// Test auto-sized square.
#square(fill: eastern)[
#font(fill: white, weight: "bold")
- #align(center)
- #pad(5pt)[Typst]
+ #align(center, pad(5pt)[Typst])
]
---
diff --git a/tests/typ/layout/align.typ b/tests/typ/layout/align.typ
new file mode 100644
index 00000000..1454542a
--- /dev/null
+++ b/tests/typ/layout/align.typ
@@ -0,0 +1,21 @@
+// Test alignment.
+
+---
+#page(height: 100pt)
+#stack(dir: ltr,
+ align(left, square(size: 15pt, fill: eastern)),
+ align(center, square(size: 20pt, fill: eastern)),
+ align(right, square(size: 15pt, fill: eastern)),
+)
+#align(center, center, rect(fill: eastern, height: 10pt))
+#align(bottom, stack(
+ align(center, rect(fill: conifer, height: 10pt)),
+ rect(fill: forest, height: 10pt),
+))
+
+---
+#align(center)[
+ Lorem Ipsum
+
+ Dolor
+]
diff --git a/tests/typ/layout/containers.typ b/tests/typ/layout/containers.typ
index b2835b5e..d4556a0f 100644
--- a/tests/typ/layout/containers.typ
+++ b/tests/typ/layout/containers.typ
@@ -19,24 +19,3 @@ First!
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/grid-1.typ b/tests/typ/layout/grid-1.typ
index afd01a5f..2d13452b 100644
--- a/tests/typ/layout/grid-1.typ
+++ b/tests/typ/layout/grid-1.typ
@@ -34,11 +34,10 @@
---
#page(height: 3cm, margins: 0pt)
-#align(center)
#grid(
columns: (1fr,),
rows: (1fr, auto, 2fr),
[],
- [A bit more to the top],
+ align(center)[A bit more to the top],
[],
)
diff --git a/tests/typ/layout/grid-3.typ b/tests/typ/layout/grid-3.typ
index 82472e55..6f7f6977 100644
--- a/tests/typ/layout/grid-3.typ
+++ b/tests/typ/layout/grid-3.typ
@@ -24,7 +24,7 @@
row-gutter: 10pt,
column-gutter: (0pt, 10%),
align(top, image("../../res/rhino.png")),
- align(right, rect(width: 100%, fill: eastern)[LoL]),
+ align(top, rect(fill: eastern, align(right)[LoL])),
[rofl],
[\ A] * 3,
[Ha!\ ] * 3,
@@ -55,7 +55,7 @@
column-gutter: (0pt, 10%),
[A], [B], [C], [D],
grid(columns: 2, [A], [B], [C\ ]*3, [D]),
- align(right, rect(width: 100%, fill: eastern)[LoL]),
+ align(top, rect(fill: eastern, align(right)[LoL])),
[rofl],
[E\ ]*4,
)
diff --git a/tests/typ/layout/grid-5.typ b/tests/typ/layout/grid-5.typ
index 18736b90..585fc6ce 100644
--- a/tests/typ/layout/grid-5.typ
+++ b/tests/typ/layout/grid-5.typ
@@ -16,13 +16,14 @@
#grid(
columns: 2,
gutter: 10pt,
- [#align(bottom) A],
+ align(bottom)[A],
[
Top
- #align(bottom)
- Bottom \
- Bottom \
- Top
+ #align(bottom)[
+ Bottom \
+ Bottom \
+ Top
+ ]
],
- [#align(top) B],
+ align(top)[B],
)
diff --git a/tests/typ/layout/page.typ b/tests/typ/layout/page.typ
index 315680a6..1d2fdb62 100644
--- a/tests/typ/layout/page.typ
+++ b/tests/typ/layout/page.typ
@@ -15,10 +15,10 @@
// 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(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]
diff --git a/tests/typ/text/align.typ b/tests/typ/text/align.typ
deleted file mode 100644
index 9d0c48bf..00000000
--- a/tests/typ/text/align.typ
+++ /dev/null
@@ -1,28 +0,0 @@
-// Test text alignment.
-
----
-// Test that alignment depends on the paragraph's full width.
-#box[
- Hello World \
- #align(right)[World]
-]
-
----
-// Test that a line with multiple alignments respects the paragraph's full
-// width.
-#box[
- Hello #align(center)[World] \
- Hello from the World
-]
-
----
-// Test that `start` alignment after `end` alignment doesn't do anything until
-// the next line break ...
-L #align(right)[R] R
-
-// ... but make sure it resets to left after the line break.
-L #align(right)[R] \ L
-
----
-// FIXME: There should be a line break opportunity on alignment change.
-LLLLLLLLLLLLLLLLL#align(center)[CCCC]