patak-dev / vite-plugin-terminal

Log in the node terminal from the browser
MIT License
267 stars 17 forks source link

Assert is backwards? #8

Closed jods4 closed 2 years ago

jods4 commented 2 years ago

For a method called assert, I'd have opposite expectations to what this cool lib is doing...

In other languages / framework I know of, an assertion is expected to be true. assert calls would throw or display a message when an assertion is violated, i.e. it's false.

Example in C#

// Checks that the index is positive.
// If it's not, display an error message.
Debug.Assert(index > -1);

This library displays a green message when asserts are true. Seems to me it should instead display a red message when asserts are false.

The choice of color (green) is itself an indication this is backwards: we need to know what's wrong (red) not what's working as intended (green).

patak-dev commented 2 years ago

Thanks @jods4! released with a proper assertion (and including the message "Assertion failed: " like the browser does) in 0.0.11

jods4 commented 2 years ago

That was quick! Thanks 🙏