Re: [whatwg/streams] Add TransformStream tests for re-entrant strategies (#795)

domenic approved this pull request.

LGTM with a couple questions... still need to think about #794 more though.

> +      if (calls < 2) {
+        controller.enqueue('b');
+      }
+      return 1;
+    },
+    highWaterMark: Infinity
+  });
+  const writer = ts.writable.getWriter();
+  return Promise.all([writer.write('a'), writer.close()])
+      .then(() => readableStreamToArray(ts.readable))
+      .then(array => assert_array_equals(array, ['b', 'a'], 'array should contain two chunks'));
+}, 'enqueue() inside size() should work');
+
+// The behaviour in this test may seem strange, but it is logical. The call to controller.close() happens while the
+// readable queue is still empty, so the readable transitions to the "closed" state immediately, and the chunk is left
+// stranded in the readable's queue.

stranded in the writable's queue, right?

> +    writeResolved = true;
+  });
+  return flushAsyncEvents().then(() => {
+    assert_false(writeResolved);
+    controller.enqueue('a');
+    assert_equals(calls, 1, 'size() should have been called once');
+    return delay(0);
+  }).then(() => {
+    assert_true(writeResolved);
+    assert_equals(calls, 1, 'size() should only be called once');
+    return readPromise;
+  }).then(({ value, done }) => {
+    assert_false(done, 'done should be false');
+    // See https://github.com/whatwg/streams/issues/794 for why this chunk is not 'a'.
+    assert_equals(value, 'b', 'chunk should have been read');
+    return writePromise;

Maybe throw in another assert on calls? It doesn't hurt... Same in next test.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/795#pullrequestreview-62952004

Received on Friday, 15 September 2017 07:18:43 UTC