branch: master commit 22678a3353693bdcf7320bf486baa5e45ccdeff7 Author: Nicolas Petton <nico...@petton.fr> Commit: Nicolas Petton <nico...@petton.fr>
Update stream.el to version 2.0.0 * packages/stream/stream.el: * packages/stream/tests/stream-tests.el: Update. --- packages/stream/stream.el | 6 +++--- packages/stream/tests/stream-tests.el | 27 ++++++++++----------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/packages/stream/stream.el b/packages/stream/stream.el index 375999f..5506f78 100644 --- a/packages/stream/stream.el +++ b/packages/stream/stream.el @@ -4,7 +4,7 @@ ;; Author: Nicolas Petton <nico...@petton.fr> ;; Keywords: stream, laziness, sequences -;; Version: 1.1.0 +;; Version: 2.0.0 ;; Package-Requires: ((emacs "25")) ;; Package: stream @@ -142,7 +142,7 @@ range is infinite." (stream-range (+ start step) end step)))) -(defun stream-p (stream) +(defun streamp (stream) "Return non-nil if STREAM is a stream, nil otherwise." (and (consp stream) (eq (car stream) stream--identifier))) @@ -171,7 +171,7 @@ range is infinite." (cl-generic-make-generalizer 11 (lambda (name) - `(when (stream-p ,name) + `(when (streamp ,name) 'stream)) (lambda (tag) (when (eq tag 'stream) diff --git a/packages/stream/tests/stream-tests.el b/packages/stream/tests/stream-tests.el index a59aced..a7cb727 100644 --- a/packages/stream/tests/stream-tests.el +++ b/packages/stream/tests/stream-tests.el @@ -36,11 +36,11 @@ (reverse result))) (ert-deftest stream-empty-test () - (should (stream-p (stream-empty))) + (should (streamp (stream-empty))) (should (stream-empty-p (stream-empty)))) (ert-deftest stream-make-test () - (should (stream-p (stream-range))) + (should (streamp (stream-range))) (should (not (stream-empty-p (stream-range))))) ;; Should use stream-list or something (ert-deftest stream-first-test () @@ -76,7 +76,7 @@ (should (= first 2)) (should (= third 4)) ;; The rest of the stream shouldn't be consumed - (should (stream-p rest)) + (should (streamp rest)) (should (= 5 (stream-first rest))) (should (= 6 (stream-first (stream-rest rest)))) (should (stream-empty-p (stream-rest (stream-rest rest)))))) @@ -86,21 +86,21 @@ ) (ert-deftest stream-seq-into-test () - (should (stream-p (seq-into (stream-empty) 'stream))) - (should (stream-p (seq-into '(2 4 5) 'stream))) + (should (streamp (seq-into (stream-empty) 'stream))) + (should (streamp (seq-into '(2 4 5) 'stream))) (should (= 2 (stream-first (seq-into '(2 4 5) 'stream)))) (should (null (seq-into (stream-empty) 'list))) (should (equal '(0 1 2 3 4 5 6 7 8 9) (seq-into (stream-range 0 10) 'list)))) (ert-deftest stream-seq-take-test () - (should (stream-p (seq-take (stream-range) 2))) + (should (streamp (seq-take (stream-range) 2))) (should (= 0 (stream-first (seq-take (stream-range) 2)))) (should (= 1 (stream-first (stream-rest (seq-take (stream-range) 2))))) (should (null (stream-first (stream-rest (stream-rest (seq-take (stream-range) 2)))))) (should (stream-empty-p (stream-rest (stream-rest (seq-take (stream-range) 2)))))) (ert-deftest stream-seq-drop-test () - (should (stream-p (seq-drop (stream-range) 2))) + (should (streamp (seq-drop (stream-range) 2))) (should (= 2 (stream-first (seq-drop (stream-range) 2)))) (should (= 3 (stream-first (stream-rest (seq-drop (stream-range) 2))))) (should (stream-empty-p (seq-drop (stream-empty) 2)))) @@ -108,14 +108,14 @@ (ert-deftest stream-seq-take-while-test () (let ((stream (stream '(1 3 2 5)))) (should (stream-empty-p (seq-take-while #'identity (stream-empty)))) - (should (stream-p (seq-take-while #'oddp stream))) + (should (streamp (seq-take-while #'oddp stream))) (should (= 1 (stream-first (seq-take-while #'oddp stream)))) (should (= 3 (stream-first (stream-rest (seq-take-while #'oddp stream))))) (should (stream-empty-p (stream-rest (stream-rest (seq-take-while #'oddp stream))))))) (ert-deftest stream-seq-drop-while-test () (let ((stream (stream '(1 3 2 5)))) - (should (stream-p (seq-drop-while #'evenp stream))) + (should (streamp (seq-drop-while #'evenp stream))) (should (stream-empty-p (seq-drop-while #'identity (stream-empty)))) (should (= 2 (stream-first (seq-drop-while #'evenp stream)))) (should (= 5 (stream-first (stream-rest (seq-drop-while #'evenp stream))))) @@ -142,7 +142,7 @@ (should (stream-empty-p (stream-rest (stream-rest (seq-filter #'oddp (stream-range 0 4))))))) (ert-deftest stream-seq-copy-test () - (should (stream-p (seq-copy (stream-range)))) + (should (streamp (seq-copy (stream-range)))) (should (= 0 (stream-first (seq-copy (stream-range))))) (should (= 1 (stream-first (stream-rest (seq-copy (stream-range))))))) @@ -168,12 +168,5 @@ (should (= (seq-length (seq-subseq (stream-range 2 10) 1 3)) 2)) (should (= (seq-elt (seq-subseq (stream-range 2 10) 1 3) 1) 4))) -(ert-deftest stream-rest-should-return-the-empty-stream-at-end-of-stream () - (should (stream-empty-p (stream-rest (stream-rest (stream nil)))))) - -(ert-deftest seq-take-should-not-signal-exceptions-at-end-of-stream () - (should (equal (seq-into-sequence (seq-take (stream (list 1 2 3)) 4)) - '(1 2 3)))) - (provide 'stream-tests) ;;; stream-tests.el ends here