Skip to content

Commit 5176599

Browse files
Copilotjackfirth
andauthored
Move formatting preservation tests to rule-specific test files (#677)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jackfirth <[email protected]>
1 parent bddaa02 commit 5176599

File tree

4 files changed

+63
-71
lines changed

4 files changed

+63
-71
lines changed

default-recommendations/boolean-shortcuts-test.rkt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ test: "nested ands interspersed with ors can be flattened"
7070
- (and 1 2 (or 3 4) 5 6)
7171

7272

73+
test: "refactoring an expression doesn't affect formatting of unrefactored code"
74+
----------------------------------------
75+
( displayln "foo" )
76+
(or 1 (or 2 3))
77+
( displayln "bar" )
78+
========================================
79+
( displayln "foo" )
80+
(or 1 2 3)
81+
( displayln "bar" )
82+
----------------------------------------
83+
84+
7385
test: "using if to convert a boolean expression to a boolean can be removed"
7486
- (if (string? "foo") #true #false)
7587
- (string? "foo")

default-recommendations/formatting-preservation-test.rkt

Lines changed: 0 additions & 71 deletions
This file was deleted.

default-recommendations/let-replacement/cond-let-replacement-test.rkt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,25 @@ no-change-test: "and with more than two arguments should not be refactored"
297297
(and 'some-condition 'another-condition (let ([x 42]) (* x 2)))
298298
------------------------------
299299

300+
301+
test: "cond-let-to-cond-define doesn't reformat the entire cond expression"
302+
----------------------------------------
303+
(define (f c1 c2)
304+
(cond
305+
[c1 ( displayln "foo" )]
306+
[c2
307+
( displayln "bar" )
308+
(let ([x 1])
309+
(* x 2))]
310+
[else ( displayln "else" )]))
311+
========================================
312+
(define (f c1 c2)
313+
(cond
314+
[c1 ( displayln "foo" )]
315+
[c2
316+
( displayln "bar" )
317+
(define x 1)
318+
(* x 2)]
319+
[else ( displayln "else" )]))
320+
----------------------------------------
321+

default-recommendations/let-replacement/let-replacement-test.rkt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,3 +625,32 @@ test: "let binding with body nested in begin0 extractable to definition and body
625625
(displayln "bar")))
626626
------------------------------
627627

628+
629+
test: "let-to-define doesn't reformat the entire definition context"
630+
----------------------------------------
631+
(define (f)
632+
( displayln "foo" )
633+
(let ([x 1])
634+
(* x 2)))
635+
========================================
636+
(define (f)
637+
( displayln "foo" )
638+
(define x 1)
639+
(* x 2))
640+
----------------------------------------
641+
642+
643+
test: "define-let-to-double-define doesn't reformat the entire definition context"
644+
----------------------------------------
645+
(define (f)
646+
( displayln "foo" )
647+
(define y (let ([x 1]) (* x 2)))
648+
( displayln "bar" ))
649+
========================================
650+
(define (f)
651+
( displayln "foo" )
652+
(define x 1)
653+
(define y (* x 2))
654+
( displayln "bar" ))
655+
----------------------------------------
656+

0 commit comments

Comments
 (0)