@@ -698,260 +698,6 @@ test: "if clause with begin in false branch and commented true branch refactorab
698698------------------------------
699699
700700
701- test: "if clause with let in true branch refactorable to cond "
702- ------------------------------
703- (define (f a b)
704- (if a
705- (let ([x 1 ])
706- x)
707- b))
708- ==============================
709- (define (f a b)
710- (cond
711- [a
712- (define x 1 )
713- x]
714- [else b]))
715- ------------------------------
716-
717-
718- test: "if clause with let in false branch refactorable to cond "
719- ------------------------------
720- (define (f a b)
721- (if a
722- b
723- (let ([x 1 ])
724- x)))
725- ==============================
726- (define (f a b)
727- (cond
728- [a b]
729- [else
730- (define x 1 )
731- x]))
732- ------------------------------
733-
734-
735- test: "if clause with let in both branches refactorable to cond "
736- ------------------------------
737- (define (f a)
738- (if a
739- (let ([x 1 ])
740- x)
741- (let ([x 1 ])
742- x)))
743- ==============================
744- (define (f a)
745- (cond
746- [a
747- (define x 1 )
748- x]
749- [else
750- (define x 1 )
751- x]))
752- ------------------------------
753-
754-
755- test: "if clause with multiline condition and let in true branch refactorable to cond "
756- ------------------------------
757- (define (f a b)
758- (if (a 10000000000000000000000000000000000000
759- 20000000000000000000000000000000000000
760- 30000000000000000000000000000000000000 )
761- (let ([x 1 ])
762- x)
763- b))
764- ==============================
765- (define (f a b)
766- (cond
767- [(a 10000000000000000000000000000000000000
768- 20000000000000000000000000000000000000
769- 30000000000000000000000000000000000000 )
770- (define x 1 )
771- x]
772- [else b]))
773- ------------------------------
774-
775-
776- test: "if clause with multiline condition and let in false branch refactorable to cond "
777- ------------------------------
778- (define (f a b)
779- (if (a 10000000000000000000000000000000000000
780- 20000000000000000000000000000000000000
781- 30000000000000000000000000000000000000 )
782- b
783- (let ([x 1 ])
784- x)))
785- ==============================
786- (define (f a b)
787- (cond
788- [(a 10000000000000000000000000000000000000
789- 20000000000000000000000000000000000000
790- 30000000000000000000000000000000000000 )
791- b]
792- [else
793- (define x 1 )
794- x]))
795- ------------------------------
796-
797-
798- test: "if clause with multiline condition and let in both branches refactorable to cond "
799- ------------------------------
800- (define (f a)
801- (if (a 10000000000000000000000000000000000000
802- 20000000000000000000000000000000000000
803- 30000000000000000000000000000000000000 )
804- (let ([x 1 ])
805- x)
806- (let ([x 1 ])
807- x)))
808- ==============================
809- (define (f a)
810- (cond
811- [(a 10000000000000000000000000000000000000
812- 20000000000000000000000000000000000000
813- 30000000000000000000000000000000000000 )
814- (define x 1 )
815- x]
816- [else
817- (define x 1 )
818- x]))
819- ------------------------------
820-
821-
822- test: "if clause with let in commented true branch refactorable to cond "
823- ------------------------------
824- (define (f a b)
825- (if a
826- ;; This is the true case
827- (let ([x 1 ])
828- x)
829- b))
830- ==============================
831- (define (f a b)
832- (cond
833- [a
834- ;; This is the true case
835- (define x 1 )
836- x]
837- [else b]))
838- ------------------------------
839-
840-
841- test: "if clause with let in commented false branch refactorable to cond "
842- ------------------------------
843- (define (f a b)
844- (if a
845- b
846- ;; This is the false case
847- (let ([x 1 ])
848- x)))
849- ==============================
850- (define (f a b)
851- (cond
852- [a b]
853- ;; This is the false case
854- [else
855- (define x 1 )
856- x]))
857- ------------------------------
858-
859-
860- test: "if clause with let in both commented branches refactorable to cond "
861- ------------------------------
862- (define (f a)
863- (if a
864- ;; This is the true case
865- (let ([x 1 ])
866- x)
867- ;; This is the false case
868- (let ([x 1 ])
869- x)))
870- ==============================
871- (define (f a)
872- (cond
873- [a
874- ;; This is the true case
875- (define x 1 )
876- x]
877- ;; This is the false case
878- [else
879- (define x 1 )
880- x]))
881- ------------------------------
882-
883-
884-
885- test: "if clause with let in true branch and commented false branch refactorable to cond "
886- ------------------------------
887- (define (f a b)
888- (if a
889- (let ([x 1 ])
890- x)
891- ;; This is the false case
892- b))
893- ==============================
894- (define (f a b)
895- (cond
896- [a
897- (define x 1 )
898- x]
899- ;; This is the false case
900- [else b]))
901- ------------------------------
902-
903-
904- test: "if clause with let in false branch and commented true branch refactorable to cond "
905- ------------------------------
906- (define (f a b)
907- (if a
908- ;; This is the true case
909- b
910- (let ([x 1 ])
911- x)))
912- ==============================
913- (define (f a b)
914- (cond
915- ;; This is the true case
916- [a b]
917- [else
918- (define x 1 )
919- x]))
920- ------------------------------
921-
922-
923- test: "and with let can be refactored to cond with define "
924- ------------------------------
925- (and 'some-condition
926- (let ([x 42 ])
927- (* x 2 )))
928- ==============================
929- (cond
930- ['some-condition
931- (define x 42 )
932- (* x 2 )]
933- [else #f ])
934- ------------------------------
935-
936-
937- no-change-test: "and without let should not be refactored "
938- ------------------------------
939- (and 'some-condition (* 42 2 ))
940- ------------------------------
941-
942-
943- no-change-test: "and with empty let should not be refactored "
944- ------------------------------
945- (and 'some-condition (let () (* 42 2 )))
946- ------------------------------
947-
948-
949- no-change-test: "and with more than two arguments should not be refactored "
950- ------------------------------
951- (and 'some-condition 'another-condition (let ([x 42 ]) (* x 2 )))
952- ------------------------------
953-
954-
955701test: "immediately-nested when expressions can be merged "
956702--------------------
957703(define (f c1 c2)
0 commit comments