Began making changes ... (overwrite this commit)
parent
45f3d62727
commit
4e1380837f
6
Makefile
6
Makefile
|
@ -64,7 +64,11 @@ $(compiler):
|
||||||
| 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) --compilation_level ADVANCED_OPTIMIZATIONS \
|
||||||
|
--formatting pretty_print \
|
||||||
|
--property_map_output_file build/min-propmap.xml \
|
||||||
|
--warning_level VERBOSE \
|
||||||
|
--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)
|
||||||
|
|
|
@ -30,6 +30,15 @@ Under no circumstances should a test be completely removed without being
|
||||||
replaced unless the feature was entirely removed.
|
replaced unless the feature was entirely removed.
|
||||||
|
|
||||||
|
|
||||||
|
Compiling
|
||||||
|
---------
|
||||||
|
Closure Compiler will rename all unquoted properties. It is therefore important
|
||||||
|
to keep consistent with how properties are accessed. All properties that are to
|
||||||
|
remain accessible by name when minified must be quoted. Furthermore, all
|
||||||
|
properties defined using defineSecureProp() or by means of any other string
|
||||||
|
definition (e.g. Object.defineProperty()) must be accessed as a quoted string.
|
||||||
|
|
||||||
|
|
||||||
Submitting Patches
|
Submitting Patches
|
||||||
------------------
|
------------------
|
||||||
You may send pull requests via your preferred method or e-mail patches to the
|
You may send pull requests via your preferred method or e-mail patches to the
|
||||||
|
|
|
@ -247,7 +247,7 @@ exports.isInstanceOf = function( type, instance )
|
||||||
|
|
||||||
// if no metadata is available, then our remaining checks cannot be
|
// if no metadata is available, then our remaining checks cannot be
|
||||||
// performed
|
// performed
|
||||||
if ( !instance.__cid || !( meta = exports.getMeta( instance ) ) )
|
if ( !instance['__cid'] || !( meta = exports.getMeta( instance ) ) )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -613,7 +613,7 @@ exports.prototype.createConcreteCtor = function( cname, members )
|
||||||
}
|
}
|
||||||
|
|
||||||
initInstance( this );
|
initInstance( this );
|
||||||
this.__initProps();
|
this['__initProps']();
|
||||||
|
|
||||||
// If we're extending, we don't actually want to invoke any class
|
// If we're extending, we don't actually want to invoke any class
|
||||||
// construction logic. The above is sufficient to use this class in a
|
// construction logic. The above is sufficient to use this class in a
|
||||||
|
@ -746,7 +746,7 @@ exports.prototype._attachPropInit = function(
|
||||||
// defaults to false
|
// defaults to false
|
||||||
inherit = !!inherit;
|
inherit = !!inherit;
|
||||||
|
|
||||||
var iid = this.__iid;
|
var iid = this['__iid'];
|
||||||
|
|
||||||
// first initialize the parent's properties, so that ours will overwrite
|
// first initialize the parent's properties, so that ours will overwrite
|
||||||
// them
|
// them
|
||||||
|
@ -926,7 +926,7 @@ function attachStatic( ctor, members, base, inheriting )
|
||||||
// TODO: This check is simple, but quick. It may be worth
|
// TODO: This check is simple, but quick. It may be worth
|
||||||
// setting a flag on the class during definition to specify if
|
// setting a flag on the class during definition to specify if
|
||||||
// it's extending from a non-class base.
|
// it's extending from a non-class base.
|
||||||
return ( base.__cid && base.$ || exports.ClassBase.$ ).apply(
|
return ( base['__cid'] && base.$ || exports.ClassBase.$ ).apply(
|
||||||
context, arguments
|
context, arguments
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -979,8 +979,8 @@ function attachStatic( ctor, members, base, inheriting )
|
||||||
*/
|
*/
|
||||||
function createMeta( func, cparent )
|
function createMeta( func, cparent )
|
||||||
{
|
{
|
||||||
var id = func.__cid,
|
var id = func['__cid'],
|
||||||
parent_meta = ( ( cparent.__cid )
|
parent_meta = ( ( cparent['__cid'] )
|
||||||
? exports.getMeta( cparent )
|
? exports.getMeta( cparent )
|
||||||
: undefined
|
: undefined
|
||||||
);
|
);
|
||||||
|
@ -1099,7 +1099,7 @@ function attachInstanceOf( instance )
|
||||||
*/
|
*/
|
||||||
exports.getMethodInstance = function( inst, cid )
|
exports.getMethodInstance = function( inst, cid )
|
||||||
{
|
{
|
||||||
var iid = inst.__iid,
|
var iid = inst['__iid'],
|
||||||
data = inst.___$$vis$$;
|
data = inst.___$$vis$$;
|
||||||
|
|
||||||
return ( iid && data )
|
return ( iid && data )
|
||||||
|
|
|
@ -163,7 +163,7 @@ exports.prototype.validateMethod = function(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( keywords.override )
|
else if ( keywords[ 'override' ] )
|
||||||
{
|
{
|
||||||
// using the override keyword without a super method may indicate a bug,
|
// using the override keyword without a super method may indicate a bug,
|
||||||
// but it shouldn't stop the class definition (it doesn't adversely
|
// but it shouldn't stop the class definition (it doesn't adversely
|
||||||
|
|
|
@ -366,9 +366,11 @@ exports.createAbstractMethod = function()
|
||||||
throw new Error( "Cannot call abstract method" );
|
throw new Error( "Cannot call abstract method" );
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.defineSecureProp( method, 'abstractFlag', true );
|
// TODO: should we protect these from modification (is it worth the
|
||||||
exports.defineSecureProp( method, 'definition', definition );
|
// overhead)?
|
||||||
exports.defineSecureProp( method, '__length', arguments.length );
|
method.abstractFlag = true;
|
||||||
|
method.definition = definition;
|
||||||
|
method.__length = arguments.length;
|
||||||
|
|
||||||
return method;
|
return method;
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,7 +34,9 @@ common.testCase(
|
||||||
caseSetUp: function()
|
caseSetUp: function()
|
||||||
{
|
{
|
||||||
// There's a couple ways to create interfaces. Test 'em both.
|
// There's a couple ways to create interfaces. Test 'em both.
|
||||||
this.baseTypes = [
|
// (Note: we must quote this so that the name is not minified, since it
|
||||||
|
// is referenced within a string)
|
||||||
|
this['baseTypes'] = [
|
||||||
Interface.extend(
|
Interface.extend(
|
||||||
{
|
{
|
||||||
method: [],
|
method: [],
|
||||||
|
@ -46,10 +48,10 @@ common.testCase(
|
||||||
];
|
];
|
||||||
|
|
||||||
// non-object values to assert failures upon
|
// non-object values to assert failures upon
|
||||||
this.invalidExtend = [ 'moo', 5, false, undefined ];
|
this['invalidExtend'] = [ 'moo', 5, false, undefined ];
|
||||||
|
|
||||||
// bad access modifiers (cannot be used in interfaces)
|
// bad access modifiers (cannot be used in interfaces)
|
||||||
this.badAm = [ 'protected', 'private' ];
|
this['badAm'] = [ 'protected', 'private' ];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,15 @@ require( 'common' ).testCase(
|
||||||
|
|
||||||
this.quickKeywordMethodTest = function( keywords, identifier, prev )
|
this.quickKeywordMethodTest = function( keywords, identifier, prev )
|
||||||
{
|
{
|
||||||
shared.quickKeywordTest.call( this,
|
shared.quickKeywordTest.call( _self,
|
||||||
'validateMethod', keywords, identifier, prev
|
// this awkward syntax (instead of simply passing a string) is
|
||||||
|
// to ensure the tests will still work after being compiled
|
||||||
|
function()
|
||||||
|
{
|
||||||
|
return _self.sut.validateMethod.apply(
|
||||||
|
_self.sut, arguments
|
||||||
|
);
|
||||||
|
}, keywords, identifier, prev
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,8 +56,8 @@ require( 'common' ).testCase(
|
||||||
shared.quickVisChangeTest.call( _self, start, override, failtest,
|
shared.quickVisChangeTest.call( _self, start, override, failtest,
|
||||||
function( name, startobj, overrideobj )
|
function( name, startobj, overrideobj )
|
||||||
{
|
{
|
||||||
startobj.virtual = true;
|
startobj[ 'virtual' ] = true;
|
||||||
overrideobj.override = true;
|
overrideobj[ 'override' ] = true;
|
||||||
|
|
||||||
_self.sut.validateMethod(
|
_self.sut.validateMethod(
|
||||||
name,
|
name,
|
||||||
|
|
|
@ -37,8 +37,15 @@ require( 'common' ).testCase(
|
||||||
|
|
||||||
this.quickKeywordPropTest = function( keywords, identifier, prev )
|
this.quickKeywordPropTest = function( keywords, identifier, prev )
|
||||||
{
|
{
|
||||||
shared.quickKeywordTest.call( this,
|
shared.quickKeywordTest.call( _self,
|
||||||
'validateProperty', keywords, identifier, prev
|
// this awkward syntax (instead of simply passing a string) is
|
||||||
|
// to ensure the tests will still work after being compiled
|
||||||
|
function()
|
||||||
|
{
|
||||||
|
return _self.sut.validateProperty.apply(
|
||||||
|
_self.sut, arguments
|
||||||
|
);
|
||||||
|
}, keywords, identifier, prev
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ exports.quickKeywordTest = function( type, keywords, identifier, prev )
|
||||||
|
|
||||||
var testfunc = function()
|
var testfunc = function()
|
||||||
{
|
{
|
||||||
_self.sut[ type ](
|
type(
|
||||||
name, function() {}, keyword_obj, prev_data, prev_obj
|
name, function() {}, keyword_obj, prev_data, prev_obj
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,7 +41,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 +105,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 +282,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' )
|
||||||
|
@ -393,7 +393,26 @@ function outputTestFailures( failures )
|
||||||
*/
|
*/
|
||||||
var testPrint = ( ( typeof process === 'undefined' )
|
var testPrint = ( ( typeof process === 'undefined' )
|
||||||
|| ( typeof process.stdout === 'undefined' ) )
|
|| ( typeof process.stdout === 'undefined' ) )
|
||||||
? function() {}
|
? ( ( typeof console === 'undefined' )
|
||||||
|
? function() {}
|
||||||
|
: ( function()
|
||||||
|
{
|
||||||
|
var buffer = '';
|
||||||
|
|
||||||
|
return function( str )
|
||||||
|
{
|
||||||
|
if ( str.search( '\n' ) !== -1 )
|
||||||
|
{
|
||||||
|
console.log( buffer + str );
|
||||||
|
buffer = '';
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer += str;
|
||||||
|
}
|
||||||
|
} )()
|
||||||
|
)
|
||||||
: function( str )
|
: function( str )
|
||||||
{
|
{
|
||||||
process.stdout.write( str );
|
process.stdout.write( str );
|
||||||
|
|
|
@ -181,7 +181,7 @@ var ctor_called = false,
|
||||||
// methods)
|
// methods)
|
||||||
var SubAbstractFoo = AbstractClass.extend( AbstractFoo,
|
var SubAbstractFoo = AbstractClass.extend( AbstractFoo,
|
||||||
{
|
{
|
||||||
second: function()
|
'second': function()
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -189,14 +189,14 @@ var SubAbstractFoo = AbstractClass.extend( AbstractFoo,
|
||||||
// concrete
|
// concrete
|
||||||
var ConcreteFoo = Class.extend( AbstractFoo,
|
var ConcreteFoo = Class.extend( AbstractFoo,
|
||||||
{
|
{
|
||||||
method: function( one, two, three )
|
'method': function( one, two, three )
|
||||||
{
|
{
|
||||||
// prevent Closure Compiler from optimizing the arguments away, causing
|
// prevent Closure Compiler from optimizing the arguments away, causing
|
||||||
// a definition failure
|
// a definition failure
|
||||||
return [ one, two, three ];
|
return [ one, two, three ];
|
||||||
},
|
},
|
||||||
|
|
||||||
second: function()
|
'second': function()
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -64,9 +64,10 @@ assert.equal(
|
||||||
"Constructor should be invoked once the class is instantiated"
|
"Constructor should be invoked once the class is instantiated"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// XXX: This may be encapsulated in the future
|
||||||
assert.equal(
|
assert.equal(
|
||||||
construct_context.__iid,
|
construct_context['__iid'],
|
||||||
obj.__iid,
|
obj['__iid'],
|
||||||
"Constructor should be invoked within the context of the class instance"
|
"Constructor should be invoked within the context of the class instance"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -110,8 +111,8 @@ assert.equal(
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
construct_context.__iid,
|
construct_context['__iid'],
|
||||||
subobj.__iid,
|
subobj['__iid'],
|
||||||
"Parent constructor is run in context of the subtype"
|
"Parent constructor is run in context of the subtype"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -133,8 +134,8 @@ assert.ok(
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
construct_context.__iid,
|
construct_context['__iid'],
|
||||||
subobj2.__iid,
|
subobj2['__iid'],
|
||||||
"Self-invoking constructor is run in the context of the new object"
|
"Self-invoking constructor is run in the context of the new object"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -143,13 +143,15 @@ assert.equal(
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// XXX: Ultimately, this will be determined via reflection (at which time we
|
||||||
|
// need to determine if we want to let the compiler rename this)
|
||||||
assert.ok(
|
assert.ok(
|
||||||
( Foo.__cid !== undefined ),
|
( Foo['__cid'] !== undefined ),
|
||||||
"Class id available via class"
|
"Class id available via class"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
( Foo.prototype.__cid !== undefined ),
|
( Foo.prototype['__cid'] !== undefined ),
|
||||||
"Class id available via class prototype"
|
"Class id available via class prototype"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ var common = require( './common' ),
|
||||||
// sandbox in which combined script will be run
|
// sandbox in which combined script will be run
|
||||||
sandbox = vm.createContext( {
|
sandbox = vm.createContext( {
|
||||||
// stub document.write() so we don't blow up
|
// stub document.write() so we don't blow up
|
||||||
|
window: {},
|
||||||
document: { write: function() {} },
|
document: { write: function() {} },
|
||||||
runTests: null,
|
runTests: null,
|
||||||
} );
|
} );
|
||||||
|
@ -72,5 +73,5 @@ data = "delete Object.defineProperty;" +
|
||||||
vm.runInNewContext( data, sandbox );
|
vm.runInNewContext( data, sandbox );
|
||||||
|
|
||||||
// cross your fingers
|
// cross your fingers
|
||||||
sandbox.easejs.runTests();
|
sandbox.window.easejs.runTests();
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ var common = require( './common' ),
|
||||||
// sandbox in which combined script will be run
|
// sandbox in which combined script will be run
|
||||||
sandbox = {
|
sandbox = {
|
||||||
// stub document.write() so we don't blow up
|
// stub document.write() so we don't blow up
|
||||||
|
window: {},
|
||||||
document: { write: function() {} },
|
document: { write: function() {} },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ while ( i-- )
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
( sandbox.easejs !== undefined ),
|
( sandbox.window.easejs !== undefined ),
|
||||||
"'easejs' namespace is defined within combined file"
|
"'easejs' namespace is defined within combined file"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ while ( i-- )
|
||||||
] .forEach( function( item )
|
] .forEach( function( item )
|
||||||
{
|
{
|
||||||
assert.ok(
|
assert.ok(
|
||||||
sandbox.easejs[ item ],
|
sandbox.window.easejs[ item ],
|
||||||
"Combined file exports exposes " + item
|
"Combined file exports exposes " + item
|
||||||
);
|
);
|
||||||
} );
|
} );
|
||||||
|
@ -95,12 +96,12 @@ while ( i-- )
|
||||||
if ( file.match( /ease-full/ ) )
|
if ( file.match( /ease-full/ ) )
|
||||||
{
|
{
|
||||||
assert.ok(
|
assert.ok(
|
||||||
( typeof sandbox.easejs.runTests === 'function' ),
|
( typeof sandbox.window.easejs.runTests === 'function' ),
|
||||||
"Full ease.js file contains test runner"
|
"Full ease.js file contains test runner"
|
||||||
);
|
);
|
||||||
|
|
||||||
// cross your fingers
|
// cross your fingers
|
||||||
sandbox.easejs.runTests();
|
sandbox.window.easejs.runTests();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ if [ "$INC_TEST" ]; then
|
||||||
cat "$TPL_TEST_PATH" | grep -v '^#' | $RMTRAIL
|
cat "$TPL_TEST_PATH" | grep -v '^#' | $RMTRAIL
|
||||||
|
|
||||||
echo "/** TEST CASES **/"
|
echo "/** TEST CASES **/"
|
||||||
echo "ns_exports.runTests = function()"
|
echo "ns_exports['runTests'] = function()"
|
||||||
echo "{"
|
echo "{"
|
||||||
|
|
||||||
for testcase in $TEST_INC $TEST_CASES; do
|
for testcase in $TEST_INC $TEST_CASES; do
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
# #
|
# #
|
||||||
|
|
||||||
module.common = module['test/common'] = { exports: {
|
module['common'] = module['test/common'] = { exports: {
|
||||||
require: function ( id )
|
require: function ( id )
|
||||||
{
|
{
|
||||||
return require( id );
|
return require( id );
|
||||||
|
@ -41,8 +41,10 @@ function failAssertion( err )
|
||||||
* Bare-bones implementation of node.js assert module
|
* Bare-bones implementation of node.js assert module
|
||||||
*
|
*
|
||||||
* This contains only the used assertions
|
* This contains only the used assertions
|
||||||
|
*
|
||||||
|
* This is an export; as such, it is quoted to prevent minification.
|
||||||
*/
|
*/
|
||||||
module.assert = { exports: {
|
module['assert'] = { exports: {
|
||||||
equal: function ( val, cmp, err )
|
equal: function ( val, cmp, err )
|
||||||
{
|
{
|
||||||
if ( val != cmp )
|
if ( val != cmp )
|
||||||
|
|
|
@ -11,9 +11,11 @@
|
||||||
*
|
*
|
||||||
* var util = easejs.Class;
|
* var util = easejs.Class;
|
||||||
*
|
*
|
||||||
|
* Note: Quoted for Closure Compiler export
|
||||||
|
*
|
||||||
* @type {Object}
|
* @type {Object}
|
||||||
*/
|
*/
|
||||||
var easejs = {};
|
window['easejs'] = {};
|
||||||
|
|
||||||
( function( ns_exports )
|
( function( ns_exports )
|
||||||
{
|
{
|
||||||
|
@ -57,9 +59,9 @@ var easejs = {};
|
||||||
/**{CONTENT}**/
|
/**{CONTENT}**/
|
||||||
|
|
||||||
// the following should match the exports of /index.js
|
// the following should match the exports of /index.js
|
||||||
ns_exports.Class = module['class'].exports;
|
ns_exports['Class'] = module['class'].exports;
|
||||||
ns_exports.AbstractClass = module['class_abstract'].exports;
|
ns_exports['AbstractClass'] = module['class_abstract'].exports;
|
||||||
ns_exports.FinalClass = module['class_final'].exports;
|
ns_exports['FinalClass'] = module['class_final'].exports;
|
||||||
ns_exports.Interface = module['interface'].exports;
|
ns_exports['Interface'] = module['interface'].exports;
|
||||||
} )( easejs );
|
} )( window['easejs'] );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue