From 8b58171d7ca036d71b32749286c251cc91bdd10e Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 18 May 2021 00:36:11 +0200 Subject: Reorganize test cases --- tests/typ/code/block-scoping.typ | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/typ/code/block-scoping.typ (limited to 'tests/typ/code/block-scoping.typ') diff --git a/tests/typ/code/block-scoping.typ b/tests/typ/code/block-scoping.typ new file mode 100644 index 00000000..7bb98969 --- /dev/null +++ b/tests/typ/code/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") +} -- cgit v1.2.3