1
0
Fork 0

Fixed initial warnings provided by Closure Compiler

Getting ready for release means that we need to rest assured that everything is
operating as it should. Tests do an excellent job at aiding in this, but they
cannot cover everything. For example, a simple missing comma in a variable
declaration list could have terrible, global consequences.
perfodd
Mike Gerwitz 2011-12-10 11:06:34 -05:00
parent 45f3d62727
commit d1b1d2691a
22 changed files with 63 additions and 52 deletions

View File

@ -58,13 +58,16 @@ perf-%.js: default
# minificatino process uses Google Closure compiler # minificatino process uses Google Closure compiler
min: build/ease.min.js build/ease-full.min.js $(path_build)/browser-test-min.html \ min: build/ease.min.js build/ease-full.min.js $(path_build)/browser-test-min.html \
| combine $(path_tools)/externs-global.js | combine
$(compiler): $(compiler):
wget -O- http://closure-compiler.googlecode.com/files/compiler-latest.tar.gz \ wget -O- http://closure-compiler.googlecode.com/files/compiler-latest.tar.gz \
| tar -C $(path_tools) -xzv compiler.jar | tar -C $(path_tools) -xzv compiler.jar
build/%.min.js: build/%.js $(compiler) build/%.min.js: build/%.js $(compiler)
cat $(path_tools)/license.tpl > $@ cat $(path_tools)/license.tpl > $@
java -jar $(compiler) --js $< >> $@ || rm $@ java -jar $(compiler) \
--warning_level VERBOSE \
--externs $(path_tools)/externs-global.js \
--js $< >> $@ || rm $@
install: doc-info install: doc-info
[ -d $(path_info_install) ] || mkdir -p $(path_info_install) [ -d $(path_info_install) ] || mkdir -p $(path_info_install)

View File

@ -64,7 +64,7 @@ var util = require( __dirname + '/util' ),
* is performed only for methods. This is for performance reasons. We do not * is performed only for methods. This is for performance reasons. We do not
* have a situation where we will want to check for properties as well. * have a situation where we will want to check for properties as well.
* *
* @type {Object.<string,boolean} * @type {Object.<string,boolean>}
*/ */
public_methods = { public_methods = {
'__construct': true, '__construct': true,
@ -296,7 +296,7 @@ exports.prototype.build = function extend()
static_members = { static_members = {
methods: this._memberBuilder.initMembers(), methods: this._memberBuilder.initMembers(),
props: this._memberBuilder.initMembers(), props: this._memberBuilder.initMembers(),
} },
abstract_methods = abstract_methods =
util.clone( exports.getMeta( base ).abstractMethods ) util.clone( exports.getMeta( base ).abstractMethods )
@ -438,10 +438,7 @@ exports.prototype.buildMembers = function buildMembers(
// disallow use of our internal __initProps() method // disallow use of our internal __initProps() method
if ( reserved_members[ name ] === true ) if ( reserved_members[ name ] === true )
{ {
throw Error( throw Error( name + " is reserved" );
( ( cname ) ? cname + '::' : '' ) +
( name + " is reserved" )
);
} }
// if a member was defined multiple times in the same class // if a member was defined multiple times in the same class
@ -730,7 +727,7 @@ exports.prototype.createAbstractCtor = function( cname )
* *
* @param {{public: Object, protected: Object, private: Object}} members * @param {{public: Object, protected: Object, private: Object}} members
* *
* @param {function() ctor class * @param {function()} ctor class
* @param {number} cid class id * @param {number} cid class id
* *
* @return {undefined} * @return {undefined}
@ -1095,7 +1092,7 @@ function attachInstanceOf( instance )
* @param {function()} inst instance that the method is being called from * @param {function()} inst instance that the method is being called from
* @param {number} cid class id * @param {number} cid class id
* *
* @return {Object,null} instance object if found, otherwise null * @return {Object|null} instance object if found, otherwise null
*/ */
exports.getMethodInstance = function( inst, cid ) exports.getMethodInstance = function( inst, cid )
{ {

View File

@ -109,7 +109,7 @@ exports.prototype._createPrivateLayer = function( atop_of, properties )
obj_ctor.prototype = atop_of; obj_ctor.prototype = atop_of;
// we'll be returning an instance, so that the prototype takes effect // we'll be returning an instance, so that the prototype takes effect
obj = new obj_ctor(); var obj = new obj_ctor();
// All protected properties need to be proxied from the private object // All protected properties need to be proxied from the private object
// (which will be passed as the context) to the object containing protected // (which will be passed as the context) to the object containing protected
@ -142,7 +142,7 @@ exports.prototype._doSetup = function(
// copy over the methods // copy over the methods
if ( methods !== undefined ) if ( methods !== undefined )
{ {
for ( method_name in methods ) for ( var method_name in methods )
{ {
if ( hasOwn.call( methods, method_name ) ) if ( hasOwn.call( methods, method_name ) )
{ {
@ -172,7 +172,7 @@ exports.prototype._doSetup = function(
} }
// initialize private/protected properties and store in instance data // initialize private/protected properties and store in instance data
for ( prop in properties ) for ( var prop in properties )
{ {
if ( hasOwn.call( properties, prop ) ) if ( hasOwn.call( properties, prop ) )
{ {
@ -205,7 +205,7 @@ exports.prototype.createPropProxy = function( base, dest, props )
{ {
var hasOwn = Object.prototype.hasOwnProperty; var hasOwn = Object.prototype.hasOwnProperty;
for ( prop in props ) for ( var prop in props )
{ {
if ( !( hasOwn.call( props, prop ) ) ) if ( !( hasOwn.call( props, prop ) ) )
{ {

View File

@ -51,7 +51,7 @@ var util = require( __dirname + '/util' ),
*/ */
module.exports = function() module.exports = function()
{ {
var type = typeof arguments[ 0 ] var type = typeof arguments[ 0 ],
result = null result = null
; ;

View File

@ -153,7 +153,7 @@ exports.clone = function clone( data, deep )
hasOwn = Object.prototype.hasOwnProperty; hasOwn = Object.prototype.hasOwnProperty;
// copy data to the new object // copy data to the new object
for ( prop in data ) for ( var prop in data )
{ {
if ( hasOwn.call( data, prop ) ) if ( hasOwn.call( data, prop ) )
{ {
@ -204,7 +204,7 @@ exports.copyTo = function( dest, src, deep )
// slower; supports getters/setters // slower; supports getters/setters
if ( can_define_prop ) if ( can_define_prop )
{ {
for ( prop in src ) for ( var prop in src )
{ {
data = Object.getOwnPropertyDescriptor( src, prop ); data = Object.getOwnPropertyDescriptor( src, prop );
@ -228,7 +228,7 @@ exports.copyTo = function( dest, src, deep )
// quick (keep if statement out of the loop) // quick (keep if statement out of the loop)
else else
{ {
for ( prop in src ) for ( var prop in src )
{ {
// normal copy; cloned if deep, otherwise by reference // normal copy; cloned if deep, otherwise by reference
dest[ prop ] = ( deep ) dest[ prop ] = ( deep )
@ -274,7 +274,7 @@ exports.propParse = function( data, options )
// for each of the given properties, determine what type of property we're // for each of the given properties, determine what type of property we're
// dealing with (in the classic OO sense) // dealing with (in the classic OO sense)
for ( prop in data ) for ( var prop in data )
{ {
// ignore properties of instance prototypes // ignore properties of instance prototypes
if ( !( hasOwn.call( data, prop ) ) ) if ( !( hasOwn.call( data, prop ) ) )

View File

@ -81,7 +81,7 @@ require( 'common' ).testCase(
_self.incAssertCount(); _self.incAssertCount();
for ( level in _self.members ) for ( var level in _self.members )
{ {
if ( typeof _self.members[ level ][ name ] === 'undefined' ) if ( typeof _self.members[ level ][ name ] === 'undefined' )
{ {
@ -264,7 +264,7 @@ require( 'common' ).testCase(
; ;
// ensure we can initialize the values of each visibility level // ensure we can initialize the values of each visibility level
for ( vis in test ) for ( var vis in test )
{ {
this.assertStrictEqual( test[ vis ], members[ vis ], this.assertStrictEqual( test[ vis ], members[ vis ],
"Visibility level '" + vis + "' cannot be initialized" "Visibility level '" + vis + "' cannot be initialized"
@ -282,7 +282,7 @@ require( 'common' ).testCase(
var _self = this, var _self = this,
tests = [ 'public', 'protected', 'private' ]; tests = [ 'public', 'protected', 'private' ];
for ( i in tests ) for ( var i in tests )
{ {
_self.basicVisPropTest( tests[ i ] ); _self.basicVisPropTest( tests[ i ] );
_self.basicVisMethodTest( tests[ i ] ); _self.basicVisMethodTest( tests[ i ] );

View File

@ -23,7 +23,7 @@
var common = require( './common' ), var common = require( './common' ),
assert = require( 'assert' ), assert = require( 'assert' ),
util = common.require( 'util' ) util = common.require( 'util' ),
sut = common.require( 'MethodWrappers' ) sut = common.require( 'MethodWrappers' )
; ;
@ -45,7 +45,7 @@ var common = require( './common' ),
{ {
called = true; called = true;
return instance; return instance;
} },
method = sut.standard.wrapNew( method = sut.standard.wrapNew(
function() function()
@ -152,7 +152,7 @@ var common = require( './common' ),
super_called = true; super_called = true;
}, },
null, 0, getInst null, 0, getInst
) ),
// the overriding method // the overriding method
override = sut.standard.wrapOverride( override = sut.standard.wrapOverride(

View File

@ -111,7 +111,7 @@ var VisibilityObjectFactory = common.require( 'VisibilityObjectFactory' ),
sut.createPropProxy( base, dest, props ); sut.createPropProxy( base, dest, props );
// check to ensure the properties are properly proxied // check to ensure the properties are properly proxied
for ( prop in props ) for ( var prop in props )
{ {
dest[ prop ] = val; dest[ prop ] = val;

View File

@ -25,6 +25,7 @@ var assert = require( 'assert' ),
assert_wrapped = {}, assert_wrapped = {},
acount = 0, acount = 0,
icount = 0, icount = 0,
scount = 0,
skpcount = 0, skpcount = 0,
tcount = 0, tcount = 0,
@ -41,7 +42,7 @@ var assert = require( 'assert' ),
// wrap each of the assertions so that we can keep track of the number of times // wrap each of the assertions so that we can keep track of the number of times
// that they were invoked // that they were invoked
for ( f in assert ) for ( var f in assert )
{ {
var _assert_cur = assert[ f ]; var _assert_cur = assert[ f ];
@ -105,7 +106,7 @@ module.exports = function( test_case )
delete test_case.setUp; delete test_case.setUp;
// run each test in the case // run each test in the case
for ( test in test_case ) for ( var test in test_case )
{ {
// xUnit-style setup // xUnit-style setup
if ( setUp ) if ( setUp )
@ -282,7 +283,7 @@ function getMock( proto )
proto = Mock.prototype = new P() proto = Mock.prototype = new P()
; ;
for ( i in proto ) for ( var i in proto )
{ {
// only mock out methods // only mock out methods
if ( typeof proto[ i ] !== 'function' ) if ( typeof proto[ i ] !== 'function' )
@ -350,7 +351,7 @@ function outputTestFailures( failures )
var err = '', var err = '',
i = failures.length; i = failures.length;
for ( i in failures ) for ( var i in failures )
{ {
var failure = failures[ i ]; var failure = failures[ i ];
@ -368,7 +369,7 @@ function outputTestFailures( failures )
throw Error( err ); throw Error( err );
} }
for ( i = 0; i < failures.length; i++ ) for ( var i = 0; i < failures.length; i++ )
{ {
cur = failures[ i ]; cur = failures[ i ];

View File

@ -29,7 +29,7 @@ var common = require( './common' ),
// will still be set even if the context of the constructor is wrong // will still be set even if the context of the constructor is wrong
var construct_count = 0, var construct_count = 0,
construct_context = null, construct_context = null,
construct_args = null construct_args = null,
// create a basic test class // create a basic test class
Foo = Class.extend( Foo = Class.extend(

View File

@ -36,7 +36,7 @@ var foo_props = {
Class( foo_props ), Class( foo_props ),
], ],
class_count = classes.length class_count = classes.length,
// will hold the class being tested // will hold the class being tested
Foo = null Foo = null

View File

@ -199,8 +199,8 @@ var common = require( './common' ),
( function testCanCreateNamedClassUsingStagingMethod() ( function testCanCreateNamedClassUsingStagingMethod()
{ {
var name = 'Foo', var name = 'Foo',
named = Class( name ).extend( {} ) named = Class( name ).extend( {} ),
namedi = Class( name ).implement( Interface( {} ) ).extend( {} ) namedi = Class( name ).implement( Interface( {} ) ).extend( {} ),
// we should also be able to extend classes in this manner // we should also be able to extend classes in this manner
namede = Class( name ).implement( Interface( {} ) ).extend( named, {} ) namede = Class( name ).implement( Interface( {} ) ).extend( named, {} )

View File

@ -23,7 +23,7 @@
var common = require( './common' ), var common = require( './common' ),
assert = require( 'assert' ), assert = require( 'assert' ),
Class = common.require( 'class' ); Class = common.require( 'class' ),
// we store these outside of the class to ensure that visibility bugs do not // we store these outside of the class to ensure that visibility bugs do not
// get in the way of our assertions // get in the way of our assertions

View File

@ -28,7 +28,7 @@ var common = require( './common' ),
common.require( 'VisibilityObjectFactoryFactory' ).fromEnvironment() common.require( 'VisibilityObjectFactoryFactory' ).fromEnvironment()
), ),
Class = common.require( 'class' ) Class = common.require( 'class' ),
FinalClass = common.require( 'class_final' ) FinalClass = common.require( 'class_final' )
; ;

View File

@ -24,6 +24,7 @@
var common = require( './common' ), var common = require( './common' ),
assert = require( 'assert' ), assert = require( 'assert' ),
Class = common.require( 'class' ),
ClassBuilder = common.require( 'ClassBuilder' ), ClassBuilder = common.require( 'ClassBuilder' ),
builder = ClassBuilder( builder = ClassBuilder(
common.require( 'MemberBuilder' )(), common.require( 'MemberBuilder' )(),
@ -84,7 +85,7 @@ var common = require( './common' ),
count = 0; count = 0;
// test each of the reserved members // test each of the reserved members
for ( name in reserved ) for ( var name in reserved )
{ {
// properties // properties
assert['throws']( assert['throws'](
@ -137,7 +138,7 @@ var common = require( './common' ),
"Can retrieve hash of forced-public methods" "Can retrieve hash of forced-public methods"
); );
for ( name in pub ) for ( var name in pub )
{ {
count++; count++;
} }
@ -176,12 +177,12 @@ var common = require( './common' ),
var pub = ClassBuilder.getForcedPublicMethods(); var pub = ClassBuilder.getForcedPublicMethods();
// test each of the reserved members // test each of the reserved members
for ( name in pub ) for ( var name in pub )
{ {
assert['throws']( function() assert['throws']( function()
{ {
var obj = {}; var obj = {};
obj[ name ] = function() {}; obj[ 'private ' + name ] = function() {};
Class( obj ); Class( obj );
}, Error, "Forced-public methods must be declared as public" ); }, Error, "Forced-public methods must be declared as public" );

View File

@ -22,7 +22,7 @@
*/ */
var common = require( './common' ), var common = require( './common' ),
fallback = common.require( 'util' ).definePropertyFallback() fallback = common.require( 'util' ).definePropertyFallback(),
// XXX: get rid of this disgusting mess; we're mid-refactor and all these // XXX: get rid of this disgusting mess; we're mid-refactor and all these
// dependencies should not be necessary for testing // dependencies should not be necessary for testing
@ -183,7 +183,7 @@ require( 'common' ).testCase(
// we must define in this manner so older engines won't blow up due to // we must define in this manner so older engines won't blow up due to
// syntax errors // syntax errors
var def = {}, var def = {},
val = 'baz' val = 'baz',
called = []; called = [];
Object.defineProperty( def, 'public static foo', { Object.defineProperty( def, 'public static foo', {
@ -615,7 +615,7 @@ require( 'common' ).testCase(
this.foo = val; this.foo = val;
}, },
}, },
val = 'baz' val = 'baz',
called = []; called = [];
Object.defineProperty( def, 'protected static foo', { Object.defineProperty( def, 'protected static foo', {
@ -915,7 +915,7 @@ require( 'common' ).testCase(
this.foo = val; this.foo = val;
}, },
}, },
val = 'baz' val = 'baz',
called = []; called = [];
Object.defineProperty( def, 'private static foo', { Object.defineProperty( def, 'private static foo', {

View File

@ -62,7 +62,7 @@ require( 'common' ).testCase(
*/ */
'Self property references instance rather than property object': function() 'Self property references instance rather than property object': function()
{ {
var result = null var result = null,
ref = null, ref = null,
foo = this.builder.build( { foo = this.builder.build( {

View File

@ -52,7 +52,7 @@ for ( var i = 0, len = arr.length; i < len; i++ )
} }
// ensure object was properly cloned // ensure object was properly cloned
for ( prop in obj ) for ( var prop in obj )
{ {
assert.equal( assert.equal(
obj2[ prop ], obj2[ prop ],
@ -94,7 +94,7 @@ while ( deep_i-- )
); );
} }
for ( prop in deep_obj ) for ( var prop in deep_obj )
{ {
assert.ok( assert.ok(
( deep_obj2[ prop ] !== deep_obj[ prop ] ), ( deep_obj2[ prop ] !== deep_obj[ prop ] ),

View File

@ -49,7 +49,7 @@ var common = require( './common' ),
copyTo( dest, src ); copyTo( dest, src );
for ( key in src ) for ( var key in src )
{ {
assert.deepEqual( src[ key ], dest[ key ], assert.deepEqual( src[ key ], dest[ key ],
"Copies by reference by default" "Copies by reference by default"

View File

@ -161,7 +161,7 @@ var common = require( './common' ),
}, },
} ); } );
for ( prop in parsed_keywords ) for ( var prop in parsed_keywords )
{ {
assert.deepEqual( assert.deepEqual(
parsed_keywords[ prop ], parsed_keywords[ prop ],

View File

@ -61,7 +61,7 @@ if ( get_set )
var chk_each = {}; var chk_each = {};
for ( i in data ) for ( var i in data )
{ {
chk_each[ i ] = 1; chk_each[ i ] = 1;
} }
@ -152,7 +152,7 @@ if ( get_set )
var chk_each_count = 0; var chk_each_count = 0;
for ( item in chk_each ) for ( var item in chk_each )
{ {
chk_each_count++; chk_each_count++;
} }

View File

@ -0,0 +1,9 @@
/**
* Common global externs for Closure Compiler
*/
// available in most modern environments or extensions
var console = {};
// Node.js
var process = {};