-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdummy_generated_test.clj
65 lines (54 loc) · 2.06 KB
/
dummy_generated_test.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
(ns dum.dummy-generated-test
(:require
[clojure.test :refer [deftest is]]
[scicloj.note-to-test.v1.api :as note-to-test]
[tablecloth.api :as tc]))
(deftest test-everything
(is (= (note-to-test/represent-value-with-meta
(note-to-test/define-value-representations!
[{:predicate symbol?
:representation (partial str "symbol ")}
{:predicate tc/dataset?
:representation (fn [ds]
(-> ds
(update-vals vec)
(->> (into {}))))}
{:predicate (partial = 5)
:representation (constantly :five)}
{:predicate map?
:representation (fn [m]
(-> m
(update-keys note-to-test/represent-value)
(update-vals note-to-test/represent-value)))}
{:predicate sequential?
:representation (partial mapv note-to-test/represent-value)}]))
{:value [:ok], :meta nil}))
(is (= (note-to-test/represent-value-with-meta
(+ 2 3))
{:value :five, :meta nil}))
(is (= (note-to-test/represent-value-with-meta
{:x (+ 2 3)})
{:value {:x :five}, :meta nil}))
(is (= (note-to-test/represent-value-with-meta
(+ 4
5
6))
{:value 15, :meta nil}))
(is (= (note-to-test/represent-value-with-meta
(defn f [x]
(+ x 19)))
:var-or-nil))
(is (= (note-to-test/represent-value-with-meta
(f 12))
{:value 31, :meta nil}))
(is (= (note-to-test/represent-value-with-meta
(-> {:x [1 2 3]}
tc/dataset
(tc/map-columns :y [:x] (partial * 10))))
{:value {:x [1 2 3], :y [10 20 30]}, :meta {:name "_unnamed"}}))
(is (= (note-to-test/represent-value-with-meta
(f 13))
{:value 32, :meta nil}))
(is (= (note-to-test/represent-value-with-meta
{:x 9})
{:value {:x 9}, :meta nil})))