Skip to content

Commit

Permalink
updated example
Browse files Browse the repository at this point in the history
  • Loading branch information
daslu committed Aug 20, 2023
1 parent 03a797d commit cda4d39
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 60 deletions.
29 changes: 21 additions & 8 deletions notebooks/dum/dummy.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,33 @@
(:require [scicloj.note-to-test.v1.api :as note-to-test]
[tablecloth.api :as tc]))

(note-to-test/define-value-representation!
"tablecloth dataset"
{:predicate tc/dataset?
:representation (fn [ds]
(-> ds
(update-vals vec)
(->> (into {}))))})
:note-to-test/skip
(note-to-test/define-value-representations!
[{:predicate var?
:representation (constantly :var)}
{:predicate tc/dataset?
:representation (fn [ds]
(-> ds
(update-vals vec)
(->> (into {}))))}
{:predicate (partial = 5)
:representation (constantly :five)}])

(+ 2 3)

(+ 4
5
6)

:note-to-test/skip
(+ 1 2)

(defn f [x]
(+ x 19))

(f 12)

(require 'clojure.java.io)

(-> {:x [1 2 3]}
tc/dataset
Expand All @@ -28,6 +37,10 @@
(f 13)


{:x 9}

(comment
(note-to-test/gentest! "notebooks/dum/dummy.clj")
(note-to-test/gentest! "notebooks/dum/dummy.clj"
{:accept true
:verbose true})
,)
120 changes: 68 additions & 52 deletions test/dum/dummy_generated_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,71 @@
(:require
[clojure.test :refer [deftest is]]
[scicloj.note-to-test.v1.api :as note-to-test]
[tablecloth.api :as tc]))

(deftest test-0
(is (->
(note-to-test/define-value-representation!
"tablecloth dataset"
{:predicate tc/dataset?
:representation (fn [ds]
(-> ds
(update-vals vec)
(->> (into {}))))})
note-to-test/represent-value
(=
:ok))))


(deftest test-1
(is (->
(+ 4
5
6)
note-to-test/represent-value
(=
15))))

(defn f [x]
(+ x 19))

(deftest test-3
(is (->
(f 12)
note-to-test/represent-value
(=
31))))


(deftest test-4
(is (->
(-> {:x [1 2 3]}
tc/dataset
(tc/map-columns :y [:x] (partial * 10)))
note-to-test/represent-value
(=
{:x [1 2 3], :y [10 20 30]}))))


(deftest test-5
(is (->
(f 13)
note-to-test/represent-value
(=
32))))
[tablecloth.api :as tc]
clojure.java.io))

(deftest test-everything

(is (= (note-to-test/represent-value
(note-to-test/define-value-representations!
[{:predicate var?
:representation (constantly :var)}
{:predicate tc/dataset?
:representation (fn [ds]
(-> ds
(update-vals vec)
(->> (into {}))))}
{:predicate (partial = 5)
:representation (constantly :five)}]))
:ok))


(is (= (note-to-test/represent-value
(+ 2 3))
:five))


(is (= (note-to-test/represent-value
(+ 4
5
6))
15))


(is (= (note-to-test/represent-value
(+ 1 2))
3))


(is (= (note-to-test/represent-value
(defn f [x]
(+ x 19)))
:var))


(is (= (note-to-test/represent-value
(f 12))
31))


(is (= (note-to-test/represent-value
(require 'clojure.java.io))
nil))


(is (= (note-to-test/represent-value
(-> {:x [1 2 3]}
tc/dataset
(tc/map-columns :y [:x] (partial * 10))))
{:x [1 2 3], :y [10 20 30]}))


(is (= (note-to-test/represent-value
(f 13))
32))


(is (= (note-to-test/represent-value
{:x 9})
{:x 9}))
)

0 comments on commit cda4d39

Please sign in to comment.