test: display rounding and percent rules (K-U9)
Tests encode the display rules: half away from zero, no negative zero, no percent of a zero or negative base, plus a scoped source check that no round_dp or float conversion remains in the money display paths. view_model's pct_change(-100, -50) expectation moves from Some(50.0) to None under the new rule. docs/proofs/display.md is the unit note (no Kani, no Lean for display, per the audit). Co-Authored-By: Muse Wonder 1.0
This commit is contained in:
1 parent
a7d0c7f2d3
commit
2463c10af9
3 files changed
+251
-3
No files matched your search
@@ -324,9 +324,10 @@ fn origins_and_parties() {
|
||||
fn percent_change_and_tax_forms() {
|
||||
let d = |s: &str| s.parse::<Decimal>().unwrap();
|
||||
assert_eq!(fmt::pct_change(d("0"), d("5")), None);
|
||||
assert_eq!(fmt::pct_change(d("100"), d("150")), Some(50.0));
|
||||
assert_eq!(fmt::pct_change(d("200"), d("150")), Some(-25.0));
|
||||
assert_eq!(fmt::pct_change(d("-100"), d("-50")), Some(50.0));
|
||||
assert_eq!(fmt::pct_change(d("100"), d("150")), Some(d("50.0")));
|
||||
assert_eq!(fmt::pct_change(d("200"), d("150")), Some(d("-25.0")));
|
||||
// K-U9: no percent of a negative base (it misleads); Decimal, never f64.
|
||||
assert_eq!(fmt::pct_change(d("-100"), d("-50")), None);
|
||||
use ledger_core::TaxForm::*;
|
||||
for (f, number) in [
|
||||
(ScheduleC, "Schedule C"),
|
||||
|
||||
Reference in new issue
Block a user