真实离线执行 · 人工参考修复

Cline 代码重构教程:提取重复函数与行为回归

修改前后 diff

--- a/app.py
+++ b/app.py
@@ -1,5 +1,8 @@
+def _total(price, shipping, discount):
+    return round(price * discount + shipping, 2)
+
 def guest_total(price, shipping):
-    return round(price + shipping, 2)
+    return _total(price, shipping, 1)
 
 def member_total(price, shipping):
-    return round(price * 0.9 + shipping, 2)
+    return _total(price, shipping, 0.9)

真实测试记录

before exit=0\ntest_contract (test_app.LessonTest.test_contract) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
\nfixed exit=0\ntest_contract (test_app.LessonTest.test_contract) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

标准库测试真实运行;参考代码人工编写,未执行 Cline 或付费模型。