code wiki / (root) / nx_flavor_chem_test.nx

nx_flavor_chem_test.nx source

↩ module page · 39 lines · 1999 B

1// nx_flavor_chem_test.nx -- smoke for nx_flavor_chem (T3). 2// 3// Proves structure -> taste prediction + the MEASURED EXCEED (generalises 4// to molecules outside any ingredient table): 5// - 6 grounded reference molecules classify correctly (1-6) 6// - sweetness POTENCY is read from structure (7-8) 7// - a NOVEL molecule (in no table) is classified from structure (9-10) 8// - a structurally inert molecule -> NONE (11) 9// Exit code = failed assertion number; 0 = all pass. 10 11import "nx_syscalls.nx" 12import "nx_taste_transduce.nx" 13import "nx_flavor_chem.nx" 14 15func main() -> i64 { 16 // --- grounded reference molecules --- 17 if nx_flavor_predict_taste(nx_molsensory_sucrose()) != NX_TQ_SWEET { return 1 } 18 if nx_flavor_predict_taste(nx_molsensory_sucralose()) != NX_TQ_SWEET { return 2 } 19 if nx_flavor_predict_taste(nx_molsensory_citric()) != NX_TQ_SOUR { return 3 } 20 if nx_flavor_predict_taste(nx_molsensory_nacl()) != NX_TQ_SALTY { return 4 } 21 if nx_flavor_predict_taste(nx_molsensory_quinine()) != NX_TQ_BITTER { return 5 } 22 if nx_flavor_predict_taste(nx_molsensory_msg()) != NX_TQ_UMAMI { return 6 } 23 24 // --- potency from structure: hydrophobic X -> high-potency sweetener --- 25 if nx_flavor_sweet_potency(nx_molsensory_sucrose()) != 200 { return 7 } 26 if nx_flavor_sweet_potency(nx_molsensory_sucralose()) <= nx_flavor_sweet_potency(nx_molsensory_sucrose()) { return 8 } 27 28 // --- MEASURED EXCEED: a NOVEL molecule (no ingredient table entry) is 29 // classified SWEET, high-potency, purely from its structure --- 30 let novel: *NxMolSensory = nx_molsensory_new(4, 4, 320, 1, 0, 99000, 0, 0, 0) 31 if nx_flavor_predict_taste(novel) != NX_TQ_SWEET { return 9 } 32 if nx_flavor_sweet_potency(novel) != 1000 { return 10 } 33 34 // --- a structurally inert molecule has no SAR match -> NONE --- 35 let inert: *NxMolSensory = nx_molsensory_new(0, 1, 600, 0, 0, 99000, 0, 0, 0) 36 if nx_flavor_predict_taste(inert) != NX_TQ_NONE { return 11 } 37 38 return 0 39}