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

tyoshino commented on this pull request.



> +      controller = c;
+    }
+  }, undefined, {
+    size() {
+      // This is triggered by controller.enqueue(). The queue is empty and there are no pending reads. pull() is called
+      // synchronously, allowing transform() to proceed asynchronously. This results in a second call to enqueue(),
+      // which resolves this pending read() without calling size() again.
+      readPromise = reader.read();
+      ++calls;
+      return 1;
+    },
+    highWaterMark: 0
+  });
+  reader = ts.readable.getReader();
+  const writer = ts.writable.getWriter();
+  let writeCalled = false;

how about naming this writeResolved, writeCompleted, etc?

> +  });
+  reader = ts.readable.getReader();
+  const writer = ts.writable.getWriter();
+  let writeCalled = false;
+  const writePromise = writer.write('b').then(() => {
+    writeCalled = true;
+  });
+  return flushAsyncEvents().then(() => {
+    assert_false(writeCalled);
+    controller.enqueue('a');
+    assert_equals(calls, 1, 'size() should have been called once');
+    return delay(0);
+  }).then(() => {
+    assert_true(writeCalled);
+    assert_equals(calls, 1, 'size() should only be called once');
+    return readPromises[0];

readPromise?

-- 
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-61783122

Received on Monday, 11 September 2017 11:30:57 UTC