Mercurial > hg
diff tests/test-command-template.t @ 37015:a318bb154d42
templatefuncs: do not stringify result of if*() expression
Returning a generator means that the result is a byte string. I can't find
any reason to make the "if" condition lazy since it is evaluated anyway
when {if()} has to be evaluated. So let's simply make if*() return an input
expression unmodified.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 19 Mar 2018 22:10:40 +0900 |
parents | 1b179d151578 |
children | e7bc0667c521 |
line wrap: on
line diff
--- a/tests/test-command-template.t Mon Mar 19 21:55:02 2018 +0900 +++ b/tests/test-command-template.t Mon Mar 19 22:10:40 2018 +0900 @@ -3242,6 +3242,35 @@ $ hg log -R latesttag -l1 -T '{max(revset("9:10"))}\n' 10 +Test min/max of if() result + + $ cd latesttag + $ hg log -l1 -T '{min(if(true, revset("9:10"), ""))}\n' + 9 + $ hg log -l1 -T '{max(if(false, "", revset("9:10")))}\n' + 10 + $ hg log -l1 -T '{min(ifcontains("a", "aa", revset("9:10"), ""))}\n' + 9 + $ hg log -l1 -T '{max(ifcontains("a", "bb", "", revset("9:10")))}\n' + 10 + $ hg log -l1 -T '{min(ifeq(0, 0, revset("9:10"), ""))}\n' + 9 + $ hg log -l1 -T '{max(ifeq(0, 1, "", revset("9:10")))}\n' + 10 + $ cd .. + +Test laziness of if() then/else clause + + $ hg debugtemplate '{count(0)}' + abort: incompatible use of template filter 'count' + [255] + $ hg debugtemplate '{if(true, "", count(0))}' + $ hg debugtemplate '{if(false, count(0), "")}' + $ hg debugtemplate '{ifcontains("a", "aa", "", count(0))}' + $ hg debugtemplate '{ifcontains("a", "bb", count(0), "")}' + $ hg debugtemplate '{ifeq(0, 0, "", count(0))}' + $ hg debugtemplate '{ifeq(0, 1, count(0), "")}' + Test dot operator precedence: $ hg debugtemplate -R latesttag -r0 -v '{manifest.node|short}\n'