Hi Bram and List,
2016-1-8(Fri) 2:27:17 UTC+9 Bram Moolenaar:
> Hirohito Higashi wrote:
>
> > > > To: Bram (As a Vimboss)
> > > > To: Christian Brabandt (As a visual <C-A>/<C-X> first patch author)
> > > > To: Jason Schulz (As a support for bin 'nrformats' patch author)
> > > >
> > > > Hi,
> > > >
> > > > I refactored visual <C-A>/<C-X> to support vcol et al.
> > > > This mean is <TAB> code free!
> > > >
> > > > Contents of patch.
> > > > - visual <C-A>/<C-X> support vcol. (<TAB> code free)
> > > > - 'test_increment' convert from old style test to new style test. and
> > > > added some test items.
> > > > - Processing was allowed to separate.
> > > > (line loop process and add/subtract process)
> > > > (We have to use the existing function block_prep() to process the
> > > > block-wise)
> > > > - We removed the halfway right-to-left processing.
> > > > (Remove RLADDSUBFIX() macro)
> > > > (This is causing the actual problem)
> > > > $ vim -Nu NONE -c "set rightleft"
> > > > i123 45<Esc>
> > > > <C-A> " Unexpected swap the numbers of strings occurred.
> > > >
> > > > Christian Brabandt and Jason Schulz and List>
> > > > I was wondering if you could review this patch.
> > > >
> > > > Jason Schulz>
> > > > Sorry to such just your patch was included.
> > > > I have just completed the doing has been working since last fall :-)
> > >
> > > That's a big change. Can you give an example of what didn't work before
> > > and works now?
> >
> > Please see Test_visual_increment_27() ~ Test_visual_increment_34().
> > Below is ather exsample.
> >
> > Case 1 (Visual blockwise <C-A> with TAB and SPACE mixed)
> > - Manipulate
> > $ vim -Nu NONE
> > :call setline(1, ["1234 56", "\<TAB>78"])
> > :exec "norm! ggw\<C-V>jl\<C-A>"
> > - Expect result
> > "1234 57"
> > "\<TAB>79"
> > - Unpatched result
> > "1235 56"
> > "\<TAB>79"
>
>
> I see, thanks for fixing that.
>
> > > To make reviewing easier, it would be good to first make a patch to
> > > change the test from old to new style. Then we know the test works with
> > > the old code.
> >
> > Okay. I attached simple patch that only convert to new style test of
> > test_increment.
>
> Thanks. The original test had a nice explanation of what it was doing.
> Although the new style test do have the assert_equal() calls that make
> it easier to see what is going on, the commands themselves are still a
> bit of a puzzle. Since the explanations were already written, we can
> keep them. Using the comment above the test function should work well.
Indeed. I did it. Please check and include attached patch.
BTW, The following changes I thought happy for test_increment.vim.
How do you like it?
diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim
index 1c4cead..de1bda1 100644
--- a/src/testdir/runtest.vim
+++ b/src/testdir/runtest.vim
@@ -66,7 +66,7 @@ endif
redir @q
function /^Test_
redir END
-let tests = split(substitute(@q, 'function \(\k*()\)', '\1', 'g'))
+let tests = sort(split(substitute(@q, 'function \(\k*()\)', '\1', 'g')))
for test in tests
if exists("*SetUp")
--
Best regards,
Hirohito Higashi (a.k.a h_east)
--
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/Makefile b/src/Makefile
index f6b760f..3281572 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1944,7 +1944,6 @@ test1 \
test_erasebackword \
test_eval \
test_fixeol \
- test_increment \
test_insertcount \
test_listchars \
test_listlbr \
@@ -1980,6 +1979,8 @@ test1 \
test_assert \
test_backspace_opt \
test_cdo \
+ test_increment \
+ test_lispwords \
test_menu \
test_quickfix \
test_searchpos \
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index 2ad039c..f392451 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -102,7 +102,6 @@ SCRIPTS_ALL = \
test_erasebackword.out \
test_eval.out \
test_fixeol.out \
- test_increment.out \
test_insertcount.out \
test_listchars.out \
test_listlbr.out \
@@ -174,6 +173,7 @@ SCRIPTS_GUI = test16.out
# Keep test_alot.res as the last one, sort the others.
NEW_TESTS = test_assert.res \
test_cdo.res \
+ test_increment.res \
test_quickfix.res \
test_viml.res \
test_alot.res
diff --git a/src/testdir/test_increment.in b/src/testdir/test_increment.in
deleted file mode 100644
index f5d8ff9..0000000
--- a/src/testdir/test_increment.in
+++ /dev/null
@@ -1,734 +0,0 @@
-Tests for using Ctrl-A/Ctrl-X on visual selections
-
-Test cases
-==========
-
-1) Ctrl-A on visually selected number
-Text:
-foobar-10
- Expected:
- 1) Ctrl-A on start of line:
- foobar-9
- 2) Ctrl-A on visually selected "-10":
- foobar-9
- 3) Ctrl-A on visually selected "10":
- foobar-11
- 4) Ctrl-X on visually selected "-10"
- foobar-11
- 5) Ctrl-X on visually selected "10"
- foobar-9
-
-2) Ctrl-A on visually selected lines
-Text:
-10
-20
-30
-40
-
- Expected:
- 1) Ctrl-A on visually selected lines:
-11
-21
-31
-41
-
- 2) Ctrl-X on visually selected lines:
-9
-19
-29
-39
-
-3) g Ctrl-A on visually selected lines, with non-numbers in between
-Text:
-10
-
-20
-
-30
-
-40
-
- Expected:
- 1) 2 g Ctrl-A on visually selected lines:
-12
-
-24
-
-36
-
-48
- 2) 2 g Ctrl-X on visually selected lines
-8
-
-16
-
-24
-
-32
-
-4) Ctrl-A on non-number
-Text:
-foobar-10
- Expected:
- 1) visually select foobar:
- foobar-10
-
-5) g<Ctrl-A> on letter
-Test:
-a
-a
-a
-a
- Expected:
- 1) g Ctrl-A on visually selected lines
- b
- c
- d
- e
-
-6) g<Ctrl-A> on letter
-Test:
-z
-z
-z
-z
- Expected:
- 1) g Ctrl-X on visually selected lines
- y
- x
- w
- v
-
-7) <Ctrl-A> on letter
-Test:
-2
-1
-0
--1
--2
-
- Expected:
- 1) Ctrl-A on visually selected lines
- 3
- 2
- 1
- 0
- -1
-
- 2) Ctrl-X on visually selected lines
- 1
- 0
- -1
- -2
- -3
-8) Block increment on 0x9
-Text:
-0x9
-0x9
- Expected:
- 1) Ctrl-A on visually block selected region (cursor at beginning):
- 0xa
- 0xa
- 2) Ctrl-A on visually block selected region (cursor at end)
- 0xa
- 0xa
-
-9) Increment and redo
-Text:
-2
-2
-
-3
-3
-
- Expected:
- 1) 2 Ctrl-A on first 2 visually selected lines
- 4
- 4
- 2) redo (.) on 3
- 5
- 5
-10) sequentially decrement 1
-Text:
-1
-1
-1
-1
- Expected:
- 1) g Ctrl-X on visually selected lines
- 0
- -1
- -2
- -3
-
-11) visually block selected indented lines
-Text:
- 1
-1
- 1
- 1
- Expexted:
- 1) g Ctrl-A on block selected indented lines
- 2
-1
- 3
- 4
-
-12) visually selected several columns
-Text:
-0 0
-0 0
-0 0
- Expected:
- 1) 'v' select last zero and first zeroes
- 0 1
- 1 0
- 1 0
-
-13) visually selected part of columns
-Text:
-max: 100px
-max: 200px
-max: 300px
-max: 400px
- Expected:
- 1) 'v' on first two numbers Ctrl-A
- max: 110px
- max: 220px
- max: 330px
- max: 400px
- 2) 'v' on first two numbers Ctrl-X
- max: 90px
- max: 190px
- max: 290px
- max: 400px
-
-14) redo in block mode
-Text:
-1 1
-1 1
- Expected:
- 1) Ctrl-a on first column, redo on second column
- 2 2
- 2 2
-
-15) block select single numbers
-Text:
-101
- Expected:
- 1) Ctrl-a on visually selected zero
- 111
-
-16) increment right aligned numbers
-Text:
- 1
- 19
- 119
- Expected:
- 1) Ctrl-a on line selected region
- 2
- 20
- 120
-
-17) block-wise increment and redo
-Text:
- 100
- 1
-
- 100
- 1
-
- Expected:
- 1) Ctrl-V j $ on first block, afterwards '.' on second
- 101
- 2
-
- 101
- 2
-
-18) repeat of g<Ctrl-a>
-Text:
- 0
- 0
- 0
- 0
-
- Expected:
- 1) V 4j g<ctrl-a>, repeat twice afterwards with .
- 3
- 6
- 9
- 12
-
-19) increment on number with nrformat including alpha
-Text:
- 1
- 1a
-
- Expected:
- 1) <Ctrl-V>j$ <ctrl-a>
- 2
- 2a
-
-20) increment a single letter
-Text:
- a
-
- Expected:
- 1) <Ctrl-a> and cursor is on a
- b
-
-21) block-wise increment on part of hexadecimal
-Text:
-0x123456
-
- Expected:
- 1) Ctrl-V f3 <ctrl-a>
-0x124456
-
-22) Block increment on 0b0
-Text:
-0b1
-0b1
- Expected:
- 1) Ctrl-A on visually block selected region (cursor at beginning):
- 0b10
- 0b10
- 2) Ctrl-A on visually block selected region (cursor at end)
- 0b10
- 0b10
-
-23) block-wise increment on part of binary
-Text:
-0b1001
-
- Expected:
- 1) Ctrl-V 5l <ctrl-a>
-0b1011
-
-24) increment hexadecimal
-Text:
-0x0b1001
-
- Expected:
- 1) <ctrl-a>
-0x0b1002
-
-25) increment binary with nrformats including alpha
-Text:
-0b1001a
-
- Expected:
- 1) <ctrl-a>
-0b1010a
-
-26) increment binary with 64 bits
-Text:
-0b1111111111111111111111111111111111111111111111111111111111111110
-
- Expected:
- 1) <ctrl-a>
-0b1111111111111111111111111111111111111111111111111111111111111111
-
-
-STARTTEST
-:so small.vim
-:"
-:" Avoid CTRL-X being mapped in Visual mode for MS-Windows
-:vmapclear
-:"
-:" Test 1
-:/^S1=/+,/^E1=/-y a
-:/^E1=/+put a
-:/^E1=/+2put a
-f-v$:/^E1=/+3put a
-f1v$:/^E1=/+4put a
-f-v$:/^E1=/+5put a
-f1v$
-
-:" Test 2
-:/^S2=/+,/^E2=/-y a
-:/^E2=/+put a
-V3k$3j:.+put a
-V3k$
-
-:" Test 3
-:/^S3=/+,/^E3=/-y a
-:/^E3=/+put a
-V6k2g6j:.+put a
-V6k2g
-
-:" Test 4
-:/^S4=/+,/^E4=/-y a
-:/^E4=/+put a
-vf-
-
-:" Test 5
-:set nrformats+=alpha
-:/^S5=/+,/^E5=/-y a
-:/^E5=/+put a
-v3kg
-
-:" Test 6
-:/^S6=/+,/^E6=/-y a
-:/^E6=/+put a
-v3kg
-
-:" Test 7
-:set nrformats&vim
-:/^S7=/+,/^E7=/-y a
-:/^E7=/+put a
-V4k4j:.+put a
-V4k
-
-:" Test 8
-:/^S8=/+,/^E8=/-y a
-:/^E8=/+put a
-kj$j:.+put a
-k$+
-
-:" Test 9
-:/^S9=/+,/^E9=/-y a
-:/^E9=/+put a
-5kVj23j.
-
-:" Test 10
-:/^S10=/+,/^E10=/-y a
-:/^E10=/+put a
-V3kg
-
-: Test 11
-:/^S11=/+,/^E11=/-y a
-:/^E11=/+put a
-3kf13jg
-
-:" Test 12
-:/^S12=/+,/^E12=/-y a
-:/^E12=/+put a
-2k$v++
-
-:" Test 13
-:/^S13=/+,/^E13=/-y a
-:/^E13=/+put a
-3kf1l2j3j:.+put a
-3kf1l2j
-
-:" Test 14
-:/^S14=/+,/^E14=/-y a
-:/^E14=/+put a
-kw.
-
-:" Test 15
-:/^S15=/+,/^E15=/-y a
-:/^E15=/+put a
-lv
-
-:" Test 16
-:/^S16=/+,/^E16=/-y a
-:/^E16=/+put a
-V3k
-
-:" Test 17
-:/^S17=/+,/^E17=/-y a
-:/^E17=/+put a
-4kj$2j.
-
-:" Test 18
-:/^S18=/+,/^E18=/-y a
-:/^E18=/+put a
-V3kg..
-
-:" Test 19
-:set nrformats+=alpha
-:/^S19=/+,/^E19=/-y a
-:/^E19=/+put a
-k$
-:set nrformats&vim
-
-:" Test 20
-:set nrformats+=alpha
-:/^S20=/+,/^E20=/-y a
-:/^E20=/+put a
-:.put =col('.')
-:set nrformats&vim
-
-:" Test 21
-:/^S21=/+,/^E21=/-y a
-:/^E21=/+put a
-:set nrformats&vim
-f3
-
-:" Test 22
-:/^S22=/+,/^E22=/-y a
-:/^E22=/+put a
-kj$j:.+put a
-k$+
-
-:" Test 23
-:/^S23=/+,/^E23=/-y a
-:/^E23=/+put a
-:set nrformats&vim
-4l
-
-:" Test 24
-:/^S24=/+,/^E24=/-y a
-:/^E24=/+put a
-:set nrformats&vim
-$
-
-:" Test 25
-:set nrformats+=alpha
-:/^S25=/+,/^E25=/-y a
-:/^E25=/+put a
-k$
-:set nrformats&vim
-
-:" Test 26
-:set nrformats+=alpha
-:/^S26=/+,/^E26=/-y a
-:/^E26=/+put a
-k$
-:set nrformats&vim
-
-:" Save the report
-:/^# Test 1/,$w! test.out
-:qa!
-
-
-# Test 1
-S1======
-foobar-10
-E1======
-
-
-
-# Test 2
-S2=====
-10
-20
-30
-40
-E2=====
-
-
-
-# Test 3
-S3=====
-10
-
-20
-
-30
-
-40
-E3=====
-
-
-
-# Test 4
-S4=====
-foobar-10
-E4=====
-
-
-
-# Test 5
-S5====
-a
-a
-a
-a
-E5====
-
-
-# Test 6
-S6====
-z
-z
-z
-z
-E6====
-
-
-
-# Test 7
-S7====
-2
-1
-0
--1
--2
-E7====
-
-
-
-# Test 8
-S8====
-0x9
-0x9
-E8====
-
-
-
-
-# Test 9
-S9====
-2
-2
-
-3
-3
-
-E9====
-
-
-
-
-# Test 10
-S10====
-1
-1
-1
-1
-E10====
-
-
-
-
-# Test 11
-S11====
- 1
-1
- 1
- 1
-E11====
-
-
-
-# Test 12
-S12====
-0 0
-0 0
-0 0
-E12====
-
-
-
-# Test 13
-S13====
-max: 100px
-max: 200px
-max: 300px
-max: 400px
-E13====
-
-
-
-# Test 14
-S14====
-1 1
-1 1
-E14====
-
-
-
-# Test 15
-S15====
-101
-E15====
-
-
-
-# Test 16
-S16====
- 1
- 19
- 119
-E16====
-
-
-
-# Test 17
-S17====
- 100
- 1
-
- 100
- 1
-E17====
-
-
-# Test 18
-S18====
-0
-0
-0
-0
-E18====
-
-
-
-# Test 19
-S19====
-1
-1a
-E19====
-
-
-
-# Test 20
-S20====
-a
-E20====
-
-
-
-# Test 21
-S21====
-0x123456
-E21====
-
-
-
-# Test 22
-S22====
-0b1
-0b1
-E22====
-
-
-
-
-# Test 23
-S23====
-0b1001
-E23====
-
-
-
-
-# Test 24
-S24====
-0x0b1001
-E24====
-
-
-
-
-# Test 25
-S25====
-0b1001a
-E25====
-
-
-
-
-# Test 26
-S26====
-0b11111111111111111111111111111110
-E26====
-
-
-
-ENDTEST
-
diff --git a/src/testdir/test_increment.ok b/src/testdir/test_increment.ok
deleted file mode 100644
index 77ce9d4..0000000
--- a/src/testdir/test_increment.ok
+++ /dev/null
@@ -1,340 +0,0 @@
-# Test 1
-S1======
-foobar-10
-E1======
-
-foobar-9
-foobar-9
-foobar-11
-foobar-11
-foobar-9
-
-
-# Test 2
-S2=====
-10
-20
-30
-40
-E2=====
-
-11
-21
-31
-41
-
-9
-19
-29
-39
-
-# Test 3
-S3=====
-10
-
-20
-
-30
-
-40
-E3=====
-
-12
-
-24
-
-36
-
-48
-
-8
-
-16
-
-24
-
-32
-
-# Test 4
-S4=====
-foobar-10
-E4=====
-
-foobar-10
-
-
-# Test 5
-S5====
-a
-a
-a
-a
-E5====
-
-b
-c
-d
-e
-
-# Test 6
-S6====
-z
-z
-z
-z
-E6====
-
-y
-x
-w
-v
-
-
-# Test 7
-S7====
-2
-1
-0
--1
--2
-E7====
-
-3
-2
-1
-0
--1
-
-1
-0
--1
--2
--3
-
-# Test 8
-S8====
-0x9
-0x9
-E8====
-
-0xa
-0xa
-
-0xa
-0xa
-
-
-# Test 9
-S9====
-2
-2
-
-3
-3
-
-E9====
-
-4
-4
-
-5
-5
-
-
-
-
-# Test 10
-S10====
-1
-1
-1
-1
-E10====
-
-0
--1
--2
--3
-
-
-
-# Test 11
-S11====
- 1
-1
- 1
- 1
-E11====
-
- 2
-1
- 3
- 4
-
-
-# Test 12
-S12====
-0 0
-0 0
-0 0
-E12====
-
-0 1
-1 0
-1 0
-
-
-# Test 13
-S13====
-max: 100px
-max: 200px
-max: 300px
-max: 400px
-E13====
-
-max: 110px
-max: 210px
-max: 310px
-max: 400px
-
-max: 90px
-max: 190px
-max: 290px
-max: 400px
-
-# Test 14
-S14====
-1 1
-1 1
-E14====
-
-2 2
-2 2
-
-
-# Test 15
-S15====
-101
-E15====
-
-111
-
-
-# Test 16
-S16====
- 1
- 19
- 119
-E16====
-
- 2
- 20
- 120
-
-
-# Test 17
-S17====
- 100
- 1
-
- 100
- 1
-E17====
-
- 101
- 2
-
- 101
- 1
-
-# Test 18
-S18====
-0
-0
-0
-0
-E18====
-
-3
-6
-9
-12
-
-
-# Test 19
-S19====
-1
-1a
-E19====
-
-2
-2a
-
-
-# Test 20
-S20====
-a
-E20====
-
-b
-1
-
-
-# Test 21
-S21====
-0x123456
-E21====
-
-0x124456
-
-
-# Test 22
-S22====
-0b1
-0b1
-E22====
-
-0b10
-0b10
-
-0b10
-0b10
-
-
-# Test 23
-S23====
-0b1001
-E23====
-
-0b1011
-
-
-
-# Test 24
-S24====
-0x0b1001
-E24====
-
-0x0b1002
-
-
-
-# Test 25
-S25====
-0b1001a
-E25====
-
-0b1010a
-
-
-
-# Test 26
-S26====
-0b11111111111111111111111111111110
-E26====
-
-0b11111111111111111111111111111111
-
-
-ENDTEST
-
diff --git a/src/testdir/test_increment.vim b/src/testdir/test_increment.vim
new file mode 100644
index 0000000..ab75c1c
--- /dev/null
+++ b/src/testdir/test_increment.vim
@@ -0,0 +1,561 @@
+" Tests for using Ctrl-A/Ctrl-X on visual selections
+
+func SetUp()
+ new dummy
+ set nrformats&vim
+endfunc
+
+func TearDown()
+ bwipe!
+endfunc
+
+" 1) Ctrl-A on visually selected number
+" Text:
+" foobar-10
+" Expected:
+" 1) Ctrl-A on start of line:
+" foobar-9
+" 2) Ctrl-A on visually selected "-10":
+" foobar-9
+" 3) Ctrl-A on visually selected "10":
+" foobar-11
+" 4) Ctrl-X on visually selected "-10"
+" foobar-11
+" 5) Ctrl-X on visually selected "10"
+" foobar-9
+func Test_visual_increment_01()
+ call setline(1, repeat(["foobaar-10"], 5))
+
+ call cursor(1, 1)
+ exec "norm! \<C-A>"
+ call assert_equal("foobaar-9", getline('.'))
+ call assert_equal([0, 1, 9, 0], getpos('.'))
+
+ call cursor(2, 1)
+ exec "norm! f-v$\<C-A>"
+ call assert_equal("foobaar-9", getline('.'))
+ call assert_equal([0, 2, 8, 0], getpos('.'))
+
+ call cursor(3, 1)
+ exec "norm! f1v$\<C-A>"
+ call assert_equal("foobaar-11", getline('.'))
+ call assert_equal([0, 3, 9, 0], getpos('.'))
+
+ call cursor(4, 1)
+ exec "norm! f-v$\<C-X>"
+ call assert_equal("foobaar-11", getline('.'))
+ call assert_equal([0, 4, 8, 0], getpos('.'))
+
+ call cursor(5, 1)
+ exec "norm! f1v$\<C-X>"
+ call assert_equal("foobaar-9", getline('.'))
+ call assert_equal([0, 5, 9, 0], getpos('.'))
+endfunc
+
+" 2) Ctrl-A on visually selected lines
+" Text:
+" 10
+" 20
+" 30
+" 40
+"
+" Expected:
+" 1) Ctrl-A on visually selected lines:
+" 11
+" 21
+" 31
+" 41
+"
+" 2) Ctrl-X on visually selected lines:
+" 9
+" 19
+" 29
+" 39
+func Test_visual_increment_02()
+ call setline(1, ["10", "20", "30", "40"])
+ exec "norm! GV3k$\<C-A>"
+ call assert_equal(["11", "21", "31", "41"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ call setline(1, ["10", "20", "30", "40"])
+ exec "norm! GV3k$\<C-X>"
+ call assert_equal(["9", "19", "29", "39"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 3) g Ctrl-A on visually selected lines, with non-numbers in between
+" Text:
+" 10
+"
+" 20
+"
+" 30
+"
+" 40
+"
+" Expected:
+" 1) 2 g Ctrl-A on visually selected lines:
+" 12
+"
+" 24
+"
+" 36
+"
+" 48
+" 2) 2 g Ctrl-X on visually selected lines
+" 8
+"
+" 16
+"
+" 24
+"
+" 32
+func Test_visual_increment_03()
+ call setline(1, ["10", "", "20", "", "30", "", "40"])
+ exec "norm! GV6k2g\<C-A>"
+ call assert_equal(["12", "", "24", "", "36", "", "48"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ call setline(1, ["10", "", "20", "", "30", "", "40"])
+ exec "norm! GV6k2g\<C-X>"
+ call assert_equal(["8", "", "16", "", "24", "", "32"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 4) Ctrl-A on non-number
+" Text:
+" foobar-10
+" Expected:
+" 1) visually select foobar:
+" foobar-10
+func Test_visual_increment_04()
+ call setline(1, ["foobar-10"])
+ exec "norm! vf-\<C-A>"
+ call assert_equal(["foobar-10"], getline(1, '$'))
+ " NOTE: I think this is correct behavior...
+ "call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 5) g<Ctrl-A> on letter
+" Test:
+" a
+" a
+" a
+" a
+" Expected:
+" 1) g Ctrl-A on visually selected lines
+" b
+" c
+" d
+" e
+func Test_visual_increment_05()
+ set nrformats+=alpha
+ call setline(1, repeat(["a"], 4))
+ exec "norm! GV3kg\<C-A>"
+ call assert_equal(["b", "c", "d", "e"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 6) g<Ctrl-A> on letter
+" Test:
+" z
+" z
+" z
+" z
+" Expected:
+" 1) g Ctrl-X on visually selected lines
+" y
+" x
+" w
+" v
+func Test_visual_increment_06()
+ set nrformats+=alpha
+ call setline(1, repeat(["z"], 4))
+ exec "norm! GV3kg\<C-X>"
+ call assert_equal(["y", "x", "w", "v"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 7) <Ctrl-A> on letter
+" Test:
+" 2
+" 1
+" 0
+" -1
+" -2
+"
+" Expected:
+" 1) Ctrl-A on visually selected lines
+" 3
+" 2
+" 1
+" 0
+" -1
+"
+" 2) Ctrl-X on visually selected lines
+" 1
+" 0
+" -1
+" -2
+" -3
+func Test_visual_increment_07()
+ call setline(1, ["2", "1", "0", "-1", "-2"])
+ exec "norm! GV4k\<C-A>"
+ call assert_equal(["3", "2", "1", "0", "-1"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ call setline(1, ["2", "1", "0", "-1", "-2"])
+ exec "norm! GV4k\<C-X>"
+ call assert_equal(["1", "0", "-1", "-2", "-3"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 8) Block increment on 0x9
+" Text:
+" 0x9
+" 0x9
+" Expected:
+" 1) Ctrl-A on visually block selected region (cursor at beginning):
+" 0xa
+" 0xa
+" 2) Ctrl-A on visually block selected region (cursor at end)
+" 0xa
+" 0xa
+func Test_visual_increment_08()
+ call setline(1, repeat(["0x9"], 2))
+ exec "norm! \<C-V>j$\<C-A>"
+ call assert_equal(["0xa", "0xa"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ call setline(1, repeat(["0x9"], 2))
+ exec "norm! gg$\<C-V>+\<C-A>"
+ call assert_equal(["0xa", "0xa"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 9) Increment and redo
+" Text:
+" 2
+" 2
+"
+" 3
+" 3
+"
+" Expected:
+" 1) 2 Ctrl-A on first 2 visually selected lines
+" 4
+" 4
+" 2) redo (.) on 3
+" 5
+" 5
+func Test_visual_increment_09()
+ call setline(1, ["2", "2", "", "3", "3", ""])
+ exec "norm! ggVj2\<C-A>"
+ call assert_equal(["4", "4", "", "3", "3", ""], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ exec "norm! 3j."
+ call assert_equal(["4", "4", "", "5", "5", ""], getline(1, '$'))
+ call assert_equal([0, 4, 1, 0], getpos('.'))
+endfunc
+
+" 10) sequentially decrement 1
+" Text:
+" 1
+" 1
+" 1
+" 1
+" Expected:
+" 1) g Ctrl-X on visually selected lines
+" 0
+" -1
+" -2
+" -3
+func Test_visual_increment_10()
+ call setline(1, repeat(["1"], 4))
+ exec "norm! GV3kg\<C-X>"
+ call assert_equal(["0", "-1", "-2", "-3"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 11) visually block selected indented lines
+" Text:
+" 1
+" 1
+" 1
+" 1
+" Expexted:
+" 1) g Ctrl-A on block selected indented lines
+" 2
+" 1
+" 3
+" 4
+func Test_visual_increment_11()
+ call setline(1, [" 1", "1", " 1", " 1"])
+ exec "norm! f1\<C-V>3jg\<C-A>"
+ call assert_equal([" 2", "1", " 3", " 4"], getline(1, '$'))
+ call assert_equal([0, 1, 5, 0], getpos('.'))
+endfunc
+
+" 12) visually selected several columns
+" Text:
+" 0 0
+" 0 0
+" 0 0
+" Expected:
+" 1) 'v' select last zero and first zeroes
+" 0 1
+" 1 0
+" 1 0
+func Test_visual_increment_12()
+ call setline(1, repeat(["0 0"], 3))
+ exec "norm! $v++\<C-A>"
+ call assert_equal(["0 1", "1 0", "1 0"], getline(1, '$'))
+ call assert_equal([0, 1, 3, 0], getpos('.'))
+endfunc
+
+" 13) visually selected part of columns
+" Text:
+" max: 100px
+" max: 200px
+" max: 300px
+" max: 400px
+" Expected:
+" 1) 'v' on first two numbers Ctrl-A
+" max: 110px
+" max: 220px
+" max: 330px
+" max: 400px
+" 2) 'v' on first two numbers Ctrl-X
+" max: 90px
+" max: 190px
+" max: 290px
+" max: 400px
+func Test_visual_increment_13()
+ call setline(1, ["max: 100px", "max: 200px", "max: 300px", "max: 400px"])
+ exec "norm! f1\<C-V>l2j\<C-A>"
+ call assert_equal(["max: 110px", "max: 210px", "max: 310px", "max: 400px"], getline(1, '$'))
+ call assert_equal([0, 1, 6, 0], getpos('.'))
+
+ call setline(1, ["max: 100px", "max: 200px", "max: 300px", "max: 400px"])
+ exec "norm! ggf1\<C-V>l2j\<C-X>"
+ call assert_equal(["max: 90px", "max: 190px", "max: 290px", "max: 400px"], getline(1, '$'))
+ call assert_equal([0, 1, 6, 0], getpos('.'))
+endfunc
+
+" 14) redo in block mode
+" Text:
+" 1 1
+" 1 1
+" Expected:
+" 1) Ctrl-a on first column, redo on second column
+" 2 2
+" 2 2
+func Test_visual_increment_14()
+ call setline(1, repeat(["1 1"], 2))
+ exec "norm! G\<C-V>k\<C-A>w."
+ call assert_equal(["2 2", "2 2"], getline(1, '$'))
+ call assert_equal([0, 1, 3, 0], getpos('.'))
+endfunc
+
+" 15) block select single numbers
+" Text:
+" 101
+" Expected:
+" 1) Ctrl-a on visually selected zero
+" 111
+func Test_visual_increment_15()
+ call setline(1, ["101"])
+ exec "norm! lv\<C-A>"
+ call assert_equal(["111"], getline(1, '$'))
+ call assert_equal([0, 1, 2, 0], getpos('.'))
+endfunc
+
+" 16) increment right aligned numbers
+" Text:
+" 1
+" 19
+" 119
+" Expected:
+" 1) Ctrl-a on line selected region
+" 2
+" 20
+" 120
+func Test_visual_increment_16()
+ call setline(1, [" 1", " 19", " 119"])
+ exec "norm! VG\<C-A>"
+ call assert_equal([" 2", " 20", " 120"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 17) block-wise increment and redo
+" Text:
+" 100
+" 1
+"
+" 100
+" 1
+"
+" Expected:
+" 1) Ctrl-V j $ on first block, afterwards '.' on second
+" 101
+" 2
+"
+" 101
+" 2
+func Test_visual_increment_17()
+ call setline(1, [" 100", " 1", "", " 100", " 1"])
+ exec "norm! \<C-V>j$\<C-A>2j."
+ call assert_equal([" 101", " 2", "", " 101", " 1"], getline(1, '$'))
+ call assert_equal([0, 3, 1, 0], getpos('.'))
+endfunc
+
+" 18) repeat of g<Ctrl-a>
+" Text:
+" 0
+" 0
+" 0
+" 0
+"
+" Expected:
+" 1) V 4j g<ctrl-a>, repeat twice afterwards with .
+" 3
+" 6
+" 9
+" 12
+func Test_visual_increment_18()
+ call setline(1, repeat(["0"], 4))
+ exec "norm! GV3kg\<C-A>"
+ exec "norm! .."
+ call assert_equal(["3", "6", "9", "12"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 19) increment on number with nrformat including alpha
+" Text:
+" 1
+" 1a
+"
+" Expected:
+" 1) <Ctrl-V>j$ <ctrl-a>
+" 2
+" 2a
+func Test_visual_increment_19()
+ set nrformats+=alpha
+ call setline(1, ["1", "1a"])
+ exec "norm! \<C-V>G$\<C-A>"
+ call assert_equal(["2", "2a"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 20) increment a single letter
+" Text:
+" a
+"
+" Expected:
+" 1) <Ctrl-a> and cursor is on a
+" b
+func Test_visual_increment_20()
+ set nrformats+=alpha
+ call setline(1, ["a"])
+ exec "norm! \<C-A>"
+ call assert_equal(["b"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 21) block-wise increment on part of hexadecimal
+" Text:
+" 0x123456
+"
+" Expected:
+" 1) Ctrl-V f3 <ctrl-a>
+" 0x124456
+func Test_visual_increment_21()
+ call setline(1, ["0x123456"])
+ exec "norm! \<C-V>f3\<C-A>"
+ call assert_equal(["0x124456"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 22) Block increment on 0b0
+" Text:
+" 0b1
+" 0b1
+" Expected:
+" 1) Ctrl-A on visually block selected region (cursor at beginning):
+" 0b10
+" 0b10
+" 2) Ctrl-A on visually block selected region (cursor at end)
+" 0b10
+" 0b10
+func Test_visual_increment_22()
+ call setline(1, repeat(["0b1"], 2))
+ exec "norm! \<C-V>j$\<C-A>"
+ call assert_equal(repeat(["0b10"], 2), getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+
+ call setline(1, repeat(["0b1"], 2))
+ exec "norm! $\<C-V>+\<C-A>"
+ call assert_equal(repeat(["0b10"], 2), getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 23) block-wise increment on part of binary
+" Text:
+" 0b1001
+"
+" Expected:
+" 1) Ctrl-V 5l <ctrl-a>
+" 0b1011
+func Test_visual_increment_23()
+ call setline(1, ["0b1001"])
+ exec "norm! \<C-V>4l\<C-A>"
+ call assert_equal(["0b1011"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 24) increment hexadecimal
+" Text:
+" 0x0b1001
+"
+" Expected:
+" 1) <ctrl-a>
+" 0x0b1002
+func Test_visual_increment_24()
+ call setline(1, ["0x0b1001"])
+ exec "norm! \<C-V>$\<C-A>"
+ call assert_equal(["0x0b1002"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 25) increment binary with nrformats including alpha
+" Text:
+" 0b1001a
+"
+" Expected:
+" 1) <ctrl-a>
+" 0b1010a
+func Test_visual_increment_25()
+ set nrformats+=alpha
+ call setline(1, ["0b1001a"])
+ exec "norm! \<C-V>$\<C-A>"
+ call assert_equal(["0b1010a"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" 26) increment binary with 32 bits
+" Text:
+" 0b11111111111111111111111111111110
+"
+" Expected:
+" 1) <ctrl-a>
+" 0b11111111111111111111111111111111
+func Test_visual_increment_26()
+ set nrformats+=alpha
+ call setline(1, ["0b11111111111111111111111111111110"])
+ exec "norm! \<C-V>$\<C-A>"
+ call assert_equal(["0b11111111111111111111111111111111"], getline(1, '$'))
+ call assert_equal([0, 1, 1, 0], getpos('.'))
+endfunc
+
+" vim: tabstop=2 shiftwidth=2 expandtab