summaryrefslogtreecommitdiff
path: root/tests/typ/library
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-06-10 16:46:01 +0200
committerLaurenz <laurmaedje@gmail.com>2021-06-10 16:46:01 +0200
commit5611c26577c4cf6d52b9b66b7b1a32253aa23ec1 (patch)
treeb06a64845ef691700aed7fd0ed1e22dd064cc742 /tests/typ/library
parentbce553a991f19b2b5bb9efef6b74bd12e15a10c6 (diff)
Restructure tests
Diffstat (limited to 'tests/typ/library')
-rw-r--r--tests/typ/library/basic.typ25
-rw-r--r--tests/typ/library/circle.typ41
-rw-r--r--tests/typ/library/ellipse.typ16
-rw-r--r--tests/typ/library/font.typ76
-rw-r--r--tests/typ/library/grid-table.typ29
-rw-r--r--tests/typ/library/grid.typ54
-rw-r--r--tests/typ/library/image.typ38
-rw-r--r--tests/typ/library/lang.typ16
-rw-r--r--tests/typ/library/math.typ15
-rw-r--r--tests/typ/library/pad.typ13
-rw-r--r--tests/typ/library/page.typ50
-rw-r--r--tests/typ/library/pagebreak.typ23
-rw-r--r--tests/typ/library/paragraph.typ14
-rw-r--r--tests/typ/library/rect.typ27
-rw-r--r--tests/typ/library/spacing.typ18
-rw-r--r--tests/typ/library/square.typ31
-rw-r--r--tests/typ/library/stack.typ9
17 files changed, 0 insertions, 495 deletions
diff --git a/tests/typ/library/basic.typ b/tests/typ/library/basic.typ
deleted file mode 100644
index a6aa71af..00000000
--- a/tests/typ/library/basic.typ
+++ /dev/null
@@ -1,25 +0,0 @@
-// Test basic functions.
-// Ref: false
-
----
-#test(type("hi"), "string")
-#test(repr((1, 2, false, )), "(1, 2, false)")
-
----
-// Check the output.
-#test(rgb(0.0, 0.3, 0.7), #004db3)
-
-// Alpha channel.
-#test(rgb(1.0, 0.0, 0.0, 0.5), #ff000080)
-
-// Warning: 2:11-2:14 should be between 0.0 and 1.0
-// Warning: 1:16-1:20 should be between 0.0 and 1.0
-#test(rgb(-30, 15.5, 0.5), #00ff80)
-
-// Error: 11-15 missing argument: blue component
-#test(rgb(0, 1), #00ff00)
-
-// Error: 3:11-3:11 missing argument: red component
-// Error: 2:11-2:11 missing argument: green component
-// Error: 1:11-1:11 missing argument: blue component
-#test(rgb(), black)
diff --git a/tests/typ/library/circle.typ b/tests/typ/library/circle.typ
deleted file mode 100644
index d2fa928e..00000000
--- a/tests/typ/library/circle.typ
+++ /dev/null
@@ -1,41 +0,0 @@
-// Test the `circle` function.
-
----
-// Test auto sizing.
-
-Auto-sized circle. \
-#circle(fill: #eb5278, align(center, center, [But, soft!]))
-
-Center-aligned rect in auto-sized circle.
-#circle(fill: forest)[
- #align(center, center)
- #rect(fill: conifer, pad(5pt)[But, soft!])
-]
-
-100%-width rect in auto-sized circle. \
-#circle(fill: forest, rect(width: 100%, fill: conifer)[
- But, soft! what light through yonder window breaks?
-])
-
-Expanded by height.
-#circle(fill: conifer)[A \ B \ C]
-
----
-// Test relative sizing.
-#rect(width: 100%, height: 50pt, fill: #aaa)[
- #align(center, center)
- #font(color: #fff)
- #circle(radius: 10pt, fill: eastern)[A]
- #circle(height: 60%, fill: eastern)[B]
- #circle(width: 20% + 20pt, fill: eastern)[C]
-]
-
----
-// Radius wins over width and height.
-// Error: 2:23-2:34 unexpected argument
-// Error: 1:36-1:49 unexpected argument
-#circle(radius: 10pt, width: 50pt, height: 100pt, fill: eastern)
-
-// Width wins over height.
-// Error: 22-34 unexpected argument
-#circle(width: 20pt, height: 50pt, fill: eastern)
diff --git a/tests/typ/library/ellipse.typ b/tests/typ/library/ellipse.typ
deleted file mode 100644
index 9b10eded..00000000
--- a/tests/typ/library/ellipse.typ
+++ /dev/null
@@ -1,16 +0,0 @@
-// Test the `ellipse` function.
-
----
-100% rect in 100% ellipse in fixed rect. \
-#rect(width: 3cm, height: 2cm, fill: #2a631a)[
- #ellipse(width: 100%, height: 100%, fill: forest)[
- #rect(width: 100%, height: 100%, fill: conifer)[
- #align(center, center)[Stuff inside an ellipse!]
- ]
- ]
-]
-
-Auto-sized ellipse. \
-#ellipse(fill: conifer)[
- But, soft! what light through yonder window breaks?
-]
diff --git a/tests/typ/library/font.typ b/tests/typ/library/font.typ
deleted file mode 100644
index 34b08f26..00000000
--- a/tests/typ/library/font.typ
+++ /dev/null
@@ -1,76 +0,0 @@
-// Test the `font` function.
-
----
-// Test configuring font properties.
-
-// Set same font size in three different ways.
-#font(22pt)[A]
-#font(200%)[A]
-#font(16.5pt + 50%)[A]
-
-// Do nothing.
-#font[Normal]
-
-// Set style (is available).
-#font(style: italic)[Italic]
-
-// Set weight (is available).
-#font(weight: bold)[Bold]
-
-// Set stretch (not available, matching closest).
-#font(stretch: 50%)[Condensed]
-
-// Set family.
-#font("PT Sans")[Sans serif]
-
-// Emoji.
-Emoji: 🐪, 🌋, 🏞
-
-// Math.
-#font("Latin Modern Math")[
- ∫ 𝛼 + 3𝛽 d𝑡
-]
-
-// Colors.
-#font(color: eastern)[This is #font(color: #FA644B)[way more] colorful.]
-
----
-// Test top and bottom edge.
-
-#page(width: 170pt)
-#let try(top, bottom) = rect(fill: conifer)[
- #font(top-edge: top, bottom-edge: bottom)
- `From `#top` to `#bottom
-]
-
-#try(ascender, descender)
-#try(ascender, baseline)
-#try(cap-height, baseline)
-#try(x-height, baseline)
-
----
-// Test class definitions.
-#font(sans-serif: "PT Sans")
-#font(sans-serif)[Sans-serif.] \
-#font(monospace)[Monospace.] \
-#font(monospace, monospace: ("Nope", "Latin Modern Math"))[Math.]
-
----
-// Ref: false
-
-// Error: 7-12 unexpected argument
-#font(false)
-
-// Error: 3:14-3:18 expected font style, found font weight
-// Error: 2:28-2:34 expected font weight, found string
-// Error: 1:43-1:44 expected string or array of strings, found integer
-#font(style: bold, weight: "thin", serif: 0)
-
-// Warning: 15-19 should be between 100 and 900
-#font(weight: 2700)
-
-// Warning: 16-21 should be between 50% and 200%
-#font(stretch: 1000%)
-
-// Error: 7-27 unexpected argument
-#font(something: "invalid")
diff --git a/tests/typ/library/grid-table.typ b/tests/typ/library/grid-table.typ
deleted file mode 100644
index 277e695c..00000000
--- a/tests/typ/library/grid-table.typ
+++ /dev/null
@@ -1,29 +0,0 @@
-// Test using the `grid` function to create a finance table.
-
----
-#page(width: 12cm, height: 2.5cm)
-#grid(
- columns: 5,
- gutter-columns: (2fr, 1fr, 1fr),
- gutter-rows: 4 * (6pt,),
- [*Quarter*],
- [Expenditure],
- [External Revenue],
- [Financial ROI],
- [_total_],
- [*Q1*],
- [173,472.57 \$],
- [472,860.91 \$],
- [51,286.84 \$],
- [_350,675.18 \$_],
- [*Q2*],
- [93,382.12 \$],
- [439,382.85 \$],
- [-1,134.30 \$],
- [_344,866.43 \$_],
- [*Q3*],
- [96,421.49 \$],
- [238,583.54 \$],
- [3,497.12 \$],
- [_145,659.17 \$_],
-)
diff --git a/tests/typ/library/grid.typ b/tests/typ/library/grid.typ
deleted file mode 100644
index afb43684..00000000
--- a/tests/typ/library/grid.typ
+++ /dev/null
@@ -1,54 +0,0 @@
-// Test the `grid` function.
-
----
-#let rect(width, color) = rect(width: width, height: 2cm, fill: color)
-
-#page(width: 100pt, height: 140pt)
-#grid(
- columns: (auto, 1fr, 3fr, 0.25cm, 3%, 2mm + 10%),
- rect(0.5cm, #2a631a),
- rect(100%, forest),
- rect(100%, conifer),
- rect(100%, #ff0000),
- rect(100%, #00ff00),
- rect(80%, #00faf0),
- rect(1cm, #00ff00),
- rect(0.5cm, #2a631a),
- rect(100%, forest),
- rect(100%, conifer),
- rect(100%, #ff0000),
- rect(100%, #00ff00),
-)
-
-#grid()
-
----
-#grid(
- columns: (auto, auto, 40%),
- gutter: (1fr,),
- rect(fill: eastern)[dddaa aaa aaa],
- rect(fill: conifer)[ccc],
- rect(width: 100%, fill: #dddddd)[aaa],
-)
-
----
-#page(height: 3cm, width: 2cm)
-#grid(
- columns: (1fr, 1cm, 1fr, 1fr),
- column-dir: ttb,
- rows: (auto, 1fr),
- rect(height: 100%, fill: #222222)[foo],
- rect(height: 100%, fill: #547d0a)[bar],
- rect(height: 100%, fill: eastern)[hab],
- rect(height: 100%, fill: conifer)[baz],
- rect(height: 100%, width: 100%, fill: #547d0a)[bar],
-)
-
----
-#page(height: 3cm, margins: 0pt)
-#align(center)
-#grid(
- columns: (1fr,),
- rows: (1fr, auto, 2fr),
- [], rect(width: 100%)[A bit more to the top], [],
-)
diff --git a/tests/typ/library/image.typ b/tests/typ/library/image.typ
deleted file mode 100644
index 1fa128f0..00000000
--- a/tests/typ/library/image.typ
+++ /dev/null
@@ -1,38 +0,0 @@
-// Test the `image` function.
-
----
-// Test loading different image formats.
-
-// Load an RGBA PNG image.
-#image("../../res/rhino.png")
-#pagebreak()
-
-// Load an RGB JPEG image.
-#image("../../res/tiger.jpg")
-
-// Error: 8-29 file not found
-#image("path/does/not/exist")
-
-// Error: 8-20 failed to load image
-#image("./font.typ")
-
----
-// Test configuring the size and fitting behaviour of images.
-
-// Fit to width of page.
-#image("../../res/rhino.png")
-
-// Fit to height of page.
-#page(height: 40pt, image("../../res/rhino.png"))
-
-// Set width explicitly.
-#image("../../res/rhino.png", width: 50pt)
-
-// Set height explicitly.
-#image("../../res/rhino.png", height: 50pt)
-
-// Set width and height explicitly and force stretching.
-#image("../../res/rhino.png", width: 25pt, height: 50pt)
-
-// Make sure the bounding-box of the image is correct.
-#align(bottom, right, image("../../res/tiger.jpg", width: 60pt))
diff --git a/tests/typ/library/lang.typ b/tests/typ/library/lang.typ
deleted file mode 100644
index 87d2c154..00000000
--- a/tests/typ/library/lang.typ
+++ /dev/null
@@ -1,16 +0,0 @@
-// Test the `lang` function.
-
----
-Left to right.
-
-#lang("ar")
-Right to left.
-
-#lang(dir: ltr)
-Back again.
-
----
-// Ref: false
-
-// Error: 12-15 must be horizontal
-#lang(dir: ttb)
diff --git a/tests/typ/library/math.typ b/tests/typ/library/math.typ
deleted file mode 100644
index db234d9c..00000000
--- a/tests/typ/library/math.typ
+++ /dev/null
@@ -1,15 +0,0 @@
-// Test math functions.
-// Ref: false
-
----
-// Test `min` and `max` functions.
-#test(min(2, -4), -4)
-#test(min(3.5, 1e2, -0.1, 3), -0.1)
-#test(max(-3, 11), 11)
-#test(min("hi"), "hi")
-
-// Error: 6 missing argument: value
-#min()
-
-// Error: 11-18 cannot compare integer with string
-#test(min(1, "hi"), error)
diff --git a/tests/typ/library/pad.typ b/tests/typ/library/pad.typ
deleted file mode 100644
index 3726ce53..00000000
--- a/tests/typ/library/pad.typ
+++ /dev/null
@@ -1,13 +0,0 @@
-// Test the `pad` function.
-
----
-// Use for indentation.
-#pad(left: 10pt, [Indented!])
-
-// All sides together.
-#rect(fill: conifer,
- pad(10pt, right: 20pt,
- rect(width: 20pt, height: 20pt, fill: #eb5278)))
-
-// Error: 14-24 missing argument: body
-Hi #rect(pad(left: 10pt)) there
diff --git a/tests/typ/library/page.typ b/tests/typ/library/page.typ
deleted file mode 100644
index 7f9a0d2c..00000000
--- a/tests/typ/library/page.typ
+++ /dev/null
@@ -1,50 +0,0 @@
-// Test the `page` function.
-
----
-// Test configuring page sizes and margins.
-
-// Set width and height.
-#page(width: 120pt, height: 120pt)
-#page(width: 40pt)[High]
-#page(height: 40pt)[Wide]
-
-// Set all margins at once.
-#page(margins: 30pt)[
- #align(top, left)[TL]
- #align(bottom, right)[BR]
-]
-
-// 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])
-
-// Ensure that specific margins override general margins.
-#page(margins: 0pt, left: 20pt)[Overriden]
-
-// Error: 7-18 unknown variable
-#page(nonexistant)
-
-// Flipped predefined paper.
-#page("a11", flip: true)[Flipped A11]
-
-// Flipped custom page size.
-#page(width: 40pt, height: 120pt)
-#page(flip: true)
-Wide
-
----
-// Test a combination of pages with bodies and normal content.
-
-#page(height: 50pt)
-
-#page[First]
-#page[Second]
-#pagebreak()
-#pagebreak()
-Fourth
-#page[]
-Sixth
-#page[Seventh and last]
diff --git a/tests/typ/library/pagebreak.typ b/tests/typ/library/pagebreak.typ
deleted file mode 100644
index 26629f4b..00000000
--- a/tests/typ/library/pagebreak.typ
+++ /dev/null
@@ -1,23 +0,0 @@
-// Test the `pagebreak` function.
-
----
-First of two
-#pagebreak()
-#page(height: 40pt)
-
----
-// Make sure that you can't do page related stuff in a shape.
-A
-#rect[
- B
- // Error: 16 cannot modify page from here
- #pagebreak()
-
- // Error: 11-15 cannot modify page from here
- #page("a4")
-]
-C
-
-// No consequences from the page("A4") call here.
-#pagebreak()
-D
diff --git a/tests/typ/library/paragraph.typ b/tests/typ/library/paragraph.typ
deleted file mode 100644
index a26aed84..00000000
--- a/tests/typ/library/paragraph.typ
+++ /dev/null
@@ -1,14 +0,0 @@
-// Test the `paragraph` function.
-
----
-// Test configuring paragraph properties.
-
-// FIXME: Word spacing doesn't work due to new shaping process.
-#par(spacing: 10pt, leading: 25%, word-spacing: 1pt)
-
-But, soft! what light through yonder window breaks? It is the east, and Juliet
-is the sun.
-
----
-// Test that it finishes an existing paragraph.
-Hello #par(word-spacing: 0pt) t h e r e !
diff --git a/tests/typ/library/rect.typ b/tests/typ/library/rect.typ
deleted file mode 100644
index f450064a..00000000
--- a/tests/typ/library/rect.typ
+++ /dev/null
@@ -1,27 +0,0 @@
-// Test shapes.
-
----
-// Test the `rect` function.
-
-#page(width: 150pt)
-
-// Fit to text.
-#rect(fill: conifer)[Textbox]
-
-// Empty with fixed width and height.
-#rect(width: 3cm, height: 12pt, fill: #CB4CED)
-
-// Fixed width, text height.
-#rect(width: 2cm, fill: #9650D6, pad(5pt)[Fixed and padded])
-
-// Page width, fixed height.
-#rect(height: 1cm, width: 100%, fill: #734CED)[Topleft]
-
-// Not visible, but creates a gap between the boxes above and below
-// due to line spacing.
-#rect(width: 1in, fill: #ff0000)
-
-// These are in a row!
-#rect(width: 0.5in, height: 10pt, fill: #D6CD67)
-#rect(width: 0.5in, height: 10pt, fill: #EDD466)
-#rect(width: 0.5in, height: 10pt, fill: #E3BE62)
diff --git a/tests/typ/library/spacing.typ b/tests/typ/library/spacing.typ
deleted file mode 100644
index bd38631e..00000000
--- a/tests/typ/library/spacing.typ
+++ /dev/null
@@ -1,18 +0,0 @@
-// Test the `h` and `v` functions.
-
----
-// Ends paragraphs.
-Tightly #v(0pt) packed
-
-// Eating up soft spacing.
-Inv #h(0pt) isible
-
-// Multiple spacings in a row.
-Add #h(10pt) #h(10pt) up
-
-// Relative to font size.
-Relative #h(100%) spacing
-
-// Missing spacing.
-// Error: 12 missing argument: spacing
-Totally #h() ignored
diff --git a/tests/typ/library/square.typ b/tests/typ/library/square.typ
deleted file mode 100644
index 649d31c0..00000000
--- a/tests/typ/library/square.typ
+++ /dev/null
@@ -1,31 +0,0 @@
-// Test the `square` function.
-
----
-Auto-sized square. \
-#square(fill: eastern)[
- #align(center)
- #pad(5pt)[
- #font(color: #fff, weight: bold)
- Typst
- ]
-]
-
----
-// Length wins over width and height.
-// Error: 2:9-2:20 unexpected argument
-// Error: 1:22-1:34 unexpected argument
-#square(width: 10cm, height: 20cm, length: 1cm, fill: #eb5278)
-
----
-// Test height overflow.
-#page(width: 75pt, height: 100pt)
-#square(fill: conifer)[
- But, soft! what light through yonder window breaks?
-]
-
----
-// Test width overflow.
-#page(width: 100pt, height: 75pt)
-#square(fill: conifer)[
- But, soft! what light through yonder window breaks?
-]
diff --git a/tests/typ/library/stack.typ b/tests/typ/library/stack.typ
deleted file mode 100644
index d03a95c8..00000000
--- a/tests/typ/library/stack.typ
+++ /dev/null
@@ -1,9 +0,0 @@
-// Test the `stack` function.
-
----
-#let rect(width, color) = rect(width: width, height: 1cm, fill: color)
-#stack(
- rect(2cm, #2a631a),
- rect(3cm, forest),
- rect(1cm, conifer),
-)