code wiki / (root) / nx_market_test.nx

nx_market_test.nx source

↩ module page · 38 lines · 1775 B

1// nx_market_test.nx -- smoke for nx_market. Proves production cost-down, 2// Wright's-law learning curve, margin pricing, break-even, customer payback, 3// the viability verdict, and composition with the real BOM. 4// Exit code = failed assertion number; 0 = all pass. 5 6import "nx_syscalls.nx" 7import "nx_bom.nx" 8import "nx_market.nx" 9 10func main() -> i64 { 11 // --- production cost is a bulk fraction of the $203 prototype --- 12 if mk_production_unit_cost(20300, 45) != 9135 { return 1 } // $91.35 13 14 // --- Wright's law: 15% cheaper per doubling of cumulative volume --- 15 if mk_learning_cost(9135, 85, 3) != 5609 { return 2 } // after 8x volume ~ $56 16 if mk_learning_cost(9135, 85, 0) != 9135 { return 3 } // volume 1 = base 17 18 // --- pricing for a target gross margin --- 19 if mk_price_for_margin(9000, 60) != 22500 { return 4 } // $225 at 60% margin 20 if mk_gross_margin_pct(22500, 9000) != 60 { return 5 } 21 22 // --- break-even on $50k fixed cost --- 23 if mk_break_even_units(5000000, 22500, 9000) != 371 { return 6 } 24 25 // --- customer payback vs bottled water (4 L/day, $1/L vs our $0.15/L) --- 26 if mk_daily_savings_cents(4, 100, 15) != 340 { return 7 } // $3.40/day saved 27 if mk_payback_days(22500, 340) != 66 { return 8 } // ~2.2 months 28 29 // --- go-to-market viability verdict --- 30 if mk_viable(60, 66) != 1 { return 9 } // healthy margin + fast payback 31 if mk_viable(30, 66) != 0 { return 10 } // margin too thin 32 if mk_viable(60, 500) != 0 { return 11 } // payback too slow 33 34 // --- COMPOSES the real BOM: water production cost derives from it --- 35 if mk_water_production_cost(45) != 9135 { return 12 } 36 37 return 0 38}