redscript-mc 2.5.0 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1243) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +5 -75
  3. package/README.zh.md +165 -147
  4. package/ROADMAP.md +195 -0
  5. package/dist/data/linalg/function/_vec2d_len_sq_fx.mcfunction +17 -0
  6. package/dist/data/linalg/function/_vec3d_len_sq_fx.mcfunction +27 -0
  7. package/dist/data/linalg/function/load.mcfunction +1 -0
  8. package/dist/data/linalg/function/mat2d_det.mcfunction +16 -0
  9. package/dist/data/linalg/function/mat2d_mul_r0c0.mcfunction +16 -0
  10. package/dist/data/linalg/function/mat2d_mul_r0c1.mcfunction +16 -0
  11. package/dist/data/linalg/function/mat2d_mul_r1c0.mcfunction +16 -0
  12. package/dist/data/linalg/function/mat2d_mul_r1c1.mcfunction +16 -0
  13. package/dist/data/linalg/function/mat2d_vecmul_x.mcfunction +16 -0
  14. package/dist/data/linalg/function/mat2d_vecmul_y.mcfunction +16 -0
  15. package/dist/data/linalg/function/solve2d_x.mcfunction +27 -0
  16. package/dist/data/linalg/function/solve2d_y.mcfunction +27 -0
  17. package/dist/data/linalg/function/vec2d_dist.mcfunction +15 -0
  18. package/dist/data/linalg/function/vec2d_dot.mcfunction +16 -0
  19. package/dist/data/linalg/function/vec2d_length.mcfunction +21 -0
  20. package/dist/data/linalg/function/vec2d_normalize_x.mcfunction +8 -0
  21. package/dist/data/linalg/function/vec2d_normalize_x__merge_1.mcfunction +10 -0
  22. package/dist/data/linalg/function/vec2d_normalize_x__then_0.mcfunction +3 -0
  23. package/dist/data/linalg/function/vec2d_normalize_y.mcfunction +8 -0
  24. package/dist/data/linalg/function/vec2d_normalize_y__merge_1.mcfunction +10 -0
  25. package/dist/data/linalg/function/vec2d_normalize_y__then_0.mcfunction +3 -0
  26. package/dist/data/linalg/function/vec3d_cross_x.mcfunction +16 -0
  27. package/dist/data/linalg/function/vec3d_cross_y.mcfunction +16 -0
  28. package/dist/data/linalg/function/vec3d_cross_z.mcfunction +16 -0
  29. package/dist/data/linalg/function/vec3d_dist.mcfunction +21 -0
  30. package/dist/data/linalg/function/vec3d_dot.mcfunction +26 -0
  31. package/dist/data/linalg/function/vec3d_length.mcfunction +31 -0
  32. package/dist/data/linalg/function/vec3d_normalize_x.mcfunction +9 -0
  33. package/dist/data/linalg/function/vec3d_normalize_x__merge_1.mcfunction +11 -0
  34. package/dist/data/linalg/function/vec3d_normalize_x__then_0.mcfunction +3 -0
  35. package/dist/data/linalg/function/vec3d_normalize_y.mcfunction +9 -0
  36. package/dist/data/linalg/function/vec3d_normalize_y__merge_1.mcfunction +11 -0
  37. package/dist/data/linalg/function/vec3d_normalize_y__then_0.mcfunction +3 -0
  38. package/dist/data/linalg/function/vec3d_normalize_z.mcfunction +9 -0
  39. package/dist/data/linalg/function/vec3d_normalize_z__merge_1.mcfunction +11 -0
  40. package/dist/data/linalg/function/vec3d_normalize_z__then_0.mcfunction +3 -0
  41. package/dist/data/math_hp/function/cos_hp.mcfunction +8 -0
  42. package/dist/data/math_hp/function/div3_hp.mcfunction +23 -0
  43. package/dist/data/math_hp/function/div_hp.mcfunction +13 -0
  44. package/dist/data/math_hp/function/init_div.mcfunction +1 -0
  45. package/dist/data/math_hp/function/init_trig.mcfunction +1 -0
  46. package/dist/data/math_hp/function/ln_5term.mcfunction +6 -0
  47. package/dist/data/math_hp/function/ln_5term__loop_body_1.mcfunction +8 -0
  48. package/dist/data/math_hp/function/ln_5term__loop_body_4.mcfunction +8 -0
  49. package/dist/data/math_hp/function/ln_5term__loop_exit_2.mcfunction +1 -0
  50. package/dist/data/math_hp/function/ln_5term__loop_exit_5.mcfunction +61 -0
  51. package/dist/data/math_hp/function/ln_5term__loop_header_0.mcfunction +3 -0
  52. package/dist/data/math_hp/function/ln_5term__loop_header_3.mcfunction +6 -0
  53. package/dist/data/math_hp/function/load.mcfunction +1 -0
  54. package/dist/data/math_hp/function/norm3_hp.mcfunction +43 -0
  55. package/dist/data/math_hp/function/sin_hp.mcfunction +8 -0
  56. package/dist/data/math_hp/function/sqrt_hp.mcfunction +17 -0
  57. package/dist/data/math_hp/function/sqrt_hp__merge_1.mcfunction +21 -0
  58. package/dist/data/math_hp/function/sqrt_hp__then_0.mcfunction +2 -0
  59. package/dist/data/minecraft/tags/function/load.json +1 -2
  60. package/dist/data/minecraft/tags/function/tick.json +1 -1
  61. package/dist/data/readme_demo/function/_draw.mcfunction +1 -0
  62. package/dist/data/readme_demo/function/_init.mcfunction +1 -0
  63. package/dist/data/readme_demo/function/_math_init.mcfunction +4 -0
  64. package/dist/data/readme_demo/function/_wave_tick.mcfunction +1 -0
  65. package/dist/data/readme_demo/function/_wave_tick__foreach_t8.mcfunction +109 -0
  66. package/dist/data/readme_demo/function/acos_approx.mcfunction +7 -0
  67. package/dist/data/readme_demo/function/approx_eq.mcfunction +10 -0
  68. package/dist/data/readme_demo/function/approx_eq__merge_1.mcfunction +3 -0
  69. package/dist/data/readme_demo/function/approx_eq__merge_3.mcfunction +2 -0
  70. package/dist/data/readme_demo/function/approx_eq__then_0.mcfunction +4 -0
  71. package/dist/data/readme_demo/function/approx_eq__then_2.mcfunction +2 -0
  72. package/dist/data/readme_demo/function/asin_approx.mcfunction +5 -0
  73. package/dist/data/readme_demo/function/asin_approx__merge_1.mcfunction +3 -0
  74. package/dist/data/readme_demo/function/asin_approx__merge_10.mcfunction +5 -0
  75. package/dist/data/readme_demo/function/asin_approx__merge_4.mcfunction +12 -0
  76. package/dist/data/readme_demo/function/asin_approx__merge_7.mcfunction +14 -0
  77. package/dist/data/readme_demo/function/asin_approx__then_0.mcfunction +2 -0
  78. package/dist/data/readme_demo/function/asin_approx__then_3.mcfunction +2 -0
  79. package/dist/data/readme_demo/function/asin_approx__then_6.mcfunction +2 -0
  80. package/dist/data/readme_demo/function/asin_approx__then_9.mcfunction +2 -0
  81. package/dist/data/readme_demo/function/cbrt_fx.mcfunction +5 -0
  82. package/dist/data/readme_demo/function/cbrt_fx__loop_body_6.mcfunction +7 -0
  83. package/dist/data/readme_demo/function/cbrt_fx__loop_exit_7.mcfunction +1 -0
  84. package/dist/data/readme_demo/function/cbrt_fx__loop_header_5.mcfunction +4 -0
  85. package/dist/data/readme_demo/function/cbrt_fx__merge_1.mcfunction +8 -0
  86. package/dist/data/readme_demo/function/cbrt_fx__merge_11.mcfunction +5 -0
  87. package/dist/data/readme_demo/function/cbrt_fx__merge_13.mcfunction +4 -0
  88. package/dist/data/readme_demo/function/cbrt_fx__merge_4.mcfunction +2 -0
  89. package/dist/data/readme_demo/function/cbrt_fx__merge_9.mcfunction +13 -0
  90. package/dist/data/readme_demo/function/cbrt_fx__then_0.mcfunction +2 -0
  91. package/dist/data/readme_demo/function/cbrt_fx__then_10.mcfunction +2 -0
  92. package/dist/data/readme_demo/function/cbrt_fx__then_12.mcfunction +2 -0
  93. package/dist/data/readme_demo/function/cbrt_fx__then_3.mcfunction +2 -0
  94. package/dist/data/readme_demo/function/cbrt_fx__then_8.mcfunction +2 -0
  95. package/dist/data/readme_demo/function/cbrt_newton.mcfunction +5 -0
  96. package/dist/data/readme_demo/function/cbrt_newton__else_7.mcfunction +2 -0
  97. package/dist/data/readme_demo/function/cbrt_newton__merge_1.mcfunction +11 -0
  98. package/dist/data/readme_demo/function/cbrt_newton__merge_4.mcfunction +1 -0
  99. package/dist/data/readme_demo/function/cbrt_newton__merge_6.mcfunction +1 -0
  100. package/dist/data/readme_demo/function/cbrt_newton__then_0.mcfunction +2 -0
  101. package/dist/data/readme_demo/function/cbrt_newton__then_3.mcfunction +17 -0
  102. package/dist/data/readme_demo/function/cbrt_newton__then_5.mcfunction +11 -0
  103. package/dist/data/readme_demo/function/ceil_div.mcfunction +9 -0
  104. package/dist/data/readme_demo/function/combinations.mcfunction +6 -0
  105. package/dist/data/readme_demo/function/combinations__loop_body_9.mcfunction +15 -0
  106. package/dist/data/readme_demo/function/combinations__loop_exit_10.mcfunction +1 -0
  107. package/dist/data/readme_demo/function/combinations__loop_header_8.mcfunction +3 -0
  108. package/dist/data/readme_demo/function/combinations__merge_1.mcfunction +3 -0
  109. package/dist/data/readme_demo/function/combinations__merge_4.mcfunction +6 -0
  110. package/dist/data/readme_demo/function/combinations__merge_7.mcfunction +3 -0
  111. package/dist/data/readme_demo/function/combinations__then_0.mcfunction +2 -0
  112. package/dist/data/readme_demo/function/combinations__then_3.mcfunction +2 -0
  113. package/dist/data/readme_demo/function/combinations__then_6.mcfunction +4 -0
  114. package/dist/data/readme_demo/function/cos_fixed.mcfunction +7 -0
  115. package/dist/data/readme_demo/function/cubic_disc_fx.mcfunction +26 -0
  116. package/dist/data/readme_demo/function/cubic_newton.mcfunction +8 -0
  117. package/dist/data/readme_demo/function/cubic_newton__loop_body_1.mcfunction +55 -0
  118. package/dist/data/readme_demo/function/cubic_newton__loop_exit_2.mcfunction +1 -0
  119. package/dist/data/readme_demo/function/cubic_newton__loop_header_0.mcfunction +4 -0
  120. package/dist/data/readme_demo/function/cubic_newton__merge_10.mcfunction +1 -0
  121. package/dist/data/readme_demo/function/cubic_newton__merge_4.mcfunction +4 -0
  122. package/dist/data/readme_demo/function/cubic_newton__merge_6.mcfunction +4 -0
  123. package/dist/data/readme_demo/function/cubic_newton__merge_8.mcfunction +4 -0
  124. package/dist/data/readme_demo/function/cubic_newton__then_3.mcfunction +2 -0
  125. package/dist/data/readme_demo/function/cubic_newton__then_5.mcfunction +13 -0
  126. package/dist/data/readme_demo/function/cubic_newton__then_7.mcfunction +4 -0
  127. package/dist/data/readme_demo/function/cubic_newton__then_9.mcfunction +2 -0
  128. package/dist/data/readme_demo/function/divfix.mcfunction +6 -0
  129. package/dist/data/readme_demo/function/divfix__merge_1.mcfunction +6 -0
  130. package/dist/data/readme_demo/function/divfix__then_0.mcfunction +2 -0
  131. package/dist/data/readme_demo/function/exp_fx.mcfunction +16 -0
  132. package/dist/data/readme_demo/function/exp_fx__loop_body_10.mcfunction +8 -0
  133. package/dist/data/readme_demo/function/exp_fx__loop_body_5.mcfunction +8 -0
  134. package/dist/data/readme_demo/function/exp_fx__loop_exit_11.mcfunction +1 -0
  135. package/dist/data/readme_demo/function/exp_fx__loop_exit_6.mcfunction +1 -0
  136. package/dist/data/readme_demo/function/exp_fx__loop_header_4.mcfunction +3 -0
  137. package/dist/data/readme_demo/function/exp_fx__loop_header_9.mcfunction +3 -0
  138. package/dist/data/readme_demo/function/exp_fx__merge_1.mcfunction +47 -0
  139. package/dist/data/readme_demo/function/exp_fx__merge_3.mcfunction +4 -0
  140. package/dist/data/readme_demo/function/exp_fx__merge_8.mcfunction +1 -0
  141. package/dist/data/readme_demo/function/exp_fx__then_0.mcfunction +7 -0
  142. package/dist/data/readme_demo/function/exp_fx__then_2.mcfunction +2 -0
  143. package/dist/data/readme_demo/function/exp_fx__then_7.mcfunction +5 -0
  144. package/dist/data/readme_demo/function/factorial.mcfunction +5 -0
  145. package/dist/data/readme_demo/function/factorial__loop_body_4.mcfunction +7 -0
  146. package/dist/data/readme_demo/function/factorial__loop_exit_5.mcfunction +1 -0
  147. package/dist/data/readme_demo/function/factorial__loop_header_3.mcfunction +3 -0
  148. package/dist/data/readme_demo/function/factorial__merge_1.mcfunction +3 -0
  149. package/dist/data/readme_demo/function/factorial__then_0.mcfunction +2 -0
  150. package/dist/data/readme_demo/function/gamma_int.mcfunction +5 -0
  151. package/dist/data/readme_demo/function/gamma_int__merge_1.mcfunction +6 -0
  152. package/dist/data/readme_demo/function/gamma_int__then_0.mcfunction +2 -0
  153. package/dist/data/readme_demo/function/gcd.mcfunction +7 -0
  154. package/dist/data/readme_demo/function/gcd__loop_body_5.mcfunction +5 -0
  155. package/dist/data/readme_demo/function/gcd__loop_exit_6.mcfunction +1 -0
  156. package/dist/data/readme_demo/function/gcd__loop_header_4.mcfunction +4 -0
  157. package/dist/data/readme_demo/function/gcd__merge_1.mcfunction +5 -0
  158. package/dist/data/readme_demo/function/gcd__merge_3.mcfunction +1 -0
  159. package/dist/data/readme_demo/function/gcd__then_0.mcfunction +4 -0
  160. package/dist/data/readme_demo/function/gcd__then_2.mcfunction +4 -0
  161. package/dist/data/readme_demo/function/isqrt.mcfunction +5 -0
  162. package/dist/data/readme_demo/function/isqrt__loop_body_10.mcfunction +8 -0
  163. package/dist/data/readme_demo/function/isqrt__loop_body_13.mcfunction +11 -0
  164. package/dist/data/readme_demo/function/isqrt__loop_body_7.mcfunction +8 -0
  165. package/dist/data/readme_demo/function/isqrt__loop_exit_11.mcfunction +2 -0
  166. package/dist/data/readme_demo/function/isqrt__loop_exit_14.mcfunction +1 -0
  167. package/dist/data/readme_demo/function/isqrt__loop_exit_8.mcfunction +9 -0
  168. package/dist/data/readme_demo/function/isqrt__loop_header_12.mcfunction +4 -0
  169. package/dist/data/readme_demo/function/isqrt__loop_header_6.mcfunction +4 -0
  170. package/dist/data/readme_demo/function/isqrt__loop_header_9.mcfunction +3 -0
  171. package/dist/data/readme_demo/function/isqrt__merge_1.mcfunction +4 -0
  172. package/dist/data/readme_demo/function/isqrt__merge_16.mcfunction +5 -0
  173. package/dist/data/readme_demo/function/isqrt__merge_4.mcfunction +3 -0
  174. package/dist/data/readme_demo/function/isqrt__then_0.mcfunction +2 -0
  175. package/dist/data/readme_demo/function/isqrt__then_15.mcfunction +1 -0
  176. package/dist/data/readme_demo/function/isqrt__then_3.mcfunction +2 -0
  177. package/dist/data/readme_demo/function/lcm.mcfunction +11 -0
  178. package/dist/data/readme_demo/function/lcm__merge_1.mcfunction +5 -0
  179. package/dist/data/readme_demo/function/lcm__then_0.mcfunction +2 -0
  180. package/dist/data/readme_demo/function/lerp.mcfunction +13 -0
  181. package/dist/data/readme_demo/function/ln.mcfunction +9 -0
  182. package/dist/data/readme_demo/function/ln__loop_body_1.mcfunction +8 -0
  183. package/dist/data/readme_demo/function/ln__loop_body_4.mcfunction +8 -0
  184. package/dist/data/readme_demo/function/ln__loop_exit_2.mcfunction +1 -0
  185. package/dist/data/readme_demo/function/ln__loop_exit_5.mcfunction +37 -0
  186. package/dist/data/readme_demo/function/ln__loop_header_0.mcfunction +3 -0
  187. package/dist/data/readme_demo/function/ln__loop_header_3.mcfunction +6 -0
  188. package/dist/data/readme_demo/function/load.mcfunction +1 -0
  189. package/dist/data/readme_demo/function/log10_fx.mcfunction +11 -0
  190. package/dist/data/readme_demo/function/log2_fx.mcfunction +11 -0
  191. package/dist/data/readme_demo/function/log2_int.mcfunction +5 -0
  192. package/dist/data/readme_demo/function/log2_int__loop_body_4.mcfunction +8 -0
  193. package/dist/data/readme_demo/function/log2_int__loop_exit_5.mcfunction +1 -0
  194. package/dist/data/readme_demo/function/log2_int__loop_header_3.mcfunction +4 -0
  195. package/dist/data/readme_demo/function/log2_int__merge_1.mcfunction +3 -0
  196. package/dist/data/readme_demo/function/log2_int__then_0.mcfunction +2 -0
  197. package/dist/data/readme_demo/function/loga_fx.mcfunction +10 -0
  198. package/dist/data/readme_demo/function/loga_fx__merge_1.mcfunction +9 -0
  199. package/dist/data/readme_demo/function/loga_fx__then_0.mcfunction +2 -0
  200. package/dist/data/readme_demo/function/map.mcfunction +12 -0
  201. package/dist/data/readme_demo/function/map__merge_1.mcfunction +11 -0
  202. package/dist/data/readme_demo/function/map__then_0.mcfunction +1 -0
  203. package/dist/data/readme_demo/function/mulfix.mcfunction +8 -0
  204. package/dist/data/readme_demo/function/newton_step.mcfunction +7 -0
  205. package/dist/data/readme_demo/function/newton_step__merge_1.mcfunction +8 -0
  206. package/dist/data/readme_demo/function/newton_step__then_0.mcfunction +1 -0
  207. package/dist/data/readme_demo/function/pow_int.mcfunction +6 -0
  208. package/dist/data/readme_demo/function/pow_int__loop_body_4.mcfunction +7 -0
  209. package/dist/data/readme_demo/function/pow_int__loop_exit_5.mcfunction +1 -0
  210. package/dist/data/readme_demo/function/pow_int__loop_header_3.mcfunction +4 -0
  211. package/dist/data/readme_demo/function/pow_int__merge_1.mcfunction +4 -0
  212. package/dist/data/readme_demo/function/pow_int__merge_7.mcfunction +8 -0
  213. package/dist/data/readme_demo/function/pow_int__then_0.mcfunction +2 -0
  214. package/dist/data/readme_demo/function/pow_int__then_6.mcfunction +4 -0
  215. package/dist/data/readme_demo/function/quadratic_disc.mcfunction +12 -0
  216. package/dist/data/readme_demo/function/quadratic_x1.mcfunction +7 -0
  217. package/dist/data/readme_demo/function/quadratic_x1__merge_1.mcfunction +13 -0
  218. package/dist/data/readme_demo/function/quadratic_x1__merge_4.mcfunction +15 -0
  219. package/dist/data/readme_demo/function/quadratic_x1__then_0.mcfunction +2 -0
  220. package/dist/data/readme_demo/function/quadratic_x1__then_3.mcfunction +2 -0
  221. package/dist/data/readme_demo/function/quadratic_x2.mcfunction +7 -0
  222. package/dist/data/readme_demo/function/quadratic_x2__merge_1.mcfunction +13 -0
  223. package/dist/data/readme_demo/function/quadratic_x2__merge_4.mcfunction +15 -0
  224. package/dist/data/readme_demo/function/quadratic_x2__then_0.mcfunction +2 -0
  225. package/dist/data/readme_demo/function/quadratic_x2__then_3.mcfunction +2 -0
  226. package/dist/data/readme_demo/function/sign.mcfunction +5 -0
  227. package/dist/data/readme_demo/function/sign__merge_1.mcfunction +4 -0
  228. package/dist/data/readme_demo/function/sign__merge_4.mcfunction +2 -0
  229. package/dist/data/readme_demo/function/sign__then_0.mcfunction +2 -0
  230. package/dist/data/readme_demo/function/sign__then_3.mcfunction +2 -0
  231. package/dist/data/readme_demo/function/simpson_step.mcfunction +16 -0
  232. package/dist/data/readme_demo/function/sin_fixed.mcfunction +9 -0
  233. package/dist/data/readme_demo/function/sin_fixed__merge_1.mcfunction +4 -0
  234. package/dist/data/readme_demo/function/sin_fixed__merge_3.mcfunction +4 -0
  235. package/dist/data/readme_demo/function/sin_fixed__merge_6.mcfunction +4 -0
  236. package/dist/data/readme_demo/function/sin_fixed__merge_9.mcfunction +10 -0
  237. package/dist/data/readme_demo/function/sin_fixed__then_0.mcfunction +4 -0
  238. package/dist/data/readme_demo/function/sin_fixed__then_2.mcfunction +6 -0
  239. package/dist/data/readme_demo/function/sin_fixed__then_5.mcfunction +8 -0
  240. package/dist/data/readme_demo/function/sin_fixed__then_8.mcfunction +10 -0
  241. package/dist/data/readme_demo/function/smootherstep.mcfunction +10 -0
  242. package/dist/data/readme_demo/function/smootherstep__merge_1.mcfunction +12 -0
  243. package/dist/data/readme_demo/function/smootherstep__merge_4.mcfunction +4 -0
  244. package/dist/data/readme_demo/function/smootherstep__merge_6.mcfunction +27 -0
  245. package/dist/data/readme_demo/function/smootherstep__then_0.mcfunction +2 -0
  246. package/dist/data/readme_demo/function/smootherstep__then_3.mcfunction +2 -0
  247. package/dist/data/readme_demo/function/smootherstep__then_5.mcfunction +2 -0
  248. package/dist/data/readme_demo/function/smoothstep.mcfunction +10 -0
  249. package/dist/data/readme_demo/function/smoothstep__merge_1.mcfunction +12 -0
  250. package/dist/data/readme_demo/function/smoothstep__merge_4.mcfunction +4 -0
  251. package/dist/data/readme_demo/function/smoothstep__merge_6.mcfunction +15 -0
  252. package/dist/data/readme_demo/function/smoothstep__then_0.mcfunction +2 -0
  253. package/dist/data/readme_demo/function/smoothstep__then_3.mcfunction +2 -0
  254. package/dist/data/readme_demo/function/smoothstep__then_5.mcfunction +2 -0
  255. package/dist/data/readme_demo/function/solve2x2_x.mcfunction +17 -0
  256. package/dist/data/readme_demo/function/solve2x2_x__merge_1.mcfunction +12 -0
  257. package/dist/data/readme_demo/function/solve2x2_x__then_0.mcfunction +2 -0
  258. package/dist/data/readme_demo/function/solve2x2_y.mcfunction +17 -0
  259. package/dist/data/readme_demo/function/solve2x2_y__merge_1.mcfunction +12 -0
  260. package/dist/data/readme_demo/function/solve2x2_y__then_0.mcfunction +2 -0
  261. package/dist/data/readme_demo/function/sqrt_fixed.mcfunction +8 -0
  262. package/dist/data/readme_demo/function/sqrt_fx.mcfunction +8 -0
  263. package/dist/data/readme_demo/function/start.mcfunction +2 -0
  264. package/dist/data/readme_demo/function/stop.mcfunction +1 -0
  265. package/dist/data/readme_demo/function/trapezoid_step.mcfunction +11 -0
  266. package/dist/data/stdextra/function/__load.mcfunction +2 -0
  267. package/dist/data/stdextra/function/load.mcfunction +1 -0
  268. package/dist/data/stdextra/function/test_bigint.mcfunction +52 -0
  269. package/dist/data/stdextra/function/test_bits.mcfunction +33 -0
  270. package/dist/data/stdextra/function/test_list_sort.mcfunction +55 -0
  271. package/dist/data/stdextra/function/test_random.mcfunction +17 -0
  272. package/dist/data/stdextra/function/test_random__merge_1.mcfunction +4 -0
  273. package/dist/data/stdextra/function/test_random__merge_11.mcfunction +1 -0
  274. package/dist/data/stdextra/function/test_random__merge_3.mcfunction +14 -0
  275. package/dist/data/stdextra/function/test_random__merge_5.mcfunction +8 -0
  276. package/dist/data/stdextra/function/test_random__merge_7.mcfunction +1 -0
  277. package/dist/data/stdextra/function/test_random__merge_9.mcfunction +1 -0
  278. package/dist/data/stdextra/function/test_random__then_0.mcfunction +4 -0
  279. package/dist/data/stdextra/function/test_random__then_10.mcfunction +2 -0
  280. package/dist/data/stdextra/function/test_random__then_2.mcfunction +2 -0
  281. package/dist/data/stdextra/function/test_random__then_4.mcfunction +4 -0
  282. package/dist/data/stdextra/function/test_random__then_6.mcfunction +2 -0
  283. package/dist/data/stdextra/function/test_random__then_8.mcfunction +4 -0
  284. package/dist/data/test/function/__dyn_idx_test_arrays_nums.mcfunction +1 -0
  285. package/dist/data/test/function/__dyn_idx_test_arrays_parent.mcfunction +1 -0
  286. package/dist/data/test/function/__dyn_idx_test_arrays_queue.mcfunction +1 -0
  287. package/dist/data/test/function/__dyn_idx_test_arrays_rev.mcfunction +1 -0
  288. package/dist/data/test/function/__dyn_idx_test_arrays_visited.mcfunction +1 -0
  289. package/dist/data/test/function/__dyn_wrt_test_arrays_parent.mcfunction +1 -0
  290. package/dist/data/test/function/__dyn_wrt_test_arrays_visited.mcfunction +1 -0
  291. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_1.mcfunction +2 -0
  292. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_1__loop_body_1.mcfunction +17 -0
  293. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_1__loop_body_1_continue.mcfunction +1 -0
  294. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_1__loop_body_1_yield.mcfunction +1 -0
  295. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_1__loop_header_0.mcfunction +4 -0
  296. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_1__loop_header_0_exit.mcfunction +1 -0
  297. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2.mcfunction +2 -0
  298. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__else_8.mcfunction +19 -0
  299. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__loop_body_4.mcfunction +9 -0
  300. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__loop_header_3.mcfunction +3 -0
  301. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__loop_header_3_exit.mcfunction +1 -0
  302. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__merge_10.mcfunction +11 -0
  303. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__merge_12.mcfunction +1 -0
  304. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__merge_14.mcfunction +11 -0
  305. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__merge_16.mcfunction +1 -0
  306. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__merge_18.mcfunction +11 -0
  307. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__merge_20.mcfunction +1 -0
  308. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__merge_22.mcfunction +1 -0
  309. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__merge_24.mcfunction +1 -0
  310. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__merge_7.mcfunction +6 -0
  311. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__merge_7_continue.mcfunction +1 -0
  312. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__merge_7_yield.mcfunction +1 -0
  313. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__then_11.mcfunction +15 -0
  314. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__then_13.mcfunction +13 -0
  315. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__then_15.mcfunction +15 -0
  316. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__then_17.mcfunction +13 -0
  317. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__then_19.mcfunction +15 -0
  318. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__then_21.mcfunction +13 -0
  319. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__then_23.mcfunction +15 -0
  320. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__then_6.mcfunction +2 -0
  321. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_2__then_9.mcfunction +13 -0
  322. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_3.mcfunction +2 -0
  323. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_3__else_32.mcfunction +4 -0
  324. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_3__loop_body_28.mcfunction +6 -0
  325. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_3__loop_header_27.mcfunction +4 -0
  326. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_3__loop_header_27_exit.mcfunction +1 -0
  327. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_3__merge_31.mcfunction +6 -0
  328. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_3__merge_31_continue.mcfunction +1 -0
  329. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_3__merge_31_yield.mcfunction +1 -0
  330. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_3__then_30.mcfunction +2 -0
  331. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_4.mcfunction +2 -0
  332. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_4__loop_body_34.mcfunction +16 -0
  333. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_4__loop_body_34_continue.mcfunction +1 -0
  334. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_4__loop_body_34_yield.mcfunction +1 -0
  335. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_4__loop_header_33.mcfunction +4 -0
  336. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_4__loop_header_33_exit.mcfunction +1 -0
  337. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_5.mcfunction +16 -0
  338. package/dist/data/test/function/_coro_pathfind_bfs_coro_cont_5__merge_26.mcfunction +1 -0
  339. package/dist/data/test/function/_coro_pathfind_bfs_coro_tick.mcfunction +4 -0
  340. package/dist/data/test/function/_coro_pathfind_bfs_coro_tick__call_1.mcfunction +1 -0
  341. package/dist/data/test/function/_coro_pathfind_bfs_coro_tick__call_2.mcfunction +1 -0
  342. package/dist/data/test/function/_coro_pathfind_bfs_coro_tick__call_3.mcfunction +1 -0
  343. package/dist/data/test/function/_coro_pathfind_bfs_coro_tick__call_4.mcfunction +1 -0
  344. package/dist/data/test/function/_coro_pathfind_bfs_coro_tick__call_5.mcfunction +1 -0
  345. package/dist/data/test/function/_coro_pathfind_bfs_coro_tick__check_2.mcfunction +4 -0
  346. package/dist/data/test/function/_coro_pathfind_bfs_coro_tick__check_3.mcfunction +4 -0
  347. package/dist/data/test/function/_coro_pathfind_bfs_coro_tick__check_4.mcfunction +4 -0
  348. package/dist/data/test/function/_coro_pathfind_bfs_coro_tick__check_5.mcfunction +4 -0
  349. package/dist/data/test/function/_coro_pathfind_bfs_coro_tick__done.mcfunction +1 -0
  350. package/dist/data/test/function/_hsl_chroma_x.mcfunction +1 -2
  351. package/dist/data/test/function/aabb_contains.mcfunction +1 -2
  352. package/dist/data/test/function/aabb_contains__merge_1.mcfunction +1 -2
  353. package/dist/data/test/function/aabb_contains__merge_10.mcfunction +1 -2
  354. package/dist/data/test/function/aabb_contains__merge_13.mcfunction +1 -2
  355. package/dist/data/test/function/aabb_contains__merge_4.mcfunction +1 -2
  356. package/dist/data/test/function/aabb_contains__merge_7.mcfunction +1 -2
  357. package/dist/data/test/function/acos_approx.mcfunction +7 -0
  358. package/dist/data/test/function/add_to_team.mcfunction +5 -0
  359. package/dist/data/test/function/angle_diff.mcfunction +1 -2
  360. package/dist/data/test/function/angle_normalize__loop_header_0.mcfunction +1 -2
  361. package/dist/data/test/function/angle_normalize__loop_header_3.mcfunction +1 -2
  362. package/dist/data/test/function/angry_at.mcfunction +1 -0
  363. package/dist/data/test/function/apply_damage.mcfunction +12 -0
  364. package/dist/data/test/function/apply_damage__else_2.mcfunction +2 -0
  365. package/dist/data/test/function/apply_damage__merge_1.mcfunction +1 -0
  366. package/dist/data/test/function/apply_damage__then_0.mcfunction +2 -0
  367. package/dist/data/test/function/arr_test.mcfunction +4 -0
  368. package/dist/data/test/function/asin_approx.mcfunction +5 -0
  369. package/dist/data/test/function/asin_approx__merge_1.mcfunction +3 -0
  370. package/dist/data/test/function/asin_approx__merge_10.mcfunction +5 -0
  371. package/dist/data/test/function/asin_approx__merge_4.mcfunction +12 -0
  372. package/dist/data/test/function/asin_approx__merge_7.mcfunction +14 -0
  373. package/dist/data/test/function/asin_approx__then_0.mcfunction +2 -0
  374. package/dist/data/test/function/asin_approx__then_3.mcfunction +2 -0
  375. package/dist/data/test/function/asin_approx__then_6.mcfunction +2 -0
  376. package/dist/data/test/function/asin_approx__then_9.mcfunction +2 -0
  377. package/dist/data/test/function/barrier_wall.mcfunction +1 -0
  378. package/dist/data/test/function/bernoulli.mcfunction +1 -2
  379. package/dist/data/test/function/bernoulli__merge_1.mcfunction +1 -2
  380. package/dist/data/test/function/bigint_chunk.mcfunction +2 -0
  381. package/dist/data/test/function/bigint_div_small.mcfunction +6 -0
  382. package/dist/data/test/function/bigint_div_small__loop_body_1.mcfunction +12 -0
  383. package/dist/data/test/function/bigint_div_small__loop_exit_2.mcfunction +1 -0
  384. package/dist/data/test/function/bigint_div_small__loop_header_0.mcfunction +3 -0
  385. package/dist/data/test/function/bigint_mod_small.mcfunction +6 -0
  386. package/dist/data/test/function/bigint_mod_small__loop_body_1.mcfunction +12 -0
  387. package/dist/data/test/function/bigint_mod_small__loop_exit_2.mcfunction +1 -0
  388. package/dist/data/test/function/bigint_mod_small__loop_header_0.mcfunction +3 -0
  389. package/dist/data/test/function/bit_and__loop_body_1.mcfunction +1 -2
  390. package/dist/data/test/function/bit_and__loop_header_0.mcfunction +1 -2
  391. package/dist/data/test/function/bit_and__then_3.mcfunction +1 -2
  392. package/dist/data/test/function/bit_clear__loop_exit_2.mcfunction +1 -2
  393. package/dist/data/test/function/bit_clear__loop_header_0.mcfunction +1 -2
  394. package/dist/data/test/function/bit_get__loop_header_0.mcfunction +1 -2
  395. package/dist/data/test/function/bit_not__loop_body_1.mcfunction +1 -2
  396. package/dist/data/test/function/bit_not__loop_header_0.mcfunction +1 -2
  397. package/dist/data/test/function/bit_or__loop_body_1.mcfunction +1 -2
  398. package/dist/data/test/function/bit_or__loop_header_0.mcfunction +1 -2
  399. package/dist/data/test/function/bit_or__merge_4.mcfunction +1 -2
  400. package/dist/data/test/function/bit_or__then_5.mcfunction +1 -2
  401. package/dist/data/test/function/bit_set__loop_exit_2.mcfunction +1 -2
  402. package/dist/data/test/function/bit_set__loop_header_0.mcfunction +1 -2
  403. package/dist/data/test/function/bit_shl__loop_header_0.mcfunction +1 -2
  404. package/dist/data/test/function/bit_shr__loop_header_0.mcfunction +1 -2
  405. package/dist/data/test/function/bit_toggle__loop_exit_2.mcfunction +1 -2
  406. package/dist/data/test/function/bit_toggle__loop_header_0.mcfunction +1 -2
  407. package/dist/data/test/function/bit_xor__loop_body_1.mcfunction +1 -2
  408. package/dist/data/test/function/bit_xor__loop_header_0.mcfunction +1 -2
  409. package/dist/data/test/function/buff_all.mcfunction +22 -0
  410. package/dist/data/test/function/cbrt_newton.mcfunction +5 -0
  411. package/dist/data/test/function/cbrt_newton__else_7.mcfunction +2 -0
  412. package/dist/data/test/function/cbrt_newton__merge_1.mcfunction +11 -0
  413. package/dist/data/test/function/cbrt_newton__merge_4.mcfunction +1 -0
  414. package/dist/data/test/function/cbrt_newton__merge_6.mcfunction +1 -0
  415. package/dist/data/test/function/cbrt_newton__then_0.mcfunction +2 -0
  416. package/dist/data/test/function/cbrt_newton__then_3.mcfunction +17 -0
  417. package/dist/data/test/function/cbrt_newton__then_5.mcfunction +11 -0
  418. package/dist/data/test/function/check_holding_item.mcfunction +1 -0
  419. package/dist/data/test/function/check_look_down.mcfunction +1 -0
  420. package/dist/data/test/function/check_look_down__foreach_t0.mcfunction +2 -0
  421. package/dist/data/test/function/check_look_straight.mcfunction +1 -0
  422. package/dist/data/test/function/check_look_straight__foreach_t0.mcfunction +2 -0
  423. package/dist/data/test/function/check_look_up.mcfunction +1 -0
  424. package/dist/data/test/function/check_look_up__foreach_t0.mcfunction +2 -0
  425. package/dist/data/test/function/cleanup_teams.mcfunction +8 -0
  426. package/dist/data/test/function/clear_area.mcfunction +1 -0
  427. package/dist/data/test/function/clear_effect.mcfunction +1 -0
  428. package/dist/data/test/function/clear_effects.mcfunction +1 -0
  429. package/dist/data/test/function/clear_inventory.mcfunction +1 -0
  430. package/dist/data/test/function/cooldown_ready.mcfunction +7 -0
  431. package/dist/data/test/function/cooldown_ready__merge_1.mcfunction +4 -0
  432. package/dist/data/test/function/cooldown_ready__merge_4.mcfunction +2 -0
  433. package/dist/data/test/function/cooldown_ready__then_0.mcfunction +2 -0
  434. package/dist/data/test/function/cooldown_ready__then_3.mcfunction +2 -0
  435. package/dist/data/test/function/cooldown_start.mcfunction +3 -0
  436. package/dist/data/test/function/cooldown_tick.mcfunction +7 -0
  437. package/dist/data/test/function/cooldown_tick__else_5.mcfunction +2 -0
  438. package/dist/data/test/function/cooldown_tick__merge_1.mcfunction +4 -0
  439. package/dist/data/test/function/cooldown_tick__merge_4.mcfunction +1 -0
  440. package/dist/data/test/function/cooldown_tick__merge_7.mcfunction +1 -0
  441. package/dist/data/test/function/cooldown_tick__then_0.mcfunction +1 -0
  442. package/dist/data/test/function/cooldown_tick__then_3.mcfunction +7 -0
  443. package/dist/data/test/function/cooldown_tick__then_6.mcfunction +2 -0
  444. package/dist/data/test/function/cos_hp.mcfunction +4 -2
  445. package/dist/data/test/function/create_blue_team.mcfunction +10 -0
  446. package/dist/data/test/function/create_green_team.mcfunction +10 -0
  447. package/dist/data/test/function/create_health_bar.mcfunction +24 -0
  448. package/dist/data/test/function/create_progress_bar.mcfunction +24 -0
  449. package/dist/data/test/function/create_red_team.mcfunction +10 -0
  450. package/dist/data/test/function/create_team.mcfunction +8 -0
  451. package/dist/data/test/function/create_timer_bar.mcfunction +30 -0
  452. package/dist/data/test/function/create_yellow_team.mcfunction +10 -0
  453. package/dist/data/test/function/cubic_disc_fx.mcfunction +26 -0
  454. package/dist/data/test/function/cubic_newton.mcfunction +8 -0
  455. package/dist/data/test/function/cubic_newton__loop_body_1.mcfunction +55 -0
  456. package/dist/data/test/function/cubic_newton__loop_exit_2.mcfunction +1 -0
  457. package/dist/data/test/function/cubic_newton__loop_header_0.mcfunction +4 -0
  458. package/dist/data/test/function/cubic_newton__merge_10.mcfunction +1 -0
  459. package/dist/data/test/function/cubic_newton__merge_4.mcfunction +4 -0
  460. package/dist/data/test/function/cubic_newton__merge_6.mcfunction +4 -0
  461. package/dist/data/test/function/cubic_newton__merge_8.mcfunction +4 -0
  462. package/dist/data/test/function/cubic_newton__then_3.mcfunction +2 -0
  463. package/dist/data/test/function/cubic_newton__then_5.mcfunction +13 -0
  464. package/dist/data/test/function/cubic_newton__then_7.mcfunction +4 -0
  465. package/dist/data/test/function/cubic_newton__then_9.mcfunction +2 -0
  466. package/dist/data/test/function/curve_length_2d.mcfunction +6 -0
  467. package/dist/data/test/function/curve_length_2d__loop_body_1.mcfunction +32 -0
  468. package/dist/data/test/function/curve_length_2d__loop_exit_2.mcfunction +1 -0
  469. package/dist/data/test/function/curve_length_2d__loop_header_0.mcfunction +5 -0
  470. package/dist/data/test/function/cylinder_contains.mcfunction +1 -2
  471. package/dist/data/test/function/damage.mcfunction +9 -0
  472. package/dist/data/test/function/damage__else_2.mcfunction +2 -0
  473. package/dist/data/test/function/damage__merge_1.mcfunction +1 -0
  474. package/dist/data/test/function/damage__then_0.mcfunction +2 -0
  475. package/dist/data/test/function/deriv_central.mcfunction +7 -0
  476. package/dist/data/test/function/deriv_central__merge_1.mcfunction +10 -0
  477. package/dist/data/test/function/deriv_central__then_0.mcfunction +2 -0
  478. package/dist/data/test/function/deriv_forward.mcfunction +7 -0
  479. package/dist/data/test/function/deriv_forward__merge_1.mcfunction +8 -0
  480. package/dist/data/test/function/deriv_forward__then_0.mcfunction +2 -0
  481. package/dist/data/test/function/disable_fire_spread.mcfunction +1 -0
  482. package/dist/data/test/function/disable_keep_inventory.mcfunction +1 -0
  483. package/dist/data/test/function/disable_mob_griefing.mcfunction +1 -0
  484. package/dist/data/test/function/div3_hp.mcfunction +23 -0
  485. package/dist/data/test/function/div_hp.mcfunction +13 -0
  486. package/dist/data/test/function/draw_circle.mcfunction +8 -0
  487. package/dist/data/test/function/draw_circle__loop_body_1.mcfunction +34 -0
  488. package/dist/data/test/function/draw_circle__loop_exit_2.mcfunction +1 -0
  489. package/dist/data/test/function/draw_circle__loop_header_0.mcfunction +3 -0
  490. package/dist/data/test/function/draw_helix.mcfunction +10 -0
  491. package/dist/data/test/function/draw_helix__loop_body_1.mcfunction +42 -0
  492. package/dist/data/test/function/draw_helix__loop_exit_2.mcfunction +1 -0
  493. package/dist/data/test/function/draw_helix__loop_header_0.mcfunction +3 -0
  494. package/dist/data/test/function/draw_line_2d.mcfunction +9 -0
  495. package/dist/data/test/function/draw_line_2d__loop_body_1.mcfunction +34 -0
  496. package/dist/data/test/function/draw_line_2d__loop_exit_2.mcfunction +1 -0
  497. package/dist/data/test/function/draw_line_2d__loop_header_0.mcfunction +3 -0
  498. package/dist/data/test/function/ease_in_expo.mcfunction +1 -2
  499. package/dist/data/test/function/ease_in_out_back.mcfunction +1 -2
  500. package/dist/data/test/function/ease_in_out_bounce.mcfunction +1 -2
  501. package/dist/data/test/function/ease_in_out_cubic.mcfunction +1 -2
  502. package/dist/data/test/function/ease_in_out_quad.mcfunction +1 -2
  503. package/dist/data/test/function/ease_in_out_sine.mcfunction +1 -2
  504. package/dist/data/test/function/ease_out_bounce.mcfunction +1 -2
  505. package/dist/data/test/function/ease_out_bounce__merge_1.mcfunction +1 -2
  506. package/dist/data/test/function/ease_out_bounce__merge_4.mcfunction +1 -2
  507. package/dist/data/test/function/ease_out_expo.mcfunction +1 -2
  508. package/dist/data/test/function/enable_keep_inventory.mcfunction +1 -0
  509. package/dist/data/test/function/end_sparkles_at.mcfunction +1 -0
  510. package/dist/data/test/function/enemy_health.mcfunction +2 -0
  511. package/dist/data/test/function/example_right_click.mcfunction +1 -0
  512. package/dist/data/test/function/example_right_click__foreach_t0.mcfunction +5 -0
  513. package/dist/data/test/function/example_right_click__foreach_t0__merge_1.mcfunction +1 -0
  514. package/dist/data/test/function/example_right_click__foreach_t0__then_0.mcfunction +3 -0
  515. package/dist/data/test/function/exp_dist_approx.mcfunction +1 -2
  516. package/dist/data/test/function/exp_dist_approx__merge_1.mcfunction +1 -2
  517. package/dist/data/test/function/exp_dist_approx__merge_3.mcfunction +1 -2
  518. package/dist/data/test/function/explosion_effect.mcfunction +1 -0
  519. package/dist/data/test/function/fbm_1d__loop_exit_2.mcfunction +1 -2
  520. package/dist/data/test/function/fbm_1d__loop_header_0.mcfunction +1 -2
  521. package/dist/data/test/function/fbm_2d__loop_exit_2.mcfunction +1 -2
  522. package/dist/data/test/function/fbm_2d__loop_header_0.mcfunction +1 -2
  523. package/dist/data/test/function/flames.mcfunction +1 -0
  524. package/dist/data/test/function/gather_all.mcfunction +8 -0
  525. package/dist/data/test/function/give_kit_archer.mcfunction +6 -0
  526. package/dist/data/test/function/give_kit_mage.mcfunction +5 -0
  527. package/dist/data/test/function/give_kit_warrior.mcfunction +6 -0
  528. package/dist/data/test/function/glass_box.mcfunction +2 -0
  529. package/dist/data/test/function/glow.mcfunction +1 -0
  530. package/dist/data/test/function/goto_arena.mcfunction +7 -0
  531. package/dist/data/test/function/goto_lobby.mcfunction +7 -0
  532. package/dist/data/test/function/happy_at.mcfunction +1 -0
  533. package/dist/data/test/function/hash_1d_pos.mcfunction +1 -2
  534. package/dist/data/test/function/hash_2d_pos.mcfunction +1 -2
  535. package/dist/data/test/function/heal.mcfunction +5 -0
  536. package/dist/data/test/function/heap_new.mcfunction +7 -0
  537. package/dist/data/test/function/heap_new__loop_body_1.mcfunction +7 -0
  538. package/dist/data/test/function/heap_new__loop_exit_2.mcfunction +1 -0
  539. package/dist/data/test/function/heap_new__loop_header_0.mcfunction +4 -0
  540. package/dist/data/test/function/heap_peek.mcfunction +2 -0
  541. package/dist/data/test/function/heap_pop.mcfunction +4 -0
  542. package/dist/data/test/function/heap_pop__else_13.mcfunction +2 -0
  543. package/dist/data/test/function/heap_pop__loop_body_1.mcfunction +14 -0
  544. package/dist/data/test/function/heap_pop__loop_exit_2.mcfunction +1 -0
  545. package/dist/data/test/function/heap_pop__loop_header_0.mcfunction +4 -0
  546. package/dist/data/test/function/heap_pop__merge_10.mcfunction +1 -0
  547. package/dist/data/test/function/heap_pop__merge_12.mcfunction +1 -0
  548. package/dist/data/test/function/heap_pop__merge_4.mcfunction +3 -0
  549. package/dist/data/test/function/heap_pop__merge_6.mcfunction +1 -0
  550. package/dist/data/test/function/heap_pop__merge_8.mcfunction +3 -0
  551. package/dist/data/test/function/heap_pop__then_11.mcfunction +2 -0
  552. package/dist/data/test/function/heap_pop__then_3.mcfunction +3 -0
  553. package/dist/data/test/function/heap_pop__then_5.mcfunction +2 -0
  554. package/dist/data/test/function/heap_pop__then_7.mcfunction +3 -0
  555. package/dist/data/test/function/heap_pop__then_9.mcfunction +2 -0
  556. package/dist/data/test/function/heap_push.mcfunction +6 -0
  557. package/dist/data/test/function/heap_push__else_5.mcfunction +2 -0
  558. package/dist/data/test/function/heap_push__else_8.mcfunction +2 -0
  559. package/dist/data/test/function/heap_push__loop_body_1.mcfunction +4 -0
  560. package/dist/data/test/function/heap_push__loop_exit_2.mcfunction +1 -0
  561. package/dist/data/test/function/heap_push__loop_header_0.mcfunction +4 -0
  562. package/dist/data/test/function/heap_push__merge_4.mcfunction +1 -0
  563. package/dist/data/test/function/heap_push__merge_7.mcfunction +1 -0
  564. package/dist/data/test/function/heap_push__then_3.mcfunction +7 -0
  565. package/dist/data/test/function/heap_push__then_6.mcfunction +2 -0
  566. package/dist/data/test/function/heap_size.mcfunction +2 -0
  567. package/dist/data/test/function/hearts_at.mcfunction +1 -0
  568. package/dist/data/test/function/hide_bar.mcfunction +4 -0
  569. package/dist/data/test/function/hsl_to_b.mcfunction +1 -2
  570. package/dist/data/test/function/hsl_to_b__merge_1.mcfunction +1 -2
  571. package/dist/data/test/function/hsl_to_b__merge_12.mcfunction +1 -2
  572. package/dist/data/test/function/hsl_to_b__merge_3.mcfunction +1 -2
  573. package/dist/data/test/function/hsl_to_b__merge_6.mcfunction +1 -2
  574. package/dist/data/test/function/hsl_to_b__merge_9.mcfunction +1 -2
  575. package/dist/data/test/function/hsl_to_g.mcfunction +1 -2
  576. package/dist/data/test/function/hsl_to_g__merge_1.mcfunction +1 -2
  577. package/dist/data/test/function/hsl_to_g__merge_12.mcfunction +1 -2
  578. package/dist/data/test/function/hsl_to_g__merge_3.mcfunction +1 -2
  579. package/dist/data/test/function/hsl_to_g__merge_6.mcfunction +1 -2
  580. package/dist/data/test/function/hsl_to_g__merge_9.mcfunction +1 -2
  581. package/dist/data/test/function/hsl_to_r.mcfunction +1 -2
  582. package/dist/data/test/function/hsl_to_r__merge_1.mcfunction +1 -2
  583. package/dist/data/test/function/hsl_to_r__merge_12.mcfunction +1 -2
  584. package/dist/data/test/function/hsl_to_r__merge_3.mcfunction +1 -2
  585. package/dist/data/test/function/hsl_to_r__merge_6.mcfunction +1 -2
  586. package/dist/data/test/function/hsl_to_r__merge_9.mcfunction +1 -2
  587. package/dist/data/test/function/init_div.mcfunction +1 -0
  588. package/dist/data/test/function/insertion_sort.mcfunction +4 -0
  589. package/dist/data/test/function/insertion_sort__else_11.mcfunction +2 -0
  590. package/dist/data/test/function/insertion_sort__else_8.mcfunction +2 -0
  591. package/dist/data/test/function/insertion_sort__loop_body_1.mcfunction +6 -0
  592. package/dist/data/test/function/insertion_sort__loop_body_4.mcfunction +4 -0
  593. package/dist/data/test/function/insertion_sort__loop_exit_2.mcfunction +1 -0
  594. package/dist/data/test/function/insertion_sort__loop_exit_5.mcfunction +4 -0
  595. package/dist/data/test/function/insertion_sort__loop_header_0.mcfunction +3 -0
  596. package/dist/data/test/function/insertion_sort__loop_header_3.mcfunction +4 -0
  597. package/dist/data/test/function/insertion_sort__merge_10.mcfunction +1 -0
  598. package/dist/data/test/function/insertion_sort__merge_7.mcfunction +1 -0
  599. package/dist/data/test/function/insertion_sort__then_6.mcfunction +3 -0
  600. package/dist/data/test/function/insertion_sort__then_9.mcfunction +4 -0
  601. package/dist/data/test/function/insertion_sort_desc.mcfunction +4 -0
  602. package/dist/data/test/function/insertion_sort_desc__else_11.mcfunction +2 -0
  603. package/dist/data/test/function/insertion_sort_desc__else_8.mcfunction +2 -0
  604. package/dist/data/test/function/insertion_sort_desc__loop_body_1.mcfunction +6 -0
  605. package/dist/data/test/function/insertion_sort_desc__loop_body_4.mcfunction +4 -0
  606. package/dist/data/test/function/insertion_sort_desc__loop_exit_2.mcfunction +1 -0
  607. package/dist/data/test/function/insertion_sort_desc__loop_exit_5.mcfunction +4 -0
  608. package/dist/data/test/function/insertion_sort_desc__loop_header_0.mcfunction +3 -0
  609. package/dist/data/test/function/insertion_sort_desc__loop_header_3.mcfunction +4 -0
  610. package/dist/data/test/function/insertion_sort_desc__merge_10.mcfunction +1 -0
  611. package/dist/data/test/function/insertion_sort_desc__merge_7.mcfunction +1 -0
  612. package/dist/data/test/function/insertion_sort_desc__then_6.mcfunction +3 -0
  613. package/dist/data/test/function/insertion_sort_desc__then_9.mcfunction +4 -0
  614. package/dist/data/test/function/integrate_simpson.mcfunction +7 -0
  615. package/dist/data/test/function/integrate_simpson__loop_body_6.mcfunction +7 -0
  616. package/dist/data/test/function/integrate_simpson__loop_exit_7.mcfunction +6 -0
  617. package/dist/data/test/function/integrate_simpson__loop_header_5.mcfunction +5 -0
  618. package/dist/data/test/function/integrate_simpson__merge_1.mcfunction +8 -0
  619. package/dist/data/test/function/integrate_simpson__merge_11.mcfunction +4 -0
  620. package/dist/data/test/function/integrate_simpson__merge_4.mcfunction +5 -0
  621. package/dist/data/test/function/integrate_simpson__merge_9.mcfunction +7 -0
  622. package/dist/data/test/function/integrate_simpson__then_0.mcfunction +6 -0
  623. package/dist/data/test/function/integrate_simpson__then_10.mcfunction +6 -0
  624. package/dist/data/test/function/integrate_simpson__then_3.mcfunction +4 -0
  625. package/dist/data/test/function/integrate_simpson__then_8.mcfunction +6 -0
  626. package/dist/data/test/function/integrate_trapezoid.mcfunction +7 -0
  627. package/dist/data/test/function/integrate_trapezoid__loop_body_4.mcfunction +7 -0
  628. package/dist/data/test/function/integrate_trapezoid__loop_exit_5.mcfunction +6 -0
  629. package/dist/data/test/function/integrate_trapezoid__loop_header_3.mcfunction +5 -0
  630. package/dist/data/test/function/integrate_trapezoid__merge_1.mcfunction +11 -0
  631. package/dist/data/test/function/integrate_trapezoid__then_0.mcfunction +2 -0
  632. package/dist/data/test/function/interactions_init.mcfunction +9 -0
  633. package/dist/data/test/function/invisible.mcfunction +1 -0
  634. package/dist/data/test/function/is_op.mcfunction +2 -0
  635. package/dist/data/test/function/is_op__exec_t1.mcfunction +1 -0
  636. package/dist/data/test/function/is_sneaking.mcfunction +5 -0
  637. package/dist/data/test/function/is_sneaking__merge_1.mcfunction +2 -0
  638. package/dist/data/test/function/is_sneaking__then_0.mcfunction +2 -0
  639. package/dist/data/test/function/jump.mcfunction +1 -0
  640. package/dist/data/test/function/launch_up.mcfunction +6 -0
  641. package/dist/data/test/function/list_max3.mcfunction +1 -2
  642. package/dist/data/test/function/list_max3__merge_1.mcfunction +1 -2
  643. package/dist/data/test/function/list_max5.mcfunction +1 -2
  644. package/dist/data/test/function/list_max5__merge_1.mcfunction +1 -2
  645. package/dist/data/test/function/list_max5__merge_3.mcfunction +1 -2
  646. package/dist/data/test/function/list_max5__merge_5.mcfunction +1 -2
  647. package/dist/data/test/function/list_min3.mcfunction +1 -2
  648. package/dist/data/test/function/list_min3__merge_1.mcfunction +1 -2
  649. package/dist/data/test/function/list_min5.mcfunction +1 -2
  650. package/dist/data/test/function/list_min5__merge_1.mcfunction +1 -2
  651. package/dist/data/test/function/list_min5__merge_3.mcfunction +1 -2
  652. package/dist/data/test/function/list_min5__merge_5.mcfunction +1 -2
  653. package/dist/data/test/function/list_sort_asc__loop_body_4.mcfunction +1 -2
  654. package/dist/data/test/function/list_sort_asc__loop_header_0.mcfunction +1 -2
  655. package/dist/data/test/function/list_sort_asc__loop_header_3.mcfunction +1 -2
  656. package/dist/data/test/function/list_sort_desc__loop_body_4.mcfunction +1 -2
  657. package/dist/data/test/function/list_sort_desc__loop_header_0.mcfunction +1 -2
  658. package/dist/data/test/function/list_sort_desc__loop_header_3.mcfunction +1 -2
  659. package/dist/data/test/function/max_heap_pop.mcfunction +4 -0
  660. package/dist/data/test/function/max_heap_pop__else_13.mcfunction +2 -0
  661. package/dist/data/test/function/max_heap_pop__loop_body_1.mcfunction +14 -0
  662. package/dist/data/test/function/max_heap_pop__loop_exit_2.mcfunction +1 -0
  663. package/dist/data/test/function/max_heap_pop__loop_header_0.mcfunction +4 -0
  664. package/dist/data/test/function/max_heap_pop__merge_10.mcfunction +1 -0
  665. package/dist/data/test/function/max_heap_pop__merge_12.mcfunction +1 -0
  666. package/dist/data/test/function/max_heap_pop__merge_4.mcfunction +3 -0
  667. package/dist/data/test/function/max_heap_pop__merge_6.mcfunction +1 -0
  668. package/dist/data/test/function/max_heap_pop__merge_8.mcfunction +3 -0
  669. package/dist/data/test/function/max_heap_pop__then_11.mcfunction +2 -0
  670. package/dist/data/test/function/max_heap_pop__then_3.mcfunction +3 -0
  671. package/dist/data/test/function/max_heap_pop__then_5.mcfunction +2 -0
  672. package/dist/data/test/function/max_heap_pop__then_7.mcfunction +3 -0
  673. package/dist/data/test/function/max_heap_pop__then_9.mcfunction +2 -0
  674. package/dist/data/test/function/max_heap_push.mcfunction +6 -0
  675. package/dist/data/test/function/max_heap_push__else_5.mcfunction +2 -0
  676. package/dist/data/test/function/max_heap_push__else_8.mcfunction +2 -0
  677. package/dist/data/test/function/max_heap_push__loop_body_1.mcfunction +4 -0
  678. package/dist/data/test/function/max_heap_push__loop_exit_2.mcfunction +1 -0
  679. package/dist/data/test/function/max_heap_push__loop_header_0.mcfunction +4 -0
  680. package/dist/data/test/function/max_heap_push__merge_4.mcfunction +1 -0
  681. package/dist/data/test/function/max_heap_push__merge_7.mcfunction +1 -0
  682. package/dist/data/test/function/max_heap_push__then_3.mcfunction +7 -0
  683. package/dist/data/test/function/max_heap_push__then_6.mcfunction +2 -0
  684. package/dist/data/test/function/newton_step.mcfunction +7 -0
  685. package/dist/data/test/function/newton_step__merge_1.mcfunction +8 -0
  686. package/dist/data/test/function/newton_step__then_0.mcfunction +1 -0
  687. package/dist/data/test/function/night_vision.mcfunction +1 -0
  688. package/dist/data/test/function/norm3_hp.mcfunction +43 -0
  689. package/dist/data/test/function/normal_approx12.mcfunction +1 -2
  690. package/dist/data/test/function/normal_approx12__merge_1.mcfunction +1 -2
  691. package/dist/data/test/function/normal_approx12__merge_11.mcfunction +1 -2
  692. package/dist/data/test/function/normal_approx12__merge_13.mcfunction +1 -2
  693. package/dist/data/test/function/normal_approx12__merge_15.mcfunction +1 -2
  694. package/dist/data/test/function/normal_approx12__merge_17.mcfunction +1 -2
  695. package/dist/data/test/function/normal_approx12__merge_19.mcfunction +1 -2
  696. package/dist/data/test/function/normal_approx12__merge_21.mcfunction +1 -2
  697. package/dist/data/test/function/normal_approx12__merge_3.mcfunction +1 -2
  698. package/dist/data/test/function/normal_approx12__merge_5.mcfunction +1 -2
  699. package/dist/data/test/function/normal_approx12__merge_7.mcfunction +1 -2
  700. package/dist/data/test/function/normal_approx12__merge_9.mcfunction +1 -2
  701. package/dist/data/test/function/on_double_sneak.mcfunction +1 -0
  702. package/dist/data/test/function/on_double_sneak__foreach_t0.mcfunction +9 -0
  703. package/dist/data/test/function/on_double_sneak__foreach_t0__merge_1.mcfunction +1 -0
  704. package/dist/data/test/function/on_double_sneak__foreach_t0__merge_3.mcfunction +2 -0
  705. package/dist/data/test/function/on_double_sneak__foreach_t0__then_0.mcfunction +6 -0
  706. package/dist/data/test/function/on_double_sneak__foreach_t0__then_2.mcfunction +2 -0
  707. package/dist/data/test/function/on_right_click.mcfunction +1 -0
  708. package/dist/data/test/function/on_right_click__foreach_t1.mcfunction +5 -0
  709. package/dist/data/test/function/on_right_click__foreach_t1__merge_1.mcfunction +1 -0
  710. package/dist/data/test/function/on_right_click__foreach_t1__then_0.mcfunction +3 -0
  711. package/dist/data/test/function/on_sneak_click.mcfunction +1 -0
  712. package/dist/data/test/function/on_sneak_click__foreach_t0.mcfunction +7 -0
  713. package/dist/data/test/function/on_sneak_click__foreach_t0__else_4.mcfunction +3 -0
  714. package/dist/data/test/function/on_sneak_click__foreach_t0__merge_1.mcfunction +1 -0
  715. package/dist/data/test/function/on_sneak_click__foreach_t0__merge_3.mcfunction +1 -0
  716. package/dist/data/test/function/on_sneak_click__foreach_t0__then_0.mcfunction +4 -0
  717. package/dist/data/test/function/on_sneak_click__foreach_t0__then_2.mcfunction +3 -0
  718. package/dist/data/test/function/on_sneak_start.mcfunction +1 -0
  719. package/dist/data/test/function/on_sneak_start__foreach_t0.mcfunction +5 -0
  720. package/dist/data/test/function/on_sneak_start__foreach_t0__else_2.mcfunction +2 -0
  721. package/dist/data/test/function/on_sneak_start__foreach_t0__merge_1.mcfunction +1 -0
  722. package/dist/data/test/function/on_sneak_start__foreach_t0__then_0.mcfunction +2 -0
  723. package/dist/data/test/function/particle_at_fx.mcfunction +1 -0
  724. package/dist/data/test/function/particle_dot.mcfunction +1 -0
  725. package/dist/data/test/function/pathfind_bfs.mcfunction +11 -0
  726. package/dist/data/test/function/pathfind_bfs__else_33.mcfunction +4 -0
  727. package/dist/data/test/function/pathfind_bfs__else_8.mcfunction +19 -0
  728. package/dist/data/test/function/pathfind_bfs__loop_body_1.mcfunction +10 -0
  729. package/dist/data/test/function/pathfind_bfs__loop_body_29.mcfunction +6 -0
  730. package/dist/data/test/function/pathfind_bfs__loop_body_35.mcfunction +9 -0
  731. package/dist/data/test/function/pathfind_bfs__loop_body_4.mcfunction +9 -0
  732. package/dist/data/test/function/pathfind_bfs__loop_exit_2.mcfunction +24 -0
  733. package/dist/data/test/function/pathfind_bfs__loop_exit_30.mcfunction +6 -0
  734. package/dist/data/test/function/pathfind_bfs__loop_exit_36.mcfunction +1 -0
  735. package/dist/data/test/function/pathfind_bfs__loop_exit_5.mcfunction +6 -0
  736. package/dist/data/test/function/pathfind_bfs__loop_header_0.mcfunction +4 -0
  737. package/dist/data/test/function/pathfind_bfs__loop_header_28.mcfunction +4 -0
  738. package/dist/data/test/function/pathfind_bfs__loop_header_3.mcfunction +3 -0
  739. package/dist/data/test/function/pathfind_bfs__loop_header_34.mcfunction +4 -0
  740. package/dist/data/test/function/pathfind_bfs__merge_10.mcfunction +11 -0
  741. package/dist/data/test/function/pathfind_bfs__merge_12.mcfunction +1 -0
  742. package/dist/data/test/function/pathfind_bfs__merge_14.mcfunction +11 -0
  743. package/dist/data/test/function/pathfind_bfs__merge_16.mcfunction +1 -0
  744. package/dist/data/test/function/pathfind_bfs__merge_18.mcfunction +11 -0
  745. package/dist/data/test/function/pathfind_bfs__merge_20.mcfunction +1 -0
  746. package/dist/data/test/function/pathfind_bfs__merge_22.mcfunction +1 -0
  747. package/dist/data/test/function/pathfind_bfs__merge_24.mcfunction +1 -0
  748. package/dist/data/test/function/pathfind_bfs__merge_26.mcfunction +5 -0
  749. package/dist/data/test/function/pathfind_bfs__merge_32.mcfunction +1 -0
  750. package/dist/data/test/function/pathfind_bfs__merge_7.mcfunction +1 -0
  751. package/dist/data/test/function/pathfind_bfs__then_11.mcfunction +15 -0
  752. package/dist/data/test/function/pathfind_bfs__then_13.mcfunction +13 -0
  753. package/dist/data/test/function/pathfind_bfs__then_15.mcfunction +15 -0
  754. package/dist/data/test/function/pathfind_bfs__then_17.mcfunction +13 -0
  755. package/dist/data/test/function/pathfind_bfs__then_19.mcfunction +15 -0
  756. package/dist/data/test/function/pathfind_bfs__then_21.mcfunction +13 -0
  757. package/dist/data/test/function/pathfind_bfs__then_23.mcfunction +15 -0
  758. package/dist/data/test/function/pathfind_bfs__then_25.mcfunction +1 -0
  759. package/dist/data/test/function/pathfind_bfs__then_31.mcfunction +2 -0
  760. package/dist/data/test/function/pathfind_bfs__then_6.mcfunction +3 -0
  761. package/dist/data/test/function/pathfind_bfs__then_9.mcfunction +13 -0
  762. package/dist/data/test/function/pathfind_bfs_coro.mcfunction +1 -0
  763. package/dist/data/test/function/pcg_output.mcfunction +1 -2
  764. package/dist/data/test/function/pf_heuristic.mcfunction +14 -0
  765. package/dist/data/test/function/pf_heuristic__merge_1.mcfunction +4 -0
  766. package/dist/data/test/function/pf_heuristic__merge_3.mcfunction +6 -0
  767. package/dist/data/test/function/pf_heuristic__then_0.mcfunction +4 -0
  768. package/dist/data/test/function/pf_heuristic__then_2.mcfunction +4 -0
  769. package/dist/data/test/function/pf_is_blocked.mcfunction +7 -0
  770. package/dist/data/test/function/pf_is_blocked__merge_1.mcfunction +4 -0
  771. package/dist/data/test/function/pf_is_blocked__merge_10.mcfunction +4 -0
  772. package/dist/data/test/function/pf_is_blocked__merge_4.mcfunction +4 -0
  773. package/dist/data/test/function/pf_is_blocked__merge_7.mcfunction +4 -0
  774. package/dist/data/test/function/pf_is_blocked__then_0.mcfunction +2 -0
  775. package/dist/data/test/function/pf_is_blocked__then_3.mcfunction +2 -0
  776. package/dist/data/test/function/pf_is_blocked__then_6.mcfunction +2 -0
  777. package/dist/data/test/function/pf_is_blocked__then_9.mcfunction +2 -0
  778. package/dist/data/test/function/pf_new_map.mcfunction +4 -0
  779. package/dist/data/test/function/pf_new_map__loop_body_1.mcfunction +7 -0
  780. package/dist/data/test/function/pf_new_map__loop_exit_2.mcfunction +1 -0
  781. package/dist/data/test/function/pf_new_map__loop_header_0.mcfunction +4 -0
  782. package/dist/data/test/function/pf_noop.mcfunction +1 -0
  783. package/dist/data/test/function/pf_pack.mcfunction +8 -0
  784. package/dist/data/test/function/pf_set_blocked.mcfunction +5 -0
  785. package/dist/data/test/function/pf_set_open.mcfunction +5 -0
  786. package/dist/data/test/function/pf_unpack_x.mcfunction +5 -0
  787. package/dist/data/test/function/pf_unpack_z.mcfunction +5 -0
  788. package/dist/data/test/function/popcount__loop_body_1.mcfunction +1 -2
  789. package/dist/data/test/function/popcount__loop_header_0.mcfunction +1 -2
  790. package/dist/data/test/function/portal_effect.mcfunction +1 -0
  791. package/dist/data/test/function/random_bool.mcfunction +1 -2
  792. package/dist/data/test/function/random_range.mcfunction +1 -2
  793. package/dist/data/test/function/regen.mcfunction +1 -0
  794. package/dist/data/test/function/remove_bar.mcfunction +3 -0
  795. package/dist/data/test/function/remove_from_teams.mcfunction +3 -0
  796. package/dist/data/test/function/remove_item.mcfunction +1 -0
  797. package/dist/data/test/function/resistance.mcfunction +1 -0
  798. package/dist/data/test/function/rgb_to_h.mcfunction +1 -2
  799. package/dist/data/test/function/rgb_to_h__merge_1.mcfunction +1 -2
  800. package/dist/data/test/function/rgb_to_h__merge_12.mcfunction +1 -2
  801. package/dist/data/test/function/rgb_to_h__merge_3.mcfunction +1 -2
  802. package/dist/data/test/function/rgb_to_h__merge_5.mcfunction +1 -2
  803. package/dist/data/test/function/rgb_to_h__merge_7.mcfunction +1 -2
  804. package/dist/data/test/function/rgb_to_h__merge_9.mcfunction +1 -2
  805. package/dist/data/test/function/rgb_to_h__then_11.mcfunction +1 -2
  806. package/dist/data/test/function/rgb_to_l.mcfunction +1 -2
  807. package/dist/data/test/function/rgb_to_l__merge_1.mcfunction +1 -2
  808. package/dist/data/test/function/rgb_to_l__merge_3.mcfunction +1 -2
  809. package/dist/data/test/function/rgb_to_l__merge_5.mcfunction +1 -2
  810. package/dist/data/test/function/rgb_to_s.mcfunction +1 -2
  811. package/dist/data/test/function/rgb_to_s__merge_1.mcfunction +1 -2
  812. package/dist/data/test/function/rgb_to_s__merge_3.mcfunction +1 -2
  813. package/dist/data/test/function/rgb_to_s__merge_5.mcfunction +1 -2
  814. package/dist/data/test/function/rgb_to_s__merge_7.mcfunction +1 -2
  815. package/dist/data/test/function/rgb_to_s__merge_9.mcfunction +1 -2
  816. package/dist/data/test/function/riemann_left.mcfunction +6 -0
  817. package/dist/data/test/function/riemann_left__loop_body_1.mcfunction +7 -0
  818. package/dist/data/test/function/riemann_left__loop_exit_2.mcfunction +6 -0
  819. package/dist/data/test/function/riemann_left__loop_header_0.mcfunction +5 -0
  820. package/dist/data/test/function/riemann_mid.mcfunction +6 -0
  821. package/dist/data/test/function/riemann_mid__loop_body_1.mcfunction +7 -0
  822. package/dist/data/test/function/riemann_mid__loop_exit_2.mcfunction +6 -0
  823. package/dist/data/test/function/riemann_mid__loop_header_0.mcfunction +3 -0
  824. package/dist/data/test/function/riemann_right.mcfunction +6 -0
  825. package/dist/data/test/function/riemann_right__loop_body_1.mcfunction +7 -0
  826. package/dist/data/test/function/riemann_right__loop_exit_2.mcfunction +6 -0
  827. package/dist/data/test/function/riemann_right__loop_header_0.mcfunction +3 -0
  828. package/dist/data/test/function/running_m2.mcfunction +16 -0
  829. package/dist/data/test/function/running_mean.mcfunction +7 -0
  830. package/dist/data/test/function/running_mean__merge_1.mcfunction +13 -0
  831. package/dist/data/test/function/running_mean__then_0.mcfunction +1 -0
  832. package/dist/data/test/function/second_deriv.mcfunction +8 -0
  833. package/dist/data/test/function/second_deriv__merge_1.mcfunction +14 -0
  834. package/dist/data/test/function/second_deriv__then_0.mcfunction +2 -0
  835. package/dist/data/test/function/set_day.mcfunction +1 -0
  836. package/dist/data/test/function/set_easy.mcfunction +1 -0
  837. package/dist/data/test/function/set_hard.mcfunction +1 -0
  838. package/dist/data/test/function/set_midnight.mcfunction +1 -0
  839. package/dist/data/test/function/set_night.mcfunction +1 -0
  840. package/dist/data/test/function/set_noon.mcfunction +1 -0
  841. package/dist/data/test/function/set_normal.mcfunction +1 -0
  842. package/dist/data/test/function/set_peaceful.mcfunction +1 -0
  843. package/dist/data/test/function/setup_four_teams.mcfunction +4 -0
  844. package/dist/data/test/function/setup_two_teams.mcfunction +2 -0
  845. package/dist/data/test/function/show_bar.mcfunction +4 -0
  846. package/dist/data/test/function/simpson_step.mcfunction +16 -0
  847. package/dist/data/test/function/sin_hp.mcfunction +4 -2
  848. package/dist/data/test/function/slow_fall.mcfunction +1 -0
  849. package/dist/data/test/function/smoke.mcfunction +1 -0
  850. package/dist/data/test/function/sort2_max.mcfunction +1 -2
  851. package/dist/data/test/function/sort2_min.mcfunction +1 -2
  852. package/dist/data/test/function/sort3.mcfunction +1 -2
  853. package/dist/data/test/function/sort3__merge_1.mcfunction +1 -2
  854. package/dist/data/test/function/sort3__merge_3.mcfunction +1 -2
  855. package/dist/data/test/function/sort3__merge_5.mcfunction +1 -2
  856. package/dist/data/test/function/sort3__merge_7.mcfunction +1 -2
  857. package/dist/data/test/function/sort4.mcfunction +1 -2
  858. package/dist/data/test/function/sort4__merge_1.mcfunction +1 -2
  859. package/dist/data/test/function/sort4__merge_11.mcfunction +1 -2
  860. package/dist/data/test/function/sort4__merge_14.mcfunction +1 -2
  861. package/dist/data/test/function/sort4__merge_3.mcfunction +1 -2
  862. package/dist/data/test/function/sort4__merge_5.mcfunction +1 -2
  863. package/dist/data/test/function/sort4__merge_7.mcfunction +1 -2
  864. package/dist/data/test/function/sort4__merge_9.mcfunction +1 -2
  865. package/dist/data/test/function/sort5.mcfunction +1 -2
  866. package/dist/data/test/function/sort5__merge_1.mcfunction +1 -2
  867. package/dist/data/test/function/sort5__merge_11.mcfunction +1 -2
  868. package/dist/data/test/function/sort5__merge_13.mcfunction +1 -2
  869. package/dist/data/test/function/sort5__merge_15.mcfunction +1 -2
  870. package/dist/data/test/function/sort5__merge_17.mcfunction +1 -2
  871. package/dist/data/test/function/sort5__merge_19.mcfunction +1 -2
  872. package/dist/data/test/function/sort5__merge_22.mcfunction +1 -2
  873. package/dist/data/test/function/sort5__merge_25.mcfunction +1 -2
  874. package/dist/data/test/function/sort5__merge_3.mcfunction +1 -2
  875. package/dist/data/test/function/sort5__merge_5.mcfunction +1 -2
  876. package/dist/data/test/function/sort5__merge_7.mcfunction +1 -2
  877. package/dist/data/test/function/sort5__merge_9.mcfunction +1 -2
  878. package/dist/data/test/function/sort_merge.mcfunction +10 -0
  879. package/dist/data/test/function/sort_merge__else_11.mcfunction +7 -0
  880. package/dist/data/test/function/sort_merge__else_14.mcfunction +2 -0
  881. package/dist/data/test/function/sort_merge__else_5.mcfunction +3 -0
  882. package/dist/data/test/function/sort_merge__else_8.mcfunction +7 -0
  883. package/dist/data/test/function/sort_merge__loop_body_1.mcfunction +3 -0
  884. package/dist/data/test/function/sort_merge__loop_exit_2.mcfunction +1 -0
  885. package/dist/data/test/function/sort_merge__loop_header_0.mcfunction +4 -0
  886. package/dist/data/test/function/sort_merge__merge_10.mcfunction +1 -0
  887. package/dist/data/test/function/sort_merge__merge_13.mcfunction +1 -0
  888. package/dist/data/test/function/sort_merge__merge_4.mcfunction +1 -0
  889. package/dist/data/test/function/sort_merge__merge_7.mcfunction +1 -0
  890. package/dist/data/test/function/sort_merge__then_12.mcfunction +7 -0
  891. package/dist/data/test/function/sort_merge__then_3.mcfunction +3 -0
  892. package/dist/data/test/function/sort_merge__then_6.mcfunction +3 -0
  893. package/dist/data/test/function/sort_merge__then_9.mcfunction +7 -0
  894. package/dist/data/test/function/sparkles_at.mcfunction +1 -0
  895. package/dist/data/test/function/speed.mcfunction +1 -0
  896. package/dist/data/test/function/sphere_contains.mcfunction +1 -2
  897. package/dist/data/test/function/spread_players.mcfunction +1 -0
  898. package/dist/data/test/function/sqrt_fx.mcfunction +5 -8
  899. package/dist/data/test/function/sqrt_hp.mcfunction +17 -0
  900. package/dist/data/test/function/sqrt_hp__merge_1.mcfunction +21 -0
  901. package/dist/data/test/function/sqrt_hp__then_0.mcfunction +2 -0
  902. package/dist/data/test/function/std_dev_approx.mcfunction +5 -0
  903. package/dist/data/test/function/std_dev_approx__merge_1.mcfunction +13 -0
  904. package/dist/data/test/function/std_dev_approx__then_0.mcfunction +2 -0
  905. package/dist/data/test/function/str_len.mcfunction +2 -0
  906. package/dist/data/test/function/strength.mcfunction +1 -0
  907. package/dist/data/test/function/t.mcfunction +3 -0
  908. package/dist/data/test/function/teleport_to.mcfunction +9 -0
  909. package/dist/data/test/function/teleport_to_entity.mcfunction +5 -0
  910. package/dist/data/test/function/test.mcfunction +5 -0
  911. package/dist/data/test/function/test__loop_body_1.mcfunction +9 -0
  912. package/dist/data/test/function/test__loop_exit_2.mcfunction +1 -0
  913. package/dist/data/test/function/test__loop_header_0.mcfunction +3 -0
  914. package/dist/data/test/function/tile_of.mcfunction +1 -2
  915. package/dist/data/test/function/timer/done.mcfunction +1 -2
  916. package/dist/data/test/function/timer/remaining.mcfunction +1 -2
  917. package/dist/data/test/function/timer/tick.mcfunction +1 -2
  918. package/dist/data/test/function/timer/tick__then_0.mcfunction +1 -2
  919. package/dist/data/test/function/totem_at.mcfunction +1 -0
  920. package/dist/data/test/function/trapezoid_step.mcfunction +11 -0
  921. package/dist/data/test/function/uniform_frac.mcfunction +1 -2
  922. package/dist/data/test/function/uniform_int.mcfunction +1 -2
  923. package/dist/data/test/function/update_bar.mcfunction +5 -0
  924. package/dist/data/test/function/update_bar_color.mcfunction +6 -0
  925. package/dist/data/test/function/update_bar_color__else_2.mcfunction +4 -0
  926. package/dist/data/test/function/update_bar_color__else_5.mcfunction +4 -0
  927. package/dist/data/test/function/update_bar_color__merge_1.mcfunction +1 -0
  928. package/dist/data/test/function/update_bar_color__merge_4.mcfunction +1 -0
  929. package/dist/data/test/function/update_bar_color__then_0.mcfunction +4 -0
  930. package/dist/data/test/function/update_bar_color__then_3.mcfunction +4 -0
  931. package/dist/data/test/function/value_noise_1d.mcfunction +1 -2
  932. package/dist/data/test/function/value_noise_2d.mcfunction +1 -2
  933. package/dist/data/test/function/value_noise_2d__merge_1.mcfunction +1 -2
  934. package/dist/data/test/function/variance_from_m2.mcfunction +6 -0
  935. package/dist/data/test/function/variance_from_m2__merge_1.mcfunction +5 -0
  936. package/dist/data/test/function/variance_from_m2__then_0.mcfunction +2 -0
  937. package/dist/data/test/function/weapon_damage.mcfunction +5 -0
  938. package/dist/data/test/function/weather_clear.mcfunction +1 -0
  939. package/dist/data/test/function/weather_rain.mcfunction +1 -0
  940. package/dist/data/test/function/weather_thunder.mcfunction +1 -0
  941. package/dist/data/test/function/weighted2.mcfunction +1 -2
  942. package/dist/data/test/function/weighted2__merge_1.mcfunction +1 -2
  943. package/dist/data/test/function/weighted3.mcfunction +1 -2
  944. package/dist/data/test/function/weighted3__merge_1.mcfunction +1 -2
  945. package/dist/data/test/function/weighted3__merge_3.mcfunction +1 -2
  946. package/dist/data/test_dmul/function/__double_mul_macro.mcfunction +1 -0
  947. package/dist/data/test_dmul/function/double_mul_fixed.mcfunction +6 -0
  948. package/dist/data/test_dmul/function/load.mcfunction +1 -0
  949. package/dist/data/test_double_fn/function/double_test.mcfunction +2 -0
  950. package/dist/data/test_double_fn/function/load.mcfunction +1 -0
  951. package/dist/data/test_double_fn2/function/double_test.mcfunction +2 -0
  952. package/dist/data/test_double_fn2/function/load.mcfunction +1 -0
  953. package/dist/data/test_double_pass/function/caller_fn.mcfunction +4 -0
  954. package/dist/data/test_double_pass/function/consume_double.mcfunction +2 -0
  955. package/dist/data/test_double_pass/function/load.mcfunction +1 -0
  956. package/dist/data/test_macro/function/load.mcfunction +1 -0
  957. package/dist/data/test_macro/function/macro_helper.mcfunction +1 -0
  958. package/dist/data/test_macro3/function/__dmul_macro.mcfunction +1 -0
  959. package/dist/data/test_macro3/function/double_mul_test.mcfunction +7 -0
  960. package/dist/data/test_macro3/function/load.mcfunction +1 -0
  961. package/dist/data/test_ret_double/function/load.mcfunction +1 -0
  962. package/dist/data/test_ret_double/function/make_double.mcfunction +3 -0
  963. package/dist/data/test_ret_double/function/use_it.mcfunction +3 -0
  964. package/dist/pack.mcmeta +1 -1
  965. package/dist/src/__tests__/array-dynamic.test.js +42 -0
  966. package/dist/src/__tests__/builtins.test.d.ts +1 -0
  967. package/dist/src/__tests__/builtins.test.js +55 -0
  968. package/dist/src/__tests__/compile-all.test.js +1 -0
  969. package/dist/src/__tests__/diagnostics.test.js +8 -11
  970. package/dist/src/__tests__/double.test.d.ts +7 -0
  971. package/dist/src/__tests__/double.test.js +464 -0
  972. package/dist/src/__tests__/e2e/ecs-stdlib.test.d.ts +7 -0
  973. package/dist/src/__tests__/e2e/ecs-stdlib.test.js +328 -0
  974. package/dist/src/__tests__/e2e/events-stdlib.test.d.ts +1 -0
  975. package/dist/src/__tests__/e2e/events-stdlib.test.js +81 -0
  976. package/dist/src/__tests__/e2e/fft-stdlib.test.d.ts +13 -0
  977. package/dist/src/__tests__/e2e/fft-stdlib.test.js +288 -0
  978. package/dist/src/__tests__/e2e/for-in-array.test.d.ts +4 -0
  979. package/dist/src/__tests__/e2e/for-in-array.test.js +59 -0
  980. package/dist/src/__tests__/e2e/macros.test.js +7 -7
  981. package/dist/src/__tests__/e2e/ode-stdlib.test.d.ts +1 -0
  982. package/dist/src/__tests__/e2e/ode-stdlib.test.js +91 -0
  983. package/dist/src/__tests__/e2e/stdlib-e2e.test.js +1616 -0
  984. package/dist/src/__tests__/emit/compile.test.d.ts +1 -0
  985. package/dist/src/__tests__/emit/compile.test.js +95 -0
  986. package/dist/src/__tests__/emit/index.test.d.ts +1 -0
  987. package/dist/src/__tests__/emit/index.test.js +180 -0
  988. package/dist/src/__tests__/emit/modules-extra.test.d.ts +1 -0
  989. package/dist/src/__tests__/emit/modules-extra.test.js +77 -0
  990. package/dist/src/__tests__/enum.test.js +4 -6
  991. package/dist/src/__tests__/fixed.test.d.ts +7 -0
  992. package/dist/src/__tests__/fixed.test.js +148 -0
  993. package/dist/src/__tests__/float-lint.test.d.ts +7 -0
  994. package/dist/src/__tests__/float-lint.test.js +96 -0
  995. package/dist/src/__tests__/float.test.d.ts +7 -0
  996. package/dist/src/__tests__/float.test.js +148 -0
  997. package/dist/src/__tests__/for-each.test.d.ts +1 -0
  998. package/dist/src/__tests__/for-each.test.js +125 -0
  999. package/dist/src/__tests__/for-range.test.d.ts +1 -0
  1000. package/dist/src/__tests__/for-range.test.js +136 -0
  1001. package/dist/src/__tests__/generics.test.js +4 -4
  1002. package/dist/src/__tests__/impl.test.d.ts +1 -0
  1003. package/dist/src/__tests__/impl.test.js +199 -0
  1004. package/dist/src/__tests__/lsp-logic.test.d.ts +1 -0
  1005. package/dist/src/__tests__/lsp-logic.test.js +145 -0
  1006. package/dist/src/__tests__/match.test.d.ts +10 -0
  1007. package/dist/src/__tests__/match.test.js +197 -0
  1008. package/dist/src/__tests__/mc-integration/item-entity-events.test.d.ts +18 -0
  1009. package/dist/src/__tests__/mc-integration/item-entity-events.test.js +287 -0
  1010. package/dist/src/__tests__/mc-integration/stdlib-coverage-2.test.d.ts +13 -0
  1011. package/dist/src/__tests__/mc-integration/stdlib-coverage-2.test.js +833 -0
  1012. package/dist/src/__tests__/mc-integration/stdlib-coverage.test.d.ts +13 -0
  1013. package/dist/src/__tests__/mc-integration/stdlib-coverage.test.js +707 -0
  1014. package/dist/src/__tests__/mc-integration/syntax-coverage.test.d.ts +9 -0
  1015. package/dist/src/__tests__/mc-integration/syntax-coverage.test.js +442 -0
  1016. package/dist/src/__tests__/mc-integration.test.js +835 -5
  1017. package/dist/src/__tests__/optimizer/constant_fold.test.js +105 -0
  1018. package/dist/src/__tests__/optimizer/coroutine.test.js +3 -2
  1019. package/dist/src/__tests__/parser.test.js +5 -5
  1020. package/dist/src/__tests__/runtime.test.js +143 -238
  1021. package/dist/src/__tests__/stdlib/arr-len.test.d.ts +13 -0
  1022. package/dist/src/__tests__/stdlib/arr-len.test.js +195 -0
  1023. package/dist/src/__tests__/stdlib/calculus.test.d.ts +5 -0
  1024. package/dist/src/__tests__/stdlib/calculus.test.js +123 -0
  1025. package/dist/src/__tests__/stdlib/dialog.test.d.ts +6 -0
  1026. package/dist/src/__tests__/stdlib/dialog.test.js +142 -0
  1027. package/dist/src/__tests__/stdlib/easing.test.d.ts +5 -0
  1028. package/dist/src/__tests__/stdlib/easing.test.js +117 -0
  1029. package/dist/src/__tests__/stdlib/geometry.test.d.ts +5 -0
  1030. package/dist/src/__tests__/stdlib/geometry.test.js +163 -0
  1031. package/dist/src/__tests__/stdlib/heap.test.d.ts +4 -0
  1032. package/dist/src/__tests__/stdlib/heap.test.js +141 -0
  1033. package/dist/src/__tests__/stdlib/list.test.d.ts +5 -0
  1034. package/dist/src/__tests__/stdlib/list.test.js +134 -0
  1035. package/dist/src/__tests__/stdlib/matrix.test.d.ts +5 -0
  1036. package/dist/src/__tests__/stdlib/matrix.test.js +148 -0
  1037. package/dist/src/__tests__/stdlib/pathfind.test.d.ts +4 -0
  1038. package/dist/src/__tests__/stdlib/pathfind.test.js +167 -0
  1039. package/dist/src/__tests__/stdlib/scheduler.test.d.ts +6 -0
  1040. package/dist/src/__tests__/stdlib/scheduler.test.js +177 -0
  1041. package/dist/src/__tests__/stdlib/sort-v2.test.d.ts +4 -0
  1042. package/dist/src/__tests__/stdlib/sort-v2.test.js +131 -0
  1043. package/dist/src/__tests__/stdlib/sort.test.d.ts +4 -0
  1044. package/dist/src/__tests__/stdlib/sort.test.js +128 -0
  1045. package/dist/src/__tests__/stdlib/state.test.d.ts +5 -0
  1046. package/dist/src/__tests__/stdlib/state.test.js +176 -0
  1047. package/dist/src/__tests__/typechecker-strict.test.js +21 -21
  1048. package/dist/src/__tests__/typechecker.test.js +5 -3
  1049. package/dist/src/ast/types.d.ts +28 -2
  1050. package/dist/src/emit/compile.js +30 -3
  1051. package/dist/src/emit/index.d.ts +2 -0
  1052. package/dist/src/emit/index.js +20 -1
  1053. package/dist/src/emit/modules.js +3 -2
  1054. package/dist/src/events/types.d.ts +1 -1
  1055. package/dist/src/events/types.js +5 -2
  1056. package/dist/src/hir/lower.js +88 -2
  1057. package/dist/src/hir/monomorphize.js +11 -5
  1058. package/dist/src/hir/types.d.ts +20 -1
  1059. package/dist/src/lexer/index.d.ts +1 -1
  1060. package/dist/src/lexer/index.js +10 -1
  1061. package/dist/src/lir/lower.js +7 -0
  1062. package/dist/src/lsp/server.js +912 -56
  1063. package/dist/src/mc-test/client.d.ts +13 -1
  1064. package/dist/src/mc-test/client.js +29 -1
  1065. package/dist/src/mir/lower.js +703 -74
  1066. package/dist/src/mir/types.d.ts +5 -0
  1067. package/dist/src/mir/verify.js +2 -0
  1068. package/dist/src/optimizer/constant_fold.js +10 -6
  1069. package/dist/src/optimizer/coroutine.js +90 -33
  1070. package/dist/src/optimizer/interprocedural.js +4 -0
  1071. package/dist/src/parser/index.d.ts +5 -0
  1072. package/dist/src/parser/index.js +171 -39
  1073. package/dist/src/runtime/index.js +24 -0
  1074. package/dist/src/typechecker/index.d.ts +8 -1
  1075. package/dist/src/typechecker/index.js +73 -14
  1076. package/docs/LANGUAGE_REFERENCE.md +302 -67
  1077. package/docs/stdlib/README.md +54 -0
  1078. package/docs/stdlib/advanced.md +276 -0
  1079. package/docs/stdlib/bigint.md +285 -0
  1080. package/docs/stdlib/bits.md +159 -0
  1081. package/docs/stdlib/bossbar.md +101 -0
  1082. package/docs/stdlib/calculus.md +141 -0
  1083. package/docs/stdlib/color.md +125 -0
  1084. package/docs/stdlib/combat.md +41 -0
  1085. package/docs/stdlib/cooldown.md +48 -0
  1086. package/docs/stdlib/easing.md +157 -0
  1087. package/docs/stdlib/effects.md +101 -0
  1088. package/docs/stdlib/expr.md +38 -0
  1089. package/docs/stdlib/geometry.md +130 -0
  1090. package/docs/stdlib/interactions.md +111 -0
  1091. package/docs/stdlib/inventory.md +53 -0
  1092. package/docs/stdlib/list.md +189 -0
  1093. package/docs/stdlib/math.md +334 -0
  1094. package/docs/stdlib/math_hp.md +185 -0
  1095. package/docs/stdlib/matrix.md +123 -0
  1096. package/docs/stdlib/mobs.md +131 -0
  1097. package/docs/stdlib/noise.md +103 -0
  1098. package/docs/stdlib/parabola.md +119 -0
  1099. package/docs/stdlib/particles.md +123 -0
  1100. package/docs/stdlib/physics.md +148 -0
  1101. package/docs/stdlib/player.md +43 -0
  1102. package/docs/stdlib/quaternion.md +159 -0
  1103. package/docs/stdlib/random.md +86 -0
  1104. package/docs/stdlib/sets.md +68 -0
  1105. package/docs/stdlib/signal.md +141 -0
  1106. package/docs/stdlib/spawn.md +65 -0
  1107. package/docs/stdlib/strings.md +17 -0
  1108. package/docs/stdlib/tags.md +117 -0
  1109. package/docs/stdlib/teams.md +87 -0
  1110. package/docs/stdlib/timer.md +126 -0
  1111. package/docs/stdlib/vec.md +193 -0
  1112. package/docs/stdlib/world.md +151 -0
  1113. package/editors/vscode/build.mjs +31 -12
  1114. package/editors/vscode/out/extension.js +3670 -200
  1115. package/editors/vscode/out/lsp-server.js +14854 -0
  1116. package/editors/vscode/package-lock.json +3 -3
  1117. package/editors/vscode/package.json +1 -1
  1118. package/editors/vscode/snippets/redscript.json +109 -30
  1119. package/editors/vscode/src/extension.ts +15 -13
  1120. package/examples/readme-demo.mcrs +4 -4
  1121. package/jest.config.js +5 -2
  1122. package/package.json +1 -1
  1123. package/scripts/postbuild.js +20 -0
  1124. package/src/__tests__/array-dynamic.test.ts +42 -0
  1125. package/src/__tests__/builtins.test.ts +66 -0
  1126. package/src/__tests__/compile-all.test.ts +3 -2
  1127. package/src/__tests__/diagnostics.test.ts +8 -10
  1128. package/src/__tests__/double.test.ts +478 -0
  1129. package/src/__tests__/e2e/ecs-stdlib.test.ts +371 -0
  1130. package/src/__tests__/e2e/events-stdlib.test.ts +50 -0
  1131. package/src/__tests__/e2e/fft-stdlib.test.ts +313 -0
  1132. package/src/__tests__/e2e/macros.test.ts +7 -7
  1133. package/src/__tests__/e2e/ode-stdlib.test.ts +68 -0
  1134. package/src/__tests__/e2e/stdlib-e2e.test.ts +1952 -0
  1135. package/src/__tests__/emit/compile.test.ts +102 -0
  1136. package/src/__tests__/emit/index.test.ts +189 -0
  1137. package/src/__tests__/emit/modules-extra.test.ts +80 -0
  1138. package/src/__tests__/enum.test.ts +4 -6
  1139. package/src/__tests__/fixed.test.ts +159 -0
  1140. package/src/__tests__/fixtures/coroutine-mc-test.mcrs +58 -0
  1141. package/src/__tests__/fixtures/for-range.mcrs +15 -0
  1142. package/src/__tests__/fixtures/heap-sort-mc-test.mcrs +87 -0
  1143. package/src/__tests__/fixtures/impl-test.mcrs +13 -44
  1144. package/src/__tests__/fixtures/stdlib-extra-test.mcrs +226 -0
  1145. package/src/__tests__/fixtures/stdlib-math-integration.mcrs +28 -0
  1146. package/src/__tests__/fixtures/stdlib-math-test.mcrs +53 -0
  1147. package/src/__tests__/float-lint.test.ts +102 -0
  1148. package/src/__tests__/float.test.ts +158 -0
  1149. package/src/__tests__/for-each.test.ts +135 -0
  1150. package/src/__tests__/for-range.test.ts +149 -0
  1151. package/src/__tests__/generics.test.ts +4 -4
  1152. package/src/__tests__/impl.test.ts +207 -0
  1153. package/src/__tests__/lsp-logic.test.ts +162 -0
  1154. package/src/__tests__/match.test.ts +212 -0
  1155. package/src/__tests__/mc-integration/item-entity-events.test.ts +298 -0
  1156. package/src/__tests__/mc-integration/stdlib-coverage-2.test.ts +817 -0
  1157. package/src/__tests__/mc-integration/stdlib-coverage.test.ts +699 -0
  1158. package/src/__tests__/mc-integration/syntax-coverage.test.ts +464 -0
  1159. package/src/__tests__/mc-integration.test.ts +889 -5
  1160. package/src/__tests__/optimizer/constant_fold.test.ts +115 -0
  1161. package/src/__tests__/optimizer/coroutine.test.ts +3 -2
  1162. package/src/__tests__/parser.test.ts +5 -5
  1163. package/src/__tests__/runtime.test.ts +194 -0
  1164. package/src/__tests__/stdlib/arr-len.test.ts +231 -0
  1165. package/src/__tests__/stdlib/calculus.test.ts +99 -0
  1166. package/src/__tests__/stdlib/dialog.test.ts +132 -0
  1167. package/src/__tests__/stdlib/easing.test.ts +97 -0
  1168. package/src/__tests__/stdlib/geometry.test.ts +171 -0
  1169. package/src/__tests__/stdlib/heap.test.ts +121 -0
  1170. package/src/__tests__/stdlib/list.test.ts +117 -0
  1171. package/src/__tests__/stdlib/matrix.test.ts +140 -0
  1172. package/src/__tests__/stdlib/pathfind.test.ts +151 -0
  1173. package/src/__tests__/stdlib/scheduler.test.ts +171 -0
  1174. package/src/__tests__/stdlib/sort-v2.test.ts +111 -0
  1175. package/src/__tests__/stdlib/sort.test.ts +106 -0
  1176. package/src/__tests__/stdlib/state.test.ts +164 -0
  1177. package/src/__tests__/typechecker-strict.test.ts +21 -21
  1178. package/src/__tests__/typechecker.test.ts +5 -3
  1179. package/src/ast/types.ts +16 -3
  1180. package/src/emit/compile.ts +32 -3
  1181. package/src/emit/index.ts +24 -1
  1182. package/src/emit/modules.ts +2 -1
  1183. package/src/events/types.ts +5 -2
  1184. package/src/examples/capture_the_flag.mcrs +2 -2
  1185. package/src/examples/hunger_games.mcrs +4 -4
  1186. package/src/examples/parkour_race.mcrs +8 -8
  1187. package/src/examples/tutorial_01_hello.mcrs +63 -0
  1188. package/src/examples/tutorial_02_variables.mcrs +157 -0
  1189. package/src/examples/tutorial_03_functions_structs.mcrs +162 -0
  1190. package/src/examples/tutorial_04_selectors.mcrs +139 -0
  1191. package/src/examples/tutorial_05_decorators.mcrs +131 -0
  1192. package/src/examples/tutorial_06_math_particles.mcrs +123 -0
  1193. package/src/examples/tutorial_07_random.mcrs +142 -0
  1194. package/src/examples/tutorial_08_coroutine.mcrs +163 -0
  1195. package/src/examples/tutorial_09_precision.mcrs +154 -0
  1196. package/src/examples/tutorial_10_kill_race.mcrs +289 -0
  1197. package/src/examples/zombie_survival.mcrs +7 -7
  1198. package/src/hir/lower.ts +101 -4
  1199. package/src/hir/monomorphize.ts +11 -6
  1200. package/src/hir/types.ts +14 -1
  1201. package/src/lexer/index.ts +11 -2
  1202. package/src/lir/lower.ts +8 -0
  1203. package/src/lsp/server.ts +894 -54
  1204. package/src/mc-test/client.ts +32 -1
  1205. package/src/mir/lower.ts +703 -74
  1206. package/src/mir/types.ts +1 -0
  1207. package/src/mir/verify.ts +2 -0
  1208. package/src/optimizer/constant_fold.ts +11 -6
  1209. package/src/optimizer/coroutine.ts +89 -29
  1210. package/src/optimizer/interprocedural.ts +4 -0
  1211. package/src/parser/index.ts +175 -41
  1212. package/src/runtime/index.ts +26 -0
  1213. package/src/stdlib/advanced.mcrs +47 -0
  1214. package/src/stdlib/bigint.mcrs +251 -0
  1215. package/src/stdlib/calculus.mcrs +150 -0
  1216. package/src/stdlib/color.mcrs +102 -82
  1217. package/src/stdlib/combat.mcrs +18 -12
  1218. package/src/stdlib/dialog.mcrs +55 -0
  1219. package/src/stdlib/ecs.mcrs +238 -0
  1220. package/src/stdlib/events.mcrs +29 -0
  1221. package/src/stdlib/expr.mcrs +117 -0
  1222. package/src/stdlib/fft.mcrs +177 -0
  1223. package/src/stdlib/geometry.mcrs +89 -0
  1224. package/src/stdlib/graph.mcrs +274 -0
  1225. package/src/stdlib/heap.mcrs +175 -0
  1226. package/src/stdlib/linalg.mcrs +260 -0
  1227. package/src/stdlib/list.mcrs +99 -0
  1228. package/src/stdlib/math.mcrs +121 -5
  1229. package/src/stdlib/math_hp.mcrs +452 -0
  1230. package/src/stdlib/matrix.mcrs +113 -0
  1231. package/src/stdlib/ode.mcrs +168 -0
  1232. package/src/stdlib/parabola.mcrs +160 -0
  1233. package/src/stdlib/particles.mcrs +69 -0
  1234. package/src/stdlib/pathfind.mcrs +321 -0
  1235. package/src/stdlib/quaternion.mcrs +192 -0
  1236. package/src/stdlib/random.mcrs +46 -1
  1237. package/src/stdlib/scheduler.mcrs +271 -0
  1238. package/src/stdlib/signal.mcrs +223 -0
  1239. package/src/stdlib/sort.mcrs +194 -0
  1240. package/src/stdlib/state.mcrs +65 -0
  1241. package/src/stdlib/world.mcrs +24 -0
  1242. package/src/typechecker/index.ts +88 -15
  1243. package/test_trig.ts +43 -0
@@ -28,6 +28,10 @@ const VEC_SRC = fs.readFileSync(
28
28
  path.join(__dirname, '../../stdlib/vec.mcrs'),
29
29
  'utf-8',
30
30
  )
31
+ const ODE_SRC = fs.readFileSync(
32
+ path.join(__dirname, '../../stdlib/ode.mcrs'),
33
+ 'utf-8',
34
+ )
31
35
 
32
36
  /** Compile source with math stdlib, load into MCRuntime, init objective */
33
37
  function makeRuntime(source: string, libs: string[] = [MATH_SRC]): MCRuntime {
@@ -346,3 +350,1951 @@ describe('stdlib e2e: vec3d length & distance', () => {
346
350
  expect(val).toBeLessThanOrEqual(1733)
347
351
  })
348
352
  })
353
+
354
+ // ===========================================================================
355
+ // Additional stdlib: load sources
356
+ // ===========================================================================
357
+
358
+ const RANDOM_SRC = fs.readFileSync(
359
+ path.join(__dirname, '../../stdlib/random.mcrs'),
360
+ 'utf-8',
361
+ )
362
+ const LIST_SRC = fs.readFileSync(
363
+ path.join(__dirname, '../../stdlib/list.mcrs'),
364
+ 'utf-8',
365
+ )
366
+ const BIGINT_SRC = fs.readFileSync(
367
+ path.join(__dirname, '../../stdlib/bigint.mcrs'),
368
+ 'utf-8',
369
+ )
370
+ const EASING_SRC = fs.readFileSync(
371
+ path.join(__dirname, '../../stdlib/easing.mcrs'),
372
+ 'utf-8',
373
+ )
374
+ const NOISE_SRC = fs.readFileSync(
375
+ path.join(__dirname, '../../stdlib/noise.mcrs'),
376
+ 'utf-8',
377
+ )
378
+ const SIGNAL_SRC = fs.readFileSync(
379
+ path.join(__dirname, '../../stdlib/signal.mcrs'),
380
+ 'utf-8',
381
+ )
382
+ const ADVANCED_SRC = fs.readFileSync(
383
+ path.join(__dirname, '../../stdlib/advanced.mcrs'),
384
+ 'utf-8',
385
+ )
386
+ const VEC_SRC_FULL = fs.readFileSync(
387
+ path.join(__dirname, '../../stdlib/vec.mcrs'),
388
+ 'utf-8',
389
+ )
390
+ const PARABOLA_SRC = fs.readFileSync(
391
+ path.join(__dirname, '../../stdlib/parabola.mcrs'),
392
+ 'utf-8',
393
+ )
394
+ const QUAT_SRC = fs.readFileSync(
395
+ path.join(__dirname, '../../stdlib/quaternion.mcrs'),
396
+ 'utf-8',
397
+ )
398
+ const MATH_HP_SRC = fs.readFileSync(
399
+ path.join(__dirname, '../../stdlib/math_hp.mcrs'),
400
+ 'utf-8',
401
+ )
402
+ const EXPR_SRC = fs.readFileSync(
403
+ path.join(__dirname, '../../stdlib/expr.mcrs'),
404
+ 'utf-8',
405
+ )
406
+ const GEOM_SRC = fs.readFileSync(
407
+ path.join(__dirname, '../../stdlib/geometry.mcrs'),
408
+ 'utf-8',
409
+ )
410
+ const COLOR_SRC = fs.readFileSync(
411
+ path.join(__dirname, '../../stdlib/color.mcrs'),
412
+ 'utf-8',
413
+ )
414
+ const WORLD_SRC = fs.readFileSync(
415
+ path.join(__dirname, '../../stdlib/world.mcrs'),
416
+ 'utf-8',
417
+ )
418
+
419
+ // ===========================================================================
420
+ // math.mcrs — runtime execution (extended)
421
+ // ===========================================================================
422
+
423
+ describe('math.mcrs — runtime execution', () => {
424
+ const rt = makeRuntime(`
425
+ fn test_abs_neg42(): int { return abs(-42); }
426
+ fn test_min_3_7(): int { return min(3, 7); }
427
+ fn test_max_3_7(): int { return max(3, 7); }
428
+ fn test_clamp_15(): int { return clamp(15, 0, 10); }
429
+ fn test_clamp_neg5(): int { return clamp(-5, 0, 10); }
430
+ fn test_isqrt_144(): int { return isqrt(144); }
431
+ fn test_isqrt_2(): int { return isqrt(2); }
432
+ fn test_gcd_12_8(): int { return gcd(12, 8); }
433
+ fn test_lcm_4_6(): int { return lcm(4, 6); }
434
+ fn test_pow_2_10(): int { return pow_int(2, 10); }
435
+ fn test_comb_5_2(): int { return combinations(5, 2); }
436
+ fn test_comb_10_3(): int { return combinations(10, 3); }
437
+ fn test_factorial_5(): int { return factorial(5); }
438
+ fn test_log2_8(): int { return log2_int(8); }
439
+ fn test_log2_1024(): int { return log2_int(1024); }
440
+ fn test_sqrt_fx_40000(): int { return sqrt_fx(40000); }
441
+ fn test_cbrt_fx_27(): int { return cbrt_fx(27); }
442
+ fn test_cbrt_fx_1000(): int { return cbrt_fx(1000); }
443
+ fn test_approx_eq_1(): int { return approx_eq(100, 103, 5); }
444
+ fn test_approx_eq_0(): int { return approx_eq(100, 110, 5); }
445
+ `)
446
+
447
+ test('abs(-42) == 42', () => expect(callAndGetRet(rt, 'test_abs_neg42')).toBe(42))
448
+ test('min(3,7) == 3', () => expect(callAndGetRet(rt, 'test_min_3_7')).toBe(3))
449
+ test('max(3,7) == 7', () => expect(callAndGetRet(rt, 'test_max_3_7')).toBe(7))
450
+ test('clamp(15,0,10) == 10', () => expect(callAndGetRet(rt, 'test_clamp_15')).toBe(10))
451
+ test('clamp(-5,0,10) == 0', () => expect(callAndGetRet(rt, 'test_clamp_neg5')).toBe(0))
452
+ test('isqrt(144) == 12', () => expect(callAndGetRet(rt, 'test_isqrt_144')).toBe(12))
453
+ test('isqrt(2) == 1', () => expect(callAndGetRet(rt, 'test_isqrt_2')).toBe(1))
454
+ test('gcd(12,8) == 4', () => expect(callAndGetRet(rt, 'test_gcd_12_8')).toBe(4))
455
+ test('lcm(4,6) == 12', () => expect(callAndGetRet(rt, 'test_lcm_4_6')).toBe(12))
456
+ test('pow_int(2,10) == 1024', () => expect(callAndGetRet(rt, 'test_pow_2_10')).toBe(1024))
457
+ test('combinations(5,2) == 10', () => expect(callAndGetRet(rt, 'test_comb_5_2')).toBe(10))
458
+ test('combinations(10,3) == 120', () => expect(callAndGetRet(rt, 'test_comb_10_3')).toBe(120))
459
+ test('factorial(5) == 120', () => expect(callAndGetRet(rt, 'test_factorial_5')).toBe(120))
460
+ test('log2_int(8) == 3', () => expect(callAndGetRet(rt, 'test_log2_8')).toBe(3))
461
+ test('log2_int(1024) == 10', () => expect(callAndGetRet(rt, 'test_log2_1024')).toBe(10))
462
+ test('sqrt_fx(40000) == 20000 (√4.0 × 10000 scale, fixed)', () => {
463
+ // sqrt_fx(40000) = √(40000/10000) × 10000 = √4 × 10000 = 20000
464
+ // Implementation: isqrt(40000) * 100 = 200 * 100 = 20000
465
+ const val = callAndGetRet(rt, 'test_sqrt_fx_40000')
466
+ expect(val).toBe(20000)
467
+ })
468
+ test('cbrt_fx(27) == 3', () => expect(callAndGetRet(rt, 'test_cbrt_fx_27')).toBe(3))
469
+ test('cbrt_fx(1000) == 10', () => expect(callAndGetRet(rt, 'test_cbrt_fx_1000')).toBe(10))
470
+ test('approx_eq(100, 103, 5) == 1', () => expect(callAndGetRet(rt, 'test_approx_eq_1')).toBe(1))
471
+ test('approx_eq(100, 110, 5) == 0', () => expect(callAndGetRet(rt, 'test_approx_eq_0')).toBe(0))
472
+ })
473
+
474
+ // ===========================================================================
475
+ // random.mcrs — runtime
476
+ // ===========================================================================
477
+
478
+ describe('random.mcrs — runtime', () => {
479
+ const rt = makeRuntime(`
480
+ fn test_lcg_a(): int { return next_lcg(12345); }
481
+ fn test_lcg_b(): int { return next_lcg(next_lcg(12345)); }
482
+ fn test_rrange(): int { return random_range(next_lcg(99999), 0, 100); }
483
+ fn test_rbool(): int { return random_bool(next_lcg(42)); }
484
+ `, [MATH_SRC, RANDOM_SRC])
485
+
486
+ test('next_lcg produces different values each call', () => {
487
+ const a = callAndGetRet(rt, 'test_lcg_a')
488
+ const b = callAndGetRet(rt, 'test_lcg_b')
489
+ expect(a).not.toBe(b)
490
+ })
491
+ test('random_range stays in bounds [0,100)', () => {
492
+ const val = callAndGetRet(rt, 'test_rrange')
493
+ expect(val).toBeGreaterThanOrEqual(0)
494
+ expect(val).toBeLessThan(100)
495
+ })
496
+ test('random_bool returns 0 or 1', () => {
497
+ const val = callAndGetRet(rt, 'test_rbool')
498
+ expect([0, 1]).toContain(val)
499
+ })
500
+ })
501
+
502
+ // ===========================================================================
503
+ // list.mcrs — runtime
504
+ // ===========================================================================
505
+
506
+ describe('list.mcrs — runtime', () => {
507
+ const rt = makeRuntime(`
508
+ fn test_sort3_min(): int { return sort3(30, 10, 20, 0); }
509
+ fn test_sort3_max(): int { return sort3(30, 10, 20, 2); }
510
+ fn test_sort4_min(): int { return sort4(40, 10, 30, 20, 0); }
511
+ fn test_list_min3(): int { return list_min3(5, 3, 8); }
512
+ fn test_list_max3(): int { return list_max3(5, 3, 8); }
513
+ fn test_avg3(): int { return avg3(10, 20, 30); }
514
+ fn test_weighted2(): int { return weighted2(12345, 1, 1); }
515
+ `, [MATH_SRC, LIST_SRC])
516
+
517
+ test('sort3(30,10,20, 0) == 10 (min)', () => expect(callAndGetRet(rt, 'test_sort3_min')).toBe(10))
518
+ test('sort3(30,10,20, 2) == 30 (max)', () => expect(callAndGetRet(rt, 'test_sort3_max')).toBe(30))
519
+ test('sort4(40,10,30,20, 0) == 10', () => expect(callAndGetRet(rt, 'test_sort4_min')).toBe(10))
520
+ test('list_min3(5,3,8) == 3', () => expect(callAndGetRet(rt, 'test_list_min3')).toBe(3))
521
+ test('list_max3(5,3,8) == 8', () => expect(callAndGetRet(rt, 'test_list_max3')).toBe(8))
522
+ test('avg3(10,20,30) == 20', () => expect(callAndGetRet(rt, 'test_avg3')).toBe(20))
523
+ test('weighted2 returns 0 or 1', () => {
524
+ const val = callAndGetRet(rt, 'test_weighted2')
525
+ expect([0, 1]).toContain(val)
526
+ })
527
+ })
528
+
529
+ // ===========================================================================
530
+ // bigint.mcrs — runtime
531
+ // ===========================================================================
532
+
533
+ describe('bigint.mcrs — runtime', () => {
534
+ // bigint3_add: [0, 9999, 1] + [0, 0, 9999] = [0, 1, 0, 0] overflow mid → [1, 0, 0]
535
+ // Use simpler: add_lo / carry
536
+ const rt = makeRuntime(`
537
+ fn test_bigint3_add_lo(): int { return bigint3_add_lo(9999, 1); }
538
+ fn test_bigint3_carry_lo(): int { return bigint3_carry_lo(9999, 1); }
539
+ fn test_bigint3_add_mid_carry(): int {
540
+ let carry: int = bigint3_carry_lo(9999, 1);
541
+ return bigint3_add_mid(9999, 0, carry);
542
+ }
543
+ fn test_bigint3_carry_mid(): int {
544
+ let carry: int = bigint3_carry_lo(9999, 1);
545
+ return bigint3_carry_mid(9999, 0, carry);
546
+ }
547
+ fn test_bigint3_cmp_gt(): int {
548
+ return bigint3_cmp(1, 0, 0, 0, 9999, 9999);
549
+ }
550
+ fn test_bigint3_cmp_eq(): int {
551
+ return bigint3_cmp(0, 100, 5000, 0, 100, 5000);
552
+ }
553
+ fn test_int32_bigint3_lo(): int { return int32_to_bigint3_lo(1023456789); }
554
+ fn test_int32_bigint3_mid(): int { return int32_to_bigint3_mid(1023456789); }
555
+ fn test_int32_bigint3_hi(): int { return int32_to_bigint3_hi(1023456789); }
556
+ `, [MATH_SRC, BIGINT_SRC])
557
+
558
+ test('bigint3_add_lo(9999,1) == 0 (overflow)', () =>
559
+ expect(callAndGetRet(rt, 'test_bigint3_add_lo')).toBe(0))
560
+ test('bigint3_carry_lo(9999,1) == 1', () =>
561
+ expect(callAndGetRet(rt, 'test_bigint3_carry_lo')).toBe(1))
562
+ test('bigint3_add_mid with carry propagates: (9999+0+1)%10000 == 0', () =>
563
+ expect(callAndGetRet(rt, 'test_bigint3_add_mid_carry')).toBe(0))
564
+ test('bigint3_carry_mid(9999,0,1) == 1 (cascade carry)', () =>
565
+ expect(callAndGetRet(rt, 'test_bigint3_carry_mid')).toBe(1))
566
+ test('bigint3_cmp: [1,0,0] > [0,9999,9999] returns 1', () =>
567
+ expect(callAndGetRet(rt, 'test_bigint3_cmp_gt')).toBe(1))
568
+ test('bigint3_cmp: equal returns 0', () =>
569
+ expect(callAndGetRet(rt, 'test_bigint3_cmp_eq')).toBe(0))
570
+ // 1023456789 = 10 * 10000^2 + 2345 * 10000 + 6789
571
+ test('int32_to_bigint3_lo(1023456789) == 6789', () =>
572
+ expect(callAndGetRet(rt, 'test_int32_bigint3_lo')).toBe(6789))
573
+ test('int32_to_bigint3_mid(1023456789) == 2345', () =>
574
+ expect(callAndGetRet(rt, 'test_int32_bigint3_mid')).toBe(2345))
575
+ test('int32_to_bigint3_hi(1023456789) == 10', () =>
576
+ expect(callAndGetRet(rt, 'test_int32_bigint3_hi')).toBe(10))
577
+ })
578
+
579
+ // ===========================================================================
580
+ // noise.mcrs — runtime
581
+ // ===========================================================================
582
+
583
+ describe('noise.mcrs — runtime', () => {
584
+ const rt = makeRuntime(`
585
+ fn test_hash_det(): int {
586
+ let a: int = hash_1d(42);
587
+ let b: int = hash_1d(42);
588
+ if (a == b) { return 1; }
589
+ return 0;
590
+ }
591
+ fn test_hash_diff(): int {
592
+ let a: int = hash_1d(0);
593
+ let b: int = hash_1d(1);
594
+ if (a != b) { return 1; }
595
+ return 0;
596
+ }
597
+ fn test_hash_1d_pos_in_range(): int {
598
+ let h: int = hash_1d_pos(99);
599
+ if (h >= 0) {
600
+ if (h <= 10000) { return 1; }
601
+ }
602
+ return 0;
603
+ }
604
+ fn test_hash_2d_det(): int {
605
+ let a: int = hash_2d(3, 7);
606
+ let b: int = hash_2d(3, 7);
607
+ if (a == b) { return 1; }
608
+ return 0;
609
+ }
610
+ fn test_vn1d_in_range(): int {
611
+ let v: int = value_noise_1d(15000);
612
+ if (v >= 0) {
613
+ if (v <= 10000) { return 1; }
614
+ }
615
+ return 0;
616
+ }
617
+ fn test_vn1d_det(): int {
618
+ let a: int = value_noise_1d(25000);
619
+ let b: int = value_noise_1d(25000);
620
+ if (a == b) { return 1; }
621
+ return 0;
622
+ }
623
+ fn test_vn1d_at_integer(): int {
624
+ let vn: int = value_noise_1d(20000);
625
+ let h: int = hash_1d_pos(2);
626
+ if (vn == h) { return 1; }
627
+ return 0;
628
+ }
629
+ fn test_vn2d_in_range(): int {
630
+ let v: int = value_noise_2d(15000, 25000);
631
+ if (v >= 0) {
632
+ if (v <= 10000) { return 1; }
633
+ }
634
+ return 0;
635
+ }
636
+ fn test_fbm1d_1oct(): int {
637
+ let f: int = fbm_1d(20000, 1, 5000);
638
+ let v: int = value_noise_1d(20000);
639
+ if (f == v) { return 1; }
640
+ return 0;
641
+ }
642
+ fn test_fbm1d_in_range(): int {
643
+ let v: int = fbm_1d(30000, 3, 5000);
644
+ if (v >= 0) {
645
+ if (v <= 10000) { return 1; }
646
+ }
647
+ return 0;
648
+ }
649
+ fn test_fbm2d_in_range(): int {
650
+ let v: int = fbm_2d(10000, 20000, 2, 6000);
651
+ if (v >= 0) {
652
+ if (v <= 10000) { return 1; }
653
+ }
654
+ return 0;
655
+ }
656
+ fn test_terrain_in_range(): int {
657
+ let h: int = terrain_height(0, 0, 64, 20);
658
+ if (h >= 64) {
659
+ if (h <= 84) { return 1; }
660
+ }
661
+ return 0;
662
+ }
663
+ fn test_terrain_spatial(): int {
664
+ let a: int = terrain_height(0, 0, 64, 20);
665
+ let b: int = terrain_height(7, 13, 64, 20);
666
+ if (a != b) { return 1; }
667
+ return 0;
668
+ }
669
+ `, [MATH_SRC, NOISE_SRC])
670
+
671
+ test('hash_1d is deterministic', () => expect(callAndGetRet(rt, 'test_hash_det')).toBe(1))
672
+ test('hash_1d(0) != hash_1d(1)', () => expect(callAndGetRet(rt, 'test_hash_diff')).toBe(1))
673
+ test('hash_1d_pos returns [0, 10000]', () => expect(callAndGetRet(rt, 'test_hash_1d_pos_in_range')).toBe(1))
674
+ test('hash_2d is deterministic', () => expect(callAndGetRet(rt, 'test_hash_2d_det')).toBe(1))
675
+ test('value_noise_1d returns [0, 10000]', () => expect(callAndGetRet(rt, 'test_vn1d_in_range')).toBe(1))
676
+ test('value_noise_1d is deterministic', () => expect(callAndGetRet(rt, 'test_vn1d_det')).toBe(1))
677
+ test('value_noise_1d at integer boundary == hash_1d_pos', () => expect(callAndGetRet(rt, 'test_vn1d_at_integer')).toBe(1))
678
+ test('value_noise_2d returns [0, 10000]', () => expect(callAndGetRet(rt, 'test_vn2d_in_range')).toBe(1))
679
+ test('fbm_1d(x,1,p) == value_noise_1d(x) (1 octave)', () => expect(callAndGetRet(rt, 'test_fbm1d_1oct')).toBe(1))
680
+ test('fbm_1d returns [0, 10000]', () => expect(callAndGetRet(rt, 'test_fbm1d_in_range')).toBe(1))
681
+ test('fbm_2d returns [0, 10000]', () => expect(callAndGetRet(rt, 'test_fbm2d_in_range')).toBe(1))
682
+ test('terrain_height(0,0,64,20) in [64,84]', () => expect(callAndGetRet(rt, 'test_terrain_in_range')).toBe(1))
683
+ test('terrain_height varies spatially', () => expect(callAndGetRet(rt, 'test_terrain_spatial')).toBe(1))
684
+ })
685
+
686
+ // ===========================================================================
687
+ // signal.mcrs — runtime
688
+ // ===========================================================================
689
+
690
+ describe('signal.mcrs — runtime', () => {
691
+ const rt = makeRuntime(`
692
+ fn test_uniform_int_range(): int {
693
+ let v: int = uniform_int(12345, 0, 10);
694
+ if (v >= 0) { if (v <= 10) { return 1; } }
695
+ return 0;
696
+ }
697
+ fn test_uniform_int_det(): int {
698
+ let a: int = uniform_int(99999, 0, 100);
699
+ let b: int = uniform_int(99999, 0, 100);
700
+ if (a == b) { return 1; }
701
+ return 0;
702
+ }
703
+ fn test_uniform_int_single(): int {
704
+ return uniform_int(42, 5, 5);
705
+ }
706
+ fn test_uniform_frac_range(): int {
707
+ let v: int = uniform_frac(12345);
708
+ if (v >= 0) { if (v <= 10000) { return 1; } }
709
+ return 0;
710
+ }
711
+ fn test_bernoulli_range(): int {
712
+ let v: int = bernoulli(42, 5000);
713
+ if (v >= 0) { if (v <= 1) { return 1; } }
714
+ return 0;
715
+ }
716
+ fn test_bernoulli_always(): int { return bernoulli(42, 10000); }
717
+ fn test_bernoulli_never(): int { return bernoulli(42, 0); }
718
+ fn test_normal_range(): int {
719
+ let v: int = normal_approx12(42);
720
+ if (v >= -60000) { if (v <= 60000) { return 1; } }
721
+ return 0;
722
+ }
723
+ fn test_normal_det(): int {
724
+ let a: int = normal_approx12(100);
725
+ let b: int = normal_approx12(100);
726
+ if (a == b) { return 1; }
727
+ return 0;
728
+ }
729
+ fn test_weighted2_range(): int {
730
+ let v: int = weighted2(12345, 3, 7);
731
+ if (v >= 0) { if (v <= 1) { return 1; } }
732
+ return 0;
733
+ }
734
+ fn test_weighted2_all_on_1(): int { return weighted2(42, 0, 1); }
735
+ fn test_weighted2_all_on_0(): int { return weighted2(42, 1, 0); }
736
+ fn test_weighted3_range(): int {
737
+ let v: int = weighted3(99999, 2, 3, 5);
738
+ if (v >= 0) { if (v <= 2) { return 1; } }
739
+ return 0;
740
+ }
741
+ fn test_weighted3_all_on_2(): int { return weighted3(42, 0, 0, 1); }
742
+ fn test_weighted3_all_on_0(): int { return weighted3(42, 1, 0, 0); }
743
+ fn test_exp_range(): int {
744
+ let v: int = exp_dist_approx(42, 10000);
745
+ if (v >= 0) { if (v <= 100000) { return 1; } }
746
+ return 0;
747
+ }
748
+ fn test_exp_det(): int {
749
+ let a: int = exp_dist_approx(12345, 10000);
750
+ let b: int = exp_dist_approx(12345, 10000);
751
+ if (a == b) { return 1; }
752
+ return 0;
753
+ }
754
+ `, [MATH_SRC, RANDOM_SRC, SIGNAL_SRC])
755
+
756
+ test('uniform_int(seed,0,10) in [0,10]', () => expect(callAndGetRet(rt, 'test_uniform_int_range')).toBe(1))
757
+ test('uniform_int is deterministic', () => expect(callAndGetRet(rt, 'test_uniform_int_det')).toBe(1))
758
+ test('uniform_int(seed,5,5) == 5', () => expect(callAndGetRet(rt, 'test_uniform_int_single')).toBe(5))
759
+ test('uniform_frac returns [0,10000]', () => expect(callAndGetRet(rt, 'test_uniform_frac_range')).toBe(1))
760
+ test('bernoulli returns 0 or 1', () => expect(callAndGetRet(rt, 'test_bernoulli_range')).toBe(1))
761
+ test('bernoulli(seed,10000) == 1 (always)', () => expect(callAndGetRet(rt, 'test_bernoulli_always')).toBe(1))
762
+ test('bernoulli(seed,0) == 0 (never)', () => expect(callAndGetRet(rt, 'test_bernoulli_never')).toBe(0))
763
+ test('normal_approx12 in [-60000,60000]', () => expect(callAndGetRet(rt, 'test_normal_range')).toBe(1))
764
+ test('normal_approx12 is deterministic', () => expect(callAndGetRet(rt, 'test_normal_det')).toBe(1))
765
+ test('weighted2 returns 0 or 1', () => expect(callAndGetRet(rt, 'test_weighted2_range')).toBe(1))
766
+ test('weighted2(seed,0,1) == 1 (all weight on 1)', () => expect(callAndGetRet(rt, 'test_weighted2_all_on_1')).toBe(1))
767
+ test('weighted2(seed,1,0) == 0 (all weight on 0)', () => expect(callAndGetRet(rt, 'test_weighted2_all_on_0')).toBe(0))
768
+ test('weighted3 returns 0,1,2', () => expect(callAndGetRet(rt, 'test_weighted3_range')).toBe(1))
769
+ test('weighted3(seed,0,0,1) == 2 (all weight on 2)', () => expect(callAndGetRet(rt, 'test_weighted3_all_on_2')).toBe(2))
770
+ test('weighted3(seed,1,0,0) == 0 (all weight on 0)', () => expect(callAndGetRet(rt, 'test_weighted3_all_on_0')).toBe(0))
771
+ test('exp_dist_approx in [0,100000]', () => expect(callAndGetRet(rt, 'test_exp_range')).toBe(1))
772
+ test('exp_dist_approx is deterministic', () => expect(callAndGetRet(rt, 'test_exp_det')).toBe(1))
773
+ })
774
+
775
+ // ===========================================================================
776
+ // signal.mcrs — statistical distributions (Gamma, Poisson, NegBin)
777
+ // ===========================================================================
778
+
779
+ describe('signal.mcrs — statistical distributions', () => {
780
+ const rt = makeRuntime(`
781
+ fn test_gamma_pos(): int {
782
+ let v: int = gamma_sample(10000, 10000, 42);
783
+ if (v > 0) { return 1; }
784
+ return 0;
785
+ }
786
+ fn test_poisson_range(): int {
787
+ let v: int = poisson_sample(30000, 42);
788
+ if (v >= 0) { if (v <= 20) { return 1; } }
789
+ return 0;
790
+ }
791
+ fn test_negbin_nonneg(): int {
792
+ let v: int = negative_binomial_sample(1, 5000, 42);
793
+ if (v >= 0) { return 1; }
794
+ return 0;
795
+ }
796
+ `, [MATH_SRC, RANDOM_SRC, SIGNAL_SRC])
797
+
798
+ // Note: gamma_sample uses ln() which has nested while loops — MCRuntime may not
799
+ // produce accurate values. This test only verifies the function compiles and runs.
800
+ test('gamma_sample compiles and returns int', () => expect(typeof callAndGetRet(rt, 'test_gamma_pos')).toBe('number'))
801
+ test('poisson_sample(30000, 42) in [0, 20] (lambda=3)', () => expect(callAndGetRet(rt, 'test_poisson_range')).toBe(1))
802
+ test('negative_binomial_sample(1, 5000, 42) >= 0 (r=1, p=0.5)', () => expect(callAndGetRet(rt, 'test_negbin_nonneg')).toBe(1))
803
+ })
804
+
805
+ // ===========================================================================
806
+ // signal.mcrs — DFT (Discrete Fourier Transform)
807
+ // ===========================================================================
808
+
809
+ describe('signal.mcrs — DFT', () => {
810
+ const rt = makeRuntime(`
811
+ // Uniform signal [10000, 10000, 10000, 10000], n=4
812
+ // DC bin (k=0): real = mean = 10000, imag = 0, magnitude = 10000
813
+ fn test_dft_real_dc(): int {
814
+ return dft_real(10000, 10000, 10000, 10000, 0, 0, 0, 0, 4, 0);
815
+ }
816
+ fn test_dft_imag_dc(): int {
817
+ return dft_imag(10000, 10000, 10000, 10000, 0, 0, 0, 0, 4, 0);
818
+ }
819
+ fn test_dft_mag_dc(): int {
820
+ return dft_magnitude(10000, 10000, 10000, 10000, 0, 0, 0, 0, 4, 0);
821
+ }
822
+ // Uniform signal, k=1: all non-DC bins should be ~0
823
+ fn test_dft_real_k1(): int {
824
+ let v: int = dft_real(10000, 10000, 10000, 10000, 0, 0, 0, 0, 4, 1);
825
+ if (v < 0) { v = 0 - v; }
826
+ if (v <= 500) { return 1; }
827
+ return 0;
828
+ }
829
+ fn test_dft_mag_k1_near_zero(): int {
830
+ let v: int = dft_magnitude(10000, 10000, 10000, 10000, 0, 0, 0, 0, 4, 1);
831
+ if (v <= 500) { return 1; }
832
+ return 0;
833
+ }
834
+ fn test_dft_mag_k2_near_zero(): int {
835
+ let v: int = dft_magnitude(10000, 10000, 10000, 10000, 0, 0, 0, 0, 4, 2);
836
+ if (v <= 500) { return 1; }
837
+ return 0;
838
+ }
839
+ fn test_dft_mag_k3_near_zero(): int {
840
+ let v: int = dft_magnitude(10000, 10000, 10000, 10000, 0, 0, 0, 0, 4, 3);
841
+ if (v <= 500) { return 1; }
842
+ return 0;
843
+ }
844
+ // n=8 uniform signal: DC = 10000, all other bins near zero
845
+ fn test_dft_real_dc_n8(): int {
846
+ return dft_real(10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 8, 0);
847
+ }
848
+ fn test_dft_mag_k1_n8(): int {
849
+ let v: int = dft_magnitude(10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 8, 1);
850
+ if (v <= 500) { return 1; }
851
+ return 0;
852
+ }
853
+ // _sin45 / _cos45 sanity checks
854
+ fn test_sin45_0(): int { return _sin45(0); }
855
+ fn test_sin45_2(): int { return _sin45(2); }
856
+ fn test_cos45_0(): int { return _cos45(0); }
857
+ fn test_cos45_2(): int { return _cos45(2); }
858
+ `, [MATH_SRC, SIGNAL_SRC])
859
+
860
+ test('_sin45(0) == 0', () => expect(callAndGetRet(rt, 'test_sin45_0')).toBe(0))
861
+ test('_sin45(2) == 10000', () => expect(callAndGetRet(rt, 'test_sin45_2')).toBe(10000))
862
+ test('_cos45(0) == 10000', () => expect(callAndGetRet(rt, 'test_cos45_0')).toBe(10000))
863
+ test('_cos45(2) == 0', () => expect(callAndGetRet(rt, 'test_cos45_2')).toBe(0))
864
+
865
+ test('dft_real(uniform×4, n=4, k=0) == 10000 (DC = mean)', () => expect(callAndGetRet(rt, 'test_dft_real_dc')).toBe(10000))
866
+ test('dft_imag(uniform×4, n=4, k=0) == 0', () => expect(callAndGetRet(rt, 'test_dft_imag_dc')).toBe(0))
867
+ test('dft_magnitude(uniform×4, n=4, k=0) == 10000', () => expect(callAndGetRet(rt, 'test_dft_mag_dc')).toBe(10000))
868
+ test('dft_real(uniform×4, n=4, k=1) ≈ 0 (±500)', () => expect(callAndGetRet(rt, 'test_dft_real_k1')).toBe(1))
869
+ test('dft_magnitude(uniform×4, n=4, k=1) ≤ 500', () => expect(callAndGetRet(rt, 'test_dft_mag_k1_near_zero')).toBe(1))
870
+ test('dft_magnitude(uniform×4, n=4, k=2) ≤ 500', () => expect(callAndGetRet(rt, 'test_dft_mag_k2_near_zero')).toBe(1))
871
+ test('dft_magnitude(uniform×4, n=4, k=3) ≤ 500', () => expect(callAndGetRet(rt, 'test_dft_mag_k3_near_zero')).toBe(1))
872
+ test('dft_real(uniform×8, n=8, k=0) == 10000 (DC = mean)', () => expect(callAndGetRet(rt, 'test_dft_real_dc_n8')).toBe(10000))
873
+ test('dft_magnitude(uniform×8, n=8, k=1) ≤ 500', () => expect(callAndGetRet(rt, 'test_dft_mag_k1_n8')).toBe(1))
874
+ })
875
+
876
+ // ===========================================================================
877
+ // advanced.mcrs — runtime
878
+ // ===========================================================================
879
+
880
+ describe('advanced.mcrs — number theory', () => {
881
+ const rt = makeRuntime(`
882
+ fn test_fib_0(): int { return fib(0); }
883
+ fn test_fib_1(): int { return fib(1); }
884
+ fn test_fib_10(): int { return fib(10); }
885
+ fn test_fib_20(): int { return fib(20); }
886
+ fn test_is_prime_2(): int { return is_prime(2); }
887
+ fn test_is_prime_4(): int { return is_prime(4); }
888
+ fn test_is_prime_97(): int { return is_prime(97); }
889
+ fn test_is_prime_1(): int { return is_prime(1); }
890
+ fn test_collatz_1(): int { return collatz_steps(1); }
891
+ fn test_collatz_6(): int { return collatz_steps(6); }
892
+ fn test_collatz_27(): int { return collatz_steps(27); }
893
+ fn test_digit_sum_123(): int { return digit_sum(123); }
894
+ fn test_digit_sum_0(): int { return digit_sum(0); }
895
+ fn test_count_digits_0(): int { return count_digits(0); }
896
+ fn test_count_digits_100(): int { return count_digits(100); }
897
+ fn test_reverse_12345(): int { return reverse_int(12345); }
898
+ fn test_reverse_neg42(): int { return reverse_int(-42); }
899
+ fn test_mod_pow(): int { return mod_pow(2, 10, 1000); }
900
+ fn test_mod_pow_base(): int { return mod_pow(3, 0, 7); }
901
+ fn test_digital_root_493(): int { return digital_root(493); }
902
+ fn test_digital_root_9(): int { return digital_root(9); }
903
+ fn test_digital_root_0(): int { return digital_root(0); }
904
+ fn test_newton_sqrt_25(): int { return newton_sqrt(25); }
905
+ fn test_newton_sqrt_100(): int { return newton_sqrt(100); }
906
+ fn test_newton_sqrt_2(): int { return newton_sqrt(2); }
907
+ fn test_spiral_ring_1(): int { return spiral_ring(1); }
908
+ fn test_spiral_ring_9(): int { return spiral_ring(9); }
909
+ fn test_spiral_ring_25(): int { return spiral_ring(25); }
910
+ `, [MATH_SRC, ADVANCED_SRC])
911
+
912
+ // fib
913
+ test('fib(0) == 0', () => expect(callAndGetRet(rt, 'test_fib_0')).toBe(0))
914
+ test('fib(1) == 1', () => expect(callAndGetRet(rt, 'test_fib_1')).toBe(1))
915
+ test('fib(10) == 55', () => expect(callAndGetRet(rt, 'test_fib_10')).toBe(55))
916
+ test('fib(20) == 6765', () => expect(callAndGetRet(rt, 'test_fib_20')).toBe(6765))
917
+
918
+ // is_prime
919
+ test('is_prime(2) == 1', () => expect(callAndGetRet(rt, 'test_is_prime_2')).toBe(1))
920
+ test('is_prime(4) == 0', () => expect(callAndGetRet(rt, 'test_is_prime_4')).toBe(0))
921
+ test('is_prime(97) == 1', () => expect(callAndGetRet(rt, 'test_is_prime_97')).toBe(1))
922
+ test('is_prime(1) == 0', () => expect(callAndGetRet(rt, 'test_is_prime_1')).toBe(0))
923
+
924
+ // collatz
925
+ test('collatz_steps(1) == 0', () => expect(callAndGetRet(rt, 'test_collatz_1')).toBe(0))
926
+ test('collatz_steps(6) == 8', () => expect(callAndGetRet(rt, 'test_collatz_6')).toBe(8))
927
+ test('collatz_steps(27) == 111', () => expect(callAndGetRet(rt, 'test_collatz_27')).toBe(111))
928
+
929
+ // digit_sum / count_digits
930
+ test('digit_sum(123) == 6', () => expect(callAndGetRet(rt, 'test_digit_sum_123')).toBe(6))
931
+ test('digit_sum(0) == 0', () => expect(callAndGetRet(rt, 'test_digit_sum_0')).toBe(0))
932
+ test('count_digits(0) == 1', () => expect(callAndGetRet(rt, 'test_count_digits_0')).toBe(1))
933
+ test('count_digits(100) == 3', () => expect(callAndGetRet(rt, 'test_count_digits_100')).toBe(3))
934
+
935
+ // reverse_int
936
+ test('reverse_int(12345) == 54321', () => expect(callAndGetRet(rt, 'test_reverse_12345')).toBe(54321))
937
+ test('reverse_int(-42) == -24', () => expect(callAndGetRet(rt, 'test_reverse_neg42')).toBe(-24))
938
+
939
+ // mod_pow
940
+ test('mod_pow(2, 10, 1000) == 24', () => expect(callAndGetRet(rt, 'test_mod_pow')).toBe(24))
941
+ test('mod_pow(3, 0, 7) == 1 (anything^0 = 1)', () => expect(callAndGetRet(rt, 'test_mod_pow_base')).toBe(1))
942
+
943
+ // digital_root
944
+ test('digital_root(493) == 7', () => expect(callAndGetRet(rt, 'test_digital_root_493')).toBe(7))
945
+ test('digital_root(9) == 9', () => expect(callAndGetRet(rt, 'test_digital_root_9')).toBe(9))
946
+ test('digital_root(0) == 0', () => expect(callAndGetRet(rt, 'test_digital_root_0')).toBe(0))
947
+
948
+ // newton_sqrt
949
+ test('newton_sqrt(25) == 5', () => expect(callAndGetRet(rt, 'test_newton_sqrt_25')).toBe(5))
950
+ test('newton_sqrt(100) == 10', () => expect(callAndGetRet(rt, 'test_newton_sqrt_100')).toBe(10))
951
+ test('newton_sqrt(2) == 1 (floor)', () => expect(callAndGetRet(rt, 'test_newton_sqrt_2')).toBe(1))
952
+
953
+ // spiral_ring
954
+ test('spiral_ring(1) == 0', () => expect(callAndGetRet(rt, 'test_spiral_ring_1')).toBe(0))
955
+ test('spiral_ring(9) == 1', () => expect(callAndGetRet(rt, 'test_spiral_ring_9')).toBe(1))
956
+ test('spiral_ring(25) == 2', () => expect(callAndGetRet(rt, 'test_spiral_ring_25')).toBe(2))
957
+ })
958
+
959
+ describe('advanced.mcrs — curves & fractals', () => {
960
+ const rt = makeRuntime(`
961
+ fn test_bezier_quad_start(): int { return bezier_quad(0, 500, 1000, 0); }
962
+ fn test_bezier_quad_end(): int { return bezier_quad(0, 500, 1000, 1000); }
963
+ fn test_bezier_quad_mid(): int { return bezier_quad(0, 500, 1000, 500); }
964
+ fn test_bezier_quad_arch(): int { return bezier_quad(0, 1000, 0, 500); }
965
+ fn test_bezier_cubic_start(): int { return bezier_cubic(0, 333, 667, 1000, 0); }
966
+ fn test_bezier_cubic_end(): int { return bezier_cubic(0, 333, 667, 1000, 1000); }
967
+ fn test_mandelbrot_in_set(): int { return mandelbrot_iter(-1000, 0, 100); }
968
+ fn test_mandelbrot_outside(): int { return mandelbrot_iter(1000, 0, 100); }
969
+ fn test_hash_int_det(): int {
970
+ let a: int = hash_int(42);
971
+ let b: int = hash_int(42);
972
+ if (a == b) { return 1; }
973
+ return 0;
974
+ }
975
+ fn test_hash_int_diff(): int {
976
+ let a: int = hash_int(0);
977
+ let b: int = hash_int(1);
978
+ if (a != b) { return 1; }
979
+ return 0;
980
+ }
981
+ fn test_noise1d_range(): int {
982
+ let v: int = noise1d(500);
983
+ if (v >= 0) { if (v < 1000) { return 1; } }
984
+ return 0;
985
+ }
986
+ `, [MATH_SRC, ADVANCED_SRC])
987
+
988
+ // bezier_quad
989
+ test('bezier_quad(0,500,1000, t=0) == 0 (start)', () => expect(callAndGetRet(rt, 'test_bezier_quad_start')).toBe(0))
990
+ test('bezier_quad(0,500,1000, t=1000) == 1000 (end)', () => expect(callAndGetRet(rt, 'test_bezier_quad_end')).toBe(1000))
991
+ test('bezier_quad(0,500,1000, t=500) == 500 (midpoint)', () => expect(callAndGetRet(rt, 'test_bezier_quad_mid')).toBe(500))
992
+ test('bezier_quad(0,1000,0, t=500) == 500 (arch)', () => expect(callAndGetRet(rt, 'test_bezier_quad_arch')).toBe(500))
993
+
994
+ // bezier_cubic
995
+ test('bezier_cubic(0,333,667,1000, t=0) == 0 (start)', () => expect(callAndGetRet(rt, 'test_bezier_cubic_start')).toBe(0))
996
+ test('bezier_cubic(0,333,667,1000, t=1000) == 1000 (end)', () => expect(callAndGetRet(rt, 'test_bezier_cubic_end')).toBe(1000))
997
+
998
+ // mandelbrot
999
+ test('mandelbrot_iter(-1000,0,100) == 100 (in set, c=-1+0i)', () => expect(callAndGetRet(rt, 'test_mandelbrot_in_set')).toBe(100))
1000
+ test('mandelbrot_iter(1000,0,100) < 100 (outside, escapes quickly)', () => expect(callAndGetRet(rt, 'test_mandelbrot_outside')).toBeLessThan(100))
1001
+
1002
+ // hash_int
1003
+ test('hash_int is deterministic', () => expect(callAndGetRet(rt, 'test_hash_int_det')).toBe(1))
1004
+ test('hash_int(0) != hash_int(1)', () => expect(callAndGetRet(rt, 'test_hash_int_diff')).toBe(1))
1005
+
1006
+ // noise1d
1007
+ test('noise1d(500) in [0, 1000)', () => expect(callAndGetRet(rt, 'test_noise1d_range')).toBe(1))
1008
+ })
1009
+
1010
+ // ===========================================================================
1011
+ // bigint.mcrs — full multiplication (bigint_mul / bigint_sq)
1012
+ // ===========================================================================
1013
+
1014
+ describe('bigint.mcrs — bigint_mul / bigint_sq', () => {
1015
+ const rt = makeRuntime(`
1016
+ // bigint_mul: [0, 0, 3] * [0, 0, 4] = [0, 0, 0, 0, 12]
1017
+ fn test_mul_simple_lo(): int {
1018
+ let a: int[] = [0, 0, 3];
1019
+ let b: int[] = [0, 0, 4];
1020
+ let r: int[] = [0, 0, 0, 0, 0, 0];
1021
+ bigint_mul(a, b, r, 3, 3);
1022
+ return r[5]; // LSB: 3*4=12
1023
+ }
1024
+ fn test_mul_simple_hi(): int {
1025
+ let a: int[] = [0, 0, 3];
1026
+ let b: int[] = [0, 0, 4];
1027
+ let r: int[] = [0, 0, 0, 0, 0, 0];
1028
+ bigint_mul(a, b, r, 3, 3);
1029
+ return r[4]; // should be 0
1030
+ }
1031
+
1032
+ // bigint_mul: [0, 1, 0] * [0, 0, 5000] = [0, 0, 0, 5000, 0, 0]
1033
+ // = 10000 * 5000 = 50,000,000 = [0, 0, 5000, 0] in base 10000
1034
+ // With 3+3=6 chunks: [0, 0, 0, 5000, 0, 0]
1035
+ fn test_mul_carry_chunk(): int {
1036
+ let a: int[] = [0, 1, 0]; // value = 10000
1037
+ let b: int[] = [0, 0, 5000]; // value = 5000
1038
+ // product = 50,000,000 = [0,0,0,5000,0,0] in 6 chunks
1039
+ // a[1]*b[2] -> pos = 1+2+1 = 4, so r[4]=5000
1040
+ let r: int[] = [0, 0, 0, 0, 0, 0];
1041
+ bigint_mul(a, b, r, 3, 3);
1042
+ return r[4]; // 5000
1043
+ }
1044
+
1045
+ // bigint_mul: 9999 * 9999 = 99,980,001
1046
+ // bigint3: [0, 0, 9999] * [0, 0, 9999] = 99,980,001
1047
+ // = [0, 0, 0, 9998, 1] in base 10000
1048
+ fn test_mul_max_chunk_lo(): int {
1049
+ let a: int[] = [0, 0, 9999];
1050
+ let b: int[] = [0, 0, 9999];
1051
+ let r: int[] = [0, 0, 0, 0, 0, 0];
1052
+ bigint_mul(a, b, r, 3, 3);
1053
+ return r[5]; // 99980001 % 10000 = 1 (wait: 99980001 = 9998*10000 + 1)... = 1
1054
+ }
1055
+ fn test_mul_max_chunk_hi(): int {
1056
+ let a: int[] = [0, 0, 9999];
1057
+ let b: int[] = [0, 0, 9999];
1058
+ let r: int[] = [0, 0, 0, 0, 0, 0];
1059
+ bigint_mul(a, b, r, 3, 3);
1060
+ return r[4]; // 9998
1061
+ }
1062
+
1063
+ // bigint_sq: [0, 0, 3]^2 = [0, 0, 0, 0, 0, 9]
1064
+ fn test_sq_simple(): int {
1065
+ let a: int[] = [0, 0, 3];
1066
+ let r: int[] = [0, 0, 0, 0, 0, 0];
1067
+ bigint_sq(a, r, 3);
1068
+ return r[5]; // 9
1069
+ }
1070
+
1071
+ // bigint_sq: [0, 0, 100]^2 = [0, 0, 0, 0, 1, 0] (10000)
1072
+ fn test_sq_100_hi(): int {
1073
+ let a: int[] = [0, 0, 100];
1074
+ let r: int[] = [0, 0, 0, 0, 0, 0];
1075
+ bigint_sq(a, r, 3);
1076
+ return r[4]; // 10000/10000 = 1
1077
+ }
1078
+ fn test_sq_100_lo(): int {
1079
+ let a: int[] = [0, 0, 100];
1080
+ let r: int[] = [0, 0, 0, 0, 0, 0];
1081
+ bigint_sq(a, r, 3);
1082
+ return r[5]; // 10000 % 10000 = 0
1083
+ }
1084
+
1085
+ // bigint_mul_result_len
1086
+ fn test_result_len(): int { return bigint_mul_result_len(3, 4); }
1087
+ `, [MATH_SRC, BIGINT_SRC])
1088
+
1089
+ test('bigint_mul([0,0,3], [0,0,4]) lo == 12', () => expect(callAndGetRet(rt, 'test_mul_simple_lo')).toBe(12))
1090
+ test('bigint_mul([0,0,3], [0,0,4]) hi == 0 (no overflow)', () => expect(callAndGetRet(rt, 'test_mul_simple_hi')).toBe(0))
1091
+ test('bigint_mul([0,1,0], [0,0,5000]) chunk[4] == 5000 (carry)', () => expect(callAndGetRet(rt, 'test_mul_carry_chunk')).toBe(5000))
1092
+ test('bigint_mul(9999, 9999) lo == 1', () => expect(callAndGetRet(rt, 'test_mul_max_chunk_lo')).toBe(1))
1093
+ test('bigint_mul(9999, 9999) hi chunk == 9998', () => expect(callAndGetRet(rt, 'test_mul_max_chunk_hi')).toBe(9998))
1094
+ test('bigint_sq([0,0,3]) lo == 9', () => expect(callAndGetRet(rt, 'test_sq_simple')).toBe(9))
1095
+ test('bigint_sq([0,0,100]) chunk[4] == 1 (10000 carry)', () => expect(callAndGetRet(rt, 'test_sq_100_hi')).toBe(1))
1096
+ test('bigint_sq([0,0,100]) chunk[5] == 0', () => expect(callAndGetRet(rt, 'test_sq_100_lo')).toBe(0))
1097
+ test('bigint_mul_result_len(3, 4) == 7', () => expect(callAndGetRet(rt, 'test_result_len')).toBe(7))
1098
+ })
1099
+
1100
+ // ===========================================================================
1101
+ // parabola.mcrs — runtime
1102
+ // ===========================================================================
1103
+
1104
+ describe('parabola.mcrs — ballistic trajectory', () => {
1105
+ const rt = makeRuntime(`
1106
+ // parabola_vx(10, 20) = 10*10000/20 = 5000 (0.5 b/tick)
1107
+ fn test_vx(): int { return parabola_vx(10, 20); }
1108
+
1109
+ // parabola_vz(0, 20) = 0
1110
+ fn test_vz_zero(): int { return parabola_vz(0, 20); }
1111
+
1112
+ // parabola_vy: flat shot (dy=0, t=20) = gravity_half * t^2 / t = 400*400/20 = 8000
1113
+ // = (0 + 400*20*20/10000) / 20 = (0 + 1600) / 20 = 80... wait
1114
+ // g_term = 400 * 20 * 20 / 10000 = 160000/10000 = 16
1115
+ // vy = (0 + 16*10000) / 20... no:
1116
+ // g_term = parabola_gravity_half() * ticks * ticks / 10000 = 400*20*20/10000 = 16
1117
+ // vy = (dy*10000 + g_term) / ticks = (0 + 16) / 20 = 0 (integer division)
1118
+ // Actually: g_term = 400 * 20 * 20 / 10000 = 160000/10000 = 16
1119
+ // vy = (0 + 16) / 20 = 0 (floors!)
1120
+ // That's correct for integer: very small arc over 20 ticks
1121
+ fn test_vy_flat(): int { return parabola_vy(0, 20); }
1122
+
1123
+ // parabola_vy(10, 20): dy=10 blocks up in 20 ticks
1124
+ // g_term = 400*400/10000 = 16 (same)
1125
+ // vy = (10*10000 + 16) / 20 = 100016 / 20 = 5000
1126
+ fn test_vy_up(): int { return parabola_vy(10, 20); }
1127
+
1128
+ // parabola_x(5000, 20) = 5000*20/10000 = 10
1129
+ fn test_x_at_t(): int { return parabola_x(5000, 20); }
1130
+
1131
+ // parabola_y(5000, 20): vy0=5000 (0.5 b/t), at t=20
1132
+ // = 5000*20/10000 - 400*20*20/10000 = 10 - 16 = -6 (landed below)
1133
+ fn test_y_at_t(): int { return parabola_y(5000, 20); }
1134
+
1135
+ // parabola_flight_time(8000): vy0=0.8 b/t
1136
+ // t = 2 * 8000 / 800 = 20
1137
+ fn test_flight_time(): int { return parabola_flight_time(8000); }
1138
+
1139
+ // parabola_max_height(8000): apex at t=8000/800=10
1140
+ // y(10) = 8000*10/10000 - 400*100/10000 = 8 - 4 = 4
1141
+ fn test_max_height(): int { return parabola_max_height(8000); }
1142
+
1143
+ // parabola_in_range(3, 4, 5) = 1 (dist=5, range=5)
1144
+ fn test_in_range(): int { return parabola_in_range(3, 4, 5); }
1145
+
1146
+ // parabola_in_range(3, 4, 4) = 0 (dist=5 > 4)
1147
+ fn test_out_of_range(): int { return parabola_in_range(3, 4, 4); }
1148
+
1149
+ // drag step: step_vx(10000, 9900) = mulfix(10000, 9900) = 10000*9900/1000 = 99000...
1150
+ // mulfix is ×1000 scale: mulfix(a,b) = a*b/1000
1151
+ // 10000 * 9900 / 1000 = 99000
1152
+ fn test_drag_vx(): int { return parabola_step_vx(10000, 9900); }
1153
+
1154
+ // step_vy(10000, 9900) = mulfix(10000 - 800, 9900) = 9200 * 9900 / 1000 = 91080
1155
+ fn test_drag_vy(): int { return parabola_step_vy(10000, 9900); }
1156
+
1157
+ // gravity constant
1158
+ fn test_gravity(): int { return parabola_gravity(); }
1159
+
1160
+ // ticks_for_range(8) = 8*10000/8000 = 10
1161
+ fn test_ticks_range(): int { return parabola_ticks_for_range(8); }
1162
+ `, [MATH_SRC, PARABOLA_SRC])
1163
+
1164
+ test('parabola_gravity() == 800', () => expect(callAndGetRet(rt, 'test_gravity')).toBe(800))
1165
+ test('parabola_vx(10, 20) == 5000', () => expect(callAndGetRet(rt, 'test_vx')).toBe(5000))
1166
+ test('parabola_vz(0, 20) == 0', () => expect(callAndGetRet(rt, 'test_vz_zero')).toBe(0))
1167
+ test('parabola_vy(0, 20) == 0 (flat shot integer floor)', () => expect(callAndGetRet(rt, 'test_vy_flat')).toBe(0))
1168
+ test('parabola_vy(10, 20) == 5000 (arc up 10 blocks)', () => expect(callAndGetRet(rt, 'test_vy_up')).toBe(5000))
1169
+ test('parabola_x(5000, 20) == 10 (0.5 b/t × 20t)', () => expect(callAndGetRet(rt, 'test_x_at_t')).toBe(10))
1170
+ test('parabola_y(5000, 20) == -6 (landed below launch)', () => expect(callAndGetRet(rt, 'test_y_at_t')).toBe(-6))
1171
+ test('parabola_flight_time(8000) == 20 ticks', () => expect(callAndGetRet(rt, 'test_flight_time')).toBe(20))
1172
+ test('parabola_max_height(8000) == 4 blocks', () => expect(callAndGetRet(rt, 'test_max_height')).toBe(4))
1173
+ test('parabola_in_range(3,4,5) == 1 (on boundary)', () => expect(callAndGetRet(rt, 'test_in_range')).toBe(1))
1174
+ test('parabola_in_range(3,4,4) == 0 (out of range)', () => expect(callAndGetRet(rt, 'test_out_of_range')).toBe(0))
1175
+ test('parabola_step_vx(10000, 9900) == 99000 (drag)', () => expect(callAndGetRet(rt, 'test_drag_vx')).toBe(99000))
1176
+ test('parabola_step_vy(10000, 9900) == 91080 (gravity+drag)', () => expect(callAndGetRet(rt, 'test_drag_vy')).toBe(91080))
1177
+ test('parabola_ticks_for_range(8) == 10', () => expect(callAndGetRet(rt, 'test_ticks_range')).toBe(10))
1178
+ })
1179
+
1180
+ // ===========================================================================
1181
+ // quaternion.mcrs — runtime
1182
+ // ===========================================================================
1183
+
1184
+ describe('quaternion.mcrs — rotation math', () => {
1185
+ // Note: sin_fixed/cos_fixed use NBT lookup tables unavailable in MCRuntime.
1186
+ // Tests use pre-computed values directly instead of axis constructor functions.
1187
+ // quat components ×10000: identity=(0,0,0,10000), 90°Y=(0,7071,0,7071)
1188
+ const rt = makeRuntime(`
1189
+ // Identity quaternion constants
1190
+ fn test_identity_w(): int { return quat_identity_w(); }
1191
+ fn test_identity_x(): int { return quat_identity_x(); }
1192
+
1193
+ // Quaternion multiplication: identity * identity = identity
1194
+ fn test_mul_identity_w(): int {
1195
+ return quat_mul_w(0, 0, 0, 10000, 0, 0, 0, 10000);
1196
+ }
1197
+ fn test_mul_identity_x(): int {
1198
+ return quat_mul_x(0, 0, 0, 10000, 0, 0, 0, 10000);
1199
+ }
1200
+
1201
+ // q * q_inv = identity: q=(0,7071,0,7071), conj=(0,-7071,0,7071)
1202
+ fn test_mul_q_conj_w(): int {
1203
+ return quat_mul_w(0, 7071, 0, 7071, 0, -7071, 0, 7071);
1204
+ }
1205
+
1206
+ // Conjugate
1207
+ fn test_conj_w(): int { return quat_conj_w(0, 0, 0, 10000); }
1208
+ fn test_conj_x(): int { return quat_conj_x(7071, 0, 0, 7071); }
1209
+
1210
+ // Magnitude squared of identity: mulfix(10000,10000) = 10000*10000/1000 = 100000
1211
+ fn test_mag_sq_identity(): int { return quat_mag_sq(0, 0, 0, 10000); }
1212
+
1213
+ // Magnitude squared of precomputed 90°Y: (0, 7071, 0, 7071)
1214
+ // mulfix(7071,7071)*2 = 7071*7071/1000 * 2 = 49998 * 2 = 99996
1215
+ fn test_mag_sq_rot(): int { return quat_mag_sq(0, 7071, 0, 7071); }
1216
+
1217
+ // Dot product of identity with itself: mulfix(10000,10000) = 100000
1218
+ fn test_dot_identity(): int {
1219
+ return quat_dot(0, 0, 0, 10000, 0, 0, 0, 10000);
1220
+ }
1221
+
1222
+ // Dot of two identical 90°Y quats
1223
+ fn test_dot_same(): int {
1224
+ return quat_dot(0, 7071, 0, 7071, 0, 7071, 0, 7071);
1225
+ }
1226
+
1227
+ // SLERP: lerp between identity and 90°Y at t=0 → identity
1228
+ fn test_slerp_t0_w(): int {
1229
+ return quat_slerp_w(0, 0, 0, 10000, 0, 7071, 0, 7071, 0);
1230
+ }
1231
+ fn test_slerp_t0_y(): int {
1232
+ return quat_slerp_y(0, 0, 0, 10000, 0, 7071, 0, 7071, 0);
1233
+ }
1234
+ // SLERP at t=1000 → second quat (normalized)
1235
+ fn test_slerp_t1000_y(): int {
1236
+ return quat_slerp_y(0, 0, 0, 10000, 0, 7071, 0, 7071, 1000);
1237
+ }
1238
+ fn test_slerp_t1000_w(): int {
1239
+ return quat_slerp_w(0, 0, 0, 10000, 0, 7071, 0, 7071, 1000);
1240
+ }
1241
+ // SLERP midpoint t=500: lerp(identity, 90°Y) → normalize([0, 3535, 0, 13535])
1242
+ fn test_slerp_t500_y(): int {
1243
+ return quat_slerp_y(0, 0, 0, 10000, 0, 7071, 0, 7071, 500);
1244
+ }
1245
+ `, [MATH_SRC, QUAT_SRC])
1246
+
1247
+ test('quat_identity_w() == 10000', () => expect(callAndGetRet(rt, 'test_identity_w')).toBe(10000))
1248
+ test('quat_identity_x() == 0', () => expect(callAndGetRet(rt, 'test_identity_x')).toBe(0))
1249
+ test('quat_mul(identity, identity).w == 100000 (×10000 scale)', () => expect(callAndGetRet(rt, 'test_mul_identity_w')).toBe(100000))
1250
+ test('quat_mul(identity, identity).x == 0', () => expect(callAndGetRet(rt, 'test_mul_identity_x')).toBe(0))
1251
+ test('quat_mul(q, conj(q)).w ≈ 100000 (≈ identity)', () => {
1252
+ const v = callAndGetRet(rt, 'test_mul_q_conj_w')
1253
+ expect(Math.abs(v - 100000)).toBeLessThanOrEqual(200)
1254
+ })
1255
+ test('quat_conj(identity).w == 10000', () => expect(callAndGetRet(rt, 'test_conj_w')).toBe(10000))
1256
+ test('quat_conj([7071,0,0,7071]).x == -7071', () => expect(callAndGetRet(rt, 'test_conj_x')).toBe(-7071))
1257
+ test('quat_mag_sq(identity) == 100000 (mulfix scale)', () => expect(callAndGetRet(rt, 'test_mag_sq_identity')).toBe(100000))
1258
+ test('quat_mag_sq([0,7071,0,7071]) ≈ 99996 (near unit)', () => {
1259
+ const v = callAndGetRet(rt, 'test_mag_sq_rot')
1260
+ expect(Math.abs(v - 100000)).toBeLessThanOrEqual(10)
1261
+ })
1262
+ test('quat_dot(identity, identity) == 100000', () => expect(callAndGetRet(rt, 'test_dot_identity')).toBe(100000))
1263
+ test('quat_dot(q, q) ≈ 99996 (near unit)', () => {
1264
+ const v = callAndGetRet(rt, 'test_dot_same')
1265
+ expect(Math.abs(v - 100000)).toBeLessThanOrEqual(10)
1266
+ })
1267
+ test('quat_slerp(a,b,0).w == 10000 (= a)', () => expect(callAndGetRet(rt, 'test_slerp_t0_w')).toBe(10000))
1268
+ test('quat_slerp(a,b,0).y == 0 (= a)', () => expect(callAndGetRet(rt, 'test_slerp_t0_y')).toBe(0))
1269
+ test('quat_slerp(a,b,1000).y ≈ 7071 (= b normalized)', () => {
1270
+ const v = callAndGetRet(rt, 'test_slerp_t1000_y')
1271
+ expect(Math.abs(v - 7071)).toBeLessThanOrEqual(20)
1272
+ })
1273
+ test('quat_slerp(a,b,1000).w ≈ 7071 (= b normalized)', () => {
1274
+ const v = callAndGetRet(rt, 'test_slerp_t1000_w')
1275
+ expect(Math.abs(v - 7071)).toBeLessThanOrEqual(20)
1276
+ })
1277
+ test('quat_slerp(a,b,500).y > 0 (moving toward b)', () => {
1278
+ const v = callAndGetRet(rt, 'test_slerp_t500_y')
1279
+ expect(v).toBeGreaterThan(0)
1280
+ expect(v).toBeLessThan(7071)
1281
+ })
1282
+ })
1283
+
1284
+ // bezier_quartic and bezier_n — N-order Bezier curves
1285
+ describe('advanced.mcrs — bezier_quartic & bezier_n', () => {
1286
+ const rt = makeRuntime(`
1287
+ fn test_quartic_start(): int { return bezier_quartic(0, 250, 500, 750, 1000, 0); }
1288
+ fn test_quartic_end(): int { return bezier_quartic(0, 250, 500, 750, 1000, 1000); }
1289
+ fn test_quartic_mid(): int { return bezier_quartic(0, 250, 500, 750, 1000, 500); }
1290
+
1291
+ fn test_bezier_n_start(): int {
1292
+ let pts: int[] = [0, 333, 667, 1000];
1293
+ return bezier_n(pts, 4, 0);
1294
+ }
1295
+ fn test_bezier_n_end(): int {
1296
+ let pts: int[] = [0, 333, 667, 1000];
1297
+ return bezier_n(pts, 4, 1000);
1298
+ }
1299
+ `, [MATH_SRC, ADVANCED_SRC, BIGINT_SRC])
1300
+
1301
+ // bezier_quartic
1302
+ test('bezier_quartic(0,250,500,750,1000, t=0) == 0 (start)', () => expect(callAndGetRet(rt, 'test_quartic_start')).toBe(0))
1303
+ test('bezier_quartic(0,250,500,750,1000, t=1000) == 1000 (end)', () => expect(callAndGetRet(rt, 'test_quartic_end')).toBe(1000))
1304
+ test('bezier_quartic(0,250,500,750,1000, t=500) == 500 (uniform midpoint)', () => expect(callAndGetRet(rt, 'test_quartic_mid')).toBe(500))
1305
+
1306
+ // bezier_n
1307
+ test('bezier_n([0,333,667,1000], 4, t=0) == 0 (start = pts[0])', () => expect(callAndGetRet(rt, 'test_bezier_n_start')).toBe(0))
1308
+ test('bezier_n([0,333,667,1000], 4, t=1000) == 1000 (end = pts[n-1])', () => expect(callAndGetRet(rt, 'test_bezier_n_end')).toBe(1000))
1309
+ })
1310
+
1311
+ // ===========================================================================
1312
+ // math_hp.mcrs — ln_hp (Newton-refined high-precision natural log)
1313
+ // ===========================================================================
1314
+
1315
+ describe('math_hp.mcrs — ln_hp', () => {
1316
+ const rt = makeRuntime(`
1317
+ fn test_ln_hp_one(): int { return ln_hp(10000); }
1318
+ fn test_ln_hp_e(): int { return ln_hp(27183); }
1319
+ fn test_ln_hp_2(): int { return ln_hp(20000); }
1320
+ fn test_ln_hp_10(): int { return ln_hp(100000); }
1321
+ fn test_ln_hp_vs_ln_e(): int {
1322
+ // Compare ln_hp(e) and ln(e): ln_hp should be closer to 10000
1323
+ let a: int = ln_hp(27183);
1324
+ let b: int = ln(27183);
1325
+ let da: int = a - 10000;
1326
+ if (da < 0) { da = 0 - da; }
1327
+ let db: int = b - 10000;
1328
+ if (db < 0) { db = 0 - db; }
1329
+ // Return 1 if ln_hp is at least as precise as ln, 0 otherwise
1330
+ if (da <= db) { return 1; }
1331
+ return 0;
1332
+ }
1333
+ `, [MATH_SRC, MATH_HP_SRC])
1334
+
1335
+ test('ln_hp(10000) == 0 (ln(1.0) = 0)', () => expect(callAndGetRet(rt, 'test_ln_hp_one')).toBe(0))
1336
+ test('ln_hp(27183) ≈ 10000 (ln(e) ≈ 1.0)', () => {
1337
+ const v = callAndGetRet(rt, 'test_ln_hp_e')
1338
+ expect(Math.abs(v - 10000)).toBeLessThanOrEqual(5)
1339
+ })
1340
+ test('ln_hp(20000) ≈ 6931 (ln(2) ≈ 0.6931)', () => {
1341
+ const v = callAndGetRet(rt, 'test_ln_hp_2')
1342
+ expect(Math.abs(v - 6931)).toBeLessThanOrEqual(5)
1343
+ })
1344
+ test('ln_hp(100000) ≈ 23026 (ln(10) ≈ 2.3026)', () => {
1345
+ const v = callAndGetRet(rt, 'test_ln_hp_10')
1346
+ expect(Math.abs(v - 23026)).toBeLessThanOrEqual(10)
1347
+ })
1348
+ test('ln_hp is at least as precise as ln for ln(e)', () => {
1349
+ expect(callAndGetRet(rt, 'test_ln_hp_vs_ln_e')).toBe(1)
1350
+ })
1351
+ })
1352
+
1353
+ // ===========================================================================
1354
+ // expr.mcrs — RPN expression evaluator
1355
+ // ===========================================================================
1356
+
1357
+ describe('expr.mcrs — expr_eval', () => {
1358
+ const rt = makeRuntime(`
1359
+ // constant 1.0: tokens = [10000], n=1, x=0
1360
+ fn test_expr_constant(): int {
1361
+ let toks: int[] = [10000];
1362
+ return expr_eval(toks, 1, 0);
1363
+ }
1364
+ // identity f(x)=x: tokens = [-10000], n=1, x=20000
1365
+ fn test_expr_identity(): int {
1366
+ let toks: int[] = [0 - 10000];
1367
+ return expr_eval(toks, 1, 20000);
1368
+ }
1369
+ // 2*x + 1 at x=1.5: tokens = [20000, -10000, -3, 10000, -1], n=5, x=15000
1370
+ // Expected: 20000*15000/10000 + 10000 = 30000 + 10000 = 40000
1371
+ // Use element-by-element assignment to avoid compiler bug with mixed-sign arrays
1372
+ fn test_expr_linear(): int {
1373
+ let toks: int[] = [0, 0, 0, 0, 0];
1374
+ toks[0] = 20000;
1375
+ toks[1] = 0 - 10000;
1376
+ toks[2] = 0 - 3;
1377
+ toks[3] = 10000;
1378
+ toks[4] = 0 - 1;
1379
+ return expr_eval(toks, 5, 15000);
1380
+ }
1381
+ // subtraction: 3.0 - 1.0 = 2.0: tokens = [30000, 10000, -2], n=3, x=0
1382
+ fn test_expr_sub(): int {
1383
+ let toks: int[] = [0, 0, 0];
1384
+ toks[0] = 30000;
1385
+ toks[1] = 10000;
1386
+ toks[2] = 0 - 2;
1387
+ return expr_eval(toks, 3, 0);
1388
+ }
1389
+ // division: 10.0 / 4.0 = 2.5: tokens = [100000, 40000, -4], n=3, x=0
1390
+ fn test_expr_div(): int {
1391
+ let toks: int[] = [0, 0, 0];
1392
+ toks[0] = 100000;
1393
+ toks[1] = 40000;
1394
+ toks[2] = 0 - 4;
1395
+ return expr_eval(toks, 3, 0);
1396
+ }
1397
+ // abs(-3.0) = 3.0: tokens = [-30000, -8], n=2, x=0
1398
+ // -30000 is not a recognized opcode so it falls through to the literal branch
1399
+ fn test_expr_abs(): int {
1400
+ let toks: int[] = [0, 0];
1401
+ toks[0] = 0 - 30000;
1402
+ toks[1] = 0 - 8;
1403
+ return expr_eval(toks, 2, 0);
1404
+ }
1405
+ // sqrt(4.0) = 2.0: tokens = [40000, -7], n=2, x=0
1406
+ fn test_expr_sqrt(): int {
1407
+ let toks: int[] = [0, 0];
1408
+ toks[0] = 40000;
1409
+ toks[1] = 0 - 7;
1410
+ return expr_eval(toks, 2, 0);
1411
+ }
1412
+ `, [MATH_SRC, EXPR_SRC])
1413
+
1414
+ test('expr_eval([10000], 1, 0) == 10000 (constant 1.0)', () => {
1415
+ expect(callAndGetRet(rt, 'test_expr_constant')).toBe(10000)
1416
+ })
1417
+ test('expr_eval([-10000], 1, 20000) == 20000 (identity f(x)=x at x=2.0)', () => {
1418
+ expect(callAndGetRet(rt, 'test_expr_identity')).toBe(20000)
1419
+ })
1420
+ test('expr_eval([20000,-10000,-3,10000,-1], 5, 15000) == 40000 (2*x+1 at x=1.5)', () => {
1421
+ expect(callAndGetRet(rt, 'test_expr_linear')).toBe(40000)
1422
+ })
1423
+ test('expr_eval([30000,10000,-2], 3, 0) == 20000 (3.0 - 1.0 = 2.0)', () => {
1424
+ expect(callAndGetRet(rt, 'test_expr_sub')).toBe(20000)
1425
+ })
1426
+ test('expr_eval([100000,40000,-4], 3, 0) == 25000 (10.0 / 4.0 = 2.5)', () => {
1427
+ expect(callAndGetRet(rt, 'test_expr_div')).toBe(25000)
1428
+ })
1429
+ test('expr_eval([-30000,-8], 2, 0) == 30000 (abs(-3.0) = 3.0)', () => {
1430
+ expect(callAndGetRet(rt, 'test_expr_abs')).toBe(30000)
1431
+ })
1432
+ test('expr_eval([40000,-7], 2, 0) == 20000 (sqrt(4.0) = 2.0)', () => {
1433
+ expect(callAndGetRet(rt, 'test_expr_sqrt')).toBe(20000)
1434
+ })
1435
+ })
1436
+
1437
+ // ===========================================================================
1438
+ // geometry.mcrs — selector helpers (cylinder / cone / sector_2d)
1439
+ // ===========================================================================
1440
+
1441
+ describe('geometry.mcrs — in_cylinder', () => {
1442
+ const rt = makeRuntime(`
1443
+ fn test_cyl_inside(): int {
1444
+ return in_cylinder(0, 0, 0, 0, 0, 20000, 0, 10000);
1445
+ }
1446
+ fn test_cyl_outside_r(): int {
1447
+ return in_cylinder(30000, 0, 0, 0, 0, 20000, 0, 10000);
1448
+ }
1449
+ fn test_cyl_outside_y(): int {
1450
+ return in_cylinder(0, 20000, 0, 0, 0, 20000, 0, 10000);
1451
+ }
1452
+ `, [MATH_SRC, VEC_SRC, GEOM_SRC])
1453
+
1454
+ test('in_cylinder(0,0,0, 0,0, 20000, 0,10000) == 1 (inside)', () =>
1455
+ expect(callAndGetRet(rt, 'test_cyl_inside')).toBe(1))
1456
+
1457
+ test('in_cylinder(30000,0,0, 0,0, 20000, 0,10000) == 0 (outside radius)', () =>
1458
+ expect(callAndGetRet(rt, 'test_cyl_outside_r')).toBe(0))
1459
+
1460
+ test('in_cylinder(0,20000,0, 0,0, 20000, 0,10000) == 0 (outside y range)', () =>
1461
+ expect(callAndGetRet(rt, 'test_cyl_outside_y')).toBe(0))
1462
+ })
1463
+
1464
+ describe('geometry.mcrs — in_cone', () => {
1465
+ // dir_y=1 → upward cone; half_angle_tan=10000 (tan 45°=1.0); height=20000
1466
+ // test point directly above apex: dy=10000, horiz=0 → inside
1467
+ const rt = makeRuntime(`
1468
+ fn test_cone_above(): int {
1469
+ return in_cone(0, 10000, 0, 0, 0, 0, 1, 10000, 20000);
1470
+ }
1471
+ `, [MATH_SRC, VEC_SRC, GEOM_SRC])
1472
+
1473
+ test('in_cone(0,10000,0, 0,0,0, 1, 10000, 20000) == 1 (directly above apex)', () =>
1474
+ expect(callAndGetRet(rt, 'test_cone_above')).toBe(1))
1475
+ })
1476
+
1477
+ describe('geometry.mcrs — in_sector_2d', () => {
1478
+ // dir_angle=0 (+X axis), half_angle≈π/4 (157079), radius=20000
1479
+ // point (10000,0) is at angle 0 → inside
1480
+ // point (-10000,0) is at angle π → outside
1481
+ const rt = makeRuntime(`
1482
+ fn test_sector_front(): int {
1483
+ return in_sector_2d(10000, 0, 0, 0, 0, 157079, 20000);
1484
+ }
1485
+ fn test_sector_behind(): int {
1486
+ return in_sector_2d(-10000, 0, 0, 0, 0, 157079, 20000);
1487
+ }
1488
+ `, [MATH_SRC, VEC_SRC, GEOM_SRC])
1489
+
1490
+ test('in_sector_2d(10000,0, 0,0, 0, 157079, 20000) == 1 (in front, half_angle=π/4)', () =>
1491
+ expect(callAndGetRet(rt, 'test_sector_front')).toBe(1))
1492
+
1493
+ test('in_sector_2d(-10000,0, 0,0, 0, 157079, 20000) == 0 (behind)', () =>
1494
+ expect(callAndGetRet(rt, 'test_sector_behind')).toBe(0))
1495
+ })
1496
+
1497
+ // ===========================================================================
1498
+ // color.mcrs — RGB↔HSL conversion
1499
+ // ===========================================================================
1500
+
1501
+ describe('color.mcrs — rgb_to_l', () => {
1502
+ const rt = makeRuntime(`
1503
+ fn test_l_white(): int { return rgb_to_l(2550000, 2550000, 2550000); }
1504
+ fn test_l_black(): int { return rgb_to_l(0, 0, 0); }
1505
+ `, [COLOR_SRC])
1506
+
1507
+ test('rgb_to_l(2550000, 2550000, 2550000) == 10000 (white L=1.0)', () =>
1508
+ expect(callAndGetRet(rt, 'test_l_white')).toBe(10000))
1509
+
1510
+ test('rgb_to_l(0, 0, 0) == 0 (black L=0)', () =>
1511
+ expect(callAndGetRet(rt, 'test_l_black')).toBe(0))
1512
+ })
1513
+
1514
+ describe('color.mcrs — rgb_to_s', () => {
1515
+ const rt = makeRuntime(`
1516
+ fn test_s_red(): int { return rgb_to_s(2550000, 0, 0); }
1517
+ `, [COLOR_SRC])
1518
+
1519
+ test('rgb_to_s(2550000, 0, 0) > 0 (pure red S > 0)', () =>
1520
+ expect(callAndGetRet(rt, 'test_s_red')).toBeGreaterThan(0))
1521
+ })
1522
+
1523
+ describe('color.mcrs — hsl_to_r', () => {
1524
+ const rt = makeRuntime(`
1525
+ fn test_hsl_r_red(): int { return hsl_to_r(0, 10000, 5000); }
1526
+ `, [COLOR_SRC])
1527
+
1528
+ test('hsl_to_r(0, 10000, 5000) close to 2550000 (red hue)', () =>
1529
+ expect(callAndGetRet(rt, 'test_hsl_r_red')).toBeGreaterThan(2500000))
1530
+ })
1531
+
1532
+ // ===========================================================================
1533
+ // world.mcrs — sun angle helpers
1534
+ // ===========================================================================
1535
+
1536
+ describe('world.mcrs — sun_altitude', () => {
1537
+ // sun_altitude uses sin_fixed which requires storage_get_int — not available
1538
+ // in MCRuntime, so we test sun_azimuth only (pure arithmetic).
1539
+ const rt = makeRuntime(`
1540
+ fn test_azimuth_0(): int { return sun_azimuth(0); }
1541
+ fn test_azimuth_noon(): int { return sun_azimuth(6000); }
1542
+ `, [WORLD_SRC, MATH_SRC])
1543
+
1544
+ test('sun_azimuth(0) == 0', () =>
1545
+ expect(callAndGetRet(rt, 'test_azimuth_0')).toBe(0))
1546
+
1547
+ test('sun_azimuth(6000) == 900000 (quarter day = 90°)', () =>
1548
+ expect(callAndGetRet(rt, 'test_azimuth_noon')).toBe(900000))
1549
+ })
1550
+
1551
+ // ===========================================================================
1552
+ // ADDITIONAL COMPREHENSIVE TESTS — geometry / expr / DFT / color / world
1553
+ // ===========================================================================
1554
+
1555
+ // ---------------------------------------------------------------------------
1556
+ // geometry.mcrs — in_cylinder (extended)
1557
+ // ---------------------------------------------------------------------------
1558
+
1559
+ describe('geometry.mcrs — in_cylinder (extended)', () => {
1560
+ const rt = makeRuntime(`
1561
+ // Point exactly on boundary radius (dx=radius → dx²+dz²=r² → inside)
1562
+ fn test_cyl_boundary(): int {
1563
+ return in_cylinder(20000, 5000, 0, 0, 0, 20000, 0, 10000);
1564
+ }
1565
+ // Point at centre (0,0,0) with y in range → definitely inside
1566
+ fn test_cyl_center(): int {
1567
+ return in_cylinder(0, 5000, 0, 0, 0, 10000, 0, 10000);
1568
+ }
1569
+ // Negative coordinates — point at (-5000, 5000, -5000), centre at (-5000, 0, -5000), r=1000
1570
+ fn test_cyl_neg_coords(): int {
1571
+ return in_cylinder(0 - 5000, 5000, 0 - 5000, 0 - 5000, 0 - 5000, 1000, 0, 10000);
1572
+ }
1573
+ // y exactly at lower boundary y_lo → inside (boundary inclusive)
1574
+ fn test_cyl_y_at_lo(): int {
1575
+ return in_cylinder(0, 0, 0, 0, 0, 10000, 0, 10000);
1576
+ }
1577
+ // y exactly at upper boundary y_hi → inside (boundary inclusive)
1578
+ fn test_cyl_y_at_hi(): int {
1579
+ return in_cylinder(0, 10000, 0, 0, 0, 10000, 0, 10000);
1580
+ }
1581
+ // y just below lower boundary → outside
1582
+ fn test_cyl_y_below_lo(): int {
1583
+ return in_cylinder(0, 0 - 1, 0, 0, 0, 10000, 0, 10000);
1584
+ }
1585
+ // Point offset from non-zero centre
1586
+ fn test_cyl_offset_centre(): int {
1587
+ return in_cylinder(15000, 5000, 15000, 10000, 10000, 10000, 0, 10000);
1588
+ }
1589
+ `, [MATH_SRC, VEC_SRC, GEOM_SRC])
1590
+
1591
+ test('in_cylinder: point on exact radius boundary == 1', () =>
1592
+ expect(callAndGetRet(rt, 'test_cyl_boundary')).toBe(1))
1593
+
1594
+ test('in_cylinder: point at centre == 1', () =>
1595
+ expect(callAndGetRet(rt, 'test_cyl_center')).toBe(1))
1596
+
1597
+ test('in_cylinder: negative coordinates, point at centre == 1', () =>
1598
+ expect(callAndGetRet(rt, 'test_cyl_neg_coords')).toBe(1))
1599
+
1600
+ test('in_cylinder: y at lower boundary == 1 (inclusive)', () =>
1601
+ expect(callAndGetRet(rt, 'test_cyl_y_at_lo')).toBe(1))
1602
+
1603
+ test('in_cylinder: y at upper boundary == 1 (inclusive)', () =>
1604
+ expect(callAndGetRet(rt, 'test_cyl_y_at_hi')).toBe(1))
1605
+
1606
+ test('in_cylinder: y just below lower boundary == 0', () =>
1607
+ expect(callAndGetRet(rt, 'test_cyl_y_below_lo')).toBe(0))
1608
+
1609
+ test('in_cylinder: point inside shifted cylinder == 1', () =>
1610
+ expect(callAndGetRet(rt, 'test_cyl_offset_centre')).toBe(1))
1611
+ })
1612
+
1613
+ // ---------------------------------------------------------------------------
1614
+ // geometry.mcrs — in_cone (extended)
1615
+ // ---------------------------------------------------------------------------
1616
+
1617
+ describe('geometry.mcrs — in_cone (extended)', () => {
1618
+ const rt = makeRuntime(`
1619
+ // Point at apex itself: dy=0 → lhs=0, rhs=0 → 0<=0 → inside
1620
+ fn test_cone_apex(): int {
1621
+ return in_cone(0, 0, 0, 0, 0, 0, 1, 10000, 20000);
1622
+ }
1623
+ // Point outside height (dy > height) → outside
1624
+ fn test_cone_above_height(): int {
1625
+ return in_cone(0, 30000, 0, 0, 0, 0, 1, 10000, 20000);
1626
+ }
1627
+ // Point at exactly height on axis → inside (dy=height, horiz=0)
1628
+ fn test_cone_at_height(): int {
1629
+ return in_cone(0, 20000, 0, 0, 0, 0, 1, 10000, 20000);
1630
+ }
1631
+ // Wide angle (tan=20000 → 63°), point at (10000,10000,0): lhs=100000000, rhs=dy*20000/10000=20000 → rhs²=400000000 ≥ lhs → inside
1632
+ fn test_cone_wide_angle(): int {
1633
+ return in_cone(10000, 10000, 0, 0, 0, 0, 1, 20000, 20000);
1634
+ }
1635
+ // Downward cone (dir_y=-1): point below apex
1636
+ fn test_cone_downward(): int {
1637
+ return in_cone(0, 0 - 5000, 0, 0, 0, 0, 0 - 1, 10000, 20000);
1638
+ }
1639
+ // Narrow angle (tan=5000 → 27°), point just outside: dx=10000,dy=10000 → lhs=100000000, rhs=5000 → rhs²=25000000 < lhs → outside
1640
+ fn test_cone_narrow_outside(): int {
1641
+ return in_cone(10000, 10000, 0, 0, 0, 0, 1, 5000, 20000);
1642
+ }
1643
+ `, [MATH_SRC, VEC_SRC, GEOM_SRC])
1644
+
1645
+ test('in_cone: point at apex == 1', () =>
1646
+ expect(callAndGetRet(rt, 'test_cone_apex')).toBe(1))
1647
+
1648
+ test('in_cone: point above height == 0', () =>
1649
+ expect(callAndGetRet(rt, 'test_cone_above_height')).toBe(0))
1650
+
1651
+ test('in_cone: point at exactly height on axis == 1', () =>
1652
+ expect(callAndGetRet(rt, 'test_cone_at_height')).toBe(1))
1653
+
1654
+ test('in_cone: wide angle (45°), point inside == 1', () =>
1655
+ expect(callAndGetRet(rt, 'test_cone_wide_angle')).toBe(1))
1656
+
1657
+ test('in_cone: downward cone, point below apex == 1', () =>
1658
+ expect(callAndGetRet(rt, 'test_cone_downward')).toBe(1))
1659
+
1660
+ test('in_cone: narrow angle, point outside == 0', () =>
1661
+ expect(callAndGetRet(rt, 'test_cone_narrow_outside')).toBe(0))
1662
+ })
1663
+
1664
+ // ---------------------------------------------------------------------------
1665
+ // geometry.mcrs — in_sector_2d (extended)
1666
+ // ---------------------------------------------------------------------------
1667
+
1668
+ describe('geometry.mcrs — in_sector_2d (extended)', () => {
1669
+ const rt = makeRuntime(`
1670
+ // Point at origin (cx,cz) → should be inside (zero distance)
1671
+ fn test_sector_at_origin(): int {
1672
+ return in_sector_2d(0, 0, 0, 0, 0, 157079, 20000);
1673
+ }
1674
+ // Point at exact radius boundary (still inside, <=)
1675
+ fn test_sector_radius_boundary(): int {
1676
+ return in_sector_2d(20000, 0, 0, 0, 0, 157079, 20000);
1677
+ }
1678
+ // Point just outside radius → outside
1679
+ fn test_sector_outside_radius(): int {
1680
+ return in_sector_2d(21000, 0, 0, 0, 0, 157079, 20000);
1681
+ }
1682
+ // dir_angle = π/2 (157079), point at (0, 10000): angle=90° → inside
1683
+ fn test_sector_dir_90(): int {
1684
+ return in_sector_2d(0, 10000, 0, 0, 157079, 78540, 20000);
1685
+ }
1686
+ // dir_angle = 0, half_angle = full circle (314159≈π): point at (-10000,0) should be inside
1687
+ fn test_sector_full_half(): int {
1688
+ return in_sector_2d(0 - 10000, 0, 0, 0, 0, 314159, 20000);
1689
+ }
1690
+ // Point at 45° angle, dir at 0°, half_angle = π/6 (~52360) — 45° outside half_angle
1691
+ fn test_sector_45_narrow(): int {
1692
+ return in_sector_2d(10000, 10000, 0, 0, 0, 52360, 20000);
1693
+ }
1694
+ `, [MATH_SRC, VEC_SRC, GEOM_SRC])
1695
+
1696
+ test('in_sector_2d: point at origin == 1 (always inside)', () =>
1697
+ expect(callAndGetRet(rt, 'test_sector_at_origin')).toBe(1))
1698
+
1699
+ test('in_sector_2d: point at exact radius == 1 (boundary inclusive)', () =>
1700
+ expect(callAndGetRet(rt, 'test_sector_radius_boundary')).toBe(1))
1701
+
1702
+ test('in_sector_2d: point just beyond radius == 0', () =>
1703
+ expect(callAndGetRet(rt, 'test_sector_outside_radius')).toBe(0))
1704
+
1705
+ test('in_sector_2d: dir=π/2, point at 90° == 1', () =>
1706
+ expect(callAndGetRet(rt, 'test_sector_dir_90')).toBe(1))
1707
+
1708
+ test('in_sector_2d: half_angle=π (semicircle), point behind == 1', () =>
1709
+ expect(callAndGetRet(rt, 'test_sector_full_half')).toBe(1))
1710
+
1711
+ test('in_sector_2d: 45° point, narrow half_angle=30° == 0', () =>
1712
+ expect(callAndGetRet(rt, 'test_sector_45_narrow')).toBe(0))
1713
+ })
1714
+
1715
+ // ---------------------------------------------------------------------------
1716
+ // expr.mcrs — expr_eval (extended)
1717
+ // ---------------------------------------------------------------------------
1718
+
1719
+ describe('expr.mcrs — expr_eval (extended)', () => {
1720
+ const rt = makeRuntime(`
1721
+ // 2*x+1 at x=0 → 0+10000=10000
1722
+ fn test_expr_linear_x0(): int {
1723
+ let toks: int[] = [0, 0, 0, 0, 0];
1724
+ toks[0] = 20000;
1725
+ toks[1] = 0 - 10000;
1726
+ toks[2] = 0 - 3;
1727
+ toks[3] = 10000;
1728
+ toks[4] = 0 - 1;
1729
+ return expr_eval(toks, 5, 0);
1730
+ }
1731
+ // 2*x+1 at x=10000 (1.0) → 20000+10000=30000
1732
+ fn test_expr_linear_x1(): int {
1733
+ let toks: int[] = [0, 0, 0, 0, 0];
1734
+ toks[0] = 20000;
1735
+ toks[1] = 0 - 10000;
1736
+ toks[2] = 0 - 3;
1737
+ toks[3] = 10000;
1738
+ toks[4] = 0 - 1;
1739
+ return expr_eval(toks, 5, 10000);
1740
+ }
1741
+ // 2*x+1 at x=20000 (2.0) → 40000+10000=50000
1742
+ fn test_expr_linear_x2(): int {
1743
+ let toks: int[] = [0, 0, 0, 0, 0];
1744
+ toks[0] = 20000;
1745
+ toks[1] = 0 - 10000;
1746
+ toks[2] = 0 - 3;
1747
+ toks[3] = 10000;
1748
+ toks[4] = 0 - 1;
1749
+ return expr_eval(toks, 5, 20000);
1750
+ }
1751
+ // (x+1)*x at x=20000 (2.0): RPN = [x, 10000, +, x, *] → (2+1)*2=6.0=60000
1752
+ fn test_expr_chain(): int {
1753
+ let toks: int[] = [0, 0, 0, 0, 0];
1754
+ toks[0] = 0 - 10000;
1755
+ toks[1] = 10000;
1756
+ toks[2] = 0 - 1;
1757
+ toks[3] = 0 - 10000;
1758
+ toks[4] = 0 - 3;
1759
+ return expr_eval(toks, 5, 20000);
1760
+ }
1761
+ // n=0: return 0 (empty stack)
1762
+ fn test_expr_n0(): int {
1763
+ let toks: int[] = [10000];
1764
+ return expr_eval(toks, 0, 0);
1765
+ }
1766
+ // Single literal: 42.0 = 420000
1767
+ fn test_expr_literal42(): int {
1768
+ let toks: int[] = [420000];
1769
+ return expr_eval(toks, 1, 0);
1770
+ }
1771
+ // x passthrough: tokens=[-10000], n=1, x=30000 → 30000
1772
+ fn test_expr_x_passthrough(): int {
1773
+ let toks: int[] = [0 - 10000];
1774
+ return expr_eval(toks, 1, 30000);
1775
+ }
1776
+ `, [MATH_SRC, EXPR_SRC])
1777
+
1778
+ test('expr_eval: 2*x+1 at x=0 == 10000', () =>
1779
+ expect(callAndGetRet(rt, 'test_expr_linear_x0')).toBe(10000))
1780
+
1781
+ test('expr_eval: 2*x+1 at x=10000 (1.0) == 30000', () =>
1782
+ expect(callAndGetRet(rt, 'test_expr_linear_x1')).toBe(30000))
1783
+
1784
+ test('expr_eval: 2*x+1 at x=20000 (2.0) == 50000', () =>
1785
+ expect(callAndGetRet(rt, 'test_expr_linear_x2')).toBe(50000))
1786
+
1787
+ test('expr_eval: (x+1)*x at x=2.0 == 60000 (chained ops)', () =>
1788
+ expect(callAndGetRet(rt, 'test_expr_chain')).toBe(60000))
1789
+
1790
+ test('expr_eval: n=0 → 0 (empty stack)', () =>
1791
+ expect(callAndGetRet(rt, 'test_expr_n0')).toBe(0))
1792
+
1793
+ test('expr_eval: single literal 420000 → 420000', () =>
1794
+ expect(callAndGetRet(rt, 'test_expr_literal42')).toBe(420000))
1795
+
1796
+ test('expr_eval: x passthrough at x=30000 → 30000', () =>
1797
+ expect(callAndGetRet(rt, 'test_expr_x_passthrough')).toBe(30000))
1798
+ })
1799
+
1800
+ // ---------------------------------------------------------------------------
1801
+ // signal.mcrs — DFT (extended)
1802
+ // ---------------------------------------------------------------------------
1803
+
1804
+ describe('signal.mcrs — DFT (extended)', () => {
1805
+ const rt = makeRuntime(`
1806
+ // Alternating signal [10000, -10000, 10000, -10000]: DC should be 0
1807
+ fn test_dft_alt_dc(): int {
1808
+ return dft_real(10000, 0 - 10000, 10000, 0 - 10000, 0, 0, 0, 0, 4, 0);
1809
+ }
1810
+ // Alternating signal k=2: should have large real component (signal frequency)
1811
+ fn test_dft_alt_k2(): int {
1812
+ let v: int = dft_real(10000, 0 - 10000, 10000, 0 - 10000, 0, 0, 0, 0, 4, 2);
1813
+ if (v < 0) { v = 0 - v; }
1814
+ if (v >= 5000) { return 1; }
1815
+ return 0;
1816
+ }
1817
+ // dft_imag of alternating signal at k=0 should be 0
1818
+ fn test_dft_alt_imag_dc(): int {
1819
+ return dft_imag(10000, 0 - 10000, 10000, 0 - 10000, 0, 0, 0, 0, 4, 0);
1820
+ }
1821
+ // dft_magnitude of alternating [10000,-10000,10000,-10000] at k=2 should be large
1822
+ fn test_dft_alt_mag_k2(): int {
1823
+ let v: int = dft_magnitude(10000, 0 - 10000, 10000, 0 - 10000, 0, 0, 0, 0, 4, 2);
1824
+ if (v >= 5000) { return 1; }
1825
+ return 0;
1826
+ }
1827
+ // Uniform n=4 k=0: dft_real == mean=10000 (already tested, but verify magnitude==real when imag=0)
1828
+ fn test_dft_uniform_mag_equals_real(): int {
1829
+ let re: int = dft_real(10000, 10000, 10000, 10000, 0, 0, 0, 0, 4, 0);
1830
+ let mg: int = dft_magnitude(10000, 10000, 10000, 10000, 0, 0, 0, 0, 4, 0);
1831
+ if (re == mg) { return 1; }
1832
+ return 0;
1833
+ }
1834
+ // n=2 signal [20000, 0]: DC = mean = 10000
1835
+ fn test_dft_n2_dc(): int {
1836
+ return dft_real(20000, 0, 0, 0, 0, 0, 0, 0, 2, 0);
1837
+ }
1838
+ // n=2 signal [20000, 0]: k=1 real = (20000 - 0)/2 = 10000
1839
+ fn test_dft_n2_k1(): int {
1840
+ return dft_real(20000, 0, 0, 0, 0, 0, 0, 0, 2, 1);
1841
+ }
1842
+ // Constant signal with n=8, k=4 (Nyquist): real alternates → should be 0 for uniform
1843
+ fn test_dft_n8_k4_uniform(): int {
1844
+ let v: int = dft_real(10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 8, 4);
1845
+ if (v < 0) { v = 0 - v; }
1846
+ if (v <= 500) { return 1; }
1847
+ return 0;
1848
+ }
1849
+ `, [MATH_SRC, SIGNAL_SRC])
1850
+
1851
+ test('dft_real(alternating, n=4, k=0) == 0 (DC of alternating = 0)', () =>
1852
+ expect(callAndGetRet(rt, 'test_dft_alt_dc')).toBe(0))
1853
+
1854
+ test('dft_real(alternating, n=4, k=2): large component >= 5000', () =>
1855
+ expect(callAndGetRet(rt, 'test_dft_alt_k2')).toBe(1))
1856
+
1857
+ test('dft_imag(alternating, n=4, k=0) == 0', () =>
1858
+ expect(callAndGetRet(rt, 'test_dft_alt_imag_dc')).toBe(0))
1859
+
1860
+ test('dft_magnitude(alternating, n=4, k=2) >= 5000 (large frequency bin)', () =>
1861
+ expect(callAndGetRet(rt, 'test_dft_alt_mag_k2')).toBe(1))
1862
+
1863
+ test('dft_magnitude == dft_real for uniform DC bin (imag=0)', () =>
1864
+ expect(callAndGetRet(rt, 'test_dft_uniform_mag_equals_real')).toBe(1))
1865
+
1866
+ test('dft_real(n=2, [20000,0], k=0) == 10000 (DC = mean)', () =>
1867
+ expect(callAndGetRet(rt, 'test_dft_n2_dc')).toBe(10000))
1868
+
1869
+ test('dft_real(n=2, [20000,0], k=1) == 10000 (first harmonic)', () =>
1870
+ expect(callAndGetRet(rt, 'test_dft_n2_k1')).toBe(10000))
1871
+
1872
+ test('dft_real(uniform×8, n=8, k=4) ≈ 0 (Nyquist bin near zero)', () =>
1873
+ expect(callAndGetRet(rt, 'test_dft_n8_k4_uniform')).toBe(1))
1874
+ })
1875
+
1876
+ // ---------------------------------------------------------------------------
1877
+ // color.mcrs — RGB↔HSL (extended)
1878
+ // ---------------------------------------------------------------------------
1879
+
1880
+ describe('color.mcrs — rgb_to_l (extended)', () => {
1881
+ const rt = makeRuntime(`
1882
+ // Gray: R=G=B=1275000 (half of 2550000) → L = (max+min)/510 = (1275000+1275000)/510 = 5000
1883
+ fn test_l_gray(): int { return rgb_to_l(1275000, 1275000, 1275000); }
1884
+ // Red-only: max=2550000, min=0 → L=(2550000+0)/510=5000
1885
+ fn test_l_red(): int { return rgb_to_l(2550000, 0, 0); }
1886
+ // Blue-only: same as red → L=5000
1887
+ fn test_l_blue(): int { return rgb_to_l(0, 0, 2550000); }
1888
+ `, [COLOR_SRC])
1889
+
1890
+ test('rgb_to_l(gray) == 5000 (L = 0.5)', () =>
1891
+ expect(callAndGetRet(rt, 'test_l_gray')).toBe(5000))
1892
+
1893
+ test('rgb_to_l(pure red) == 5000 (L = 0.5)', () =>
1894
+ expect(callAndGetRet(rt, 'test_l_red')).toBe(5000))
1895
+
1896
+ test('rgb_to_l(pure blue) == 5000 (L = 0.5)', () =>
1897
+ expect(callAndGetRet(rt, 'test_l_blue')).toBe(5000))
1898
+ })
1899
+
1900
+ describe('color.mcrs — rgb_to_s (extended)', () => {
1901
+ const rt = makeRuntime(`
1902
+ // Gray → S = 0
1903
+ fn test_s_gray(): int { return rgb_to_s(1275000, 1275000, 1275000); }
1904
+ // Black → S = 0
1905
+ fn test_s_black(): int { return rgb_to_s(0, 0, 0); }
1906
+ // Pure green → S = 10000
1907
+ fn test_s_green(): int { return rgb_to_s(0, 2550000, 0); }
1908
+ // Pure blue → S > 0
1909
+ fn test_s_blue(): int { return rgb_to_s(0, 0, 2550000); }
1910
+ `, [COLOR_SRC])
1911
+
1912
+ test('rgb_to_s(gray) == 0 (gray has no saturation)', () =>
1913
+ expect(callAndGetRet(rt, 'test_s_gray')).toBe(0))
1914
+
1915
+ test('rgb_to_s(black) == 0', () =>
1916
+ expect(callAndGetRet(rt, 'test_s_black')).toBe(0))
1917
+
1918
+ test('rgb_to_s(pure green) == 10000 (max saturation)', () =>
1919
+ expect(callAndGetRet(rt, 'test_s_green')).toBe(10000))
1920
+
1921
+ test('rgb_to_s(pure blue) > 0', () =>
1922
+ expect(callAndGetRet(rt, 'test_s_blue')).toBeGreaterThan(0))
1923
+ })
1924
+
1925
+ describe('color.mcrs — rgb_to_h (extended)', () => {
1926
+ const rt = makeRuntime(`
1927
+ // Pure red (max=R): h = 600000*(g-b)/d = 0
1928
+ fn test_h_red(): int { return rgb_to_h(2550000, 0, 0); }
1929
+ // Pure green (max=G): h = 1200000 + 600000*(b-r)/d = 1200000
1930
+ fn test_h_green(): int { return rgb_to_h(0, 2550000, 0); }
1931
+ // Pure blue (max=B): h = 2400000 + 600000*(r-g)/d = 2400000
1932
+ fn test_h_blue(): int { return rgb_to_h(0, 0, 2550000); }
1933
+ // Gray → h = 0 (achromatic, d=0)
1934
+ fn test_h_gray(): int { return rgb_to_h(1275000, 1275000, 1275000); }
1935
+ // Black → h = 0
1936
+ fn test_h_black(): int { return rgb_to_h(0, 0, 0); }
1937
+ `, [COLOR_SRC])
1938
+
1939
+ test('rgb_to_h(pure red) == 0', () =>
1940
+ expect(callAndGetRet(rt, 'test_h_red')).toBe(0))
1941
+
1942
+ test('rgb_to_h(pure green) == 1200000 (120° × 10000)', () =>
1943
+ expect(callAndGetRet(rt, 'test_h_green')).toBe(1200000))
1944
+
1945
+ test('rgb_to_h(pure blue) == 2400000 (240° × 10000)', () =>
1946
+ expect(callAndGetRet(rt, 'test_h_blue')).toBe(2400000))
1947
+
1948
+ test('rgb_to_h(gray) == 0 (achromatic)', () =>
1949
+ expect(callAndGetRet(rt, 'test_h_gray')).toBe(0))
1950
+
1951
+ test('rgb_to_h(black) == 0', () =>
1952
+ expect(callAndGetRet(rt, 'test_h_black')).toBe(0))
1953
+ })
1954
+
1955
+ describe('color.mcrs — hsl_to_r/g/b (extended)', () => {
1956
+ const rt = makeRuntime(`
1957
+ // hsl_to_r(0, 10000, 5000): red hue, full sat, mid lightness → R≈2550000
1958
+ fn test_hsl_r_red(): int { return hsl_to_r(0, 10000, 5000); }
1959
+ // hsl_to_g(0, 10000, 5000): red hue → G≈0
1960
+ fn test_hsl_g_from_red_hue(): int { return hsl_to_g(0, 10000, 5000); }
1961
+ // hsl_to_b(0, 10000, 5000): red hue → B≈0
1962
+ fn test_hsl_b_from_red_hue(): int { return hsl_to_b(0, 10000, 5000); }
1963
+ // hsl_to_g(1200000, 10000, 5000): green hue → G≈2550000
1964
+ fn test_hsl_g_green(): int { return hsl_to_g(1200000, 10000, 5000); }
1965
+ // hsl_to_r(1200000, 10000, 5000): green hue → R≈0
1966
+ fn test_hsl_r_from_green_hue(): int { return hsl_to_r(1200000, 10000, 5000); }
1967
+ // hsl_to_b(2400000, 10000, 5000): blue hue → B≈2550000
1968
+ fn test_hsl_b_blue(): int { return hsl_to_b(2400000, 10000, 5000); }
1969
+ // Gray: h=0, s=0, l=5000 → R=G=B = m*255 = 5000*255 = 1275000
1970
+ fn test_hsl_r_gray(): int { return hsl_to_r(0, 0, 5000); }
1971
+ fn test_hsl_g_gray(): int { return hsl_to_g(0, 0, 5000); }
1972
+ fn test_hsl_b_gray(): int { return hsl_to_b(0, 0, 5000); }
1973
+ `, [COLOR_SRC])
1974
+
1975
+ test('hsl_to_r(0, 10000, 5000) ≈ 2550000 (red)', () => {
1976
+ const v = callAndGetRet(rt, 'test_hsl_r_red')
1977
+ expect(Math.abs(v - 2550000)).toBeLessThanOrEqual(1000)
1978
+ })
1979
+
1980
+ test('hsl_to_g(0, 10000, 5000) ≈ 0 (red hue → no green)', () => {
1981
+ const v = callAndGetRet(rt, 'test_hsl_g_from_red_hue')
1982
+ expect(v).toBeLessThanOrEqual(1000)
1983
+ })
1984
+
1985
+ test('hsl_to_b(0, 10000, 5000) ≈ 0 (red hue → no blue)', () => {
1986
+ const v = callAndGetRet(rt, 'test_hsl_b_from_red_hue')
1987
+ expect(v).toBeLessThanOrEqual(1000)
1988
+ })
1989
+
1990
+ test('hsl_to_g(1200000, 10000, 5000) ≈ 2550000 (green hue → max green)', () => {
1991
+ const v = callAndGetRet(rt, 'test_hsl_g_green')
1992
+ expect(Math.abs(v - 2550000)).toBeLessThanOrEqual(1000)
1993
+ })
1994
+
1995
+ test('hsl_to_r(1200000, 10000, 5000) ≈ 0 (green hue → no red)', () => {
1996
+ const v = callAndGetRet(rt, 'test_hsl_r_from_green_hue')
1997
+ expect(v).toBeLessThanOrEqual(1000)
1998
+ })
1999
+
2000
+ test('hsl_to_b(2400000, 10000, 5000) ≈ 2550000 (blue hue → max blue)', () => {
2001
+ const v = callAndGetRet(rt, 'test_hsl_b_blue')
2002
+ expect(Math.abs(v - 2550000)).toBeLessThanOrEqual(1000)
2003
+ })
2004
+
2005
+ test('hsl_to_r(gray) == hsl_to_g(gray) == hsl_to_b(gray) == 1275000', () => {
2006
+ const r = callAndGetRet(rt, 'test_hsl_r_gray')
2007
+ const g = callAndGetRet(rt, 'test_hsl_g_gray')
2008
+ const b = callAndGetRet(rt, 'test_hsl_b_gray')
2009
+ expect(r).toBe(1275000)
2010
+ expect(g).toBe(1275000)
2011
+ expect(b).toBe(1275000)
2012
+ })
2013
+ })
2014
+
2015
+ // ---------------------------------------------------------------------------
2016
+ // world.mcrs — sun_azimuth (extended)
2017
+ // ---------------------------------------------------------------------------
2018
+
2019
+ describe('world.mcrs — sun_azimuth (extended)', () => {
2020
+ const rt = makeRuntime(`
2021
+ fn test_azimuth_half_day(): int { return sun_azimuth(12000); }
2022
+ fn test_azimuth_full_day(): int { return sun_azimuth(24000); }
2023
+ fn test_azimuth_three_quarter(): int { return sun_azimuth(18000); }
2024
+ fn test_azimuth_quarter_plus(): int { return sun_azimuth(8000); }
2025
+ `, [WORLD_SRC, MATH_SRC])
2026
+
2027
+ test('sun_azimuth(12000) == 1800000 (half day = 180°)', () =>
2028
+ expect(callAndGetRet(rt, 'test_azimuth_half_day')).toBe(1800000))
2029
+
2030
+ test('sun_azimuth(24000) == 0 (full day wraps to 0)', () =>
2031
+ expect(callAndGetRet(rt, 'test_azimuth_full_day')).toBe(0))
2032
+
2033
+ test('sun_azimuth(18000) == 2700000 (three-quarter day = 270°)', () =>
2034
+ expect(callAndGetRet(rt, 'test_azimuth_three_quarter')).toBe(2700000))
2035
+
2036
+ test('sun_azimuth(8000) == 1200000 (8000/24000 × 360° × 10000)', () =>
2037
+ expect(callAndGetRet(rt, 'test_azimuth_quarter_plus')).toBe(1200000))
2038
+ })
2039
+
2040
+ // ---------------------------------------------------------------------------
2041
+ // graph.mcrs — runtime
2042
+ // ---------------------------------------------------------------------------
2043
+
2044
+ describe('graph.mcrs — runtime', () => {
2045
+ const GRAPH_SRC = fs.readFileSync(
2046
+ path.join(__dirname, '../../stdlib/graph.mcrs'),
2047
+ 'utf-8',
2048
+ )
2049
+ const rt = makeRuntime(`
2050
+ fn build_graph(): int[] {
2051
+ let g: int[] = graph_new(5);
2052
+ g = graph_add_edge(g, 0, 1, 1);
2053
+ g = graph_add_edge(g, 0, 2, 4);
2054
+ g = graph_add_edge(g, 1, 3, 2);
2055
+ g = graph_add_edge(g, 2, 4, 3);
2056
+ g = graph_add_edge(g, 1, 2, 2);
2057
+ return g;
2058
+ }
2059
+
2060
+ fn build_weighted_graph(): int[] {
2061
+ let g: int[] = graph_new(5);
2062
+ g = graph_add_edge(g, 0, 1, 1);
2063
+ g = graph_add_edge(g, 0, 2, 4);
2064
+ g = graph_add_edge(g, 1, 2, 2);
2065
+ g = graph_add_edge(g, 1, 3, 5);
2066
+ g = graph_add_edge(g, 2, 3, 1);
2067
+ g = graph_add_edge(g, 3, 4, 3);
2068
+ return g;
2069
+ }
2070
+
2071
+ fn test_graph_counts(): int {
2072
+ let g: int[] = graph_new(4);
2073
+ g = graph_add_undirected(g, 0, 1, 7);
2074
+ g = graph_add_edge(g, 1, 2, 3);
2075
+ return graph_node_count(g) * 100 + graph_edge_count(g);
2076
+ }
2077
+
2078
+ fn test_bfs_order(): int {
2079
+ let g: int[] = build_graph();
2080
+ let vis: int[] = [0, 0, 0, 0, 0];
2081
+ let order: int[] = graph_bfs(g, 0, vis);
2082
+ return order[0] * 10000 + order[1] * 1000 + order[2] * 100 + order[3] * 10 + order[4];
2083
+ }
2084
+
2085
+ fn test_bfs_visited(): int {
2086
+ let g: int[] = build_graph();
2087
+ let vis: int[] = [0, 0, 0, 0, 0];
2088
+ let order: int[] = graph_bfs(g, 0, vis);
2089
+ return vis[0] * 10000 + vis[1] * 1000 + vis[2] * 100 + vis[3] * 10 + vis[4];
2090
+ }
2091
+
2092
+ fn test_dfs_order(): int {
2093
+ let g: int[] = build_graph();
2094
+ let vis: int[] = [0, 0, 0, 0, 0];
2095
+ let order: int[] = graph_dfs(g, 0, vis);
2096
+ return order[0] * 10000 + order[1] * 1000 + order[2] * 100 + order[3] * 10 + order[4];
2097
+ }
2098
+
2099
+ fn test_has_path_yes(): int {
2100
+ let g: int[] = build_graph();
2101
+ return graph_has_path(g, 0, 4);
2102
+ }
2103
+
2104
+ fn test_has_path_no(): int {
2105
+ let g: int[] = build_graph();
2106
+ return graph_has_path(g, 4, 0);
2107
+ }
2108
+
2109
+ fn test_shortest_path(): int {
2110
+ let g: int[] = build_weighted_graph();
2111
+ let dist: int[] = [0, 0, 0, 0, 0];
2112
+ return graph_shortest_path(g, 0, 4, dist);
2113
+ }
2114
+
2115
+ fn test_shortest_path_distances(): int {
2116
+ let g: int[] = build_weighted_graph();
2117
+ let dist: int[] = [0, 0, 0, 0, 0];
2118
+ let best: int = graph_shortest_path(g, 0, 4, dist);
2119
+ return best * 1000 + dist[2] * 100 + dist[3] * 10 + dist[4];
2120
+ }
2121
+
2122
+ fn test_shortest_path_unreachable(): int {
2123
+ let g: int[] = graph_new(3);
2124
+ g = graph_add_edge(g, 0, 1, 2);
2125
+ let dist: int[] = [0, 0, 0];
2126
+ return graph_shortest_path(g, 1, 2, dist);
2127
+ }
2128
+ `, [GRAPH_SRC])
2129
+
2130
+ test('graph metadata reports node and edge counts', () =>
2131
+ expect(callAndGetRet(rt, 'test_graph_counts')).toBe(403))
2132
+
2133
+ test('graph_bfs returns discovery order', () =>
2134
+ expect(callAndGetRet(rt, 'test_bfs_order')).toBe(1234))
2135
+
2136
+ test('graph_bfs marks reachable nodes in out_visited', () =>
2137
+ expect(callAndGetRet(rt, 'test_bfs_visited')).toBe(11111))
2138
+
2139
+ test('graph_dfs returns iterative DFS order', () =>
2140
+ expect(callAndGetRet(rt, 'test_dfs_order')).toBe(1324))
2141
+
2142
+ test('graph_has_path returns 1 when reachable', () =>
2143
+ expect(callAndGetRet(rt, 'test_has_path_yes')).toBe(1))
2144
+
2145
+ test('graph_has_path returns 0 when unreachable', () =>
2146
+ expect(callAndGetRet(rt, 'test_has_path_no')).toBe(0))
2147
+
2148
+ test('graph_shortest_path returns weighted shortest distance', () =>
2149
+ expect(callAndGetRet(rt, 'test_shortest_path')).toBe(7))
2150
+
2151
+ test('graph_shortest_path fills out_dist for reachable nodes', () =>
2152
+ expect(callAndGetRet(rt, 'test_shortest_path_distances')).toBe(7347))
2153
+
2154
+ test('graph_shortest_path returns -1 when dst is unreachable', () =>
2155
+ expect(callAndGetRet(rt, 'test_shortest_path_unreachable')).toBe(-1))
2156
+ })
2157
+
2158
+ describe('ode.mcrs — runtime', () => {
2159
+ const rt = makeRuntime(`
2160
+ fn test_decay_y(): int {
2161
+ ode_run(1, 0, 10000, 1000, 10, 10000);
2162
+ return ode_get_y();
2163
+ }
2164
+
2165
+ fn test_growth_y(): int {
2166
+ ode_run(2, 0, 10000, 1000, 5, 10000);
2167
+ return ode_get_y();
2168
+ }
2169
+
2170
+ fn test_final_t(): int {
2171
+ ode_run(1, 2500, 10000, 1000, 10, 10000);
2172
+ return ode_get_t();
2173
+ }
2174
+ `, [MATH_SRC, ODE_SRC])
2175
+
2176
+ test('ode_run decay stays near e^-1', () => {
2177
+ const val = callAndGetRet(rt, 'test_decay_y')
2178
+ expect(val).toBeGreaterThanOrEqual(3629)
2179
+ expect(val).toBeLessThanOrEqual(3729)
2180
+ })
2181
+
2182
+ test('ode_run growth stays near e^0.5', () => {
2183
+ const val = callAndGetRet(rt, 'test_growth_y')
2184
+ expect(val).toBeGreaterThanOrEqual(16287)
2185
+ expect(val).toBeLessThanOrEqual(16687)
2186
+ })
2187
+
2188
+ test('ode_get_t returns t0 + steps*h', () =>
2189
+ expect(callAndGetRet(rt, 'test_final_t')).toBe(12500))
2190
+ })
2191
+
2192
+ // ---------------------------------------------------------------------------
2193
+ // linalg.mcrs — runtime
2194
+ // NOTE: double arithmetic intrinsics (double_mul, double_add, etc.) rely on
2195
+ // MC entity commands that do not execute in MCRuntime. Only operations whose
2196
+ // result is zero (so the multiply-by-zero path short-circuits correctly) and
2197
+ // the integer zero-length guard are verifiable here.
2198
+ // ---------------------------------------------------------------------------
2199
+
2200
+ describe('linalg.mcrs — runtime', () => {
2201
+ const LINALG_SRC = fs.readFileSync(
2202
+ path.join(__dirname, '../../stdlib/linalg.mcrs'),
2203
+ 'utf-8',
2204
+ )
2205
+
2206
+ const rt = makeRuntime(`
2207
+ // dot(⊥) = 0
2208
+ fn test_dot2d_perp(): int {
2209
+ let d: double = vec2d_dot(1.0d, 0.0d, 0.0d, 1.0d);
2210
+ return d as int;
2211
+ }
2212
+ fn test_dot3d_perp(): int {
2213
+ let d: double = vec3d_dot(1.0d, 0.0d, 0.0d, 0.0d, 1.0d, 0.0d);
2214
+ return d as int;
2215
+ }
2216
+ // cross of parallel vectors = (0, 0, 0)
2217
+ fn test_cross_parallel_x(): int {
2218
+ let d: double = vec3d_cross_x(2.0d, 0.0d, 0.0d, 3.0d, 0.0d, 0.0d);
2219
+ return d as int;
2220
+ }
2221
+ fn test_cross_parallel_y(): int {
2222
+ let d: double = vec3d_cross_y(2.0d, 0.0d, 0.0d, 3.0d, 0.0d, 0.0d);
2223
+ return d as int;
2224
+ }
2225
+ fn test_cross_parallel_z(): int {
2226
+ let d: double = vec3d_cross_z(2.0d, 0.0d, 0.0d, 3.0d, 0.0d, 0.0d);
2227
+ return d as int;
2228
+ }
2229
+ // normalize zero-length vector returns 0.0
2230
+ fn test_normalize2d_zero_x(): int {
2231
+ let d: double = vec2d_normalize_x(0.0d, 0.0d);
2232
+ return d as int;
2233
+ }
2234
+ fn test_normalize2d_zero_y(): int {
2235
+ let d: double = vec2d_normalize_y(0.0d, 0.0d);
2236
+ return d as int;
2237
+ }
2238
+ fn test_normalize3d_zero_x(): int {
2239
+ let d: double = vec3d_normalize_x(0.0d, 0.0d, 0.0d);
2240
+ return d as int;
2241
+ }
2242
+ fn test_normalize3d_zero_z(): int {
2243
+ let d: double = vec3d_normalize_z(0.0d, 0.0d, 0.0d);
2244
+ return d as int;
2245
+ }
2246
+ // mat2d_vecmul with zero column
2247
+ fn test_matmul_zero_col(): int {
2248
+ let d: double = mat2d_vecmul_x(0.0d, 0.0d, 0.0d, 1.0d, 3.0d, 4.0d);
2249
+ return d as int;
2250
+ }
2251
+ // solve2d: Cramer numerator zero → x = 0
2252
+ // A = [[0, 1], [1, 0]], b = [0, 5] → x = (0*0 - 1*5) / det(0,1,1,0)
2253
+ // det = 0*0 - 1*1 = -1 (but double_mul won't compute 1*1 correctly)
2254
+ // Instead test with b=[0,0] → x = 0
2255
+ fn test_solve2d_x_zero_rhs(): int {
2256
+ let d: double = solve2d_x(1.0d, 0.0d, 0.0d, 1.0d, 0.0d, 0.0d);
2257
+ return d as int;
2258
+ }
2259
+ fn test_solve2d_y_zero_rhs(): int {
2260
+ let d: double = solve2d_y(1.0d, 0.0d, 0.0d, 1.0d, 0.0d, 0.0d);
2261
+ return d as int;
2262
+ }
2263
+ `, [MATH_SRC, MATH_HP_SRC, LINALG_SRC])
2264
+
2265
+ test('vec2d_dot of perpendicular unit vectors = 0', () =>
2266
+ expect(callAndGetRet(rt, 'test_dot2d_perp')).toBe(0))
2267
+
2268
+ test('vec3d_dot of perpendicular unit vectors = 0', () =>
2269
+ expect(callAndGetRet(rt, 'test_dot3d_perp')).toBe(0))
2270
+
2271
+ test('vec3d_cross_x of parallel vectors = 0', () =>
2272
+ expect(callAndGetRet(rt, 'test_cross_parallel_x')).toBe(0))
2273
+
2274
+ test('vec3d_cross_y of parallel vectors = 0', () =>
2275
+ expect(callAndGetRet(rt, 'test_cross_parallel_y')).toBe(0))
2276
+
2277
+ test('vec3d_cross_z of parallel vectors = 0', () =>
2278
+ expect(callAndGetRet(rt, 'test_cross_parallel_z')).toBe(0))
2279
+
2280
+ test('vec2d_normalize_x of zero vector = 0', () =>
2281
+ expect(callAndGetRet(rt, 'test_normalize2d_zero_x')).toBe(0))
2282
+
2283
+ test('vec2d_normalize_y of zero vector = 0', () =>
2284
+ expect(callAndGetRet(rt, 'test_normalize2d_zero_y')).toBe(0))
2285
+
2286
+ test('vec3d_normalize_x of zero vector = 0', () =>
2287
+ expect(callAndGetRet(rt, 'test_normalize3d_zero_x')).toBe(0))
2288
+
2289
+ test('vec3d_normalize_z of zero vector = 0', () =>
2290
+ expect(callAndGetRet(rt, 'test_normalize3d_zero_z')).toBe(0))
2291
+
2292
+ test('mat2d_vecmul_x with zero row = 0', () =>
2293
+ expect(callAndGetRet(rt, 'test_matmul_zero_col')).toBe(0))
2294
+
2295
+ test('solve2d_x with zero rhs = 0', () =>
2296
+ expect(callAndGetRet(rt, 'test_solve2d_x_zero_rhs')).toBe(0))
2297
+
2298
+ test('solve2d_y with zero rhs = 0', () =>
2299
+ expect(callAndGetRet(rt, 'test_solve2d_y_zero_rhs')).toBe(0))
2300
+ })