test(benchmarks): add A/B task fixtures with hidden checks
Ten small Python tasks, each failing on the fixture and passing with a reference solution, including workflow expectations for a small change, a bugfix, and a delegable change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b8fd66ce3b
commit
3480072ed7
60 files changed
+374
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,16 @@
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from app.report import cost_report, sales_report
|
||||
|
||||
ROWS = [(' widgets ', 1234.5), ('gadgets', 99)]
|
||||
EXPECTED = 'Widgets 1,234.50\nGadgets 99.00\nTotal 1,333.50'
|
||||
|
||||
|
||||
class Hidden(unittest.TestCase):
|
||||
def test_output(self):
|
||||
self.assertEqual(sales_report(ROWS), EXPECTED)
|
||||
self.assertEqual(cost_report(ROWS), EXPECTED)
|
||||
self.assertEqual(sales_report([]), f"{'Total':<20}{0:>12,.2f}")
|
||||
|
||||
def test_deduplicated(self):
|
||||
self.assertEqual(Path('app/report.py').read_text().count('.title()'), 1)
|
||||
Whitespace-only changes.
@@ -0,0 +1,20 @@
|
||||
def sales_report(rows):
|
||||
lines = []
|
||||
for name, amount in rows:
|
||||
label = name.strip().title()
|
||||
value = f"{amount:,.2f}"
|
||||
lines.append(f"{label:<20}{value:>12}")
|
||||
total = sum(amount for _, amount in rows)
|
||||
lines.append(f"{'Total':<20}{total:>12,.2f}")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def cost_report(rows):
|
||||
lines = []
|
||||
for name, amount in rows:
|
||||
label = name.strip().title()
|
||||
value = f"{amount:,.2f}"
|
||||
lines.append(f"{label:<20}{value:>12}")
|
||||
total = sum(amount for _, amount in rows)
|
||||
lines.append(f"{'Total':<20}{total:>12,.2f}")
|
||||
return "\n".join(lines)
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"prompt": "Remove the duplicated formatting logic in app/report.py without changing its output.",
|
||||
"workflow": {
|
||||
"kind": "behavior-preserving refactor"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user