Skip to content

Commit

Permalink
see #42: a test for serializing a map of functions, checking deep rec…
Browse files Browse the repository at this point in the history
…ursion on bindings.
  • Loading branch information
chrisbetz committed Dec 19, 2014
1 parent e2ee9dd commit 99c998c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
flambo.rdd.hadoopAvro
flambo.rdd.jdbc
flambo.api-test
flambo.function-test
flambo.conf-test
flambo.rdd.hadoopAvro-test
flambo.rdd.jdbc-test
Expand Down
26 changes: 24 additions & 2 deletions test/flambo/function_test.clj
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
(ns flambo.function-test
(:use clojure.test)
(:require [flambo.function :as func]))
(:require [flambo.function :as func]
[flambo.kryoserializer :as ks]
[clojure.test :refer :all]
))


(deftest serializable-functions

(let [kryo (ks/kryo-serializer)
myfn (fn [x] (* 2 x))]

(testing
"we can serialize and deserialize it to a function"
(is (fn? (ks/round-trip kryo myfn))))

(testing (is (= 6
((ks/round-trip kryo myfn) 3))))


(let [x {:f identity :g (fn [s] (identity s))}] ;; check discussion on https://github.com/yieldbot/flambo/issues/42
(testing (is (= 'test-symbol
(((ks/round-trip kryo x) :g)
'test-symbol)
))))))

0 comments on commit 99c998c

Please sign in to comment.