Loading ...
Sorry, an error occurred while loading the content.

[PATCH] (21/27?) Python interface improvements: add tests for vim.bufferlist

Expand Messages
  • ZyX
    “27?” means that I am not sure whether there will not be some fixes to the existing patches. # HG changeset patch # User ZyX # Date
    Message 1 of 49 , May 1, 2013
    • 0 Attachment
      “27?” means that I am not sure whether there will not be some fixes to the existing patches.

      # HG changeset patch
      # User ZyX <kp-pav@...>
      # Date 1367169637 -14400
      # Branch python-extended-2
      # Node ID 0dca91db547a8b20984492d342b51f08146bd503
      # Parent e29132a9a246e303b8ce749564f7328bc2329ac0
      Add tests for vim.bufferslist object

      diff -r e29132a9a246 -r 0dca91db547a src/testdir/test86.in
      --- a/src/testdir/test86.in Sun Apr 28 19:42:28 2013 +0400
      +++ b/src/testdir/test86.in Sun Apr 28 21:20:37 2013 +0400
      @@ -460,6 +460,9 @@
      : call RecVars(oname)
      :endfor
      :only
      +:for buf in g:bufs[1:]
      +: execute 'bwipeout!' buf
      +:endfor
      :"
      :" Test buffer object
      :vnew
      @@ -502,6 +505,62 @@
      # 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 -r e29132a9a246 -r 0dca91db547a src/testdir/test86.ok
      --- a/src/testdir/test86.ok Sun Apr 28 19:42:28 2013 +0400
      +++ b/src/testdir/test86.ok Sun Apr 28 21:20:37 2013 +0400
      @@ -316,3 +316,15 @@
      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 -r e29132a9a246 -r 0dca91db547a src/testdir/test87.in
      --- a/src/testdir/test87.in Sun Apr 28 19:42:28 2013 +0400
      +++ b/src/testdir/test87.in Sun Apr 28 21:20:37 2013 +0400
      @@ -446,6 +446,9 @@
      : call RecVars(oname)
      :endfor
      :only
      +:for buf in g:bufs[1:]
      +: execute 'bwipeout!' buf
      +:endfor
      :"
      :" Test buffer object
      :vnew
      @@ -488,6 +491,62 @@
      # 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 @@
      :call garbagecollect(1)
      :"
      :/^start:/,$wq! test.out
      +:call getchar()
      ENDTEST

      start:
      diff -r e29132a9a246 -r 0dca91db547a src/testdir/test87.ok
      --- a/src/testdir/test87.ok Sun Apr 28 19:42:28 2013 +0400
      +++ b/src/testdir/test87.ok Sun Apr 28 21:20:37 2013 +0400
      @@ -305,3 +305,15 @@
      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

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • ZyX
      ... Because you have problems with encoding somewhere: there were no question marks in the patch, but Russian text. I just was not aware of the strange choice:
      Message 49 of 49 , May 15, 2013
      • 0 Attachment
        > After including this patch the tests were failing. The .ok files had
        > "????" where the test results in "window". I assume those question
        > marks were wrong, so I fixed the .ok files for that. But I wonder why
        > this happened.

        Because you have problems with encoding somewhere: there were no question marks in the patch, but Russian text. I just was not aware of the strange choice: using translated strings in `repr()`. I think translated messages here are just as “good” as translated exceptions; needless to say I have never seen them translated in other projects.

        --
        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      Your message has been successfully submitted and would be delivered to recipients shortly.