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/interplane-forge/blob/main/research/tests/json.sh # interplane-forge INTERPLANE Forge Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-forge / research / tests / json.sh` 27 lines ยท 1493 bytes Raw Blame History 1 #!/bin/sh 2 set -eu 3 cd "$(dirname "$0")/../.." 4 T=$(mktemp -d) 5 trap 'rm -rf "$T"' EXIT HUP INT TERM 6 OMC=$HOME/work/flux/omega-mv/seed/out/omc 7 PIN=`3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194` 8 [ "$(sha256sum "$OMC" | cut -d' ' -f1)" = "$PIN" ] || exit 2 9 "$OMC" < research/lib/jflat.om > "$T/flat"; chmod 700 "$T/flat" 10 pass=0; fail=0 11 ok(){ pass=$((pass+1)); echo "PASS json $*"; } 12 bad(){ fail=$((fail+1)); echo "FAIL json $*"; } 13 for v in 0 -0 1 -1 12 0.1 -0.1 1e2 1E+2 1e-2 -1.2E+3 true false null; do 14 if printf '%s\n' "$v" | "$T/flat" > "$T/out" 2> "$T/err"; then 15 [ "$(cat "$T/out")" = "$(printf '/\t%s' "$v")" ] && ok "valid literal $v" || bad "value changed $v" 16 else bad "valid literal refused $v"; fi 17 done 18 for v in 1e 1e+ 1. 1.2.3 +1 01 -01 --1 1e2e3 NaN Infinity -Infinity; do 19 rc=0; printf '%s\n' "$v" | "$T/flat" > "$T/out" 2> "$T/err" || rc=$? 20 [ "$rc" = 2 ] && grep -q 'malformed JSON' "$T/err" && ok "invalid number $v refused for JSON grammar" || bad "INVALID_NUMBER_ACCEPTED $v" 21 done 22 sed 's/if not jnumok s p/if false/' research/lib/jflat.om > "$T/mutant.om" 23 "$OMC" < "$T/mutant.om" > "$T/mutant"; chmod 700 "$T/mutant" 24 rc=0; printf '1e\n' | "$T/mutant" > "$T/mutant.out" 2> "$T/mutant.err" || rc=$? 25 [ "$rc" = 0 ] && [ "$(cat "$T/mutant.out")" = "$(printf '/\t1e')" ] && ok 'MUTANT caught as INVALID_NUMBER_ACCEPTED, not parser setup failure' || bad 'numeric grammar mutant wrong reason' 26 echo "JSON_RESULT pass=$pass fail=$fail" 27 [ "$fail" = 0 ]