code wiki / (root) / nx_ferment_recipes_test.nx

nx_ferment_recipes_test.nx source

↩ module page · 41 lines · 1823 B

1// nx_ferment_recipes_test.nx -- smoke for nx_ferment_recipes (R4). 2// 3// Proves a data-driven catalog where EVERY entry is R0-safety-verified: 4// - catalog lookups return the right ferment kind (1-2) 5// - all 7 named recipes pass the R0 never-poison law (100+id on failure) 6// - LIAR-KILL: an unsafe raw-milk cheese under 60 days is REFUSED (3) 7// - LIAR-KILL: an under-salted anaerobic brine is REFUSED (4) 8// Exit code = failed assertion number; 0 = all pass. 9 10import "nx_syscalls.nx" 11import "nx_ferment_safety.nx" 12import "nx_ferment_recipes.nx" 13 14func main() -> i64 { 15 let env: *NxFermentSafetyEnvelope = nx_ferment_safety_envelope_default(1) 16 let nolog: *NxFermentReadingLog = (0) as *NxFermentReadingLog 17 18 // --- catalog lookups (bind to a local; func().field chaining is unreliable) --- 19 let yr: *NxFermentRecipeSpec = nx_ferment_recipe(NX_RCP_YOGURT) 20 if yr.ferment_kind != NX_FK_DAIRY_CULTURED { return 1 } 21 let kr: *NxFermentRecipeSpec = nx_ferment_recipe(NX_RCP_SAUERKRAUT) 22 if kr.ferment_kind != NX_FK_VEG_ANAEROBIC { return 2 } 23 24 // --- every catalog recipe passes the R0 never-poison law --- 25 var i: i64 = 0 26 while i < NX_RCP_N { 27 let r: *NxFermentRecipeSpec = nx_ferment_recipe(i) 28 if nx_ferment_recipe_safe(env, r) != NX_FS_OK { return 100 + i } 29 i = i + 1 30 } 31 32 // --- LIAR-KILL: an unsafe raw-milk cheese aged only 10 days is REFUSED --- 33 if nx_ferment_validate(env, NX_FK_CHEESE_RAWMILK, NX_OX_AEROBIC, 34 31000, 5200, 0, 48, 10, nolog, 48) != NX_FS_REFUSED_RAW_MILK_AGE { return 3 } 35 36 // --- LIAR-KILL: an under-salted anaerobic brine is REFUSED --- 37 if nx_ferment_validate(env, NX_FK_VEG_ANAEROBIC, NX_OX_ANAEROBIC, 38 20000, 3500, 1000, 48, 0, nolog, 48) != NX_FS_REFUSED_INSUFFICIENT_SALT { return 4 } 39 40 return 0 41}