Patch 8.2.3398

5 views
Skip to first unread message

Bram Moolenaar

unread,
Sep 3, 2021, 10:50:58 AM9/3/21
to vim...@googlegroups.com

Patch 8.2.3398
Problem: Html text objects are not fully tested.
Solution: Add tests for dbcs encoding and different number of backslashes.
(Dominique Pellé, closes #8831)
Files: src/testdir/test_textobjects.vim


*** ../vim-8.2.3397/src/testdir/test_textobjects.vim 2021-07-31 13:31:37.327213783 +0200
--- src/testdir/test_textobjects.vim 2021-09-03 16:48:18.635852337 +0200
***************
*** 88,188 ****

" Tests for string and html text objects
func Test_string_html_objects()
- enew!

! let t = '"wo\"rd\\" foo'
! put =t
! normal! da"
! call assert_equal('foo', getline('.'))
!
! let t = "'foo' 'bar' 'piep'"
! put =t
! normal! 0va'a'rx
! call assert_equal("xxxxxxxxxxxx'piep'", getline('.'))
!
! let t = "bla bla `quote` blah"
! put =t
! normal! 02f`da`
! call assert_equal("bla bla blah", getline('.'))
!
! let t = 'out " in "noXno"'
! put =t
! normal! 0fXdi"
! call assert_equal('out " in ""', getline('.'))
!
! let t = "\"'\" 'blah' rep 'buh'"
! put =t
! normal! 03f'vi'ry
! call assert_equal("\"'\" 'blah'yyyyy'buh'", getline('.'))
!
! set quoteescape=+*-
! let t = "bla `s*`d-`+++`l**` b`la"
! put =t
! normal! di`
! call assert_equal("bla `` b`la", getline('.'))
!
! let t = 'voo "nah" sdf " asdf" sdf " sdf" sd'
! put =t
! normal! $F"va"oha"i"rz
! call assert_equal('voo "zzzzzzzzzzzzzzzzzzzzzzzzzzzzsd', getline('.'))
!
! let t = "-<b>asdf<i>Xasdf</i>asdf</b>-"
! put =t
! normal! fXdit
! call assert_equal('-<b>asdf<i></i>asdf</b>-', getline('.'))
!
! let t = "-<b>asdX<i>a<i />sdf</i>asdf</b>-"
! put =t
! normal! 0fXdit
! call assert_equal('-<b></b>-', getline('.'))
!
! let t = "-<b>asdf<i>Xasdf</i>asdf</b>-"
! put =t
! normal! fXdat
! call assert_equal('-<b>asdfasdf</b>-', getline('.'))
!
! let t = "-<b>asdX<i>as<b />df</i>asdf</b>-"
! put =t
! normal! 0fXdat
! call assert_equal('--', getline('.'))
!
! let t = "-<b>\ninnertext object\n</b>"
! put =t
! normal! dit
! call assert_equal('-<b></b>', getline('.'))
!
! " copy the tag block from leading indentation before the start tag
! let t = " <b>\ntext\n</b>"
! $put =t
! normal! 2kvaty
! call assert_equal("<b>\ntext\n</b>", @")
!
! " copy the tag block from the end tag
! let t = "<title>\nwelcome\n</title>"
! $put =t
! normal! $vaty
! call assert_equal("<title>\nwelcome\n</title>", @")
!
! " copy the outer tag block from a tag without an end tag
! let t = "<html>\n<title>welcome\n</html>"
! $put =t
! normal! k$vaty
! call assert_equal("<html>\n<title>welcome\n</html>", @")
!
! " nested tag that has < in a different line from >
! let t = "<div><div\n></div></div>"
! $put =t
! normal! k0vaty
! call assert_equal("<div><div\n></div></div>", @")
!
! " nested tag with attribute that has < in a different line from >
! let t = "<div><div\nattr=\"attr\"\n></div></div>"
! $put =t
! normal! 2k0vaty
! call assert_equal("<div><div\nattr=\"attr\"\n></div></div>", @")

! set quoteescape&
! enew!
endfunc

func Test_empty_html_tag()
--- 88,194 ----

" Tests for string and html text objects
func Test_string_html_objects()

! for e in ['utf-8', 'latin1', 'cp932']
! enew!
! exe 'set enc=' .. e
!
! let t = '"wo\"rd\\" foo'
! put =t
! normal! da"
! call assert_equal('foo', getline('.'), e)
!
! let t = "'foo' 'bar' 'piep'"
! put =t
! normal! 0va'a'rx
! call assert_equal("xxxxxxxxxxxx'piep'", getline('.'), e)
!
! let t = "bla bla `quote` blah"
! put =t
! normal! 02f`da`
! call assert_equal("bla bla blah", getline('.'), e)
!
! let t = 'out " in "noXno"'
! put =t
! normal! 0fXdi"
! call assert_equal('out " in ""', getline('.'), e)
!
! let t = "\"'\" 'blah' rep 'buh'"
! put =t
! normal! 03f'vi'ry
! call assert_equal("\"'\" 'blah'yyyyy'buh'", getline('.'), e)
!
! set quoteescape=+*-
! let t = "bla `s*`d-`+++`l**` b`la"
! put =t
! normal! di`
! call assert_equal("bla `` b`la", getline('.'), e)
!
! let t = 'voo "nah" sdf " asdf" sdf " sdf" sd'
! put =t
! normal! $F"va"oha"i"rz
! call assert_equal('voo "zzzzzzzzzzzzzzzzzzzzzzzzzzzzsd', getline('.'), e)
!
! let t = "-<b>asdf<i>Xasdf</i>asdf</b>-"
! put =t
! normal! fXdit
! call assert_equal('-<b>asdf<i></i>asdf</b>-', getline('.'), e)
!
! let t = "-<b>asdX<i>a<i />sdf</i>asdf</b>-"
! put =t
! normal! 0fXdit
! call assert_equal('-<b></b>-', getline('.'), e)
!
! let t = "-<b>asdf<i>Xasdf</i>asdf</b>-"
! put =t
! normal! fXdat
! call assert_equal('-<b>asdfasdf</b>-', getline('.'), e)
!
! let t = "-<b>asdX<i>as<b />df</i>asdf</b>-"
! put =t
! normal! 0fXdat
! call assert_equal('--', getline('.'), e)
!
! let t = "-<b>\ninnertext object\n</b>"
! put =t
! normal! dit
! call assert_equal('-<b></b>', getline('.'), e)
!
! " copy the tag block from leading indentation before the start tag
! let t = " <b>\ntext\n</b>"
! $put =t
! normal! 2kvaty
! call assert_equal("<b>\ntext\n</b>", @", e)
!
! " copy the tag block from the end tag
! let t = "<title>\nwelcome\n</title>"
! $put =t
! normal! $vaty
! call assert_equal("<title>\nwelcome\n</title>", @", e)
!
! " copy the outer tag block from a tag without an end tag
! let t = "<html>\n<title>welcome\n</html>"
! $put =t
! normal! k$vaty
! call assert_equal("<html>\n<title>welcome\n</html>", @", e)
!
! " nested tag that has < in a different line from >
! let t = "<div><div\n></div></div>"
! $put =t
! normal! k0vaty
! call assert_equal("<div><div\n></div></div>", @", e)
!
! " nested tag with attribute that has < in a different line from >
! let t = "<div><div\nattr=\"attr\"\n></div></div>"
! $put =t
! normal! 2k0vaty
! call assert_equal("<div><div\nattr=\"attr\"\n></div></div>", @", e)

! set quoteescape&
! endfor
!
! set enc=utf-8
! bwipe!
endfunc

func Test_empty_html_tag()
***************
*** 561,566 ****
--- 567,586 ----
normal 0ya'
call assert_equal(" 'special'", @")

+ " quoted string with odd or even number of backslashes.
+ call setline(1, 'char *s = "foo\"bar"')
+ normal $hhyi"
+ call assert_equal('foo\"bar', @")
+ call setline(1, 'char *s = "foo\\"bar"')
+ normal $hhyi"
+ call assert_equal('bar', @")
+ call setline(1, 'char *s = "foo\\\"bar"')
+ normal $hhyi"
+ call assert_equal('foo\\\"bar', @")
+ call setline(1, 'char *s = "foo\\\\"bar"')
+ normal $hhyi"
+ call assert_equal('bar', @")
+
close!
endfunc

*** ../vim-8.2.3397/src/version.c 2021-09-02 20:05:22.925120220 +0200
--- src/version.c 2021-09-03 16:49:50.639653017 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3398,
/**/

--
Sometimes you can protect millions of dollars in your budget simply by buying
a bag of cookies, dropping it on the budget anylyst's desk, and saying
something deeply personal such as "How was your weekend, big guy?"
(Scott Adams - The Dilbert principle)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages