Re: [whatwg/streams] Rigorously specify and test pipeTo (#512)

ricea commented on this pull request.



> +      if (this.started) {
+        this.paused = true;
+        clearInterval(this._intervalHandle);
+        this._intervalHandle = undefined;
+      } else {
+        throw new Error('Can\'t pause reading an unstarted source.');
+      }
+    }
+  }
+
+  function randomChunk(size) {
+    let chunk = '';
+
+    for (let i = 0; i < size; ++i) {
+      // Add a random character from the basic printable ASCII set.
+      chunk += String.fromCharCode(Math.round(Math.random() * 84) + 32);

Randomness in tests is a bad idea because it leads to flakiness and unreproducible failures.

That doesn't appear to apply here because the outcome of the test does not depend on the random values. Even so, it would be better to avoid even the suspicion of the problem by making the sequence the same on every run of the test. Unless we have a need for strong randomness, just adding a constant to a global on every iteration would work.

-- 
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/512#pullrequestreview-4404736

Received on Monday, 17 October 2016 02:26:17 UTC