diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-02-20 17:53:40 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-02-20 23:34:33 +0100 |
| commit | 05727bfc3a9cfd45a8e2028dfd0806f7a8f88015 (patch) | |
| tree | 6c0b66eb2a9dff224cb39eb6ccb478656a706c04 | |
| parent | 927341d93ae29678095e3b874bd68bfc57d4bc05 (diff) | |
Reorganize tests 🔀
| -rw-r--r-- | .gitignore | 4 | ||||
| -rw-r--r-- | bench/src/bench.rs | 2 | ||||
| -rw-r--r-- | tests/README.md | 35 | ||||
| -rw-r--r-- | tests/lang/typ/expr-unary.typ | 23 | ||||
| -rw-r--r-- | tests/ref/comment.png (renamed from tests/lang/ref/comment.png) | bin | 682 -> 682 bytes | |||
| -rw-r--r-- | tests/ref/control/for-invalid.png (renamed from tests/lang/ref/for-invalid.png) | bin | 1653 -> 1653 bytes | |||
| -rw-r--r-- | tests/ref/control/for-value.png (renamed from tests/lang/ref/for-value.png) | bin | 1702 -> 1702 bytes | |||
| -rw-r--r-- | tests/ref/control/for.png (renamed from tests/lang/ref/for.png) | bin | 1389 -> 1389 bytes | |||
| -rw-r--r-- | tests/ref/control/if-invalid.png (renamed from tests/lang/ref/if-invalid.png) | bin | 1343 -> 1343 bytes | |||
| -rw-r--r-- | tests/ref/control/if.png (renamed from tests/lang/ref/if.png) | bin | 1227 -> 1227 bytes | |||
| -rw-r--r-- | tests/ref/control/let-invalid.png (renamed from tests/lang/ref/let-invalid.png) | bin | 364 -> 364 bytes | |||
| -rw-r--r-- | tests/ref/control/let-terminated.png (renamed from tests/lang/ref/let-terminated.png) | bin | 1459 -> 1459 bytes | |||
| -rw-r--r-- | tests/ref/empty.png (renamed from tests/lang/ref/empty.png) | bin | 94 -> 94 bytes | |||
| -rw-r--r-- | tests/ref/expr/array.png (renamed from tests/lang/ref/array.png) | bin | 3922 -> 3922 bytes | |||
| -rw-r--r-- | tests/ref/expr/block-invalid.png (renamed from tests/lang/ref/block-invalid.png) | bin | 507 -> 507 bytes | |||
| -rw-r--r-- | tests/ref/expr/block.png (renamed from tests/lang/ref/block.png) | bin | 1367 -> 1367 bytes | |||
| -rw-r--r-- | tests/ref/expr/call-invalid.png (renamed from tests/lang/ref/call-invalid.png) | bin | 3043 -> 3043 bytes | |||
| -rw-r--r-- | tests/ref/expr/call.png (renamed from tests/lang/ref/call.png) | bin | 5661 -> 5661 bytes | |||
| -rw-r--r-- | tests/ref/expr/dict.png (renamed from tests/lang/ref/dict.png) | bin | 1905 -> 1905 bytes | |||
| -rw-r--r-- | tests/ref/expr/ops.png (renamed from tests/lang/ref/expr-binary.png) | bin | 756 -> 756 bytes | |||
| -rw-r--r-- | tests/ref/full/coma.png (renamed from tests/full/ref/coma.png) | bin | 61297 -> 61297 bytes | |||
| -rw-r--r-- | tests/ref/library/box.png (renamed from tests/library/ref/box.png) | bin | 2704 -> 2704 bytes | |||
| -rw-r--r-- | tests/ref/library/font.png (renamed from tests/library/ref/font.png) | bin | 5386 -> 5386 bytes | |||
| -rw-r--r-- | tests/ref/library/hv.png (renamed from tests/library/ref/hv.png) | bin | 3961 -> 3961 bytes | |||
| -rw-r--r-- | tests/ref/library/image.png (renamed from tests/library/ref/image.png) | bin | 220343 -> 220343 bytes | |||
| -rw-r--r-- | tests/ref/library/page.png (renamed from tests/library/ref/page.png) | bin | 8097 -> 8097 bytes | |||
| -rw-r--r-- | tests/ref/library/pagebreak.png (renamed from tests/library/ref/pagebreak.png) | bin | 821 -> 821 bytes | |||
| -rw-r--r-- | tests/ref/library/rgb.png (renamed from tests/library/ref/rgb.png) | bin | 3068 -> 3068 bytes | |||
| -rw-r--r-- | tests/ref/markup/emph.png (renamed from tests/lang/ref/emph.png) | bin | 3112 -> 3112 bytes | |||
| -rw-r--r-- | tests/ref/markup/escape.png (renamed from tests/lang/ref/escape.png) | bin | 4241 -> 4241 bytes | |||
| -rw-r--r-- | tests/ref/markup/heading.png (renamed from tests/lang/ref/heading.png) | bin | 4285 -> 4285 bytes | |||
| -rw-r--r-- | tests/ref/markup/linebreak.png (renamed from tests/lang/ref/linebreak.png) | bin | 3668 -> 3668 bytes | |||
| -rw-r--r-- | tests/ref/markup/nbsp.png (renamed from tests/lang/ref/nbsp.png) | bin | 1854 -> 1854 bytes | |||
| -rw-r--r-- | tests/ref/markup/raw.png (renamed from tests/lang/ref/raw.png) | bin | 8220 -> 8220 bytes | |||
| -rw-r--r-- | tests/ref/markup/strong.png (renamed from tests/lang/ref/strong.png) | bin | 2810 -> 2810 bytes | |||
| -rw-r--r-- | tests/ref/repr.png (renamed from tests/lang/ref/repr.png) | bin | 9032 -> 9032 bytes | |||
| -rw-r--r-- | tests/ref/spacing.png (renamed from tests/lang/ref/spacing.png) | bin | 3858 -> 3858 bytes | |||
| -rw-r--r-- | tests/ref/text.png (renamed from tests/lang/ref/text.png) | bin | 1892 -> 1892 bytes | |||
| -rw-r--r-- | tests/typ/comment.typ (renamed from tests/lang/typ/comment.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/control/for-invalid.typ (renamed from tests/lang/typ/for-invalid.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/control/for-pattern.typ (renamed from tests/lang/typ/for-pattern.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/control/for-value.typ (renamed from tests/lang/typ/for-value.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/control/for.typ (renamed from tests/lang/typ/for.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/control/if-invalid.typ (renamed from tests/lang/typ/if-invalid.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/control/if-value.typ (renamed from tests/lang/typ/if-value.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/control/if.typ (renamed from tests/lang/typ/if.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/control/let-invalid.typ (renamed from tests/lang/typ/let-invalid.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/control/let-terminated.typ (renamed from tests/lang/typ/let-terminated.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/control/let.typ (renamed from tests/lang/typ/let.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/empty.typ (renamed from tests/lang/typ/empty.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/expr/array.typ (renamed from tests/lang/typ/array.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/expr/assoc.typ (renamed from tests/lang/typ/expr-assoc.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/expr/block-invalid.typ (renamed from tests/lang/typ/block-invalid.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/expr/block-scoping.typ (renamed from tests/lang/typ/block-scoping.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/expr/block.typ (renamed from tests/lang/typ/block.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/expr/call-invalid.typ (renamed from tests/lang/typ/call-invalid.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/expr/call.typ (renamed from tests/lang/typ/call.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/expr/dict.typ (renamed from tests/lang/typ/dict.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/expr/ops-invalid.typ (renamed from tests/lang/typ/expr-invalid.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/expr/ops.typ (renamed from tests/lang/typ/expr-binary.typ) | 19 | ||||
| -rw-r--r-- | tests/typ/expr/prec.typ (renamed from tests/lang/typ/expr-prec.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/full/coma.typ (renamed from tests/full/typ/coma.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/library/box.typ (renamed from tests/library/typ/box.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/library/font.typ (renamed from tests/library/typ/font.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/library/hv.typ (renamed from tests/library/typ/hv.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/library/image.typ (renamed from tests/library/typ/image.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/library/page.typ (renamed from tests/library/typ/page.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/library/pagebreak.typ (renamed from tests/library/typ/pagebreak.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/library/rgb.typ (renamed from tests/library/typ/rgb.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/markup/emph.typ (renamed from tests/lang/typ/emph.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/markup/escape.typ (renamed from tests/lang/typ/escape.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/markup/heading.typ (renamed from tests/lang/typ/heading.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/markup/linebreak.typ (renamed from tests/lang/typ/linebreak.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/markup/nbsp.typ (renamed from tests/lang/typ/nbsp.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/markup/raw.typ (renamed from tests/lang/typ/raw.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/markup/strong.typ (renamed from tests/lang/typ/strong.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/repr.typ (renamed from tests/lang/typ/repr.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/spacing.typ (renamed from tests/lang/typ/spacing.typ) | 0 | ||||
| -rw-r--r-- | tests/typ/text.typ (renamed from tests/lang/typ/text.typ) | 0 | ||||
| -rw-r--r-- | tests/typeset.rs | 46 |
80 files changed, 51 insertions, 78 deletions
@@ -6,8 +6,8 @@ bench/target **/*.rs.bk Cargo.lock -tests/*/png -tests/*/pdf +tests/png +tests/pdf tests/playground.* tarpaulin-report.html diff --git a/bench/src/bench.rs b/bench/src/bench.rs index 0999b246..cf752769 100644 --- a/bench/src/bench.rs +++ b/bench/src/bench.rs @@ -12,7 +12,7 @@ use typst::parse::parse; use typst::typeset; const FONT_DIR: &str = "../fonts"; -const COMA: &str = include_str!("../../tests/full/typ/coma.typ"); +const COMA: &str = include_str!("../../tests/typ/full/coma.typ"); fn benchmarks(c: &mut Criterion) { macro_rules! bench { diff --git a/tests/README.md b/tests/README.md index 5334c271..fb755f1b 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,5 +1,14 @@ # Tests +## Directory structure +Top level directory structure: +- `typ`: Input files. +- `ref`: Reference images which the output is compared with to determine whether + a test passed or failed. +- `png`: PNG files produced by tests. +- `pdf`: PDF files produced by tests. +- `res`: Resource files used by tests. + ## Running the tests ```bash # Run all tests @@ -11,34 +20,16 @@ cargo test --lib # Run integration tests (the tests in this directory) cargo test --test typeset -# Run all tests whose names contain a filter word -cargo test --test typeset call -``` - -For experimenting it's often useful to have a test file you can quickly run. For that purpose you can have a file named `playground.typ` right in this directory (the file is ignored by git). The playground test will be executed whenever no other test matches the filter, so you can run it with (since no real test's name contains an underscore): -```bash -cargo test --test typeset _ +# Run all tests whose names contain the word `filter` +cargo test --test typeset filter ``` -## 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. -- `png`: PNG files produced by tests. -- `pdf`: PDF files produced by tests. - +## Creating new tests To keep things small, please optimize reference images before committing them: ```bash # One image 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/lang/typ/expr-unary.typ b/tests/lang/typ/expr-unary.typ deleted file mode 100644 index c4b1937d..00000000 --- a/tests/lang/typ/expr-unary.typ +++ /dev/null @@ -1,23 +0,0 @@ -// Test unary expressions. -// Ref: false - ---- -// Test plus and minus. -#for v in (1, 3.14, 12pt, 45deg, 90%, 13% + 10pt) { - // Test plus. - test(+v, v) - - // Test minus. - test(-v, -1 * v) - test(--v, v) - - // Test combination. - test(-++ --v, -v) -} - -#test(-(4 + 2), 6-12) - ---- -// Test not. -#test(not true, false) -#test(not false, true) diff --git a/tests/lang/ref/comment.png b/tests/ref/comment.png Binary files differindex 7ab48b3a..7ab48b3a 100644 --- a/tests/lang/ref/comment.png +++ b/tests/ref/comment.png diff --git a/tests/lang/ref/for-invalid.png b/tests/ref/control/for-invalid.png Binary files differindex d758aa95..d758aa95 100644 --- a/tests/lang/ref/for-invalid.png +++ b/tests/ref/control/for-invalid.png diff --git a/tests/lang/ref/for-value.png b/tests/ref/control/for-value.png Binary files differindex fa323edc..fa323edc 100644 --- a/tests/lang/ref/for-value.png +++ b/tests/ref/control/for-value.png diff --git a/tests/lang/ref/for.png b/tests/ref/control/for.png Binary files differindex 2f13985a..2f13985a 100644 --- a/tests/lang/ref/for.png +++ b/tests/ref/control/for.png diff --git a/tests/lang/ref/if-invalid.png b/tests/ref/control/if-invalid.png Binary files differindex 319fbdbd..319fbdbd 100644 --- a/tests/lang/ref/if-invalid.png +++ b/tests/ref/control/if-invalid.png diff --git a/tests/lang/ref/if.png b/tests/ref/control/if.png Binary files differindex 75a20d00..75a20d00 100644 --- a/tests/lang/ref/if.png +++ b/tests/ref/control/if.png diff --git a/tests/lang/ref/let-invalid.png b/tests/ref/control/let-invalid.png Binary files differindex 19d4d545..19d4d545 100644 --- a/tests/lang/ref/let-invalid.png +++ b/tests/ref/control/let-invalid.png diff --git a/tests/lang/ref/let-terminated.png b/tests/ref/control/let-terminated.png Binary files differindex 24f20c69..24f20c69 100644 --- a/tests/lang/ref/let-terminated.png +++ b/tests/ref/control/let-terminated.png diff --git a/tests/lang/ref/empty.png b/tests/ref/empty.png Binary files differindex 87c06b0a..87c06b0a 100644 --- a/tests/lang/ref/empty.png +++ b/tests/ref/empty.png diff --git a/tests/lang/ref/array.png b/tests/ref/expr/array.png Binary files differindex 5bfddeb1..5bfddeb1 100644 --- a/tests/lang/ref/array.png +++ b/tests/ref/expr/array.png diff --git a/tests/lang/ref/block-invalid.png b/tests/ref/expr/block-invalid.png Binary files differindex 56471574..56471574 100644 --- a/tests/lang/ref/block-invalid.png +++ b/tests/ref/expr/block-invalid.png diff --git a/tests/lang/ref/block.png b/tests/ref/expr/block.png Binary files differindex a3c03698..a3c03698 100644 --- a/tests/lang/ref/block.png +++ b/tests/ref/expr/block.png diff --git a/tests/lang/ref/call-invalid.png b/tests/ref/expr/call-invalid.png Binary files differindex eee20e4d..eee20e4d 100644 --- a/tests/lang/ref/call-invalid.png +++ b/tests/ref/expr/call-invalid.png diff --git a/tests/lang/ref/call.png b/tests/ref/expr/call.png Binary files differindex 5963d30e..5963d30e 100644 --- a/tests/lang/ref/call.png +++ b/tests/ref/expr/call.png diff --git a/tests/lang/ref/dict.png b/tests/ref/expr/dict.png Binary files differindex b30f1300..b30f1300 100644 --- a/tests/lang/ref/dict.png +++ b/tests/ref/expr/dict.png diff --git a/tests/lang/ref/expr-binary.png b/tests/ref/expr/ops.png Binary files differindex 6c94ef9b..6c94ef9b 100644 --- a/tests/lang/ref/expr-binary.png +++ b/tests/ref/expr/ops.png diff --git a/tests/full/ref/coma.png b/tests/ref/full/coma.png Binary files differindex 081defeb..081defeb 100644 --- a/tests/full/ref/coma.png +++ b/tests/ref/full/coma.png diff --git a/tests/library/ref/box.png b/tests/ref/library/box.png Binary files differindex 9827c6c3..9827c6c3 100644 --- a/tests/library/ref/box.png +++ b/tests/ref/library/box.png diff --git a/tests/library/ref/font.png b/tests/ref/library/font.png Binary files differindex 1e025c6f..1e025c6f 100644 --- a/tests/library/ref/font.png +++ b/tests/ref/library/font.png diff --git a/tests/library/ref/hv.png b/tests/ref/library/hv.png Binary files differindex ee649fb6..ee649fb6 100644 --- a/tests/library/ref/hv.png +++ b/tests/ref/library/hv.png diff --git a/tests/library/ref/image.png b/tests/ref/library/image.png Binary files differindex 70f263e6..70f263e6 100644 --- a/tests/library/ref/image.png +++ b/tests/ref/library/image.png diff --git a/tests/library/ref/page.png b/tests/ref/library/page.png Binary files differindex 97557437..97557437 100644 --- a/tests/library/ref/page.png +++ b/tests/ref/library/page.png diff --git a/tests/library/ref/pagebreak.png b/tests/ref/library/pagebreak.png Binary files differindex 16eae0e4..16eae0e4 100644 --- a/tests/library/ref/pagebreak.png +++ b/tests/ref/library/pagebreak.png diff --git a/tests/library/ref/rgb.png b/tests/ref/library/rgb.png Binary files differindex a6e6f7d4..a6e6f7d4 100644 --- a/tests/library/ref/rgb.png +++ b/tests/ref/library/rgb.png diff --git a/tests/lang/ref/emph.png b/tests/ref/markup/emph.png Binary files differindex a3aae726..a3aae726 100644 --- a/tests/lang/ref/emph.png +++ b/tests/ref/markup/emph.png diff --git a/tests/lang/ref/escape.png b/tests/ref/markup/escape.png Binary files differindex aafe09eb..aafe09eb 100644 --- a/tests/lang/ref/escape.png +++ b/tests/ref/markup/escape.png diff --git a/tests/lang/ref/heading.png b/tests/ref/markup/heading.png Binary files differindex f72806ec..f72806ec 100644 --- a/tests/lang/ref/heading.png +++ b/tests/ref/markup/heading.png diff --git a/tests/lang/ref/linebreak.png b/tests/ref/markup/linebreak.png Binary files differindex 4769e291..4769e291 100644 --- a/tests/lang/ref/linebreak.png +++ b/tests/ref/markup/linebreak.png diff --git a/tests/lang/ref/nbsp.png b/tests/ref/markup/nbsp.png Binary files differindex 537a70eb..537a70eb 100644 --- a/tests/lang/ref/nbsp.png +++ b/tests/ref/markup/nbsp.png diff --git a/tests/lang/ref/raw.png b/tests/ref/markup/raw.png Binary files differindex 6d90c960..6d90c960 100644 --- a/tests/lang/ref/raw.png +++ b/tests/ref/markup/raw.png diff --git a/tests/lang/ref/strong.png b/tests/ref/markup/strong.png Binary files differindex eb5e4d8e..eb5e4d8e 100644 --- a/tests/lang/ref/strong.png +++ b/tests/ref/markup/strong.png diff --git a/tests/lang/ref/repr.png b/tests/ref/repr.png Binary files differindex 13ba6297..13ba6297 100644 --- a/tests/lang/ref/repr.png +++ b/tests/ref/repr.png diff --git a/tests/lang/ref/spacing.png b/tests/ref/spacing.png Binary files differindex 5c3acf9b..5c3acf9b 100644 --- a/tests/lang/ref/spacing.png +++ b/tests/ref/spacing.png diff --git a/tests/lang/ref/text.png b/tests/ref/text.png Binary files differindex 88ce95e3..88ce95e3 100644 --- a/tests/lang/ref/text.png +++ b/tests/ref/text.png diff --git a/tests/lang/typ/comment.typ b/tests/typ/comment.typ index 25180211..25180211 100644 --- a/tests/lang/typ/comment.typ +++ b/tests/typ/comment.typ diff --git a/tests/lang/typ/for-invalid.typ b/tests/typ/control/for-invalid.typ index c8bdebdd..c8bdebdd 100644 --- a/tests/lang/typ/for-invalid.typ +++ b/tests/typ/control/for-invalid.typ diff --git a/tests/lang/typ/for-pattern.typ b/tests/typ/control/for-pattern.typ index 38253b33..38253b33 100644 --- a/tests/lang/typ/for-pattern.typ +++ b/tests/typ/control/for-pattern.typ diff --git a/tests/lang/typ/for-value.typ b/tests/typ/control/for-value.typ index 3ab80716..3ab80716 100644 --- a/tests/lang/typ/for-value.typ +++ b/tests/typ/control/for-value.typ diff --git a/tests/lang/typ/for.typ b/tests/typ/control/for.typ index 294345b5..294345b5 100644 --- a/tests/lang/typ/for.typ +++ b/tests/typ/control/for.typ diff --git a/tests/lang/typ/if-invalid.typ b/tests/typ/control/if-invalid.typ index 6d2deab1..6d2deab1 100644 --- a/tests/lang/typ/if-invalid.typ +++ b/tests/typ/control/if-invalid.typ diff --git a/tests/lang/typ/if-value.typ b/tests/typ/control/if-value.typ index d7124255..d7124255 100644 --- a/tests/lang/typ/if-value.typ +++ b/tests/typ/control/if-value.typ diff --git a/tests/lang/typ/if.typ b/tests/typ/control/if.typ index 4ed6b649..4ed6b649 100644 --- a/tests/lang/typ/if.typ +++ b/tests/typ/control/if.typ diff --git a/tests/lang/typ/let-invalid.typ b/tests/typ/control/let-invalid.typ index f29353ed..f29353ed 100644 --- a/tests/lang/typ/let-invalid.typ +++ b/tests/typ/control/let-invalid.typ diff --git a/tests/lang/typ/let-terminated.typ b/tests/typ/control/let-terminated.typ index 623265e0..623265e0 100644 --- a/tests/lang/typ/let-terminated.typ +++ b/tests/typ/control/let-terminated.typ diff --git a/tests/lang/typ/let.typ b/tests/typ/control/let.typ index e609d3a9..e609d3a9 100644 --- a/tests/lang/typ/let.typ +++ b/tests/typ/control/let.typ diff --git a/tests/lang/typ/empty.typ b/tests/typ/empty.typ index e69de29b..e69de29b 100644 --- a/tests/lang/typ/empty.typ +++ b/tests/typ/empty.typ diff --git a/tests/lang/typ/array.typ b/tests/typ/expr/array.typ index c9383501..c9383501 100644 --- a/tests/lang/typ/array.typ +++ b/tests/typ/expr/array.typ diff --git a/tests/lang/typ/expr-assoc.typ b/tests/typ/expr/assoc.typ index 19c56951..19c56951 100644 --- a/tests/lang/typ/expr-assoc.typ +++ b/tests/typ/expr/assoc.typ diff --git a/tests/lang/typ/block-invalid.typ b/tests/typ/expr/block-invalid.typ index d98bf06b..d98bf06b 100644 --- a/tests/lang/typ/block-invalid.typ +++ b/tests/typ/expr/block-invalid.typ diff --git a/tests/lang/typ/block-scoping.typ b/tests/typ/expr/block-scoping.typ index 7bb98969..7bb98969 100644 --- a/tests/lang/typ/block-scoping.typ +++ b/tests/typ/expr/block-scoping.typ diff --git a/tests/lang/typ/block.typ b/tests/typ/expr/block.typ index 196e6c14..196e6c14 100644 --- a/tests/lang/typ/block.typ +++ b/tests/typ/expr/block.typ diff --git a/tests/lang/typ/call-invalid.typ b/tests/typ/expr/call-invalid.typ index 0ed5246f..0ed5246f 100644 --- a/tests/lang/typ/call-invalid.typ +++ b/tests/typ/expr/call-invalid.typ diff --git a/tests/lang/typ/call.typ b/tests/typ/expr/call.typ index 213d5554..213d5554 100644 --- a/tests/lang/typ/call.typ +++ b/tests/typ/expr/call.typ diff --git a/tests/lang/typ/dict.typ b/tests/typ/expr/dict.typ index 655a3299..655a3299 100644 --- a/tests/lang/typ/dict.typ +++ b/tests/typ/expr/dict.typ diff --git a/tests/lang/typ/expr-invalid.typ b/tests/typ/expr/ops-invalid.typ index f760ae31..f760ae31 100644 --- a/tests/lang/typ/expr-invalid.typ +++ b/tests/typ/expr/ops-invalid.typ diff --git a/tests/lang/typ/expr-binary.typ b/tests/typ/expr/ops.typ index 9fbffe18..2390b7b4 100644 --- a/tests/lang/typ/expr-binary.typ +++ b/tests/typ/expr/ops.typ @@ -9,6 +9,21 @@ --- // Test math operators. +// Test plus and minus. +#for v in (1, 3.14, 12pt, 45deg, 90%, 13% + 10pt) { + // Test plus. + test(+v, v) + + // Test minus. + test(-v, -1 * v) + test(--v, v) + + // Test combination. + test(-++ --v, -v) +} + +#test(-(4 + 2), 6-12) + // Addition. #test(2 + 4, 6) #test("a" + "b", "ab") @@ -74,6 +89,10 @@ --- // Test boolean operators. +// Test not. +#test(not true, false) +#test(not false, true) + // And. #test(false and false, false) #test(false and true, false) diff --git a/tests/lang/typ/expr-prec.typ b/tests/typ/expr/prec.typ index e64e583c..e64e583c 100644 --- a/tests/lang/typ/expr-prec.typ +++ b/tests/typ/expr/prec.typ diff --git a/tests/full/typ/coma.typ b/tests/typ/full/coma.typ index 03f6dcc3..03f6dcc3 100644 --- a/tests/full/typ/coma.typ +++ b/tests/typ/full/coma.typ diff --git a/tests/library/typ/box.typ b/tests/typ/library/box.typ index 57763f12..57763f12 100644 --- a/tests/library/typ/box.typ +++ b/tests/typ/library/box.typ diff --git a/tests/library/typ/font.typ b/tests/typ/library/font.typ index 7f13e8a6..7f13e8a6 100644 --- a/tests/library/typ/font.typ +++ b/tests/typ/library/font.typ diff --git a/tests/library/typ/hv.typ b/tests/typ/library/hv.typ index 154445cf..154445cf 100644 --- a/tests/library/typ/hv.typ +++ b/tests/typ/library/hv.typ diff --git a/tests/library/typ/image.typ b/tests/typ/library/image.typ index 9c3cd4fe..9c3cd4fe 100644 --- a/tests/library/typ/image.typ +++ b/tests/typ/library/image.typ diff --git a/tests/library/typ/page.typ b/tests/typ/library/page.typ index b7ac0348..b7ac0348 100644 --- a/tests/library/typ/page.typ +++ b/tests/typ/library/page.typ diff --git a/tests/library/typ/pagebreak.typ b/tests/typ/library/pagebreak.typ index dc3e5682..dc3e5682 100644 --- a/tests/library/typ/pagebreak.typ +++ b/tests/typ/library/pagebreak.typ diff --git a/tests/library/typ/rgb.typ b/tests/typ/library/rgb.typ index b962bbc0..b962bbc0 100644 --- a/tests/library/typ/rgb.typ +++ b/tests/typ/library/rgb.typ diff --git a/tests/lang/typ/emph.typ b/tests/typ/markup/emph.typ index 772e15ab..772e15ab 100644 --- a/tests/lang/typ/emph.typ +++ b/tests/typ/markup/emph.typ diff --git a/tests/lang/typ/escape.typ b/tests/typ/markup/escape.typ index eeac4997..eeac4997 100644 --- a/tests/lang/typ/escape.typ +++ b/tests/typ/markup/escape.typ diff --git a/tests/lang/typ/heading.typ b/tests/typ/markup/heading.typ index 8497ec8f..8497ec8f 100644 --- a/tests/lang/typ/heading.typ +++ b/tests/typ/markup/heading.typ diff --git a/tests/lang/typ/linebreak.typ b/tests/typ/markup/linebreak.typ index e6392992..e6392992 100644 --- a/tests/lang/typ/linebreak.typ +++ b/tests/typ/markup/linebreak.typ diff --git a/tests/lang/typ/nbsp.typ b/tests/typ/markup/nbsp.typ index 5af6c84f..5af6c84f 100644 --- a/tests/lang/typ/nbsp.typ +++ b/tests/typ/markup/nbsp.typ diff --git a/tests/lang/typ/raw.typ b/tests/typ/markup/raw.typ index f5074c8e..f5074c8e 100644 --- a/tests/lang/typ/raw.typ +++ b/tests/typ/markup/raw.typ diff --git a/tests/lang/typ/strong.typ b/tests/typ/markup/strong.typ index b02a55a5..b02a55a5 100644 --- a/tests/lang/typ/strong.typ +++ b/tests/typ/markup/strong.typ diff --git a/tests/lang/typ/repr.typ b/tests/typ/repr.typ index 666db428..666db428 100644 --- a/tests/lang/typ/repr.typ +++ b/tests/typ/repr.typ diff --git a/tests/lang/typ/spacing.typ b/tests/typ/spacing.typ index d44cd84c..d44cd84c 100644 --- a/tests/lang/typ/spacing.typ +++ b/tests/typ/spacing.typ diff --git a/tests/lang/typ/text.typ b/tests/typ/text.typ index d86f4895..d86f4895 100644 --- a/tests/lang/typ/text.typ +++ b/tests/typ/text.typ diff --git a/tests/typeset.rs b/tests/typeset.rs index 3041499a..e1e55087 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -28,10 +28,10 @@ use typst::shaping::Shaped; use typst::syntax::{Location, Pos}; use typst::typeset; -const TYP_DIR: &str = "typ"; -const REF_DIR: &str = "ref"; -const PNG_DIR: &str = "png"; -const PDF_DIR: &str = "pdf"; +const TYP_DIR: &str = "./typ"; +const REF_DIR: &str = "./ref"; +const PNG_DIR: &str = "./png"; +const PDF_DIR: &str = "./pdf"; const FONT_DIR: &str = "../fonts"; fn main() { @@ -71,25 +71,13 @@ fn main() { resources: ResourceLoader::new(), }; - let playground = Path::new("playground.typ"); - if playground.exists() && filtered.is_empty() { - test( - playground, - Path::new("playground.png"), - Path::new("playground.pdf"), - None, - &mut env, - ); - } - let mut ok = true; for src_path in filtered { - 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); + let trailer = src_path.strip_prefix(TYP_DIR).unwrap(); + let png_path = Path::new(PNG_DIR).join(trailer).with_extension("png"); + let pdf_path = Path::new(PDF_DIR).join(trailer).with_extension("pdf"); + let ref_path = Path::new(REF_DIR).join(trailer).with_extension("png"); + ok &= test(&src_path, &png_path, &pdf_path, &ref_path, &mut env); } if !ok { @@ -131,7 +119,7 @@ fn test( src_path: &Path, png_path: &Path, pdf_path: &Path, - ref_path: Option<&Path>, + ref_path: &Path, env: &mut Env, ) -> bool { let name = src_path.strip_prefix(TYP_DIR).unwrap_or(src_path); @@ -176,16 +164,14 @@ fn test( fs::create_dir_all(&png_path.parent().unwrap()).unwrap(); canvas.pixmap.save_png(png_path).unwrap(); - if let Some(ref_path) = ref_path { - if let Ok(ref_pixmap) = Pixmap::load_png(ref_path) { - if canvas.pixmap != ref_pixmap { - println!(" Does not match reference image. ❌"); - ok = false; - } - } else { - println!(" Failed to open reference image. ❌"); + if let Ok(ref_pixmap) = Pixmap::load_png(ref_path) { + if canvas.pixmap != ref_pixmap { + println!(" Does not match reference image. ❌"); ok = false; } + } else { + println!(" Failed to open reference image. ❌"); + ok = false; } } |
