code wiki / (root) / nx_bom_test.nx

nx_bom_test.nx source

↩ module page · 35 lines · 1774 B

1// nx_bom_test.nx -- smoke for nx_bom. Proves the part catalog, the wate 2// bench-prototype rollup (cost/mass/critical-path/make-count), per-category 3// subtotals, and cost conservation. Exit code = failed assertion #; 0 = pass. 4 5import "nx_syscalls.nx" 6import "nx_bom.nx" 7 8func main() -> i64 { 9 // --- part catalog --- 10 let pel: *NxPart = nx_bom_part(BP_PELTIER) 11 if pel.unit_cost_cents != 500 { return 1 } 12 if pel.category != BC_HARVEST { return 2 } 13 let enc: *NxPart = nx_bom_part(BP_ENCLOSURE) 14 if enc.make_buy != BM_MAKE { return 3 } // we 3D-print it 15 if enc.category != BC_ENCLOSURE { return 4 } 16 17 // --- water bench-prototype rollup --- 18 let b: *NxBom = nx_bom_water_assemble() 19 if b.total_cost_cents != 20300 { return 5 } // $203.00 20 if b.total_mass_g != 2865 { return 6 } // 2.865 kg 21 if nx_bom_critical_path_days(b) != 14 { return 7 } // UV-C LED + mineral cartridge gate the schedule 22 if b.part_count != 17 { return 8 } // 16 line items, two intake fans 23 if b.make_count != 1 { return 9 } // only the enclosure is MAKE (vertical integration) 24 25 // --- per-category subtotals --- 26 if nx_bom_water_category_cost(BC_CONTROL) != 6000 { return 10 } 27 if nx_bom_water_category_cost(BC_HARVEST) != 3900 { return 11 } 28 if nx_bom_water_category_cost(BC_ENCLOSURE) != 800 { return 12 } 29 30 // --- CONSERVATION: category subtotals sum to the total --- 31 let sum: i64 = nx_bom_water_category_cost(BC_HARVEST) + nx_bom_water_category_cost(BC_COLLECT) + nx_bom_water_category_cost(BC_TREAT) + nx_bom_water_category_cost(BC_MINERAL) + nx_bom_water_category_cost(BC_CONTROL) + nx_bom_water_category_cost(BC_ENCLOSURE) 32 if sum != 20300 { return 13 } 33 34 return 0 35}