1
0
Fork 0

[#25] Began moving test-class-visibility over to new test case style

closure/master
Mike Gerwitz 2011-11-02 22:04:53 -04:00
parent 48dbfea990
commit f15fa03a3b
1 changed files with 575 additions and 566 deletions

View File

@ -23,7 +23,6 @@
*/ */
var common = require( './common' ), var common = require( './common' ),
assert = require( 'assert' ),
Class = common.require( 'class' ), Class = common.require( 'class' ),
Interface = common.require( 'interface' ), Interface = common.require( 'interface' ),
util = common.require( 'util' ), util = common.require( 'util' ),
@ -136,63 +135,67 @@ var common = require( './common' ),
; ;
/** require( 'common' ).testCase(
* Public members are the only members added to the instance's prototype to be
* accessible externally
*/
( function testPublicMembersAreAccessbileExternally()
{ {
assert.equal( /**
* Public members are the only members added to the instance's prototype to
* be accessible externally
*/
'Public members are accessible externally': function()
{
this.assertEqual(
foo.pub, foo.pub,
pub, pub,
"Public properties are accessible via public interface" "Public properties are accessible via public interface"
); );
assert.equal( this.assertEqual(
foo.pubf(), foo.pubf(),
pub, pub,
"Public methods are accessible via public interface" "Public methods are accessible via public interface"
); );
} )(); },
/** /**
* For reasons that are discussed in the next test (writing to public * For reasons that are discussed in the next test (writing to public
* properties), we need to make sure public members are available internally. * properties), we need to make sure public members are available
* Actually, we don't need to test public methods, really, but it's in there for * internally. Actually, we don't need to test public methods, really, but
* good measure. Who knows what bugs may be introduced in the future. * it's in there for good measure. Who knows what bugs may be introduced in
* the future.
* *
* This ensures that the getter is properly proxying the value to us. * This ensures that the getter is properly proxying the value to us.
*/ */
( function testPublicMembersAreAccessibleInternally() 'Public members are accessible internally': function()
{ {
assert.equal( this.assertEqual(
foo.getProp( 'pub' ), foo.getProp( 'pub' ),
pub, pub,
"Public properties are accessible internally" "Public properties are accessible internally"
); );
assert.equal( this.assertEqual(
foo.getProp( 'pubf' )(), foo.getProp( 'pubf' )(),
pub, pub,
"Public methods are accessible internally" "Public methods are accessible internally"
); );
} )(); },
/** /**
* This may sound like an odd test, but it's actually very important. Due to how * This may sound like an odd test, but it's actually very important. Due to
* private/protected members are implemented, it compromises public members. In * how private/protected members are implemented, it compromises public
* fact, public members would not work internally without what is essentially a * members. In fact, public members would not work internally without what
* proxy via setters. * is essentially a proxy via setters.
* *
* This test is to ensure that the setter is properly forwarding writes to the * This test is to ensure that the setter is properly forwarding writes to
* object within the prototype chain containing the public values. Otherwise, * the object within the prototype chain containing the public values.
* setting the value would simply mask it in the prototype chain. The value * Otherwise, setting the value would simply mask it in the prototype chain.
* would appear to have changed internally, but when accessed externally, the * The value would appear to have changed internally, but when accessed
* value would still be the same. That would obviously be a problem ;) * externally, the value would still be the same. That would obviously be a
* problem ;)
*/ */
( function testPublicPropertiesAreWritableInternally() 'Public properties are writable internally': function()
{ {
var val = 'moomookittypoo'; var val = 'moomookittypoo';
@ -200,7 +203,7 @@ var common = require( './common' ),
foo.setValue( 'pub', val ); foo.setValue( 'pub', val );
// we should see that change internally... // we should see that change internally...
assert.equal( this.assertEqual(
foo.getProp( 'pub' ), foo.getProp( 'pub' ),
val, val,
"Setting the value of a public property internally should be " + "Setting the value of a public property internally should be " +
@ -208,16 +211,16 @@ var common = require( './common' ),
); );
// ...as well as externally // ...as well as externally
assert.equal( this.assertEqual(
foo.pub, foo.pub,
val, val,
"Setting the value of a public property internally should be " + "Setting the value of a public property internally should be " +
"observable /externally/" "observable /externally/"
); );
} )(); },
( function testProtectedAndPrivateMembersAreNotAccessibleExternally() 'Protected and private members are not accessible externally': function()
{ {
// browsers that do not support the property proxy will not support // browsers that do not support the property proxy will not support
// encapsulating properties // encapsulating properties
@ -226,38 +229,38 @@ var common = require( './common' ),
return; return;
} }
assert.equal( this.assertEqual(
foo.peeps, foo.peeps,
undefined, undefined,
"Protected properties are inaccessible via public interface" "Protected properties are inaccessible via public interface"
); );
assert.equal( this.assertEqual(
foo.parts, foo.parts,
undefined, undefined,
"Private properties are inaccessible via public interface" "Private properties are inaccessible via public interface"
); );
assert.equal( this.assertEqual(
foo.protf, foo.protf,
undefined, undefined,
"Protected methods are inaccessible via public interface" "Protected methods are inaccessible via public interface"
); );
assert.equal( this.assertEqual(
foo.privf, foo.privf,
undefined, undefined,
"Private methods are inaccessible via public interface" "Private methods are inaccessible via public interface"
); );
} )(); },
/** /**
* Protected members should be accessible from within class methods * Protected members should be accessible from within class methods
*/ */
( function testProtectedMembersAreAccessibleInternally() 'Protected members are accessible internally': function()
{ {
assert.equal( this.assertEqual(
foo.getProp( 'peeps' ), foo.getProp( 'peeps' ),
prot, prot,
"Protected properties are available internally" "Protected properties are available internally"
@ -265,20 +268,20 @@ var common = require( './common' ),
// invoke rather than checking for equality, because the method may be // invoke rather than checking for equality, because the method may be
// wrapped // wrapped
assert.equal( this.assertEqual(
foo.getProp( 'protf' )(), foo.getProp( 'protf' )(),
prot, prot,
"Protected methods are available internally" "Protected methods are available internally"
); );
} )(); },
/** /**
* Private members should be accessible from within class methods * Private members should be accessible from within class methods
*/ */
( function testPrivateMembersAreAccessibleInternally() 'Private members are accessible internally': function()
{ {
assert.equal( this.assertEqual(
foo.getProp( 'parts' ), foo.getProp( 'parts' ),
priv, priv,
"Private properties are available internally" "Private properties are available internally"
@ -286,20 +289,20 @@ var common = require( './common' ),
// invoke rather than checking for equality, because the method may be // invoke rather than checking for equality, because the method may be
// wrapped // wrapped
assert.equal( this.assertEqual(
foo.getProp( 'privf' )(), foo.getProp( 'privf' )(),
priv, priv,
"Private methods are available internally" "Private methods are available internally"
); );
} )(); },
/** /**
* Inheritance 101; protected members should be available to subtypes * Inheritance 101; protected members should be available to subtypes
*/ */
( function testProtectedMembersAreInheritedFromParent() 'Protected members are inherited from parent': function()
{ {
assert.equal( this.assertEqual(
sub_foo.getProp( 'peeps' ), sub_foo.getProp( 'peeps' ),
prot, prot,
"Protected properties are available to subtypes" "Protected properties are available to subtypes"
@ -307,18 +310,19 @@ var common = require( './common' ),
// invoke rather than checking for equality, because the method may be // invoke rather than checking for equality, because the method may be
// wrapped // wrapped
assert.equal( this.assertEqual(
sub_foo.getProp( 'protf' )(), sub_foo.getProp( 'protf' )(),
prot, prot,
"Protected methods are available to subtypes" "Protected methods are available to subtypes"
); );
} )(); },
/** /**
* Interface 101-2: We do not want private members to be available to subtypes. * Interface 101-2: We do not want private members to be available to
* subtypes.
*/ */
( function testPrivateMembersOfSupertypesAreInaccessibleToSubtypes() 'Private members of supertypes are inaccessible to subtypes': function()
{ {
// browsers that do not support the property proxy will not support // browsers that do not support the property proxy will not support
// encapsulating properties // encapsulating properties
@ -327,7 +331,7 @@ var common = require( './common' ),
return; return;
} }
assert.equal( this.assertEqual(
sub_foo.getProp( 'parts' ), sub_foo.getProp( 'parts' ),
undefined, undefined,
"Private properties of supertypes should be unavailable to subtypes" "Private properties of supertypes should be unavailable to subtypes"
@ -335,28 +339,28 @@ var common = require( './common' ),
// invoke rather than checking for equality, because the method may be // invoke rather than checking for equality, because the method may be
// wrapped // wrapped
assert.equal( this.assertEqual(
sub_foo.getProp( 'privf' ), sub_foo.getProp( 'privf' ),
undefined, undefined,
"Private methods of supertypes should be unavailable to subtypes" "Private methods of supertypes should be unavailable to subtypes"
); );
} )(); },
/** /**
* For good measure, let's make sure we didn't screw anything up. To ensure that * For good measure, let's make sure we didn't screw anything up. To ensure
* the same object isn't being passed around to subtypes, ensure that multiple * that the same object isn't being passed around to subtypes, ensure that
* class instances do not share prototypes. * multiple class instances do not share prototypes.
*/ */
( function testProtectedMembersAreNotSharedBetweenClassInstances() 'Protected members are not shared between class instances': function()
{ {
var val = 'foobar'; var val = 'foobar';
foo.setValue( 'prot', val ); foo.setValue( 'prot', val );
// ensure that class instances do not share values (ensuring the same object // ensure that class instances do not share values (ensuring the same
// isn't somehow being passed around) // object isn't somehow being passed around)
assert.notEqual( this.assertNotEqual(
sub_foo.getProp( 'prot' ), sub_foo.getProp( 'prot' ),
val, val,
"Class instances do not share protected values (subtype)" "Class instances do not share protected values (subtype)"
@ -366,119 +370,120 @@ var common = require( './common' ),
var sub_foo2 = SubFoo(); var sub_foo2 = SubFoo();
sub_foo2.setValue( 'prot', val ); sub_foo2.setValue( 'prot', val );
assert.notEqual( this.assertNotEqual(
sub_foo.getProp( 'prot' ), sub_foo.getProp( 'prot' ),
val, val,
"Class instances do not share protected values (same type)" "Class instances do not share protected values (same type)"
); );
} )(); },
/** /**
* When a method is called, 'this' is bound to the property object containing * When a method is called, 'this' is bound to the property object
* private and protected members. Returning 'this' would therefore be a very bad * containing private and protected members. Returning 'this' would
* thing. Not only would it break encapsulation, but it would likely have other * therefore be a very bad thing. Not only would it break encapsulation, but
* problems down the road. * it would likely have other problems down the road.
* *
* Therefore, we have to check the return value of the method. If the return * Therefore, we have to check the return value of the method. If the return
* value is the property object that it was bound to, we need to replace the * value is the property object that it was bound to, we need to replace the
* return value with the actual class instance. This allows us to transparently * return value with the actual class instance. This allows us to
* enforce encapsulation. How sweet is that? * transparently enforce encapsulation. How sweet is that?
*/ */
( function testReturningSelfFromMethodShouldReturnInstanceNotPropObj() 'Returning self from method should return instance not prop obj': function()
{ {
assert.deepEqual( this.assertDeepEqual(
foo.getSelf(), foo.getSelf(),
foo, foo,
"Returning 'this' from a method should return instance of self" "Returning 'this' from a method should return instance of self"
); );
// what happens in the case of inheritance? // what happens in the case of inheritance?
assert.deepEqual( this.assertDeepEqual(
sub_foo.getSelf(), sub_foo.getSelf(),
sub_foo, sub_foo,
"Returning 'this' from a super method should return the subtype" "Returning 'this' from a super method should return the subtype"
); );
// finally, overridden methods should still return the instance // finally, overridden methods should still return the instance
assert.deepEqual( this.assertDeepEqual(
sub_foo.getSelfOverride(), sub_foo.getSelfOverride(),
sub_foo, sub_foo,
"Returning 'this' from a overridden method should return the subtype" "Returning 'this' from a overridden method should return subtype"
); );
} )(); },
/** /**
* This one's a particularly nasty bug that snuck up on me. Private members * This one's a particularly nasty bug that snuck up on me. Private members
* should not be accessible to subtypes; that's a given. However, they need to * should not be accessible to subtypes; that's a given. However, they need
* be accessible to the parent methods. For example, let's say class Foo * to be accessible to the parent methods. For example, let's say class Foo
* contains public method bar(), which invokes private method _baz(). This is * contains public method bar(), which invokes private method _baz(). This
* perfectly legal. Then SubFoo extends Foo, but does not override method bar(). * is perfectly legal. Then SubFoo extends Foo, but does not override method
* Invoking method bar() should still be able to invoke private method _baz(), * bar(). Invoking method bar() should still be able to invoke private
* because, from the perspective of the parent class, that operation is * method _baz(), because, from the perspective of the parent class, that
* perfectly legal. * operation is perfectly legal.
* *
* The resolution of this bug required a slight system redesign. The short-term * The resolution of this bug required a slight system redesign. The
* fix was to declare any needed private members are protected, so that they * short-term fix was to declare any needed private members are protected,
* were accessible by the subtype. * so that they were accessible by the subtype.
*/ */
( function testParentMethodsCanAccessPrivateMembersOfParent() 'Parent methods can access private members of parent': function()
{ {
// properties // properties
assert.equal( this.assertEqual(
sub_foo.getPrivProp(), sub_foo.getPrivProp(),
priv, priv,
"Parent methods should have access to the private properties of the " + "Parent methods should have access to the private properties of " +
"parent" "the parent"
); );
// methods // methods
assert.equal( this.assertEqual(
sub_foo.invokePriv(), sub_foo.invokePriv(),
priv, priv,
"Parent methods should have access to the private methods of the parent" "Parent methods should have access to the private methods of the " +
"parent"
); );
// should apply to super-supertypes too // should apply to super-supertypes too
assert.equal( this.assertEqual(
sub_sub_foo.getPrivProp(), sub_sub_foo.getPrivProp(),
priv, priv,
"Parent methods should have access to the private properties of the " + "Parent methods should have access to the private properties of " +
"parent (2)" "the parent (2)"
); );
assert.equal( this.assertEqual(
sub_sub_foo.invokePriv(), sub_sub_foo.invokePriv(),
priv, priv,
"Parent methods should have access to the private methods of the " + "Parent methods should have access to the private methods of the " +
"parent (2)" "parent (2)"
); );
} )(); },
/** /**
* When a parent method is invoked, the parent should not be given access to the * When a parent method is invoked, the parent should not be given access to
* private members of the invoking subtype. Why? * the private members of the invoking subtype. Why?
* *
* This is not a matter of whether or not this is possible to do. In fact it's * This is not a matter of whether or not this is possible to do. In fact
* relatively simple to implement. The issue is whether or not it makes sense. * it's relatively simple to implement. The issue is whether or not it makes
* Consider a compiled language. Let's say Foo and SubFoo (as defined in this * sense. Consider a compiled language. Let's say Foo and SubFoo (as
* test case) were written in C++. Should Foo have access to a private property * defined in this test case) were written in C++. Should Foo have access to
* on SubFoo when it is overridden? * a private property on SubFoo when it is overridden?
* *
* No - that doesn't make sense. The private member is not a member of Foo and * No - that doesn't make sense. The private member is not a member of Foo
* therefore Foo would fail to even compile. Alright, but we don't have such a * and therefore Foo would fail to even compile. Alright, but we don't have
* restriction in our case. So why not implement it? * such a restriction in our case. So why not implement it?
* *
* Proponents of such an implementation are likely thinking of the act of * Proponents of such an implementation are likely thinking of the act of
* inheriting methods as a copy/paste type of scenario. If we inherit public * inheriting methods as a copy/paste type of scenario. If we inherit public
* method baz(), and it were a copy/paste type of situation, then surely baz() * method baz(), and it were a copy/paste type of situation, then surely
* would have access to all of SubFoo's private members. But that is not the * baz() would have access to all of SubFoo's private members. But that is
* case. Should baz() be defined as a member of Foo, then its scope is * not the case. Should baz() be defined as a member of Foo, then its scope
* restricted to Foo and its supertypes. That is not how OO works. It is /not/ * is restricted to Foo and its supertypes. That is not how OO works. It is
* copy/paste. It is inheriting functionality. * /not/ copy/paste. It is inheriting functionality.
*/ */
( function testParentsShouldNotHaveAccessToPrivateMembersOfSubtypes() 'Parents should not have access to private members of subtypes': function()
{ {
// browsers that do not support the property proxy will not support // browsers that do not support the property proxy will not support
// encapsulating properties // encapsulating properties
@ -488,30 +493,30 @@ var common = require( './common' ),
} }
// property // property
assert.equal( this.assertEqual(
sub_foo.nonOverrideGetProp( '_pfoo' ), sub_foo.nonOverrideGetProp( '_pfoo' ),
undefined, undefined,
"Parent should not have access to private properties of subtype when " + "Parent should not have access to private properties of subtype " +
"a parent method is invoked" "whena parent method is invoked"
); );
// member // member
assert.equal( this.assertEqual(
sub_foo.nonOverrideGetProp( '_myOwnPrivateFoo' ), sub_foo.nonOverrideGetProp( '_myOwnPrivateFoo' ),
undefined, undefined,
"Parent should not have access to private methods of subtype when " + "Parent should not have access to private methods of subtype " +
"a parent method is invoked" "when a parent method is invoked"
); );
} )(); },
/** /**
* Visibility escalation (protected -> private) should be permitted * Visibility escalation (protected -> private) should be permitted
*/ */
( function testCanEscalateMemberVisibility() 'Can escalate member visibility': function()
{ {
// escalate // escalate
assert.doesNotThrow( function() this.assertDoesNotThrow( function()
{ {
Class( Class(
{ {
@ -524,7 +529,7 @@ var common = require( './common' ),
}, Error, "Can escalate visibility of subtype members" ); }, Error, "Can escalate visibility of subtype members" );
// same level of visibility // same level of visibility
assert.doesNotThrow( function() this.assertDoesNotThrow( function()
{ {
Class( Class(
{ {
@ -535,17 +540,17 @@ var common = require( './common' ),
'override protected baz': function() {}, 'override protected baz': function() {},
} ); } );
}, Error, "Can retain level of visibility for subtype members" ); }, Error, "Can retain level of visibility for subtype members" );
} )(); },
/** /**
* We should /not/ be able to de-escalate member visibility * We should /not/ be able to de-escalate member visibility
* (public -> {protected,private} * (public -> {protected,private}
*/ */
( function testCannotDeescalateMemberVisibility() 'Cannot de-escalate member visibility': function()
{ {
// public -> protected // public -> protected
assert.throws( function() this.assertThrows( function()
{ {
Class( Class(
{ {
@ -553,9 +558,9 @@ var common = require( './common' ),
} ).extend( { } ).extend( {
'protected foo': 'bar', 'protected foo': 'bar',
} ); } );
}, Error, "Cannot de-escalate visibility of subtype props to protected" ); }, Error, "Cannot de-escalate visibility of sub-props to protected" );
assert.throws( function() this.assertThrows( function()
{ {
Class( Class(
{ {
@ -563,11 +568,11 @@ var common = require( './common' ),
} ).extend( { } ).extend( {
'protected baz': function() {}, 'protected baz': function() {},
} ); } );
}, Error, "Cannot de-escalate visibility of subtype methods to protected" ); }, Error, "Cannot de-escalate visibility of sub-methods to protected" );
// public -> private // public -> private
assert.throws( function() this.assertThrows( function()
{ {
Class( Class(
{ {
@ -577,7 +582,7 @@ var common = require( './common' ),
} ); } );
}, Error, "Cannot de-escalate visibility of subtype props to private" ); }, Error, "Cannot de-escalate visibility of subtype props to private" );
assert.throws( function() this.assertThrows( function()
{ {
Class( Class(
{ {
@ -585,11 +590,11 @@ var common = require( './common' ),
} ).extend( { } ).extend( {
'private baz': function() {}, 'private baz': function() {},
} ); } );
}, Error, "Cannot de-escalate visibility of subtype methods to private" ); }, Error, "Cannot de-escalate visibility of sub-methods to private" );
// protected -> private // protected -> private
assert.throws( function() this.assertThrows( function()
{ {
Class( Class(
{ {
@ -597,9 +602,9 @@ var common = require( './common' ),
} ).extend( { } ).extend( {
'private foo': 'bar', 'private foo': 'bar',
} ); } );
}, Error, "Cannot de-escalate visibility of subtype props to private2" ); }, Error, "Cannot de-escalate visibility of sub-props to private2" );
assert.throws( function() this.assertThrows( function()
{ {
Class( Class(
{ {
@ -607,17 +612,17 @@ var common = require( './common' ),
} ).extend( { } ).extend( {
'private baz': function() {}, 'private baz': function() {},
} ); } );
}, Error, "Cannot de-escalate visibility of subtype methods to private2" ); }, Error, "Cannot de-escalate visibility of sub-methods to private2" );
} )(); },
/** /**
* With the visibility implementation, it's possible that __super() will not * With the visibility implementation, it's possible that __super() will not
* work properly with protected methods. This is because of the override lookup * work properly with protected methods. This is because of the override
* process (which hopefully was fixed in the commit before this test was * lookup process (which hopefully was fixed in the commit before this test
* originally introduced: ce736bea). * was originally introduced: ce736bea).
*/ */
( function testCallingSuperMethodWorksProperlyWithProtectedMethods() 'Calling super method works properly with protected methods': function()
{ {
var val = 'foobar', var val = 'foobar',
result = Class( { result = Class( {
@ -634,40 +639,43 @@ var common = require( './common' ),
}, },
} )().foo(); } )().foo();
assert.equal( result, val, this.assertEqual( result, val,
"__super() calls work with protected overrides" "__super() calls work with protected overrides"
); );
} )(); },
/** /**
* Concrete implementations of interfaces should have to follow the same * Concrete implementations of interfaces should have to follow the same
* visibility de-escalation rules as defined in the above tests (otherwise, that * visibility de-escalation rules as defined in the above tests (otherwise,
* defeats the purpose of an interface). In other words, they must be public. * that defeats the purpose of an interface). In other words, they must be
* public.
*/ */
( function testVisibilityDeescalationRulesApplyToInterfaces() 'Visibility de-escalation rulse apply to interfaces': function()
{ {
assert.throws( function() this.assertThrows( function()
{ {
Class.implement( Interface( { 'abstract public foo': [] } ) ).extend( Class.implement( Interface( { 'abstract public foo': [] } ) )
.extend(
{ {
// should throw an exception; visibility de-escalation // should throw an exception; visibility de-escalation
'protected foo': function() {}, 'protected foo': function() {},
} ); }
);
}, Error, "Cannot de-escalate visibility for interface members" ); }, Error, "Cannot de-escalate visibility for interface members" );
} )(); },
/** /**
* Due to the way the property object is laid atop of the public members, we * Due to the way the property object is laid atop of the public members, we
* need to ensure that protected methods' functionality can /actually/ be * need to ensure that protected methods' functionality can /actually/ be
* overridden, since the protected method is higher in the prototype chain and * overridden, since the protected method is higher in the prototype chain
* therefore will be accessed before the public method. * and therefore will be accessed before the public method.
* *
* We don't care about private -> protected, because that's not possible through * We don't care about private -> protected, because that's not possible
* inheritance. * through inheritance.
*/ */
( function testCanOverrideProtectedMethodFunctionalityWithPublic() 'Can override protected method functionality with public': function()
{ {
// get the result of invoking overridden foo() // get the result of invoking overridden foo()
var result = Class( var result = Class(
@ -685,22 +693,22 @@ var common = require( './common' ),
}, },
} )().foo(); } )().foo();
// if the override was successful, we'll be able to invoke the overridden // if the override was successful, we'll be able to invoke the
// method // overridden method
assert.equal( result, true, this.assertEqual( result, true,
"Can properly override protected methods with public" "Can properly override protected methods with public"
); );
} )(); },
/** /**
* There was an issue where the private property object was not proxying values * There was an issue where the private property object was not proxying
* to the true protected values. This would mean that when the parent * values to the true protected values. This would mean that when the parent
* initialized protected values, those values would be unavailable to the * initialized protected values, those values would be unavailable to the
* subtype. Instead, the value available to the subtype was the value that was * subtype. Instead, the value available to the subtype was the value that
* assigned as the default value in the class definition. * was assigned as the default value in the class definition.
*/ */
( function testProtectedValuesAreAvailableToSubtypesWhenSetByParentMethod() 'Protected values are available to subtypes when set by parent': function()
{ {
var expected = 5, var expected = 5,
result = Class( result = Class(
@ -719,22 +727,22 @@ var common = require( './common' ),
}, },
} )().getVal(); } )().getVal();
assert.equal( result, expected, this.assertEqual( result, expected,
"Subtypes should have acess to protected properties values set by " + "Subtypes should have acess to protected properties values set " +
"super methods" "by super methods"
); );
} )(); },
/** /**
* There was a bug introduced when we prevented protected members from * There was a bug introduced when we prevented protected members from
* overriding public (since in the prototype chain, protected members are laid * overriding public (since in the prototype chain, protected members are
* atop public, and this cannot change). This bug would disallow protected * laid atop public, and this cannot change). This bug would disallow
* members from being overridden by other protected members. * protected members from being overridden by other protected members.
* *
* This test is both a proof and a regression test. * This test is both a proof and a regression test.
*/ */
( function testCanProperlyOverrideProtectedWithProtected() 'Can properly override protected with protected': function()
{ {
var val = 'foobar', var val = 'foobar',
result = Class( result = Class(
@ -757,9 +765,10 @@ var common = require( './common' ),
// if everything worked as expected, the value of 'val' will have been // if everything worked as expected, the value of 'val' will have been
// returned and stored in 'result' // returned and stored in 'result'
assert.equal( result, val, this.assertEqual( result, val,
"Protected methods can properly be overriden by another protected " + "Protected methods can properly be overriden by another " +
"method" "protected method"
); );
} )(); },
} );