summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-11-22 14:30:43 +0100
committerLaurenz <laurmaedje@gmail.com>2021-11-29 16:47:35 +0100
commited50661378f356e02c6ec943bc4840091d33cfbd (patch)
tree7ed51339ea1a4b7ccc4308c902b36e86f9c07e26 /tests
parentcef46e6c40fed0089a20e44ff2f251c06878891c (diff)
Castable optional and smart values
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/elements/fill-stroke.pngbin0 -> 1942 bytes
-rw-r--r--tests/ref/layout/page.pngbin5829 -> 4157 bytes
-rw-r--r--tests/ref/layout/pagebreak.pngbin1254 -> 3145 bytes
-rw-r--r--tests/typ/elements/fill-stroke.typ26
-rw-r--r--tests/typ/layout/page.typ20
-rw-r--r--tests/typ/layout/pagebreak.typ14
-rw-r--r--tests/typ/text/features.typ8
-rw-r--r--tests/typeset.rs4
8 files changed, 54 insertions, 18 deletions
diff --git a/tests/ref/elements/fill-stroke.png b/tests/ref/elements/fill-stroke.png
new file mode 100644
index 00000000..2d04b3dd
--- /dev/null
+++ b/tests/ref/elements/fill-stroke.png
Binary files differ
diff --git a/tests/ref/layout/page.png b/tests/ref/layout/page.png
index dae3d488..57e4b8f1 100644
--- a/tests/ref/layout/page.png
+++ b/tests/ref/layout/page.png
Binary files differ
diff --git a/tests/ref/layout/pagebreak.png b/tests/ref/layout/pagebreak.png
index 043b5086..fbb1d00c 100644
--- a/tests/ref/layout/pagebreak.png
+++ b/tests/ref/layout/pagebreak.png
Binary files differ
diff --git a/tests/typ/elements/fill-stroke.typ b/tests/typ/elements/fill-stroke.typ
new file mode 100644
index 00000000..b8f2b4bc
--- /dev/null
+++ b/tests/typ/elements/fill-stroke.typ
@@ -0,0 +1,26 @@
+// Test shape fill & stroke.
+
+---
+#let rect with (width: 20pt, height: 10pt)
+#let items = for i, rect in (
+ rect(stroke: none),
+ rect(),
+ rect(fill: none),
+ rect(thickness: 2pt),
+ rect(stroke: eastern),
+ rect(stroke: eastern, thickness: 2pt),
+ rect(fill: eastern),
+ rect(fill: eastern, stroke: none),
+ rect(fill: forest, stroke: none, thickness: 2pt),
+ rect(fill: forest, stroke: conifer),
+ rect(fill: forest, thickness: 2pt),
+ rect(fill: forest, stroke: conifer, thickness: 2pt),
+) {
+ (align(vertical: center)[{i + 1}.], rect, [])
+}
+
+#grid(
+ columns: (auto, auto, 1fr, auto, auto, 0fr),
+ gutter: 5pt,
+ ..items,
+)
diff --git a/tests/typ/layout/page.typ b/tests/typ/layout/page.typ
index 9bb3097d..1f707327 100644
--- a/tests/typ/layout/page.typ
+++ b/tests/typ/layout/page.typ
@@ -27,20 +27,8 @@
[#page(paper: "a11", flip: true) Flipped A11]
---
-// Test a combination of pages with bodies and normal content.
-
-#page(width: 80pt, height: 30pt)
-
-[#page() First]
-[#page() Second]
-#pagebreak()
-#pagebreak()
-Fourth
-[#page(height: 25pt)]
-Sixth
-[#page() Seventh]
-
----
#page(width: 80pt, height: 40pt, fill: eastern)
-#font(15pt, "Roboto", fill: white, smallcaps: true)
-Typst
+#font(15pt, "Roboto", fill: white, smallcaps: true)[Typst]
+
+#page(width: 40pt, fill: none, margins: auto, top: 10pt)
+Hi
diff --git a/tests/typ/layout/pagebreak.typ b/tests/typ/layout/pagebreak.typ
index ab591c87..f9a935bc 100644
--- a/tests/typ/layout/pagebreak.typ
+++ b/tests/typ/layout/pagebreak.typ
@@ -18,3 +18,17 @@ C
// No consequences from the page("A4") call here.
#pagebreak()
D
+
+---
+// Test a combination of pages with bodies and normal content.
+
+#page(width: 80pt, height: 30pt)
+
+[#page() First]
+[#page() Second]
+#pagebreak()
+#pagebreak()
+Fourth
+[#page(height: 25pt)]
+Sixth
+[#page() Seventh]
diff --git a/tests/typ/text/features.typ b/tests/typ/text/features.typ
index fc84514b..d60583d8 100644
--- a/tests/typ/text/features.typ
+++ b/tests/typ/text/features.typ
@@ -53,10 +53,18 @@ fi vs. #font(ligatures: false)[No fi] \
fi vs. #font(features: (liga: 0))[No fi]
---
+// Error: 22-27 expected integer or none, found boolean
+#font(stylistic-set: false)
+
+---
// Error: 22-24 must be between 1 and 20
#font(stylistic-set: 25)
---
+// Error: 20-21 expected string or auto, found integer
+#font(number-type: 2)
+
+---
// Error: 20-31 expected "lining" or "old-style"
#font(number-type: "different")
diff --git a/tests/typeset.rs b/tests/typeset.rs
index 723df4a8..6a21cf7b 100644
--- a/tests/typeset.rs
+++ b/tests/typeset.rs
@@ -10,7 +10,7 @@ use ttf_parser::{GlyphId, OutlineBuilder};
use walkdir::WalkDir;
use typst::diag::Error;
-use typst::eval::Value;
+use typst::eval::{Smart, Value};
use typst::font::Face;
use typst::frame::{Element, Frame, Geometry, Shape, Stroke, Text};
use typst::geom::{self, Color, Length, Paint, PathElement, RgbaColor, Sides, Size};
@@ -64,7 +64,7 @@ fn main() {
// large and fit them to match their content.
let mut style = Style::default();
style.page_mut().size = Size::new(Length::pt(120.0), Length::inf());
- style.page_mut().margins = Sides::splat(Some(Length::pt(10.0).into()));
+ style.page_mut().margins = Sides::splat(Smart::Custom(Length::pt(10.0).into()));
style.text_mut().size = Length::pt(10.0);
// Hook up an assert function into the global scope.