summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Add support for --hashes=sha512_256 as another algorithmJohn Wiegley2024-08-051-0/+28
|
* Improvements to the hashing testsJohn Wiegley2024-08-053-4/+36
|
* Add positive and negative tests for the --hashes optionJohn Wiegley2024-08-052-0/+51
|
* Fix denominator of roundto resultMax Nikulin2024-08-053-0/+105
| | | | | | | | | | | | | | | | | | Multiprecision rational created from a double value may have large power of 2 denominator since fractional decimal numbers can not be represented as binary floating point numbers. It leads to failed assertion when result is compared to a value converted directly from strings. Use integer multiprecision arithmetics to round numbers to ensure proper denominator. Inspired by python gmpy2 package <https://github.com/aleaxit/gmpy/blob/3e4564ae9d/src/gmpy2_mpq_misc.c#L315> The change makes `roundto` symmetric for positive/negative arguments. Halves are rounded to nearest even. Rounded away from zero are discussed in #1663 and it may be achieved with minimal modification. - See #2329 - Closes #1983
* print: Align amounts even when account names are longGwyneth Morgan2024-07-101-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When the account name is longer than the --account-width (default 36), the amounts stop aligning: 2023/01/01 Transaction with long account names Assets:Very:Long:Account:Name:That:Will:Push:The:Amount -10 ABC Assets:Another:Long:Account:Name:That:Will:Push:The:Amount -10 ABC Expenses:Short 20 ABC One can set a larger --account-width, but that is not a great solution for cases where you have only a few accounts with problematically long names. Instead, keep the current account width wherever possible, but when an account name is longer than the account width, account for that and still align the values: 2023/01/01 Transaction with short account names Assets:Short -10 ABC Assets:Short -10 ABC Expenses:Short 20 ABC 2023/01/01 Transaction with long account names Assets:Very:Long:Account:Name:That:Will:Push:The:Amount -10 ABC Assets:Another:Long:Account:Name:That:Will:Push:The:Amount -10 ABC Expenses:Short 20 ABC This is similar to hledger's behavior.
* cmake: Add Python tests only when building with Python supportAlexis Hildebrandt2024-07-081-1/+6
| | | | Fixes #2324
* Use Python raw strings for regex methods argumentAlexis Hildebrandt2024-07-087-98/+98
|
* Restore expr context after calc, #2330 #2343Tavis Ormandy2024-07-081-0/+14
| | | | | | | Part of the expr_t::compile() process is to store the current scope, but In post_t::add_to_value that scope is temporary and on the stack. Restore the original context after that process is complete.
* Fix Query Parser for Automated Transactions (#1)Igbanam Ogbuluijah2024-06-251-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add failing test for use case TBH I don't know what I'm doing here, but this seems to fail for the right reasons enough to reflect the parser bug here. * Append to the ident on a closing brace ')' When parsing the automated rule, a scanner reads the line left-to-right char-by-char. The default behaviour is to append the char under the cursor to some `ident` string. When the cursor is on a ')', it skips the default handling and switches into some special handling: it tries to test the string it's reading if it's one of the keywords it knows, to select which type of token just got scanned. If what was scanned is not a known token, it defaults to `token_t::TERM` and returns a new token with the currently accumulated `ident` as a `token_t::TERM`. Issue is, since it skipped the appending to do some custom handling, the `token_t::TERM` will always be without its closing brace. The scanner needs to append the character under the cursor if it's falling through to default processing. * fix test case - ensure proper spacing for the posting to have an amount - ensure the posting balances against an account - the meaning of the number after `->` is the exit code * undo wrong approach * consume_next if unbalanced_braces * how this can be extended
* test: Accept test names as argumentsAlexis Hildebrandt2023-12-091-0/+4
|
* chore: Fix inline python format-stringsAlexis Hildebrandt2023-12-081-2/+2
|
* Merge branch 'master' into modernize-test-scriptsAlexis Hildebrandt2023-12-053-32/+1
|\
| * test: Remove Python2 specific testsAlexis Hildebrandt2023-12-053-32/+1
| |
* | tests: Modernize test scriptsAlexis Hildebrandt2023-12-059-196/+161
|/ | | | by using argparse and pathlib and removing Python 2 specific code.
* Migrate Python scripts to Python 3Alexis Hildebrandt2023-12-0415-54/+52
|
* Fix =regex note query syntaxGwyneth Morgan2023-10-123-6/+11
| | | | | | | | | | | | The manpage documents `=regex` as equivalent to the `note regex` query syntax, but the former does not actually work as the parser only handles an equals sign in the case of `tag type=dining` syntax, and doesn't handle the case where an equals sign starts a note query. Fixing this does break queries like `tag type = dining` with spaces around the equals sign, but that syntax was not intended or documented. Closes: #2275
* add regress test for issue #2270dbear4962023-07-161-0/+13
|
* fix #2220, bucket transactions ignored with reg --relatedTavis Ormandy2023-04-181-0/+8
| | | | | | This adds a new item flag, `ITEM_INFERRED`, that differentiates generated items from bucket items. This makes them show up as related items in reports.
* Add regression test for bugs #777 and #2207Martin Michlmayr2023-03-272-0/+22
| | | | | Bugs #777 and #2207 were fixed by commit 49cf3323a ("Change a use of is_realzero to just is_zero"). Let's add test cases.
* Add test cases for issue #2205Martin Michlmayr2023-03-032-0/+31
|
* Add test/baseline/cmd-stats1.testJohn Wiegley2023-02-061-0/+24
|
* Update copyright yearAlexis Hildebrandt2023-02-021-1/+1
| | | | [skip ci]
* Remove obsolete from __future__ importsAlexis Hildebrandt2023-02-0116-28/+0
|
* Sort 786A3DD0.test chronologically by dateAlexis Hildebrandt2023-02-011-1/+1
|
* Attempt to fix Linux CI failureAlexis Hildebrandt2023-02-011-1/+1
|
* Fix python/c++ conversion for boost::optional<T>David Sklar2023-01-271-0/+9
| | | | | | | | | | | | | | Setters for types wrapped in boost::optional, such as item_t::note were broken, e.g. setting a note on a transaction resulted in garbled data that would cause Python to throw utf-8 errors when retrieving the note. (But setters that accessed strings directly, e.g. "payee" on a transaction worked fine.) This change alters the from-python conversion for optional-wrapped types based on the example at https://stackoverflow.com/questions/36485840/wrap-boostoptional-using-boostpython and a test case to verify the behavior.
* Rename quoted_rfc4180 to quoted_rfc, to avoid parser quirkDonald Lam2023-01-252-0/+14
| | | | | | | Ledger's expression parser considers quoted_rfc4180 to be an amount (quantity 4180 of commodity "quoted_rfc"). Fixes #2007.
* typo and column alignmentspaette2023-01-233-3/+3
|
* Initial fix for #2147WY2023-01-201-0/+28
|
* Python: Transaction.remove_post should call xact_base_t::remove_postDavid Sklar2023-01-101-6/+21
|
* Python: test cleanupsDavid Sklar2023-01-093-8/+4
| | | | | | | | 1. Remove references to modules (exceptions, StringIO) no longer needed for Pythn3 2. Use assertEqual instead of assertEquals 3. Clear journal files with a close_journal_files() function that uses the then-current underlying python_session pointer. Calling session.close_journal_files() sometimes leads to segfaults because python_session has changed after it was injected into the python module (as "session") on module startup.
* typosspaette2023-01-074-4/+4
|
* Fix balancing commodity with smaller unit.Maria2022-10-112-0/+26
|
* Fix typos found by codespellAlexis Hildebrandt2022-07-191-1/+1
|
* Update copyright statement for 2022Alexis Hildebrandt2022-07-021-1/+1
|
* Replace os.path.abspath with os.path.realpathAlexis Hildebrandt2022-07-015-10/+10
| | | | | | to fix failing tests on Darwin, where /tmp is a symlink to /private/tmp and the tests fail as ledger reports filenames with the symlink resolved to /private/tmp, but the tests expect files with /tmp.
* Fix unrounding for equityOleg Bulatov2022-05-061-0/+30
|
* Fix test formattingJohn Wiegley2022-05-031-3/+3
|
* Add test/regress/2109.testJohn Wiegley2022-05-031-0/+23
|
* Avoid making references to nullKunht Kun2022-03-171-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | In `compare_items` if `sort_order` is a top level expression, it has no context and `get_context()` method returns the null pointer. To see this, run $ ledger -f test/input/demo.ledger --sort display_amount reg --debug scope.symbols and there will be many lines like [DEBUG] Binding scope 0 with ... In such case making a reference to the context is an undefined behavior (honestly the dereferencing itself feels quite problematic, but many compilers just run without any complaints) and could potentially cause segfaults. Therefore, we change to use only the grandchild scope (`left` or `right`) for `find_sort_values` here. Note that it may seem to be more appropriate to use `report` here for the parent scope. However, in `find_sort_values` which is called right after, the `report` scope is always bound to this scope. So we only use grandchild scope to avoid unnecessary operations. Fixes #2069.
* Avoid dereferencing null pointerKunht Kun2022-03-121-0/+12
| | | | | | | Here `comm` could be a null pointer (the new test regress/2057 shows such a case). So test it before dereferencing to avoid segfault. Re: #2057
* Ensure absolute path for includeKunht Kun2022-03-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ensure the path of file to include in `instance_t::include_directive` is always an absolute path. Previously when the journal file is given through stdin, we prepend a "./" to the filename to include. However, in Boost >= 1.77, `path::normalize` strips the leading "./" [1]. Our `resolve_path` function calls `normalize` and thus now it returns "file" for "./file" instead of the previous "./file". This change causes a failing test regress/BF3C1F82-2 [2], and also breaks the `include` directive for stdin input: $ touch file-to-include $ echo "include file-to-include" | ledger -f - reg gives While parsing file "", line 1: Error: File to include was not found: "file-to-include" Therefore, we change to prepend the `context.current_directory` to make the filename absolute in this case as well. The test regress/BF3C1F82-2 is also updated to match the new output. Fixes #2075. [1] https://github.com/boostorg/filesystem/commit/16bd89b7c0398d0dc5904148a865ef3fc3ece7ec [2] https://github.com/ledger/ledger/issues/2075
* Modify a regression test to match output from Boost 1.77John Wiegley2022-02-241-2/+2
| | | | A better fix for this issue is needed, however.
* Use correct int return type for stream input operationskanreki2021-12-082-0/+19
| | | | | | | | This makes it safe to compare results to -1 to indicate EOF, regardless of whether char is considered signed or unsigned; and so eliminates compiler warnings on platforms such as ARM. Fixes bug #2058.
* Fix --time-colon for negative time amountsRafael Ascensão2021-09-271-0/+23
| | | | | | | | | | | | | | | While the current formula works for positive numbers, negative numbers are incorrectly represented. One of the issues comes from the fact that floor(x) < x for every x. `amount_t precision` will always be a non negative number and the code that attempts to fix the issue for negative number will never run. If we truncate the number instead, the current formula works for both positive and negative numbers without making negative numbers a corner case. So let's do that. Signed-off-by: Rafael Ascensão <rafa.almas@gmail.com>
* Update docs for move to GitHub ActionsMartin Michlmayr2021-08-241-1/+1
|
* Fix silent errors when reading lines from input files.Austin Wise2021-08-242-0/+10
| | | | | | | | Handle files that don't end with a new line. Throw an error when the buffer size is exceeded. Fixes #516 Contributes to #1149
* Show "FAILURE in exit code" when success is expectedAlan Bram2021-05-041-5/+4
| | | | Fixes #2023.
* Fix amount tokenizer re: embedded minus sign.Donald Lam2021-05-021-0/+12
| | | | | An amount may have a (single) leading minus sign, but none after that. Bug #2001 (and #1809).
* Fix using day-of-week names for `xact` commandAlan Bram2021-04-101-0/+23
| | | | Also fix end-of-command boundary checks for keywords "at", "to", etc.