Skip to content

Commit a49b826

Browse files
committed
Better tests
1 parent be6cc64 commit a49b826

File tree

8 files changed

+123
-17
lines changed

8 files changed

+123
-17
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ classifiers = [
2222
]
2323
keywords = ["cedarscript", "code-editing", "refactoring", "code-analysis", "sql-like", "ai-assisted-development"]
2424
dependencies = [
25-
"cedarscript-ast-parser>=0.5.1",
25+
"cedarscript-ast-parser>=0.5.2",
2626
"grep-ast==0.3.3",
2727
"tree-sitter-languages==1.10.2",
2828
]

tests/corpus/.refactoring-benchmark/chat.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,32 @@ POSTPONED =- [-4 -> -3] ( -------------------) (++++++++++++++++++++) codeeditor
4545
=- [-4 -> -3] ( -------------------) (++++++++++++++++++++) symbolic_shapes_ShapeEnv_bind_symbols
4646
=- [-4 -> -3] ( -----------------) (+++++++++++++ ) text_CountVectorizer__limit_features
4747

48+
--
49+
50+
- dirname: 2024-11-04-06-01-55--gemini-1.5-flash-refactoring-cedarscript-i1.1.3-e1.1.7
51+
test_cases: 89
52+
model: gemini/gemini-1.5-flash-latest
53+
edit_format: cedarscript
54+
commit_hash: 82ac553
55+
pass_rate_1: 84.3
56+
pass_rate_2: 84.3
57+
pass_rate_3: 85.4
58+
percent_cases_well_formed: 93.3
59+
error_outputs: 134
60+
num_malformed_responses: 28
61+
num_with_malformed_responses: 6
62+
user_asks: 35
63+
lazy_comments: 0
64+
syntax_errors: 6
65+
indentation_errors: 3
66+
exhausted_context_windows: 0
67+
test_timeouts: 0
68+
command: aider --model gemini/gemini-1.5-flash-latest
69+
date: 2024-11-04
70+
versions: 0.60.2.dev
71+
seconds_per_case: 17.1
72+
total_cost: 0.6229
73+
4874
</report>
4975

5076
<no-train>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<no-train>
2+
```CEDARScript
3+
UPDATE METHOD "Luhn.__init__"
4+
FROM FILE "luhn.py"
5+
REPLACE BODY
6+
WITH CONTENT r'''
7+
self.card_num = card_num.replace(" ", "")
8+
''';
9+
10+
UPDATE METHOD "Luhn.valid"
11+
FROM FILE "luhn.py"
12+
REPLACE BODY
13+
WITH CONTENT r'''
14+
if len(self.card_num) <= 1:
15+
if 1 < 1
16+
if 1 < 1:
17+
return True
18+
return False
19+
# \x
20+
return checksum % 10 == 0
21+
''';
22+
```
23+
24+
```CEDARScript
25+
UPDATE METHOD "Luhn.__init__"
26+
FROM FILE "luhn2.py"
27+
REPLACE BODY
28+
WITH CONTENT r'''
29+
@0:self.card_num = card_num.replace(" ", "")
30+
''';
31+
32+
UPDATE METHOD "Luhn.valid"
33+
FROM FILE "luhn2.py"
34+
REPLACE BODY
35+
WITH CONTENT r'''
36+
@0:if len(self.card_num) <= 1:
37+
@1:if 1 < 1
38+
@2:if 1 < 1:
39+
@3:return True
40+
@1:return False
41+
@1:# \x
42+
@0:return checksum % 10 == 0
43+
''';
44+
45+
```
46+
47+
</no-train>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class A:
2+
class Luhn:
3+
def __init__(self, card_num):
4+
self.card_num = card_num.replace(" ", "")
5+
6+
def valid(self):
7+
if len(self.card_num) <= 1:
8+
if 1 < 1
9+
if 1 < 1:
10+
return True
11+
return False
12+
# \x
13+
return checksum % 10 == 0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class A:
2+
class Luhn:
3+
def __init__(self, card_num):
4+
self.card_num = card_num.replace(" ", "")
5+
6+
def valid(self):
7+
if len(self.card_num) <= 1:
8+
if 1 < 1
9+
if 1 < 1:
10+
return True
11+
return False
12+
# \x
13+
return checksum % 10 == 0
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class A:
2+
class Luhn:
3+
def __init__(self, card_num):
4+
pass
5+
6+
def valid(self):
7+
pass

tests/corpus/refactor-benchmark.indentation-size-discovery/base.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ def load_middleware(self, is_async=False):
102102
self._middleware_chain = handler
103103

104104
def adapt_method_mode(
105-
self,
106-
is_async,
107-
method,
108-
method_is_async=None,
109-
debug=False,
110-
name=None,
105+
self,
106+
is_async,
107+
method,
108+
method_is_async=None,
109+
debug=False,
110+
name=None,
111111
):
112112
"""
113113
Adapt a method to be in the correct "mode":
@@ -214,7 +214,7 @@ def _get_response(self, request):
214214
response,
215215
middleware_method,
216216
name="%s.process_template_response"
217-
% (middleware_method.__self__.__class__.__name__,),
217+
% (middleware_method.__self__.__class__.__name__,),
218218
)
219219
try:
220220
response = response.render()
@@ -275,7 +275,7 @@ async def _get_response_async(self, request):
275275
response,
276276
middleware_method,
277277
name="%s.process_template_response"
278-
% (middleware_method.__self__.__class__.__name__,),
278+
% (middleware_method.__self__.__class__.__name__,),
279279
)
280280
try:
281281
if asyncio.iscoroutinefunction(response.render):

tests/corpus/refactor-benchmark.indentation-size-discovery/expected.base.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919

2020
def adapt_method_mode(
21-
self,
22-
is_async,
23-
method,
24-
method_is_async=None,
25-
debug=False,
26-
name=None,
21+
self,
22+
is_async,
23+
method,
24+
method_is_async=None,
25+
debug=False,
26+
name=None,
2727
):
2828
"""
2929
Adapt a method to be in the correct "mode":
@@ -214,7 +214,7 @@ def _get_response(self, request):
214214
response,
215215
middleware_method,
216216
name="%s.process_template_response"
217-
% (middleware_method.__self__.__class__.__name__,),
217+
% (middleware_method.__self__.__class__.__name__,),
218218
)
219219
try:
220220
response = response.render()
@@ -275,7 +275,7 @@ async def _get_response_async(self, request):
275275
response,
276276
middleware_method,
277277
name="%s.process_template_response"
278-
% (middleware_method.__self__.__class__.__name__,),
278+
% (middleware_method.__self__.__class__.__name__,),
279279
)
280280
try:
281281
if asyncio.iscoroutinefunction(response.render):

0 commit comments

Comments
 (0)