Le 18/02/2013 16:48, Claus Reinke a écrit :
Talking about 100% coverage and "catching all errors" is never a
good combination - even if you should have found an example of
where this works, it will be an exception.
There are a couple of things I'm sure of. For instance, direct eval
aside (eval needs some specific work anyway because its semantics is
changed a lot), if you have 100% coverage, every instance of setting
to an undeclared variable will be caught. There is no exception.
Out of curiosity, what does your favorite test coverage tool report
for the source below? And what does it report when you comment
out the directive?
:-p Ok, there are exceptions if your code depends on semantic changes
described in the third section of the article (dynamic this/eval/arguments).
That's you case with how you define isStrict (dynamic this)
So: if your code does *not* depend on semantic changes, all instances of
setting to an undeclared variable will be caught.
So I guess the first thing to do when transitioning to strict mode is
getting rid of all the things that result in non-direct error semantic
changes (dynamic this/eval/arguments).
Thanks for the feedback,
David
Claus
----------------
function test(force) {
"use strict";
function isStrict() { return !this }
console.log(isStrict());
if (!force && (!isStrict() && (doocument="unndefined"))) {
console.log("we don't have lift-off");
} else {
console.log("ready to go!");
// do stuff
}
!isStrict() && console.log(doocument);
}
test(false);
test(true);
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss