diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-05-15 14:39:52 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-05-15 14:39:52 +0200 |
commit | b6c589a529bc8c5720477494696c6f69fe457475 (patch) | |
tree | fa6f512190cb15fa5a0a3186312ede6115881e61 /src/testdir | |
parent | 46a7561f3a151fefc469225d41822dd0be292f98 (diff) | |
download | vim-b6c589a529bc8c5720477494696c6f69fe457475.zip |
updated for version 7.3.947
Problem: Python: No iterator for vim.list and vim.bufferlist.
Solution: Add the iterators. Also fix name of FunctionType. Add tests for
vim.buffers. (ZyX)
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test86.in | 59 | ||||
-rw-r--r-- | src/testdir/test86.ok | 12 | ||||
-rw-r--r-- | src/testdir/test87.in | 60 | ||||
-rw-r--r-- | src/testdir/test87.ok | 12 |
4 files changed, 143 insertions, 0 deletions
diff --git a/src/testdir/test86.in b/src/testdir/test86.in index 555a5fdf5..5b87633a7 100644 --- a/src/testdir/test86.in +++ b/src/testdir/test86.in @@ -477,6 +477,9 @@ EOF : call RecVars(oname) :endfor :only +:for buf in g:bufs[1:] +: execute 'bwipeout!' buf +:endfor :" :" Test buffer object :vnew @@ -519,6 +522,62 @@ for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc")'): # Should not happen in any case cb.append('No exception for ' + expr) EOF +:" +:" Test vim.buffers object +:set hidden +:edit a +:buffer # +:edit b +:buffer # +:edit c +:buffer # +py << EOF +# Check GCing iterator that was not fully exhausted +i = iter(vim.buffers) +cb.append('i:' + str(next(i))) +# and also check creating more then one iterator at a time +i2 = iter(vim.buffers) +cb.append('i2:' + str(next(i2))) +cb.append('i:' + str(next(i))) +# The following should trigger GC and not cause any problems +del i +del i2 +i3 = iter(vim.buffers) +cb.append('i3:' + str(next(i3))) +del i3 + +prevnum = 0 +for b in vim.buffers: + # Check buffer order + if prevnum >= b.number: + cb.append('!!! Buffer numbers not in strictly ascending order') + # Check indexing: vim.buffers[number].number == number + cb.append(str(b.number) + ':' + repr(vim.buffers[b.number]) + '=' + repr(b)) + prevnum = b.number + +cb.append(str(len(vim.buffers))) + +bnums = list(map(lambda b: b.number, vim.buffers))[1:] + +# Test wiping out buffer with existing iterator +i4 = iter(vim.buffers) +cb.append('i4:' + str(next(i4))) +vim.command('bwipeout! ' + str(bnums.pop(0))) +try: + next(i4) +except vim.error: + pass +else: + cb.append('!!!! No vim.error') +i4 = iter(vim.buffers) +vim.command('bwipeout! ' + str(bnums.pop(-1))) +vim.command('bwipeout! ' + str(bnums.pop(-1))) +cb.append('i4:' + str(next(i4))) +try: + next(i4) +except StopIteration: + cb.append('StopIteration') +EOF :endfun :" :call Test() diff --git a/src/testdir/test86.ok b/src/testdir/test86.ok index 13a719309..4b54d985f 100644 --- a/src/testdir/test86.ok +++ b/src/testdir/test86.ok @@ -319,3 +319,15 @@ bar Second line Third line foo +i:<buffer test86.in> +i2:<buffer test86.in> +i:<buffer a> +i3:<buffer test86.in> +1:<buffer test86.in>=<buffer test86.in> +6:<buffer a>=<buffer a> +7:<buffer b>=<buffer b> +8:<buffer c>=<buffer c> +4 +i4:<buffer test86.in> +i4:<buffer test86.in> +StopIteration diff --git a/src/testdir/test87.in b/src/testdir/test87.in index 6f3cce0fa..f9b8a65fd 100644 --- a/src/testdir/test87.in +++ b/src/testdir/test87.in @@ -446,6 +446,9 @@ EOF : call RecVars(oname) :endfor :only +:for buf in g:bufs[1:] +: execute 'bwipeout!' buf +:endfor :" :" Test buffer object :vnew @@ -488,6 +491,62 @@ for expr in ('b[1]','b[:] = ["A", "B"]','b[:]','b.append("abc")'): # Should not happen in any case cb.append('No exception for ' + expr) EOF +:" +:" Test vim.buffers object +:set hidden +:edit a +:buffer # +:edit b +:buffer # +:edit c +:buffer # +py3 << EOF +# Check GCing iterator that was not fully exhausted +i = iter(vim.buffers) +cb.append('i:' + str(next(i))) +# and also check creating more then one iterator at a time +i2 = iter(vim.buffers) +cb.append('i2:' + str(next(i2))) +cb.append('i:' + str(next(i))) +# The following should trigger GC and not cause any problems +del i +del i2 +i3 = iter(vim.buffers) +cb.append('i3:' + str(next(i3))) +del i3 + +prevnum = 0 +for b in vim.buffers: + # Check buffer order + if prevnum >= b.number: + cb.append('!!! Buffer numbers not in strictly ascending order') + # Check indexing: vim.buffers[number].number == number + cb.append(str(b.number) + ':' + repr(vim.buffers[b.number]) + '=' + repr(b)) + prevnum = b.number + +cb.append(str(len(vim.buffers))) + +bnums = list(map(lambda b: b.number, vim.buffers))[1:] + +# Test wiping out buffer with existing iterator +i4 = iter(vim.buffers) +cb.append('i4:' + str(next(i4))) +vim.command('bwipeout! ' + str(bnums.pop(0))) +try: + next(i4) +except vim.error: + pass +else: + cb.append('!!!! No vim.error') +i4 = iter(vim.buffers) +vim.command('bwipeout! ' + str(bnums.pop(-1))) +vim.command('bwipeout! ' + str(bnums.pop(-1))) +cb.append('i4:' + str(next(i4))) +try: + next(i4) +except StopIteration: + cb.append('StopIteration') +EOF :endfun :" :call Test() @@ -496,6 +555,7 @@ EOF :call garbagecollect(1) :" :/^start:/,$wq! test.out +:call getchar() ENDTEST start: diff --git a/src/testdir/test87.ok b/src/testdir/test87.ok index c204fc521..e7d031bfb 100644 --- a/src/testdir/test87.ok +++ b/src/testdir/test87.ok @@ -308,3 +308,15 @@ bar Second line Third line foo +i:<buffer test87.in> +i2:<buffer test87.in> +i:<buffer a> +i3:<buffer test87.in> +1:<buffer test87.in>=<buffer test87.in> +6:<buffer a>=<buffer a> +7:<buffer b>=<buffer b> +8:<buffer c>=<buffer c> +4 +i4:<buffer test87.in> +i4:<buffer test87.in> +StopIteration |