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

#482 #483 #491 Make word breaker testable and start writing tests. #492

Merged
merged 6 commits into from
Jun 13, 2020

Conversation

danfickle
Copy link
Owner

We need a much more robust line breaker so any suggested unit tests will be incorporated.

@syjer
Copy link
Contributor

syjer commented May 27, 2020

I wonder if we could do a property based test in this case (using something like junit quickcheck ).

Plus minor behaviour change for word break method to avoid setting ends-on -soft-hyphen flag for soft hyphen at end of box.
This is to make sure infinite loop fixes do not break this functionality.
…w line.

With test to prove that we don't trigger safety valve with lots of unbreakable words. Safety valve should only be triggered if there is still a bug in our code.
This should ensure no infinite loop bugs creep in over time.
@danfickle danfickle marked this pull request as ready for review June 13, 2020 05:04
@danfickle
Copy link
Owner Author

This pr does the following:

  • Makes line breaker (by word) unit testable.
  • Adds several unit tests to exercise line breaker.
  • Adds end to end random fuzz testing for the line breaking. This includes all white-space values, both break-word and normal line breaking, with fonts which have a zero width soft hyphen as well as one that does not, in divs from 0px wide upwards. A random sampling of 5 character sequences (with the five characters chosen being special meaning in the line break algorithms) is used when the test is run each time, with the seed output to logs so any troublesome runs can be investigated. Hopefully, this random and regular testing will stop endless loop bugs creeping in again.
  • A safety valve for line breaking attempts when break-word is in effect. Triggering this safety check will deliberately result in a fatal exception which should be reported. Yes, this is a code smell, but one thought necessary after at least 3 endless loop bugs in my implementation of this complex functionality. We should be able to remove the safety check if the current fixed implementation proves robust.

@danfickle
Copy link
Owner Author

I wonder if we could do a property based test in this case (using something like junit quickcheck ).

I initially thought of parameter testing, but was underwhelmed by the syntax in Junit 4. After looking at the documentation of quickcheck, I probably should have used it rather than reinventing the wheel...

@danfickle danfickle merged commit 9ab4c10 into open-dev-v1 Jun 13, 2020
@danfickle danfickle deleted the robust_breaker branch June 13, 2020 05:44
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.

2 participants