# Conformance cases: each line is one command, run natively and in WASM under LC_ALL=C and LC_ALL=C.UTF-8.
# Stdout, stderr and exit code must match byte for byte. Quote as in a POSIX shell; ' | ' separates stages.
# A "[sorted]" prefix compares stdout as sorted lines: grep -r lists files in the order the filesystem returns
# them, which differs between Linux filesystems and MEMFS (and so must never decide a puzzle answer).
# Files are under conformance/fixtures/. Group headings follow the design doc's concept order.
# Not testable here (see self-tests instead): awk system(), sed 'e', |& coprocesses, /inet, runaway regex.

# --- 1. Glyphs: literals, '.', anchors, classes, negation ---
grep vesper logs/access.log
grep '^10\.0\.4\.' logs/access.log
grep 'HTTP/1\.1" 40[0-9]' logs/access.log
grep '[[:digit:]]\{4\}$' logs/access.log
grep '[^a-z]rook' registry/passwd
grep '[[:upper:]]' chat/glassrow.txt
grep -o '.$' chat/glassrow.txt
grep 'caf.' chat/glassrow.txt
grep -o 'S.ren' chat/glassrow.txt

# --- 2. Repetition, greediness, basic vs extended ---
grep -o 'v.*r' chat/glassrow.txt
grep -E '[0-9]{3,}' ledger/transfers.psv
grep 'o\+k' chat/glassrow.txt
grep -E 'ok( ok)+' chat/glassrow.txt
grep -c 'ok\?' chat/glassrow.txt
grep -E 'a{,2}x' chat/glassrow.txt

# --- 3. Grouping, alternation, backreferences ---
grep -E 'GET|DELETE' logs/access.log
grep 'vault\|docks' logs/access.log
grep -E '\|([a-z]+)\|\1\|' ledger/transfers.psv
grep -E '(ok)\. \1' chat/glassrow.txt
grep -E '\b(\w+) is the \1\b' chat/glassrow.txt

# --- 4. grep flags ---
grep -i VESPER chat/glassrow.txt
grep -v vesper logs/access.log
grep -w ok chat/glassrow.txt
grep -x 'id|from|to|amount|memo' ledger/transfers.psv
grep -n -F '[22/Nov' logs/access.log
grep -c POST logs/access.log
grep -f data/suspects.txt ledger/transfers.psv
grep -A1 -B1 nologin registry/passwd
grep -C1 robots logs/access.log
grep -m2 -n 10.0.4 logs/access.log
grep -l vesper logs/access.log ledger/transfers.psv chat/glassrow.txt
grep -L vesper logs/access.log registry/passwd
grep -h vesper logs/access.log chat/glassrow.txt
grep -H -o 'T-[0-9]*' ledger/transfers.psv
grep -b -o vault logs/access.log
grep -q vesper logs/access.log
grep -s vesper missing.txt
[sorted] grep -r --include='*.psv' vesper .
[sorted] grep -rc vesper chat
grep vesper data/blob.bin
grep -a vesper data/blob.bin
grep -c '' chat/fragment.txt
grep -o 'two' chat/crlf.txt
grep -z -o 'line' chat/crlf.txt

# --- 4b. grep errors and exit codes ---
grep nothing-matches logs/access.log
grep vesper missing.txt
grep vesper logs
grep -E 'a{1' chat/glassrow.txt
grep '\(' chat/glassrow.txt
grep -P vesper logs/access.log
grep --no-such-flag x logs/access.log

# --- 5. sed ---
sed 's/vesper/V/' registry/passwd
sed 's/o/0/g' chat/glassrow.txt
sed 's|/home/|~|' registry/passwd
sed -n 's/.*"\(GET\|POST\) \([^ ]*\).*/\1 \2/p' logs/access.log
sed -E 's/([0-9]+)\.([0-9]+)/[\2.\1]/' ledger/transfers.psv
sed 's/[a-z]*/(&)/' registry/passwd
sed -E 's/(\w+)/\U\1/2' chat/glassrow.txt
sed -n '2,4p' logs/access.log
sed -n '/okafor/,/rook/p' logs/access.log
sed '/nologin/d' registry/passwd
sed -n '$p' chat/glassrow.txt
sed '1~2d' ledger/transfers.psv
sed '$!N;s/\n/ + /' chat/glassrow.txt
sed 'y/abc/ABC/' chat/glassrow.txt
sed = chat/fragment.txt
sed -n l chat/glassrow.txt
sed -n l chat/crlf.txt
sed 'a\--' chat/fragment.txt
sed -s -n '$p' chat/glassrow.txt registry/passwd
sed 's/x/' chat/glassrow.txt
sed -n '/[/p' chat/glassrow.txt
sed p missing.txt

# --- 6. awk ---
gawk -F: '{ print $1, $3 }' registry/passwd
gawk -F: '$7 == "/bin/zsh" { print $1 }' registry/passwd
gawk -F'|' 'NR > 1 { total += $4 } END { print total }' ledger/transfers.psv
gawk -F'|' 'NR > 1 { sum[$3] += $4 } END { for (k in sum) print k, sum[k] }' ledger/transfers.psv
gawk -F'|' 'NR > 1 { sum[$3] += $4 } END { n = asorti(sum, keys); for (i = 1; i <= n; i++) printf "%-8s %10.2f\n", keys[i], sum[keys[i]] }' ledger/transfers.psv
gawk '{ print NR, NF, $NF }' logs/access.log
gawk 'BEGIN { FS = ":" } NR == FNR { name[$1] = $5; next } FNR > 1 { split($0, f, "|"); print f[1], name[f[2]] }' registry/passwd ledger/transfers.psv
gawk '{ print length($0) }' chat/glassrow.txt
gawk '{ print toupper(substr($0, 1, 12)) }' chat/glassrow.txt
gawk '{ n = gsub(/o/, "0"); print n, $0 }' chat/glassrow.txt
gawk 'match($0, /[0-9]+\.[0-9]+/) { print substr($0, RSTART, RLENGTH) }' ledger/transfers.psv
gawk 'BEGIN { print 0.1 + 0.2; print 1e6, 1e16, 1e300 * 1e10; print 2^53, 2^53 + 1; print -0 }'
gawk 'BEGIN { printf "%.20f|%e|%g|%G|%a\n", 1/3, 12345.678, 0.0001234, 1e-10, 1 }'
gawk 'BEGIN { printf "%d|%i|%o|%x|%X|%u|%c|%5.1s|%%\n", 1e30, -7.9, 8, 255, 255, -1, 65, "abc" }'
gawk 'BEGIN { printf "%.0f %.0f %.0f %.0f\n", 0.5, 1.5, 2.5, -0.5 }'
gawk 'BEGIN { print log(-1), sqrt(-1), int(-3.7), 7 % -3, exp(1000) }'
gawk 'BEGIN { srand(1); print rand(), rand(); print srand(5) }'
gawk 'BEGIN { print strftime("%Y-%m-%d %H:%M:%S %Z", 0, 1) }'
gawk 'BEGIN { print strftime("%H:%M %z", 86400) }'
gawk 'BEGIN { print mktime("2026 11 22 00 00 00") }'
gawk 'BEGIN { print length("café Søren"), toupper("café"), index("Søren", "r") }'
gawk 'BEGIN { s = sprintf("%c", 233); print length(s) }'
gawk 'BEGIN { n = split("a:b::c", parts, ":"); print n, parts[3] == "", parts[4] }'
gawk 'BEGIN { print substr("hello", 0, 2), substr("hello", -1), substr("hello", 4, 100) }'
gawk 'BEGIN { x["a"]; delete x; print length(x); print typeof(x), typeof(1), typeof("s") }'
gawk '{ print > "/dev/stderr" }' chat/fragment.txt
gawk 'END { print NR, $0 }' chat/fragment.txt
gawk 'BEGIN { RS = "" } { print NR ": " $1 }' chat/glassrow.txt
gawk 'BEGIN { getline line < "registry/passwd"; print line; close("registry/passwd") }'
gawk --version
gawk 'BEGIN { print PROCINFO["version"], PROCINFO["FS"] }'
gawk 'BEGIN { print ENVIRON["LC_ALL"]; n = 0; for (k in ENVIRON) n++; print n }'
gawk 'BEGIN { print 1/0 }'
gawk '{ print $1' chat/glassrow.txt
gawk 'BEGIN { print substr( }'
gawk -f missing.awk
gawk '{ print }' missing.txt

# --- 7. Pipelines ---
gawk '{ print $1 }' logs/access.log | grep -c 10.0.4
grep -o '"[A-Z]* ' logs/access.log | sed 's/[" ]//g' | gawk '{ c[$1]++ } END { for (m in c) print m, c[m] }'
sed -n '2,$p' ledger/transfers.psv | gawk -F'|' '$4 > 1000 { print $2 " -> " $3 }'
grep vesper chat/glassrow.txt | sed 's/^\[[0-9:]*\] //' | gawk '{ print NR ": " $0 }'

# --- 8. Platform differences found by diffing native and WASM config.h ---
# wasm32 has 32-bit long (SIZEOF_UNSIGNED_LONG 4 vs 8): bitwise functions and large integers.
gawk 'BEGIN { print and(2^40 + 5, 2^40 + 3), or(2^33, 1), xor(2^40, 2^41), lshift(1, 40), rshift(2^50, 10) }'
gawk 'BEGIN { print compl(0), compl(2^40) }'
gawk 'BEGIN { printf "%x %X %o %u %d %i\n", 2^40, 2^52, 2^35, 2^33, 2^62, -2^40 }'
gawk 'BEGIN { print strtonum("0x1FFFFFFFFF"), strtonum("077777777777"), strtonum("4294967297") }'
gawk 'BEGIN { x[2^33] = 1; x[4294967296] = 2; for (k in x) print k, x[k] }'
gawk 'BEGIN { print int(2^40 / 3), 2^40 % 7, -2^40 % 7, 2^63, 2^64 }'
# srand seeds >= 2^32: gawk builtin.c:1558 converts the double seed to unsigned long, undefined behaviour when
# long is 32 bits (wasm32). Accepted for v1 by the owner (2026-11-22); a wasm64 (MEMORY64) build would remove it.
[known] gawk 'BEGIN { srand(2^40); print rand() }'
gawk 'BEGIN { printf "%c%c\n", 2^32 + 65, 256 + 66 }'
# printf %a and %F (configure guessed "no" when cross-compiling) and signed NaN/infinity formatting.
gawk 'BEGIN { printf "%a %A %F %.2F\n", 1, 0.5, 2.5, -1e10 }'
gawk 'BEGIN { x = -log(-1); y = log(-1); printf "%f %F %e %g %d\n", x, y, x, y, x; print x, y, -x, log(0), -log(0) }'
gawk 'BEGIN { print exp(1000), exp(-1000), exp(0) }'
# Local time: the runtime pins it to UTC (Emscripten ignores TZ); native runs with TZ=UTC0.
gawk 'BEGIN { print strftime("%Y-%m-%d %H:%M:%S %Z %z", 0), strftime("%c", 1795392000) }'
gawk 'BEGIN { print mktime("2026 11 22 00 00 00"), mktime("2026 07 01 12 00 00"), mktime("2026 11 22 00 00 00 0") }'
# mktime with the DST flag forced to 1: glibc (TZ=UTC0, a zone without DST) subtracts an hour; the UTC pin
# (timegm) ignores the flag. Accepted for v1 by the owner (2026-11-22).
[known] gawk 'BEGIN { print mktime("2026 11 22 00 00 00 1") }'
gawk 'BEGIN { print strftime("%A %B %j %U %w", mktime("2026 03 29 02 30 00")) }'

# --- 9. Parser-related: GNU long-option abbreviations (gnulib getopt in WASM vs glibc natively), gawk --sandbox ---
grep --ignore VESPER chat/glassrow.txt
grep --fixed '[22/Nov' logs/access.log
grep --col=never -c vesper logs/access.log
grep --fi x logs/access.log
grep --count=3 x logs/access.log
sed --quie -e 1p chat/fragment.txt
gawk --field-sep=: '{ print $1 }' registry/passwd
gawk --sandbox -F: '{ print $1 }' registry/passwd
gawk --sandbox 'BEGIN { system("ls") }'
gawk --sandbox 'BEGIN { print "x" > "f" }'
gawk --sandbox 'BEGIN { "date" | getline d }'
gawk --sandbox 'BEGIN { getline line < "registry/passwd"; print line }'
gawk --sandbox '{ print FILENAME ": " $1 }' registry/passwd chat/fragment.txt

# --- 10. coreutils (one multi-call binary in WASM): locale-sensitive behaviour under C and C.UTF-8 ---
sort chat/glassrow.txt
sort -f registry/passwd
sort -t: -k3,3n registry/passwd
sort -u -k2 chat/glassrow.txt
cut -d: -f1,5 registry/passwd
cut -c1-12 chat/glassrow.txt
wc -lwmc chat/glassrow.txt
tr 'a-z' 'A-Z' < chat/glassrow.txt
tr -s ' ' chat/glassrow.txt
tr -cd '[:alpha:]\n' chat/glassrow.txt
uniq -c data/suspects.txt
head -c 20 chat/glassrow.txt
tail -n +7 chat/glassrow.txt
tac registry/passwd
nl -ba -w2 chat/fragment.txt
paste -d'|' registry/passwd data/suspects.txt
fold -w 15 -s chat/glassrow.txt
od -An -c chat/crlf.txt
base64 -w 20 registry/passwd
sha256sum registry/passwd chat/glassrow.txt
md5sum ledger/transfers.psv
printf '%5.2f|%-6s|%d\n' 3.14159 ab 42
seq -w 8 12
expand -t 3 chat/glassrow.txt
date -u -d '2026-11-22 01:02:03' '+%F %T %Z %s'
ls registry logs
cat -A chat/crlf.txt
sort nosuchfile
cut -f1 -d
