FA-75561 / Text diff and three-way merge / Open access
Whitespace comparison modes: -w removes only spaces · case 01
Tab and other whitespace differences are still reported under -w.
ROOT CAUSE
The -w normalization deletes space characters only.
VERIFIED REPAIR
Delete every whitespace character under -w.
Unsuccessful approach: Deleting spaces and tabs still leaves vertical tabs and form feeds.
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 and line.endswith('\r'):
line = line[:-1]
if mode == 'w':
return line.replace(' ', '')
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', '\t'], 'b': ['abc', ''], 'equal': False} | {'a': ['abc', ''], 'b': ['abc', ''], 'equal': True} | Failed |
| 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', '\t', 'y'], 'b': ['x', 'y'], 'equal': False} | {'a': ['x', 'y'], 'b': ['x', 'y'], 'equal': True} | Failed |
| tabs under -w | {'a': ['k\tv', 'q'], 'b': ['kv', 'q'], 'equal': False} | {'a': ['kv', 'q'], 'b': ['kv', 'q'], 'equal': True} | Failed |
| vertical tab under -w | {'a': ['m\x0bn'], 'b': ['mn'], 'equal': False} | {'a': ['mn'], 'b': ['mn'], 'equal': True} | Failed |
SHA-256 / a194c5abb52bbbd1c3f15a41e47246890bd707a3a6bbaa4c483e3ffa30c21686
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 and line.endswith('\r'):
line = line[:-1]
if mode == 'w':
return re.sub(r'[ \t]', '', line)
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': ['m\x0bn'], 'b': ['mn'], 'equal': False} | {'a': ['mn'], 'b': ['mn'], 'equal': True} | Failed |
SHA-256 / 06067d73c99bf81d8956121cfb6bc85af5a32c47e0b425779733ee234a3734ad
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.752662+00:00.
Case digest / 08e711702b0387fb392c744fc52e087c1555915e1eee20f0b0cc9721f7420880