883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
26 lines
1.6 KiB
Python
26 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Compare the native codec with the independently compiled Trinity writer.
|
|
|
|
This establishes serializer parity, not real-client consumption or adoption.
|
|
"""
|
|
import struct
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
root=Path(__file__).resolve().parents[1]
|
|
oracle=Path(sys.argv[2]) if len(sys.argv)>2 else root/'build/forever-schema/forever-create-codec'
|
|
if not oracle.is_file():
|
|
print('Optional source-derived serializer not built');sys.exit(77)
|
|
for limit in range(1,11):
|
|
native=subprocess.run([sys.argv[1],str(limit)],capture_output=True,check=True,timeout=5).stdout
|
|
reference=subprocess.run([str(oracle),'--glue-features'],input=struct.pack('<I',limit),capture_output=True,check=True,timeout=5).stdout
|
|
assert len(native)==106 and native==reference,'Native glue writer differs from compiled source'
|
|
assert native[:6]==bytes(6) and struct.unpack_from('<I',native,18)[0]==limit
|
|
assert struct.unpack_from('<I',native,50)==(1,), 'Native GameRules count missing'
|
|
assert struct.unpack_from('<iif',native,94)==(93,2,0.0), 'Native Vanilla finder rule missing'
|
|
for invalid in ('0','11','4294967295','-1','junk','10junk'):
|
|
assert subprocess.run([sys.argv[1],invalid],capture_output=True,timeout=5).returncode==1
|
|
for malformed in (b'',b'\1',struct.pack('<I',11),struct.pack('<II',10,0)):
|
|
assert subprocess.run([str(oracle),'--glue-features'],input=malformed,capture_output=True,timeout=5).returncode==1
|
|
print('Native glue initialization matches independent source serializer for all Turtle character limits; invalid policies rejected.')
|