<commit_before>;;;
;;; This file is a part of the nl-unittest project, released under
;;; MIT license.
;;;
;;; See the COPYING file for more details.
;;;
;;; Copyright (c) 2011 by Dương "Yang" <NAME> <<EMAIL>>
;;;

;;; This file is not designed to use as a standalone program but in
;;; conjuction with other programs.

;;; need cleaning up!!!!!!!!!!!!

;; Modified by nkmathew
;; Original: https://github.com/cmpitg/newlisp-unittest/blob/master/nl-unittest.lsp
;;
;; Modifications include color changes and the ability to suppress reports on
;; passed test cases that forces one to scroll everytime a test case fails when
;; running with (UnitTest:run-all 'MAIN)

(context 'TermColor)

;;; define some terminal color

(constant '+fg-light-red+     "\027[1;31m")
(constant '+fg-light-green+   "\027[1;32m")
(constant '+fg-light-yellow+  "\027[1;33m")
(constant '+fg-purple+        "\027[1;35m")
(constant '+fg-red+           "\027[31m")
(constant '+fg-green+         "\027[32m")
(constant '+fg-yellow+        "\027[33m")

(constant '+bg-cyan+          "\027[46m")
(constant '+bg-dark-gray+     "\027[1;40m")

(constant '+reset+            "\027[0m")

;;; colorize a string
(define (colorize color str)
  (letn ((color-name (term color))
         (const-str (append "+" color-name "+"))
         (color-sym (sym const-str)))
    (append (eval color-sym) str +reset+)))

(context 'UnitTest)

(setq *enable-term-color*       true)   ; use colors in console?
(setq *report-failed*           true)   ; report failed assertions?
(setq *report-passed*           nil)   ; report passed assertions?
(setq *continue-after-failure*  true)
(setq *verbose*                 nil)

;;; current test in a test-case, *cur-test* help tracking a test which
;;; contains other test cases
(setq *cur-test* '())

;;; convert and concat all the arguments into a string and colorize it
;;; if necessary
(define (colorize color)
  (letn (s (apply append (args)))
    (if *enable-term-color*
        (TermColor:colorize color s)
        s)))

(define (report-failure expression)
  (let (report
        (if (true? *verbose*)
            (colorize 'fg-red "--> " (string expression) " FAILED!")
            (colorize 'fg-purple
                      ;; "--> Expression: " (string (expression 2))
                      "--> " (string expression)
                      "\n => Expected: " (string (eval (expression 1)))
                      "\n -> Received: " (string (eval (expression 2))) ".")))
    (if *report-failed*
        (println report)))
  nil)

(define (report-error expression msg)
  (let (report
        (colorize 'fg-light-yellow "--> " (string expression)
                  " got error(s):\n"
                  (join (map (lambda (s) (append "    " s))
                             (parse msg "\n"))
                        "\n")))
    (println report))
  nil)

;;; requert result of a passed test
(define (report-pass expression)
  (let (report (colorize 'fg-green "--> " (string expression) " passed"))
    (if *report-passed*
        (println report)))
  true)<commit_msg>Print the expected values in a new line for better comparison of indentation<commit_after>;;;
;;; This file is a part of the nl-unittest project, released under
;;; MIT license.
;;;
;;; See the COPYING file for more details.
;;;
;;; Copyright (c) 2011 by <NAME>" <NAME> <<EMAIL>>
;;;

;;; This file is not designed to use as a standalone program but in
;;; conjuction with other programs.

;;; need cleaning up!!!!!!!!!!!!

;; Modified by nkmathew
;; Original: https://github.com/cmpitg/newlisp-unittest/blob/master/nl-unittest.lsp
;;
;; Modifications include color changes and the ability to suppress reports on
;; passed test cases that forces one to scroll everytime a test case fails when
;; running with (UnitTest:run-all 'MAIN)

(context 'TermColor)

;;; define some terminal color

(constant '+fg-light-red+     "\027[1;31m")
(constant '+fg-light-green+   "\027[1;32m")
(constant '+fg-light-yellow+  "\027[1;33m")
(constant '+fg-purple+        "\027[1;35m")
(constant '+fg-red+           "\027[31m")
(constant '+fg-green+         "\027[32m")
(constant '+fg-yellow+        "\027[33m")

(constant '+bg-cyan+          "\027[46m")
(constant '+bg-dark-gray+     "\027[1;40m")

(constant '+reset+            "\027[0m")

;;; colorize a string
(define (colorize color str)
  (letn ((color-name (term color))
         (const-str (append "+" color-name "+"))
         (color-sym (sym const-str)))
    (append (eval color-sym) str +reset+)))

(context 'UnitTest)

(setq *enable-term-color*       true)   ; use colors in console?
(setq *report-failed*           true)   ; report failed assertions?
(setq *report-passed*           nil)   ; report passed assertions?
(setq *continue-after-failure*  true)
(setq *verbose*                 nil)

;;; current test in a test-case, *cur-test* help tracking a test which
;;; contains other test cases
(setq *cur-test* '())

;;; convert and concat all the arguments into a string and colorize it
;;; if necessary
(define (colorize color)
  (letn (s (apply append (args)))
    (if *enable-term-color*
        (TermColor:colorize color s)
        s)))

(define (report-failure expression)
  (let (report
        (if (true? *verbose*)
            (colorize 'fg-red "--> " (string expression) " FAILED!")
            (colorize 'fg-purple
                      ;; "--> Expression: " (string (expression 2))
                      "--> " (string expression)
                      "\n => Expected: \n" (string (eval (expression 1)))
                      "\n -> Received: \n" (string (eval (expression 2))) ".")))
    (if *report-failed*
        (println report)))
  nil)

(define (report-error expression msg)
  (let (report
        (colorize 'fg-light-yellow "--> " (string expression)
                  " got error(s):\n"
                  (join (map (lambda (s) (append "    " s))
                             (parse msg "\n"))
                        "\n")))
    (println report))
  nil)

;;; requert result of a passed test
(define (report-pass expression)
  (let (report (colorize 'fg-green "--> " (string expression) " passed"))
    (if *report-passed*
        (println report)))
  true)
{'fraction_non_alphanumeric': 0.1612746683921061, 'fraction_numerical': 0.01973471368489162, 'mean_word_length': 2.553448275862069, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 24, 'https://': 2, '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': '6501001', 'n_tokens_mistral': 2037, 'n_tokens_neox': 1908, 'n_words': 606}