Open ptomato opened 6 months ago
I'm trying to put together guidance on writing a testing plan, so I thought I'd use this proposal as a sample.
There may be some things in this list that are past the point of diminishing returns, like repeating all of the success cases for both arrays and non-array iterables, or all of the iterator protocol boilerplate.
This looks like a good amount of detail for a testing plan to me, but I agree that many of the tests are past the point of diminishing returns. In particular:
Cases you've missed:
.return
is called) when a non-number value is yielded. (It's implicitly covered in the "failure to conform to iterable protocol" section, but you don't have one for .return
behaving correctly, which I think is the only thing actually worth testing.)valueOf
and toString
methods are not called.is extensible / Function.prototype: I've found that many existing functions do actually test these! That's how they found their way onto my "boilerplate" list :smile: I've been toying with the idea of just automatically generating the "boilerplate" tests for all functions, that would take the burden off of proposal writers to write these.
iterator protocol: Agreed. Now that I've written this list out, though, seems like a candidate for automation as well... I'll note it down elsewhere for the future.
Each type of primitive: Sure, but it's also very little extra cost to write a loop over an array of [undefined, null, true, '25', 25n, Symbol('25'), {valueOf() {return 25;}}]
Array vs non-array iterables: Agreed. I'd still suggest testing an empty iterable distinct from an empty array though.
Missed cases: Added, thanks.
I thought of a few more missed cases as well:
length
Boilerplate
Success cases
Failure cases
Other edge cases
return
is called) after yielding a non-NumbervalueOf
,toString
, or[Symbol.toPrimitive]
methods called[Symbol.iterator]
method, not by gettinglength