Added test for good measure to ensure class instances do not share protected member values
parent
e05a65d5fa
commit
4e2f174667
|
@ -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)"
|
||||
);
|
||||
} )();
|
||||
|
||||
|
|
Loading…
Reference in New Issue