nx_soda_flavor_test.nx source
↩ module page · 63 lines · 2853 B
1// nx_soda_flavor_test.nx -- smoke for nx_soda_flavor (craft-soda F0).
2//
3// Proves the "smooth + strong + WITHOUT sugar hiding it" model + its exceeds:
4// - malic is a softer acid than citric at equal molarity (1-3)
5// - the citric:malic BLEND beats either acid alone for roundness (4-5)
6// - a sweet-aroma whisper rounds WITHOUT sugar; clarity stays perfect (6-7)
7// - LIAR-KILL: sugar-free honest, a sugary recipe rejected + muted (8-10)
8// - CARBONATION is a flavor lever: adds sourness + lifts intensity (11-13)
9// - GENERATIVE: design a smooth strong SUGAR-FREE soda at a target (14-18)
10// Exit code = failed assertion number; 0 = all pass.
11
12import "nx_syscalls.nx"
13import "nx_soda_flavor.nx"
14
15func main() -> i64 {
16 // --- malic is the softer/smoother acid (less [H+] per mole) ---
17 if soda_malic_hplus_um(15) >= soda_citric_hplus_um(15) { return 1 }
18 if soda_citric_hplus_um(20) <= soda_citric_hplus_um(10) { return 2 }
19 if soda_citric_hplus_um(0) != 0 { return 3 }
20
21 // --- the BLEND beats either acid alone (pointy citric / flat malic) ---
22 let blend: i64 = soda_smoothness_milli(10, 10, 0)
23 if blend <= soda_smoothness_milli(20, 0, 0) { return 4 }
24 if blend <= soda_smoothness_milli(0, 20, 0) { return 5 }
25
26 // --- a sweet-aroma whisper rounds WITHOUT sugar; clarity stays perfect ---
27 if soda_smoothness_milli(13, 7, 150) <= soda_smoothness_milli(13, 7, 0) { return 6 }
28 if soda_clarity_milli(0) != 1000 { return 7 }
29
30 // --- LIAR-KILL: honest at zero sugar; a sugary recipe rejected + muted ---
31 if soda_is_honest_sugarfree(0) != 1 { return 8 }
32 if soda_is_honest_sugarfree(50) != 0 { return 9 }
33 if soda_clarity_milli(50) >= soda_clarity_milli(0) { return 10 }
34
35 // --- CARBONATION is a flavor lever: same flavor, +CO2 -> +sour +intensity ---
36 let rc: *NxSodaRecipe = (sys_mmap(48)) as *NxSodaRecipe
37 rc.citric_mM = 8
38 rc.malic_mM = 7
39 rc.aroma_milli = 150
40 rc.sugar_g_per_l = 0
41 rc.carbonation_volumes_milli = 4000
42 rc.temp_c = 4
43 let rf: *NxSodaRecipe = (sys_mmap(48)) as *NxSodaRecipe
44 rf.citric_mM = 8
45 rf.malic_mM = 7
46 rf.aroma_milli = 150
47 rf.sugar_g_per_l = 0
48 rf.carbonation_volumes_milli = 0
49 rf.temp_c = 4
50 if soda_recipe_sour_milli(rc) <= soda_recipe_sour_milli(rf) { return 11 }
51 if soda_recipe_intensity_milli(rc) <= soda_recipe_intensity_milli(rf) { return 12 }
52 if soda_recipe_honest(rc) != 1 { return 13 }
53
54 // --- GENERATIVE: design a smooth STRONG SUGAR-FREE soda at target sour ---
55 let d: *NxSodaRecipe = soda_design_smooth(400, 4)
56 if soda_recipe_sour_milli(d) < 400 { return 14 }
57 if soda_recipe_sour_milli(d) > 450 { return 15 }
58 if soda_recipe_honest(d) != 1 { return 16 }
59 if d.sugar_g_per_l != 0 { return 17 }
60 if soda_recipe_smoothness_milli(d) < 800 { return 18 }
61
62 return 0
63}