From e90699c80506368cb8449fdbb2822023a17085ba Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Tue, 25 Oct 2011 23:47:06 -0400 Subject: [PATCH] [#25] Added test to MemberBuilder/Visibility test to ensure members will be declared public by default (if no access modifier is given) --- test/MemberBuilder/VisibilityTest.js | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/MemberBuilder/VisibilityTest.js b/test/MemberBuilder/VisibilityTest.js index ffa2d12..5c85675 100644 --- a/test/MemberBuilder/VisibilityTest.js +++ b/test/MemberBuilder/VisibilityTest.js @@ -198,6 +198,36 @@ require( 'common' ).testCase( }, + /** + * If no access modifier is provided, it should be assumed that the member + * is to be public. This also allows for more concise code should the + * developer with to omit unnecessary keywords. + */ + 'Members will be declared public if access modifier is omitted': function() + { + var name_prop = 'prop', val_prop = 'foo', + name_method = 'method', val_method = function() {} + ; + + this.sut.buildProp( this.members, {}, name_prop, val_prop, {}, {} ); + this.sut.buildMethod( this.members, {}, name_method, val_method, + {}, function() {}, 1, {} + ); + + this.assertStrictEqual( + this.members[ 'public' ][ name_prop ][ 0 ], + val_prop, + 'Properties should be public by default' + ); + + this.assertStrictEqual( + this.members[ 'public' ][ name_method ], + val_method, + 'Methods should be public by default' + ); + }, + + 'Only one access modifier may be used per property': function() { var _self = this;