From 016808fd06ec940540e2a107b8dbbe9e0612c432 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 21 Jun 2019 12:16:56 -0700 Subject: [PATCH] ;journal: tests for recursive aliases, application order (#1055) [ci skip] --- tests/misc/account-aliases.test | 79 +++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tests/misc/account-aliases.test b/tests/misc/account-aliases.test index 5a26e959e..903294a40 100644 --- a/tests/misc/account-aliases.test +++ b/tests/misc/account-aliases.test @@ -146,3 +146,82 @@ alias a = b $ hledger -f- reg '^a$' '^b$' 2017/01/01 b 1 1 b -1 0 + +# recursive aliases https://github.com/simonmichael/hledger/issues/1055 + +# 10. Recursive command line simple aliases. +< +2000/01/01 + (one) 1 + +$ hledger -f- --alias "one=two" --alias "two=three" print +2000/01/01 + (three) 1 + +>=0 + +# 11. Recursive simple alias directives. Note the reverse order, +# alias directives are applied most recent first (bottom up). +< +alias two = three +alias one = two +2000/01/01 + (one) 1 + +$ hledger -f- print +2000/01/01 + (three) 1 + +>=0 + +# 12. Only one of these is applied. +< +alias one = three +alias one = two +2000/01/01 + (one) 1 + +$ hledger -f- print +2000/01/01 + (two) 1 + +>=0 + +# 13. Recursive command line regexp aliases. +< +2000/01/01 + (one) 1 + +$ hledger -f- --alias "/one/=two" --alias "/two/=three" print +2000/01/01 + (three) 1 + +>=0 + +# 14. Recursive regexp alias directives. +# Alias directives are applied most recent first (bottom up). +< +alias /two/ = three +alias /one/ = two +2000/01/01 + (one) 1 + +$ hledger -f- print +2000/01/01 + (three) 1 + +>=0 + +# 15. Only one of these is applied. +< +alias /one/ = three +alias /one/ = two +2000/01/01 + (one) 1 + +$ hledger -f- print +2000/01/01 + (two) 1 + +>=0 +