code wiki / (root) / nx_preservation_test.nx

nx_preservation_test.nx source

↩ module page · 54 lines · 2842 B

1// nx_preservation_test.nx -- smoke for nx_preservation (food-preservation 2// science). Proves thermal death kinetics (12-D botulinum cook, z-value 3// scaling), water activity classes, Leistner hurdle stability + its exceed 4// over single-factor checking, and the never-poison canning gate. 5// Exit code = failed assertion number; 0 = all pass. 6 7import "nx_syscalls.nx" 8import "nx_preservation.nx" 9 10func main() -> i64 { 11 // --- thermal death kinetics --- 12 // 2.52 min at 121.1 C with D=0.21 min -> exactly 12 log reductions. 13 if pv_reductions_milli(2520, 210) != 12000 { return 1 } 14 if pv_is_12d(2520, 210) != 1 { return 2 } 15 // 11 log (2.31 min) is NOT the botulinum cook. 16 if pv_is_12d(2310, 210) != 0 { return 3 } 17 // minimum process to hit 12-D from D=0.21 min = 2.52 min. 18 if pv_min_process_mmin(210, 12000) != 2520 { return 4 } 19 20 // --- z-value scaling (exact powers of ten) --- 21 if pv_pow10(3) != 1000 { return 5 } 22 if pv_d_at_z_steps(1000, 1) != 100 { return 6 } // 1 z hotter -> D/10 23 if pv_d_at_z_steps(1000, 2) != 10 { return 7 } // 2 z hotter -> D/100 24 if pv_d_at_z_steps(1000, -1) != 10000 { return 8 } // 1 z colder -> D*10 25 26 // --- water activity classes --- 27 if pv_water_activity_class(980) != PV_AW_UNSAFE { return 9 } 28 if pv_water_activity_class(700) != PV_AW_MOLD_ONLY { return 10 } 29 if pv_water_activity_class(500) != PV_AW_SHELF { return 11 } 30 31 // --- shelf stability --- 32 if pv_shelf_stable(3500, 980) != PV_STABLE_ACID { return 12 } // sauerkraut 33 if pv_shelf_stable(5600, 980) != PV_UNSTABLE { return 13 } // green beans (low-acid, wet) 34 if pv_shelf_stable(6500, 550) != PV_STABLE_DRY { return 14 } // crackers 35 if pv_shelf_stable(6500, 800) != PV_STABLE_LOW_AW { return 15 } // jerky 36 if pv_shelf_stable(4900, 890) != PV_STABLE_HURDLE { return 16 } // fermented sausage 37 38 // --- the HURDLE EXCEED over single-factor checking --- 39 if pv_hurdle_beats_single(4900, 890) != 1 { return 17 } // hurdle finds it stable 40 if pv_single_factor_stable(4900, 890) != 0 { return 18 } // single-factor misses it 41 if pv_hurdle_beats_single(3500, 980) != 0 { return 19 } // acid is single-factor stable 42 if pv_hurdle_beats_single(6500, 980) != 0 { return 20 } // genuinely unstable, no false claim 43 44 // --- canning method selection --- 45 if pv_canning_method(3500) != PV_METHOD_WATER_BATH { return 21 } 46 if pv_canning_method(5600) != PV_METHOD_PRESSURE_CAN { return 22 } 47 48 // --- NEVER-POISON: low-acid food via boiling-water-bath is REFUSED --- 49 if pv_canning_admit(5600, PV_METHOD_WATER_BATH) != PV_CAN_REFUSED_LOW_ACID_WB { return 23 } 50 if pv_canning_admit(3500, PV_METHOD_WATER_BATH) != PV_CAN_OK { return 24 } 51 if pv_canning_admit(5600, PV_METHOD_PRESSURE_CAN) != PV_CAN_OK { return 25 } 52 53 return 0 54}