summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-02-17 21:30:20 +0100
committerLaurenz <laurmaedje@gmail.com>2021-02-17 21:30:20 +0100
commit2f4dc99cec1c6fa33257dea91ab3bcd99b1cbdf5 (patch)
treeeb983e54bac5ae226474bd8c5d6a29006b00ff12
parentdb1659a987cd240b78e45666617248d3d0cc7d64 (diff)
Refresh tests 🌊
-rw-r--r--tests/full/typ/coma.typ16
-rw-r--r--tests/lang/ref/call-bracket.pngbin12516 -> 0 bytes
-rw-r--r--tests/lang/typ/array.typ6
-rw-r--r--tests/lang/typ/block-invalid.typ18
-rw-r--r--tests/lang/typ/block-scoping.typ14
-rw-r--r--tests/lang/typ/block-value.typ16
-rw-r--r--tests/lang/typ/call-args.typ28
-rw-r--r--tests/lang/typ/call-bracket.typ48
-rw-r--r--tests/lang/typ/call-invalid.typ36
-rw-r--r--tests/lang/typ/call-paren.typ11
-rw-r--r--tests/lang/typ/call-value.typ14
-rw-r--r--tests/lang/typ/comment.typ4
-rw-r--r--tests/lang/typ/dict.typ2
-rw-r--r--tests/lang/typ/escape.typ2
-rw-r--r--tests/lang/typ/expr-assoc.typ10
-rw-r--r--tests/lang/typ/expr-binary.typ110
-rw-r--r--tests/lang/typ/expr-invalid.typ12
-rw-r--r--tests/lang/typ/expr-prec.typ16
-rw-r--r--tests/lang/typ/expr-unary.typ8
-rw-r--r--tests/lang/typ/for-invalid.typ29
-rw-r--r--tests/lang/typ/for-loop.typ33
-rw-r--r--tests/lang/typ/for-pattern.typ10
-rw-r--r--tests/lang/typ/for-value.typ14
-rw-r--r--tests/lang/typ/heading.typ6
-rw-r--r--tests/lang/typ/if-branch.typ2
-rw-r--r--tests/lang/typ/if-invalid.typ14
-rw-r--r--tests/lang/typ/if-value.typ12
-rw-r--r--tests/lang/typ/let-invalid.typ6
-rw-r--r--tests/lang/typ/let-terminated.typ16
-rw-r--r--tests/lang/typ/let-value.typ4
-rw-r--r--tests/lang/typ/raw.typ2
-rw-r--r--tests/lang/typ/spacing.typ14
-rw-r--r--tests/lang/typ/strong.typ2
-rw-r--r--tests/library/typ/box.typ16
-rw-r--r--tests/library/typ/font.typ46
-rw-r--r--tests/library/typ/hv.typ18
-rw-r--r--tests/library/typ/image.typ26
-rw-r--r--tests/library/typ/page.typ52
-rw-r--r--tests/library/typ/pagebreak.typ4
-rw-r--r--tests/library/typ/rgb.typ16
-rw-r--r--tests/typeset.rs4
41 files changed, 328 insertions, 389 deletions
diff --git a/tests/full/typ/coma.typ b/tests/full/typ/coma.typ
index 32990997..7cf62da7 100644
--- a/tests/full/typ/coma.typ
+++ b/tests/full/typ/coma.typ
@@ -1,23 +1,23 @@
-#[page width: 450pt, height: 300pt, margins: 1cm]
+#page(width: 450pt, height: 300pt, margins: 1cm)
-#[box][
+#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]
+#align(right, box[*WiSe 2019/2020* \ Woche 3])
-#[v 6mm]
+#v(6mm)
-#[align center][
- ==== 3. Übungsblatt Computerorientierte Mathematik II #[v 2mm]
- *Abgabe: 03.05.2019* (bis 10:10 Uhr in MA 001) #[v 2mm]
+#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)]
+*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
diff --git a/tests/lang/ref/call-bracket.png b/tests/lang/ref/call-bracket.png
deleted file mode 100644
index b5b2f767..00000000
--- a/tests/lang/ref/call-bracket.png
+++ /dev/null
Binary files differ
diff --git a/tests/lang/typ/array.typ b/tests/lang/typ/array.typ
index f80cc0cd..b17b722c 100644
--- a/tests/lang/typ/array.typ
+++ b/tests/lang/typ/array.typ
@@ -19,13 +19,13 @@
, #003
,)}
-// Error: 3-3 expected closing paren
+// Error: 3 expected closing paren
{(}
// Error: 2-3 expected expression, found closing paren
{)}
-// Error: 2:4-2:4 expected comma
+// Error: 2:4 expected comma
// Error: 1:4-1:6 expected expression, found end of block comment
{(1*/2)}
@@ -36,7 +36,7 @@
{(,1)}
// Missing expression makes named pair incomplete, making this an empty array.
-// Error: 5-5 expected expression
+// Error: 5 expected expression
{(a:)}
// Named pair after this is already identified as an array.
diff --git a/tests/lang/typ/block-invalid.typ b/tests/lang/typ/block-invalid.typ
index cf51b91b..28874861 100644
--- a/tests/lang/typ/block-invalid.typ
+++ b/tests/lang/typ/block-invalid.typ
@@ -7,28 +7,28 @@
{1u}
// Should output `1`.
-// Error: 3-3 expected semicolon or line break
+// Error: 3 expected semicolon or line break
{0 1}
// Should output `2`.
-// Error: 2:13-2:13 expected semicolon or line break
-// Error: 1:24-1:24 expected semicolon or line break
-{#let x = -1 #let y = 3 x + y}
+// Error: 2:12 expected semicolon or line break
+// Error: 1:22 expected semicolon or line break
+{let x = -1 let y = 3 x + y}
// Should output `3`.
{
- // Error: 10-13 expected identifier, found string
- #for "v"
+ // Error: 9-12 expected identifier, found string
+ for "v"
- // Error: 11-11 expected keyword `#in`
- #for v #let z = 1 + 2
+ // Error: 10 expected keyword `#in`
+ for v let z = 1 + 2
z
}
---
// Ref: false
-// Error: 3:1-3:1 expected closing brace
+// Error: 3:1 expected closing brace
{
---
diff --git a/tests/lang/typ/block-scoping.typ b/tests/lang/typ/block-scoping.typ
index bd1f5867..7bb98969 100644
--- a/tests/lang/typ/block-scoping.typ
+++ b/tests/lang/typ/block-scoping.typ
@@ -3,17 +3,17 @@
---
// Block in template does not create a scope.
-{ #let x = 1 }
-#[test x, 1]
+{ let x = 1 }
+#test(x, 1)
---
// Block in expression does create a scope.
#let a = {
- #let b = 1
+ let b = 1
b
}
-#[test a, 1]
+#test(a, 1)
// Error: 2-3 unknown variable
{b}
@@ -21,12 +21,12 @@
---
// Multiple nested scopes.
{
- #let a = "a1"
+ let a = "a1"
{
- #let a = "a2"
+ let a = "a2"
{
test(a, "a2")
- #let a = "a3"
+ let a = "a3"
test(a, "a3")
}
test(a, "a2")
diff --git a/tests/lang/typ/block-value.typ b/tests/lang/typ/block-value.typ
index 62934ce6..4a075c03 100644
--- a/tests/lang/typ/block-value.typ
+++ b/tests/lang/typ/block-value.typ
@@ -7,7 +7,7 @@ All none
{}
// Let evaluates to none.
-{ #let v = 0 }
+{ let v = 0 }
// Trailing none evaluates to none.
{
@@ -20,19 +20,19 @@ All none
{ "Hello" }
// Evaluates to trailing expression.
-{ #let x = "Hel"; x + "lo" }
+{ let x = "Hel"; x + "lo" }
// Evaluates to concatenation of for loop bodies.
{
- #let parts = ("Hel", "lo")
- #for s #in parts [{s}]
+ let parts = ("Hel", "lo")
+ for s in parts [{s}]
}
---
// Works the same way in code environment.
// Ref: false
-#[test {
- #let x = 1
- #let y = 2
+#test(3, {
+ let x = 1
+ let y = 2
x + y
-}, 3]
+})
diff --git a/tests/lang/typ/call-args.typ b/tests/lang/typ/call-args.typ
index cf79c1f0..53ae0b97 100644
--- a/tests/lang/typ/call-args.typ
+++ b/tests/lang/typ/call-args.typ
@@ -2,33 +2,33 @@
---
// One argument.
-#[f bold]
+#f(bold)
// One argument and trailing comma.
-#[f 1,]
+#f(1,)
// One named argument.
-#[f a:2]
+#f(a:2)
// Mixed arguments.
{f(1, a: (3, 4), 2, b: "5")}
---
-// Error: 5-6 expected expression, found colon
-#[f :]
+// Error: 4-5 expected expression, found colon
+#f(:)
-// Error: 8-10 expected expression, found end of block comment
-#[f a:1*/]
+// Error: 7-9 expected expression, found end of block comment
+#f(a:1*/)
-// Error: 6-6 expected comma
-#[f 1 2]
+// Error: 5 expected comma
+#f(1 2)
-// Error: 2:5-2:6 expected identifier
-// Error: 1:7-1:7 expected expression
-#[f 1:]
+// Error: 2:4-2:5 expected identifier
+// Error: 1:6 expected expression
+#f(1:)
-// Error: 5-6 expected identifier
-#[f 1:2]
+// Error: 4-5 expected identifier
+#f(1:2)
// Error: 4-7 expected identifier
{f((x):1)}
diff --git a/tests/lang/typ/call-bracket.typ b/tests/lang/typ/call-bracket.typ
deleted file mode 100644
index eb097094..00000000
--- a/tests/lang/typ/call-bracket.typ
+++ /dev/null
@@ -1,48 +0,0 @@
-// Test bracketed function calls.
-
----
-// Whitespace is insignificant.
-#[ f ]
-
-// Alternatives for embedding.
-#[f f()], #[f #[f]], #[f][#[f]],
-
-// Tight functions.
-#[f]#[f]
-
-// Multi-paragraph body.
-#[align right][
- First
-
- Second
-]
-
----
-// Chained once.
-#[f | f]
-
-// Chained twice.
-#[f|f|f]
-
-// With body.
-// Error: 7-8 expected identifier, found integer
-#[f | 1 | box][💕]
-
-// With actual functions.
-#[box width: 1cm | image "res/rhino.png"]
-
----
-// Error: 8-8 expected identifier
-#[f 1 |]
-
-// Error: 4-4 expected identifier
-#[ | f true]
-
-// Error: 2:3-2:3 expected identifier
-// Error: 1:4-1:4 expected identifier
-#[|][Nope]
-
-// Pipe wins over parens.
-// Error: 2:6-2:6 expected closing paren
-// Error: 1:9-1:10 expected expression, found closing paren
-#[f (|f )]
diff --git a/tests/lang/typ/call-invalid.typ b/tests/lang/typ/call-invalid.typ
index 8e3efa32..a04f5959 100644
--- a/tests/lang/typ/call-invalid.typ
+++ b/tests/lang/typ/call-invalid.typ
@@ -1,36 +1,24 @@
// Test invalid function calls.
---
-// Error: 4-4 expected closing paren
-{f(}
-
----
-// Error: 4:1-4:1 expected identifier
-// Error: 3:1-3:1 expected closing bracket
-#[
+// Error: 1-2 unexpected invalid token
+#
---
-// Error: 3-3 expected identifier
-#[]
-
-// Error: 3-6 expected identifier, found string
-#["f"]
+#let x = "string"
-// Error: 2:3-2:4 expected identifier, found opening paren
-// Error: 1:5-1:6 expected expression, found closing paren
-#[(f)]
+// Error: 2-3 expected function, found string
+#x()
---
-#let x = "string"
-
-// Error: 3-4 expected function, found string
-#[x]
+// Error: 3:1 expected closing bracket
+#f[`a]`
---
-// Error: 3:1-3:1 expected closing bracket
-#[f][`a]`
+// Error: 4 expected closing paren
+{f(}
---
-// Error: 3:1-3:1 expected quote
-// Error: 2:1-2:1 expected closing bracket
-#[f "]
+// Error: 3:1 expected quote
+// Error: 2:1 expected closing bracket
+#f("]
diff --git a/tests/lang/typ/call-paren.typ b/tests/lang/typ/call-paren.typ
deleted file mode 100644
index 482e20e8..00000000
--- a/tests/lang/typ/call-paren.typ
+++ /dev/null
@@ -1,11 +0,0 @@
-// Test parenthesized function calls.
-// Ref: false
-
----
-// Whitespace insignificant.
-#[test type(1), "integer"]
-#[test type (1), "integer"]
-
-// From variable.
-#let alias = type
-#[test alias(alias), "function"]
diff --git a/tests/lang/typ/call-value.typ b/tests/lang/typ/call-value.typ
new file mode 100644
index 00000000..0e257717
--- /dev/null
+++ b/tests/lang/typ/call-value.typ
@@ -0,0 +1,14 @@
+// Test function calls.
+// Ref: false
+
+---
+// Whitespace is insignificant.
+#test(type(1), "integer")
+#test (type (1), "integer")
+
+// From variable.
+#let alias = type
+#test(alias(alias), "function")
+
+// Returns template.
+#test(type(font(12pt)), "template")
diff --git a/tests/lang/typ/comment.typ b/tests/lang/typ/comment.typ
index 8b394f1f..e5892453 100644
--- a/tests/lang/typ/comment.typ
+++ b/tests/lang/typ/comment.typ
@@ -11,8 +11,8 @@ C/*
*/D
// Works in code.
-#[test type /*1*/ (1) //
-, "integer"]
+#test(type /*1*/ (1) //
+, "integer")
---
// End should not appear without start.
diff --git a/tests/lang/typ/dict.typ b/tests/lang/typ/dict.typ
index b12dbd59..076a572f 100644
--- a/tests/lang/typ/dict.typ
+++ b/tests/lang/typ/dict.typ
@@ -14,7 +14,7 @@
// Identified as dictionary due to initial colon.
// Error: 4:4-4:5 expected named pair, found expression
-// Error: 3:5-3:5 expected comma
+// Error: 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/escape.typ b/tests/lang/typ/escape.typ
index 3c0f02f3..eeac4997 100644
--- a/tests/lang/typ/escape.typ
+++ b/tests/lang/typ/escape.typ
@@ -26,5 +26,5 @@
\u{FFFFFF}
// Unterminated.
-// Error: 6-6 expected closing brace
+// Error: 6 expected closing brace
\u{41*Bold*
diff --git a/tests/lang/typ/expr-assoc.typ b/tests/lang/typ/expr-assoc.typ
index 64db98c6..19c56951 100644
--- a/tests/lang/typ/expr-assoc.typ
+++ b/tests/lang/typ/expr-assoc.typ
@@ -3,15 +3,15 @@
---
// Math operators are left-associative.
-#[test 10 / 2 / 2 == (10 / 2) / 2, true]
-#[test 10 / 2 / 2 == 10 / (2 / 2), false]
-#[test 1 / 2 * 3, 1.5]
+#test(10 / 2 / 2 == (10 / 2) / 2, true)
+#test(10 / 2 / 2 == 10 / (2 / 2), false)
+#test(1 / 2 * 3, 1.5)
---
// Assignment is right-associative.
{
- #let x = 1
- #let y = 2
+ let x = 1
+ let y = 2
x = y = "ok"
test(x, none)
test(y, "ok")
diff --git a/tests/lang/typ/expr-binary.typ b/tests/lang/typ/expr-binary.typ
index e84cb282..9fbffe18 100644
--- a/tests/lang/typ/expr-binary.typ
+++ b/tests/lang/typ/expr-binary.typ
@@ -10,30 +10,30 @@
// Test math operators.
// Addition.
-#[test 2 + 4, 6]
-#[test "a" + "b", "ab"]
-#[test (1, 2) + (3, 4), (1, 2, 3, 4)]
-#[test (a: 1) + (b: 2, c: 3), (a: 1, b: 2, c: 3)]
+#test(2 + 4, 6)
+#test("a" + "b", "ab")
+#test((1, 2) + (3, 4), (1, 2, 3, 4))
+#test((a: 1) + (b: 2, c: 3), (a: 1, b: 2, c: 3))
// Subtraction.
-#[test 1-4, 3*-1]
-#[test 4cm - 2cm, 2cm]
-#[test 1e+2-1e-2, 99.99]
+#test(1-4, 3*-1)
+#test(4cm - 2cm, 2cm)
+#test(1e+2-1e-2, 99.99)
// Multiplication.
-#[test 2 * 4, 8]
+#test(2 * 4, 8)
// Division.
-#[test 12pt/.4, 30pt]
-#[test 7 / 2, 3.5]
+#test(12pt/.4, 30pt)
+#test(7 / 2, 3.5)
// Combination.
-#[test 3-4 * 5 < -10, true]
-#[test { #let x; x = 1 + 4*5 >= 21 and { x = "a"; x + "b" == "ab" }; x }, true]
+#test(3-4 * 5 < -10, true)
+#test({ let x; x = 1 + 4*5 >= 21 and { x = "a"; x + "b" == "ab" }; x }, true)
// Mathematical identities.
#let nums = (1, 3.14, 12pt, 45deg, 90%, 13% + 10pt)
-#for v #in nums {
+#for v in nums {
// Test plus and minus.
test(v + v - v, v)
test(v - v - v, -v)
@@ -43,12 +43,12 @@
test(v + v, 2 * v)
// Integer addition does not give a float.
- #if type(v) != "integer" {
+ if type(v) != "integer" {
test(v + v, 2.0 * v)
}
// Linears cannot be divided by themselves.
- #if type(v) != "linear" {
+ if type(v) != "linear" {
test(v / v, 1.0)
test(v / v == 1, true)
}
@@ -59,12 +59,12 @@
// - multiplied with integers and floats,
// - divided by floats.
#let dims = (10pt, 30%, 50% + 3cm)
-#for a #in dims {
- #for b #in dims {
+#for a in dims {
+ for b in dims {
test(type(a + b), type(a - b))
}
- #for b #in (7, 3.14) {
+ for b in (7, 3.14) {
test(type(a * b), type(a))
test(type(b * a), type(a))
test(type(a / b), type(a))
@@ -75,57 +75,57 @@
// Test boolean operators.
// And.
-#[test false and false, false]
-#[test false and true, false]
-#[test true and false, false]
-#[test true and true, true]
+#test(false and false, false)
+#test(false and true, false)
+#test(true and false, false)
+#test(true and true, true)
// Or.
-#[test false or false, false]
-#[test false or true, true]
-#[test true or false, true]
-#[test true or true, true]
+#test(false or false, false)
+#test(false or true, true)
+#test(true or false, true)
+#test(true or true, true)
// Short-circuiting.
-#[test false and dont-care, false]
-#[test true or dont-care, true]
+#test(false and dont-care, false)
+#test(true or dont-care, true)
---
// Test equality operators.
-#[test 1 == "hi", false]
-#[test 1 == 1.0, true]
-#[test 30% == 30% + 0cm, true]
-#[test 1in == 0% + 72pt, true]
-#[test 30% == 30% + 1cm, false]
-#[test "ab" == "a" + "b", true]
-#[test () == (1,), false]
-#[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(1 == "hi", false)
+#test(1 == 1.0, true)
+#test(30% == 30% + 0cm, true)
+#test(1in == 0% + 72pt, true)
+#test(30% == 30% + 1cm, false)
+#test("ab" == "a" + "b", true)
+#test(() == (1,), false)
+#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.
-#[test 13 * 3 < 14 * 4, true]
-#[test 5 < 10, true]
-#[test 5 > 5, false]
-#[test 5 <= 5, true]
-#[test 5 <= 4, false]
-#[test 45deg < 1rad, true]
+#test(13 * 3 < 14 * 4, true)
+#test(5 < 10, true)
+#test(5 > 5, false)
+#test(5 <= 5, true)
+#test(5 <= 4, false)
+#test(45deg < 1rad, true)
---
// Test assignment operators.
#let x = 0
-{ x = 10 } #[test x, 10]
-{ x -= 5 } #[test x, 5]
-{ x += 1 } #[test x, 6]
-{ x *= x } #[test x, 36]
-{ x /= 2.0 } #[test x, 18.0]
-{ x = "some" } #[test x, "some"]
-{ x += "thing" } #[test x, "something"]
+{ x = 10 } #test(x, 10)
+{ x -= 5 } #test(x, 5)
+{ x += 1 } #test(x, 6)
+{ x *= x } #test(x, 36)
+{ x /= 2.0 } #test(x, 18.0)
+{ x = "some" } #test(x, "some")
+{ x += "thing" } #test(x, "something")
diff --git a/tests/lang/typ/expr-invalid.typ b/tests/lang/typ/expr-invalid.typ
index 2d16034b..329a2616 100644
--- a/tests/lang/typ/expr-invalid.typ
+++ b/tests/lang/typ/expr-invalid.typ
@@ -4,14 +4,14 @@
---
// Missing expressions.
-// Error: 3-3 expected expression
+// Error: 3 expected expression
{-}
-// Error: 11-11 expected expression
-#[test {1+}, 1]
+// Error: 10 expected expression
+#test({1+}, 1)
-// Error: 11-11 expected expression
-#[test {2*}, 2]
+// Error: 10 expected expression
+#test({2*}, 2)
---
// Mismatched types.
@@ -36,7 +36,7 @@
{(1 + "2", 40% - 1, 2 * true, 3 / 12pt)}
// Error: 15-23 cannot apply '+=' to integer and string
-{ #let x = 1; x += "2" }
+{ let x = 1; x += "2" }
---
// Bad left-hand sides of assignment.
diff --git a/tests/lang/typ/expr-prec.typ b/tests/lang/typ/expr-prec.typ
index fea5f794..738e8fdf 100644
--- a/tests/lang/typ/expr-prec.typ
+++ b/tests/lang/typ/expr-prec.typ
@@ -3,14 +3,14 @@
---
// Multiplication binds stronger than addition.
-#[test 1+2*-3, -5]
+#test(1+2*-3, -5)
// Subtraction binds stronger than comparison.
-#[test 3 == 5 - 2, true]
+#test(3 == 5 - 2, true)
// Boolean operations bind stronger than '=='.
-#[test "a" == "a" and 2 < 3, true]
-#[test not "b" == "b", false]
+#test("a" == "a" and 2 < 3, true)
+#test(not "b" == "b", false)
// Assignment binds stronger than boolean operations.
// Error: 2-7 cannot assign to this expression
@@ -18,11 +18,11 @@
---
// Parentheses override precedence.
-#[test (1), 1]
-#[test (1+2)*-3, -9]
+#test((1), 1)
+#test((1+2)*-3, -9)
-// Error: 15-15 expected closing paren
-#[test {(1 + 1}, 2]
+// Error: 15 expected closing paren
+#test({(1 + 1}, 2)
---
// Precedence doesn't matter for chained unary operators.
diff --git a/tests/lang/typ/expr-unary.typ b/tests/lang/typ/expr-unary.typ
index a1d97a49..c4b1937d 100644
--- a/tests/lang/typ/expr-unary.typ
+++ b/tests/lang/typ/expr-unary.typ
@@ -3,7 +3,7 @@
---
// Test plus and minus.
-#for v #in (1, 3.14, 12pt, 45deg, 90%, 13% + 10pt) {
+#for v in (1, 3.14, 12pt, 45deg, 90%, 13% + 10pt) {
// Test plus.
test(+v, v)
@@ -15,9 +15,9 @@
test(-++ --v, -v)
}
-#[test -(4 + 2), 6-12]
+#test(-(4 + 2), 6-12)
---
// Test not.
-#[test not true, false]
-#[test not false, true]
+#test(not true, false)
+#test(not false, true)
diff --git a/tests/lang/typ/for-invalid.typ b/tests/lang/typ/for-invalid.typ
index ca83649a..3866909f 100644
--- a/tests/lang/typ/for-invalid.typ
+++ b/tests/lang/typ/for-invalid.typ
@@ -7,29 +7,26 @@
// Error: 7-7 expected keyword `#in`
#for v
-// Error: 11-11 expected expression
-#for v #in
+// Error: 10-10 expected expression
+#for v in
-// Error: 16-16 expected body
-#for v #in iter
+// Error: 15-15 expected body
+#for v in iter
---
-// Should output `v iter`.
-// Error: 2:5-2:5 expected identifier
-// Error: 2:3-2:6 unexpected keyword `#in`
+// Should output `v in iter`.
+// Error: 5 expected identifier
#for
-v #in iter {}
+v in iter {}
// Should output `A thing`.
// Error: 7-10 expected identifier, found string
A#for "v" thing.
-// Should output `iter`.
-// Error: 2:6-2:9 expected identifier, found string
-// Error: 1:10-1:13 unexpected keyword `#in`
-#for "v" #in iter {}
+// Should output `in iter`.
+// Error: 6-9 expected identifier, found string
+#for "v" in iter {}
-// Should output `+ b iter`.
-// Error: 2:7-2:7 expected keyword `#in`
-// Error: 1:12-1:15 unexpected keyword `#in`
-#for a + b #in iter {}
+// Should output `+ b in iter`.
+// Error: 7 expected keyword `#in`
+#for a + b in iter {}
diff --git a/tests/lang/typ/for-loop.typ b/tests/lang/typ/for-loop.typ
index 2af7ab04..e38ed190 100644
--- a/tests/lang/typ/for-loop.typ
+++ b/tests/lang/typ/for-loop.typ
@@ -4,28 +4,29 @@
---
// Array.
-#for x #in () {}
+#for x in () {}
#let sum = 0
-#for x #in (1, 2, 3, 4, 5) {
+#for x in (1, 2, 3, 4, 5) {
sum += x
}
-#[test sum, 15]
+
+#test(sum, 15)
---
// Dictionary.
// Ref: true
-(\ #for k, v #in (name: "Typst", age: 2) [
- #[h 0.5cm] {k}: {v}, \
+(\ #for k, v in (name: "Typst", age: 2) [
+ #h(0.5cm) {k}: {v}, \
])
---
// String.
{
- #let out = ""
- #let first = true
- #for c #in "abc" {
- #if not first {
+ let out = ""
+ let first = true
+ for c in "abc" {
+ if not first {
out += ", "
}
first = false
@@ -36,16 +37,16 @@
---
// Uniterable expression.
-// Error: 12-16 cannot loop over boolean
-#for v #in true {}
+// Error: 11-15 cannot loop over boolean
+#for v in true {}
// Make sure that we don't complain twice.
-// Error: 12-19 cannot add integer and string
-#for v #in 1 + "2" {}
+// Error: 11-18 cannot add integer and string
+#for v in 1 + "2" {}
// Error: 14-17 cannot apply '-' to string
#let error = -""
-#let result = #for v #in (1, 2, 3) {
- #if v < 2 [Ok] #else {error}
+#let result = for v in (1, 2, 3) {
+ if v < 2 [Ok] else {error}
}
-#[test result, error]
+#test(result, error)
diff --git a/tests/lang/typ/for-pattern.typ b/tests/lang/typ/for-pattern.typ
index 87bf603f..38253b33 100644
--- a/tests/lang/typ/for-pattern.typ
+++ b/tests/lang/typ/for-pattern.typ
@@ -5,26 +5,26 @@
#let out = ()
// Values of array.
-#for v #in (1, 2, 3) {
+#for v in (1, 2, 3) {
out += (v,)
}
// Values of dictionary.
-#for v #in (a: 4, b: 5) {
+#for v in (a: 4, b: 5) {
out += (v,)
}
// Keys and values of dictionary.
-#for k, v #in (a: 6, b: 7) {
+#for k, v in (a: 6, b: 7) {
out += (k,)
out += (v,)
}
-#[test out, (1, 2, 3, 4, 5, "a", 6, "b", 7)]
+#test(out, (1, 2, 3, 4, 5, "a", 6, "b", 7))
---
// Keys and values of array.
// Error: 6-10 mismatched pattern
-#for k, v #in (-1, -2, -3) {
+#for k, v in (-1, -2, -3) {
dont-care
}
diff --git a/tests/lang/typ/for-value.typ b/tests/lang/typ/for-value.typ
index 1813787d..3ab80716 100644
--- a/tests/lang/typ/for-value.typ
+++ b/tests/lang/typ/for-value.typ
@@ -3,18 +3,18 @@
---
// Template body yields template.
// Should output `234`.
-#for v #in (1, 2, 3, 4) [#if v >= 2 [{v}]]
+#for v in (1, 2, 3, 4) [#if v >= 2 [{v}]]
---
// Block body yields template.
// Should output `[1st, 2nd, 3rd, 4th, 5th, 6th]`.
{
- "[" + #for v #in (1, 2, 3, 4, 5, 6) {
- (#if v > 1 [, ]
+ "[" + for v in (1, 2, 3, 4, 5, 6) {
+ (if v > 1 [, ]
+ [{v}]
- + #if v == 1 [st]
- + #if v == 2 [nd]
- + #if v == 3 [rd]
- + #if v >= 4 [th])
+ + if v == 1 [st]
+ + if v == 2 [nd]
+ + if v == 3 [rd]
+ + if v >= 4 [th])
} + "]"
}
diff --git a/tests/lang/typ/heading.typ b/tests/lang/typ/heading.typ
index 9bff2e6e..8497ec8f 100644
--- a/tests/lang/typ/heading.typ
+++ b/tests/lang/typ/heading.typ
@@ -9,7 +9,7 @@
======6
// Too many hashtags.
-// Warning: 1:1-1:8 should not exceed depth 6
+// Warning: 1-8 should not exceed depth 6
=======7
---
@@ -21,7 +21,7 @@
}
// Function call continues heading.
-= #[box][
+= #box[
A
] B
@@ -35,7 +35,7 @@ B
// Parsed as headings if at start of the context.
/**/ = Ok
{[== Ok]}
-#[box][=== Ok]
+#box[=== Ok]
// Not at the start of the context.
No = heading
diff --git a/tests/lang/typ/if-branch.typ b/tests/lang/typ/if-branch.typ
index 8399d674..64523a63 100644
--- a/tests/lang/typ/if-branch.typ
+++ b/tests/lang/typ/if-branch.typ
@@ -30,7 +30,7 @@
#if false [
Bad.
] #else {
- #let pt = "."
+ let pt = "."
"Ok" + pt
}
diff --git a/tests/lang/typ/if-invalid.typ b/tests/lang/typ/if-invalid.typ
index c7ead226..166de122 100644
--- a/tests/lang/typ/if-invalid.typ
+++ b/tests/lang/typ/if-invalid.typ
@@ -1,13 +1,13 @@
// Test invalid if syntax.
---
-// Error: 4-4 expected expression
+// Error: 4 expected expression
#if
-// Error: 5-5 expected expression
-{#if}
+// Error: 4 expected expression
+{if}
-// Error: 6-6 expected body
+// Error: 6 expected body
#if x
// Error: 1-6 unexpected keyword `#else`
@@ -15,14 +15,14 @@
---
// Should output `x`.
-// Error: 4-4 expected expression
+// Error: 4 expected expression
#if
x {}
// Should output `something`.
-// Error: 6-6 expected body
+// Error: 6 expected body
#if x something
// Should output `A thing.`
-// Error: 20-20 expected body
+// Error: 20 expected body
A#if false {} #else thing
diff --git a/tests/lang/typ/if-value.typ b/tests/lang/typ/if-value.typ
index f9e95ff6..d7124255 100644
--- a/tests/lang/typ/if-value.typ
+++ b/tests/lang/typ/if-value.typ
@@ -3,19 +3,19 @@
---
{
- #let x = 1
- #let y = 2
- #let z
+ let x = 1
+ let y = 2
+ let z
// Returns if branch.
- z = #if x < y { "ok" }
+ z = if x < y { "ok" }
test(z, "ok")
// Returns else branch.
- z = #if x > y { "bad" } #else { "ok" }
+ z = if x > y { "bad" } else { "ok" }
test(z, "ok")
// Missing else evaluates to none.
- z = #if x > y { "bad" }
+ z = if x > y { "bad" }
test(z, none)
}
diff --git a/tests/lang/typ/let-invalid.typ b/tests/lang/typ/let-invalid.typ
index 3e32e2cf..f29353ed 100644
--- a/tests/lang/typ/let-invalid.typ
+++ b/tests/lang/typ/let-invalid.typ
@@ -1,17 +1,17 @@
// Test invalid let binding syntax.
---
-// Error: 5-5 expected identifier
+// Error: 5 expected identifier
#let
// Error: 6-9 expected identifier, found string
#let "v"
// Should output `1`.
-// Error: 7-7 expected semicolon or line break
+// Error: 7 expected semicolon or line break
#let v 1
-// Error: 9-9 expected expression
+// Error: 9 expected expression
#let v =
---
diff --git a/tests/lang/typ/let-terminated.typ b/tests/lang/typ/let-terminated.typ
index 6dda7bb2..623265e0 100644
--- a/tests/lang/typ/let-terminated.typ
+++ b/tests/lang/typ/let-terminated.typ
@@ -13,16 +13,16 @@ One
Three
// Terminated because expression ends.
-// Error: 12-12 expected semicolon or line break
+// Error: 12 expected semicolon or line break
#let v4 = 4 Four
// Terminated by semicolon even though we are in a paren group.
-// Error: 2:19-2:19 expected expression
-// Error: 1:19-1:19 expected closing paren
+// Error: 2:19 expected expression
+// Error: 1:19 expected closing paren
#let v5 = (1, 2 + ; Five
-#[test v1, 1]
-#[test v2, 2]
-#[test v3, 3]
-#[test v4, 4]
-#[test v5, (1, 2)]
+#test(v1, 1)
+#test(v2, 2)
+#test(v3, 3)
+#test(v4, 4)
+#test(v5, (1, 2))
diff --git a/tests/lang/typ/let-value.typ b/tests/lang/typ/let-value.typ
index 12e1ba78..700d337d 100644
--- a/tests/lang/typ/let-value.typ
+++ b/tests/lang/typ/let-value.typ
@@ -4,8 +4,8 @@
---
// Automatically initialized with none.
#let x
-#[test x, none]
+#test(x, none)
// Manually initialized with one.
#let x = 1
-#[test x, 1]
+#test(x, 1)
diff --git a/tests/lang/typ/raw.typ b/tests/lang/typ/raw.typ
index a783216e..f5074c8e 100644
--- a/tests/lang/typ/raw.typ
+++ b/tests/lang/typ/raw.typ
@@ -47,5 +47,5 @@ def hi():
---
// Unterminated.
-// Error: 2:1-2:1 expected backtick(s)
+// Error: 2:1 expected backtick(s)
`endless
diff --git a/tests/lang/typ/spacing.typ b/tests/lang/typ/spacing.typ
index 54e49f2d..d44cd84c 100644
--- a/tests/lang/typ/spacing.typ
+++ b/tests/lang/typ/spacing.typ
@@ -3,11 +3,11 @@
---
// Spacing around let.
-// Error: 6-6 expected identifier
+// Error: 6 expected identifier
A#let;B \
-A#let x = 1;B #[test x, 1] \
-A #let x = 2;B #[test x, 2] \
-A#let x = 3; B #[test x, 3] \
+A#let x = 1;B #test(x, 1) \
+A #let x = 2;B #test(x, 2) \
+A#let x = 3; B #test(x, 3) \
---
// Spacing around if-else.
@@ -22,6 +22,6 @@ A#if true [B] #else [] C \
---
// Spacing around for loop.
-A#for _ #in (none,) [B]C \
-A#for _ #in (none,) [B] C \
-A #for _ #in (none,) [B]C \
+A#for _ in (none,) [B]C \
+A#for _ in (none,) [B] C \
+A #for _ in (none,) [B]C \
diff --git a/tests/lang/typ/strong.typ b/tests/lang/typ/strong.typ
index 63e6eb35..b02a55a5 100644
--- a/tests/lang/typ/strong.typ
+++ b/tests/lang/typ/strong.typ
@@ -8,7 +8,7 @@
Partly str*ength*ened.
// Scoped to body.
-#[box][*Scoped] to body.
+#box[*Scoped] to body.
// Unterminated is fine.
*The End
diff --git a/tests/library/typ/box.typ b/tests/library/typ/box.typ
index 67abe350..57763f12 100644
--- a/tests/library/typ/box.typ
+++ b/tests/library/typ/box.typ
@@ -1,20 +1,20 @@
-#[page "a7", flip: true]
+#page("a7", flip: true)
// Box with fixed width, should have text height.
-#[box width: 2cm, color: #9650D6][A]
+#box(width: 2cm, color: #9650D6)[A]
Sometimes there is no box.
// Box with fixed height, should span line.
-#[box height: 2cm, width: 100%, color: #734CED][B]
+#box(height: 2cm, width: 100%, color: #734CED)[B]
// Empty box with fixed width and height.
-#[box width: 6cm, height: 12pt, color: #CB4CED]
+#box(width: 6cm, height: 12pt, color: #CB4CED)
// Not visiblem, but creates a gap between the boxes above and below.
-#[box width: 2in, color: #ff0000]
+#box(width: 2in, color: #ff0000)
// These are in a row!
-#[box width: 1in, height: 10pt, color: #D6CD67]
-#[box width: 1in, height: 10pt, color: #EDD466]
-#[box width: 1in, height: 10pt, color: #E3BE62]
+#box(width: 1in, height: 10pt, color: #D6CD67)
+#box(width: 1in, height: 10pt, color: #EDD466)
+#box(width: 1in, height: 10pt, color: #E3BE62)
diff --git a/tests/library/typ/font.typ b/tests/library/typ/font.typ
index 1bfc1fa6..7f13e8a6 100644
--- a/tests/library/typ/font.typ
+++ b/tests/library/typ/font.typ
@@ -1,37 +1,37 @@
// Test configuring font properties.
-#[font "PT Sans", 10pt]
+#font("PT Sans", 10pt)
// Set same font size in three different ways.
-#[font 20pt][A]
-#[font 200%][A]
-#[font 15pt + 50%][A]
+#font(20pt)[A]
+#font(200%)[A]
+#font(15pt + 50%)[A]
// Do nothing.
-#[font][Normal]
+#font[Normal]
// Set style (is available).
-#[font style: italic][Italic]
+#font(style: italic)[Italic]
// Set weight (is available).
-#[font weight: bold][Bold]
+#font(weight: bold)[Bold]
// Set stretch (not available, matching closest).
-#[font stretch: ultra-condensed][Condensed]
+#font(stretch: ultra-condensed)[Condensed]
-// Error: 8-13 unexpected argument
-#[font false]
+// Error: 7-12 unexpected argument
+#font(false)
-// Error: 3:15-3:19 expected font style, found font weight
-// Error: 2:29-2:35 expected font weight, found string
-// Error: 1:44-1:45 expected font family or array of font families, found integer
-#[font style: bold, weight: "thin", serif: 0]
+// 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: 16-20 should be between 100 and 900
-#[font weight: 2700]
+// Warning: 15-19 should be between 100 and 900
+#font(weight: 2700)
-// Error: 8-28 unexpected argument
-#[font something: "invalid"]
+// Error: 7-27 unexpected argument
+#font(something: "invalid")
---
// Test font fallback and class definitions.
@@ -40,17 +40,17 @@
Emoji: 🏀
// CMU Serif + Noto Emoji.
-#[font "CMU Serif", "Noto Emoji"][
+#font("CMU Serif", "Noto Emoji")[
Emoji: 🏀
]
// Class definitions.
-#[font serif: ("CMU Serif", "Latin Modern Math", "Noto Emoji")]
-#[font serif][
+#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)]
+#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
index 15799c81..154445cf 100644
--- a/tests/library/typ/hv.typ
+++ b/tests/library/typ/hv.typ
@@ -1,22 +1,22 @@
// Ends paragraphs.
-Tightly #[v -5pt] packed
+Tightly #v(-5pt) packed
// Eating up soft spacing.
-Inv #[h 0pt] isible
+Inv #h(0pt) isible
// Multiple spacings in a row.
-Add #[h 10pt] #[h 10pt] up
+Add #h(10pt) #h(10pt) up
// Relative to font size.
-Relative #[h 100%] spacing
+Relative #h(100%) spacing
// Missing spacing.
-// Error: 12-12 missing argument: spacing
-Totally #[h] ignored
+// Error: 12 missing argument: spacing
+Totally #h() ignored
// Swapped axes.
-#[page main-dir: rtl, cross-dir: ttb, height: 80pt][
- 1 #[h 1cm] 2
+#page(main-dir: rtl, cross-dir: ttb, height: 80pt)[
+ 1 #h(1cm) 2
- 3 #[v 1cm] 4 #[v -1cm] 5
+ 3 #v(1cm) 4 #v(-1cm) 5
]
diff --git a/tests/library/typ/image.typ b/tests/library/typ/image.typ
index ced364b3..8bf972b2 100644
--- a/tests/library/typ/image.typ
+++ b/tests/library/typ/image.typ
@@ -1,39 +1,35 @@
// Test loading different image formats.
// Load an RGBA PNG image.
-#[image "res/rhino.png"]
-#[pagebreak]
+#image("res/rhino.png")
+#pagebreak()
// Load an RGB JPEG image.
-#[image "res/tiger.jpg"]
+#image("res/tiger.jpg")
// Error: 9-30 failed to load image
-#[image "path/does/not/exist"]
+#image("path/does/not/exist")
// Error: 9-30 failed to load image
-#[image "typ/image-error.typ"]
+#image("typ/image-error.typ")
---
// Test configuring the size and fitting behaviour of images.
// Fit to width of page.
-#[image "res/rhino.png"]
+#image("res/rhino.png")
// Fit to height of page.
-#[page height: 40pt][
- #[image "res/rhino.png"]
-]
+#page(height: 40pt, image("res/rhino.png"))
// Set width explicitly.
-#[image "res/rhino.png", width: 50pt]
+#image("res/rhino.png", width: 50pt)
// Set height explicitly.
-#[image "res/rhino.png", height: 50pt]
+#image("res/rhino.png", height: 50pt)
// Set width and height explicitly and force stretching.
-#[image "res/rhino.png", width: 25pt, height: 50pt]
+#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]
-]
+#align(bottom, right, image("res/tiger.jpg", width: 60pt))
diff --git a/tests/library/typ/page.typ b/tests/library/typ/page.typ
index 8a9604ad..b7ac0348 100644
--- a/tests/library/typ/page.typ
+++ b/tests/library/typ/page.typ
@@ -1,53 +1,53 @@
// Test configuring page sizes and margins.
// Set width and height.
-#[page width: 120pt, height: 120pt]
-#[page width: 40pt][High]
-#[page height: 40pt][Wide]
+#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]
+#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]
+#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]
+#page(margins: 0pt, left: 20pt)[Overriden]
-// Error: 8-19 unknown variable
-#[page nonexistant]
+// Error: 7-18 unknown variable
+#page(nonexistant)
-// Error: 18-21 aligned axis
-#[page main-dir: ltr]
+// Error: 17-20 aligned axis
+#page(main-dir: ltr)
// Flipped predefined paper.
-#[page "a11", flip: true][Flipped A11]
+#page("a11", flip: true)[Flipped A11]
// Flipped custom page size.
-#[page width: 40pt, height: 120pt]
-#[page flip: true]
+#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]
+#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(height: 50pt)
-#[page][First]
-#[page][Second]
-#[pagebreak]
+#page[First]
+#page[Second]
+#pagebreak()
Fourth
-#[page][]
+#page[]
Sixth
-#[page][Seventh and last]
+#page[Seventh and last]
diff --git a/tests/library/typ/pagebreak.typ b/tests/library/typ/pagebreak.typ
index 08dd9c7b..dc3e5682 100644
--- a/tests/library/typ/pagebreak.typ
+++ b/tests/library/typ/pagebreak.typ
@@ -1,3 +1,3 @@
First of two
-#[pagebreak]
-#[page height: 40pt]
+#pagebreak()
+#page(height: 40pt)
diff --git a/tests/library/typ/rgb.typ b/tests/library/typ/rgb.typ
index 06f7be52..b962bbc0 100644
--- a/tests/library/typ/rgb.typ
+++ b/tests/library/typ/rgb.typ
@@ -1,17 +1,17 @@
// Check the output.
-#[rgb 0.0, 0.3, 0.7]
+#rgb(0.0, 0.3, 0.7)
// Alpha channel.
-#[rgb 1.0, 0.0, 0.0, 0.5]
+#rgb(1.0, 0.0, 0.0, 0.5)
-// Warning: 2:7-2:10 should be between 0.0 and 1.0
-// Warning: 1:12-1:16 should be between 0.0 and 1.0
-#[rgb -30, 15.5, 0.5]
+// Warning: 2:6-2:9 should be between 0.0 and 1.0
+// Warning: 1:11-1:15 should be between 0.0 and 1.0
+#rgb(-30, 15.5, 0.5)
-// Error: 7-11 missing argument: blue component
-#[rgb 0, 1]
+// Error: 6-10 missing argument: blue component
+#rgb(0, 1)
// Error: 3:6-3:6 missing argument: red component
// Error: 2:6-2:6 missing argument: green component
// Error: 1:6-1:6 missing argument: blue component
-#[rgb]
+#rgb()
diff --git a/tests/typeset.rs b/tests/typeset.rs
index 7f8646be..ac4fe9b0 100644
--- a/tests/typeset.rs
+++ b/tests/typeset.rs
@@ -296,7 +296,9 @@ fn parse_metadata(src: &str, map: &LineMap) -> (Option<bool>, DiagSet) {
};
let mut s = Scanner::new(rest);
- let (start, _, end) = (pos(&mut s), s.eat_assert('-'), pos(&mut s));
+ let start = pos(&mut s);
+ let end = if s.eat_if('-') { pos(&mut s) } else { start };
+
diags.insert(Diag::new(start .. end, level, s.rest().trim()));
}