<commit_before>#lang scheme/base

(require scheme/class
         scheme/file
         mred
         framework
         string-constants
         "test-info.scm"
         "test-engine.scm"
	 "print.ss"
 	 (except-in deinprogramm/contract/contract contract-violation) ; clashes with test-engine
 	 deinprogramm/quickcheck/quickcheck)

(define test-display%
  (class* object% ()

    (init-field (current-rep #f))

    (define test-info #f)
    (define/pubment (install-info t) 
      (set! test-info t)
      (inner (void) install-info t))

    (define current-tab #f)
    (define drscheme-frame #f)
    (define src-editor #f)
    (define/public (display-settings df ct ed)
      (set! current-tab ct)
      (set! drscheme-frame df)
      (set! src-editor ed))

    (define (docked?)
      (and drscheme-frame
           (get-preference 'test:test-window:docked? 
                           (lambda () (put-preferences '(test:test-window:docked?) '(#f)) #f))))
    
    (define/public (report-success)
      (when current-rep
        (unless current-tab
          (set! current-tab (send (send current-rep get-definitions-text) get-tab)))
        (unless drscheme-frame
          (set! drscheme-frame (send current-rep get-top-level-window)))
        (let ([curr-win (and current-tab (send current-tab get-test-window))])
	  (when curr-win
	    (let ([content (make-object (editor:standard-style-list-mixin text%))])
	      (send content lock #t)
	      (when curr-win (send curr-win update-editor content))
	      (when current-tab (send current-tab current-test-editor content))
	      (when (docked?)
		(send drscheme-frame display-test-panel content)
		(send curr-win show #f)))))))

    (define/public (display-success-summary port count)
      (unless (test-silence)
	(display (case count
		   [(0) (string-constant test-engine-0-tests-passed)]
		   [(1) (string-constant test-engine-1-test-passed)]
		   [(2) (string-constant test-engine-both-tests-passed)]
		   [else (format (string-constant test-engine-all-n-tests-passed)
				 count)])
		 port)))

    (define/public (display-untested-summary port)
      (unless (test-silence)
        (display (string-constant test-engine-should-be-tested) port)
	(display "\n" port)))

    (define/public (display-disabled-summary port)
      (display (string-constant test-engine-tests-disabled) port)
      (display "\n" port))
    
    (define/public (display-results)
      (let* ([curr-win (and current-tab (send current-tab get-test-window))]
             [window (or curr-win (make-object test-window%))]
             [content (make-object (editor:standard-style-list-mixin text%))])
        
        (send this insert-test-results content test-info src-editor)
        (send content lock #t)
        (send window update-editor content)
        (when current-tab
          (send current-tab current-test-editor content)
          (unless curr-win
            (send current-tab current-test-window window)
            (send drscheme-frame register-test-window window)
            (send window update-switch
                  (lambda () (send drscheme-frame dock-tests)))
            (send window update-disable
                  (lambda () (send current-tab update-test-preference #f)))
            (send window update-closer
                  (lambda()
                    (send drscheme-frame deregister-test-window window)
                    (send current-tab current-test-window #f)
                    (send current-tab current-test-editor #f)))))
        (if (docked?)
            (send drscheme-frame display-test-panel content)
            (send window show #t))))

    (define/pubment (insert-test-results editor test-info src-editor)
      (let* ([style (send test-info test-style)]
             [total-tests (send test-info tests-run)]
             [failed-tests (send test-info tests-failed)]
             [total-checks (send test-info checks-run)]
             [failed-checks (send test-info checks-failed)]
	     [violated-contracts (send test-info failed-contracts)]

             [check-outcomes
              (lambda (total failed zero-message ck?)
                (send editor insert
                      (cond
		       [(zero? total) zero-message]
		       [(= 1 total) 
			(string-append
			 (if ck?
			     (string-constant test-engine-ran-1-check)
			     (string-constant test-engine-ran-1-test))
			 "\n")]
		       [else 
			(format (string-append
				 (if ck?
				     (string-constant test-engine-ran-n-checks)
				     (string-constant test-engine-ran-n-tests))
				 "\n")
				total)]))
                (when (> total 0)
                  (send editor insert
                        (cond
			 [(and (zero? failed) (= 1 total))
			  (string-append (if ck?
					     (string-constant test-engine-1-check-passed)
					     (string-constant test-engine-1-test-passed))
					 "\n\n")]
			 [(zero? failed) 
			  (string-append (if ck?
					     (string-constant test-engine-all-checks-passed)
					     (string-constant test-engine-all-tests-passed))
					 "\n\n")]
			 [(= failed total)
			  (string-append (if ck?
					     (string-constant test-engine-0-checks-passed)
					     (string-constant test-engine-0-tests-passed))
					 "\n")]
			 [else (format (string-append
					(if ck?
					    (string-constant test-engine-m-of-n-checks-failed)
					    (string-constant test-engine-0-tests-passed))
					"\n\n")
				       failed total)])))
		(send editor insert
		      (cond
		       ((null? violated-contracts)
			(string-append (string-constant test-engine-no-contract-violations) "\n\n"))
		       ((null? (cdr violated-contracts))
			(string-append (string-constant test-engine-1-contract-violation) "\n\n"))
		       (else
			(format (string-append (string-constant test-engine-n-contract-violations) "\n\n")
				(length violated-contracts)))))
		)]

	     [check-outcomes/check
	      (lambda (zero-message)
		(check-outcomes total-checks failed-checks
				zero-message #t))]<commit_msg>Fix one of the test-outcome messages.<commit_after>#lang scheme/base

(require scheme/class
         scheme/file
         mred
         framework
         string-constants
         "test-info.scm"
         "test-engine.scm"
	 "print.ss"
 	 (except-in deinprogramm/contract/contract contract-violation) ; clashes with test-engine
 	 deinprogramm/quickcheck/quickcheck)

(define test-display%
  (class* object% ()

    (init-field (current-rep #f))

    (define test-info #f)
    (define/pubment (install-info t) 
      (set! test-info t)
      (inner (void) install-info t))

    (define current-tab #f)
    (define drscheme-frame #f)
    (define src-editor #f)
    (define/public (display-settings df ct ed)
      (set! current-tab ct)
      (set! drscheme-frame df)
      (set! src-editor ed))

    (define (docked?)
      (and drscheme-frame
           (get-preference 'test:test-window:docked? 
                           (lambda () (put-preferences '(test:test-window:docked?) '(#f)) #f))))
    
    (define/public (report-success)
      (when current-rep
        (unless current-tab
          (set! current-tab (send (send current-rep get-definitions-text) get-tab)))
        (unless drscheme-frame
          (set! drscheme-frame (send current-rep get-top-level-window)))
        (let ([curr-win (and current-tab (send current-tab get-test-window))])
	  (when curr-win
	    (let ([content (make-object (editor:standard-style-list-mixin text%))])
	      (send content lock #t)
	      (when curr-win (send curr-win update-editor content))
	      (when current-tab (send current-tab current-test-editor content))
	      (when (docked?)
		(send drscheme-frame display-test-panel content)
		(send curr-win show #f)))))))

    (define/public (display-success-summary port count)
      (unless (test-silence)
	(display (case count
		   [(0) (string-constant test-engine-0-tests-passed)]
		   [(1) (string-constant test-engine-1-test-passed)]
		   [(2) (string-constant test-engine-both-tests-passed)]
		   [else (format (string-constant test-engine-all-n-tests-passed)
				 count)])
		 port)))

    (define/public (display-untested-summary port)
      (unless (test-silence)
        (display (string-constant test-engine-should-be-tested) port)
	(display "\n" port)))

    (define/public (display-disabled-summary port)
      (display (string-constant test-engine-tests-disabled) port)
      (display "\n" port))
    
    (define/public (display-results)
      (let* ([curr-win (and current-tab (send current-tab get-test-window))]
             [window (or curr-win (make-object test-window%))]
             [content (make-object (editor:standard-style-list-mixin text%))])
        
        (send this insert-test-results content test-info src-editor)
        (send content lock #t)
        (send window update-editor content)
        (when current-tab
          (send current-tab current-test-editor content)
          (unless curr-win
            (send current-tab current-test-window window)
            (send drscheme-frame register-test-window window)
            (send window update-switch
                  (lambda () (send drscheme-frame dock-tests)))
            (send window update-disable
                  (lambda () (send current-tab update-test-preference #f)))
            (send window update-closer
                  (lambda()
                    (send drscheme-frame deregister-test-window window)
                    (send current-tab current-test-window #f)
                    (send current-tab current-test-editor #f)))))
        (if (docked?)
            (send drscheme-frame display-test-panel content)
            (send window show #t))))

    (define/pubment (insert-test-results editor test-info src-editor)
      (let* ([style (send test-info test-style)]
             [total-tests (send test-info tests-run)]
             [failed-tests (send test-info tests-failed)]
             [total-checks (send test-info checks-run)]
             [failed-checks (send test-info checks-failed)]
	     [violated-contracts (send test-info failed-contracts)]

             [check-outcomes
              (lambda (total failed zero-message ck?)
                (send editor insert
                      (cond
		       [(zero? total) zero-message]
		       [(= 1 total) 
			(string-append
			 (if ck?
			     (string-constant test-engine-ran-1-check)
			     (string-constant test-engine-ran-1-test))
			 "\n")]
		       [else 
			(format (string-append
				 (if ck?
				     (string-constant test-engine-ran-n-checks)
				     (string-constant test-engine-ran-n-tests))
				 "\n")
				total)]))
                (when (> total 0)
                  (send editor insert
                        (cond
			 [(and (zero? failed) (= 1 total))
			  (string-append (if ck?
					     (string-constant test-engine-1-check-passed)
					     (string-constant test-engine-1-test-passed))
					 "\n\n")]
			 [(zero? failed) 
			  (string-append (if ck?
					     (string-constant test-engine-all-checks-passed)
					     (string-constant test-engine-all-tests-passed))
					 "\n\n")]
			 [(= failed total)
			  (string-append (if ck?
					     (string-constant test-engine-0-checks-passed)
					     (string-constant test-engine-0-tests-passed))
					 "\n")]
			 [else (format (string-append
					(if ck?
					    (string-constant test-engine-m-of-n-checks-failed)
					    (string-constant test-engine-m-of-n-tests-failed))
					"\n\n")
				       failed total)])))
		(send editor insert
		      (cond
		       ((null? violated-contracts)
			(string-append (string-constant test-engine-no-contract-violations) "\n\n"))
		       ((null? (cdr violated-contracts))
			(string-append (string-constant test-engine-1-contract-violation) "\n\n"))
		       (else
			(format (string-append (string-constant test-engine-n-contract-violations) "\n\n")
				(length violated-contracts)))))
		)]

	     [check-outcomes/check
	      (lambda (zero-message)
		(check-outcomes total-checks failed-checks
				zero-message #t))]
{'fraction_non_alphanumeric': 0.13678496868475992, 'fraction_numerical': 0.0025887265135699374, 'mean_word_length': 2.1532385466034754, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3088865', 'n_tokens_mistral': 4047, 'n_tokens_neox': 3547, 'n_words': 836}