amount/price func. test cleanups

This commit is contained in:
Simon Michael 2011-01-19 19:00:42 +00:00
parent d3663b818e
commit c8614b9a15
6 changed files with 118 additions and 100 deletions

View File

@ -1,4 +1,5 @@
# test mixed amount layout with various commands
# amount layout tests, using default vertical layout
# 1. print
bin/hledger -f - print
<<<
2010/1/1
@ -12,7 +13,7 @@ bin/hledger -f - print
EUR -1
c USD -1 ; a euro and a dollar
#
# 2. register
bin/hledger -f - register
<<<
2010/1/1
@ -25,7 +26,7 @@ bin/hledger -f - register
b USD 1 USD 1
EUR -1
c USD -1 0
#
# 3. balance
bin/hledger -f - balance
<<<
2010/1/1
@ -39,3 +40,51 @@ bin/hledger -f - balance
USD -1 c
--------------------
EUR 0
# 4. mixed amounts with prices
# XXX
# bin/hledger -f - print
# <<<
# 2010/1/1
# a EUR 1 @ USD 1.1 ; a euro
# b USD 1 ; a dollar
# c ; a euro and a dollar
# >>>
# 2010/01/01
# a EUR 1 @ USD 1.1 ; a euro
# b USD 1 ; a dollar
# EUR -1 @ USD 1.1
# c USD -1 ; a euro and a dollar
#
##
# 2010/01/01
# a EUR 1 @ USD 1.1 ; a euro
# b USD 1.0 ; a dollar
# c USD -2.1 ; a euro and a dollar
#
# #
# bin/hledger -f - register
# <<<
# 2010/1/1
# a EUR 1 @ USD 1.1 ; a euro
# b USD 1 ; a dollar
# c ; a euro and a dollar
# >>>
# 2010/01/01 a EUR 1 EUR 1
# EUR 1
# b USD 1.0 USD 1.0
# EUR 1
# c USD -2.1 USD -1.1
# #
# bin/hledger -f - balance
# <<<
# 2010/1/1
# a EUR 1 @ USD 1.1 ; a euro
# b USD 1 ; a dollar
# c ; a euro and a dollar
# >>>
# EUR 1 a
# USD 1.0 b
# USD -2.1 c
# --------------------
# EUR 1
# USD -1.1

View File

@ -1,24 +0,0 @@
# 1. a no-commodity amount with a unit price
bin/hledger -f - print
<<<
2010/1/1 x
a 1 @ $2
b
>>>
2010/01/01 x
a 1 @ $2
b -1 @ $2
# 2. with a total price
bin/hledger -f - print
<<<
2010/1/1 x
a 2 @@ $2
b
>>>
2010/01/01 x
a 2 @@ $2
b -2 @@ $2

View File

@ -1,14 +0,0 @@
bin/hledger -f - print
<<<
P 2009/1/1 p 0.5h
2009/1/1 t
a 1p
b
>>>
2009/01/01 t
a 1p @ 0.5h
b -1p @ 0.5h
>>>2

66
tests/prices.tests Normal file
View File

@ -0,0 +1,66 @@
# price-related tests
# 1. print a transaction with an explicit unit price
bin/hledger -f- print
<<<
2011/01/01
expenses:foreign currency €100 @ $1.35
assets
>>>
2011/01/01
expenses:foreign currency €100 @ $1.35
assets €-100 @ $1.35
# 2. convert to cost basis
bin/hledger -f- print -B
<<<
2011/01/01
expenses:foreign currency €100 @ $1.35
assets
>>>
2011/01/01
expenses:foreign currency $135.00
assets $-135.00
# 2. with a historical price directive
bin/hledger -f- print -B
<<<
P 2010/12/31 € $1.34
P 2011/01/01 € $1.35
P 2011/01/02 € $1.36
2011/01/01
expenses:foreign currency €100
assets
>>>
2011/01/01
expenses:foreign currency $135.00
assets $-135.00
# 3. with a total price
bin/hledger -f - print
<<<
2011/01/01
expenses:foreign currency €100 @@ $135
assets
>>>
2011/01/01
expenses:foreign currency €100 @@ $135
assets €-100 @@ $135
# 4. with an implicit price
# bin/hledger -f - print
# <<<
# 2011/01/01
# expenses:foreign currency €100 @ $1.35
# assets $-135.00
# >>>
# 2011/01/01
# expenses:foreign currency €100 @ $1.35
# assets
#
# 2009/1/1 opening balance
# Assets:Brokerage 1 AAPL
# Assets:Checking $-20.00
#
# >>>= 0

View File

@ -1,51 +0,0 @@
# draft pricing tests
# 1. print a transaction with explicitly-priced amount
bin/hledger -f- print
<<<
2009/1/2 x
expenses:foreign currency €100 @ $1.35
assets
>>>
2009/01/02 x
expenses:foreign currency €100 @ $1.35
assets $-135.00
# 2. again, this time converting to cost basis
bin/hledger -f- print -B
<<<
2009/1/2 x
expenses:foreign currency €100 @ $1.35
assets
>>>
2009/01/02 x
expenses:foreign currency $135.00
assets $-135.00
# 3. same as above, but using a historical price directive
bin/hledger -f- print
<<<
P 2009/1/1 € $1.35
2009/1/2 x
expenses:foreign currency €100
assets
>>>
2009/01/02 x
expenses:foreign currency €100 @ $1.35
assets €-100 @ $1.35
# 4. and with conversion
bin/hledger -f- print -B
<<<
P 2009/1/1 € $1.35
2009/1/2 x
expenses:foreign currency €100
assets
>>>
2009/01/02 x
expenses:foreign currency $135.00
assets $-135.00

View File

@ -1,8 +0,0 @@
# should infer prices to balance this - not implemented
bin/hledger -f - print
<<<
2009/1/1 opening balance
Assets:Brokerage 1 AAPL
Assets:Checking $-20.00
>>>= 0