|  | 
| 9 | 9 |             #?(:clj [expectations.clojure.test-macros :refer | 
| 10 | 10 |                      [is-not' is-not passes]] | 
| 11 | 11 |                :cljs [expectations.clojure.test-macros | 
| 12 |  | -		       :refer-macros [is-not' is-not passes]]) | 
|  | 12 | +                      :refer-macros [is-not' is-not passes]]) | 
| 13 | 13 | 
 | 
| 14 | 14 |             #?(:clj [clojure.test :refer [deftest is do-report testing]] | 
| 15 | 15 |                :cljs [cljs.test :include-macros true | 
| 16 |  | -	                        :refer [do-report assert-expr] | 
| 17 |  | -				:refer-macros [deftest is testing assert-expr | 
| 18 |  | -				               use-fixtures]]) | 
|  | 16 | +                          :refer [do-report assert-expr] | 
|  | 17 | +                      :refer-macros [deftest is testing assert-expr | 
|  | 18 | +                                         use-fixtures]]) | 
| 19 | 19 |             #?(:cljs [cljs.spec.alpha :as s]) | 
| 20 | 20 |             #?(:clj [expectations.clojure.test :refer | 
| 21 | 21 |                      [from-each in more more-of] :as sut] | 
| 22 | 22 |                :cljs [expectations.clojure.test | 
| 23 |  | -	               :include-macros true | 
| 24 |  | -		       :as sut]))) | 
|  | 23 | +                      :include-macros true | 
|  | 24 | +                      :as sut]))) | 
| 25 | 25 | 
 | 
| 26 | 26 | ; The macros are in test_macros.cljc to support Clojurescript. | 
| 27 | 27 | 
 | 
|  | 
| 59 | 59 |   #_(is-not' (sut/expect #"fool" "It's foobar!") (not (re-find #"fool" "It's foobar!")))) | 
| 60 | 60 | 
 | 
| 61 | 61 | #?(:clj (deftest exception-test | 
| 62 |  | -  (passes (sut/expect ArithmeticException (/ 12 0)) | 
| 63 |  | -          (fn [ex] | 
| 64 |  | -            (let [t (Throwable->map ex)] | 
| 65 |  | -              (and (= "Divide by zero" (-> t :cause)) | 
| 66 |  | -                   (or (= 'java.lang.ArithmeticException (-> t :via first :type)) | 
| 67 |  | -                       (= java.lang.ArithmeticException (-> t :via first :type)))))))) | 
|  | 62 | +         (passes (sut/expect ArithmeticException (/ 12 0)) | 
|  | 63 | +                 (fn [ex] | 
|  | 64 | +                   (let [t (Throwable->map ex)] | 
|  | 65 | +                     (and (= "Divide by zero" (-> t :cause)) | 
|  | 66 | +                          (or (= 'java.lang.ArithmeticException (-> t :via first :type)) | 
|  | 67 | +                              (= java.lang.ArithmeticException (-> t :via first :type)))))))) | 
| 68 | 68 | 
 | 
| 69 | 69 |    :cljs (deftest cljs-exception-test | 
| 70 | 70 |            (passes (sut/expect js/Error (throw (ex-info "foo" {}))) | 
| 71 | 71 |                    (fn [ex] | 
| 72 | 72 |                      (let [t (cljs.repl/Error->map ex)] | 
| 73 | 73 |                        (and (= "foo" | 
| 74 | 74 |                                (-> t :cause)) (or (= 'ExceptionInfo | 
| 75 |  | -                                   (->> t :via first :type)) | 
| 76 |  | -                                (= ExceptionInfo | 
| 77 |  | -                                   (->> t :via first :type))))))))) | 
|  | 75 | +                                                   (->> t :via first :type)) | 
|  | 76 | +                                               (= ExceptionInfo | 
|  | 77 | +                                                  (->> t :via first :type))))))))) | 
| 78 | 78 | 
 | 
| 79 | 79 | #?(:clj (deftest class-test | 
| 80 |  | -  (is (sut/expect String (name :foo))) | 
| 81 |  | -  (is-not (sut/expect String :foo) clojure.lang.Keyword))) | 
|  | 80 | +         (is (sut/expect String (name :foo))) | 
|  | 81 | +         (is-not (sut/expect String :foo) clojure.lang.Keyword))) | 
| 82 | 82 | 
 | 
| 83 | 83 | #?(:cljs (deftest class-test | 
| 84 | 84 |            (is (sut/expect cljs.core/List '(a b c))) | 
| 85 | 85 |            (is-not (sut/expect cljs.core/List :foo) cljs.core/Keyword))) | 
| 86 | 86 | 
 | 
| 87 | 87 | #?(:clj (try | 
| 88 |  | -  (eval '(do | 
| 89 |  | -           (require '[clojure.spec.alpha :as s]) | 
| 90 |  | -           (s/def :small/value (s/and pos-int? #(< % 100))) | 
| 91 |  | -           (deftest spec-test | 
| 92 |  | -             (is (sut/expect :small/value (* 13 4))) | 
| 93 |  | -             (is-not' (sut/expect :small/value (* 13 40)) (not (=? :small/value 520)))))) | 
| 94 |  | -  (catch Throwable _ | 
| 95 |  | -    (println "\nOmitting Spec tests for Clojure" (clojure-version))))) | 
|  | 88 | +         (eval '(do | 
|  | 89 | +                  (require '[clojure.spec.alpha :as s]) | 
|  | 90 | +                  (s/def :small/value (s/and pos-int? #(< % 100))) | 
|  | 91 | +                  (deftest spec-test | 
|  | 92 | +                    (is (sut/expect :small/value (* 13 4))) | 
|  | 93 | +                    (is-not' (sut/expect :small/value (* 13 40)) (not (=? :small/value 520)))))) | 
|  | 94 | +         (catch Throwable _ | 
|  | 95 | +           (println "\nOmitting Spec tests for Clojure" (clojure-version))))) | 
| 96 | 96 | 
 | 
| 97 | 97 | ; Note :expectations.clojure.test/small-value is defined at the end of | 
| 98 | 98 | ; expectations.clojure.test/test.cljc for cljs testing.  Defining it here | 
|  | 
| 148 | 148 | 
 | 
| 149 | 149 | ; There is no cljs.test/with-test | 
| 150 | 150 | #?(:clj (sut/with-test | 
| 151 |  | -  (defn definition-test | 
| 152 |  | -    "Make sure expectations work with clojure.test/with-test." | 
| 153 |  | -    [a b c] | 
| 154 |  | -    (swap! d-t-counter inc) | 
| 155 |  | -    (* a b c)) | 
| 156 |  | -  (println "\nRunning inline tests") | 
| 157 |  | -  (reset! d-t-counter 0) | 
| 158 |  | -  (is (= 0 @d-t-counter)) | 
| 159 |  | -  (sut/expect 1 (definition-test 1 1 1)) | 
| 160 |  | -  (sut/expect 6 (definition-test 1 2 3)) | 
| 161 |  | -  (is (= 2 @d-t-counter)))) | 
|  | 151 | +         (defn definition-test | 
|  | 152 | +           "Make sure expectations work with clojure.test/with-test." | 
|  | 153 | +           [a b c] | 
|  | 154 | +           (swap! d-t-counter inc) | 
|  | 155 | +           (* a b c)) | 
|  | 156 | +         (println "\nRunning inline tests") | 
|  | 157 | +         (reset! d-t-counter 0) | 
|  | 158 | +         (is (= 0 @d-t-counter)) | 
|  | 159 | +         (sut/expect 1 (definition-test 1 1 1)) | 
|  | 160 | +         (sut/expect 6 (definition-test 1 2 3)) | 
|  | 161 | +         (is (= 2 @d-t-counter)))) | 
| 162 | 162 | 
 | 
| 163 | 163 | ;; these would be failing tests in 1.x but not in 2.x: | 
| 164 | 164 | (sut/defexpect deftest-equivalence-0) | 
|  | 
0 commit comments