summaryrefslogtreecommitdiff
path: root/tests/typ/expr/block-scoping.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-02-20 17:53:40 +0100
committerLaurenz <laurmaedje@gmail.com>2021-02-20 23:34:33 +0100
commit05727bfc3a9cfd45a8e2028dfd0806f7a8f88015 (patch)
tree6c0b66eb2a9dff224cb39eb6ccb478656a706c04 /tests/typ/expr/block-scoping.typ
parent927341d93ae29678095e3b874bd68bfc57d4bc05 (diff)
Reorganize tests 🔀
Diffstat (limited to 'tests/typ/expr/block-scoping.typ')
-rw-r--r--tests/typ/expr/block-scoping.typ35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/typ/expr/block-scoping.typ b/tests/typ/expr/block-scoping.typ
new file mode 100644
index 00000000..7bb98969
--- /dev/null
+++ b/tests/typ/expr/block-scoping.typ
@@ -0,0 +1,35 @@
+// Test scoping with blocks.
+// Ref: false
+
+---
+// Block in template does not create a scope.
+{ let x = 1 }
+#test(x, 1)
+
+---
+// Block in expression does create a scope.
+#let a = {
+ let b = 1
+ b
+}
+
+#test(a, 1)
+
+// Error: 2-3 unknown variable
+{b}
+
+---
+// Multiple nested scopes.
+{
+ let a = "a1"
+ {
+ let a = "a2"
+ {
+ test(a, "a2")
+ let a = "a3"
+ test(a, "a3")
+ }
+ test(a, "a2")
+ }
+ test(a, "a1")
+}