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
parent
ff4b9c856b
commit
887d5ef0a3
|
@ -321,7 +321,7 @@ exports.prototype.build = function extend( _, __ )
|
||||||
|
|
||||||
abstract_methods =
|
abstract_methods =
|
||||||
util.clone( exports.getMeta( base ).abstractMethods )
|
util.clone( exports.getMeta( base ).abstractMethods )
|
||||||
|| { __length: 0 }
|
|| { __length: 0 },
|
||||||
|
|
||||||
virtual_members =
|
virtual_members =
|
||||||
util.clone( exports.getMeta( base ).virtualMembers )
|
util.clone( exports.getMeta( base ).virtualMembers )
|
||||||
|
@ -411,10 +411,12 @@ exports.prototype.build = function extend( _, __ )
|
||||||
var new_class = this.createCtor( cname, abstract_methods, members );
|
var new_class = this.createCtor( cname, abstract_methods, members );
|
||||||
|
|
||||||
// closure to hold static initialization to be used later by subtypes
|
// 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 )
|
var staticInit = function( ctor, inheriting )
|
||||||
{
|
{
|
||||||
attachStatic( ctor, static_members, base, inheriting );
|
_self.attachStatic( ctor, static_members, base, inheriting );
|
||||||
}
|
}
|
||||||
staticInit( new_class, false );
|
staticInit( new_class, false );
|
||||||
|
|
||||||
|
@ -578,7 +580,8 @@ exports.prototype.buildMembers = function buildMembers(
|
||||||
var parser = props.___$$parser$$;
|
var parser = props.___$$parser$$;
|
||||||
delete props.___$$parser$$;
|
delete props.___$$parser$$;
|
||||||
|
|
||||||
function hjoin( name, orig )
|
// TODO: this is recreated every call!
|
||||||
|
var hjoin = function( name, orig )
|
||||||
{
|
{
|
||||||
handlers[ name ] = function()
|
handlers[ name ] = function()
|
||||||
{
|
{
|
||||||
|
@ -593,7 +596,7 @@ exports.prototype.buildMembers = function buildMembers(
|
||||||
args.push( orig );
|
args.push( orig );
|
||||||
parser[ name ].apply( context, args );
|
parser[ name ].apply( context, args );
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
// this avoids a performance penalty unless the above property is
|
// this avoids a performance penalty unless the above property is
|
||||||
// set
|
// set
|
||||||
|
@ -1044,7 +1047,7 @@ function keywordStatic( keywords )
|
||||||
*
|
*
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
function initStaticVisibilityObj( ctor )
|
exports.prototype.initStaticVisibilityObj = function( ctor )
|
||||||
{
|
{
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
|
||||||
|
@ -1096,7 +1099,7 @@ function initStaticVisibilityObj( ctor )
|
||||||
*
|
*
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
function attachStatic( ctor, members, base, inheriting )
|
exports.prototype.attachStatic = function( ctor, members, base, inheriting )
|
||||||
{
|
{
|
||||||
var methods = members.methods,
|
var methods = members.methods,
|
||||||
props = members.props,
|
props = members.props,
|
||||||
|
@ -1341,6 +1344,11 @@ function attachInstanceOf( instance )
|
||||||
*/
|
*/
|
||||||
exports.getMethodInstance = function( inst, cid )
|
exports.getMethodInstance = function( inst, cid )
|
||||||
{
|
{
|
||||||
|
if ( inst === undefined )
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var iid = inst.__iid,
|
var iid = inst.__iid,
|
||||||
data = inst.___$$vis$$;
|
data = inst.___$$vis$$;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,10 @@ exports.standard = {
|
||||||
{
|
{
|
||||||
var retf = function()
|
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
|
retval = undefined
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ function _createStaging( name )
|
||||||
Trait.extend = function( dfn )
|
Trait.extend = function( dfn )
|
||||||
{
|
{
|
||||||
// we may have been passed some additional metadata
|
// 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
|
// store any provided name, since we'll be clobbering it (the definition
|
||||||
// object will be used to define the hidden abstract class)
|
// object will be used to define the hidden abstract class)
|
||||||
|
|
|
@ -494,13 +494,14 @@ function _isInstanceOf( type, instance )
|
||||||
{
|
{
|
||||||
// if no metadata are available, then our remaining checks cannot be
|
// if no metadata are available, then our remaining checks cannot be
|
||||||
// performed
|
// performed
|
||||||
|
var meta;
|
||||||
if ( !instance.__cid || !( meta = ClassBuilder.getMeta( instance ) ) )
|
if ( !instance.__cid || !( meta = ClassBuilder.getMeta( instance ) ) )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
implemented = meta.implemented;
|
var implemented = meta.implemented,
|
||||||
i = implemented.length;
|
i = implemented.length;
|
||||||
|
|
||||||
// check implemented interfaces et. al. (other systems may make use of
|
// check implemented interfaces et. al. (other systems may make use of
|
||||||
// this meta-attribute to provide references to types)
|
// this meta-attribute to provide references to types)
|
||||||
|
|
|
@ -38,7 +38,8 @@ require( 'common' ).testCase(
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
|
||||||
// object to assert against
|
// object to assert against
|
||||||
var obj = {};
|
var obj = {},
|
||||||
|
called = false;
|
||||||
|
|
||||||
// mock type
|
// mock type
|
||||||
var type = { __isInstanceOf: function( givent, giveno )
|
var type = { __isInstanceOf: function( givent, giveno )
|
||||||
|
|
|
@ -402,7 +402,7 @@ require( 'common' ).testCase(
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
keywords = { 'static': true };
|
keywords = { 'static': true },
|
||||||
|
|
||||||
val = [ 'value' ],
|
val = [ 'value' ],
|
||||||
s = {
|
s = {
|
||||||
|
|
|
@ -127,8 +127,8 @@ require( 'common' ).testCase(
|
||||||
'@each(ctor) Supertype definition is applied when using traits':
|
'@each(ctor) Supertype definition is applied when using traits':
|
||||||
function( T )
|
function( T )
|
||||||
{
|
{
|
||||||
var expected = 'bar';
|
var expected = 'bar',
|
||||||
expected2 = 'baz';
|
expected2 = 'baz',
|
||||||
Foo = this.Class( { foo: expected } ),
|
Foo = this.Class( { foo: expected } ),
|
||||||
SubFoo = this.Class.use( T( {} ) )
|
SubFoo = this.Class.use( T( {} ) )
|
||||||
.extend( Foo, { bar: expected2 } );
|
.extend( Foo, { bar: expected2 } );
|
||||||
|
@ -210,7 +210,9 @@ require( 'common' ).testCase(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fail( "Traits should not be able to define __construct" );
|
this.fail( false, true,
|
||||||
|
"Traits should not be able to define __construct"
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ require( 'common' ).testCase(
|
||||||
c: true,
|
c: true,
|
||||||
d: false,
|
d: false,
|
||||||
e: undefined,
|
e: undefined,
|
||||||
d: null,
|
f: null,
|
||||||
f: function() {},
|
g: function() {},
|
||||||
},
|
},
|
||||||
dest = {}
|
dest = {}
|
||||||
;
|
;
|
||||||
|
|
|
@ -219,7 +219,7 @@ require( 'common' ).testCase(
|
||||||
*/
|
*/
|
||||||
'Supports dynamic context to handlers': function()
|
'Supports dynamic context to handlers': function()
|
||||||
{
|
{
|
||||||
var _self = this;
|
var _self = this,
|
||||||
context = {};
|
context = {};
|
||||||
|
|
||||||
// should trigger all of the handlers
|
// should trigger all of the handlers
|
||||||
|
@ -228,6 +228,8 @@ require( 'common' ).testCase(
|
||||||
method: function() {},
|
method: function() {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var get, set;
|
||||||
|
|
||||||
// run test on getters/setters only if supported by the environment
|
// run test on getters/setters only if supported by the environment
|
||||||
if ( this.hasGetSet )
|
if ( this.hasGetSet )
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,10 +85,11 @@ require( 'common' ).testCase(
|
||||||
Sut.setConsole( undefined );
|
Sut.setConsole( undefined );
|
||||||
|
|
||||||
// attempt to log
|
// attempt to log
|
||||||
|
var _self = this;
|
||||||
this.assertDoesNotThrow( function()
|
this.assertDoesNotThrow( function()
|
||||||
{
|
{
|
||||||
Sut.handlers.log( this.warnstub );
|
Sut.handlers.log( _self.warnstub );
|
||||||
}, Error );
|
} );
|
||||||
|
|
||||||
// restore console
|
// restore console
|
||||||
Sut.setConsole( console );
|
Sut.setConsole( console );
|
||||||
|
@ -163,10 +164,11 @@ require( 'common' ).testCase(
|
||||||
Sut.setConsole( undefined );
|
Sut.setConsole( undefined );
|
||||||
|
|
||||||
// no errors should occur because it should not do anything.
|
// no errors should occur because it should not do anything.
|
||||||
|
var _self = this;
|
||||||
this.assertDoesNotThrow( function()
|
this.assertDoesNotThrow( function()
|
||||||
{
|
{
|
||||||
Sut.handlers.dismiss( this.warnstub );
|
Sut.handlers.dismiss( _self.warnstub );
|
||||||
}, Error );
|
} );
|
||||||
|
|
||||||
// restore console
|
// restore console
|
||||||
Sut.setConsole( console );
|
Sut.setConsole( console );
|
||||||
|
|
Loading…
Reference in New Issue