diff --git a/test/test-class-visibility.js b/test/test-class-visibility.js index c535a75..be5df66 100644 --- a/test/test-class-visibility.js +++ b/test/test-class-visibility.js @@ -66,7 +66,8 @@ var common = require( './common' ), foo = Foo(), // subtype - sub_foo = Foo.extend( {} )() + SubFoo = Foo.extend( {} ), + sub_foo = SubFoo() ; @@ -276,3 +277,34 @@ var common = require( './common' ), ); } )(); + +/** + * For good measure, let's make sure we didn't screw anything up. To ensure that + * the same object isn't being passed around to subtypes, ensure that multiple + * class instances do not share prototypes. + */ +( function testProtectedMembersAreNotSharedBetweenClassInstances() +{ + var val = 'foobar'; + + foo.setValue( 'prot', val ); + + // ensure that class instances do not share values (ensuring the same object + // isn't somehow being passed around) + assert.notEqual( + sub_foo.getProp( 'prot' ), + val, + "Class instances do not share protected values (subtype)" + ); + + // do the same for multiple instances of the same type + var sub_foo2 = SubFoo(); + sub_foo2.setValue( 'prot', val ); + + assert.notEqual( + sub_foo.getProp( 'prot' ), + val, + "Class instances do not share protected values (same type)" + ); +} )(); +