- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
"How do you feel when you see this code on the first day of your job?" wonders Ritesh
#define EIGHTY 256
I would feel like I needed to correct it:
#define EIGHTY 128 #define ONE_HUNDRED_AND_TWENTY_EIGHT 0x80
Admin
The,fact,that,you,chose,to,focus,on,the,lack,of,a,comma,in,this,entire,thread,disturbs,me,.
Admin
A proper haiku Should make mention of seasons. Powdered cinnamon.
Admin
In fact this is a typo...
should be #define MIGHTY 256
Admin
Yes, I've seen them used occasionally when all the real tests in the file have been temporarily commented out for one reason or another. Though it makes less sense under Junit4, where you can disable tests with an @Ignore annotation.
I've also seen it on a common parent class, where the developer hadn't realised that making the class abstract was a better way of stopping JUnit from complaining.
Admin
A canary test is actually an internal test of your test setup. Sometimes the setup for your unit tests can be complicated. For example, if the test you need to load a Spring application context:
You may have made a number of changes and now all the unit tests for your module are broken. So you look.. was it something you did to the model?
However you have a simple test:
This can't possibly fail right? Well, it can, but only if JUnit's setup() method throws an Exception.
So now you know that tests are broken not because what they are testing is broken; but rather because the unit test setup is broken.
In this case, you might go back and check if you had any recent changes to your Spring application context. If you forgot a / on tag, it could make the XML invalid, and thus your unit tests don't load.
So, testAlwaysSucceed is your canary in the coal mine. It tells you if it's safe to rely on your tests.
Admin
// It's not too late/to whip it/whip it good.
[image]Admin
the shown code has been corrected and optimized as follows,
since it is bad form to use the same operator in the method a fix had been applied.
private static bool InvertBool(bool org)
{
}
I'm still waiting for the testcase to complete running It seems to be taking a while, perhaps I need a faster computer
Admin
Fun fact: Fahrzin's entry (smack it, flip it, etc...) is from the Xport Botball Controller firmware. I should know, I wrote it, back in 2004. :D
Had a couple of people poke me today going "HEY YOUR ON THEDAILYWTF!" Luckily, it was not the career ender that I feared. :)
Admin
Admin
Weird fact...
You can delete a file BEFORE you actually read it. Of course the file must be open beforehand, but the following sequence does work:
Admin
For intI = 7450 To 7450 'Now lets go and create the f*&ker ... snip... Next
I bet you an internet that the "run once" for-next loop was so the programmer could use EXIT FOR instead of GOTO.
Admin
I think that might only work in unixland, which is all that really matters.
'delete' is really 'unlink'. A file's disk space will only be recovered when there are no remaining links, and open file handles count as 'links'.
Admin
I'll not be surprised to see the following:
#define HUNDRED 256
Afterall, we all know 256 is 100 in Hex.
Admin
Yep. It's called Bilinear interpolation. It can be used to resize an image, to create Perlin noise, and for various other things.
The way all the variables are named kinda looks like decompiler output. This might not be a WTF at all.
Admin
An allusion to seasons, dual icons shine through true haiku, FUCK YOU WHALE!
Admin
TRWTF Is somebody think all know What fuck is Hauku
Admin
Admin
Nice :)
Admin
chang 1 tata 1 It's part of a drum machine chang 2 tata 2
fixed :p
Admin
Define 2 5 6, Now let's create the fucker, invert boolean !
Admin
OBIEE Magic numbers now abound Snow falls on my soul.
Admin
DBA in spring of life, know not the decode function. Keep it that way.
Admin
should delete the temp files here, no cannot because, we havent read it in yet
Admin
Admin
Admin
Sometime I use variable like temp1, temp2 when doing construction of code activity. Then during code review process it is discovered and changed to meet CMM5 level. That is advantage of CMM.
Admin
Admin
Kinda feels like it should be a haiku...
The pig go. Go is to the fountain. The pig put foot. Grunt. Foot in what? ketchup. The dove fly. Fly is in sky. The dove drop something. The something on the pig. The pig disgusting. The pig rattle. Rattle with dove. The dove angry. The pig leave. The dove produce. Produce is chicken wing. With wing bark. No Quack.
Admin
I wish I were first So I could write a comment To annoy, like frist
Admin
laoreet!
Admin
o'rly? in which hex?
Admin
Admin
Admin
Admin
Everybody knows All the best haikus end with "Boy becomes a man."
Admin
"Hex" is base 32 ... if you are expressing the base in base 4 1/2.
Admin
The funny thing about the re-implementation of the "!" operator is that he uses "!" in the function. So apparently he is aware that this operator exists and knows how to use it.
It's like when you ask someone to define a word and he uses that word in the definition: "What does 'eludicate" mean?" "Well, it's like, ya know, when you elucidate something."
Admin
Ah, but when we try to write a Haiku in English, it's a little tough to literally follow the "17 morae" rule, because, you see, there is no such thing as a "morae" in English. So we take the closest equivalent: syllables. Or to put it another way:
Seventeen "morae" Make Japanease Haiku but Adapt for English
Admin
Please be sensitive My son wrote haikus, and note No laughing matter
Admin
How many syllables do you want to count it as? I just checked thefreedictionary.com, and they give three pronunciations, the first two being a single syllable.
Admin
I'll assert that it's not /all that crazy/ to write a "testNothing" method in a JUnit class. ...based on the fact that I have done it a few times. It's usually not an ideal situation. It usually happens when you find you need to "comment out" other test methods, from time to time, due to the tests being very sensitive and some changes (possibly done by careless team members who don't run the tests!) break tests.
JUnit fails any test class that contains no test methods. So if you end up disabling all the test methods in a class, you're stuck -- unless you want to delete the class.
And if you're at a company that uses static code analysis rigorously, then the static code analysis will find the empty method objectionable. (That, in itself, can be a problem, because an empty do-nothing method can be quite correct for some subclasses using the Template design pattern. But that's another issue.) But, honestly, some programmers will put 'assertTrue(true);' just because they think that JUnit (or their coding standard) requires one and only one assert in each test method.
Sometimes these things are more, "Dude; that's just stupid", rather than a full "WTF!?!"
Admin
Once adventured too; Took an arrow to the knee; Now a common guard.
Admin
Sigh So many magic numbers, so little time.
At least the guy who defined EIGHTY did it right. Of course, it would have helped a bit if he'd actually gone to the trouble of:
#define EIGHTY 0x80
Admin
#define EIGHT_OH 128
I'm happy now.
Admin
Admin
Wait, there's a bug. I think you mean:
Admin
Who says decimal "80" is "eighty" but hex "80" is eight-oh? Maybe it's the other way around. I think you're reading decimal numbers as if they were hex.
Admin
5-7-5, dude.
Admin
I've just written a do-nothing unit test exactly like the one here.
The reason for it is this:
I'm configuring a Jenkins build server for an old project. The project currently doesn't have any unit tests.
For now my task is the build server, but we do intend to write tests for the project, so I need to have the xUnit functionality working in the build.
So I've written a dummy unit test so I can get Jenkins doing its thing.
I don't think this is a wrong at all. The example in the article here was well labeled as doing nothing; I can easily envision it having been written for a similar purpose. Perhaps the only sin here is that it wasn't subsequently deleted once its usefulness had passed.