diff src/testdir/test_normal.vim @ 16720:9c90cf08cfa8 v8.1.1362

patch 8.1.1362: code and data in tests can be hard to read commit https://github.com/vim/vim/commit/c79745a82faeb5a6058e915ca49a4c69fa60ea01 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 20 22:12:34 2019 +0200 patch 8.1.1362: code and data in tests can be hard to read Problem: Code and data in tests can be hard to read. Solution: Use the new heredoc style. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4400)
author Bram Moolenaar <Bram@vim.org>
date Mon, 20 May 2019 22:15:06 +0200
parents aebcd20a8a3f
children 6990c1160ea5
line wrap: on
line diff
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -1555,73 +1555,158 @@ endfunc
 
 fun! Test_normal29_brace()
   " basic test for { and } movements
-  let text= ['A paragraph begins after each empty line, and also at each of a set of',
-  \ 'paragraph macros, specified by the pairs of characters in the ''paragraphs''',
-  \ 'option.  The default is "IPLPPPQPP TPHPLIPpLpItpplpipbp", which corresponds to',
-  \ 'the macros ".IP", ".LP", etc.  (These are nroff macros, so the dot must be in',
-  \ 'the first column).  A section boundary is also a paragraph boundary.',
-  \ 'Note that a blank line (only containing white space) is NOT a paragraph',
-  \ 'boundary.',
-  \ '',
-  \ '',
-  \ 'Also note that this does not include a ''{'' or ''}'' in the first column.  When',
-  \ 'the ''{'' flag is in ''cpoptions'' then ''{'' in the first column is used as a',
-  \ 'paragraph boundary |posix|.',
-  \ '{',
-  \ 'This is no paragraph',
-  \ 'unless the ''{'' is set',
-  \ 'in ''cpoptions''',
-  \ '}',
-  \ '.IP',
-  \ 'The nroff macros IP separates a paragraph',
-  \ 'That means, it must be a ''.''',
-  \ 'followed by IP',
-  \ '.LPIt does not matter, if afterwards some',
-  \ 'more characters follow.',
-  \ '.SHAlso section boundaries from the nroff',
-  \ 'macros terminate a paragraph. That means',
-  \ 'a character like this:',
-  \ '.NH',
-  \ 'End of text here']
+  let text =<< trim [DATA]
+  A paragraph begins after each empty line, and also at each of a set of
+  paragraph macros, specified by the pairs of characters in the 'paragraphs'
+  option.  The default is "IPLPPPQPP TPHPLIPpLpItpplpipbp", which corresponds to
+  the macros ".IP", ".LP", etc.  (These are nroff macros, so the dot must be in
+  the first column).  A section boundary is also a paragraph boundary.
+  Note that a blank line (only containing white space) is NOT a paragraph
+  boundary.
+
+
+  Also note that this does not include a '{' or '}' in the first column.  When
+  the '{' flag is in 'cpoptions' then '{' in the first column is used as a
+  paragraph boundary |posix|.
+  {
+  This is no paragraph
+  unless the '{' is set
+  in 'cpoptions'
+  }
+  .IP
+  The nroff macros IP separates a paragraph
+  That means, it must be a '.'
+  followed by IP
+  .LPIt does not matter, if afterwards some
+  more characters follow.
+  .SHAlso section boundaries from the nroff
+  macros terminate a paragraph. That means
+  a character like this:
+  .NH
+  End of text here
+  [DATA]
+
   new
   call append(0, text)
   1
   norm! 0d2}
-  call assert_equal(['.IP',
-    \  'The nroff macros IP separates a paragraph', 'That means, it must be a ''.''', 'followed by IP',
-    \ '.LPIt does not matter, if afterwards some', 'more characters follow.', '.SHAlso section boundaries from the nroff',
-    \  'macros terminate a paragraph. That means', 'a character like this:', '.NH', 'End of text here', ''], getline(1,'$'))
+
+  let expected =<< trim [DATA]
+  .IP
+  The nroff macros IP separates a paragraph
+  That means, it must be a '.'
+  followed by IP
+  .LPIt does not matter, if afterwards some
+  more characters follow.
+  .SHAlso section boundaries from the nroff
+  macros terminate a paragraph. That means
+  a character like this:
+  .NH
+  End of text here
+
+  [DATA]
+  call assert_equal(expected, getline(1, '$'))
+
   norm! 0d}
-  call assert_equal(['.LPIt does not matter, if afterwards some', 'more characters follow.',
-    \ '.SHAlso section boundaries from the nroff', 'macros terminate a paragraph. That means',
-    \ 'a character like this:', '.NH', 'End of text here', ''], getline(1, '$'))
+
+  let expected =<< trim [DATA]
+  .LPIt does not matter, if afterwards some
+  more characters follow.
+  .SHAlso section boundaries from the nroff
+  macros terminate a paragraph. That means
+  a character like this:
+  .NH
+  End of text here
+
+  [DATA]
+  call assert_equal(expected, getline(1, '$'))
+
   $
   norm! d{
-  call assert_equal(['.LPIt does not matter, if afterwards some', 'more characters follow.',
-	\ '.SHAlso section boundaries from the nroff', 'macros terminate a paragraph. That means', 'a character like this:', ''], getline(1, '$'))
+
+  let expected =<< trim [DATA]
+  .LPIt does not matter, if afterwards some
+  more characters follow.
+  .SHAlso section boundaries from the nroff
+  macros terminate a paragraph. That means
+  a character like this:
+
+  [DATA]
+  call assert_equal(expected, getline(1, '$'))
+
   norm! d{
-  call assert_equal(['.LPIt does not matter, if afterwards some', 'more characters follow.', ''], getline(1,'$'))
+
+  let expected =<< trim [DATA]
+  .LPIt does not matter, if afterwards some
+  more characters follow.
+
+  [DATA]
+  call assert_equal(expected, getline(1, '$'))
+
   " Test with { in cpooptions
   %d
   call append(0, text)
   set cpo+={
   1
   norm! 0d2}
-  call assert_equal(['{', 'This is no paragraph', 'unless the ''{'' is set', 'in ''cpoptions''', '}',
-    \ '.IP', 'The nroff macros IP separates a paragraph', 'That means, it must be a ''.''',
-    \ 'followed by IP', '.LPIt does not matter, if afterwards some', 'more characters follow.',
-    \ '.SHAlso section boundaries from the nroff', 'macros terminate a paragraph. That means',
-    \ 'a character like this:', '.NH', 'End of text here', ''], getline(1,'$'))
+
+  let expected =<< trim [DATA]
+  {
+  This is no paragraph
+  unless the '{' is set
+  in 'cpoptions'
+  }
+  .IP
+  The nroff macros IP separates a paragraph
+  That means, it must be a '.'
+  followed by IP
+  .LPIt does not matter, if afterwards some
+  more characters follow.
+  .SHAlso section boundaries from the nroff
+  macros terminate a paragraph. That means
+  a character like this:
+  .NH
+  End of text here
+
+  [DATA]
+  call assert_equal(expected, getline(1, '$'))
+
   $
   norm! d}
-  call assert_equal(['{', 'This is no paragraph', 'unless the ''{'' is set', 'in ''cpoptions''', '}',
-    \ '.IP', 'The nroff macros IP separates a paragraph', 'That means, it must be a ''.''',
-    \ 'followed by IP', '.LPIt does not matter, if afterwards some', 'more characters follow.',
-    \ '.SHAlso section boundaries from the nroff', 'macros terminate a paragraph. That means',
-    \ 'a character like this:', '.NH', 'End of text here', ''], getline(1,'$'))
+
+  let expected =<< trim [DATA]
+  {
+  This is no paragraph
+  unless the '{' is set
+  in 'cpoptions'
+  }
+  .IP
+  The nroff macros IP separates a paragraph
+  That means, it must be a '.'
+  followed by IP
+  .LPIt does not matter, if afterwards some
+  more characters follow.
+  .SHAlso section boundaries from the nroff
+  macros terminate a paragraph. That means
+  a character like this:
+  .NH
+  End of text here
+
+  [DATA]
+  call assert_equal(expected, getline(1, '$'))
+
   norm! gg}
   norm! d5}
-  call assert_equal(['{', 'This is no paragraph', 'unless the ''{'' is set', 'in ''cpoptions''', '}', ''], getline(1,'$'))
+
+  let expected =<< trim [DATA]
+  {
+  This is no paragraph
+  unless the '{' is set
+  in 'cpoptions'
+  }
+
+  [DATA]
+  call assert_equal(expected, getline(1, '$'))
 
   " clean up
   set cpo-={