"""Compare browser normalization to Python's explicit original-audit semantics.""" import json,subprocess,unicodedata from pathlib import Path whitespace=[chr(c)for c in range(0x110000)if chr(c).isspace()] values=[c+'Cafe\u0301'+c+'note'+c for c in whitespace] values += ['\ufeffBOM kept','\u200bzero width\u200b','\u180eignored?','A\x00B','\ufeff','Cafe\u0301\r\nšŸ˜€','x\u2028y'] code="import fs from 'node:fs'; import {normalized} from './planner.mjs'; console.log(JSON.stringify(JSON.parse(fs.readFileSync(0,'utf8')).map(normalized)));" result=json.loads(subprocess.run(['node','--input-type=module','-e',code],input=json.dumps(values),text=True,capture_output=True,check=True,cwd=Path(__file__).parent).stdout) assert result==[' '.join(unicodedata.normalize('NFC',s).split())for s in values] print(json.dumps({'status':'PASS','python_whitespace_codepoints':len(whitespace),'normalization_vectors':len(values),'BOM_not_removed':True}))