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 / tests / arboris_spread_test.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Compose in om/units.sh order, removing export markers for program mode. |
| 3 | note Two upper Entity nodes with a part_of edge. An incident edge is traversed |
| 4 | note in both directions, even though ontology validation uses its declared direction. |
| 5 | fn ar_fixture r edit uint 16 to void |
| 6 | put r 0 ar_record_v1 |
| 7 | put r 1 1 |
| 8 | put r 2 2 |
| 9 | put r 3 1 |
| 10 | put r 4 2 |
| 11 | put r 5 ar_one |
| 12 | put r 13 1 |
| 13 | put r 14 1 |
| 14 | put r 15 ar_one |
| 15 | end |
| 16 | |
| 17 | fn ar_test_load to int |
| 18 | r = new uint 16 0 |
| 19 | t = new uint 8 55 |
| 20 | w = new uint 2 66 |
| 21 | ar_fixture r |
| 22 | put r 4 0 |
| 23 | if ne arboris_load_records r t w 4 |
| 24 | ret 1 |
| 25 | end |
| 26 | put r 4 2 |
| 27 | put r 14 2 |
| 28 | if ne arboris_load_records r t w 4 |
| 29 | ret 2 |
| 30 | end |
| 31 | put r 14 1 |
| 32 | put r 13 13 |
| 33 | if ne arboris_load_records r t w 4 |
| 34 | ret 3 |
| 35 | end |
| 36 | put r 1 2 |
| 37 | put r 6 7 |
| 38 | if ne arboris_load_records r t w 3 |
| 39 | ret 4 |
| 40 | end |
| 41 | if or ne get t 7 55 ne get w 0 66 |
| 42 | ret 5 |
| 43 | end |
| 44 | put r 7 5 |
| 45 | put r 9 6 |
| 46 | put r 10 3 |
| 47 | put r 13 1 |
| 48 | if ne arboris_load_records r t w 0 |
| 49 | ret 6 |
| 50 | end |
| 51 | if or ne get t 6 1 ne get t 7 0 |
| 52 | ret 7 |
| 53 | end |
| 54 | ret 0 |
| 55 | end |
| 56 | |
| 57 | fn ar_test_wave to int |
| 58 | r = new uint 16 0 |
| 59 | t = new uint 8 0 |
| 60 | w = new uint 2 0 |
| 61 | state = new uint 20 0 |
| 62 | ar_fixture r |
| 63 | if ne arboris_load_records r t w 0 |
| 64 | ret 8 |
| 65 | end |
| 66 | put state 0 2 |
| 67 | put state 2 0x3f000000 |
| 68 | put state 3 0x3f000000 |
| 69 | put state 4 ar_one |
| 70 | put state 6 ar_one |
| 71 | put state 9 ar_one |
| 72 | put state 11 ar_one |
| 73 | if ne arboris_spread_step t w state 0 |
| 74 | ret 9 |
| 75 | end |
| 76 | if or ne get state 15 0x3f000000 ne get state 18 0x3f000000 |
| 77 | ret 10 |
| 78 | end |
| 79 | if or ne get state 13 ar_one ne get state 16 ar_one |
| 80 | ret 11 |
| 81 | end |
| 82 | put state 2 0x3e800000 |
| 83 | if ne arboris_spread_step t w state 0 |
| 84 | ret 12 |
| 85 | end |
| 86 | if or ne get state 4 0 ne get state 9 0 |
| 87 | ret 13 |
| 88 | end |
| 89 | if or ne get state 7 0x3f000000 ne get state 10 0x3f000000 |
| 90 | ret 14 |
| 91 | end |
| 92 | put state 2 0 |
| 93 | if or ne arboris_spread_step t w state 0 ne get state 1 0 |
| 94 | ret 15 |
| 95 | end |
| 96 | put t 6 2 |
| 97 | if ne arboris_spread_step t w state 2 |
| 98 | ret 16 |
| 99 | end |
| 100 | if ne ar_product 1 0x3f000000 0 |
| 101 | ret 17 |
| 102 | end |
| 103 | if ne ar_product 3 0x3f000000 2 |
| 104 | ret 18 |
| 105 | end |
| 106 | ret 0 |
| 107 | end |
| 108 | |
| 109 | fn ar_test_relax to int |
| 110 | topo = new uint 9 0 |
| 111 | weights = new uint 2 ar_one |
| 112 | state = new uint 16 0 |
| 113 | put topo 0 ar_topo_v1 |
| 114 | put topo 1 3 |
| 115 | put topo 2 2 |
| 116 | put topo 5 1 |
| 117 | put topo 6 2 |
| 118 | put topo 8 1 |
| 119 | put state 0 2 |
| 120 | put state 2 0x3f000000 |
| 121 | put state 4 ar_one |
| 122 | put state 8 ar_one |
| 123 | if ne arboris_relax_step topo weights state 0 |
| 124 | ret 21 |
| 125 | end |
| 126 | if or ne get state 11 0x3f000000 ne get state 15 0x3f000000 |
| 127 | ret 22 |
| 128 | end |
| 129 | if ne arboris_relax_step topo weights state 0 |
| 130 | ret 23 |
| 131 | end |
| 132 | if or ne get state 6 0x3e800000 ne get state 8 ar_one |
| 133 | ret 24 |
| 134 | end |
| 135 | put state 4 0x7fc00000 |
| 136 | if or ne arboris_relax_step topo weights state 3 ne get state 1 0 |
| 137 | ret 25 |
| 138 | end |
| 139 | ret 0 |
| 140 | end |
| 141 | |
| 142 | fn main to int |
| 143 | rc = al_test |
| 144 | if ne rc 0 |
| 145 | ret rc |
| 146 | end |
| 147 | rc = ar_test_load |
| 148 | if ne rc 0 |
| 149 | ret rc |
| 150 | end |
| 151 | rc = ar_test_wave |
| 152 | if ne rc 0 |
| 153 | ret rc |
| 154 | end |
| 155 | ret ar_test_relax |
| 156 | end |