-
-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathiter_gen_seq_test.clj
More file actions
24 lines (21 loc) · 876 Bytes
/
iter_gen_seq_test.clj
File metadata and controls
24 lines (21 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(ns libpython-clj2.iter-gen-seq-test
"Iterators/sequences and such are crucial to handling lots of forms
of data and thus they have to work correctly between the languages."
(:require [libpython-clj2.python :as py]
[libpython-clj2.require :refer [require-python]]
[clojure.test :refer :all]))
(require-python '[builtins :as python])
(deftest generate-sequence-test
(let [{{:strs [fortwice]} :globals}
(py/run-simple-string "
def fortwice(xs):
for x in xs:
yield x
for x in xs:
yield x")]
(is (= [1 2 3 4 5 6 7 8 9 10]
(vec (fortwice (python/map inc (range 10))))))
(is (= [1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10]
(vec (fortwice (map inc (range 10))))))
(is (= [1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10]
(vec (fortwice (vec (python/map inc (range 10)))))))))