mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
Add tests for nested with
blocks
Added two tests that test the behavior of nested `with` blocks. When a nested `with` block is started, using a variable referenced from the enclosing one, expected behavior is to change the short-dot syntax scope to the newly-referenced variable.
This commit is contained in:
parent
b78cdab10b
commit
5ae8ffaed7
@ -93,6 +93,16 @@ do
|
||||
with k.j = "jo"
|
||||
print \upper!
|
||||
|
||||
do
|
||||
with a
|
||||
print .b
|
||||
-- nested `with`s should change the scope correctly
|
||||
with .c
|
||||
print .d
|
||||
|
||||
|
||||
do
|
||||
with a
|
||||
-- nested `with`s with assignments should change the scope correctly
|
||||
with .b = 2
|
||||
print .c
|
||||
|
||||
|
@ -131,6 +131,26 @@ do
|
||||
local _with_0 = "jo"
|
||||
k.j = _with_0
|
||||
print(_with_0:upper())
|
||||
end
|
||||
end
|
||||
do
|
||||
do
|
||||
local _with_0 = a
|
||||
print(_with_0.b)
|
||||
do
|
||||
local _with_1 = _with_0.c
|
||||
print(_with_1.d)
|
||||
end
|
||||
end
|
||||
end
|
||||
do
|
||||
do
|
||||
local _with_0 = a
|
||||
do
|
||||
local _with_1 = 2
|
||||
_with_0.b = _with_1
|
||||
print(_with_1.c)
|
||||
end
|
||||
return _with_0
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user