summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChristoph Dittmann <github@christoph-d.de>2021-01-30 14:32:17 +0100
committerMartin Michlmayr <tbm@cyrius.com>2021-01-30 23:44:58 +0800
commitb155f8928c6a33af42f859b27c83639b72517f5e (patch)
tree4b5d19cda86c2fc5b3786541c02326dea68f986c /test
parent2dae3bbedcdf55983d23fc90bb36111c7eb68fc7 (diff)
downloadfork-ledger-b155f8928c6a33af42f859b27c83639b72517f5e.tar.gz
fork-ledger-b155f8928c6a33af42f859b27c83639b72517f5e.tar.bz2
fork-ledger-b155f8928c6a33af42f859b27c83639b72517f5e.zip
compare_by_commodity: Always return the result of the recursive call
Commit 501fbc08ae5493db77bb34f4c4fbe1f3a3bc14e3 changed the behavior of this function to not return the "equal" result (==0) from the recursive call. Previously, the function returned the result of the recursive call unconditionally. The current behavior causes an assertion error for certain postings. The regression test added in this commit shows such a posting. I found through Travis CI that the old behavior was incomplete and caused unstable orderings, so reverting to the old behavior doesn't work. Instead, this change adds a fallback: If the recursive call that compares the prices numerically returns "equal", then compare the prices with their original commodity as a tie breaker. This commit does not change any existing ordering, it only adds deterministic ordering in a case that currently triggers an assertion error. This fixes issue #1998.
Diffstat (limited to 'test')
-rw-r--r--test/regress/1998.test14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/regress/1998.test b/test/regress/1998.test
new file mode 100644
index 00000000..e5fbdeda
--- /dev/null
+++ b/test/regress/1998.test
@@ -0,0 +1,14 @@
+2021-01-02 Same commodity, different values
+ Assets -1 Stock {100 USD} [2021-01-01]
+ Assets 1 Stock {100 EUR} [2021-01-01]
+ Equity
+
+test bal --lots
+1 Stock {EUR100} [2021/01/01]
+-1 Stock {USD100} [2021/01/01] Assets
+-1 Stock {EUR100} [2021/01/01]
+1 Stock {USD100} [2021/01/01] Equity
+--------------------
+ 0
+end test
+