observablehq / runtime

The reactive dataflow runtime that powers Observable Framework and Observable notebooks
https://observablehq.com/@observablehq/how-observable-runs
ISC License
1.02k stars 72 forks source link

Adding a test for #220 #221

Closed jashkenas closed 4 years ago

jashkenas commented 4 years ago

After much struggle, I was able to write a test that distinguishes the variable computation ordering on master from the ordering on defer-recompute-test ... but I'm not positive that it demonstrates that the change in ordering is what we desire it to be, so read carefully.

The meaningful difference between the two branches is on the line commented in the test case below. On the current master, at the time that the gen generator cell is first fulfilled, the actual generator has not resumed yet after its initial yield, and the value of i is still 1.

On the defer-recompute branch, at the time that the gen generator cell is first fulfilled, the generator has already resumed, and although the current value being yielded through the runtime is 1, i already equals 2.

Is this the behavior we want?

jashkenas commented 4 years ago

@mbostock — Would you like this as part of your merge for https://github.com/observablehq/runtime/pull/220/ ?

mbostock commented 4 years ago

Yes, thanks for the reminder! I’ve merged.