SilverSight/fortran/test_avm.f90
allaun 3b6baec64e wip: durability snapshot of local working tree (pre-existing, uncommitted)
Snapshot of previously-uncommitted local work so nothing is lost after the
power outage. NOT reviewed for correctness — a WIP checkpoint, not a feature:
- multi-language hachimoji encoders (c/cpp/fortran/julia/octave/r/scala/go/rust/coq)
- formal Lean WIP (BraidTree, Eisenstein, HachimojiCapture, MathlibConnect,
  ModularFormBridge, ClusterManifold) + lakefile + E8Sidon edit
- docs/, experiments/ (epyc oisc benches), deploy/, scripts, test scaffolding
- .gitignore: exclude **/target/ and Coq build artifacts

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 20:49:53 -05:00

43 lines
1.4 KiB
Fortran

! AVM ISA v1 — Fortran Test Harness
program test_avm
use avm
implicit none
type(State) :: s, s2
type(Instr) :: prog(10)
integer :: err, expected
print *, "AVM Fortran Port — Test Harness"
print *, "==============================="
! Test basic add: 5 + 3 = 8
prog(:)%op = 0; prog(:)%arg = 0; prog(:)%arg2 = .false.
prog(1)%op = I_PUSH_Q16; prog(1)%arg = 5 * Q16_SCALE
prog(2)%op = I_PUSH_Q16; prog(2)%arg = 3 * Q16_SCALE
prog(3)%op = I_PRIM; prog(3)%arg = PRIM_ADD
prog(4)%op = I_HALT
s = State()
call step_sub(s, prog, 4, s2, err)
do while (.not. s2%halted .and. err == 0)
s = s2; call step_sub(s, prog, 4, s2, err)
end do
if (s2%stack(s2%sp)%val == 8 * Q16_SCALE) then; print *, " ✅ basic_add: 5+3=8"
else; print *, " ❌ basic_add"; end if
! Test div: 3/5 = 0.6
s = State(); s2 = State()
prog(1)%op = I_PUSH_Q16; prog(1)%arg = 3 * Q16_SCALE
prog(2)%op = I_PUSH_Q16; prog(2)%arg = 5 * Q16_SCALE
prog(3)%op = I_PRIM; prog(3)%arg = PRIM_DIV
prog(4)%op = I_HALT
call step_sub(s, prog, 4, s2, err)
do while (.not. s2%halted .and. err == 0)
s = s2; call step_sub(s, prog, 4, s2, err)
end do
expected = (3 * Q16_SCALE) / 5
if (s2%stack(s2%sp)%val == expected) then; print *, " ✅ div_q16: 3/5=0.6"
else; print *, " ❌ div_q16"; end if
print *, ""
print *, "All Fortran tests passed."
end program test_avm