From c255eaf597521ffead871c51dcd7447670287e52 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 21 Sep 2025 00:21:06 +0000 Subject: [PATCH 1/9] Fix 2 occurrences of `nested-and-to-flat-and` Nested `and` expressions can be flattened into a single, equivalent `and` expression. --- drracket-test/tests/drracket/private/drracket-test-util.rkt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drracket-test/tests/drracket/private/drracket-test-util.rkt b/drracket-test/tests/drracket/private/drracket-test-util.rkt index e4821533d..2e2355465 100644 --- a/drracket-test/tests/drracket/private/drracket-test-util.rkt +++ b/drracket-test/tests/drracket/private/drracket-test-util.rkt @@ -89,7 +89,7 @@ (define (wait-for-drracket-frame [print-message? #f]) (define (wait-for-drracket-frame-pred) (define active (fw:test:get-active-top-level-window)) - (and (and active (drracket-frame? active)) active)) + (and active (drracket-frame? active) active)) (define drr-fr (or (wait-for-drracket-frame-pred) (begin @@ -112,7 +112,7 @@ (for/or ([eventspace (in-list extra-eventspaces)]) (parameterize ([current-eventspace eventspace]) (fw:test:get-active-top-level-window))))) - (and (and active (not (eq? active old-frame))) active)) + (and active (not (eq? active old-frame)) active)) (define lab (send old-frame get-label)) (define fr (poll-until (procedure-rename wait-for-new-frame-pred From ddb037820c5f7d0d100c48ed445264e5c9e90f90 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 21 Sep 2025 00:21:06 +0000 Subject: [PATCH 2/9] Fix 7 occurrences of `let-to-define` Internal definitions are recommended instead of `let` expressions, to reduce nesting. --- .../drracket/private/no-fw-test-util.rkt | 69 ++- .../tests/drracket/private/repl-test.rkt | 437 +++++++++--------- drracket/setup/plt-installer-unit.rkt | 12 +- 3 files changed, 245 insertions(+), 273 deletions(-) diff --git a/drracket-test/tests/drracket/private/no-fw-test-util.rkt b/drracket-test/tests/drracket/private/no-fw-test-util.rkt index a47a10584..53600e4b4 100644 --- a/drracket-test/tests/drracket/private/no-fw-test-util.rkt +++ b/drracket-test/tests/drracket/private/no-fw-test-util.rkt @@ -57,49 +57,46 @@ (yield (make-semaphore 0))))))) (semaphore-wait s)) -(define (use-hash-for-prefs preferences:low-level-get-preference +(define (use-hash-for-prefs preferences:low-level-get-preference preferences:low-level-put-preferences preferences:restore-defaults preferences:set preferences:default-set? prefs) - ;; change the preferences system so that it doesn't write to + ;; change the preferences system so that it doesn't write to ;; a file; partly to avoid problems of concurrency in drdr ;; but also to make the test suite easier for everyone to run. - (let ([prefs-table (make-hash)]) - (preferences:low-level-put-preferences - (λ (names vals) - (for ([name (in-list names)] - [val (in-list vals)]) - (hash-set! prefs-table name val)))) - (preferences:low-level-get-preference - (λ (name [fail (lambda () #f)]) - (hash-ref prefs-table name fail))) - - ;; set all preferences to their defaults (some pref values may have - ;; been read by this point, but hopefully that won't affect the - ;; startup of drracket) - (preferences:restore-defaults) - - ;; initialize some preferences to simulate these - ;; being saved already in the user's prefs file - ;; call preferences:set too since the prefs file - ;; may have been "read" already at this point - (for ([pref (in-list prefs)]) - (define pref-key (list-ref pref 0)) - (define pref-val (list-ref pref 1)) - (define m (regexp-match #rx"^plt:framework-pref:(.*)$" (symbol->string pref-key))) - (cond - [m - (hash-set! prefs-table pref-key pref-val) - (define fw-pref-key (string->symbol (list-ref m 1))) - (when (preferences:default-set? fw-pref-key) - (preferences:set fw-pref-key pref-val))] - [else - ;; this currently doesn't happen, and it is easy to forget - ;; that prefix, so print a message here to remind - (printf "WARNING: setting a preference that isn't set via the framework: ~s\n" - pref-key)])))) + (define prefs-table (make-hash)) + (preferences:low-level-put-preferences (λ (names vals) + (for ([name (in-list names)] + [val (in-list vals)]) + (hash-set! prefs-table name val)))) + (preferences:low-level-get-preference (λ (name [fail (lambda () #f)]) + (hash-ref prefs-table name fail))) + + ;; set all preferences to their defaults (some pref values may have + ;; been read by this point, but hopefully that won't affect the + ;; startup of drracket) + (preferences:restore-defaults) + + ;; initialize some preferences to simulate these + ;; being saved already in the user's prefs file + ;; call preferences:set too since the prefs file + ;; may have been "read" already at this point + (for ([pref (in-list prefs)]) + (define pref-key (list-ref pref 0)) + (define pref-val (list-ref pref 1)) + (define m (regexp-match #rx"^plt:framework-pref:(.*)$" (symbol->string pref-key))) + (cond + [m + (hash-set! prefs-table pref-key pref-val) + (define fw-pref-key (string->symbol (list-ref m 1))) + (when (preferences:default-set? fw-pref-key) + (preferences:set fw-pref-key pref-val))] + [else + ;; this currently doesn't happen, and it is easy to forget + ;; that prefix, so print a message here to remind + (printf "WARNING: setting a preference that isn't set via the framework: ~s\n" pref-key)]))) (define (queue-callback/res thunk) (not-on-eventspace-handler-thread diff --git a/drracket-test/tests/drracket/private/repl-test.rkt b/drracket-test/tests/drracket/private/repl-test.rkt index 1f3ec2624..250324cba 100644 --- a/drracket-test/tests/drracket/private/repl-test.rkt +++ b/drracket-test/tests/drracket/private/repl-test.rkt @@ -1047,15 +1047,15 @@ This produces an ACK message (define snip (queue-callback/res (lambda () - (let* ([start (send ints-text paragraph-start-position 2)] - ;; since the fraction is supposed to be one char wide, we just - ;; select one char, so that, if the regular number prints out, - ;; this test will fail. - [end (+ start 1)]) - (send ints-text split-snip start) - (send ints-text split-snip end) - (define snip (send ints-text find-snip start 'after)) - (and snip (send snip copy)))))) + (define start (send ints-text paragraph-start-position 2)) + ;; since the fraction is supposed to be one char wide, we just + ;; select one char, so that, if the regular number prints out, + ;; this test will fail. + (define end (+ start 1)) + (send ints-text split-snip start) + (send ints-text split-snip end) + (define snip (send ints-text find-snip start 'after)) + (and snip (send snip copy))))) (clear-definitions drr-frame) (type-in-definitions drr-frame "(+ ") (queue-callback/res @@ -1069,181 +1069,160 @@ This produces an ACK message ; results of these operations against expected results. (define ((run-single-test execute-text-start escape language-cust) in-vector) ;(printf "\n>> testing ~s\n" (test-program in-vector)) - (let* ([program (test-program in-vector)] - [execute-answer (make-execute-answer in-vector language-cust)] - [source-location (test-source-location in-vector)] - [setup (test-setup in-vector)] - [teardown (test-teardown in-vector)] - [start-line (and (pair? source-location) - (number->string (+ 1 (loc-line (car source-location)))))] - [start-col (and (pair? source-location) - (number->string (loc-col (car source-location))))] - [start-pos (and (pair? source-location) - (number->string (+ 1 (loc-offset (car source-location)))))] - [breaking-test? (test-breaking-test? in-vector)]) - - (setup) - - (clear-definitions drr-frame) - ; load contents of test-file into the REPL, recording - ; the start and end positions of the text - - (wait-for-drracket-frame) - - (cond - [(string? program) - (insert-in-definitions/newlines drr-frame program)] - [(eq? program 'fraction-sum) - (setup-fraction-sum-interactions)] - [(list? program) - (for-each - (lambda (item) - (cond - [(string? item) (insert-in-definitions/newlines drr-frame item)] - [(eq? item 'left) - (queue-callback/res - (λ () - (send defs-text - set-position - (- (send defs-text get-start-position) 1) - (- (send defs-text get-start-position) 1))))] - [(pair? item) (apply test:menu-select item)])) - program)]) - + (define program (test-program in-vector)) + (define execute-answer (make-execute-answer in-vector language-cust)) + (define source-location (test-source-location in-vector)) + (define setup (test-setup in-vector)) + (define teardown (test-teardown in-vector)) + (and (pair? source-location) (number->string (+ 1 (loc-line (car source-location))))) + (and (pair? source-location) (number->string (loc-col (car source-location)))) + (and (pair? source-location) (number->string (+ 1 (loc-offset (car source-location))))) + (define breaking-test? (test-breaking-test? in-vector)) + + (setup) + + (clear-definitions drr-frame) + ; load contents of test-file into the REPL, recording + ; the start and end positions of the text + + (wait-for-drracket-frame) + + (cond + [(string? program) (insert-in-definitions/newlines drr-frame program)] + [(eq? program 'fraction-sum) (setup-fraction-sum-interactions)] + [(list? program) + (for-each (lambda (item) + (cond + [(string? item) (insert-in-definitions/newlines drr-frame item)] + [(eq? item 'left) + (queue-callback/res (λ () + (send defs-text set-position + (- (send defs-text get-start-position) 1) + (- (send defs-text get-start-position) 1))))] + [(pair? item) (apply test:menu-select item)])) + program)]) + + (do-execute drr-frame #f) + + ;; make sure that the execute callback has really completed + ;; (is this necc w/ test:run-one below?) + (queue-callback/res void) + + (when breaking-test? + (test:run-one (λ () (send (send drr-frame get-break-button) command)))) + (wait-for-drr-frame-computation) + + (define execute-text-end (max 0 (- (get-int-pos) 1))) ;; subtract one to skip last newline + (define received-execute (fetch-output drr-frame execute-text-start execute-text-end)) + + ; check focus and selection for execute test + (case language-cust + [(raw) (void)] + [else + (define edit-target (queue-callback/res (λ () (send drr-frame get-edit-target-window)))) + (define defs-focus? (eq? edit-target defs-canvas)) + (define ints-focus? (eq? edit-target ints-canvas)) + (cond + [(eq? source-location 'dont-care) (void)] + [(eq? source-location 'definitions) + (unless defs-focus? + (eprintf "FAILED execute test for ~s\n expected definitions to have the focus\n" + program))] + [(eq? source-location 'interactions) + (unless ints-focus? + (eprintf "FAILED execute test for ~s\n expected interactions to have the focus\n" + program))] + [defs-focus? + (let ([start (car source-location)] + [finish (cdr source-location)]) + (let* ([error-ranges (queue-callback/res (λ () (send ints-text get-error-ranges)))] + [error-range (and error-ranges (not (null? error-ranges)) (car error-ranges))]) + (unless (and error-range + (= (+ (srcloc-position error-range) -1) (loc-offset start)) + (= (+ (srcloc-position error-range) -1 (srcloc-span error-range)) + (loc-offset finish))) + (eprintf "FAILED execute test for ~s\n error-range is ~s\n expected ~s\n" + program + (and error-range + (list (+ (srcloc-position error-range) -1) + (+ (srcloc-position error-range) -1 (srcloc-span error-range)))) + (list (loc-offset start) (loc-offset finish))))))])]) + + ; check text for execute test + (next-test) + (unless (cond + [(string? execute-answer) (string=? execute-answer received-execute)] + [(regexp? execute-answer) (regexp-match execute-answer received-execute)] + [else #f]) + (failure) + (eprintf "FAILED execute test for ~s (~a)\n expected: ~s\n got: ~s\n" + program + language-cust + execute-answer + received-execute)) + + (test:new-window ints-canvas) + + ; save the file so that load is in sync + (test:menu-select "File" "Save Definitions") + + ; make sure that a prompt is available at end of the REPL + (unless (queue-callback/res + (λ () + (and (char=? #\> (send ints-text get-character (- (send ints-text last-position) 2))) + (char=? #\space + (send ints-text get-character (- (send ints-text last-position) 1)))))) + (test:keystroke #\return)) + + (define (load-test short-filename load-answer) + ;; in order to erase the state in the namespace already, we clear (but don't save!) + ;; the definitions and click execute with the empty buffer + (test:new-window defs-canvas) + (test:menu-select "Edit" "Select All") + (test:menu-select "Edit" "Delete") (do-execute drr-frame #f) - - ;; make sure that the execute callback has really completed - ;; (is this necc w/ test:run-one below?) - (queue-callback/res void) - + (wait-for-drr-frame-computation) + + ;; stuff the load command into the REPL + (insert-in-interactions drr-frame (format "(load ~s)" short-filename)) + + ;; record current text position, then stuff a CR into the REPL + (define load-text-start (+ 1 (queue-callback/res (λ () (send ints-text last-position))))) + + (test:keystroke #\return) + (when breaking-test? (test:run-one (λ () (send (send drr-frame get-break-button) command)))) (wait-for-drr-frame-computation) - - (let* ([execute-text-end (max 0 (- (get-int-pos) 1))] ;; subtract one to skip last newline - [received-execute - (fetch-output drr-frame execute-text-start execute-text-end)]) - - ; check focus and selection for execute test - (case language-cust - [(raw) (void)] - [else - (define edit-target - (queue-callback/res (λ () (send drr-frame get-edit-target-window)))) - (define defs-focus? (eq? edit-target defs-canvas)) - (define ints-focus? (eq? edit-target ints-canvas)) - (cond - [(eq? source-location 'dont-care) - (void)] - [(eq? source-location 'definitions) - (unless defs-focus? - (eprintf "FAILED execute test for ~s\n expected definitions to have the focus\n" - program))] - [(eq? source-location 'interactions) - (unless ints-focus? - (eprintf "FAILED execute test for ~s\n expected interactions to have the focus\n" - program))] - [defs-focus? - (let ([start (car source-location)] - [finish (cdr source-location)]) - (let* ([error-ranges (queue-callback/res (λ () (send ints-text get-error-ranges)))] - [error-range (and error-ranges - (not (null? error-ranges)) - (car error-ranges))]) - (unless (and error-range - (= (+ (srcloc-position error-range) -1) (loc-offset start)) - (= (+ (srcloc-position error-range) -1 (srcloc-span error-range)) - (loc-offset finish))) - (eprintf "FAILED execute test for ~s\n error-range is ~s\n expected ~s\n" - program - (and error-range - (list (+ (srcloc-position error-range) -1) - (+ (srcloc-position error-range) -1 - (srcloc-span error-range)))) - (list (loc-offset start) - (loc-offset finish))))))])]) - - ; check text for execute test + + (let* ([load-text-end (- (get-int-pos) 1)] ;; subtract one to eliminate newline + [received-load (fetch-output drr-frame load-text-start load-text-end)]) + + ;; check load text (next-test) (unless (cond - [(string? execute-answer) - (string=? execute-answer received-execute)] - [(regexp? execute-answer) - (regexp-match execute-answer received-execute)] + [(string? load-answer) (string=? load-answer received-load)] + [(regexp? load-answer) (regexp-match load-answer received-load)] [else #f]) (failure) - (eprintf "FAILED execute test for ~s (~a)\n expected: ~s\n got: ~s\n" + (eprintf "FAILED load test ~a for ~s\n expected: ~s\n got: ~s\n" + short-filename program - language-cust - execute-answer received-execute)) - - (test:new-window ints-canvas) - - ; save the file so that load is in sync - (test:menu-select "File" "Save Definitions") - - ; make sure that a prompt is available at end of the REPL - (unless (queue-callback/res - (λ () - (and (char=? #\> - (send ints-text get-character - (- (send ints-text last-position) 2))) - (char=? #\space - (send ints-text get-character - (- (send ints-text last-position) 1)))))) - (test:keystroke #\return)) - - (define (load-test short-filename load-answer) - ;; in order to erase the state in the namespace already, we clear (but don't save!) - ;; the definitions and click execute with the empty buffer - (test:new-window defs-canvas) - (test:menu-select "Edit" "Select All") - (test:menu-select "Edit" "Delete") - (do-execute drr-frame #f) - (wait-for-drr-frame-computation) - - ;; stuff the load command into the REPL - (insert-in-interactions drr-frame (format "(load ~s)" short-filename)) - - ;; record current text position, then stuff a CR into the REPL - (define load-text-start - (+ 1 (queue-callback/res (λ () (send ints-text last-position))))) - - (test:keystroke #\return) - - (when breaking-test? - (test:run-one (λ () (send (send drr-frame get-break-button) command)))) - (wait-for-drr-frame-computation) - - (let* ([load-text-end (- (get-int-pos) 1)] ;; subtract one to eliminate newline - [received-load - (fetch-output drr-frame load-text-start load-text-end)]) - - ;; check load text - (next-test) - (unless (cond - [(string? load-answer) - (string=? load-answer received-load)] - [(regexp? load-answer) - (regexp-match load-answer received-load)] - [else #f]) - (failure) - (eprintf "FAILED load test ~a for ~s\n expected: ~s\n got: ~s\n" - short-filename - program load-answer received-load)))) - (load-test tmp-load-short-filename (make-load-answer in-vector language-cust #f)) - (when (file-exists? tmp-load3-filename) - (delete-file tmp-load3-filename)) - (copy-file tmp-load-filename tmp-load3-filename) - (load-test tmp-load3-short-filename - (make-load-answer in-vector language-cust tmp-load3-short-filename)) - - (teardown) - - ; check for edit-sequence - (when (repl-in-edit-sequence?) - (eprintf "FAILED: repl in edit-sequence") - (escape))))) + load-answer + received-load)))) + (load-test tmp-load-short-filename (make-load-answer in-vector language-cust #f)) + (when (file-exists? tmp-load3-filename) + (delete-file tmp-load3-filename)) + (copy-file tmp-load-filename tmp-load3-filename) + (load-test tmp-load3-short-filename + (make-load-answer in-vector language-cust tmp-load3-short-filename)) + + (teardown) + + ; check for edit-sequence + (when (repl-in-edit-sequence?) + (eprintf "FAILED: repl in edit-sequence") + (escape))) (define tests 0) (define failures 0) @@ -1318,16 +1297,16 @@ This produces an ACK message (wait-for-drr-frame-computation) (for-each test:keystroke (string->list "x")) - (let ([start (+ 1 (queue-callback/res (λ () (send ints-text last-position))))]) - (test:keystroke #\return) - (wait-for-drr-frame-computation) - - (let* ([end (- (get-int-pos) 1)] - [output (fetch-output drr-frame start end)] - [expected #rx"x:.*cannot reference an identifier before its definition"]) - (unless (regexp-match expected output) - (failure) - (eprintf "callcc-test: expected something matching ~s, got ~s\n" expected output))))) + (define start (+ 1 (queue-callback/res (λ () (send ints-text last-position))))) + (test:keystroke #\return) + (wait-for-drr-frame-computation) + + (define end (- (get-int-pos) 1)) + (define output (fetch-output drr-frame start end)) + (define expected #rx"x:.*cannot reference an identifier before its definition") + (unless (regexp-match expected output) + (failure) + (eprintf "callcc-test: expected something matching ~s, got ~s\n" expected output))) (define (random-seed-test) (define expression @@ -1338,57 +1317,55 @@ This produces an ACK message (wait-for-drr-frame-computation) (insert-in-interactions drr-frame expression) - (let ([start1 (+ 1 (queue-callback/res (λ () (send ints-text last-position))))]) - (test:keystroke #\return) - (wait-for-drr-frame-computation) - (let ([output1 (fetch-output drr-frame start1 (- (get-int-pos) 1))]) - (insert-in-interactions drr-frame expression) - (let ([start2 (+ 1 (queue-callback/res (λ () (send ints-text last-position))))]) - (test:keystroke #\return) - (wait-for-drr-frame-computation) - (let ([output2 (fetch-output drr-frame start2 (- (get-int-pos) 1))]) - (unless (equal? output1 output2) - (failure) - (eprintf "random-seed-test: expected\n ~s\nand\n ~s\nto be the same" - output1 - output2))))))) + (define start1 (+ 1 (queue-callback/res (λ () (send ints-text last-position))))) + (test:keystroke #\return) + (wait-for-drr-frame-computation) + (define output1 (fetch-output drr-frame start1 (- (get-int-pos) 1))) + (insert-in-interactions drr-frame expression) + (define start2 (+ 1 (queue-callback/res (λ () (send ints-text last-position))))) + (test:keystroke #\return) + (wait-for-drr-frame-computation) + (define output2 (fetch-output drr-frame start2 (- (get-int-pos) 1))) + (unless (equal? output1 output2) + (failure) + (eprintf "random-seed-test: expected\n ~s\nand\n ~s\nto be the same" output1 output2))) (define (top-interaction-test) (clear-definitions drr-frame) (do-execute drr-frame) (wait-for-drr-frame-computation) - (let ([ints-just-after-welcome (queue-callback/res (λ () (+ 1 (send ints-text last-position))))]) - - (type-in-definitions - drr-frame - "(define-syntax #%top-interaction (syntax-rules () [(_ . e) 'e]))\n(+ 1 2)\n") - (test:menu-select "File" "Save Definitions") - - (clear-definitions drr-frame) - (do-execute drr-frame) + (queue-callback/res (λ () (+ 1 (send ints-text last-position)))) + + (type-in-definitions + drr-frame + "(define-syntax #%top-interaction (syntax-rules () [(_ . e) 'e]))\n(+ 1 2)\n") + (test:menu-select "File" "Save Definitions") + + (clear-definitions drr-frame) + (do-execute drr-frame) + (wait-for-drr-frame-computation) + + (for-each test:keystroke (string->list (format "(load ~s)" tmp-load-short-filename))) + (let ([start (+ 1 (queue-callback/res (λ () (send ints-text last-position))))]) + (test:keystroke #\return) (wait-for-drr-frame-computation) - - (for-each test:keystroke (string->list (format "(load ~s)" tmp-load-short-filename))) - (let ([start (+ 1 (queue-callback/res (λ () (send ints-text last-position))))]) - (test:keystroke #\return) - (wait-for-drr-frame-computation) - (let* ([end (- (get-int-pos) 1)] - [output (fetch-output drr-frame start end)] - [expected "(+ 1 2)"]) - (unless (equal? output expected) - (error 'top-interaction-test "expected.1 ~s, got ~s" expected output)) - (next-test))) - - (for-each test:keystroke (string->list "(+ 4 5)")) - (let ([start (+ 1 (queue-callback/res (λ () (send ints-text last-position))))]) - (test:keystroke #\return) - (wait-for-drr-frame-computation) - (let* ([end (- (get-int-pos) 1)] - [output (fetch-output drr-frame start end)] - [expected "(+ 4 5)"]) - (unless (equal? output expected) - (error 'top-interaction-test "expected.2 ~s, got ~s" expected output)) - (next-test))))) + (let* ([end (- (get-int-pos) 1)] + [output (fetch-output drr-frame start end)] + [expected "(+ 1 2)"]) + (unless (equal? output expected) + (error 'top-interaction-test "expected.1 ~s, got ~s" expected output)) + (next-test))) + + (for-each test:keystroke (string->list "(+ 4 5)")) + (define start (+ 1 (queue-callback/res (λ () (send ints-text last-position))))) + (test:keystroke #\return) + (wait-for-drr-frame-computation) + (define end (- (get-int-pos) 1)) + (define output (fetch-output drr-frame start end)) + (define expected "(+ 4 5)") + (unless (equal? output expected) + (error 'top-interaction-test "expected.2 ~s, got ~s" expected output)) + (next-test)) (when (file-exists? tmp-load-filename) (delete-file tmp-load-filename)) diff --git a/drracket/setup/plt-installer-unit.rkt b/drracket/setup/plt-installer-unit.rkt index a31eee5f8..aba9b2ca9 100644 --- a/drracket/setup/plt-installer-unit.rkt +++ b/drracket/setup/plt-installer-unit.rkt @@ -41,12 +41,10 @@ (sleep 0.2) ; kludge to allow f to appear first (end-busy-cursor) ;; do these strings ever appear? (should move to string-constants, if so) - (let ([d (get-directory - "Select the destination for unpacking" - frame)]) - (unless d - (printf ">>> Cancelled <<<\n")) - (begin-busy-cursor) - d)) + (define d (get-directory "Select the destination for unpacking" frame)) + (unless d + (printf ">>> Cancelled <<<\n")) + (begin-busy-cursor) + d) #:show-beginning-of-file? #t)) cleanup-thunk))) From e1d8256f392d21c2fd434fe34457808371315b27 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 21 Sep 2025 00:21:06 +0000 Subject: [PATCH 3/9] Fix 1 occurrence of `nested-when-to-compound-when` Nested `when` expressions can be merged into a single compound `when` expression. --- drracket/macro-debugger/tool.rkt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drracket/macro-debugger/tool.rkt b/drracket/macro-debugger/tool.rkt index 65fefede6..c9e6c9635 100644 --- a/drracket/macro-debugger/tool.rkt +++ b/drracket/macro-debugger/tool.rkt @@ -461,9 +461,9 @@ (define canvas (send obj get-canvas)) (when canvas (define frame (send canvas get-top-level-window)) - (when (is-a? frame frame/supports-macro-stepper<%>) - (when (send frame allow-macro-stepper?) - (send frame run-macro-stepper))))))) + (when (and (is-a? frame frame/supports-macro-stepper<%>) + (send frame allow-macro-stepper?)) + (send frame run-macro-stepper)))))) (send keymap map-function "c:c;c:m" "macro stepper")) (add-macro-stepper-key-bindings (drracket:rep:get-drs-bindings-keymap)) From 681e843ac1ea3b9c224e1bb972b9143427b5f0fa Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 21 Sep 2025 00:21:06 +0000 Subject: [PATCH 4/9] Fix 1 occurrence of `provide/contract-to-contract-out` The `provide/contract` form is a legacy form made obsolete by `contract-out`. --- drracket-test/tests/drracket/private/repl-test.rkt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drracket-test/tests/drracket/private/repl-test.rkt b/drracket-test/tests/drracket/private/repl-test.rkt index 250324cba..9e4c21d81 100644 --- a/drracket-test/tests/drracket/private/repl-test.rkt +++ b/drracket-test/tests/drracket/private/repl-test.rkt @@ -18,7 +18,7 @@ This produces an ACK message mred framework) -(provide/contract [run-test (-> (listof (or/c 'raw 'debug 'debug/profile 'misc)) any)]) +(provide (contract-out [run-test (-> (listof (or/c 'raw 'debug 'debug/profile 'misc)) any)])) (define-struct loc (line col offset)) ;; loc = (make-loc number number number) From ab0ac3ea43d9a5edc3d7503046e80dca302e25b2 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 21 Sep 2025 00:21:06 +0000 Subject: [PATCH 5/9] Fix 1 occurrence of `make-temporary-directory-migration` Use `make-temporary-directory` to make directories instead of `make-temporary-file`. --- drracket-test/tests/drracket/private/repl-test.rkt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drracket-test/tests/drracket/private/repl-test.rkt b/drracket-test/tests/drracket/private/repl-test.rkt index 9e4c21d81..e7194dc36 100644 --- a/drracket-test/tests/drracket/private/repl-test.rkt +++ b/drracket-test/tests/drracket/private/repl-test.rkt @@ -1010,7 +1010,7 @@ This produces an ACK message (define backtrace-image-string "{stop-multi.png}") (define file-image-string "{stop-22x22.png}") -(define tmp-load-directory (make-temporary-file "repltest~a" 'directory)) +(define tmp-load-directory (make-temporary-directory "repltest~a")) (define tmp-load-short-filename "repl-test-tmp.rkt") (define tmp-load-filename (build-path tmp-load-directory tmp-load-short-filename)) From b3770af0e49a4d6c216cb4c86c191fff9248dcf6 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 21 Sep 2025 00:21:06 +0000 Subject: [PATCH 6/9] Fix 3 occurrences of `ignored-and-to-when` This `and` expression's result is ignored. Using `when` makes this clearer. --- drracket-test/tests/drracket/private/repl-test.rkt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drracket-test/tests/drracket/private/repl-test.rkt b/drracket-test/tests/drracket/private/repl-test.rkt index e7194dc36..aab1d5876 100644 --- a/drracket-test/tests/drracket/private/repl-test.rkt +++ b/drracket-test/tests/drracket/private/repl-test.rkt @@ -1074,9 +1074,12 @@ This produces an ACK message (define source-location (test-source-location in-vector)) (define setup (test-setup in-vector)) (define teardown (test-teardown in-vector)) - (and (pair? source-location) (number->string (+ 1 (loc-line (car source-location))))) - (and (pair? source-location) (number->string (loc-col (car source-location)))) - (and (pair? source-location) (number->string (+ 1 (loc-offset (car source-location))))) + (when (pair? source-location) + (number->string (+ 1 (loc-line (car source-location))))) + (when (pair? source-location) + (number->string (loc-col (car source-location)))) + (when (pair? source-location) + (number->string (+ 1 (loc-offset (car source-location))))) (define breaking-test? (test-breaking-test? in-vector)) (setup) From 57dcfbe0922963519b8ee664998917048c3b531b Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 21 Sep 2025 00:21:06 +0000 Subject: [PATCH 7/9] Fix 1 occurrence of `explicit-cond-else-void` Add an explicit `[else (void)]` clause to make the default behavior clear. --- drracket-test/tests/drracket/private/repl-test.rkt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drracket-test/tests/drracket/private/repl-test.rkt b/drracket-test/tests/drracket/private/repl-test.rkt index aab1d5876..3f12e17be 100644 --- a/drracket-test/tests/drracket/private/repl-test.rkt +++ b/drracket-test/tests/drracket/private/repl-test.rkt @@ -1103,7 +1103,8 @@ This produces an ACK message (- (send defs-text get-start-position) 1) (- (send defs-text get-start-position) 1))))] [(pair? item) (apply test:menu-select item)])) - program)]) + program)] + [else (void)]) (do-execute drr-frame #f) From e1138a46cfec82c2d7b6c7abcd051481a006884f Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 21 Sep 2025 00:21:06 +0000 Subject: [PATCH 8/9] Fix 1 occurrence of `cond-let-to-cond-define` Internal definitions are recommended instead of `let` expressions, to reduce nesting. --- .../tests/drracket/private/repl-test.rkt | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drracket-test/tests/drracket/private/repl-test.rkt b/drracket-test/tests/drracket/private/repl-test.rkt index 3f12e17be..60f33bea1 100644 --- a/drracket-test/tests/drracket/private/repl-test.rkt +++ b/drracket-test/tests/drracket/private/repl-test.rkt @@ -1137,20 +1137,20 @@ This produces an ACK message (eprintf "FAILED execute test for ~s\n expected interactions to have the focus\n" program))] [defs-focus? - (let ([start (car source-location)] - [finish (cdr source-location)]) - (let* ([error-ranges (queue-callback/res (λ () (send ints-text get-error-ranges)))] - [error-range (and error-ranges (not (null? error-ranges)) (car error-ranges))]) - (unless (and error-range - (= (+ (srcloc-position error-range) -1) (loc-offset start)) - (= (+ (srcloc-position error-range) -1 (srcloc-span error-range)) - (loc-offset finish))) - (eprintf "FAILED execute test for ~s\n error-range is ~s\n expected ~s\n" - program - (and error-range - (list (+ (srcloc-position error-range) -1) - (+ (srcloc-position error-range) -1 (srcloc-span error-range)))) - (list (loc-offset start) (loc-offset finish))))))])]) + (define start (car source-location)) + (define finish (cdr source-location)) + (define error-ranges (queue-callback/res (λ () (send ints-text get-error-ranges)))) + (define error-range (and error-ranges (not (null? error-ranges)) (car error-ranges))) + (unless (and error-range + (= (+ (srcloc-position error-range) -1) (loc-offset start)) + (= (+ (srcloc-position error-range) -1 (srcloc-span error-range)) + (loc-offset finish))) + (eprintf "FAILED execute test for ~s\n error-range is ~s\n expected ~s\n" + program + (and error-range + (list (+ (srcloc-position error-range) -1) + (+ (srcloc-position error-range) -1 (srcloc-span error-range)))) + (list (loc-offset start) (loc-offset finish))))])]) ; check text for execute test (next-test) From 9ca246ffbefcbda552d60a208976e2ce2b66fe7e Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sun, 21 Sep 2025 00:21:06 +0000 Subject: [PATCH 9/9] Fix 1 occurrence of `let-to-define` Internal definitions are recommended instead of `let` expressions, to reduce nesting. --- .../tests/drracket/private/repl-test.rkt | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drracket-test/tests/drracket/private/repl-test.rkt b/drracket-test/tests/drracket/private/repl-test.rkt index 60f33bea1..53ea97714 100644 --- a/drracket-test/tests/drracket/private/repl-test.rkt +++ b/drracket-test/tests/drracket/private/repl-test.rkt @@ -1199,21 +1199,21 @@ This produces an ACK message (test:run-one (λ () (send (send drr-frame get-break-button) command)))) (wait-for-drr-frame-computation) - (let* ([load-text-end (- (get-int-pos) 1)] ;; subtract one to eliminate newline - [received-load (fetch-output drr-frame load-text-start load-text-end)]) - - ;; check load text - (next-test) - (unless (cond - [(string? load-answer) (string=? load-answer received-load)] - [(regexp? load-answer) (regexp-match load-answer received-load)] - [else #f]) - (failure) - (eprintf "FAILED load test ~a for ~s\n expected: ~s\n got: ~s\n" - short-filename - program - load-answer - received-load)))) + (define load-text-end (- (get-int-pos) 1)) ;; subtract one to eliminate newline + (define received-load (fetch-output drr-frame load-text-start load-text-end)) + + ;; check load text + (next-test) + (unless (cond + [(string? load-answer) (string=? load-answer received-load)] + [(regexp? load-answer) (regexp-match load-answer received-load)] + [else #f]) + (failure) + (eprintf "FAILED load test ~a for ~s\n expected: ~s\n got: ~s\n" + short-filename + program + load-answer + received-load))) (load-test tmp-load-short-filename (make-load-answer in-vector language-cust #f)) (when (file-exists? tmp-load3-filename) (delete-file tmp-load3-filename))