From patchwork Mon Sep 8 12:06:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,3] templater: test len filter From: Anton Shestakov X-Patchwork-Id: 5723 Message-Id: <3311151410177964@web19g.yandex.ru> To: "mercurial-devel@selenic.com" Date: Mon, 08 Sep 2014 21:06:04 +0900 # HG changeset patch # User Anton Shestakov # Date 1410177351 -32400 # Mon Sep 08 20:55:51 2014 +0900 # Node ID 5ca21458ca0863fd9aec7c643e11443da11d6190 # Parent 82b3cffda4868d23ce436adac8687645f5f7441b templater: test len filter Since node hash and shortened node hash both have defined length, it's a good way to check len filter in case of strings. As for lists of strings, children, tags and file_adds are used, because they provide some variety and also prove that what's counted is the number of string items in the list, and not the list stringified (they are lists of non-empty, multi-character strings). diff --git a/tests/test-command-template.t b/tests/test-command-template.t --- a/tests/test-command-template.t +++ b/tests/test-command-template.t @@ -1413,6 +1413,33 @@ Age filter: $ hg log -l1 --template '{date|age}\n' 7 years from now +Len filter: + + $ hg log -l1 --template '{node|len} {node|short|len}\n' + 40 12 + + $ hg log -G --template '{rev}: children: {children|len}, tags: {tags|len}, file_adds: {file_adds|len}' + @ 9: children: 0, tags: 1, file_adds: 1 + | + o 8: children: 1, tags: 0, file_adds: 2 + | + o 7: children: 1, tags: 0, file_adds: 1 + + o 6: children: 0, tags: 0, file_adds: 0 + |\ + | o 5: children: 1, tags: 0, file_adds: 1 + | | + o | 4: children: 1, tags: 0, file_adds: 0 + |/ + o 3: children: 2, tags: 0, file_adds: 0 + | + o 2: children: 1, tags: 0, file_adds: 1 + | + o 1: children: 1, tags: 0, file_adds: 1 + | + o 0: children: 1, tags: 0, file_adds: 1 + + Error on syntax: $ echo 'x = "f' >> t