<commit_before>(import string (.. sub #s))
(import list (elem? traverse))

(defun format-value (value)
  (if (and (table? value) (rawget value "contents"))
    (rawget value "contents")
    (pretty value)))

(defmacro assert! (cnd msg) `(unless ,cnd (error! ,msg 0)))

(defmacro assert (&assertions)
  (let* [(handle-eq
          (lambda (tree)
            `(assert!
               (eq? ,(car tree) ,(cadr tree))
               ,(..
                  "expected "
                  (format-value (car tree))
                  " and "
                  (format-value (cadr tree))
                  " to be equal"))))
        (handle-neq
          (lambda (tree)
            `(assert!
               (neq? ,(car tree) ,(cadr tree))
               ,(..
                  "expected "
                  (format-value (car tree))
                  " and "
                  (format-value (cadr tree))
                  " to be unequal"))))
        (types '("list" "number" "string" "bool" "thread" "function" "table" "userdata"))
        (type-assertion? (lambda (str) (and
                                         (= (sub str (#s str) (#s str)) "?")
                                         (elem? (sub str 1 (- (#s str) 1)) types)
                                         )))
        (handle-ty (lambda (ty x)
                     `(assert!
                        (= (type ,x) ,ty)
                        ,(.. "expected "<commit_msg>Add key and symbol as types<commit_after>(import string (.. sub #s))
(import list (elem? traverse))

(defun format-value (value)
  (if (and (table? value) (rawget value "contents"))
    (rawget value "contents")
    (pretty value)))

(defmacro assert! (cnd msg) `(unless ,cnd (error! ,msg 0)))

(defmacro assert (&assertions)
  (let* [(handle-eq
          (lambda (tree)
            `(assert!
               (eq? ,(car tree) ,(cadr tree))
               ,(..
                  "expected "
                  (format-value (car tree))
                  " and "
                  (format-value (cadr tree))
                  " to be equal"))))
        (handle-neq
          (lambda (tree)
            `(assert!
               (neq? ,(car tree) ,(cadr tree))
               ,(..
                  "expected "
                  (format-value (car tree))
                  " and "
                  (format-value (cadr tree))
                  " to be unequal"))))
        (types '("list" "number" "string" "bool" "thread" "function" "table" "userdata"
                 "symbol" "key"))
        (type-assertion? (lambda (str) (and
                                         (= (sub str (#s str) (#s str)) "?")
                                         (elem? (sub str 1 (- (#s str) 1)) types)
                                         )))
        (handle-ty (lambda (ty x)
                     `(assert!
                        (= (type ,x) ,ty)
                        ,(.. "expected "
{'fraction_non_alphanumeric': 0.15003441156228492, 'fraction_numerical': 0.0020646937370956643, 'mean_word_length': 1.1296703296703297, '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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1266776', 'n_tokens_mistral': 835, 'n_tokens_neox': 774, 'n_words': 231}