1
0
Fork 0

Added inheritance instanceof assertions

closure/master
Mike Gerwitz 2010-11-10 21:39:09 -05:00
parent 909542d19b
commit fdf389ba2e
1 changed files with 31 additions and 0 deletions

View File

@ -66,3 +66,34 @@ for ( var prop in sub_props )
"Subtype contains its own properties: " + prop "Subtype contains its own properties: " + prop
); );
} }
assert.ok(
( new SubFoo() instanceof Foo ),
"Subtypes must be considered to be instances of their supertypes"
);
// Foo
// |
// SubFoo
// / \
// SubSubFoo SubSubFoo2
//
var SubSubFoo = SubFoo.extend(),
SubSubFoo2 = SubFoo.extend();
assert.ok(
( new SubSubFoo() instanceof Foo ),
"Sub-subtypes should be instances of their super-supertype"
);
assert.ok(
!( new SubFoo() instanceof SubSubFoo ),
"Supertypes should not be considered instances of their subtypes"
);
assert.ok(
!( new SubSubFoo2() instanceof SubSubFoo ),
"Subtypes should not be considered instances of their siblings"
);