Also, choosing JavaScript as your coding language means that you need a testing framework. This is because unit testing isn't built into the language. This is okay. A few utility functions like assert() get the job done.
/**
* The assert function verifies if a condition is truthy.
*
* @param {boolean} condition - The condition that indicates if the
* assertion passes.
* @param {string} description - The message describing the assertion.
*/functionassert(condition:boolean,description:string):void{if(!condition)thrownewError(description);}
Another function I really like is the xor() function, because we can negate assertions using an exclusive or operation.
And now, we can verify a contrapositive assertion.
constnegated:boolean=true;constcondtion:boolean=/* some truthy assertion of application state. */;// now perform the assertionassert(xor(condition,negated),"This is a negated assertion.");
This example is obviously contrived, but a bunch of tiny little tools really help. You don't need a testing framework. You need responsibility.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Also, choosing JavaScript as your coding language means that you need a testing framework. This is because unit testing isn't built into the language. This is okay. A few utility functions like
assert()get the job done.Another function I really like is the
xor()function, because we can negate assertions using an exclusive or operation.And now, we can verify a contrapositive assertion.
This example is obviously contrived, but a bunch of tiny little tools really help. You don't need a testing framework. You need responsibility.