Skip to content

Simplified and improved test-cases for ReactMultiChildText-test #1990

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

Merged
merged 1 commit into from
Aug 6, 2014
Merged

Simplified and improved test-cases for ReactMultiChildText-test #1990

merged 1 commit into from
Aug 6, 2014

Conversation

syranide
Copy link
Contributor

@syranide syranide commented Aug 4, 2014

Test-cases dissected from #1989

Easier overview of tests and much more complete testing of all possible edge-cases.

@sophiebits
Copy link
Collaborator

I like this. Can we add assertions for what the empty string renders to?

@syranide
Copy link
Contributor Author

syranide commented Aug 4, 2014

@spicyj Ah yes, will add that.

@syranide
Copy link
Contributor Author

syranide commented Aug 5, 2014

@spicyj Added. Also separated out "already tested test cases" to lessen the impact of O(n^2) and to avoid them being tested against themselves for every "list of tests".

There are probably a bunch of improvements that could be made, but perhaps this is a better starting point than what we have today (which seemed quite unmaintainable, especially when extended to adequately cover merging of adjacent strings).

@sophiebits
Copy link
Collaborator

It's hard for me to follow what's going on now. I prefer the simple O(n^2) solution which will be plenty fast as long as we don't have thousands of different tests here, which we won't.

@syranide
Copy link
Contributor Author

syranide commented Aug 5, 2014

@spicyj 40_40 = 1600 and we're doing actual "rendering" and updating, 1ms each and we're suddenly taking 1.6s for only one of the handful of tests there. 40_30 isn't really better though and perhaps not worth the complication.

But the idea with splitting up as I did was simply to avoid the test-cases in the first argument from being tested against themselves, again, for every separate test. So it's the exact same thing as before (and looks kind of the same), it's just an optimization, although that doesn't necessarily make it easily understood... :)

@sophiebits
Copy link
Collaborator

Well, I am fine with combining them into one test if that helps…

@syranide
Copy link
Contributor Author

syranide commented Aug 5, 2014

@spicyj Merged them all into one test, apparently it was a lot faster than I was led to believe (I imagined it becoming significantly slower as I added more, apparently not), good catch.

@sophiebits
Copy link
Collaborator

I think this looks good to me now, thanks.

@chenglou
Copy link
Contributor

chenglou commented Aug 5, 2014

@syranide 80 chars please, this triggers the linter =)

@syranide
Copy link
Contributor Author

syranide commented Aug 6, 2014

@chenglou Can do, although I was under the impression that char limits don't "really" apply wholesale to tests (many existing tests break 80 chars and other conventions). I don't mind doing it if you insist, but I feel that it would overall reduce the readability (as it's also using pairs of arguments to form a "test-case").

But again, I don't mind if you insist. :)

@chenglou
Copy link
Contributor

chenglou commented Aug 6, 2014

It's fine!

chenglou added a commit that referenced this pull request Aug 6, 2014
Simplified and improved test-cases for ReactMultiChildText-test
@chenglou chenglou merged commit aaa8a5f into facebook:master Aug 6, 2014
@syranide syranide deleted the rmctest branch August 8, 2014 09:38
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

Successfully merging this pull request may close these issues.

3 participants