summaryrefslogtreecommitdiff
path: root/tests/typ
diff options
context:
space:
mode:
Diffstat (limited to 'tests/typ')
-rw-r--r--tests/typ/code/ops.typ4
-rw-r--r--tests/typ/layout/page-marginals.typ2
-rw-r--r--tests/typ/style/construct.typ4
-rw-r--r--tests/typ/style/show.typ6
-rw-r--r--tests/typ/style/wrap.typ6
-rw-r--r--tests/typ/text/baseline.typ2
-rw-r--r--tests/typ/text/deco.typ4
-rw-r--r--tests/typ/text/edge.typ25
-rw-r--r--tests/typ/text/em.typ23
-rw-r--r--tests/typ/text/font.typ29
-rw-r--r--tests/typ/text/par.typ2
-rw-r--r--tests/typ/text/tracking-spacing.typ30
-rw-r--r--tests/typ/text/tracking.typ12
-rw-r--r--tests/typ/utility/math.typ22
14 files changed, 105 insertions, 66 deletions
diff --git a/tests/typ/code/ops.typ b/tests/typ/code/ops.typ
index b5a4d8d4..53cf488e 100644
--- a/tests/typ/code/ops.typ
+++ b/tests/typ/code/ops.typ
@@ -63,8 +63,8 @@
test(v + v, 2.0 * v)
}
- // Relative lengths cannot be divided by themselves.
- if type(v) != "relative length" {
+ // Lengths cannot be divided by themselves.
+ if "length" not in type(v) {
test(v / v, 1.0)
test(v / v == 1, true)
}
diff --git a/tests/typ/layout/page-marginals.typ b/tests/typ/layout/page-marginals.typ
index 2d969647..9fd193c6 100644
--- a/tests/typ/layout/page-marginals.typ
+++ b/tests/typ/layout/page-marginals.typ
@@ -5,7 +5,7 @@
header: align(horizon, {
text(eastern)[*Typst*]
h(1fr)
- text(80%)[_Chapter 1_]
+ text(0.8em)[_Chapter 1_]
}),
footer: page => v(5pt) + align(center)[\~ #page \~],
)
diff --git a/tests/typ/style/construct.typ b/tests/typ/style/construct.typ
index 8bc348a9..f01b534b 100644
--- a/tests/typ/style/construct.typ
+++ b/tests/typ/style/construct.typ
@@ -22,7 +22,7 @@
---
// The inner rectangle should also be yellow here.
// (and therefore invisible)
-[#set rect(fill: yellow);#text(100%, rect(padding: 5pt, rect()))]
+[#set rect(fill: yellow);#text(1em, rect(padding: 5pt, rect()))]
---
// The inner rectangle should not be yellow here.
@@ -30,4 +30,4 @@ A #rect(fill: yellow, padding: 5pt, rect()) B
---
// The inner list should not be indented extra.
-[#set text(100%);#list(indent: 20pt, list[A])]
+[#set text(1em);#list(indent: 20pt, list[A])]
diff --git a/tests/typ/style/show.typ b/tests/typ/style/show.typ
index 2e003b0a..7a5aba8f 100644
--- a/tests/typ/style/show.typ
+++ b/tests/typ/style/show.typ
@@ -3,11 +3,11 @@
#set page("a8", footer: p => v(-5pt) + align(right, [#p]))
#let i = 1
-#set heading(size: 100%)
+#set heading(size: 1em)
#show heading(level, body) as {
if level == 1 {
v(10pt)
- underline(text(150%, blue)[{i}. #body])
+ underline(text(1.5em, blue)[{i}. #body])
i += 1
} else {
text(red, body)
@@ -29,7 +29,7 @@ Some more text.
Another text.
---
-#set heading(size: 100%, strong: false, block: false)
+#set heading(size: 1em, strong: false, block: false)
#show heading(a, b) as [B]
A [= Heading] C
diff --git a/tests/typ/style/wrap.typ b/tests/typ/style/wrap.typ
index b549f7d0..2a9074cb 100644
--- a/tests/typ/style/wrap.typ
+++ b/tests/typ/style/wrap.typ
@@ -2,10 +2,10 @@
---
#set page(height: 130pt)
-#set text(70%)
+#set text(0.7em)
#align(center)[
- #text(130%)[*Essay on typography*] \
+ #text(1.3em)[*Essay on typography*] \
T. Ypst
]
@@ -20,7 +20,7 @@ A [_B #wrap c in [*#c*]; C_] D
---
// Test wrap style precedence.
-#set text(fill: eastern, size: 150%)
+#set text(fill: eastern, size: 1.5em)
#wrap body in text(fill: forest, body)
Forest
diff --git a/tests/typ/text/baseline.typ b/tests/typ/text/baseline.typ
index 7100ab52..5f451563 100644
--- a/tests/typ/text/baseline.typ
+++ b/tests/typ/text/baseline.typ
@@ -1,4 +1,4 @@
// Test text baseline.
---
-Hi #text(150%)[You], #text(75%)[how are you?]
+Hi #text(1.5em)[You], #text(0.75em)[how are you?]
diff --git a/tests/typ/text/deco.typ b/tests/typ/text/deco.typ
index a9f380b9..071208ac 100644
--- a/tests/typ/text/deco.typ
+++ b/tests/typ/text/deco.typ
@@ -19,11 +19,11 @@
#overline(underline[Running amongst the wolves.])
---
-#let redact = strike.with(10pt, extent: 5%)
+#let redact = strike.with(10pt, extent: 0.05em)
#let highlight = strike.with(
stroke: rgb("abcdef88"),
thickness: 10pt,
- extent: 5%,
+ extent: 0.05em,
)
// Abuse thickness and transparency for redacting and highlighting stuff.
diff --git a/tests/typ/text/edge.typ b/tests/typ/text/edge.typ
new file mode 100644
index 00000000..c3c60b28
--- /dev/null
+++ b/tests/typ/text/edge.typ
@@ -0,0 +1,25 @@
+// Test top and bottom text edge.
+
+---
+#set page(width: 160pt)
+#set text(size: 8pt)
+
+#let try(top, bottom) = rect(fill: conifer)[
+ #set text("IBM Plex Mono", top-edge: top, bottom-edge: bottom)
+ From #top to #bottom
+]
+
+#try("ascender", "descender")
+#try("ascender", "baseline")
+#try("cap-height", "baseline")
+#try("x-height", "baseline")
+#try(4pt, -2pt)
+#try(1pt + 0.3em, -0.15em)
+
+---
+// Error: 21-23 expected string or length, found array
+#set text(top-edge: ())
+
+---
+// Error: 24-26 unknown font metric
+#set text(bottom-edge: "")
diff --git a/tests/typ/text/em.typ b/tests/typ/text/em.typ
index d9b00f06..dd0a436e 100644
--- a/tests/typ/text/em.typ
+++ b/tests/typ/text/em.typ
@@ -4,14 +4,31 @@
#set text(size: 5pt)
A // 5pt
[
- #set text(size: 200%)
+ #set text(size: 2em)
B // 10pt
[
- #set text(size: 150% + 1pt)
+ #set text(size: 1.5em + 1pt)
C // 16pt
- #text(size: 200%)[D] // 32pt
+ #text(size: 2em)[D] // 32pt
E // 16pt
]
F // 10pt
]
G // 5pt
+
+---
+// Test using ems in arbitrary places.
+#set text(size: 5pt)
+#set text(size: 2em)
+#set square(fill: red)
+
+#let size = {
+ let size = 0.25em + 1pt
+ for _ in range(3) {
+ size *= 2
+ }
+ size - 3pt
+}
+
+#square(size: size)
+#square(size: 25pt)
diff --git a/tests/typ/text/font.typ b/tests/typ/text/font.typ
index 4b7d7534..b2909182 100644
--- a/tests/typ/text/font.typ
+++ b/tests/typ/text/font.typ
@@ -3,8 +3,8 @@
---
// Set same font size in three different ways.
#text(20pt)[A]
-#text(200%)[A]
-#text(size: 15pt + 50%)[A]
+#text(2em)[A]
+#text(size: 15pt + 0.5em)[A]
// Do nothing.
#text()[Normal]
@@ -39,23 +39,6 @@ Emoji: 🐪, 🌋, 🏞
2π = 𝛼 + 𝛽. ✅
---
-// Test top and bottom edge.
-#set page(width: 150pt)
-#set text(size: 8pt)
-
-#let try(top, bottom) = rect(fill: conifer)[
- #set text("IBM Plex Mono", top-edge: top, bottom-edge: bottom)
- From #top to #bottom
-]
-
-#try("ascender", "descender")
-#try("ascender", "baseline")
-#try("cap-height", "baseline")
-#try("x-height", "baseline")
-#try(4pt, -2pt)
-#try(1pt + 27%, -18%)
-
----
// Error: 11-16 unexpected argument
#set text(false)
@@ -64,14 +47,6 @@ Emoji: 🐪, 🌋, 🏞
#set text(style: "bold", weight: "thin")
---
-// Error: 21-23 expected string or relative length, found array
-#set text(top-edge: ())
-
----
-// Error: 21-23 unknown font metric
-#set text(top-edge: "")
-
----
// Error: 23-27 unexpected argument
#set text(size: 10pt, 12pt)
diff --git a/tests/typ/text/par.typ b/tests/typ/text/par.typ
index 2bff4a47..6b7c0f59 100644
--- a/tests/typ/text/par.typ
+++ b/tests/typ/text/par.typ
@@ -31,7 +31,7 @@ A #set par(spacing: 0pt, leading: 0pt); B #parbreak() C
---
// Test weird metrics.
-#set par(spacing: 100%, leading: 0pt)
+#set par(spacing: 1em, leading: 0pt)
But, soft! what light through yonder window breaks?
It is the east, and Juliet is the sun.
diff --git a/tests/typ/text/tracking-spacing.typ b/tests/typ/text/tracking-spacing.typ
new file mode 100644
index 00000000..b938af36
--- /dev/null
+++ b/tests/typ/text/tracking-spacing.typ
@@ -0,0 +1,30 @@
+// Test tracking characters apart or together.
+
+---
+// Test tracking.
+#set text(tracking: -0.01em)
+I saw Zoe yӛsterday, on the tram.
+
+---
+// Test tracking for only part of paragraph.
+I'm in#text(tracking: 0.15em + 1.5pt)[ spaace]!
+
+---
+// Test that tracking doesn't disrupt mark placement.
+#set text(tracking: 0.3em)
+טֶקסט
+
+---
+// Test tracking in arabic text (makes no sense whatsoever)
+#set text(tracking: 0.3em)
+النص
+
+---
+// Test word spacing.
+#set text(spacing: 1em)
+My text has spaces.
+
+---
+// Test word spacing relative to the font's space width.
+#set text(spacing: 50% + 1pt)
+This is tight.
diff --git a/tests/typ/text/tracking.typ b/tests/typ/text/tracking.typ
deleted file mode 100644
index e3ff70ff..00000000
--- a/tests/typ/text/tracking.typ
+++ /dev/null
@@ -1,12 +0,0 @@
-// Test tracking characters apart or together.
-
----
-#set text(tracking: -0.01)
-I saw Zoe yӛsterday, on the tram.
-
----
-I'm in#text(tracking: 0.3)[ spaace]!
-
----
-#set text("Noto Serif Hebrew", tracking: 0.3)
-טֶקסט
diff --git a/tests/typ/utility/math.typ b/tests/typ/utility/math.typ
index bb729890..4ccefa22 100644
--- a/tests/typ/utility/math.typ
+++ b/tests/typ/utility/math.typ
@@ -35,8 +35,20 @@
#test(abs(-0.0), 0.0)
#test(abs(0.0), -0.0)
#test(abs(-3.14), 3.14)
-#test(abs(-12pt), 12pt)
#test(abs(50%), 50%)
+#test(abs(-25%), 25%)
+
+---
+// Error: 6-17 expected numeric value, found string
+#abs("no number")
+
+---
+// Error: 6-11 cannot take absolute value of a length
+#abs(-12pt)
+
+---
+// Error: 6-16 cannot take absolute value of a length
+#abs(50% - 12pt)
---
// Test the `even` and `odd` functions.
@@ -62,14 +74,6 @@
#mod(3.0, 0.0)
---
-// Error: 6-16 cannot take absolute value of a relative length
-#abs(10pt + 50%)
-
----
-// Error: 6-17 expected numeric value, found string
-#abs("no number")
-
----
// Test the `min` and `max` functions.
#test(min(2, -4), -4)
#test(min(3.5, 1e2, -0.1, 3), -0.1)