nx_phi_test.nx source
↩ module page · 39 lines · 1361 B
1import "nx_syscalls.nx"
2import "nx_phi.nx"
3
4func main() -> i64 {
5 // T1: phi constants
6 if NX_PHI_Q10 != 1657 { return 1 }
7 if NX_PHI_INV_Q10 != 633 { return 2 }
8
9 // T2: ratio 1618 / 1000 ~= phi
10 let r: i64 = nx_ratio_q10(1618, 1000)
11 let dist: i64 = nx_q10_abs_distance(r, NX_PHI_Q10)
12 if dist > 5 { return 10 }
13
14 // T3: phi-band membership
15 let band: i64 = nx_phi_band_check(NX_PHI_Q10, NX_PHI_TOLERANCE_Q10)
16 if band != NX_PHI_BAND_WITHIN { return 20 }
17 let band_below: i64 = nx_phi_band_check(800, NX_PHI_TOLERANCE_Q10)
18 if band_below != NX_PHI_BAND_BELOW { return 21 }
19 let band_above: i64 = nx_phi_band_check(2000, NX_PHI_TOLERANCE_Q10)
20 if band_above != NX_PHI_BAND_ABOVE { return 22 }
21
22 // T4: Fibonacci F(10) = 55
23 let f10: i64 = nx_fib(10)
24 if f10 != 55 { return 30 }
25
26 // T5: F(15)/F(14) ratio close to phi
27 let fr: i64 = nx_fib_ratio_q10(14)
28 let fr_dist: i64 = nx_q10_abs_distance(fr, NX_PHI_Q10)
29 if fr_dist > 10 { return 40 }
30
31 // T6: proportion score peaks at target, decays linearly
32 let perfect: i64 = nx_proportion_score_q10(NX_PHI_Q10, NX_PHI_Q10, 100)
33 if perfect != NX_Q10 { return 50 }
34 let off: i64 = nx_proportion_score_q10(NX_PHI_Q10 + 50, NX_PHI_Q10, 100)
35 if off > NX_Q10 / 2 + 20 { return 51 }
36 if off < NX_Q10 / 2 - 20 { return 52 }
37
38 return 0
39}