File tree 3 files changed +52
-3
lines changed
src/clojure_noob/under_test
3 files changed +52
-3
lines changed Original file line number Diff line number Diff line change 3
3
:url " http://example.com/FIXME"
4
4
:license {:name " EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
5
5
:url " https://www.eclipse.org/legal/epl-2.0/" }
6
- :dependencies [[org.clojure/clojure " 1.10.3" ]]
6
+ :dependencies [
7
+ [org.clojure/clojure " 1.10.3" ]
8
+ [prismatic/schema " 1.2.0" ]
9
+ ]
7
10
:main ^:skip-aot clojure-noob.core
8
11
:target-path " target/%s"
9
12
:profiles {:uberjar {:aot :all
Original file line number Diff line number Diff line change
1
+ (ns clojure-noob.under-test.functions
2
+ (:require [schema.core :as s]
3
+ [schema.test :as st]))
4
+
5
+ (defn my-sum [& numbers]
6
+ (apply + (take 2 numbers)))
7
+
8
+ (my-sum 1 1 )
9
+ (my-sum 1 1 1 )
10
+
11
+ (s/defn c->f
12
+ " Celsius to Fahrenheit"
13
+ [c :- s/Int]
14
+ (int (+ 32 (/ (* c 9 ) 5 ))))
15
+
16
+ (s/defschema Something {:a s/Int
17
+ :b s/Str})
Original file line number Diff line number Diff line change 1
1
(ns clojure-noob.core-test
2
- (:require [clojure.test :refer :all ]
3
- [clojure-noob.core :refer :all ]))
2
+ (:require [clojure-noob.core :refer :all ]
3
+ [clojure-noob.under-test.functions :refer [my-sum, c->f]]
4
+ [clojure.test :refer :all ]
5
+ [schema.core :as s]
6
+ [schema.test :as st]))
7
+
8
+ (use-fixtures :once schema.test/validate-schemas)
4
9
5
10
(deftest a-test
6
11
(testing " FIXME, I fail."
7
12
(is (= 0 1 ))))
13
+
14
+ (deftest test-sum
15
+ (testing " adds numbers"
16
+ (is (= 3 (my-sum 1 2 )))
17
+ (is (= 6 (my-sum 1 2 3 )))))
18
+
19
+ (test-sum )
20
+ (test-vars [#'test-sum])
21
+ (run-tests )
22
+
23
+ (deftest test-c->f
24
+ (is (= 32 (c->f 0.0 ))))
25
+
26
+ ; it doesn't fail even though we are passing a double
27
+ (test-c->f )
28
+
29
+ (use-fixtures :once )
30
+
31
+ (deftest test-c->f-v2
32
+ (s/with-fn-validation
33
+ (is (= 32 (c->f 0.0 )))))
34
+
35
+ ; now the schema violation appears as [(named (not (integer? 0.0)) c)]
36
+ (test-c->f-v2 )
You can’t perform that action at this time.
0 commit comments