<commit_before>(ns library.test
  "Support for evaluating ClojureScript code from Clojure tests."
  (:refer-clojure :exclude [load-file])
  (:use [cljs.compiler :only (namespaces)]
        [cljs.repl :only (evaluate-form load-file load-namespace)]))

(def ^:dynamic *eval-env*)

(defn evaluate-cljs
  "Evaluate a ClojureScript form within the given evaluation
  environment. The form will also be evaluated in the passed namespace
  which defaults to 'cljs.user."
  ([eval-env form]
     (evaluate-cljs eval-env 'cljs.user form))
  ([eval-env ns form]
     (let [env {:context :statement :locals {}}]
       (cond
        (and (seq? form) ('#{load-file clojure.core/load-file} (first form)))
        (load-file eval-env (second form))
        
        (and (seq? form) ('#{load-namespace} (first form)))
        (load-namespace eval-env (second form))
        
        :else
        (let [ret (evaluate-form env
                                 (assoc env :ns (@namespaces ns))
                                 "<testing>"
                                 form
                                 (fn [x] `(cljs.core.pr-str ~x)))]
          (try (read-string ret)
               (catch Exception e
                 (if (string? ret)
                   ret
                   nil))))))))

(defn cljs-wait-for*
  "Using evaluation environment eval-env evaluate form in namespace
  ns in the browser until pred applied to the result returns true or<commit_msg>Pass proper eval-env to evaluate-form.<commit_after>(ns library.test
  "Support for evaluating ClojureScript code from Clojure tests."
  (:refer-clojure :exclude [load-file])
  (:use [cljs.compiler :only (namespaces)]
        [cljs.repl :only (evaluate-form load-file load-namespace)]))

(def ^:dynamic *eval-env*)

(defn evaluate-cljs
  "Evaluate a ClojureScript form within the given evaluation
  environment. The form will also be evaluated in the passed namespace
  which defaults to 'cljs.user."
  ([eval-env form]
     (evaluate-cljs eval-env 'cljs.user form))
  ([eval-env ns form]
     (let [env {:context :statement :locals {}}]
       (cond
        (and (seq? form) ('#{load-file clojure.core/load-file} (first form)))
        (load-file eval-env (second form))
        
        (and (seq? form) ('#{load-namespace} (first form)))
        (load-namespace eval-env (second form))
        
        :else
        (let [ret (evaluate-form eval-env
                                 (assoc env :ns (@namespaces ns))
                                 "<testing>"
                                 form
                                 (fn [x] `(cljs.core.pr-str ~x)))]
          (try (read-string ret)
               (catch Exception e
                 (if (string? ret)
                   ret
                   nil))))))))

(defn cljs-wait-for*
  "Using evaluation environment eval-env evaluate form in namespace
  ns in the browser until pred applied to the result returns true or
{'fraction_non_alphanumeric': 0.11708645336963922, 'fraction_numerical': 0.0, 'mean_word_length': 1.9243781094527364, 'pattern_counts': {'":': 0, '<': 5, '<?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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5685913', 'n_tokens_mistral': 855, 'n_tokens_neox': 830, 'n_words': 275}