-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsimplify-named-let-initialization-test.rkt
More file actions
52 lines (43 loc) · 1.06 KB
/
simplify-named-let-initialization-test.rkt
File metadata and controls
52 lines (43 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#lang resyntax/test
require: resyntax/default-recommendations simplify-named-let-initialization
header:
--------------------
#lang racket
(define (a) 1)
(define (b) 2)
(define (c) 3)
--------------------
test: "original code should be refactorable to new code"
--------------------
(define (f a b c)
(let loop ([x (+ 1 2 3)]
[y (if (a)
(b)
(c))])
(loop x y)))
====================
(define (f a b c)
(define init-y
(if (a)
(b)
(c)))
(let loop ([x (+ 1 2 3)]
[y init-y])
(loop x y)))
--------------------
no-change-test: "code not refactorable when side-effecting expression is present"
--------------------
(define (f a b c)
(let loop ([x (displayln "foo")]
[y (if (a)
(b)
(c))])
(loop x y)))
--------------------
no-change-test: "code not refactorable when all expressions are single-line"
--------------------
(define (f a b c)
(let loop ([x (+ 1 2 3)]
[y 42])
(loop x y)))
--------------------