hledger/tests/journal/balance-assertions.test
Simon Michael 21d9945ba9 tests: make functional tests use "hledger" again
Using "hledgerdev" was a hack to help ensure that tests used a fresh
developer build by default. Now they specify "hledger" again, which fits
better with stack. It's up to the tester to make sure the desired
executable is first in PATH or specified with -w. (Note a couple of
tests currently don't obey -w and will always run "hledger", see addons.test).
2015-07-12 12:29:53 -07:00

139 lines
1.9 KiB
Plaintext
Executable File

#!/usr/bin/env shelltest
# 1. test some balance assertions
hledger -f - stats
<<<
2013/1/1
a $1 =$1
b =-$1
2013/1/2
a $1 =$2
b $-1 =$-2
2013/1/3
a $1 = $3
b $-1 = $-3
(b) $1 = $-2
>>> /Transactions/
>>>2
>>>=0
# 2. same entries as 1 but different parse order, assertion should still pass based on date
hledger -f - stats
<<<
2013/1/1
a $1 =$1
b =-$1
2013/1/3
a $1 = $3
b $-1 = $-3
(b) $1 = $-2
2013/1/2
a $1 =$2
b $-1 =$-2
>>> /Transactions/
>>>2
>>>=0
# 3. like 1 but switch order of postings in last entry,
# assertion should fail and exit code should be non zero
hledger -f - stats
<<<
2013/1/1
a $1 =$1
b =-$1
2013/1/2
a $1 =$2
b $-1 =$-2
2013/1/3
a $1 = $3
(b) $1 = $-2
b $-1 = $-3
>>>
>>>2 /Balance assertion failed for account b on 2013-01-03/
>>>=1
# 4. should also work without commodity symbols
hledger -f - stats
<<<
2013/1/1
(a) 1 =1
>>> /Transactions/
>>>2
>>>=0
# 5. should work for fractional amount with trailing zeros
hledger -f - stats
<<<
2013/1/1
a $1.20 =$1.20
b =-$1.20
2013/1/2
a $0.10 =$1.3
b =-$1.3
2013/1/3
a $0.7 =$2
b =-$2
>>> /Transactions/
>>>2
>>>=0
# 6. assertions currently check only a single commodity's balance, like Ledger
hledger -f - stats
<<<
1/2
(a) A1
(a) B1 = A1
(a) 0 = A1
(a) C0 = D0
>>> /Transactions/
>>>2
>>>=0
# 7. balances should accumulate (#195)
hledger -f - stats
<<<
1/1
(a) 1F = 1F
(a) 2G = 2G
1/2
(a) 3F = 4F
>>> !/assertion failed/
>>>2
>>>=0
# 8. what should happen here ? Currently,
# in a, 3.4 EUR @@ $5.6 and -3.4 EUR cancel out (wrong ?)
# in b,
#
# hledger -f - stats
# <<<
# 2013/1/1
# a $1.20
# a 3.4 EUR @@ $5.6
# b
# 2013/1/2
# a -3.4 EUR
# b
# 2013/1/3
# a $0.1 =$1.30
# b =-$1.30
# >>> /Transactions/
# >>>2
# >>>=0