diff --git a/hledger/test/journal/directive-commodity.test b/hledger/test/journal/directive-commodity.test index 35ea6833a..24d970636 100644 --- a/hledger/test/journal/directive-commodity.test +++ b/hledger/test/journal/directive-commodity.test @@ -1,13 +1,73 @@ # commodity directive -< -commodity BTC -$ hledger -f - reg -# commodity directive with subdirective +# 1 requires an argument < -commodity BTC - note Bitcoin -$ hledger -f - reg ->2 /expecting "format"/ +commodity +$ hledger -f - commodities +>2 /unexpected newline/ >=1 +# 2 should require an amount, not just a symbol (but doesn't, TODO) +< +commodity A +$ hledger -f - commodities +A + +# 3 when there is an amount, a decimal mark is required +< +commodity A 1 +$ hledger -f - commodities +>2 /Please include a decimal point or decimal comma/ +>=1 + +# 4 +< +commodity A 1. +$ hledger -f - commodities +A + +# 5 +< +commodity A 1,00 +$ hledger -f - commodities +A + +# 6 accepts a format subdirective +< +commodity A + format 1.0 A +$ hledger -f - commodities +A + +# 7 which also requires an amount argument +< +commodity A + format +$ hledger -f - commodities +>2 /expecting amount/ +>=1 + +# 8 which must have the same commodity symbol +< +commodity A + format 1 +$ hledger -f - commodities +>2 /commodity directive symbol .* and format directive symbol .* should be the same/ +>=1 + +# 9 when there's a format subdirective, the main directive should have just a symbol +# (and the error message should be clear, TODO) +< +commodity A 1. + format 1. A +$ hledger -f - commodities +>2 /unexpected 'f'/ +>=1 + +# 10 it rejects unrecognised subdirectives (should be permissive like account, TODO) +< +commodity A + note a a +$ hledger -f - commodities +>2 /expecting "format"/ +>=1