On 06/06/2014 11:56, James Graham wrote:
On 06/06/14 11:41, Gijs Kruitbosch wrote:
On 06/06/2014 10:29, James Graham wrote:
On 05/06/14 10:38, Mike de Boer wrote:
As I tried to explain, the CommonJS API naively made sense to me at
the time. To others as well, because we’re happily using it. As I now
understand, some of us are very attached to a specific, different,
API.
FWIW I don't think that I am attached to a "specific different api". I
am, however, attached to api semantics that make writing good tests
easy. I don't think that either CommonJS or SimpleTest achieve this in
their current form. For SimpltTest I think the main problems are:
* The is() and isnot methods use non-strict equality.
I will go ahead and assert that if you have a test that relies on strict
versus non-strict equality, you should be using type checks to make that
explicit, not an extra '=' in your comparisons. Makes assumptions much
more explicit ("this return value should be a string '5' and not a
number 5") rather than implied by the comparison function.
IOW, I wouldn't consider this a bug.
So you believe that every single time you write is(some_func(), 5) you
should also write is(typeof some_func(), "number") ? That seems pretty
much insane to me and I will happily assert that no one actually does it
consistently.
If there are cases where you really don't care about the type — and I
can't think of very many — then in those cases you should explicitly
type convert as a signal that you are doing something strange.
No, I think that in 99.99% of cases, I don't care about the type, and
therefore I would normally use is() and not care that it's using
non-strict equality. I think the case where there is (a) a possibility
that I could get '5' instead of 5 when code is malfunctioning, and (b)
that would be a bug, is extremely rare, and therefore that extremely
rare case should require the additional code, instead of requiring extra
care on the part of test-writers to get their test to be strict about
types *all the time*.
~ Gijs
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform