Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tests/checker2/gen_valid.sh # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / checker2 / gen_valid.sh` 120 lines ยท 3567 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 3 # Copyright 2026 Drake Stapleton (AIEN / aien-dev) 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 # Deterministic generator of valid OSC units for the checker2 gate (omega#446): writes 18 # /gen_NN.osc for NN in 00..(count-1). Each unit varies the scalar type, array length, loop 19 # bound and shape (loops, borrows, structs, drop-flag moves, casts, contracts) by its index. No 20 # randomness: the same count gives the same files. The producer (oscc) must accept every one; 21 # that is checked by tests/checker2/differential.sh, not assumed here. 22 # Usage: sh tests/checker2/gen_valid.sh [count] 23 set -eu 24 OUT=$1 25 N=${2:-48} 26 mkdir -p "$OUT" 27 set -- u8 u16 u32 u64 i8 i16 i32 i64 28 i=0 29 while [ "$i" -lt "$N" ]; do 30 k=$((i % 8 + 1)) 31 T=$(eval echo "\${$k}") 32 L=$((i % 7 + 2)) 33 B=$((10 + i * 3)) 34 C=$((i % 5 + 1)) 35 f=$(printf '%s/gen_%02d.osc' "$OUT" "$i") 36 case $((i % 6)) in 37 0) cat > "$f" < $T { 41 let a: own [$T; $L] = alloc(x); 42 for j in 0 .. $L { a[j] = a[j] ^ (j as $T); } 43 let mut n: u32 = 0; 44 while n < $C bound $B { n = n + 1; } 45 let r: $T = a[0] | a[$((L - 1))]; 46 return r; 47 } 48 EOF 49 ;; 50 1) cat > "$f" < $T { return a[0]; } 57 fn main(v: $T) -> $T { 58 let a: own [$T; $L] = alloc(v); 59 fill(&mut a, v); 60 let r: $T = first(&a); 61 return r; 62 } 63 EOF 64 ;; 65 2) cat > "$f" < $T { 70 let s: own S$i = S$i { tag: t, vals: [v; $L], ok: t > $C }; 71 if s.ok { s.vals[0] = v & v; } 72 s.tag = s.tag | 1; 73 return s.vals[$((L - 1))]; 74 } 75 EOF 76 ;; 77 3) cat > "$f" < $T { return x[0]; } 81 fn main(c: bool, v: $T) -> $T { 82 let a: own [$T; $L] = alloc(v); 83 let mut r: $T = v; 84 if c { r = take(a); } 85 return r; 86 } 87 EOF 88 ;; 89 4) cat > "$f" < u64 { 93 let mut acc: u64 = 0; 94 let mut n: u16 = 0; 95 while n < $C bound $B { 96 acc = acc + ((x as u64) >> (s & 7)); 97 n = n + 1; 98 } 99 if (x as u64) >= acc { return acc; } 100 return acc << 1; 101 } 102 EOF 103 ;; 104 5) cat > "$f" < $T requires hi >= 0 ensures result <= hi { 108 if v > hi { return hi; } 109 return v; 110 } 111 fn main(v: $T) -> $T { 112 let a: $T = clamp(v, $C); 113 let b: $T = clamp(a, $((C + 1))); 114 return a + b; 115 } 116 EOF 117 ;; 118 esac 119 i=$((i + 1)) 120 done