summary refs log tree commit diff
path: root/implementation/tests.scm
diff options
context:
space:
mode:
Diffstat (limited to 'implementation/tests.scm')
-rw-r--r--implementation/tests.scm18
1 files changed, 18 insertions, 0 deletions
diff --git a/implementation/tests.scm b/implementation/tests.scm
index 329a8d6..e41f19c 100644
--- a/implementation/tests.scm
+++ b/implementation/tests.scm
@@ -64,6 +64,24 @@
   (flexvector->vector (string->flexvector "abc")))
 (test-equal "flexvector->string" "abc" (flexvector->string (flexvector #\a #\b #\c)))
 
+(define genlist '(a b c))
+(define (mock-generator)
+  (if (pair? genlist)
+    (let ((value (car genlist)))
+      (set! genlist (cdr genlist))
+      value)
+    (eof-object)))
+
+(test-equal "generator->flexvector" #(a b c)
+  (flexvector->vector (generator->flexvector mock-generator)))
+(test-equal "flexvector->generator" '(a b c #t)
+  (let* ((gen (flexvector->generator (flexvector 'a 'b 'c)))
+         (one (gen))
+         (two (gen))
+         (three (gen))
+         (four (eof-object? (gen))))
+    (list one two three four)))
+
 ; Nondestructive operations on one vector
 (let ((fv (flexvector 10 20 30)))
   (test-equal "flexvector->vector" #(10 20 30) (flexvector->vector fv))