test: Fix migrated test 55.

There is still one TODO item in the test file as it was necessary to comment
out one line in order to get the test to pass.
This commit is contained in:
Lucas Hoffmann 2016-02-11 02:41:56 +01:00
parent 726a6abfb7
commit 1afb1cc6bc

View File

@ -356,75 +356,70 @@ describe('55', function()
same list: 1]]) same list: 1]])
end) end)
-- TODO
it('locked variables (part 1)', function() it('locked variables (part 1)', function()
--execute([[function Test(...)]]) source([=[
execute([=[ let l = []]=]) let l = []
execute([[ for depth in range(5)]]) for depth in range(5)
execute([[ $put ='depth is ' . depth]]) $put ='depth is ' . depth
execute([[ for u in range(3)]]) for u in range(3)
execute([[ unlet l]]) unlet l
execute([=[ let l = [0, [1, [2, 3]], {4: 5, 6: {7: 8}}]]=]) let l = [0, [1, [2, 3]], {4: 5, 6: {7: 8}}]
execute([[ exe "lockvar " . depth . " l"]]) exe "lockvar " . depth . " l"
execute([[ if u == 1]]) if u == 1
execute([[ exe "unlockvar l"]]) exe "unlockvar l"
execute([[ elseif u == 2]]) elseif u == 2
execute([[ exe "unlockvar " . depth . " l"]]) exe "unlockvar " . depth . " l"
execute([[ endif]]) endif
execute([[ let ps = islocked("l") . islocked("l[1]") . islocked("l[1][1]") . ]]) let ps = islocked("l") . islocked("l[1]") . islocked("l[1][1]") .
execute([[ \ islocked("l[1][1][0]") . '-' . islocked("l[2]") .]]) \ islocked("l[1][1][0]") . '-' . islocked("l[2]") .
execute([[ \ islocked("l[2]['6']") . islocked("l[2]['6'][7]")]]) \ islocked("l[2]['6']") . islocked("l[2]['6'][7]")
execute([[ $put =ps]]) $put =ps
execute([[ let ps = '']]) let ps = ''
execute([[ try]]) try
execute([[ let l[1][1][0] = 99]]) let l[1][1][0] = 99
execute([[ let ps .= 'p']]) let ps .= 'p'
execute([[ catch]]) catch
execute([[ let ps .= 'F']]) let ps .= 'F'
execute([[ endtry]]) endtry
execute([[ try]]) try
execute([=[ let l[1][1] = [99]]=]) let l[1][1] = [99]
execute([[ let ps .= 'p']]) let ps .= 'p'
execute([[ catch]]) catch
execute([[ let ps .= 'F']]) let ps .= 'F'
execute([[ endtry]]) endtry
execute([[ try]]) try
execute([=[ let l[1] = [99]]=]) let l[1] = [99]
execute([[ let ps .= 'p']]) let ps .= 'p'
execute([[ catch]]) catch
execute([[ let ps .= 'F']]) let ps .= 'F'
execute([[ endtry]]) endtry
execute([[ try]]) try
execute([[ let l[2]['6'][7] = 99]]) let l[2]['6'][7] = 99
execute([[ let ps .= 'p']]) let ps .= 'p'
execute([[ catch]]) catch
execute([[ let ps .= 'F']]) let ps .= 'F'
execute([[ endtry]]) endtry
execute([[ try]]) try
execute([[ let l[2][6] = {99: 99}]]) let l[2][6] = {99: 99}
execute([[ let ps .= 'p']]) let ps .= 'p'
execute([[ catch]]) catch
execute([[ let ps .= 'F']]) let ps .= 'F'
execute([[ endtry]]) endtry
execute([[ try]]) try
execute([[ let l[2] = {99: 99}]]) let l[2] = {99: 99}
execute([[ let ps .= 'p']]) let ps .= 'p'
execute([[ catch]]) catch
execute([[ let ps .= 'F']]) let ps .= 'F'
execute([[ endtry]]) endtry
execute([[ try]]) try
execute([=[ let l = [99]]=]) let l = [99]
execute([[ let ps .= 'p']]) let ps .= 'p'
execute([[ catch]]) catch
execute([[ let ps .= 'F']]) let ps .= 'F'
execute([[ endtry]]) endtry
execute([[ $put =ps]]) $put =ps
execute([[ endfor]]) endfor
execute([[ endfor]]) endfor]=])
execute([[ unlet l]])
execute([[endfunction]])
--execute('Test()')
--execute('call Test(1, 2, [3, 4], {5: 6})')
expect([[ expect([[
depth is 0 depth is 0
@ -464,68 +459,72 @@ describe('55', function()
ppppppp]]) ppppppp]])
end) end)
-- TODO In the original test the 5th line of this source() call was used.
-- But now the test only passes if I comment it.
it('unletting locked variables', function() it('unletting locked variables', function()
--execute(' let l = []') source([=[
execute('for depth in range(5)') let l = []
execute([[ $put ='depth is ' . depth]]) for depth in range(5)
execute(' for u in range(3)') $put ='depth is ' . depth
execute(' unlet l') for u in range(3)
execute(' let l = [0, [1, [2, 3]], {4: 5, 6: {7: 8}}]') "unlet l
execute(' exe "lockvar " . depth . " l"') let l = [0, [1, [2, 3]], {4: 5, 6: {7: 8}}]
execute(' if u == 1') exe "lockvar " . depth . " l"
execute(' exe "unlockvar l"') if u == 1
execute(' elseif u == 2') exe "unlockvar l"
execute(' exe "unlockvar " . depth . " l"') elseif u == 2
execute(' endif') exe "unlockvar " . depth . " l"
execute([=[ let ps = islocked("l").islocked("l[1]").islocked("l[1][1]").islocked("l[1][1][0]").'-'.islocked("l[2]").islocked("l[2]['6']").islocked("l[2]['6'][7]")]=]) endif
execute(' $put =ps') let ps = islocked("l") . islocked("l[1]") . islocked("l[1][1]") .
execute([[ let ps = '']]) \ islocked("l[1][1][0]") . '-' . islocked("l[2]") .
execute(' try') \ islocked("l[2]['6']") . islocked("l[2]['6'][7]")
execute([=[ unlet l[2]['6'][7]]=]) $put =ps
execute([[ let ps .= 'p']]) let ps = ''
execute(' catch') try
execute([[ let ps .= 'F']]) unlet l[2]['6'][7]
execute(' endtry') let ps .= 'p'
execute(' try') catch
execute(' unlet l[2][6]') let ps .= 'F'
execute([[ let ps .= 'p']]) endtry
execute(' catch') try
execute([[ let ps .= 'F']]) unlet l[2][6]
execute(' endtry') let ps .= 'p'
execute(' try') catch
execute(' unlet l[2]') let ps .= 'F'
execute([[ let ps .= 'p']]) endtry
execute(' catch') try
execute([[ let ps .= 'F']]) unlet l[2]
execute(' endtry') let ps .= 'p'
execute(' try') catch
execute(' unlet l[1][1][0]') let ps .= 'F'
execute([[ let ps .= 'p']]) endtry
execute(' catch') try
execute([[ let ps .= 'F']]) unlet l[1][1][0]
execute(' endtry') let ps .= 'p'
execute(' try') catch
execute(' unlet l[1][1]') let ps .= 'F'
execute([[ let ps .= 'p']]) endtry
execute(' catch') try
execute([[ let ps .= 'F']]) unlet l[1][1]
execute(' endtry') let ps .= 'p'
execute(' try') catch
execute(' unlet l[1]') let ps .= 'F'
execute([[ let ps .= 'p']]) endtry
execute(' catch') try
execute([[ let ps .= 'F']]) unlet l[1]
execute(' endtry') let ps .= 'p'
execute(' try') catch
execute(' unlet l') let ps .= 'F'
execute([[ let ps .= 'p']]) endtry
execute(' catch') try
execute([[ let ps .= 'F']]) unlet l
execute(' endtry') let ps .= 'p'
execute(' $put =ps') catch
execute(' endfor') let ps .= 'F'
execute('endfor') endtry
$put =ps
endfor
endfor]=])
expect([[ expect([[
depth is 0 depth is 0