summaryrefslogtreecommitdiff
path: root/tests/typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-12-17 00:20:27 +0100
committerLaurenz <laurmaedje@gmail.com>2020-12-17 00:20:27 +0100
commit81e80ecfba80f5bffab45719c1f2aba4f9b91b4f (patch)
tree03452a7ef0361f24159a60c93fb543263afb91e3 /tests/typ
parent2336aeb4c32864f53a4d4e0f72e54a174df47a60 (diff)
Test [page] function 📕
- Make page break behaviour more consistent - Allow skipping reference image testing for single tests with `// compare-ref: false` (useful for tests which only check error messages)
Diffstat (limited to 'tests/typ')
-rw-r--r--tests/typ/example-coma.typ2
-rw-r--r--tests/typ/image-error.typ5
-rw-r--r--tests/typ/image-fit.typ2
-rw-r--r--tests/typ/image-formats.typ8
-rw-r--r--tests/typ/image-jpeg.typ2
-rw-r--r--tests/typ/image-png.typ2
-rw-r--r--tests/typ/page-body.typ11
-rw-r--r--tests/typ/page-dirs.typ5
-rw-r--r--tests/typ/page-error.typ11
-rw-r--r--tests/typ/page-metrics.typ25
10 files changed, 67 insertions, 6 deletions
diff --git a/tests/typ/example-coma.typ b/tests/typ/example-coma.typ
index f841a122..d41032c1 100644
--- a/tests/typ/example-coma.typ
+++ b/tests/typ/example-coma.typ
@@ -1,4 +1,4 @@
-// Small integration test of syntax, page setup, box layout and alignment.
+// Test integration of syntax, page setup, box layout and alignment.
[page: width=450pt, height=300pt, margins=1cm]
diff --git a/tests/typ/image-error.typ b/tests/typ/image-error.typ
index 4fde4ab2..9a7f2c40 100644
--- a/tests/typ/image-error.typ
+++ b/tests/typ/image-error.typ
@@ -1,5 +1,8 @@
-// error: 5:9-5:30 failed to load image
+// Test error cases of the `image` function.
+
+// compare-ref: false
// error: 8:9-8:30 failed to load image
+// error: 11:9-11:30 failed to load image
// File does not exist.
[image: "path/does/not/exist"]
diff --git a/tests/typ/image-fit.typ b/tests/typ/image-fit.typ
index b735f058..eca7c1e4 100644
--- a/tests/typ/image-fit.typ
+++ b/tests/typ/image-fit.typ
@@ -1,3 +1,5 @@
+// Test configuring the size and fitting behaviour of images.
+
// Fit to width of page.
[image: "res/rhino.png"]
diff --git a/tests/typ/image-formats.typ b/tests/typ/image-formats.typ
new file mode 100644
index 00000000..36b991d0
--- /dev/null
+++ b/tests/typ/image-formats.typ
@@ -0,0 +1,8 @@
+// Test loading different image formats.
+
+// Load an RGBA PNG image.
+[image: "res/rhino.png"]
+[pagebreak]
+
+// Load an RGB JPEG image.
+[image: "res/tiger.jpg"]
diff --git a/tests/typ/image-jpeg.typ b/tests/typ/image-jpeg.typ
deleted file mode 100644
index 48cf1a0d..00000000
--- a/tests/typ/image-jpeg.typ
+++ /dev/null
@@ -1,2 +0,0 @@
-// Load an RGB JPEG image.
-[image: "res/tiger.jpg"]
diff --git a/tests/typ/image-png.typ b/tests/typ/image-png.typ
deleted file mode 100644
index 482591e9..00000000
--- a/tests/typ/image-png.typ
+++ /dev/null
@@ -1,2 +0,0 @@
-// Load an RGBA PNG image.
-[image: "res/rhino.png"]
diff --git a/tests/typ/page-body.typ b/tests/typ/page-body.typ
new file mode 100644
index 00000000..6067dcfe
--- /dev/null
+++ b/tests/typ/page-body.typ
@@ -0,0 +1,11 @@
+// Test a combination of pages with bodies and normal content.
+
+[page: height=50pt]
+
+[page][First]
+[page][Second]
+[pagebreak]
+Fourth
+[page][Fifth]
+Sixth
+[page][Seventh and last]
diff --git a/tests/typ/page-dirs.typ b/tests/typ/page-dirs.typ
new file mode 100644
index 00000000..09ba4e9e
--- /dev/null
+++ b/tests/typ/page-dirs.typ
@@ -0,0 +1,5 @@
+// Test changing the layouting directions of pages.
+
+[page: main-dir=btt, cross-dir=rtl]
+
+Right to left!
diff --git a/tests/typ/page-error.typ b/tests/typ/page-error.typ
new file mode 100644
index 00000000..dee5c449
--- /dev/null
+++ b/tests/typ/page-error.typ
@@ -0,0 +1,11 @@
+// Test error cases of the `page` function.
+
+// compare-ref: false
+// error: 8:8-8:19 invalid paper
+// error: 11:17-11:20 aligned axis
+
+// Invalid paper.
+[page: nonexistant]
+
+// Aligned axes.
+[page: main-dir=ltr]
diff --git a/tests/typ/page-metrics.typ b/tests/typ/page-metrics.typ
new file mode 100644
index 00000000..6c7bd461
--- /dev/null
+++ b/tests/typ/page-metrics.typ
@@ -0,0 +1,25 @@
+// Test configuring page sizes and margins.
+
+// Set width.
+[page: width=50pt][High]
+
+// Set height.
+[page: height=50pt][Wide]
+
+// Set all margins at once.
+[page: margins=40pt][
+ [align: top, left][TL]
+ [align: bottom, right][BR]
+]
+
+// Set individual margins.
+[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=40pt][Overriden]
+
+// Flip the page.
+[page: a10, flip=true][Flipped]