archives

« Bugzilla Issues Index

#17 — Inelegancies with booleans


In 15.2.3.6-4-118 (http://hg.ecmascript.org/tests/test262/file/f25942ef2292/test/suite/ietestcenter/chapter15/15.2/15.2.3/15.2.3.6/15.2.3.6-4-118.js), the following line can read :

var verifyWritable = arrObj.length === 2 ? true : false;

Nothing truly fundamental, but that's inelegant. "arrObj.length === 2" is already a boolean.

I would write:
var verifyWritable = (arrObj.length === 2);
Parenthesis aren't compulsory, but they make clear to the reader that the boolean value is retrieved.


Agreed! This will be cleaned up with the next push of IE Test Center tests to Test262.

My best,

Dave


I forgot to point something out.

Some tests end with something like:
if(condition){
return true;
}
return false;

It could be seen as another inelegancy for purists (and asked to be replaced by "return condition;"), but in the context of tests, I think it's acceptable to have this pattern because it allows test readers to text-search for "return true" and "return false" in order to better understand which cases/flow path make the test fail or pass. Actually, may/could/should this be considered as some guideline for writing tests? (is it already?)


Yeah, I'm all too familiar with this pattern as well. If you have any suggestions on automatically detecting these so they can be fixed, I'm all ears. Otherwise it's going to take a bit of time to go through all the test cases by hand. Thanks again for the great suggestions!