Commit 393ad18
Phase D+E: stdlib expansion + conformance golden tests
## Phase D: ~35 new built-ins to close the gap with canonical Python omnicc
### Math (16)
abs, floor, ceil, round, frac, clamp, sqrt, log, exp, sin, cos, tan,
tanh, erf (Abramowitz & Stegun approximation), sigmoid, pow.
Constants: pi(), e(), phi().
### Strings (4)
str_reverse, str_contains, str_slice, concat_many (variadic — the
canonical workaround for OMC's broken cross-type `+` concat).
to_string and concat_many render numerics as bare values (89) not as
the HInt display form (HInt(89, φ=...)).
### Arrays (10) + arr_push fix
arr_get, arr_set, arr_first, arr_last, arr_min, arr_max, arr_concat,
arr_contains, arr_index_of, arr_slice, arr_resonance (mean across
elements). Real arr_push (was a stub returning Null).
### Type coercion (6)
to_int, to_float, to_string + int/float/string aliases. Polymorphic
len(x) for arrays and strings (canonical OMC pattern).
### Parser fixes
- Unary minus: `-5` now parses.
- `for i in range(N)` single-arg form (canonical). 2-arg still works.
## Phase E: Conformance golden tests (omnimcode-core/tests/conformance.rs)
33 integration tests locking the language's "physics":
- Fibonacci numbers have res >= 0.7 (1, 2, 3, 5, 8, 13, ... 610)
- res(89) and res(610) are perfectly 1.0
- fold() snaps to Fibonacci attractor, preserves sign
- fold(x, "fibonacci") string-mode 2-arg form works
- 89/0 returns Singularity(89/0, ctx=div), is_singularity returns int 1/0
- resolve_singularity(p, "fold") snaps |numerator| to Fibonacci
- Canonical smart_divide pattern from test_phase7_integration.omc
- int+int=int, float+int=float arithmetic stability
- phi.fold(x) === fold(x); phi.res(x) is HFloat
- sqrt(144)=12, pow(2,10)=1024, sigmoid(0)=0.5, pi=π
- arr_from_range(1,11) sums to 55 (Fibonacci coincidence)
- arr_get/set/push/min/max round-trip
- str_reverse, str_contains, concat_many semantics
- Recursive fib(10)=55, while-loop sum(0..100)=4950
Tests are designed to be the contract between this Rust port and the
canonical Python omnicc. If a test fails, it's either an intentional
language semantics change (update Python+CHANGELOG) or a regression
(fix the code, don't relax the test).
## Fixed (caught by conformance suite)
- Expression::Resonance (1-arg res(x)) was returning HInt(resonance*1000)
while the variadic call_function("res") path returns HFloat. Made
consistent — both now return HFloat resonance score.
- concat_many used Value::to_string() which produced the HInt display
format. Now renders bare numerics like to_string built-in does.
## Compatibility milestone
4 canonical Python OMNIcode programs now run end-to-end on Rust OMC
(up from 1 after Phase A+B):
- miner_nuclear.omc (131 LOC, 7 stacked pragmas)
- test_phase7_features.omc (import/module/typed-fn smoke tests)
- test_phase8_arrays.omc (array-literal smoke tests)
- test_array.omc (array stdlib regression suite)
## Tests
111 passing across the workspace (was 78 after Phase C). The new
conformance suite contributes 33; Phase D added 0 unit tests but
materially expanded what the conformance suite can exercise.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 30fc5d2 commit 393ad18
4 files changed
Lines changed: 720 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
7 | 42 | | |
8 | 43 | | |
9 | 44 | | |
| |||
0 commit comments