summaryrefslogtreecommitdiff
path: root/tests/typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-06-09 10:51:19 +0200
committerLaurenz <laurmaedje@gmail.com>2021-06-09 10:51:19 +0200
commitc7416f18bdddf48f4535a6d48927c2355d842af9 (patch)
tree2730265f83bd98d8f670ac47588d499a43c1ad92 /tests/typ
parentedff2ae6803928e59eae96e2f75cd62a7e24c76f (diff)
Move invalid syntax tests into appropriate places
Diffstat (limited to 'tests/typ')
-rw-r--r--tests/typ/code/for.typ35
-rw-r--r--tests/typ/code/if.typ28
-rw-r--r--tests/typ/code/invalid.typ100
-rw-r--r--tests/typ/code/let.typ21
-rw-r--r--tests/typ/code/ops-assoc.typ (renamed from tests/typ/code/assoc.typ)0
-rw-r--r--tests/typ/code/ops-prec.typ (renamed from tests/typ/code/prec.typ)0
-rw-r--r--tests/typ/code/while.typ22
7 files changed, 106 insertions, 100 deletions
diff --git a/tests/typ/code/for.typ b/tests/typ/code/for.typ
index bca1af46..321b08cf 100644
--- a/tests/typ/code/for.typ
+++ b/tests/typ/code/for.typ
@@ -57,6 +57,8 @@
#test(type(for v in () []), "template")
---
+// Ref: false
+
// Uniterable expression.
// Error: 11-15 cannot loop over boolean
#for v in true {}
@@ -69,3 +71,36 @@
#test(error, for v in (1, 2, 3) {
if v < 2 [Ok] else {error}
})
+
+---
+// Error: 5 expected identifier
+#for
+
+// Error: 5 expected identifier
+{for}
+
+// Error: 7 expected keyword `in`
+#for v
+
+// Error: 10 expected expression
+#for v in
+
+// Error: 15 expected body
+#for v in iter
+
+// Should output `v in iter`.
+// Error: 5 expected identifier
+#for
+v in iter {}
+
+// Should output `A thing`.
+// Error: 7-10 expected identifier, found string
+A#for "v" thing
+
+// Should output `in iter`.
+// Error: 6-9 expected identifier, found string
+#for "v" in iter {}
+
+// Should output `+ b in iter`.
+// Error: 7 expected keyword `in`
+#for a + b in iter {}
diff --git a/tests/typ/code/if.typ b/tests/typ/code/if.typ
index 8d07e9b8..dd5d23a0 100644
--- a/tests/typ/code/if.typ
+++ b/tests/typ/code/if.typ
@@ -61,6 +61,8 @@
}
---
+// Ref: false
+
// Condition must be boolean.
// If it isn't, neither branch is evaluated.
// Error: 5-14 expected boolean, found string
@@ -69,3 +71,29 @@
// Make sure that we don't complain twice.
// Error: 5-12 cannot add integer and string
#if 1 + "2" {}
+
+---
+// Error: 4 expected expression
+#if
+
+// Error: 4 expected expression
+{if}
+
+// Error: 6 expected body
+#if x
+
+// Error: 1-6 unexpected keyword `else`
+#else {}
+
+// Should output `x`.
+// Error: 4 expected expression
+#if
+x {}
+
+// Should output `something`.
+// Error: 6 expected body
+#if x something
+
+// Should output `A thing.`
+// Error: 20 expected body
+A#if false {} #else thing
diff --git a/tests/typ/code/invalid.typ b/tests/typ/code/invalid.typ
deleted file mode 100644
index 49158a68..00000000
--- a/tests/typ/code/invalid.typ
+++ /dev/null
@@ -1,100 +0,0 @@
-// Test invalid control syntax.
-
----
-// Error: 5 expected identifier
-#let
-
-// Error: 5 expected identifier
-{let}
-
-// Error: 6-9 expected identifier, found string
-#let "v"
-
-// Should output `1`.
-// Error: 7 expected semicolon or line break
-#let v 1
-
-// Error: 9 expected expression
-#let v =
-
-// Should output `= 1`.
-// Error: 6-9 expected identifier, found string
-#let "v" = 1
-
----
-// Error: 4 expected expression
-#if
-
-// Error: 4 expected expression
-{if}
-
-// Error: 6 expected body
-#if x
-
-// Error: 1-6 unexpected keyword `else`
-#else {}
-
-// Should output `x`.
-// Error: 4 expected expression
-#if
-x {}
-
-// Should output `something`.
-// Error: 6 expected body
-#if x something
-
-// Should output `A thing.`
-// Error: 20 expected body
-A#if false {} #else thing
-
----
-// Error: 7 expected expression
-#while
-
-// Error: 7 expected expression
-{while}
-
-// Error: 9 expected body
-#while x
-
-// Should output `x`.
-// Error: 7 expected expression
-#while
-x {}
-
-// Should output `something`.
-// Error: 9 expected body
-#while x something
-
----
-// Error: 5 expected identifier
-#for
-
-// Error: 5 expected identifier
-{for}
-
-// Error: 7 expected keyword `in`
-#for v
-
-// Error: 10 expected expression
-#for v in
-
-// Error: 15 expected body
-#for v in iter
-
-// Should output `v in iter`.
-// Error: 5 expected identifier
-#for
-v in iter {}
-
-// Should output `A thing`.
-// Error: 7-10 expected identifier, found string
-A#for "v" thing
-
-// Should output `in iter`.
-// Error: 6-9 expected identifier, found string
-#for "v" in iter {}
-
-// Should output `+ b in iter`.
-// Error: 7 expected keyword `in`
-#for a + b in iter {}
diff --git a/tests/typ/code/let.typ b/tests/typ/code/let.typ
index 49abec53..1a0bb10e 100644
--- a/tests/typ/code/let.typ
+++ b/tests/typ/code/let.typ
@@ -61,3 +61,24 @@ Three
#test(v3, 3)
#test(v4, 4)
#test(v5, (1, 2))
+
+---
+// Error: 5 expected identifier
+#let
+
+// Error: 5 expected identifier
+{let}
+
+// Error: 6-9 expected identifier, found string
+#let "v"
+
+// Should output `1`.
+// Error: 7 expected semicolon or line break
+#let v 1
+
+// Error: 9 expected expression
+#let v =
+
+// Should output `= 1`.
+// Error: 6-9 expected identifier, found string
+#let "v" = 1
diff --git a/tests/typ/code/assoc.typ b/tests/typ/code/ops-assoc.typ
index 19c56951..19c56951 100644
--- a/tests/typ/code/assoc.typ
+++ b/tests/typ/code/ops-assoc.typ
diff --git a/tests/typ/code/prec.typ b/tests/typ/code/ops-prec.typ
index e64e583c..e64e583c 100644
--- a/tests/typ/code/prec.typ
+++ b/tests/typ/code/ops-prec.typ
diff --git a/tests/typ/code/while.typ b/tests/typ/code/while.typ
index acf7951e..e55f8f10 100644
--- a/tests/typ/code/while.typ
+++ b/tests/typ/code/while.typ
@@ -22,10 +22,13 @@
---
// Value of while loops.
// Ref: false
+
#test(type(while false {}), "template")
#test(type(while false []), "template")
---
+// Ref: false
+
// Condition must be boolean.
// Error: 8-14 expected boolean, found template
#while [nope] [nope]
@@ -41,3 +44,22 @@
if i < 5 [nope] else { error }
})
#test(i, 5)
+
+---
+// Error: 7 expected expression
+#while
+
+// Error: 7 expected expression
+{while}
+
+// Error: 9 expected body
+#while x
+
+// Should output `x`.
+// Error: 7 expected expression
+#while
+x {}
+
+// Should output `something`.
+// Error: 9 expected body
+#while x something