Skip to content

Commit

Permalink
Automated Resyntax fixes (#681)
Browse files Browse the repository at this point in the history
This is an automated change generated by Resyntax.

#### Pass 1

Applied 1 fix to [`drracket-test/tests/drracket/repl-test-raw.rkt`](../blob/HEAD/drracket-test/tests/drracket/repl-test-raw.rkt)

  * Line 2, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.

Applied 4 fixes to [`drracket-test/tests/drracket/populate-compiled.rkt`](../blob/HEAD/drracket-test/tests/drracket/populate-compiled.rkt)

  * Line 2, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.
  * Line 12, `make-temporary-directory-migration`: Use `make-temporary-directory` to make directories instead of `make-temporary-file`.
  * Line 82, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.
  * Line 97, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.

Applied 3 fixes to [`drracket/drracket/private/honu-logo.rkt`](../blob/HEAD/drracket/drracket/private/honu-logo.rkt)

  * Line 12, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.
  * Line 18, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions (including function-returning functions).
  * Line 131, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting.

Applied 1 fix to [`drracket-test/tests/drracket/module-browser.rkt`](../blob/HEAD/drracket-test/tests/drracket/module-browser.rkt)

  * Line 2, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.

Applied 1 fix to [`drracket/drracket/syncheck-drracket-button.rkt`](../blob/HEAD/drracket/drracket/syncheck-drracket-button.rkt)

  * Line 2, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files.

## Summary

Fixed 10 issues in 5 files.

  * Fixed 5 occurrences of `tidy-require`
  * Fixed 3 occurrences of `let-to-define`
  * Fixed 1 occurrence of `make-temporary-directory-migration`
  * Fixed 1 occurrence of `define-lambda-to-define`

Co-authored-by: GitHub Actions <[email protected]>
  • Loading branch information
github-actions[bot] and actions-user authored Sep 20, 2024
1 parent 582b84f commit 34bf9de
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 111 deletions.
4 changes: 2 additions & 2 deletions drracket-test/tests/drracket/module-browser.rkt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#lang racket/base
(require racket/unit
(require drracket/private/standalone-module-browser
racket/async-channel
drracket/private/standalone-module-browser
racket/unit
rackunit)

(define (fetch-files stx/fn)
Expand Down
98 changes: 47 additions & 51 deletions drracket-test/tests/drracket/populate-compiled.rkt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#lang racket/base
(require racket/file
racket/system
compiler/find-exe
pkg/lib)
(require compiler/find-exe
pkg/lib
racket/file
racket/system)

(module test racket/base) ; disable for DrDr

(unless (eq? 'user (default-pkg-scope))
(error "Run this test with `user' default package scope"))

(define dir (make-temporary-file "~a" 'directory))
(define dir (make-temporary-directory "~a"))
(define pkg-dir (build-path dir "popcomp-pkg"))
(define coll-dir (build-path pkg-dir "popcomp"))
(define pkg2-dir (build-path dir "popcomp2-pkg"))
Expand Down Expand Up @@ -79,12 +79,12 @@
;; ----------------------------------------

(module go racket/base
(require "private/drracket-test-util.rkt"
racket/gui/base
(require framework/test
racket/class
racket/path
racket/file
framework/test)
racket/gui/base
racket/path
"private/drracket-test-util.rkt")

(define (check-compiled compiled? path)
(unless (equal? compiled? (file-exists? path))
Expand All @@ -95,59 +95,55 @@

(fire-up-drracket-and-run-tests
(λ ()
(let ([drs (wait-for-drracket-frame)])
(define x (vector-ref (current-command-line-arguments) 0))
(define dir (path-only x))

(do-execute drs)
(define drs (wait-for-drracket-frame))
(define x (vector-ref (current-command-line-arguments) 0))
(define dir (path-only x))

(do-execute drs)

(define popcomp-main-zo
(build-path dir "popcomp-pkg" "popcomp" "compiled" "drracket" "errortrace" "main_rkt.zo"))
(define popcomp2-main-zo
(build-path dir "popcomp2-pkg" "popcomp2" "compiled" "drracket" "errortrace" "main_rkt.zo"))

(define popcomp-main-zo
(build-path dir "popcomp-pkg" "popcomp" "compiled" "drracket" "errortrace" "main_rkt.zo"))
(define popcomp2-main-zo
(build-path dir "popcomp2-pkg" "popcomp2" "compiled" "drracket" "errortrace" "main_rkt.zo"))
(check-compiled #t (build-path dir "compiled" "drracket" "errortrace" "y_rkt.zo"))
(check-compiled #f popcomp-main-zo)
(check-compiled #f popcomp2-main-zo)

(check-compiled #t (build-path dir "compiled" "drracket" "errortrace" "y_rkt.zo"))
(check-compiled #f popcomp-main-zo)
(check-compiled #f popcomp2-main-zo)
;; Create a broken ".zo" file where it should not be used:
(make-directory* (path-only popcomp-main-zo))
(call-with-output-file* popcomp-main-zo (lambda (o) (fprintf o "broken\n")))

;; Create a broken ".zo" file where it should not be used:
(make-directory* (path-only popcomp-main-zo))
(call-with-output-file*
popcomp-main-zo
(lambda (o)
(fprintf o "broken\n")))
(do-execute drs)
(let* ([got (fetch-output drs)])
(unless (string=? "" got)
(error 'check-output "wrong output: ~s" got)))

(do-execute drs)
(let* ([got (fetch-output drs)])
(unless (string=? "" got)
(error 'check-output "wrong output: ~s" got)))
(delete-file popcomp-main-zo)

(delete-file popcomp-main-zo)
;; Open "main.rkt" in "popcomp-pkg", so now it should be compiled
;; when we run "x.rkt":

;; Open "main.rkt" in "popcomp-pkg", so now it should be compiled
;; when we run "x.rkt":
(test:menu-select "File" "New Tab")
(use-get/put-dialog (λ () (test:menu-select "File" "Open…"))
(build-path dir "popcomp-pkg" "popcomp" "main.rkt"))

(test:menu-select "File" "New Tab")
(use-get/put-dialog (λ ()
(test:menu-select "File" "Open…"))
(build-path dir "popcomp-pkg" "popcomp" "main.rkt"))
(queue-callback/res (λ () (send drs change-to-tab (car (send drs get-tabs)))))

(queue-callback/res (λ () (send drs change-to-tab (car (send drs get-tabs)))))
(do-execute drs)

(do-execute drs)
(check-compiled #t popcomp-main-zo)
(check-compiled #f popcomp2-main-zo)

(check-compiled #t popcomp-main-zo)
(check-compiled #f popcomp2-main-zo)
;; But if the "popcomp-pkg" directory is not writable, then
;; don't compile after all:

;; But if the "popcomp-pkg" directory is not writable, then
;; don't compile after all:
(delete-file popcomp-main-zo)
(file-or-directory-permissions (build-path dir "popcomp-pkg") #o555)

(delete-file popcomp-main-zo)
(file-or-directory-permissions (build-path dir "popcomp-pkg") #o555)

(do-execute drs)
(do-execute drs)

(check-compiled #f popcomp-main-zo)
(check-compiled #f popcomp2-main-zo)
(check-compiled #f popcomp-main-zo)
(check-compiled #f popcomp2-main-zo)

(file-or-directory-permissions (build-path dir "popcomp-pkg") #o777)))))
(file-or-directory-permissions (build-path dir "popcomp-pkg") #o777))))
3 changes: 2 additions & 1 deletion drracket-test/tests/drracket/repl-test-raw.rkt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#lang racket/base
(require "private/repl-test.rkt" "private/drracket-test-util.rkt")
(require "private/drracket-test-util.rkt"
"private/repl-test.rkt")
(fire-up-drracket-and-run-tests (λ () (run-test '(raw))))

(module+ test
Expand Down
98 changes: 44 additions & 54 deletions drracket/drracket/private/honu-logo.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,41 @@
(define body-path (make-object dc-path%))

(define (find-arc-spot x y w h end)
(let ([ce (cos end)]
[se (- (sin end))])
(values (+ x (* w 1/2) (* w 1/2 ce))
(+ y (* h 1/2) (* h 1/2 se)))))

(define weighted-arc
(lambda (path x y w h start end ccw? [dx1 0.0] [dy1 0.2] [dx2 dx1] [dy2 (- dy1)])
(let ([sweep (let loop ([s (if ccw? (- end start) (- start end))])
(if (< s 0)
(loop (+ s (* 2 pi)))
s))])
(if (> sweep pi)
(let ([halfway ((if ccw? + -) start (/ sweep 2))])
(weighted-arc path x y w h start halfway ccw? dx1 dy1 dx2 dy2)
(weighted-arc path x y w h halfway end ccw? dx2 (- dy2) dx1 (- dy1)))
(let ([p (new dc-path%)])
;; Set p to be the arc for a unit circle,
;; centered on the X-axis:
(let* ([x0 (cos (/ sweep 2))]
[y0 (sin (/ sweep 2))]
[x1 (/ (- 4 x0) 3)]
[y1 (/ (* (- 1 x0) (- 3 x0)) (* 3 y0))]
[x2 x1]
[y2 (- y1)]
[x3 x0]
[y3 (- y0)]
[sw (/ w 2)]
[sh (/ h 2)])
(send p move-to x0 y0)
(send p curve-to
(+ x1 dx1) (+ y1 dy1)
(+ x2 dx2) (+ y2 dy2)
x3 y3)
;; Rotate to match start:
(send p rotate (+ (if ccw? start end) (/ sweep 2)))
;; Scale to match width and height:
(send p scale (/ w 2) (/ h 2))
;; Translate to match x and y
(send p translate (+ x (/ w 2)) (+ y (/ h 2)))
(unless ccw?
(send p reverse)))
(send path append p))))))
(define ce (cos end))
(define se (- (sin end)))
(values (+ x (* w 1/2) (* w 1/2 ce)) (+ y (* h 1/2) (* h 1/2 se))))

(define (weighted-arc path x y w h start end ccw? [dx1 0.0] [dy1 0.2] [dx2 dx1] [dy2 (- dy1)])
(let ([sweep (let loop ([s (if ccw? (- end start) (- start end))])
(if (< s 0) (loop (+ s (* 2 pi))) s))])
(if (> sweep pi)
(let ([halfway ((if ccw? + -) start (/ sweep 2))])
(weighted-arc path x y w h start halfway ccw? dx1 dy1 dx2 dy2)
(weighted-arc path x y w h halfway end ccw? dx2 (- dy2) dx1 (- dy1)))
(let ([p (new dc-path%)])
;; Set p to be the arc for a unit circle,
;; centered on the X-axis:
(let* ([x0 (cos (/ sweep 2))]
[y0 (sin (/ sweep 2))]
[x1 (/ (- 4 x0) 3)]
[y1 (/ (* (- 1 x0) (- 3 x0)) (* 3 y0))]
[x2 x1]
[y2 (- y1)]
[x3 x0]
[y3 (- y0)]
[sw (/ w 2)]
[sh (/ h 2)])
(send p move-to x0 y0)
(send p curve-to (+ x1 dx1) (+ y1 dy1) (+ x2 dx2) (+ y2 dy2) x3 y3)
;; Rotate to match start:
(send p rotate (+ (if ccw? start end) (/ sweep 2)))
;; Scale to match width and height:
(send p scale (/ w 2) (/ h 2))
;; Translate to match x and y
(send p translate (+ x (/ w 2)) (+ y (/ h 2)))
(unless ccw?
(send p reverse)))
(send path append p)))))

(define overall-rotation (- (* pi 1/2 3/8)))

Expand Down Expand Up @@ -129,18 +122,15 @@
(+ (* pi 3/2) angle-offset)))

(define (add-big-fin-top add)
(let ([fin-width (- big-fin-right-edge big-fin-top-x)])
(add big-fin-top-x
big-fin-top-y

(+ big-fin-top-x (* 1/3 fin-width))
big-fin-curve-top-offset

(+ big-fin-top-x (* 2/3 fin-width))
big-fin-curve-top-offset

big-fin-right-edge
(+ big-fin-bottom-y 10))))
(define fin-width (- big-fin-right-edge big-fin-top-x))
(add big-fin-top-x
big-fin-top-y
(+ big-fin-top-x (* 1/3 fin-width))
big-fin-curve-top-offset
(+ big-fin-top-x (* 2/3 fin-width))
big-fin-curve-top-offset
big-fin-right-edge
(+ big-fin-bottom-y 10)))

(define (add-big-fin-bottom add)
(let ([fin-width (- big-fin-right-edge big-fin-bottom-x)])
Expand Down
6 changes: 3 additions & 3 deletions drracket/drracket/syncheck-drracket-button.rkt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#lang racket/base
(require racket/class
string-constants/string-constant
(require (for-syntax images/icons/style images/icons/tool racket/base)
images/compile-time
(for-syntax racket/base images/icons/tool images/icons/style))
racket/class
string-constants/string-constant)
(provide syncheck-drracket-button
syncheck-bitmap
syncheck-small-bitmap
Expand Down

0 comments on commit 34bf9de

Please sign in to comment.