omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / seed / host / tests / structfile.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Combined gate: a struct value drives a native file operation in one program. |
| 3 | struct H x uint y ulong end |
| 4 | text path "structfile.tmp" |
| 5 | text body "ok\n" |
| 6 | fn main to int |
| 7 | h = new H 7 9 |
| 8 | put h y 42 |
| 9 | fd = int fopen path 0 len path 577 420 |
| 10 | if lt fd 0 |
| 11 | ret 1 |
| 12 | end |
| 13 | n = write fd body 0 len body |
| 14 | r = fclose fd |
| 15 | u = unlink path 0 len path |
| 16 | if ne n long len body |
| 17 | ret 2 |
| 18 | end |
| 19 | if ne r 0 |
| 20 | ret 3 |
| 21 | end |
| 22 | if ne u 0 |
| 23 | ret 4 |
| 24 | end |
| 25 | if eq get h x 7 |
| 26 | if eq get h y 42 |
| 27 | ret 0 |
| 28 | end |
| 29 | end |
| 30 | ret 5 |
| 31 | end |