broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    r0 = x['original'] if x['cancel'] else x['provisional']
    r1 = x['source'] if x['cancel'] else x['destination']
    r2 = x['rank'] if x['cancel'] else None
    r3 = x['cancel']
    r4 = x['previous_active'] if x['cancel'] else x['dragged']
    r5 = 'commit'
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c'], 'provisional': ['b', 'c'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'b'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 2, True, 'a', 'discard'])], 2: [({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['b', 'c', 'extra0'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'b', 'extra0'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 2, True, 'a', 'discard'])], 3: [({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['b', 'c', 'extra0', 'extra1'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'b', 'extra0', 'extra1'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 2, True, 'a', 'discard'])], 4: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 2, True, 'a', 'discard'])], 5: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 2, True, 'a', 'discard'])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    r0 = x['original'] if x['cancel'] else x['provisional']
    r1 = x['source'] if x['cancel'] else x['destination']
    r2 = x['rank'] if x['cancel'] else None
    r3 = x['cancel']
    r4 = x['previous_active'] if x['cancel'] else x['dragged']
    r5 = 'discard'
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c'], 'provisional': ['b', 'c'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'c'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c'], 'provisional': ['a', 'b'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c'], 'p', 2, True, 'a', 'discard'])], 2: [({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['b', 'c', 'extra0'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'c', 'extra0'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0'], 'provisional': ['a', 'b', 'extra0'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0'], 'p', 2, True, 'a', 'discard'])], 3: [({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['b', 'c', 'extra0', 'extra1'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'c', 'extra0', 'extra1'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1'], 'provisional': ['a', 'b', 'extra0', 'extra1'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1'], 'p', 2, True, 'a', 'discard'])], 4: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2'], 'p', 2, True, 'a', 'discard'])], 5: [({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': False}, [['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', None, False, 'b', 'commit']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'a', 'rank': 0, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 0, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'p', 'destination': 'q', 'previous_active': 'b', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 1, True, 'b', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'b', 'rank': 1, 'source': 'q', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'q', 1, True, 'a', 'discard']), ({'original': ['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'provisional': ['a', 'b', 'extra0', 'extra1', 'extra2', 'extra3'], 'dragged': 'c', 'rank': 2, 'source': 'p', 'destination': 'q', 'previous_active': 'a', 'cancel': True}, [['a', 'b', 'c', 'extra0', 'extra1', 'extra2', 'extra3'], 'p', 2, True, 'a', 'discard'])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), 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)

prompt:
The tab workspace reports an incorrect detach preview discard.

Canceling a tab drag restores source pane and rank, removes provisional destination placeholder, restores prior selection, releases capture and discards detach preview.

split: open-access


meaning: Fixture-count band, not measured model difficulty

deps: stdlib

prompt:
The tab workspace reports an incorrect selection visual order.

Dragging a selected set keeps its visual order, rebases drop boundary by every moved item before it, preserves anchor view and leaves unselected tabs ordered.

split: open-access


prompt:
The tab workspace reports an incorrect all moved removal.

Dragging a selected set keeps its visual order, rebases drop boundary by every moved item before it, preserves anchor view and leaves unselected tabs ordered.

split: open-access


prompt:
The tab workspace reports an incorrect multiple boundary rebase.

Dragging a selected set keeps its visual order, rebases drop boundary by every moved item before it, preserves anchor view and leaves unselected tabs ordered.

split: open-access


prompt:
The tab workspace reports an incorrect drag anchor retention.

Dragging a selected set keeps its visual order, rebases drop boundary by every moved item before it, preserves anchor view and leaves unselected tabs ordered.

split: open-access


prompt:
The tab workspace reports an incorrect anchor offset in block.

Dragging a selected set keeps its visual order, rebases drop boundary by every moved item before it, preserves anchor view and leaves unselected tabs ordered.

split: open-access


prompt:
The tab workspace reports an incorrect moved block selection range.

Dragging a selected set keeps its visual order, rebases drop boundary by every moved item before it, preserves anchor view and leaves unselected tabs ordered.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    r0 = {}
    r1 = sum(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r2 = not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r3 = x['subscriptions'][x['closing']]
    r4 = x['document_handles'][x['views'][x['closing']]] if not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items()) else 0
    r5 = [v for v,d in x['views'].items() if v!=x['closing'] and d==x['views'][x['closing']]]
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 2, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'b': 'd'}, 0, True, 1, 4, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4, 'f': 1}}, [{'b': 'e', 'c': 'f'}, 0, True, 2, 7, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'c': 'e'}, 1, False, 3, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'd'}, 2, False, 2, 0, ['b', 'c']])], 2: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 4, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'b': 'd'}, 0, True, 2, 8, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8, 'f': 2}}, [{'b': 'e', 'c': 'f'}, 0, True, 4, 14, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'c': 'e'}, 1, False, 6, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'd'}, 2, False, 4, 0, ['b', 'c']])], 3: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 6, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'b': 'd'}, 0, True, 3, 12, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12, 'f': 3}}, [{'b': 'e', 'c': 'f'}, 0, True, 6, 21, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'c': 'e'}, 1, False, 9, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'd'}, 2, False, 6, 0, ['b', 'c']])], 4: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 8, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'b': 'd'}, 0, True, 4, 16, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16, 'f': 4}}, [{'b': 'e', 'c': 'f'}, 0, True, 8, 28, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'c': 'e'}, 1, False, 12, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'd'}, 2, False, 8, 0, ['b', 'c']])], 5: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 10, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'b': 'd'}, 0, True, 5, 20, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20, 'f': 5}}, [{'b': 'e', 'c': 'f'}, 0, True, 10, 35, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'c': 'e'}, 1, False, 15, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'd'}, 2, False, 10, 0, ['b', 'c']])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    r0 = {v:d for v,d in x['views'].items() if d!=x['views'][x['closing']]}
    r1 = sum(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r2 = not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r3 = x['subscriptions'][x['closing']]
    r4 = x['document_handles'][x['views'][x['closing']]] if not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items()) else 0
    r5 = [v for v,d in x['views'].items() if v!=x['closing'] and d==x['views'][x['closing']]]
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 2, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'b': 'd'}, 0, True, 1, 4, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4, 'f': 1}}, [{'b': 'e', 'c': 'f'}, 0, True, 2, 7, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'c': 'e'}, 1, False, 3, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'd'}, 2, False, 2, 0, ['b', 'c']])], 2: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 4, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'b': 'd'}, 0, True, 2, 8, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8, 'f': 2}}, [{'b': 'e', 'c': 'f'}, 0, True, 4, 14, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'c': 'e'}, 1, False, 6, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'd'}, 2, False, 4, 0, ['b', 'c']])], 3: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 6, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'b': 'd'}, 0, True, 3, 12, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12, 'f': 3}}, [{'b': 'e', 'c': 'f'}, 0, True, 6, 21, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'c': 'e'}, 1, False, 9, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'd'}, 2, False, 6, 0, ['b', 'c']])], 4: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 8, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'b': 'd'}, 0, True, 4, 16, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16, 'f': 4}}, [{'b': 'e', 'c': 'f'}, 0, True, 8, 28, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'c': 'e'}, 1, False, 12, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'd'}, 2, False, 8, 0, ['b', 'c']])], 5: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 10, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'b': 'd'}, 0, True, 5, 20, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20, 'f': 5}}, [{'b': 'e', 'c': 'f'}, 0, True, 10, 35, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'c': 'e'}, 1, False, 15, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'd'}, 2, False, 10, 0, ['b', 'c']])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), 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)

prompt:
The tab workspace reports an incorrect view reference removal.

Several tab views may share one document. Closing one view releases only its view resources and closes document resources only when no other view references that document.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    r0 = {v:d for v,d in x['views'].items() if v!=x['closing']}
    r1 = len(x['views'])-1
    r2 = not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r3 = x['subscriptions'][x['closing']]
    r4 = x['document_handles'][x['views'][x['closing']]] if not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items()) else 0
    r5 = [v for v,d in x['views'].items() if v!=x['closing'] and d==x['views'][x['closing']]]
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 2, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'b': 'd'}, 0, True, 1, 4, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4, 'f': 1}}, [{'b': 'e', 'c': 'f'}, 0, True, 2, 7, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'c': 'e'}, 1, False, 3, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'd'}, 2, False, 2, 0, ['b', 'c']])], 2: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 4, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'b': 'd'}, 0, True, 2, 8, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8, 'f': 2}}, [{'b': 'e', 'c': 'f'}, 0, True, 4, 14, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'c': 'e'}, 1, False, 6, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'd'}, 2, False, 4, 0, ['b', 'c']])], 3: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 6, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'b': 'd'}, 0, True, 3, 12, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12, 'f': 3}}, [{'b': 'e', 'c': 'f'}, 0, True, 6, 21, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'c': 'e'}, 1, False, 9, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'd'}, 2, False, 6, 0, ['b', 'c']])], 4: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 8, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'b': 'd'}, 0, True, 4, 16, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16, 'f': 4}}, [{'b': 'e', 'c': 'f'}, 0, True, 8, 28, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'c': 'e'}, 1, False, 12, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'd'}, 2, False, 8, 0, ['b', 'c']])], 5: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 10, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'b': 'd'}, 0, True, 5, 20, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20, 'f': 5}}, [{'b': 'e', 'c': 'f'}, 0, True, 10, 35, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'c': 'e'}, 1, False, 15, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'd'}, 2, False, 10, 0, ['b', 'c']])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    r0 = {v:d for v,d in x['views'].items() if v!=x['closing']}
    r1 = sum(d==x['views'][x['closing']] for d in x['views'].values())
    r2 = not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r3 = x['subscriptions'][x['closing']]
    r4 = x['document_handles'][x['views'][x['closing']]] if not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items()) else 0
    r5 = [v for v,d in x['views'].items() if v!=x['closing'] and d==x['views'][x['closing']]]
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 2, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'b': 'd'}, 0, True, 1, 4, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4, 'f': 1}}, [{'b': 'e', 'c': 'f'}, 0, True, 2, 7, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'c': 'e'}, 1, False, 3, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'd'}, 2, False, 2, 0, ['b', 'c']])], 2: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 4, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'b': 'd'}, 0, True, 2, 8, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8, 'f': 2}}, [{'b': 'e', 'c': 'f'}, 0, True, 4, 14, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'c': 'e'}, 1, False, 6, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'd'}, 2, False, 4, 0, ['b', 'c']])], 3: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 6, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'b': 'd'}, 0, True, 3, 12, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12, 'f': 3}}, [{'b': 'e', 'c': 'f'}, 0, True, 6, 21, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'c': 'e'}, 1, False, 9, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'd'}, 2, False, 6, 0, ['b', 'c']])], 4: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 8, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'b': 'd'}, 0, True, 4, 16, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16, 'f': 4}}, [{'b': 'e', 'c': 'f'}, 0, True, 8, 28, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'c': 'e'}, 1, False, 12, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'd'}, 2, False, 8, 0, ['b', 'c']])], 5: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 10, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'b': 'd'}, 0, True, 5, 20, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20, 'f': 5}}, [{'b': 'e', 'c': 'f'}, 0, True, 10, 35, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'c': 'e'}, 1, False, 15, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'd'}, 2, False, 10, 0, ['b', 'c']])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), 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)

prompt:
The tab workspace reports an incorrect remaining document refs.

Several tab views may share one document. Closing one view releases only its view resources and closes document resources only when no other view references that document.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    r0 = {v:d for v,d in x['views'].items() if v!=x['closing']}
    r1 = sum(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r2 = True
    r3 = x['subscriptions'][x['closing']]
    r4 = x['document_handles'][x['views'][x['closing']]] if not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items()) else 0
    r5 = [v for v,d in x['views'].items() if v!=x['closing'] and d==x['views'][x['closing']]]
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 2, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'b': 'd'}, 0, True, 1, 4, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4, 'f': 1}}, [{'b': 'e', 'c': 'f'}, 0, True, 2, 7, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'c': 'e'}, 1, False, 3, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'd'}, 2, False, 2, 0, ['b', 'c']])], 2: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 4, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'b': 'd'}, 0, True, 2, 8, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8, 'f': 2}}, [{'b': 'e', 'c': 'f'}, 0, True, 4, 14, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'c': 'e'}, 1, False, 6, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'd'}, 2, False, 4, 0, ['b', 'c']])], 3: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 6, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'b': 'd'}, 0, True, 3, 12, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12, 'f': 3}}, [{'b': 'e', 'c': 'f'}, 0, True, 6, 21, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'c': 'e'}, 1, False, 9, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'd'}, 2, False, 6, 0, ['b', 'c']])], 4: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 8, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'b': 'd'}, 0, True, 4, 16, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16, 'f': 4}}, [{'b': 'e', 'c': 'f'}, 0, True, 8, 28, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'c': 'e'}, 1, False, 12, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'd'}, 2, False, 8, 0, ['b', 'c']])], 5: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 10, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'b': 'd'}, 0, True, 5, 20, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20, 'f': 5}}, [{'b': 'e', 'c': 'f'}, 0, True, 10, 35, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'c': 'e'}, 1, False, 15, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'd'}, 2, False, 10, 0, ['b', 'c']])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    r0 = {v:d for v,d in x['views'].items() if v!=x['closing']}
    r1 = sum(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r2 = len(x['views'])==1
    r3 = x['subscriptions'][x['closing']]
    r4 = x['document_handles'][x['views'][x['closing']]] if not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items()) else 0
    r5 = [v for v,d in x['views'].items() if v!=x['closing'] and d==x['views'][x['closing']]]
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 2, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'b': 'd'}, 0, True, 1, 4, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4, 'f': 1}}, [{'b': 'e', 'c': 'f'}, 0, True, 2, 7, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'c': 'e'}, 1, False, 3, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'd'}, 2, False, 2, 0, ['b', 'c']])], 2: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 4, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'b': 'd'}, 0, True, 2, 8, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8, 'f': 2}}, [{'b': 'e', 'c': 'f'}, 0, True, 4, 14, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'c': 'e'}, 1, False, 6, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'd'}, 2, False, 4, 0, ['b', 'c']])], 3: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 6, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'b': 'd'}, 0, True, 3, 12, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12, 'f': 3}}, [{'b': 'e', 'c': 'f'}, 0, True, 6, 21, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'c': 'e'}, 1, False, 9, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'd'}, 2, False, 6, 0, ['b', 'c']])], 4: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 8, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'b': 'd'}, 0, True, 4, 16, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16, 'f': 4}}, [{'b': 'e', 'c': 'f'}, 0, True, 8, 28, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'c': 'e'}, 1, False, 12, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'd'}, 2, False, 8, 0, ['b', 'c']])], 5: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 10, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'b': 'd'}, 0, True, 5, 20, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20, 'f': 5}}, [{'b': 'e', 'c': 'f'}, 0, True, 10, 35, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'c': 'e'}, 1, False, 15, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'd'}, 2, False, 10, 0, ['b', 'c']])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), 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)

prompt:
The tab workspace reports an incorrect document close eligibility.

Several tab views may share one document. Closing one view releases only its view resources and closes document resources only when no other view references that document.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    r0 = {v:d for v,d in x['views'].items() if v!=x['closing']}
    r1 = sum(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r2 = not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r3 = sum(x['subscriptions'].values())
    r4 = x['document_handles'][x['views'][x['closing']]] if not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items()) else 0
    r5 = [v for v,d in x['views'].items() if v!=x['closing'] and d==x['views'][x['closing']]]
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 2, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'b': 'd'}, 0, True, 1, 4, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4, 'f': 1}}, [{'b': 'e', 'c': 'f'}, 0, True, 2, 7, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'c': 'e'}, 1, False, 3, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'd'}, 2, False, 2, 0, ['b', 'c']])], 2: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 4, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'b': 'd'}, 0, True, 2, 8, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8, 'f': 2}}, [{'b': 'e', 'c': 'f'}, 0, True, 4, 14, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'c': 'e'}, 1, False, 6, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'd'}, 2, False, 4, 0, ['b', 'c']])], 3: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 6, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'b': 'd'}, 0, True, 3, 12, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12, 'f': 3}}, [{'b': 'e', 'c': 'f'}, 0, True, 6, 21, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'c': 'e'}, 1, False, 9, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'd'}, 2, False, 6, 0, ['b', 'c']])], 4: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 8, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'b': 'd'}, 0, True, 4, 16, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16, 'f': 4}}, [{'b': 'e', 'c': 'f'}, 0, True, 8, 28, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'c': 'e'}, 1, False, 12, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'd'}, 2, False, 8, 0, ['b', 'c']])], 5: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 10, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'b': 'd'}, 0, True, 5, 20, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20, 'f': 5}}, [{'b': 'e', 'c': 'f'}, 0, True, 10, 35, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'c': 'e'}, 1, False, 15, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'd'}, 2, False, 10, 0, ['b', 'c']])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    r0 = {v:d for v,d in x['views'].items() if v!=x['closing']}
    r1 = sum(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r2 = not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r3 = 0
    r4 = x['document_handles'][x['views'][x['closing']]] if not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items()) else 0
    r5 = [v for v,d in x['views'].items() if v!=x['closing'] and d==x['views'][x['closing']]]
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 2, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'b': 'd'}, 0, True, 1, 4, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4, 'f': 1}}, [{'b': 'e', 'c': 'f'}, 0, True, 2, 7, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'c': 'e'}, 1, False, 3, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'd'}, 2, False, 2, 0, ['b', 'c']])], 2: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 4, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'b': 'd'}, 0, True, 2, 8, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8, 'f': 2}}, [{'b': 'e', 'c': 'f'}, 0, True, 4, 14, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'c': 'e'}, 1, False, 6, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'd'}, 2, False, 4, 0, ['b', 'c']])], 3: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 6, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'b': 'd'}, 0, True, 3, 12, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12, 'f': 3}}, [{'b': 'e', 'c': 'f'}, 0, True, 6, 21, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'c': 'e'}, 1, False, 9, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'd'}, 2, False, 6, 0, ['b', 'c']])], 4: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 8, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'b': 'd'}, 0, True, 4, 16, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16, 'f': 4}}, [{'b': 'e', 'c': 'f'}, 0, True, 8, 28, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'c': 'e'}, 1, False, 12, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'd'}, 2, False, 8, 0, ['b', 'c']])], 5: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 10, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'b': 'd'}, 0, True, 5, 20, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20, 'f': 5}}, [{'b': 'e', 'c': 'f'}, 0, True, 10, 35, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'c': 'e'}, 1, False, 15, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'd'}, 2, False, 10, 0, ['b', 'c']])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), 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)

prompt:
The tab workspace reports an incorrect released view listeners.

Several tab views may share one document. Closing one view releases only its view resources and closes document resources only when no other view references that document.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    r0 = {v:d for v,d in x['views'].items() if v!=x['closing']}
    r1 = sum(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r2 = not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r3 = x['subscriptions'][x['closing']]
    r4 = x['document_handles'][x['views'][x['closing']]]
    r5 = [v for v,d in x['views'].items() if v!=x['closing'] and d==x['views'][x['closing']]]
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 2, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'b': 'd'}, 0, True, 1, 4, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4, 'f': 1}}, [{'b': 'e', 'c': 'f'}, 0, True, 2, 7, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'c': 'e'}, 1, False, 3, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'd'}, 2, False, 2, 0, ['b', 'c']])], 2: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 4, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'b': 'd'}, 0, True, 2, 8, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8, 'f': 2}}, [{'b': 'e', 'c': 'f'}, 0, True, 4, 14, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'c': 'e'}, 1, False, 6, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'd'}, 2, False, 4, 0, ['b', 'c']])], 3: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 6, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'b': 'd'}, 0, True, 3, 12, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12, 'f': 3}}, [{'b': 'e', 'c': 'f'}, 0, True, 6, 21, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'c': 'e'}, 1, False, 9, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'd'}, 2, False, 6, 0, ['b', 'c']])], 4: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 8, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'b': 'd'}, 0, True, 4, 16, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16, 'f': 4}}, [{'b': 'e', 'c': 'f'}, 0, True, 8, 28, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'c': 'e'}, 1, False, 12, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'd'}, 2, False, 8, 0, ['b', 'c']])], 5: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 10, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'b': 'd'}, 0, True, 5, 20, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20, 'f': 5}}, [{'b': 'e', 'c': 'f'}, 0, True, 10, 35, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'c': 'e'}, 1, False, 15, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'd'}, 2, False, 10, 0, ['b', 'c']])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    r0 = {v:d for v,d in x['views'].items() if v!=x['closing']}
    r1 = sum(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r2 = not any(v!=x['closing'] and d==x['views'][x['closing']] for v,d in x['views'].items())
    r3 = x['subscriptions'][x['closing']]
    r4 = 0
    r5 = [v for v,d in x['views'].items() if v!=x['closing'] and d==x['views'][x['closing']]]
    return [r0,r1,r2,r3,r4,r5]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 2, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'b': 'd'}, 0, True, 1, 4, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4, 'f': 1}}, [{'b': 'e', 'c': 'f'}, 0, True, 2, 7, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'a': 'd', 'c': 'e'}, 1, False, 3, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 2, 'b': 3, 'c': 1}, 'document_handles': {'d': 7, 'e': 4}}, [{'b': 'd', 'c': 'd'}, 2, False, 2, 0, ['b', 'c']])], 2: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 4, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'b': 'd'}, 0, True, 2, 8, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8, 'f': 2}}, [{'b': 'e', 'c': 'f'}, 0, True, 4, 14, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'a': 'd', 'c': 'e'}, 1, False, 6, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 4, 'b': 6, 'c': 2}, 'document_handles': {'d': 14, 'e': 8}}, [{'b': 'd', 'c': 'd'}, 2, False, 4, 0, ['b', 'c']])], 3: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 6, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'b': 'd'}, 0, True, 3, 12, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12, 'f': 3}}, [{'b': 'e', 'c': 'f'}, 0, True, 6, 21, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'a': 'd', 'c': 'e'}, 1, False, 9, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 6, 'b': 9, 'c': 3}, 'document_handles': {'d': 21, 'e': 12}}, [{'b': 'd', 'c': 'd'}, 2, False, 6, 0, ['b', 'c']])], 4: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 8, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'b': 'd'}, 0, True, 4, 16, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16, 'f': 4}}, [{'b': 'e', 'c': 'f'}, 0, True, 8, 28, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'a': 'd', 'c': 'e'}, 1, False, 12, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 8, 'b': 12, 'c': 4}, 'document_handles': {'d': 28, 'e': 16}}, [{'b': 'd', 'c': 'd'}, 2, False, 8, 0, ['b', 'c']])], 5: [({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 10, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'c', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'b': 'd'}, 0, True, 5, 20, []]), ({'views': {'a': 'd', 'b': 'e', 'c': 'f'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20, 'f': 5}}, [{'b': 'e', 'c': 'f'}, 0, True, 10, 35, []]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'a', 'subscriptions': {'a': 0, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'e'}, 1, False, 0, 0, ['b']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'e'}, 'closing': 'b', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'a': 'd', 'c': 'e'}, 1, False, 15, 0, ['a']]), ({'views': {'a': 'd', 'b': 'd', 'c': 'd'}, 'closing': 'a', 'subscriptions': {'a': 10, 'b': 15, 'c': 5}, 'document_handles': {'d': 35, 'e': 20}}, [{'b': 'd', 'c': 'd'}, 2, False, 10, 0, ['b', 'c']])]}
for i, (inputs, expected) in enumerate(fixtures[N]):
    check("workspace regression "+str(i), solve(inputs), 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)

prompt:
The tab workspace reports an incorrect released document handles.

Several tab views may share one document. Closing one view releases only its view resources and closes document resources only when no other view references that document.

split: open-access