nx_hardship_nav_gate.nx source
↩ module page · 51 lines · 3237 B
1// nx_hardship_nav_gate.nx -- proves the hardship module on hand-verified fixtures: bankruptcy means-test
2// (below-median -> Ch.7; above-median + high disposable -> presumed abuse -> Ch.13), PSLF/IDR forgiveness
3// progress, and forbearance interest cost. Exit 0 iff all pass. license_tier: ORIGINAL
4import "nx_gate.nx"
5import "nx_hardship_nav.nx"
6
7func chk(name: *u8, got: i64, want: i64, st: *i64) -> i64 {
8 if got == want { st[0] = st[0] + 1; gw(" PASS " as *u8); gw(name); gw("\n" as *u8) }
9 else { st[1] = st[1] + 1; gw(" FAIL " as *u8); gw(name); gw(" got=" as *u8); gn(got); gw(" want=" as *u8); gn(want); gw("\n" as *u8) }
10 return 0
11}
12
13func main() -> i64 {
14 let st: *i64 = sys_mmap(16) as *i64
15 st[0] = 0; st[1] = 0
16
17 // -- means test. CMI $3000/mo -> $36k/yr; state median (1-person) $60k -> BELOW -> Ch.7 OK --
18 chk("annualize($3000/mo) = $36000" as *u8, hn_annualize(300000), 3600000, st)
19 chk("below median ($36k <= $60k) = 1" as *u8, hn_below_median(3600000, 6000000), 1, st)
20 chk("above median ($96k <= $60k) = 0" as *u8, hn_below_median(9600000, 6000000), 0, st)
21 chk("disposable ($8000 - $7000) = $1000/mo" as *u8, hn_disposable_monthly(800000, 700000), 100000, st)
22 // 60 x $1000 = $60000 >= high $15150 -> presumed abuse (Ch.13)
23 chk("presumption($1000/mo, 9075, 15150) = 2 (abuse)" as *u8, hn_presumption(100000, 907500, 1515000), 2, st)
24 // 60 x $100 = $6000 < low $9075 -> no presumption (Ch.7 ok)
25 chk("presumption($100/mo) = 0 (Ch.7 ok)" as *u8, hn_presumption(10000, 907500, 1515000), 0, st)
26 // 60 x $200 = $12000 -> between -> needs analysis
27 chk("presumption($200/mo) = 1 (needs analysis)" as *u8, hn_presumption(20000, 907500, 1515000), 1, st)
28 // full screens
29 chk("Ch.7 screen (below median) = 0 (OK)" as *u8, hn_ch7_screen(3600000, 6000000, 300000, 250000, 907500, 1515000), 0, st)
30 chk("Ch.7 screen (above median, high disp) = 2 (abuse)" as *u8, hn_ch7_screen(9600000, 6000000, 800000, 700000, 907500, 1515000), 2, st)
31
32 // -- PSLF / IDR forgiveness --
33 chk("PSLF remaining (90 of 120) = 30" as *u8, hn_pslf_remaining(90), 30, st)
34 chk("PSLF complete (90) = 0" as *u8, hn_pslf_complete(90), 0, st)
35 chk("PSLF progress (90) = 7500 bps (75%)" as *u8, hn_pslf_progress_bps(90), 7500, st)
36 chk("PSLF complete (120) = 1" as *u8, hn_pslf_complete(120), 1, st)
37 chk("PSLF progress (130) = 10000 bps (capped)" as *u8, hn_pslf_progress_bps(130), 10000, st)
38 chk("IDR remaining (100 of 240) = 140" as *u8, hn_idr_remaining(100, 240), 140, st)
39
40 // -- forbearance: $10000 @ 5% for 12 months --
41 chk("forbearance cost ($10k @ 5%, 12mo) = $499.92" as *u8, hn_forbearance_cost(1000000, 500, 12), 49992, st)
42 chk("forbearance new balance = $10499.92" as *u8, hn_forbearance_balance(1000000, 500, 12), 1049992, st)
43
44 // -- doctrine --
45 chk("requires a licensed professional = 1" as *u8, hn_requires_professional(), 1, st)
46
47 gw("nx_hardship_nav_gate: PASS=" as *u8); gn(st[0]); gw(" FAIL=" as *u8); gn(st[1]); gw("\n" as *u8)
48 if st[1] == 0 { gw("nx_hardship_nav: GREEN (means-test / PSLF-IDR / forbearance, hand-verified, pro-sign doctrine)\n" as *u8); return 0 }
49 gw("nx_hardship_nav: RED\n" as *u8)
50 return 1
51}