aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorZach Smith <zd@zdsmith.com>2021-08-08 13:32:00 -0400
committerZach Smith <zd@zdsmith.com>2021-08-08 13:32:00 -0400
commit9349922e85556d7716945d675ef355e987169d64 (patch)
tree2b106270cca2d11d465353ab2f6535d48d47fc95 /test
parentstream->generator (diff)
CR @pepe: Use `next ds` for cycle (0 is not always the first position to
get in a data structure) This change also *removes* the automatic wrapping of a scalar data term in an array (ie, being able to (cycle :ok) and have it "do the right thing"). For the same reason that `mapcat` expects that the return value of `f` be an iterable, we can't intelligently determine whether to wrap `ds` or not in `cycle`. There's no way to inspect a data structure and determine whether it's iterable or not, so we have to assume it is and leave it to the user to pass in an iterable.
Diffstat (limited to 'test')
-rw-r--r--test/suite11.janet6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/suite11.janet b/test/suite11.janet
index 7a887f8..96a71a5 100644
--- a/test/suite11.janet
+++ b/test/suite11.janet
@@ -67,4 +67,10 @@
(def taken (generators/take 10 s))
(assert (deep= @[1 2 3 1 2 3 1 2 3 1] (values taken)))
+(def s (generators/cycle {:a 1 :b 2 :c 3}))
+(def taken (generators/take 10 s))
+(def taken-array (values taken))
+(assert (= 10 (length taken-array)))
+(assert (deep= @[1 2 3] (sorted (distinct taken-array))))
+
(end-suite)