Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions drracket-test/tests/drracket/example-tool.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
(define new-collection-root
#;
(string->path "C:\\tmp")
(make-temporary-file "drracket-test-example-tool~a"
'directory))
(make-temporary-directory "drracket-test-example-tool~a"))
(define coll (build-path new-collection-root "coll"))
(unless (directory-exists? coll) (make-directory coll))

Expand Down
18 changes: 12 additions & 6 deletions drracket-test/tests/drracket/language-test.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -1933,16 +1933,22 @@ the settings above should match r5rs
(define (test-undefined-var id #:icon+in? [icon+in? #f])
(test-expression
id
(string-append (if icon+in? "{stop-22x22.png} " "")
(format "~a: this variable is not defined" id)
(if icon+in? (format " in: ~a " id) ""))))
(format "~a~a: this variable is not defined~a"
(if icon+in? "{stop-22x22.png} " "")
id
(if icon+in?
(format " in: ~a " id)
""))))

(define (test-undefined-fn exp id #:icon+in? [icon+in? #f])
(test-expression
exp
(string-append (if icon+in? "{stop-22x22.png} " "")
(format "~a: this function is not defined" id)
(if icon+in? (format " in: ~a " id) ""))))
(format "~a~a: this function is not defined~a"
(if icon+in? "{stop-22x22.png} " "")
id
(if icon+in?
(format " in: ~a " id)
""))))

(define-syntax (go stx)
(syntax-case stx ()
Expand Down
12 changes: 5 additions & 7 deletions drracket-test/tests/drracket/no-write-and-frame-leak.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,11 @@ This test checks:
(process-container item)))))

(define (record-shortcut item)
(when (is-a? item selectable-menu-item<%>)
(when (send item get-shortcut)
(define k (append (sort (send item get-shortcut-prefix)
string<=?
#:key symbol->string)
(list (send item get-shortcut))))
(hash-update! shortcuts k (λ (v) (cons (send item get-label) v)) '()))))
(when (and (is-a? item selectable-menu-item<%>) (send item get-shortcut))
(define k
(append (sort (send item get-shortcut-prefix) string<=? #:key symbol->string)
(list (send item get-shortcut))))
(hash-update! shortcuts k (λ (v) (cons (send item get-label) v)) '())))

(define (get-lab item)
(cond
Expand Down
57 changes: 29 additions & 28 deletions drracket-test/tests/drracket/syncheck-test.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -1772,12 +1772,11 @@
(λ ()
(define drs (wait-for-drracket-frame))
;(set-language-level! (list "Pretty Big"))
(begin
(set-language-level! (list "Pretty Big") #f)
(test:set-radio-box-item! "No debugging or profiling")
(let ([f (test:get-active-top-level-window)])
(test:button-push "OK")
(wait-for-new-frame f)))
(set-language-level! (list "Pretty Big") #f)
(test:set-radio-box-item! "No debugging or profiling")
(let ([f (test:get-active-top-level-window)])
(test:button-push "OK")
(wait-for-new-frame f))
(do-execute drs)
(define defs (queue-callback/res (λ () (send drs get-definitions-text))))
(define filename (make-temporary-file "syncheck-test~a" #f temp-dir))
Expand Down Expand Up @@ -1998,24 +1997,23 @@

(define (collapse-and-rename expected)
(define renamed
(map (lambda (ent)
(let* ([str (car ent)]
[id (cadr ent)]
[matches (assoc id remappings)])
(if matches
(list str (cadr matches))
ent)))
expected))
(for/list ([ent (in-list expected)])
(define str (car ent))
(define id (cadr ent))
(define matches (assoc id remappings))
(if matches
(list str (cadr matches))
ent)))
(let loop ([ids renamed])
(cond
[(null? ids) null]
[(null? (cdr ids)) ids]
[else
(let ([fst (car ids)]
[snd (cadr ids)])
(if (eq? (cadr fst) (cadr snd))
(loop (cons (list (string-append (car fst) (car snd)) (cadr fst)) (cddr ids)))
(cons fst (loop (cdr ids)))))])))
(define fst (car ids))
(define snd (cadr ids))
(if (eq? (cadr fst) (cadr snd))
(loop (cons (list (string-append (car fst) (car snd)) (cadr fst)) (cddr ids)))
(cons fst (loop (cdr ids))))])))

;; compare-arrows : expression
;; (or/c #f (listof (cons (list number-or-proc number-or-proc)
Expand Down Expand Up @@ -2069,15 +2067,18 @@
(for-each (test-binding #f actual-ht) (hash-map expected-ht cons))))

(define (compare-output raw-expected got arrows arrows-got input line)
(let ([expected (collapse-and-rename raw-expected)])
(cond
[(not-matching-colors got expected)
=>
(λ (msg)
(eprintf "FAILED line ~a: ~s\n expected: ~s\n got: ~s\n ~a\n"
line input expected got msg))]
[else
(compare-arrows input arrows arrows-got line)])))
(define expected (collapse-and-rename raw-expected))
(cond
[(not-matching-colors got expected)
=>
(λ (msg)
(eprintf "FAILED line ~a: ~s\n expected: ~s\n got: ~s\n ~a\n"
line
input
expected
got
msg))]
[else (compare-arrows input arrows arrows-got line)]))

(define (not-matching-colors got expected)
(let loop ([got got]
Expand Down
79 changes: 37 additions & 42 deletions drracket-test/tests/drracket/teaching-lang-coverage.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,15 @@

;; get-annotate-output : drscheme-frame -> (listof str/ann)
(define (get-annotated-output drs)
(let ([chan (make-channel)])
(queue-callback
(λ ()
(channel-put chan (get-string/style-desc (send drs get-definitions-text)))))
(channel-get chan)))
(define chan (make-channel))
(queue-callback (λ () (channel-put chan (get-string/style-desc (send drs get-definitions-text)))))
(channel-get chan))

;; returns #t if an element of the result of get-string/style-desc
;; corresponds to an uncovered region of the editor
(define (is-uncovered? ele)
(let ([style (list-ref ele 1)])
(eq? style 'test-coverage-off)))
(define style (list-ref ele 1))
(eq? style 'test-coverage-off))

;; find-uncovered-text : list[get-string/style-desc result] -> (listof string)
;; returns strings containing the uncovered text in the editor (in the order they appear in the file)
Expand All @@ -86,38 +84,35 @@

(fire-up-drracket-and-run-tests
(λ ()
(let* ([drr-frame (wait-for-drracket-frame)]
[definitions-text (send drr-frame get-definitions-text)]
[interactions-text (send drr-frame get-interactions-text)])

(let ([last-lang #f])
(for ([t (in-list tests)])


(let* ([this-lang (test-lang-regexp t)]
[same-last-time? (and (regexp? last-lang)
(equal? (object-name last-lang)
(object-name this-lang)))])
(unless same-last-time?
(set! last-lang this-lang)
(set-language-level! (list this-lang))))

(clear-definitions drr-frame)
(insert-in-definitions drr-frame (test-program t))
(do-execute drr-frame)

(let ([result (fetch-output
drr-frame
(send interactions-text paragraph-start-position 2)
(send interactions-text last-position))])
(unless (regexp-match #rx"^[ \n\t0-9>]*$" result)
(eprintf "FAILED line ~a, got ~s for the output, but expected only digits and whitespace"
(test-line t)
result)))

(let ([got (find-uncovered-text (get-annotated-output drr-frame))])
(unless (equal? got (test-uncovered t))
(eprintf "FAILED line ~a\n got: ~s\nexpected: ~s\n"
(test-line t)
got
(test-uncovered t)))))))))
(define drr-frame (wait-for-drracket-frame))
(send drr-frame get-definitions-text)
(define interactions-text (send drr-frame get-interactions-text))

(define last-lang #f)
(for ([t (in-list tests)])

(let* ([this-lang (test-lang-regexp t)]
[same-last-time? (and (regexp? last-lang)
(equal? (object-name last-lang) (object-name this-lang)))])
(unless same-last-time?
(set! last-lang this-lang)
(set-language-level! (list this-lang))))

(clear-definitions drr-frame)
(insert-in-definitions drr-frame (test-program t))
(do-execute drr-frame)

(let ([result (fetch-output drr-frame
(send interactions-text paragraph-start-position 2)
(send interactions-text last-position))])
(unless (regexp-match #rx"^[ \n\t0-9>]*$" result)
(eprintf "FAILED line ~a, got ~s for the output, but expected only digits and whitespace"
(test-line t)
result)))

(let ([got (find-uncovered-text (get-annotated-output drr-frame))])
(unless (equal? got (test-uncovered t))
(eprintf "FAILED line ~a\n got: ~s\nexpected: ~s\n"
(test-line t)
got
(test-uncovered t)))))))
21 changes: 9 additions & 12 deletions drracket-test/tests/drracket/teaching-lang-sharing-modules.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,19 @@ Of course, other (similar) things can go wrong, too.
(for ([exp (in-list things-to-try)])
(insert-in-definitions drs-frame (format "~s\n" exp)))
(do-execute drs-frame)
(let ([output (fetch-output drs-frame)])
(cond
[(equal? output first-line-output)
(try-interaction-test drs-frame)]
[else
(eprintf "teaching-lang-sharing-modules.rkt: got bad output from execute: ~s"
output)])))
(define output (fetch-output drs-frame))
(cond
[(equal? output first-line-output) (try-interaction-test drs-frame)]
[else (eprintf "teaching-lang-sharing-modules.rkt: got bad output from execute: ~s" output)]))
#:prefs '([plt:framework-pref:framework:autosaving-on? #f])))

(define (try-interaction-test drs-frame)
(type-in-interactions drs-frame "1\n")
(wait-for-computation drs-frame)
(let ([interactions-output (fetch-output drs-frame)])
(unless (equal? interactions-output (format "~a\n> 1\n1" first-line-output))
(error 'teaching-language-sharing-modules.rkt
"got bad output from interaction: ~s\n"
interactions-output))))
(define interactions-output (fetch-output drs-frame))
(unless (equal? interactions-output (format "~a\n> 1\n1" first-line-output))
(error 'teaching-language-sharing-modules.rkt
"got bad output from interaction: ~s\n"
interactions-output)))

(go)
Loading