15 points

turned out to be a semicolon

permalink
report
reply
25 points

The tests wouldn’t even run of that was the issue, pretty sure (depends on the language I suppose)

permalink
report
parent
reply
16 points

fun situations can arise when you write , instead of ; For those not in the know, in c++ the comma operator evaluates the left expression, discards the value, then evaluates the right expression and returns the value. if you now have a a situation like this

int i = 0,
printf("some message");

i has a completely different value, since it actually uses the return value of printf instead

permalink
report
parent
reply
5 points

And people give Python shit for significant whitespace 😂

permalink
report
parent
reply
4 points

I’ll just write thousands of lines of code inside a global object… I’m sure I won’t put a semicolon where a comma should be…

permalink
report
parent
reply

Easy solution:

Find all: ;

Replace with: ,

permalink
report
parent
reply
4 points

And in python, no less. Sloppy.

permalink
report
parent
reply
11 points

now you have a group of very specific tests for later debugging

permalink
report
reply
94 points

Who tests the tests

permalink
report
reply
46 points

The Testmen?

permalink
report
parent
reply
5 points

Create tests to test the tests. Create tests to test those. Recurse to infinity

permalink
report
parent
reply
3 points

Who tests the tests for the tests

permalink
report
parent
reply
3 points

Unfortunately, if anyone, I do.

permalink
report
parent
reply
12 points

I’ve written some tests that got complex enough that I also wrote tests for the logic within the tests.

permalink
report
parent
reply
7 points

We do that for some of the more complex business logic. We wrote libraries, which are used by our tests, and we wrote tests which test the library functions to ensure they provide correct results.

What always worries me is that WE came up with that. It wasn’t some higher up, or business unit, or anything. Only because we cared to do our job correctly. If we didn’t - nobody would. Nobody is watching the testers (in my experience).

permalink
report
parent
reply
6 points

Mutation testing is quite cool. Basically it analyzes you code and makes changes that should break something. For example if you have if (foo) { ... } it will remove the branch or make the branch run every time. It then runs your tests and sees if anything fails. If the tests don’t fail then either you should add another test, or that code was truly dead and should be removed.

Of course this has lots of “false positives”. For example you may be checking if an allocation succeeded and don’t need to test if every possible allocation in your code fails, you trust that you can write if (!mem) abort() correctly.

permalink
report
parent
reply
1 point

Right,too much coverage is also a bad thing. It leads to having to work on the silly tests every time you change som implementation detail.

Good tests let the insides of the unit change without breaking, as long as the behave the same to the outside world.

permalink
report
parent
reply
-4 points

If you use your type system to make invalid states impossible to represent & your functions are pure, there less—maybe nothing—to test, which will save you from this scenario.

permalink
report
reply
26 points

You can’t have any bugs if you don’t write any code.

permalink
report
parent
reply
12 points

It must be nice to work only with toy cases where this is feasible.

permalink
report
parent
reply
0 points

Nothing toy-like about using ADTs to eliminate certain cases. When all cases are handled, your tests can move from a micro state to a macro state. Contraint types or linear types can be used to only allow certain sizes of inputs or require all file handles be closed when opened.

Naturally if your language’s type system is bad you can’t make these compile-time guarantees tho. Heck, a lot of developers are still using piss-poor languages with null or the infernce sucks with any.

permalink
report
parent
reply
15 points

Nothing to test? Lol what.

def add(a: int, b: int) -> int: return a * b

All types are correct. No side effects. Does the wrong thing.

permalink
report
parent
reply
5 points

Maybe it’s doing the right thing but is badly named

permalink
report
parent
reply
6 points

Maybe the it’s the English language that is wrong?

permalink
report
parent
reply
3 points

Lmao, I just had something similar

permalink
report
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 5.3K

    Monthly active users

  • 1.5K

    Posts

  • 33K

    Comments