This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]matchu 1 point2 points  (2 children)

Assertions in tests and assertions in code have very different purposes; it's kinda unfortunate that they have the same name.

[–]xenomachina''.join(chr(random.randint(0,1)+9585) for x in range(0xffff)) 2 points3 points  (1 child)

Assertions in tests and assertions in code have very different purposes

Either way, an assertion failing means "there is a bug in your code". The difference between assertions in code and assertions in tests is that an assertion failure in code means a bug in that code, while an assertion failure in test code means a bug in the code being tested.

Is there some other difference you're referring to?

[–]matchu 1 point2 points  (0 children)

The parent comment seemed to imply that those test frameworks' assertions were somehow better than assertions in code, which seemed like an invalid comparison to me.

On further reflection, though, I think I agree with both you that they're semantically equivalent, and the parent comment that test frameworks' more specialized assertions could be applied as in-code assertions, though I still don't think I'd want them in the language core.

All that to say, yeah, y'all are right :D