Closed mattness closed 11 years ago
This was probably my .valueOf()
patch that broke it. I guess the solution is gonna be to revert that and only use valueOf()
where explicitly needed (like equal()
).
+1, this breaks commander.js's tests.
Even so, using it in equal()
, true()
and false()
(which appear to be the candidates for use) still cause existing test cases to break on node ~0.6 (and I guess anything < 0.7.7).
V8 is doing my head in with this.
It's very tricky to distinguish whether or not a given object has been wrapped by Object
in the newer versions or not; this.constructor
still looks the same as it normally would, only typeof this
returns "object"
instead of e.g. "string"
for a string.
So far the only way to "reliably" detect this appears to be a hack of checking that the constructor of the object appears to be a primitive type that might be wrapped, and then seeing if it was wrapped by looking at the typeof
.
Need to fix this...more packages will fail when upgrading to the latest version. Found a unit test in sentientwaffle/gift that worked with should.js 0.3.0), but fails with 0.6.3 I had to use the workaround for my fork.
It is most definitely caused by the valueOf when should is defined and is still in all versions after 0.6.something
At the repl:
test = new Date() Wed Jul 18 2012 11:00:31 GMT-0400 (EDT) test instanceof Date true Object(test).valueOf() 1342623631108
it should be returning 'Date'
+1
I'm using the latest version of Should and Node.js and this is still an issue. Any updates?
+1
+1
+1
+5
+5
I don't get it... if you guys want this feature, somebody write a patch.
IMO though you shouldn't be testing for instanceof
ever though (except for in constructors). Consider a Date
object returned from another VM context, it would fail this check.
Problem
Using should v0.6.3, the instanceof() method returns an incorrect result when called on a Date object and passed
Date
as its argument.Expected behavior
Calling instanceof(Date) on a Date object should not throw an AssertionError.
Steps to reproduce
Work-around