summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-03-21 17:46:09 +0100
committerLaurenz <laurmaedje@gmail.com>2021-03-21 17:50:56 +0100
commit5e08028fb36aa766957cba64c5c665edf9b96fb7 (patch)
tree912799dad3c1e25b7032f3e3bee009537c6f555b /tests
parent898728f260923a91444eb23b522d0abf01a4299b (diff)
Syntax functions 🚀
This adds overridable functions that markup desugars into. Specifically: - \ desugars into linebreak - Two newlines desugar into parbreak - * desugars into strong - _ desugars into emph - = .. desugars into heading - `..` desugars into raw
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/markup/emph.pngbin3053 -> 3387 bytes
-rw-r--r--tests/ref/markup/heading.pngbin4540 -> 5288 bytes
-rw-r--r--tests/ref/markup/linebreak.pngbin3770 -> 4307 bytes
-rw-r--r--tests/ref/markup/parbreak.pngbin0 -> 1654 bytes
-rw-r--r--tests/ref/markup/raw.pngbin7291 -> 8299 bytes
-rw-r--r--tests/ref/markup/strong.pngbin2824 -> 3374 bytes
-rw-r--r--tests/typ/expr/ops.typ3
-rw-r--r--tests/typ/library/paragraph.typ4
-rw-r--r--tests/typ/markup/emph.typ13
-rw-r--r--tests/typ/markup/heading.typ8
-rw-r--r--tests/typ/markup/linebreak.typ8
-rw-r--r--tests/typ/markup/parbreak.typ11
-rw-r--r--tests/typ/markup/raw.typ8
-rw-r--r--tests/typ/markup/strong.typ12
-rw-r--r--tests/typeset.rs2
15 files changed, 59 insertions, 10 deletions
diff --git a/tests/ref/markup/emph.png b/tests/ref/markup/emph.png
index 75231a62..f43eeecb 100644
--- a/tests/ref/markup/emph.png
+++ b/tests/ref/markup/emph.png
Binary files differ
diff --git a/tests/ref/markup/heading.png b/tests/ref/markup/heading.png
index 3473f798..515788f3 100644
--- a/tests/ref/markup/heading.png
+++ b/tests/ref/markup/heading.png
Binary files differ
diff --git a/tests/ref/markup/linebreak.png b/tests/ref/markup/linebreak.png
index 4e4702f9..aa01c99a 100644
--- a/tests/ref/markup/linebreak.png
+++ b/tests/ref/markup/linebreak.png
Binary files differ
diff --git a/tests/ref/markup/parbreak.png b/tests/ref/markup/parbreak.png
new file mode 100644
index 00000000..008afca2
--- /dev/null
+++ b/tests/ref/markup/parbreak.png
Binary files differ
diff --git a/tests/ref/markup/raw.png b/tests/ref/markup/raw.png
index 59a4e3dd..1aebc02d 100644
--- a/tests/ref/markup/raw.png
+++ b/tests/ref/markup/raw.png
Binary files differ
diff --git a/tests/ref/markup/strong.png b/tests/ref/markup/strong.png
index 7e62f0f3..20e29b1f 100644
--- a/tests/ref/markup/strong.png
+++ b/tests/ref/markup/strong.png
Binary files differ
diff --git a/tests/typ/expr/ops.typ b/tests/typ/expr/ops.typ
index 2390b7b4..ef249c43 100644
--- a/tests/typ/expr/ops.typ
+++ b/tests/typ/expr/ops.typ
@@ -122,10 +122,7 @@
#test((1, 2, 3) == (1, 2.0) + (3,), true)
#test((:) == (a: 1), false)
#test((a: 2 - 1.0, b: 2) == (b: 2, a: 1), true)
-#test([*Hi*] == [*Hi*], true)
-
#test("a" != "a", false)
-#test([*] != [_], true)
---
// Test comparison operators.
diff --git a/tests/typ/library/paragraph.typ b/tests/typ/library/paragraph.typ
index 3ce946bd..74fb8189 100644
--- a/tests/typ/library/paragraph.typ
+++ b/tests/typ/library/paragraph.typ
@@ -3,11 +3,11 @@
---
// Test configuring paragraph properties.
-#paragraph(spacing: 10pt, leading: 25%, word-spacing: 1pt)
+#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 #paragraph(word-spacing: 0pt) t h e r e !
+Hello #par(word-spacing: 0pt) t h e r e !
diff --git a/tests/typ/markup/emph.typ b/tests/typ/markup/emph.typ
index 500381c1..8e25e7d3 100644
--- a/tests/typ/markup/emph.typ
+++ b/tests/typ/markup/emph.typ
@@ -10,5 +10,14 @@ Partly em_phas_ized.
// Scoped to body.
#rect[_Scoped] to body.
-// Unterminated is fine.
-_The End
+---
+#let emph = strong
+_Strong_
+
+#let emph() = "Hi"
+_, _!
+
+#let emph = "hi"
+
+// Error: 1-2 expected function, found string
+_
diff --git a/tests/typ/markup/heading.typ b/tests/typ/markup/heading.typ
index 15c391d1..9bbe3415 100644
--- a/tests/typ/markup/heading.typ
+++ b/tests/typ/markup/heading.typ
@@ -42,3 +42,11 @@ No = heading
// Escaped.
\= No heading
+
+---
+// Make small, but double heading.
+#let heading(contents) = heading(contents + contents, level: 6)
+
+// The new heading's argument list doesn't contain `level`.
+// Error: 1-11 unexpected argument
+=== Twice.
diff --git a/tests/typ/markup/linebreak.typ b/tests/typ/markup/linebreak.typ
index e6392992..a0a501b6 100644
--- a/tests/typ/markup/linebreak.typ
+++ b/tests/typ/markup/linebreak.typ
@@ -21,3 +21,11 @@ Trailing 2
// Trailing before end of document.
Trailing 3 \
+
+---
+#let linebreak() = [
+ // Inside the old line break definition is still active.
+ #circle(radius: 2pt, fill: #000) \
+]
+
+A \ B \ C \
diff --git a/tests/typ/markup/parbreak.typ b/tests/typ/markup/parbreak.typ
new file mode 100644
index 00000000..b9b8a222
--- /dev/null
+++ b/tests/typ/markup/parbreak.typ
@@ -0,0 +1,11 @@
+// Test paragraph breaks.
+
+---
+// Paragraph breaks don't exist!
+#let parbreak() = [ ]
+
+No more
+
+paragraph breaks
+
+for you!
diff --git a/tests/typ/markup/raw.typ b/tests/typ/markup/raw.typ
index 005d413e..cae3d261 100644
--- a/tests/typ/markup/raw.typ
+++ b/tests/typ/markup/raw.typ
@@ -46,6 +46,14 @@ def hi():
```
---
+// Make everything block-level.
+#let raw(text) = raw(text, block: true)
+
+// The new raw's argument list doesn't contain `block`.
+// Error: 6-10 unexpected argument
+This `is` block-level.
+
+---
// Unterminated.
// Error: 2:1 expected backtick(s)
`endless
diff --git a/tests/typ/markup/strong.typ b/tests/typ/markup/strong.typ
index a56e0e1c..6a6fc04a 100644
--- a/tests/typ/markup/strong.typ
+++ b/tests/typ/markup/strong.typ
@@ -10,5 +10,13 @@ Partly str*ength*ened.
// Scoped to body.
#rect[*Scoped] to body.
-// Unterminated is fine.
-*The End
+---
+#let strong = emph
+*Emph*
+
+#let strong() = "Bye"
+*, *!
+
+#let strong = 123
+// Error: 1-2 expected function, found integer
+*
diff --git a/tests/typeset.rs b/tests/typeset.rs
index 2cf6bfb6..0a22c96b 100644
--- a/tests/typeset.rs
+++ b/tests/typeset.rs
@@ -209,7 +209,7 @@ fn test_part(
let (local_compare_ref, ref_diags) = parse_metadata(src, &map);
let compare_ref = local_compare_ref.unwrap_or(compare_ref);
- let mut scope = library::new();
+ let mut scope = library::_new();
let panics = Rc::new(RefCell::new(vec![]));
register_helpers(&mut scope, Rc::clone(&panics));