<commit_before>(defpackage #:cl-patterns/tests
  (:use #:cl
        #:cl-patterns
        #:alexandria
        #:mutility
        #:fiveam))

(in-package #:cl-patterns/tests)

;;;; t/test.lisp - basic tests and test utilities/fixtures/etc.

(def-suite cl-patterns-tests
  :description "cl-patterns tests suite.")

(in-suite cl-patterns-tests)

(def-fixture debug-backend-and-clock (&rest clock-args)
  "Temporarily set the backend and clock for testing."
  (let ((previously-enabled-backends (enabled-backends))
        (*clock* (apply 'make-clock clock-args)))
    (dolist (backend (enabled-backends))
      (disable-backend backend :stop nil))
    (enable-backend :debug)
    (debug-clear-events)
    (&body)
    (debug-clear-events)
    (disable-backend :debug)
    (mapc 'enable-backend previously-enabled-backends)))

(def-fixture temporary-pdef-dictionary ()
  "Temporarily create a new pdef dictionary for testing."
  (let ((cl-patterns::*pdef-dictionary* (make-hash-table)))
    (&body)))

(test system-attributes
  "Check that the system has all the standard attributes"<commit_msg>improve test.lisp comment<commit_after>(defpackage #:cl-patterns/tests
  (:use #:cl
        #:cl-patterns
        #:alexandria
        #:mutility
        #:fiveam))

(in-package #:cl-patterns/tests)

;;;; t/test.lisp - basic tests and test utilities/fixtures/etc for the cl-patterns test suite.

(def-suite cl-patterns-tests
  :description "cl-patterns tests suite.")

(in-suite cl-patterns-tests)

(def-fixture debug-backend-and-clock (&rest clock-args)
  "Temporarily set the backend and clock for testing."
  (let ((previously-enabled-backends (enabled-backends))
        (*clock* (apply 'make-clock clock-args)))
    (dolist (backend (enabled-backends))
      (disable-backend backend :stop nil))
    (enable-backend :debug)
    (debug-clear-events)
    (&body)
    (debug-clear-events)
    (disable-backend :debug)
    (mapc 'enable-backend previously-enabled-backends)))

(def-fixture temporary-pdef-dictionary ()
  "Temporarily create a new pdef dictionary for testing."
  (let ((cl-patterns::*pdef-dictionary* (make-hash-table)))
    (&body)))

(test system-attributes
  "Check that the system has all the standard attributes"
{'fraction_non_alphanumeric': 0.14202247191011236, 'fraction_numerical': 0.0, 'mean_word_length': 3.5991735537190084, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4684941', 'n_tokens_mistral': 732, 'n_tokens_neox': 709, 'n_words': 176}