Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's actually pretty straightforward:

turn_computer_off();

Assert(!is_computer_on(), "Computer should have been off but it's on.");

The opposite is a bit tricky, though.



This assert doesn't work like you think it does. If the computer is off is_computer_on is undefined, so if this is called when the computer is already off it could return a nonzero value, thus resolving to true even though the computer is already off.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: