test/modules/run 1009 B raw
1
#!/bin/sh
2
# Resolve and execute references beyond module index 127.
3
set -eu
4
emulator=${RAD_EMULATOR:-emulator}
5
work=$(mktemp -d)
6
trap 'rm -rf "$work"' EXIT HUP INT TERM
7
mkdir "$work/capacity"
8
set -- -pkg capacity -mod "$work/capacity.rad"
9
index=0
10
while [ "$index" -lt 127 ]; do
11
    printf 'export mod m%s;\n' "$index" >> "$work/capacity.rad"
12
    printf '/// Return this module index.\nexport fn value() -> u64 { return %s; }\n' "$index" > "$work/capacity/m$index.rad"
13
    set -- "$@" -mod "$work/capacity/m$index.rad"
14
    index=$((index + 1))
15
done
16
printf 'use capacity::m126;\n/// Check a package root beyond module index 127.\n@default fn main() -> u64 { assert m126::value() == 126; return 0; }\n' > "$work/entry.rad"
17
set -- "$@" -pkg entry -mod "$work/entry.rad"
18
"$emulator" -memory-size=385024 -data-size=348160 -stack-size=1024 \
19
    -run bin/radiance.rv64.dev "$@" -entry entry -o "$work/capacity.rv64"
20
"$emulator" -run "$work/capacity.rv64"
21
printf 'module scopes: references beyond index 127 passed\n'