1
0
Fork 0

GNU ease.js and test cases now compile in strict mode

During its initial development, no environments (e.g. Node.js, Chromium,
Firefox) supported strict mode; this has since changed, and node has a
--use-strict option, which is used in the test runner to ensure conformance.
protolib
Mike Gerwitz 2014-05-04 22:17:23 -04:00
parent ff4b9c856b
commit 887d5ef0a3
10 changed files with 42 additions and 23 deletions

View File

@ -321,7 +321,7 @@ exports.prototype.build = function extend( _, __ )
abstract_methods =
util.clone( exports.getMeta( base ).abstractMethods )
|| { __length: 0 }
|| { __length: 0 },
virtual_members =
util.clone( exports.getMeta( base ).virtualMembers )
@ -411,10 +411,12 @@ exports.prototype.build = function extend( _, __ )
var new_class = this.createCtor( cname, abstract_methods, members );
// closure to hold static initialization to be used later by subtypes
initStaticVisibilityObj( new_class );
this.initStaticVisibilityObj( new_class );
var _self = this;
var staticInit = function( ctor, inheriting )
{
attachStatic( ctor, static_members, base, inheriting );
_self.attachStatic( ctor, static_members, base, inheriting );
}
staticInit( new_class, false );
@ -578,7 +580,8 @@ exports.prototype.buildMembers = function buildMembers(
var parser = props.___$$parser$$;
delete props.___$$parser$$;
function hjoin( name, orig )
// TODO: this is recreated every call!
var hjoin = function( name, orig )
{
handlers[ name ] = function()
{
@ -593,7 +596,7 @@ exports.prototype.buildMembers = function buildMembers(
args.push( orig );
parser[ name ].apply( context, args );
};
}
};
// this avoids a performance penalty unless the above property is
// set
@ -1044,7 +1047,7 @@ function keywordStatic( keywords )
*
* @return {undefined}
*/
function initStaticVisibilityObj( ctor )
exports.prototype.initStaticVisibilityObj = function( ctor )
{
var _self = this;
@ -1096,7 +1099,7 @@ function initStaticVisibilityObj( ctor )
*
* @return {undefined}
*/
function attachStatic( ctor, members, base, inheriting )
exports.prototype.attachStatic = function( ctor, members, base, inheriting )
{
var methods = members.methods,
props = members.props,
@ -1341,6 +1344,11 @@ function attachInstanceOf( instance )
*/
exports.getMethodInstance = function( inst, cid )
{
if ( inst === undefined )
{
return null;
}
var iid = inst.__iid,
data = inst.___$$vis$$;

View File

@ -28,7 +28,10 @@ exports.standard = {
{
var retf = function()
{
var context = getInst( this, cid ) || this,
// we need some sort of context in order to set __super; it may
// be undefined per strict mode requirements depending on how
// the method was invoked
var context = getInst( this, cid ) || this || {},
retval = undefined
;

View File

@ -96,7 +96,7 @@ function _createStaging( name )
Trait.extend = function( dfn )
{
// we may have been passed some additional metadata
var meta = this.__$$meta || {};
var meta = ( this || {} ).__$$meta || {};
// store any provided name, since we'll be clobbering it (the definition
// object will be used to define the hidden abstract class)

View File

@ -494,13 +494,14 @@ function _isInstanceOf( type, instance )
{
// if no metadata are available, then our remaining checks cannot be
// performed
var meta;
if ( !instance.__cid || !( meta = ClassBuilder.getMeta( instance ) ) )
{
return false;
}
implemented = meta.implemented;
i = implemented.length;
var implemented = meta.implemented,
i = implemented.length;
// check implemented interfaces et. al. (other systems may make use of
// this meta-attribute to provide references to types)

View File

@ -38,7 +38,8 @@ require( 'common' ).testCase(
var _self = this;
// object to assert against
var obj = {};
var obj = {},
called = false;
// mock type
var type = { __isInstanceOf: function( givent, giveno )

View File

@ -402,7 +402,7 @@ require( 'common' ).testCase(
};
},
keywords = { 'static': true };
keywords = { 'static': true },
val = [ 'value' ],
s = {

View File

@ -127,8 +127,8 @@ require( 'common' ).testCase(
'@each(ctor) Supertype definition is applied when using traits':
function( T )
{
var expected = 'bar';
expected2 = 'baz';
var expected = 'bar',
expected2 = 'baz',
Foo = this.Class( { foo: expected } ),
SubFoo = this.Class.use( T( {} ) )
.extend( Foo, { bar: expected2 } );
@ -210,7 +210,9 @@ require( 'common' ).testCase(
return;
}
this.fail( "Traits should not be able to define __construct" );
this.fail( false, true,
"Traits should not be able to define __construct"
);
},

View File

@ -41,8 +41,8 @@ require( 'common' ).testCase(
c: true,
d: false,
e: undefined,
d: null,
f: function() {},
f: null,
g: function() {},
},
dest = {}
;

View File

@ -219,7 +219,7 @@ require( 'common' ).testCase(
*/
'Supports dynamic context to handlers': function()
{
var _self = this;
var _self = this,
context = {};
// should trigger all of the handlers
@ -228,6 +228,8 @@ require( 'common' ).testCase(
method: function() {},
};
var get, set;
// run test on getters/setters only if supported by the environment
if ( this.hasGetSet )
{

View File

@ -85,10 +85,11 @@ require( 'common' ).testCase(
Sut.setConsole( undefined );
// attempt to log
var _self = this;
this.assertDoesNotThrow( function()
{
Sut.handlers.log( this.warnstub );
}, Error );
Sut.handlers.log( _self.warnstub );
} );
// restore console
Sut.setConsole( console );
@ -163,10 +164,11 @@ require( 'common' ).testCase(
Sut.setConsole( undefined );
// no errors should occur because it should not do anything.
var _self = this;
this.assertDoesNotThrow( function()
{
Sut.handlers.dismiss( this.warnstub );
}, Error );
Sut.handlers.dismiss( _self.warnstub );
} );
// restore console
Sut.setConsole( console );