Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests #3

Open
nettyso opened this issue Apr 26, 2021 · 3 comments
Open

Tests #3

nettyso opened this issue Apr 26, 2021 · 3 comments
Assignees

Comments

@nettyso
Copy link
Owner

nettyso commented Apr 26, 2021

The reactive state library has a lot of new features/fixes over previous versions. These should be tested. Here are some initial tests to have:

  • Errors during creation shouldn't impact global state, ID counters, or run counts
  • Mismatched sig($)/sig() should throw "Mixed" error
  • Mismatched sig()/sig($) should throw "Mixed" error
  • Transactions should only commit last value and defer calling wires
  • Adoption should impact consistency checks for sigRS/sigRP lists
  • Run count should be 0 on start even for computed-signals
  • Using a computed-signal in a wire shouldn't change sigRS/sigRP lists
  • Wire unsubscribe should reset all lists and disconnect signals
  • Running in a loop causes the "Loop ${wire.name}" error
  • Pausing then writing to a signal shouldn't run a wire
  • Pausing then writing to a signal and unpausing should run a wire
  • Pause/Unpause/Pause/Unpause shouldn't do any work
  • Tree of parent/children reactors should execute in the right sorted order by pruning children
  • Error recovery. Throwing an error shouldn't hurt other wires/signals
  • Patching of a single wire works via chaining
  • Patching works
@nettyso nettyso self-assigned this Apr 26, 2021
@mindplay-dk
Copy link

If I may, I'd like to suggest zora - a very modern little test-framework with great performance and familiar surface ergonomics. For one, it does async tests way more reliably than pretty much any test-framework I've come across, which is why I found it and started using it in the first place. (It's very not "batteries included", which I like, but YMMV... tap-diff is my go-to tap reporter.)

For my own DOM integration tests, I've been using undom - it's extremely simple and probably just enough for testing things that don't depend on much more than Document and Node. I find for most of my DOM projects, I don't really need to roll out the whole jsdom kit'n'kaboodle, much less a headless browser. Worth a try maybe.

@nettyso
Copy link
Owner Author

nettyso commented Apr 26, 2021

Thanks for the tips! I'll checkout zora. I had been using ospec back when I was whiteboarding the reactive library here https://github.com/heyheyhello/haptic-reactivity/blob/work/test/sGlobalTests.js. I picked ospec at the time for the same reasons zora is preaching - be simple and light - but didn't love it.

Yeah I love undom! I actually forked it to https://github.com/heyheyhello/softdom/ when I was doing Sinuous SSR+SSG a few months back.

@nettyso
Copy link
Owner Author

nettyso commented Jul 20, 2021

Read subscribe is...complicated. Especially with the lazy computed signals. Current implementation:

    // Case: Read-Subscribe. Marks the core registered in `$` as a reader
    // This could be different than the actively running core, but shouldn't be
    else if ((read = args[0] && (args[0] as { $$?: 1 }).$$ && args[0].core)) {
      if ((read as C).sigRP.has(signal)) {
        throw new Error(`${(read as C).name} mixes sig($) & sig()`);
      }
      // Two-way link. Signal writes will now call/update core C
      (read as C).sigRS.add(signal);
      signal.cores.add((read as C));

      // Computed-signals (signals holding a core; signal.cc) can't only run C
      // when written to, they also need to run C when cc is marked stale. How
      // do we know when that happens? It'll be when one of cc.sigRS signals
      // calls cc. So, link this `read` core to each cc.sigRS call list; it'll
      // be called as collateral.
      if (signal.cc) {
        signal.cc.sigRS.forEach((_signal) => {
          // Linking _must_ be two-way. From signal.cores to core.sigXYZ. Until
          // now it's always either sigRP or sigRP, but if we use those we'll
          // break the mix error checking (above). So use a new list, sigIC.
          (read as C).sigIC.add(_signal);
          _signal.cores.add((read as C));
        });
      }
    }

I'll want to have some specific tests for this, addressing these from Sinuous:

@nettyso nettyso changed the title Tests for Haptic Wire Tests Jul 20, 2021
nettyso added a commit that referenced this issue Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants