This thread on Hacker News terrifies me

rikki cattermole rikki at cattermole.co.nz
Sat Sep 1 13:03:50 UTC 2018


On 02/09/2018 12:57 AM, tide wrote:
> On Saturday, 1 September 2018 at 12:49:12 UTC, rikki cattermole wrote:
>> On 02/09/2018 12:37 AM, tide wrote:
>>> On Saturday, 1 September 2018 at 08:18:03 UTC, Walter Bright wrote:
>>>> On 8/31/2018 7:28 PM, tide wrote:
>>>>> I'm just wondering but how would you code an assert to ensure the 
>>>>> variable for a title bar is the correct color? Just how many 
>>>>> asserts are you going to have in your real-time game that can be 
>>>>> expected to run at 144+ fps ?
>>>>
>>>> Experience will guide you on where to put the asserts.
>>>>
>>>> But really, just apply common sense. It's not just for software. If 
>>>> you're a physicist, and your calculations come up with a negative 
>>>> mass, you screwed up. If you're a mechanical engineer, and calculate 
>>>> a force of billion pounds from dropping a piano, you screwed up. If 
>>>> you're an accountant, and calculate that you owe a million dollars 
>>>> in taxes on a thousand dollars of income, you screwed up. If you 
>>>> build a diagnostic X-ray machine, and the control software computes 
>>>> a lethal dose to administer, you screwed up.
>>>>
>>>> Apply common sense and assert on unreasonable results, because your 
>>>> code is broken.
>>>
>>> That's what he, and apparently you don't get. How are you going to 
>>> use an assert to check that the color of a title bar is valid? Try 
>>> and implement that assert, and let me know what you come up with.
>>
>> If you have the ability to screenshot a window like I do, oh one 
>> simple method call is all that required with a simple index to get the 
>> color.
>>
>> But that isn't something I'd go test... Too much system-y stuff that 
>> can modify it.
> 
> And you're putting that into production code? Cause that's the entire 
> point of this topic :).

Goodness no. I can BSOD Windows just by writing user-land code that 
pretty much every program uses (yes related). Some things can definitely 
be tested in an assert, however like Walter has been arguing, are better 
left untested in production.

Keep in mind, a window whose decorations has changed color, is a very 
reasonable and should be expected situation. It is no where near an error.

This is one of the reasons I wouldn't bother with automated UI testing. 
Too many things can make it fail that is not related to your code, and 
integration may as well not exist cross-platform anyway. Let alone be 
well defined.


More information about the Digitalmars-d mailing list