diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-06-10 16:46:01 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-06-10 16:46:01 +0200 |
| commit | 5611c26577c4cf6d52b9b66b7b1a32253aa23ec1 (patch) | |
| tree | b06a64845ef691700aed7fd0ed1e22dd064cc742 /tests/typ/insert | |
| parent | bce553a991f19b2b5bb9efef6b74bd12e15a10c6 (diff) | |
Restructure tests
Diffstat (limited to 'tests/typ/insert')
| -rw-r--r-- | tests/typ/insert/circle.typ | 41 | ||||
| -rw-r--r-- | tests/typ/insert/ellipse.typ | 16 | ||||
| -rw-r--r-- | tests/typ/insert/image.typ | 38 | ||||
| -rw-r--r-- | tests/typ/insert/rect.typ | 27 | ||||
| -rw-r--r-- | tests/typ/insert/square.typ | 31 |
5 files changed, 153 insertions, 0 deletions
diff --git a/tests/typ/insert/circle.typ b/tests/typ/insert/circle.typ new file mode 100644 index 00000000..d2fa928e --- /dev/null +++ b/tests/typ/insert/circle.typ @@ -0,0 +1,41 @@ +// 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/insert/ellipse.typ b/tests/typ/insert/ellipse.typ new file mode 100644 index 00000000..9b10eded --- /dev/null +++ b/tests/typ/insert/ellipse.typ @@ -0,0 +1,16 @@ +// 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/insert/image.typ b/tests/typ/insert/image.typ new file mode 100644 index 00000000..35087c2e --- /dev/null +++ b/tests/typ/insert/image.typ @@ -0,0 +1,38 @@ +// 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-21 failed to load image +#image("./image.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/insert/rect.typ b/tests/typ/insert/rect.typ new file mode 100644 index 00000000..f450064a --- /dev/null +++ b/tests/typ/insert/rect.typ @@ -0,0 +1,27 @@ +// 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/insert/square.typ b/tests/typ/insert/square.typ new file mode 100644 index 00000000..649d31c0 --- /dev/null +++ b/tests/typ/insert/square.typ @@ -0,0 +1,31 @@ +// 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? +] |
