view src/testdir/test_increment.in @ 7094:66137191901a v7.4.859

commit https://github.com/vim/vim/commit/d8986fd91494642b3bab305406aa55268498f49c Author: Bram Moolenaar <Bram@vim.org> Date: Tue Sep 8 19:10:55 2015 +0200 patch 7.4.859 Problem: Vim doesn't recognize all htmldjango files. Solution: Recognize a comment. (Daniel Hahler, PR #410)
author Christian Brabandt <cb@256bit.org>
date Tue, 08 Sep 2015 19:15:04 +0200
parents 05afb5be93bd
children ad432f8f68fb
line wrap: on
line source

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



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

:" 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====




ENDTEST