interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / omc / tests / longnames / long_names_om2.om

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