luwes / js-diff-benchmark

Simple benchmark for testing your DOM diffing algorithm.
66 stars 5 forks source link

Spect 260 #38

Closed dy closed 4 years ago

dy commented 4 years ago
WebReflection commented 4 years ago

this looks good to me, but if you find situations that could make some implementation fail, maybe we should add that test too, probably as part of the warm-up/generic checks with assertions?

dy commented 4 years ago

@WebReflection sure, just simple identity transform check:

diff(container, [...childNodes], [...childNodes], before);

It did not fail, but created overshoot.

Another possible test cases I found -

// one in the middle
diff(container, [...childNodes], [...childNodes.slice(0, 2), createNode(0), ...childNodes.slice(3)], before)

// ring
diff(container, [...childNodes], [...childNodes.slice(1), childNodes[0]], before)

// swap tail
diff(container, [...childNodes], [...childNodes.slice(-1), childNodes.slice(1,-1), childNodes[0]], before)

// trim
diff(container, [...childNodes], childNodes.slice(1, -1), before)

I collect them here https://github.com/spectjs/spect/blob/feature/h-meta/test/diff.js

dy commented 4 years ago

Tbh I don't follow the logic of benchmark. Should that be a separate util method for each of the test cases?

dy commented 4 years ago

Ok, just checked libs in spect test suite - snabbdom is broken on prepend #39, all other libs pass all tests except for live input nodes (input array cannot be directly parent.childNodes). If you have an idea how to properly organize tests here - let's do that in a separate PR.