Patchwork D7431: tests: document behavior of indent() with empty first line

login
register
mail settings
Submitter phabricator
Date Nov. 15, 2019, 6:18 p.m.
Message ID <differential-rev-PHID-DREV-crjoneggnf4lhi5qosod-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43278/
State Superseded
Headers show

Comments

phabricator - Nov. 15, 2019, 6:18 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  indent() is documented to indent all non-empty lines, but it still
  indents the first line even if it's empty. Let's have tests for that.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7431

AFFECTED FILES
  tests/test-template-functions.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-template-functions.t b/tests/test-template-functions.t
--- a/tests/test-template-functions.t
+++ b/tests/test-template-functions.t
@@ -1504,6 +1504,21 @@ 
   
   >> other 3
 
+Test indent with empty first line
+
+  $ hg version -T "{indent('', '>> ')}\n"
+  >> 
+
+  $ hg version -T "{indent('
+  > second', '>> ')}\n"
+  >> 
+  >> second
+
+  $ hg version -T "{indent('
+  > second', '>> ', ' > ')}\n"
+   > 
+  >> second
+
 Test with non-strings like dates
 
   $ hg log -T "{indent(date, '   ')}\n" -r 2:3 -R a