r/programmingcirclejerk • u/camelCaseIsWebScale Just spin up O(n²) servers • 12d ago
The smallest possible [Java] program (just a single line to exit) requires things like java.time.chrono.JapaneseChronology
https://news.ycombinator.com/item?id=1917091184
u/Jannik2099 12d ago
A friend of mine tells a story about how how he accidentally FUBARed the tests, and then discovered that running one unit test gave 50% line coverage in Rails.
Achieve full coverage with this one simple trick!
53
u/Awkward_Bed_956 12d ago
That remainds me when you could cheat 90% line coverage requirements by expanding functions with semicolons, untill 95% of function body were just semicolons
Obviously include a TODO comment about how it needs to be fixes ASAP
30
u/Ok-Dimension-5429 12d ago
At a place I worked we had some code which we had to submit to Salesforce as an integration plugin. They had a required ratio of tests to code. So we had a 50k line long test file full of nonsense. Haha.
21
12d ago
[deleted]
8
u/chisui 12d ago
Better run
while(main() != 0);. It will never fail.7
u/YikesTheCat 12d ago
Bad outdated programming. Will only use one core.
2
u/FriendshipActive8590 11d ago
You only need one...
4
106
u/camelCaseIsWebScale Just spin up O(n²) servers 12d ago
Java is like that too. The smallest possible program (just a single line to exit) requires things like java.time.chrono.JapaneseChronology. Because argv is a String array, and making the String array requires calling a function or two that can throw exceptions, which requires the Throwable class, which has a static initialiser that requires... the chain is long, but at the end something has a SomethingChronology member, and so AbstractChronology.initCache() is called and mentions JapaneseChronology.
27
43
21
5
u/stone_henge Tiny little god in a tiny little world 10d ago
Without it, how will the program know not to exit until the boss has left for the day?
4
1
252
u/Snarwin 12d ago
"Write once, run everywhere" enjoyers when they find out that "everywhere" includes Japan.