anchor.diff:        "pstream-elt 0 does not return the first item in the pstream")
     (signals cl-patterns::pstream-out-of-range
       (pstream-elt (as-pstream (pseq '(1 2 99) 1)) 2)
  -    "pstream-elt doesn't give a pstream-out-of-range error when called for an index not yet generated"))
  +    "pstream-elt doesn't signal a pstream-out-of-range error when called for an index not yet generated")
  +  (let* ((*max-pattern-yield-length* 4)
  +         (pstr (as-pstream (pseq (list 0 1 2 3)))))
  +    (dotimes (n 8)
  +      (signals cl-patterns::pstream-out-of-range
  +        (pstream-elt pstr n)
  +        "pstream-elt doesn't signal a pstream-out-of-range error when called for an index not yet generated")
  +      (next pstr)
  +      (is-true (pstream-elt pstr n)
  +               "pstream-elt doesn't return the value for a positive index")
  +      (is-true (pstream-elt pstr -1)
  +               "pstream-elt doesn't return the last output for an index of -1"))
  +    (signals cl-patterns::pstream-out-of-range
  +      (pstream-elt pstr -5)
  +      "pstream-elt doesn't signal a pstream-out-of-range error when called for a negative index older than the oldest")
  +    (is-true (pstream-elt pstr -4)
  +             "pstream-elt doesn't return the oldest output for the oldest negative index")))
  +
  +(test pstream-elt-future
  +  "Test the behavior of the `pstream-elt-future' function"
  +  (let ((pstr (as-pstream (pseq (list 1 2 99) 1))))
  +    (is (= 1 (pstream-elt-future pstr 0))
  +        "pstream-elt-future doesn't return the first output")
  +    (next pstr)
  +    (is (= 1
  +           (pstream-elt-future pstr 0))
  +        "pstream-elt-future 0 doesn't return the first output if it has been generated")
  +    (is (= 2
  +           (pstream-elt-future pstr 1))
  +        "pstream-elt-future 1 doesn't return the next output from the pstream")
  +    (is (= 99
  +           (pstream-elt-future pstr 2))
  +        "pstream-elt-future 2 doesn't return the third output")
  +    (is (equal (list 1 1)
  +               (let ((pstr (as-pstream (pseq (list 1 2 99) 1))))
  +                 (list (pstream-elt-future pstr 0)
  +                       (next pstr))))
  +        "getting future outputs with pstream-elt-future affects outputs from `next'")))
   
   (test special-wrap-keys ;; FIX: should work for all filter patterns
     "Test behavior of wrap keys"
  
positive.code:              (event :beat 3 :x 0)
               (event :beat 5 :x 1))
              (next-upto-n (pbind :beat 2
                                  :embed (pbind :beat (p+ (pk :beat) (pseq '(1 3) 1))
                                                :x (pseries)))))
             ":beat key is not accessible in embedded patterns")
    (is-true (equal (list 0 1/2 1 3/2 2 5/2 3 7/2)
  
negative.code:     (is (= num
             (length (next-upto-n (pbind :foo 1 :bar 2))))
          "pbind doesn't yield the correct number of events by default for a *max-pattern-yield-length* of ~a"
          num))
    (is (every-event-equal (list (event) (event) (event))
                           (next-n (pbind) 3))
        "empty pbinds don't yield empty events"))
  
  (test parent ;; FIX: make sure all patterns are given parents
    "Test whether patterns have the correct parent information"
  