Closed stimberm closed 10 years ago
LGTM, but pls add in test Boolean
and String
for consistency. Also I am not sure what you mean about .type
.
This pull request should be reject.
Since in should.js L23 - L25:
var should = function(obj) {
return new Assertion(util.isWrapperType(obj) ? obj.valueOf(): obj);
};
Should.js extract the wrappertype from obj specially, but this PR wrap the value again.
I think it would make should.js unconsistency.
And more, if want optimistic assertion, use .Number.
It does not wrap primitive back. Object
function wrap primive value to according wrapper, but do not touch reference types. instanceof
is useless with primitives in any case.
I want to fix #156 by having instanceof() be optimistic in the case of primitive values, in order to compensate for should() invoking valueOf()
Note that type() is currently also optimistic: