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 / omc / tests / longnames / long_names_om2.om
| 1 | note long_names_om2: long names in an OM-2 unit: requires and ensures over long parameter names, an |
| 2 | note unsized view with a long name, a part of a long-named local, and a loop invariant over a long name. |
| 3 | note The checks exit 1..3 when they fail; then a requires with left_operand 5000 fails: trap 9, exit 109. |
| 4 | om2 |
| 5 | fn bounded_sum left_operand ulong right_operand ulong to ulong |
| 6 | requires lt left_operand 1000 |
| 7 | ensures ge result left_operand |
| 8 | ret add left_operand right_operand |
| 9 | end |
| 10 | |
| 11 | fn view_length all_the_bytes view uchar * to ulong |
| 12 | ret len all_the_bytes |
| 13 | end |
| 14 | |
| 15 | fn main to int |
| 16 | first_total = bounded_sum 5 6 |
| 17 | if ne first_total 11 |
| 18 | ret 1 |
| 19 | end |
| 20 | local_bytes = new uchar 32 7 |
| 21 | if ne view_length part local_bytes 4 9 9 |
| 22 | ret 2 |
| 23 | end |
| 24 | loop_counter = ulong 0 |
| 25 | while lt loop_counter 5 bound 10 |
| 26 | invariant le loop_counter 5 |
| 27 | loop_counter = add loop_counter 1 |
| 28 | end |
| 29 | if ne loop_counter 5 |
| 30 | ret 3 |
| 31 | end |
| 32 | over_limit = bounded_sum 5000 1 |
| 33 | ret 4 |
| 34 | end |