"""Run with Python 3: a controlled text-fixture comparison, not a build verifier."""
import hashlib
import json

lf = b'{"ready":true}\n'
crlf = b'{"ready":true}\r\n'
changed = b'{"ready":false}\r\n'

def digest(data):
    return hashlib.sha256(data).hexdigest()

assert json.loads(lf) == json.loads(crlf)
assert digest(lf) != digest(crlf)
assert crlf.replace(b"\r\n", b"\n") == lf
assert changed.replace(b"\r\n", b"\n") != lf
print(json.dumps({
    "same_parsed_record": json.loads(lf) == json.loads(crlf),
    "same_raw_digest": digest(lf) == digest(crlf),
    "lf_bytes": len(lf), "crlf_bytes": len(crlf),
    "lf_sha256": digest(lf), "crlf_sha256": digest(crlf),
    "fixture_equal_after_newline_conversion": crlf.replace(b"\r\n", b"\n") == lf,
    "changed_value_stays_different": changed.replace(b"\r\n", b"\n") != lf,
}, indent=2))
