mirror of
https://github.com/simonmichael/hledger.git
synced 2025-01-04 00:07:29 +03:00
4141067428
* Replace Parsec with Megaparsec (see #289) This builds upon PR #289 by @rasendubi * Revert renaming of parseWithState to parseWithCtx * Fix doctests * Update for Megaparsec 5 * Specialize parser to improve performance * Pretty print errors * Swap StateT and ParsecT This is necessary to get the correct backtracking behavior, i.e. discard state changes if the parsing fails.
45 lines
621 B
Plaintext
45 lines
621 B
Plaintext
# invalid dates should be rejected
|
|
# 1. valid month and day, but flipped
|
|
hledger -f- print
|
|
<<<
|
|
2010/31/12 x
|
|
a 1
|
|
b
|
|
>>>2 /bad date/
|
|
>>>= 1
|
|
# 2. too-large day
|
|
hledger -f- print
|
|
<<<
|
|
2010/12/32 x
|
|
a 1
|
|
b
|
|
>>>2 /bad date/
|
|
>>>= 1
|
|
# 3. 29th feb on leap year should be ok
|
|
hledger -f- print
|
|
<<<
|
|
2000/2/29 x
|
|
a 1
|
|
b
|
|
>>>
|
|
2000/02/29 x
|
|
a 1
|
|
b -1
|
|
|
|
>>>= 0
|
|
# 4. 29th feb on non-leap year should fail
|
|
hledger -f- print
|
|
<<<
|
|
2001/2/29 x
|
|
a 1
|
|
b
|
|
>>>2 /bad date/
|
|
>>>= 1
|
|
# 5. dates must be followed by whitespace or newline
|
|
hledger -f- print
|
|
<<<
|
|
2015/9/6*
|
|
a 0
|
|
>>>2 /unexpected '*'/
|
|
>>>= 1
|