FA-75551 / Text diff and three-way merge / Open access
Whitespace comparison modes: every trailing carriage return is stripped · case 01
Lines ending in two carriage returns compare equal to lines with one.
ROOT CAUSE
The CR stripping removes all trailing carriage returns instead of one.
VERIFIED REPAIR
Remove exactly one trailing carriage return.
Unsuccessful approach: Removing every carriage return also deletes ones inside the line.
Case contract
Normalize each line: with strip_cr remove one trailing "\r"; mode "w" deletes all whitespace (str.split semantics); mode "b" collapses runs of spaces and tabs to one space and strips trailing spaces and tabs; mode "none" leaves the line. With ignore_blank, drop lines whose normalized key is empty. Return both key lists and whether they are equal.
Why this case matters
Diff options like -w, -b, --strip-trailing-cr and --ignore-blank-lines decide which changes are shown at all.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(a, b, mode, strip_cr, ignore_blank):
def norm(line):
if strip_cr:
line = line.rstrip('\r')
if mode == 'w':
return ''.join(line.split())
if mode == 'b':
return re.sub(r'[ \t]+', ' ', line).rstrip(' \t')
return line
ka = [norm(x) for x in a]
kb = [norm(x) for x in b]
if ignore_blank:
ka = [x for x in ka if x != '']
kb = [x for x in kb if x != '']
return {'a': ka, 'b': kb, 'equal': ka == kb}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
1: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
2: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', '', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
3: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', '', '', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
4: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', '', '', '', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
5: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', '', '', '', '', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
}[N]
for label, args, expected in cases:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| amount of whitespace ignored | {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True} | {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True} | Passed |
| leading whitespace presence matters under -b | {'a': [' x'], 'b': ['x'], 'equal': False} | {'a': [' x'], 'b': ['x'], 'equal': False} | Passed |
| all whitespace ignored | {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True} | {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True} | Passed |
| carriage return stripped once | {'a': ['line', 'two'], 'b': ['line', 'two'], 'equal': True} | {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False} | Failed |
| carriage return kept without the flag | {'a': ['cr\r'], 'b': ['cr'], 'equal': False} | {'a': ['cr\r'], 'b': ['cr'], 'equal': False} | Passed |
| interior carriage return is content | {'a': ['a\rb'], 'b': ['ab'], 'equal': False} | {'a': ['a\rb'], 'b': ['ab'], 'equal': False} | Passed |
| whitespace-only line is blank only when normalized empty | {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False} | {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False} | Passed |
| blank lines ignored under -w | {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True} | {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True} | Passed |
| tabs under -w | {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True} | {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True} | Passed |
| vertical tab under -w | {'a': ['mn'], 'b': ['mn'], 'equal': True} | {'a': ['mn'], 'b': ['mn'], 'equal': True} | Passed |
SHA-256 / 360a4e62c157292847ab62849e588cdad2c4e35e120fb477a99864fd727fcb4f
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(a, b, mode, strip_cr, ignore_blank):
def norm(line):
if strip_cr:
line = line.replace('\r', '')
if mode == 'w':
return ''.join(line.split())
if mode == 'b':
return re.sub(r'[ \t]+', ' ', line).rstrip(' \t')
return line
ka = [norm(x) for x in a]
kb = [norm(x) for x in b]
if ignore_blank:
ka = [x for x in ka if x != '']
kb = [x for x in kb if x != '']
return {'a': ka, 'b': kb, 'equal': ka == kb}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
1: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
2: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', '', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
3: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', '', '', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
4: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', '', '', '', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
5: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', '', '', '', '', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
}[N]
for label, args, expected in cases:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| amount of whitespace ignored | {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True} | {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True} | Passed |
| leading whitespace presence matters under -b | {'a': [' x'], 'b': ['x'], 'equal': False} | {'a': [' x'], 'b': ['x'], 'equal': False} | Passed |
| all whitespace ignored | {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True} | {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True} | Passed |
| carriage return stripped once | {'a': ['line', 'two'], 'b': ['line', 'two'], 'equal': True} | {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False} | Failed |
| carriage return kept without the flag | {'a': ['cr\r'], 'b': ['cr'], 'equal': False} | {'a': ['cr\r'], 'b': ['cr'], 'equal': False} | Passed |
| interior carriage return is content | {'a': ['ab'], 'b': ['ab'], 'equal': True} | {'a': ['a\rb'], 'b': ['ab'], 'equal': False} | Failed |
| whitespace-only line is blank only when normalized empty | {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False} | {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False} | Passed |
| blank lines ignored under -w | {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True} | {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True} | Passed |
| tabs under -w | {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True} | {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True} | Passed |
| vertical tab under -w | {'a': ['mn'], 'b': ['mn'], 'equal': True} | {'a': ['mn'], 'b': ['mn'], 'equal': True} | Passed |
SHA-256 / 3040ca1f3751dd16c6aef0077021eabf14a1812b1774061130c15db8172ec094
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import re
N = 1
observations = []
def solve(a, b, mode, strip_cr, ignore_blank):
def norm(line):
if strip_cr and line.endswith('\r'):
line = line[:-1]
if mode == 'w':
return ''.join(line.split())
if mode == 'b':
return re.sub(r'[ \t]+', ' ', line).rstrip(' \t')
return line
ka = [norm(x) for x in a]
kb = [norm(x) for x in b]
if ignore_blank:
ka = [x for x in ka if x != '']
kb = [x for x in kb if x != '']
return {'a': ka, 'b': kb, 'equal': ka == kb}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
1: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
2: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', '', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
3: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', '', '', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
4: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', '', '', '', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
5: [('amount of whitespace ignored', [['a b', 'c\t\td '], ['a b', 'c d'], 'b', False, False], {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True}), ('leading whitespace presence matters under -b', [[' x'], ['x'], 'b', False, False], {'a': [' x'], 'b': ['x'], 'equal': False}), ('all whitespace ignored', [['a b c', ' \t'], ['abc', ''], 'w', False, False], {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True}), ('carriage return stripped once', [['line\r', 'two\r\r'], ['line', 'two\r'], 'none', True, False], {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False}), ('carriage return kept without the flag', [['cr\r'], ['cr'], 'b', False, False], {'a': ['cr\r'], 'b': ['cr'], 'equal': False}), ('interior carriage return is content', [['a\rb'], ['ab'], 'none', True, False], {'a': ['a\rb'], 'b': ['ab'], 'equal': False}), ('whitespace-only line is blank only when normalized empty', [['x', ' ', 'y'], ['x', 'y'], 'none', False, True], {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False}), ('blank lines ignored under -w', [['x', ' \t ', 'y', '', '', '', '', ''], ['x', 'y'], 'w', False, True], {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True}), ('tabs under -w', [['k\tv', 'q'], ['kv', 'q'], 'w', False, False], {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True}), ('vertical tab under -w', [['m\x0bn'], ['mn'], 'w', False, False], {'a': ['mn'], 'b': ['mn'], 'equal': True})],
}[N]
for label, args, expected in cases:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| amount of whitespace ignored | {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True} | {'a': ['a b', 'c d'], 'b': ['a b', 'c d'], 'equal': True} | Passed |
| leading whitespace presence matters under -b | {'a': [' x'], 'b': ['x'], 'equal': False} | {'a': [' x'], 'b': ['x'], 'equal': False} | Passed |
| all whitespace ignored | {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True} | {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True} | Passed |
| carriage return stripped once | {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False} | {'a': ['line', 'two\r'], 'b': ['line', 'two'], 'equal': False} | Passed |
| carriage return kept without the flag | {'a': ['cr\r'], 'b': ['cr'], 'equal': False} | {'a': ['cr\r'], 'b': ['cr'], 'equal': False} | Passed |
| interior carriage return is content | {'a': ['a\rb'], 'b': ['ab'], 'equal': False} | {'a': ['a\rb'], 'b': ['ab'], 'equal': False} | Passed |
| whitespace-only line is blank only when normalized empty | {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False} | {'a': ['x', ' ', 'y'], 'b': ['x', 'y'], 'equal': False} | Passed |
| blank lines ignored under -w | {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True} | {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True} | Passed |
| tabs under -w | {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True} | {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True} | Passed |
| vertical tab under -w | {'a': ['mn'], 'b': ['mn'], 'equal': True} | {'a': ['mn'], 'b': ['mn'], 'equal': True} | Passed |
SHA-256 / c004dde0f25b1133d2a36dd64148fa02d548feb4cbb32e1f557ed155676cebf5
Verification & scope
A deterministic, bounded teaching model of one diff, patch or merge rule with stipulated conventions; it is not a production diff or version-control implementation and makes no claim of conformance to any specific tool. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:49:07.529143+00:00.
Case digest / 293e313c94ba3f29b62e541bb5537ae80eccdaba84c89a94067e6e5bbda9319c