1
0
Fork 0

ClassBuilder.isInstanceOf() will no longer throw errors when given undefined for either argument

- Yes, this is just quickly adding a test to a pre-existing, terrible format.
  This will be refactored with the rest of the test case.
closure/master
Mike Gerwitz 2011-11-15 22:22:24 -05:00
parent 6c379968bc
commit 8e079129f3
2 changed files with 15 additions and 0 deletions

View File

@ -230,6 +230,11 @@ exports.isInstanceOf = function( type, instance )
{ {
var meta, implemented, i; var meta, implemented, i;
if ( !( type && instance ) )
{
return false;
}
try try
{ {
// check prototype chain (will throw an error if type is not a // check prototype chain (will throw an error if type is not a

View File

@ -102,6 +102,16 @@ assert.ok(
"Class instance is recognized by Class.isInstanceOf()" "Class instance is recognized by Class.isInstanceOf()"
); );
assert.ok(
Class.isInstanceOf( Foo, undefined ) === false,
"Checking instance of undefined will not throw an error"
);
assert.ok(
Class.isInstanceOf( undefined, {} ) === false,
"Checking for instance of undefined will not throw an error"
);
assert.ok( assert.ok(
!( Class.isInstanceOf( Foo, Foo ) ), !( Class.isInstanceOf( Foo, Foo ) ),
"Class is not an instance of itself when uninstantiated" "Class is not an instance of itself when uninstantiated"