From cc5f14193c25200e254e64cc594b15e84da280f9 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 16 Jan 2021 15:28:03 +0100 Subject: =?UTF-8?q?Flip=20test=20directory=20structure=20=F0=9F=94=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move full/lang/library to the top-level as that's more ergonomic to use. --- tests/README.md | 18 +++---- tests/full/ref/coma.png | Bin 0 -> 27418 bytes tests/full/typ/coma.typ | 25 ++++++++++ tests/lang/ref/arrays.png | Bin 0 -> 3479 bytes tests/lang/ref/basics.png | Bin 0 -> 5051 bytes tests/lang/ref/blocks.png | Bin 0 -> 1363 bytes tests/lang/ref/bracket-call.png | Bin 0 -> 22257 bytes tests/lang/ref/comments.png | Bin 0 -> 1148 bytes tests/lang/ref/dictionaries.png | Bin 0 -> 1769 bytes tests/lang/ref/empty.png | Bin 0 -> 94 bytes tests/lang/ref/escaping.png | Bin 0 -> 4148 bytes tests/lang/ref/expressions.png | Bin 0 -> 2351 bytes tests/lang/ref/headings.png | Bin 0 -> 7850 bytes tests/lang/ref/let.png | Bin 0 -> 1493 bytes tests/lang/ref/raw.png | Bin 0 -> 4212 bytes tests/lang/ref/values.png | Bin 0 -> 8531 bytes tests/lang/typ/arrays.typ | 33 +++++++++++++ tests/lang/typ/basics.typ | 14 ++++++ tests/lang/typ/blocks.typ | 21 +++++++++ tests/lang/typ/bracket-call.typ | 101 ++++++++++++++++++++++++++++++++++++++++ tests/lang/typ/comments.typ | 18 +++++++ tests/lang/typ/dictionaries.typ | 14 ++++++ tests/lang/typ/empty.typ | 0 tests/lang/typ/escaping.typ | 25 ++++++++++ tests/lang/typ/expressions.typ | 37 +++++++++++++++ tests/lang/typ/headings.typ | 38 +++++++++++++++ tests/lang/typ/let.typ | 20 ++++++++ tests/lang/typ/raw.typ | 23 +++++++++ tests/lang/typ/values.typ | 33 +++++++++++++ tests/library/ref/font.png | Bin 0 -> 5386 bytes tests/library/ref/hv.png | Bin 0 -> 3961 bytes tests/library/ref/image.png | Bin 0 -> 220343 bytes tests/library/ref/page.png | Bin 0 -> 8097 bytes tests/library/ref/pagebreak.png | Bin 0 -> 821 bytes tests/library/ref/rgb.png | Bin 0 -> 2688 bytes tests/library/typ/font.typ | 56 ++++++++++++++++++++++ tests/library/typ/hv.typ | 22 +++++++++ tests/library/typ/image.typ | 39 ++++++++++++++++ tests/library/typ/page.typ | 54 +++++++++++++++++++++ tests/library/typ/pagebreak.typ | 3 ++ tests/library/typ/rgb.typ | 17 +++++++ tests/ref/full/coma.png | Bin 27418 -> 0 bytes tests/ref/lang/arrays.png | Bin 3479 -> 0 bytes tests/ref/lang/basics.png | Bin 5051 -> 0 bytes tests/ref/lang/blocks.png | Bin 1363 -> 0 bytes tests/ref/lang/bracket-call.png | Bin 22257 -> 0 bytes tests/ref/lang/comments.png | Bin 1148 -> 0 bytes tests/ref/lang/dictionaries.png | Bin 1769 -> 0 bytes tests/ref/lang/empty.png | Bin 94 -> 0 bytes tests/ref/lang/escaping.png | Bin 4148 -> 0 bytes tests/ref/lang/expressions.png | Bin 2351 -> 0 bytes tests/ref/lang/headings.png | Bin 7850 -> 0 bytes tests/ref/lang/let.png | Bin 1493 -> 0 bytes tests/ref/lang/raw.png | Bin 4212 -> 0 bytes tests/ref/lang/values.png | Bin 8531 -> 0 bytes tests/ref/library/font.png | Bin 5386 -> 0 bytes tests/ref/library/hv.png | Bin 3961 -> 0 bytes tests/ref/library/image.png | Bin 220343 -> 0 bytes tests/ref/library/page.png | Bin 8097 -> 0 bytes tests/ref/library/pagebreak.png | Bin 821 -> 0 bytes tests/ref/library/rgb.png | Bin 2688 -> 0 bytes tests/typ/full/coma.typ | 25 ---------- tests/typ/lang/arrays.typ | 33 ------------- tests/typ/lang/basics.typ | 14 ------ tests/typ/lang/blocks.typ | 21 --------- tests/typ/lang/bracket-call.typ | 101 ---------------------------------------- tests/typ/lang/comments.typ | 18 ------- tests/typ/lang/dictionaries.typ | 14 ------ tests/typ/lang/empty.typ | 0 tests/typ/lang/escaping.typ | 25 ---------- tests/typ/lang/expressions.typ | 37 --------------- tests/typ/lang/headings.typ | 38 --------------- tests/typ/lang/let.typ | 20 -------- tests/typ/lang/raw.typ | 23 --------- tests/typ/lang/values.typ | 33 ------------- tests/typ/library/font.typ | 56 ---------------------- tests/typ/library/hv.typ | 22 --------- tests/typ/library/image.typ | 39 ---------------- tests/typ/library/page.typ | 54 --------------------- tests/typ/library/pagebreak.typ | 3 -- tests/typ/library/rgb.typ | 17 ------- tests/typeset.rs | 17 ++++--- 82 files changed, 613 insertions(+), 608 deletions(-) create mode 100644 tests/full/ref/coma.png create mode 100644 tests/full/typ/coma.typ create mode 100644 tests/lang/ref/arrays.png create mode 100644 tests/lang/ref/basics.png create mode 100644 tests/lang/ref/blocks.png create mode 100644 tests/lang/ref/bracket-call.png create mode 100644 tests/lang/ref/comments.png create mode 100644 tests/lang/ref/dictionaries.png create mode 100644 tests/lang/ref/empty.png create mode 100644 tests/lang/ref/escaping.png create mode 100644 tests/lang/ref/expressions.png create mode 100644 tests/lang/ref/headings.png create mode 100644 tests/lang/ref/let.png create mode 100644 tests/lang/ref/raw.png create mode 100644 tests/lang/ref/values.png create mode 100644 tests/lang/typ/arrays.typ create mode 100644 tests/lang/typ/basics.typ create mode 100644 tests/lang/typ/blocks.typ create mode 100644 tests/lang/typ/bracket-call.typ create mode 100644 tests/lang/typ/comments.typ create mode 100644 tests/lang/typ/dictionaries.typ create mode 100644 tests/lang/typ/empty.typ create mode 100644 tests/lang/typ/escaping.typ create mode 100644 tests/lang/typ/expressions.typ create mode 100644 tests/lang/typ/headings.typ create mode 100644 tests/lang/typ/let.typ create mode 100644 tests/lang/typ/raw.typ create mode 100644 tests/lang/typ/values.typ create mode 100644 tests/library/ref/font.png create mode 100644 tests/library/ref/hv.png create mode 100644 tests/library/ref/image.png create mode 100644 tests/library/ref/page.png create mode 100644 tests/library/ref/pagebreak.png create mode 100644 tests/library/ref/rgb.png create mode 100644 tests/library/typ/font.typ create mode 100644 tests/library/typ/hv.typ create mode 100644 tests/library/typ/image.typ create mode 100644 tests/library/typ/page.typ create mode 100644 tests/library/typ/pagebreak.typ create mode 100644 tests/library/typ/rgb.typ delete mode 100644 tests/ref/full/coma.png delete mode 100644 tests/ref/lang/arrays.png delete mode 100644 tests/ref/lang/basics.png delete mode 100644 tests/ref/lang/blocks.png delete mode 100644 tests/ref/lang/bracket-call.png delete mode 100644 tests/ref/lang/comments.png delete mode 100644 tests/ref/lang/dictionaries.png delete mode 100644 tests/ref/lang/empty.png delete mode 100644 tests/ref/lang/escaping.png delete mode 100644 tests/ref/lang/expressions.png delete mode 100644 tests/ref/lang/headings.png delete mode 100644 tests/ref/lang/let.png delete mode 100644 tests/ref/lang/raw.png delete mode 100644 tests/ref/lang/values.png delete mode 100644 tests/ref/library/font.png delete mode 100644 tests/ref/library/hv.png delete mode 100644 tests/ref/library/image.png delete mode 100644 tests/ref/library/page.png delete mode 100644 tests/ref/library/pagebreak.png delete mode 100644 tests/ref/library/rgb.png delete mode 100644 tests/typ/full/coma.typ delete mode 100644 tests/typ/lang/arrays.typ delete mode 100644 tests/typ/lang/basics.typ delete mode 100644 tests/typ/lang/blocks.typ delete mode 100644 tests/typ/lang/bracket-call.typ delete mode 100644 tests/typ/lang/comments.typ delete mode 100644 tests/typ/lang/dictionaries.typ delete mode 100644 tests/typ/lang/empty.typ delete mode 100644 tests/typ/lang/escaping.typ delete mode 100644 tests/typ/lang/expressions.typ delete mode 100644 tests/typ/lang/headings.typ delete mode 100644 tests/typ/lang/let.typ delete mode 100644 tests/typ/lang/raw.typ delete mode 100644 tests/typ/lang/values.typ delete mode 100644 tests/typ/library/font.typ delete mode 100644 tests/typ/library/hv.typ delete mode 100644 tests/typ/library/image.typ delete mode 100644 tests/typ/library/page.typ delete mode 100644 tests/typ/library/pagebreak.typ delete mode 100644 tests/typ/library/rgb.typ (limited to 'tests') diff --git a/tests/README.md b/tests/README.md index 91bf8f49..efca6dd6 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,23 +1,23 @@ # Tests -Directory structure: +Top level directory structure: +- `full`: Tests of full documents. +- `lang`: Tests for specific language features. +- `library`: Tests for specific library functions. +- `res`: Resource files used by tests. + +Directory structure for each category: - `typ`: Input files. - `ref`: Reference images which the output is compared with to determine whether a test passed or failed. -- `res`: Resource files used by tests. - `png`: PNG files produced by tests. - `pdf`: PDF files produced by tests. -The test files are split into three categories: -- `full`: Tests of full documents. -- `lang`: Tests for specific language features. -- `library`: Tests for specific library functions. - To keep things small, please optimize the reference images: ```bash # One image -oxipng -o max tests/ref/image.png +oxipng -o max path/to/image.png # All images -oxipng -r -o max tests/ref/* +oxipng -r -o max tests/*/ref ``` diff --git a/tests/full/ref/coma.png b/tests/full/ref/coma.png new file mode 100644 index 00000000..0c18b810 Binary files /dev/null and b/tests/full/ref/coma.png differ diff --git a/tests/full/typ/coma.typ b/tests/full/typ/coma.typ new file mode 100644 index 00000000..b7863fce --- /dev/null +++ b/tests/full/typ/coma.typ @@ -0,0 +1,25 @@ +[page width: 450pt, height: 300pt, margins: 1cm] + +[box][ + *Technische Universität Berlin* \ + *Fakultät II, Institut for Mathematik* \ + Sekretariat MA \ + Dr. Max Mustermann \ + Ola Nordmann, John Doe +] +[align right | box][*WiSe 2019/2020* \ Woche 3] + +[v 6mm] + +[align center][ + #### 3. Übungsblatt Computerorientierte Mathematik II [v 2mm] + *Abgabe: 03.05.2019* (bis 10:10 Uhr in MA 001) [v 2mm] + *Alle Antworten sind zu beweisen.* +] + +*1. Aufgabe* [align right][(1 + 1 + 2 Punkte)] + +Ein _Binärbaum_ ist ein Wurzelbaum, in dem jeder Knoten ≤ 2 Kinder hat. +Die Tiefe eines Knotens _v_ ist die Länge des eindeutigen Weges von der Wurzel +zu _v_, und die Höhe von _v_ ist die Länge eines längsten (absteigenden) Weges +von _v_ zu einem Blatt. Die Höhe des Baumes ist die Höhe der Wurzel. diff --git a/tests/lang/ref/arrays.png b/tests/lang/ref/arrays.png new file mode 100644 index 00000000..2d70a3f6 Binary files /dev/null and b/tests/lang/ref/arrays.png differ diff --git a/tests/lang/ref/basics.png b/tests/lang/ref/basics.png new file mode 100644 index 00000000..3c3dd7a0 Binary files /dev/null and b/tests/lang/ref/basics.png differ diff --git a/tests/lang/ref/blocks.png b/tests/lang/ref/blocks.png new file mode 100644 index 00000000..ca826c1b Binary files /dev/null and b/tests/lang/ref/blocks.png differ diff --git a/tests/lang/ref/bracket-call.png b/tests/lang/ref/bracket-call.png new file mode 100644 index 00000000..16afb187 Binary files /dev/null and b/tests/lang/ref/bracket-call.png differ diff --git a/tests/lang/ref/comments.png b/tests/lang/ref/comments.png new file mode 100644 index 00000000..df5e5b9c Binary files /dev/null and b/tests/lang/ref/comments.png differ diff --git a/tests/lang/ref/dictionaries.png b/tests/lang/ref/dictionaries.png new file mode 100644 index 00000000..aa40549e Binary files /dev/null and b/tests/lang/ref/dictionaries.png differ diff --git a/tests/lang/ref/empty.png b/tests/lang/ref/empty.png new file mode 100644 index 00000000..87c06b0a Binary files /dev/null and b/tests/lang/ref/empty.png differ diff --git a/tests/lang/ref/escaping.png b/tests/lang/ref/escaping.png new file mode 100644 index 00000000..575a4b2f Binary files /dev/null and b/tests/lang/ref/escaping.png differ diff --git a/tests/lang/ref/expressions.png b/tests/lang/ref/expressions.png new file mode 100644 index 00000000..309c32f1 Binary files /dev/null and b/tests/lang/ref/expressions.png differ diff --git a/tests/lang/ref/headings.png b/tests/lang/ref/headings.png new file mode 100644 index 00000000..1f374cce Binary files /dev/null and b/tests/lang/ref/headings.png differ diff --git a/tests/lang/ref/let.png b/tests/lang/ref/let.png new file mode 100644 index 00000000..be9d8397 Binary files /dev/null and b/tests/lang/ref/let.png differ diff --git a/tests/lang/ref/raw.png b/tests/lang/ref/raw.png new file mode 100644 index 00000000..f88194c0 Binary files /dev/null and b/tests/lang/ref/raw.png differ diff --git a/tests/lang/ref/values.png b/tests/lang/ref/values.png new file mode 100644 index 00000000..762ad64e Binary files /dev/null and b/tests/lang/ref/values.png differ diff --git a/tests/lang/typ/arrays.typ b/tests/lang/typ/arrays.typ new file mode 100644 index 00000000..0b8fb866 --- /dev/null +++ b/tests/lang/typ/arrays.typ @@ -0,0 +1,33 @@ +// Empty. +{()} + +// One item and trailing comma. +{(-1,)} + +// No trailing comma. +{(true, false)} + +// Multiple lines and items and trailing comma. +{("one" + , 2 + , #003 + ,)} + +// Error: 1:3-1:3 expected closing paren +{(} + +// Error: 2:4-2:6 expected expression, found end of block comment +// Error: 1:4-1:4 expected comma +{(1*/2)} + +// Error: 1:6-1:8 expected expression, found invalid token +{(1, 1u 2)} + +// Error: 1:3-1:4 expected expression, found comma +{(,1)} + +// Error: 1:5-1:5 expected expression +{(a:)} + +// Error: 1:6-1:10 expected expression, found named pair +{(1, b: 2)} diff --git a/tests/lang/typ/basics.typ b/tests/lang/typ/basics.typ new file mode 100644 index 00000000..9220e376 --- /dev/null +++ b/tests/lang/typ/basics.typ @@ -0,0 +1,14 @@ +Hello 🌏! + +_Emph_ and *strong*! + +The non-breaking~space does not work. + +// Directly after word. +Line\ Break + +// Spaces around. +Line \ Break + +// Directly before word does not work. +No \Break diff --git a/tests/lang/typ/blocks.typ b/tests/lang/typ/blocks.typ new file mode 100644 index 00000000..cadd30dd --- /dev/null +++ b/tests/lang/typ/blocks.typ @@ -0,0 +1,21 @@ +{1} + +// Function calls. +{f(1)} +{[[f 1]]} + +// Error: 1:2-1:2 expected expression +{} + +// Error: 1:2-1:4 expected expression, found invalid token +{1u} + +// Error: 1:5-1:5 expected closing brace +{({1) + 2} + +// Error: 1:12-1:12 expected closing bracket +{[*] + [ok*} + +// Error: 2:4-2:5 unexpected hex value +// Error: 1:5-1:6 unexpected opening brace +{1 #{} _end_ diff --git a/tests/lang/typ/bracket-call.typ b/tests/lang/typ/bracket-call.typ new file mode 100644 index 00000000..79667e61 --- /dev/null +++ b/tests/lang/typ/bracket-call.typ @@ -0,0 +1,101 @@ +// Basic call, whitespace insignificant. +[f], [ f ], [ + f +] + +[f bold] + +[f 1,] + +[f a:2] + +[f 1, a: (3, 4), 2, b: "5"] + +--- +// Body and no body. +[f][[f]] + +// Lots of potential bodies. +[f][f][f] + +// Multi-paragraph body. +[box][ + First + + Second +] + +--- +// Chained. +[f | f] + +// Multi-chain. +[f|f|f] + +// With body. +[f | box][💕] + +// Error: 1:2-1:2 expected function name +[|f true] + +// Error: 1:6-1:6 expected function name +[f 1|] + +// Error: 2:5-2:5 expected closing paren +// Error: 1:8-1:9 expected expression, found closing paren +[f (|f )] + +// With actual functions. +[box width: 1cm | image "res/rhino.png"] + +--- +// Error: 1:4-1:6 expected expression, found end of block comment +[f */] + +// Error: 1:7-1:8 expected expression, found colon +[f a:1:] + +// Error: 1:5-1:5 expected comma +[f 1 2] + +// Error: 2:4-2:5 expected identifier +// Error: 1:6-1:6 expected expression +[f 1:] + +// Error: 1:4-1:5 expected identifier +[f 1:2] + +// Error: 1:4-1:7 expected identifier +[f (x):1] + +--- +// Ref: false +// Error: 2:2-2:3 a value of type string is not callable +#let x = "string"; +[x] + +// Error: 1:2-1:3 expected function name, found hex value +[# 1] + +// Error: 4:1-4:1 expected function name +// Error: 3:1-3:1 expected closing bracket +[ + +--- +// Ref: false +// Error: 2:2-2:3 expected function name, found closing paren +// Error: 3:1-3:1 expected closing bracket +[) + +--- +// Error: 3:1-3:1 expected closing bracket +[f [*] + +--- +// Error: 3:1-3:1 expected closing bracket +[f][`a]` + +--- +// Error: 3:1-3:1 expected quote +// Error: 2:1-2:1 expected closing bracket +[f "] diff --git a/tests/lang/typ/comments.typ b/tests/lang/typ/comments.typ new file mode 100644 index 00000000..c5b04967 --- /dev/null +++ b/tests/lang/typ/comments.typ @@ -0,0 +1,18 @@ +// Test whether line comment acts as spacing. +A// you +B + +// Test whether block comment acts as spacing. +C/* + /* */ +*/D + +// Test in expressions. +[f /*1*/ a: "b" // +, 1] + +// Error: 1:7-1:9 unexpected end of block comment +/* */ */ + +// Unterminated block comment is okay. +/* diff --git a/tests/lang/typ/dictionaries.typ b/tests/lang/typ/dictionaries.typ new file mode 100644 index 00000000..c729b92c --- /dev/null +++ b/tests/lang/typ/dictionaries.typ @@ -0,0 +1,14 @@ +// Empty +{(:)} + +// Two pairs. +{(one: 1, two: 2)} + +// Error: 1:9-1:10 expected named pair, found expression +{(a: 1, b)} + +// Error: 4:4-4:5 expected named pair, found expression +// Error: 3:5-3:5 expected comma +// Error: 2:12-2:16 expected identifier +// Error: 1:17-1:18 expected expression, found colon +{(:1 b:[], true::)} diff --git a/tests/lang/typ/empty.typ b/tests/lang/typ/empty.typ new file mode 100644 index 00000000..e69de29b diff --git a/tests/lang/typ/escaping.typ b/tests/lang/typ/escaping.typ new file mode 100644 index 00000000..cb663612 --- /dev/null +++ b/tests/lang/typ/escaping.typ @@ -0,0 +1,25 @@ +// Escapable symbols. +\\ \/ \[ \] \{ \} \* \_ \# \~ \` \$ + +// No need to escape. +( ) = ; + +// Unescapable. +\a \: \; \( \) + +// Escaped comments. +\// +\/\* \*\/ +\/* \*/ * + +// Test unicode escape sequence. +\u{1F3D5} == 🏕 + +// Escaped escape sequence. +\u{41} vs. \\u\{41\} + +// Error: 1:1-1:11 invalid unicode escape sequence +\u{FFFFFF} + +// Error: 1:6-1:6 expected closing brace +\u{41*Bold* diff --git a/tests/lang/typ/expressions.typ b/tests/lang/typ/expressions.typ new file mode 100644 index 00000000..01725289 --- /dev/null +++ b/tests/lang/typ/expressions.typ @@ -0,0 +1,37 @@ +#let a = 2; +#let b = 4; + +// Unary operations. +{+1} +{-1} +{--1} + +// Binary operations. +{"a"+"b"} +{1-2} +{a * b} +{12pt/.4} + +// Associativity. +{1+2+3} +{1/2*3} + +// Precedence. +{1+2*-3} + +// Parentheses. +{(a)} +{(2)} +{(1+2)*3} + +// Confusion with floating-point literal. +{1e+2-1e-2} + +// Error: 1:3-1:3 expected expression +{-} + +// Error: 1:4-1:4 expected expression +{1+} + +// Error: 1:4-1:4 expected expression +{2*} diff --git a/tests/lang/typ/headings.typ b/tests/lang/typ/headings.typ new file mode 100644 index 00000000..f62f6534 --- /dev/null +++ b/tests/lang/typ/headings.typ @@ -0,0 +1,38 @@ +// Test different numbers of hashtags. + +# One +### Three +###### Six + +// Warning: 1:1-1:8 section depth should not exceed 6 +####### Seven + +--- +// Test heading vs. no heading. + +/**/ # Heading +{[## Heading]} +[box][### Heading] + +\# No heading + +Text with # hashtag + +Nr#1 + +// Error: 1:1-1:6 unexpected invalid token +#nope + +--- +// Heading continuation over linebreak. + +# This { + "works" +} + +# [box][ + This +] too + +# This +does not diff --git a/tests/lang/typ/let.typ b/tests/lang/typ/let.typ new file mode 100644 index 00000000..c7bba747 --- /dev/null +++ b/tests/lang/typ/let.typ @@ -0,0 +1,20 @@ +// Automatically initialized with `none`. +#let x; +{(x,)} + +// Can start with underscore. +#let _y=1; +{_y} + +// Multiline. +#let z = "world" + + " 🌏"; Hello, {z}! + +// Error: 1:6-1:7 expected identifier, found integer +#let 1; + +// Error: 4:1-4:3 unexpected identifier +// Error: 3:4-3:9 unexpected identifier +// Error: 3:1-3:1 expected semicolon +#let x = "" +Hi there diff --git a/tests/lang/typ/raw.typ b/tests/lang/typ/raw.typ new file mode 100644 index 00000000..22eda139 --- /dev/null +++ b/tests/lang/typ/raw.typ @@ -0,0 +1,23 @@ +The keyword ``rust let``. + +`#let x = 1` +`[f 1]` + +--- +[font 6pt] + +``py +import this + +def say_hi(): + print("Hello World!") +`` + +--- +```` +```backticks``` +```` + +--- +// Error: 2:1-2:1 expected backtick(s) +`endless diff --git a/tests/lang/typ/values.typ b/tests/lang/typ/values.typ new file mode 100644 index 00000000..ce41fc43 --- /dev/null +++ b/tests/lang/typ/values.typ @@ -0,0 +1,33 @@ +#let name = "Typst"; +#let ke-bab = "Kebab!"; +#let α = "Alpha"; + +{name} \ +{ke-bab} \ +{α} \ +{none} (empty) \ +{true} \ +{false} \ +{1.0e-4} \ +{3.15} \ +{1e-10} \ +{50.368%} \ +{0.0000012345pt} \ +{4.5cm} \ +{12e1pt} \ +{2.5rad} \ +{45deg} \ +{"hi"} \ +{"a\n[]\"\u{1F680}string"} \ +{#f7a20500} \ +{[*{"Hi"} [f 1]*]} \ +{{1}} + +// Error: 1:1-1:4 unknown variable +{_} \ + +// Error: 1:2-1:5 invalid color +{#a5} + +// Error: 1:2-1:4 expected expression, found invalid token +{1u} diff --git a/tests/library/ref/font.png b/tests/library/ref/font.png new file mode 100644 index 00000000..1e025c6f Binary files /dev/null and b/tests/library/ref/font.png differ diff --git a/tests/library/ref/hv.png b/tests/library/ref/hv.png new file mode 100644 index 00000000..ee649fb6 Binary files /dev/null and b/tests/library/ref/hv.png differ diff --git a/tests/library/ref/image.png b/tests/library/ref/image.png new file mode 100644 index 00000000..70f263e6 Binary files /dev/null and b/tests/library/ref/image.png differ diff --git a/tests/library/ref/page.png b/tests/library/ref/page.png new file mode 100644 index 00000000..97557437 Binary files /dev/null and b/tests/library/ref/page.png differ diff --git a/tests/library/ref/pagebreak.png b/tests/library/ref/pagebreak.png new file mode 100644 index 00000000..16eae0e4 Binary files /dev/null and b/tests/library/ref/pagebreak.png differ diff --git a/tests/library/ref/rgb.png b/tests/library/ref/rgb.png new file mode 100644 index 00000000..3060e42c Binary files /dev/null and b/tests/library/ref/rgb.png differ diff --git a/tests/library/typ/font.typ b/tests/library/typ/font.typ new file mode 100644 index 00000000..beaddd4e --- /dev/null +++ b/tests/library/typ/font.typ @@ -0,0 +1,56 @@ +// Test configuring font properties. + +[font "PT Sans", 10pt] + +// Set same font size in three different ways. +[font 20pt][A] +[font 200%][A] +[font 15pt + 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: ultra-condensed][Condensed] + +// Error: 1:7-1: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 font family or array of font families, found integer +[font style: bold, weight: "thin", serif: 0] + +// Warning: 1:15-1:19 must be between 100 and 900 +[font weight: 2700] + +// Error: 1:7-1:27 unexpected argument +[font something: "invalid"] + +--- +// Test font fallback and class definitions. + +// Source Sans Pro + Segoe UI Emoji. +Emoji: 🏀 + +// CMU Serif + Noto Emoji. +[font "CMU Serif", "Noto Emoji"][ + Emoji: 🏀 +] + +// Class definitions. +[font serif: ("CMU Serif", "Latin Modern Math", "Noto Emoji")] +[font serif][ + Math: ∫ α + β ➗ 3 +] + +// Class definition reused. +[font sans-serif: "Noto Emoji"] +[font sans-serif: ("Archivo", sans-serif)] +New sans-serif. 🚀 diff --git a/tests/library/typ/hv.typ b/tests/library/typ/hv.typ new file mode 100644 index 00000000..36a6d242 --- /dev/null +++ b/tests/library/typ/hv.typ @@ -0,0 +1,22 @@ +// Ends paragraphs. +Tightly [v -5pt] 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: 1:11-1:11 missing argument: spacing +Totally [h] ignored + +// Swapped axes. +[page main-dir: rtl, cross-dir: ttb, height: 80pt][ + 1 [h 1cm] 2 + + 3 [v 1cm] 4 [v -1cm] 5 +] diff --git a/tests/library/typ/image.typ b/tests/library/typ/image.typ new file mode 100644 index 00000000..2e7b1eb5 --- /dev/null +++ b/tests/library/typ/image.typ @@ -0,0 +1,39 @@ +// 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: 1:8-1:29 failed to load image +[image "path/does/not/exist"] + +// Error: 1:8-1:29 failed to load image +[image "typ/image-error.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/library/typ/page.typ b/tests/library/typ/page.typ new file mode 100644 index 00000000..9eeddc93 --- /dev/null +++ b/tests/library/typ/page.typ @@ -0,0 +1,54 @@ +// 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: 1:7-1:18 unknown variable +[page nonexistant] + +// Error: 1:17-1:20 aligned axis +[page main-dir: ltr] + +// Flipped predefined paper. +[page "a11", flip: true][Flipped A11] + +// Flipped custom page size. +[page width: 40pt, height: 120pt] +[page flip: true] +Wide + +// Test changing the layouting directions of pages. + +[page height: 50pt, main-dir: btt, cross-dir: rtl] +Right to left! + +--- +// Test a combination of pages with bodies and normal content. + +[page height: 50pt] + +[page][First] +[page][Second] +[pagebreak] +Fourth +[page][] +Sixth +[page][Seventh and last] diff --git a/tests/library/typ/pagebreak.typ b/tests/library/typ/pagebreak.typ new file mode 100644 index 00000000..2f539ce0 --- /dev/null +++ b/tests/library/typ/pagebreak.typ @@ -0,0 +1,3 @@ +First of two +[pagebreak] +[page height: 40pt] diff --git a/tests/library/typ/rgb.typ b/tests/library/typ/rgb.typ new file mode 100644 index 00000000..66d63d0d --- /dev/null +++ b/tests/library/typ/rgb.typ @@ -0,0 +1,17 @@ +// Check the output. +[rgb 0.0, 0.3, 0.7] + +// Alpha channel. +[rgb 1.0, 0.0, 0.0, 0.5] + +// Warning: 2:6-2:9 must be between 0.0 and 1.0 +// Warning: 1:11-1:15 must be between 0.0 and 1.0 +[rgb -30, 15.5, 0.5] + +// Error: 1:6-1:10 missing argument: blue component +[rgb 0, 1] + +// Error: 3:5-3:5 missing argument: red component +// Error: 2:5-2:5 missing argument: green component +// Error: 1:5-1:5 missing argument: blue component +[rgb] diff --git a/tests/ref/full/coma.png b/tests/ref/full/coma.png deleted file mode 100644 index 0c18b810..00000000 Binary files a/tests/ref/full/coma.png and /dev/null differ diff --git a/tests/ref/lang/arrays.png b/tests/ref/lang/arrays.png deleted file mode 100644 index 2d70a3f6..00000000 Binary files a/tests/ref/lang/arrays.png and /dev/null differ diff --git a/tests/ref/lang/basics.png b/tests/ref/lang/basics.png deleted file mode 100644 index 3c3dd7a0..00000000 Binary files a/tests/ref/lang/basics.png and /dev/null differ diff --git a/tests/ref/lang/blocks.png b/tests/ref/lang/blocks.png deleted file mode 100644 index ca826c1b..00000000 Binary files a/tests/ref/lang/blocks.png and /dev/null differ diff --git a/tests/ref/lang/bracket-call.png b/tests/ref/lang/bracket-call.png deleted file mode 100644 index 16afb187..00000000 Binary files a/tests/ref/lang/bracket-call.png and /dev/null differ diff --git a/tests/ref/lang/comments.png b/tests/ref/lang/comments.png deleted file mode 100644 index df5e5b9c..00000000 Binary files a/tests/ref/lang/comments.png and /dev/null differ diff --git a/tests/ref/lang/dictionaries.png b/tests/ref/lang/dictionaries.png deleted file mode 100644 index aa40549e..00000000 Binary files a/tests/ref/lang/dictionaries.png and /dev/null differ diff --git a/tests/ref/lang/empty.png b/tests/ref/lang/empty.png deleted file mode 100644 index 87c06b0a..00000000 Binary files a/tests/ref/lang/empty.png and /dev/null differ diff --git a/tests/ref/lang/escaping.png b/tests/ref/lang/escaping.png deleted file mode 100644 index 575a4b2f..00000000 Binary files a/tests/ref/lang/escaping.png and /dev/null differ diff --git a/tests/ref/lang/expressions.png b/tests/ref/lang/expressions.png deleted file mode 100644 index 309c32f1..00000000 Binary files a/tests/ref/lang/expressions.png and /dev/null differ diff --git a/tests/ref/lang/headings.png b/tests/ref/lang/headings.png deleted file mode 100644 index 1f374cce..00000000 Binary files a/tests/ref/lang/headings.png and /dev/null differ diff --git a/tests/ref/lang/let.png b/tests/ref/lang/let.png deleted file mode 100644 index be9d8397..00000000 Binary files a/tests/ref/lang/let.png and /dev/null differ diff --git a/tests/ref/lang/raw.png b/tests/ref/lang/raw.png deleted file mode 100644 index f88194c0..00000000 Binary files a/tests/ref/lang/raw.png and /dev/null differ diff --git a/tests/ref/lang/values.png b/tests/ref/lang/values.png deleted file mode 100644 index 762ad64e..00000000 Binary files a/tests/ref/lang/values.png and /dev/null differ diff --git a/tests/ref/library/font.png b/tests/ref/library/font.png deleted file mode 100644 index 1e025c6f..00000000 Binary files a/tests/ref/library/font.png and /dev/null differ diff --git a/tests/ref/library/hv.png b/tests/ref/library/hv.png deleted file mode 100644 index ee649fb6..00000000 Binary files a/tests/ref/library/hv.png and /dev/null differ diff --git a/tests/ref/library/image.png b/tests/ref/library/image.png deleted file mode 100644 index 70f263e6..00000000 Binary files a/tests/ref/library/image.png and /dev/null differ diff --git a/tests/ref/library/page.png b/tests/ref/library/page.png deleted file mode 100644 index 97557437..00000000 Binary files a/tests/ref/library/page.png and /dev/null differ diff --git a/tests/ref/library/pagebreak.png b/tests/ref/library/pagebreak.png deleted file mode 100644 index 16eae0e4..00000000 Binary files a/tests/ref/library/pagebreak.png and /dev/null differ diff --git a/tests/ref/library/rgb.png b/tests/ref/library/rgb.png deleted file mode 100644 index 3060e42c..00000000 Binary files a/tests/ref/library/rgb.png and /dev/null differ diff --git a/tests/typ/full/coma.typ b/tests/typ/full/coma.typ deleted file mode 100644 index b7863fce..00000000 --- a/tests/typ/full/coma.typ +++ /dev/null @@ -1,25 +0,0 @@ -[page width: 450pt, height: 300pt, margins: 1cm] - -[box][ - *Technische Universität Berlin* \ - *Fakultät II, Institut for Mathematik* \ - Sekretariat MA \ - Dr. Max Mustermann \ - Ola Nordmann, John Doe -] -[align right | box][*WiSe 2019/2020* \ Woche 3] - -[v 6mm] - -[align center][ - #### 3. Übungsblatt Computerorientierte Mathematik II [v 2mm] - *Abgabe: 03.05.2019* (bis 10:10 Uhr in MA 001) [v 2mm] - *Alle Antworten sind zu beweisen.* -] - -*1. Aufgabe* [align right][(1 + 1 + 2 Punkte)] - -Ein _Binärbaum_ ist ein Wurzelbaum, in dem jeder Knoten ≤ 2 Kinder hat. -Die Tiefe eines Knotens _v_ ist die Länge des eindeutigen Weges von der Wurzel -zu _v_, und die Höhe von _v_ ist die Länge eines längsten (absteigenden) Weges -von _v_ zu einem Blatt. Die Höhe des Baumes ist die Höhe der Wurzel. diff --git a/tests/typ/lang/arrays.typ b/tests/typ/lang/arrays.typ deleted file mode 100644 index 0b8fb866..00000000 --- a/tests/typ/lang/arrays.typ +++ /dev/null @@ -1,33 +0,0 @@ -// Empty. -{()} - -// One item and trailing comma. -{(-1,)} - -// No trailing comma. -{(true, false)} - -// Multiple lines and items and trailing comma. -{("one" - , 2 - , #003 - ,)} - -// Error: 1:3-1:3 expected closing paren -{(} - -// Error: 2:4-2:6 expected expression, found end of block comment -// Error: 1:4-1:4 expected comma -{(1*/2)} - -// Error: 1:6-1:8 expected expression, found invalid token -{(1, 1u 2)} - -// Error: 1:3-1:4 expected expression, found comma -{(,1)} - -// Error: 1:5-1:5 expected expression -{(a:)} - -// Error: 1:6-1:10 expected expression, found named pair -{(1, b: 2)} diff --git a/tests/typ/lang/basics.typ b/tests/typ/lang/basics.typ deleted file mode 100644 index 9220e376..00000000 --- a/tests/typ/lang/basics.typ +++ /dev/null @@ -1,14 +0,0 @@ -Hello 🌏! - -_Emph_ and *strong*! - -The non-breaking~space does not work. - -// Directly after word. -Line\ Break - -// Spaces around. -Line \ Break - -// Directly before word does not work. -No \Break diff --git a/tests/typ/lang/blocks.typ b/tests/typ/lang/blocks.typ deleted file mode 100644 index cadd30dd..00000000 --- a/tests/typ/lang/blocks.typ +++ /dev/null @@ -1,21 +0,0 @@ -{1} - -// Function calls. -{f(1)} -{[[f 1]]} - -// Error: 1:2-1:2 expected expression -{} - -// Error: 1:2-1:4 expected expression, found invalid token -{1u} - -// Error: 1:5-1:5 expected closing brace -{({1) + 2} - -// Error: 1:12-1:12 expected closing bracket -{[*] + [ok*} - -// Error: 2:4-2:5 unexpected hex value -// Error: 1:5-1:6 unexpected opening brace -{1 #{} _end_ diff --git a/tests/typ/lang/bracket-call.typ b/tests/typ/lang/bracket-call.typ deleted file mode 100644 index 79667e61..00000000 --- a/tests/typ/lang/bracket-call.typ +++ /dev/null @@ -1,101 +0,0 @@ -// Basic call, whitespace insignificant. -[f], [ f ], [ - f -] - -[f bold] - -[f 1,] - -[f a:2] - -[f 1, a: (3, 4), 2, b: "5"] - ---- -// Body and no body. -[f][[f]] - -// Lots of potential bodies. -[f][f][f] - -// Multi-paragraph body. -[box][ - First - - Second -] - ---- -// Chained. -[f | f] - -// Multi-chain. -[f|f|f] - -// With body. -[f | box][💕] - -// Error: 1:2-1:2 expected function name -[|f true] - -// Error: 1:6-1:6 expected function name -[f 1|] - -// Error: 2:5-2:5 expected closing paren -// Error: 1:8-1:9 expected expression, found closing paren -[f (|f )] - -// With actual functions. -[box width: 1cm | image "res/rhino.png"] - ---- -// Error: 1:4-1:6 expected expression, found end of block comment -[f */] - -// Error: 1:7-1:8 expected expression, found colon -[f a:1:] - -// Error: 1:5-1:5 expected comma -[f 1 2] - -// Error: 2:4-2:5 expected identifier -// Error: 1:6-1:6 expected expression -[f 1:] - -// Error: 1:4-1:5 expected identifier -[f 1:2] - -// Error: 1:4-1:7 expected identifier -[f (x):1] - ---- -// Ref: false -// Error: 2:2-2:3 a value of type string is not callable -#let x = "string"; -[x] - -// Error: 1:2-1:3 expected function name, found hex value -[# 1] - -// Error: 4:1-4:1 expected function name -// Error: 3:1-3:1 expected closing bracket -[ - ---- -// Ref: false -// Error: 2:2-2:3 expected function name, found closing paren -// Error: 3:1-3:1 expected closing bracket -[) - ---- -// Error: 3:1-3:1 expected closing bracket -[f [*] - ---- -// Error: 3:1-3:1 expected closing bracket -[f][`a]` - ---- -// Error: 3:1-3:1 expected quote -// Error: 2:1-2:1 expected closing bracket -[f "] diff --git a/tests/typ/lang/comments.typ b/tests/typ/lang/comments.typ deleted file mode 100644 index c5b04967..00000000 --- a/tests/typ/lang/comments.typ +++ /dev/null @@ -1,18 +0,0 @@ -// Test whether line comment acts as spacing. -A// you -B - -// Test whether block comment acts as spacing. -C/* - /* */ -*/D - -// Test in expressions. -[f /*1*/ a: "b" // -, 1] - -// Error: 1:7-1:9 unexpected end of block comment -/* */ */ - -// Unterminated block comment is okay. -/* diff --git a/tests/typ/lang/dictionaries.typ b/tests/typ/lang/dictionaries.typ deleted file mode 100644 index c729b92c..00000000 --- a/tests/typ/lang/dictionaries.typ +++ /dev/null @@ -1,14 +0,0 @@ -// Empty -{(:)} - -// Two pairs. -{(one: 1, two: 2)} - -// Error: 1:9-1:10 expected named pair, found expression -{(a: 1, b)} - -// Error: 4:4-4:5 expected named pair, found expression -// Error: 3:5-3:5 expected comma -// Error: 2:12-2:16 expected identifier -// Error: 1:17-1:18 expected expression, found colon -{(:1 b:[], true::)} diff --git a/tests/typ/lang/empty.typ b/tests/typ/lang/empty.typ deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/typ/lang/escaping.typ b/tests/typ/lang/escaping.typ deleted file mode 100644 index cb663612..00000000 --- a/tests/typ/lang/escaping.typ +++ /dev/null @@ -1,25 +0,0 @@ -// Escapable symbols. -\\ \/ \[ \] \{ \} \* \_ \# \~ \` \$ - -// No need to escape. -( ) = ; - -// Unescapable. -\a \: \; \( \) - -// Escaped comments. -\// -\/\* \*\/ -\/* \*/ * - -// Test unicode escape sequence. -\u{1F3D5} == 🏕 - -// Escaped escape sequence. -\u{41} vs. \\u\{41\} - -// Error: 1:1-1:11 invalid unicode escape sequence -\u{FFFFFF} - -// Error: 1:6-1:6 expected closing brace -\u{41*Bold* diff --git a/tests/typ/lang/expressions.typ b/tests/typ/lang/expressions.typ deleted file mode 100644 index 01725289..00000000 --- a/tests/typ/lang/expressions.typ +++ /dev/null @@ -1,37 +0,0 @@ -#let a = 2; -#let b = 4; - -// Unary operations. -{+1} -{-1} -{--1} - -// Binary operations. -{"a"+"b"} -{1-2} -{a * b} -{12pt/.4} - -// Associativity. -{1+2+3} -{1/2*3} - -// Precedence. -{1+2*-3} - -// Parentheses. -{(a)} -{(2)} -{(1+2)*3} - -// Confusion with floating-point literal. -{1e+2-1e-2} - -// Error: 1:3-1:3 expected expression -{-} - -// Error: 1:4-1:4 expected expression -{1+} - -// Error: 1:4-1:4 expected expression -{2*} diff --git a/tests/typ/lang/headings.typ b/tests/typ/lang/headings.typ deleted file mode 100644 index f62f6534..00000000 --- a/tests/typ/lang/headings.typ +++ /dev/null @@ -1,38 +0,0 @@ -// Test different numbers of hashtags. - -# One -### Three -###### Six - -// Warning: 1:1-1:8 section depth should not exceed 6 -####### Seven - ---- -// Test heading vs. no heading. - -/**/ # Heading -{[## Heading]} -[box][### Heading] - -\# No heading - -Text with # hashtag - -Nr#1 - -// Error: 1:1-1:6 unexpected invalid token -#nope - ---- -// Heading continuation over linebreak. - -# This { - "works" -} - -# [box][ - This -] too - -# This -does not diff --git a/tests/typ/lang/let.typ b/tests/typ/lang/let.typ deleted file mode 100644 index c7bba747..00000000 --- a/tests/typ/lang/let.typ +++ /dev/null @@ -1,20 +0,0 @@ -// Automatically initialized with `none`. -#let x; -{(x,)} - -// Can start with underscore. -#let _y=1; -{_y} - -// Multiline. -#let z = "world" - + " 🌏"; Hello, {z}! - -// Error: 1:6-1:7 expected identifier, found integer -#let 1; - -// Error: 4:1-4:3 unexpected identifier -// Error: 3:4-3:9 unexpected identifier -// Error: 3:1-3:1 expected semicolon -#let x = "" -Hi there diff --git a/tests/typ/lang/raw.typ b/tests/typ/lang/raw.typ deleted file mode 100644 index 22eda139..00000000 --- a/tests/typ/lang/raw.typ +++ /dev/null @@ -1,23 +0,0 @@ -The keyword ``rust let``. - -`#let x = 1` -`[f 1]` - ---- -[font 6pt] - -``py -import this - -def say_hi(): - print("Hello World!") -`` - ---- -```` -```backticks``` -```` - ---- -// Error: 2:1-2:1 expected backtick(s) -`endless diff --git a/tests/typ/lang/values.typ b/tests/typ/lang/values.typ deleted file mode 100644 index ce41fc43..00000000 --- a/tests/typ/lang/values.typ +++ /dev/null @@ -1,33 +0,0 @@ -#let name = "Typst"; -#let ke-bab = "Kebab!"; -#let α = "Alpha"; - -{name} \ -{ke-bab} \ -{α} \ -{none} (empty) \ -{true} \ -{false} \ -{1.0e-4} \ -{3.15} \ -{1e-10} \ -{50.368%} \ -{0.0000012345pt} \ -{4.5cm} \ -{12e1pt} \ -{2.5rad} \ -{45deg} \ -{"hi"} \ -{"a\n[]\"\u{1F680}string"} \ -{#f7a20500} \ -{[*{"Hi"} [f 1]*]} \ -{{1}} - -// Error: 1:1-1:4 unknown variable -{_} \ - -// Error: 1:2-1:5 invalid color -{#a5} - -// Error: 1:2-1:4 expected expression, found invalid token -{1u} diff --git a/tests/typ/library/font.typ b/tests/typ/library/font.typ deleted file mode 100644 index beaddd4e..00000000 --- a/tests/typ/library/font.typ +++ /dev/null @@ -1,56 +0,0 @@ -// Test configuring font properties. - -[font "PT Sans", 10pt] - -// Set same font size in three different ways. -[font 20pt][A] -[font 200%][A] -[font 15pt + 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: ultra-condensed][Condensed] - -// Error: 1:7-1: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 font family or array of font families, found integer -[font style: bold, weight: "thin", serif: 0] - -// Warning: 1:15-1:19 must be between 100 and 900 -[font weight: 2700] - -// Error: 1:7-1:27 unexpected argument -[font something: "invalid"] - ---- -// Test font fallback and class definitions. - -// Source Sans Pro + Segoe UI Emoji. -Emoji: 🏀 - -// CMU Serif + Noto Emoji. -[font "CMU Serif", "Noto Emoji"][ - Emoji: 🏀 -] - -// Class definitions. -[font serif: ("CMU Serif", "Latin Modern Math", "Noto Emoji")] -[font serif][ - Math: ∫ α + β ➗ 3 -] - -// Class definition reused. -[font sans-serif: "Noto Emoji"] -[font sans-serif: ("Archivo", sans-serif)] -New sans-serif. 🚀 diff --git a/tests/typ/library/hv.typ b/tests/typ/library/hv.typ deleted file mode 100644 index 36a6d242..00000000 --- a/tests/typ/library/hv.typ +++ /dev/null @@ -1,22 +0,0 @@ -// Ends paragraphs. -Tightly [v -5pt] 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: 1:11-1:11 missing argument: spacing -Totally [h] ignored - -// Swapped axes. -[page main-dir: rtl, cross-dir: ttb, height: 80pt][ - 1 [h 1cm] 2 - - 3 [v 1cm] 4 [v -1cm] 5 -] diff --git a/tests/typ/library/image.typ b/tests/typ/library/image.typ deleted file mode 100644 index 2e7b1eb5..00000000 --- a/tests/typ/library/image.typ +++ /dev/null @@ -1,39 +0,0 @@ -// 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: 1:8-1:29 failed to load image -[image "path/does/not/exist"] - -// Error: 1:8-1:29 failed to load image -[image "typ/image-error.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/page.typ b/tests/typ/library/page.typ deleted file mode 100644 index 9eeddc93..00000000 --- a/tests/typ/library/page.typ +++ /dev/null @@ -1,54 +0,0 @@ -// 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: 1:7-1:18 unknown variable -[page nonexistant] - -// Error: 1:17-1:20 aligned axis -[page main-dir: ltr] - -// Flipped predefined paper. -[page "a11", flip: true][Flipped A11] - -// Flipped custom page size. -[page width: 40pt, height: 120pt] -[page flip: true] -Wide - -// Test changing the layouting directions of pages. - -[page height: 50pt, main-dir: btt, cross-dir: rtl] -Right to left! - ---- -// Test a combination of pages with bodies and normal content. - -[page height: 50pt] - -[page][First] -[page][Second] -[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 2f539ce0..00000000 --- a/tests/typ/library/pagebreak.typ +++ /dev/null @@ -1,3 +0,0 @@ -First of two -[pagebreak] -[page height: 40pt] diff --git a/tests/typ/library/rgb.typ b/tests/typ/library/rgb.typ deleted file mode 100644 index 66d63d0d..00000000 --- a/tests/typ/library/rgb.typ +++ /dev/null @@ -1,17 +0,0 @@ -// Check the output. -[rgb 0.0, 0.3, 0.7] - -// Alpha channel. -[rgb 1.0, 0.0, 0.0, 0.5] - -// Warning: 2:6-2:9 must be between 0.0 and 1.0 -// Warning: 1:11-1:15 must be between 0.0 and 1.0 -[rgb -30, 15.5, 0.5] - -// Error: 1:6-1:10 missing argument: blue component -[rgb 0, 1] - -// Error: 3:5-3:5 missing argument: red component -// Error: 2:5-2:5 missing argument: green component -// Error: 1:5-1:5 missing argument: blue component -[rgb] diff --git a/tests/typeset.rs b/tests/typeset.rs index 5777950f..10e6231e 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -38,14 +38,18 @@ fn main() { let filter = TestFilter::new(env::args().skip(1)); let mut filtered = Vec::new(); - for entry in WalkDir::new(TYP_DIR).into_iter() { + for entry in WalkDir::new(".").into_iter() { let entry = entry.unwrap(); + if entry.depth() <= 1 { + continue; + } + let src_path = entry.into_path(); if src_path.extension() != Some(OsStr::new("typ")) { continue; } - if filter.matches(&src_path.to_string_lossy().to_string()) { + if filter.matches(&src_path.to_string_lossy()) { filtered.push(src_path); } } @@ -78,10 +82,11 @@ fn main() { let mut ok = true; for src_path in filtered { - let relative = src_path.strip_prefix(TYP_DIR).unwrap(); - let png_path = Path::new(PNG_DIR).join(&relative).with_extension("png"); - let pdf_path = Path::new(PDF_DIR).join(&relative).with_extension("pdf"); - let ref_path = Path::new(REF_DIR).join(&relative).with_extension("png"); + let category = src_path.parent().unwrap().parent().unwrap(); + let name = src_path.file_stem().unwrap(); + let png_path = category.join(PNG_DIR).join(name).with_extension("png"); + let pdf_path = category.join(PDF_DIR).join(name).with_extension("pdf"); + let ref_path = category.join(REF_DIR).join(name).with_extension("png"); ok &= test(&src_path, &png_path, &pdf_path, Some(&ref_path), &mut env); } -- cgit v1.2.3