From 26bd6b88dd7d5231580bc722a00982837c044c15 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Mon, 10 Feb 2014 23:33:07 -0500 Subject: [PATCH] Named classes now support mixins --- lib/class.js | 8 ++++++++ test/Trait/DefinitionTest.js | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/class.js b/lib/class.js index 2f8ad81..1096555 100644 --- a/lib/class.js +++ b/lib/class.js @@ -300,6 +300,14 @@ function createStaging( cname ) cname ); }, + + use: function() + { + return createUse( + null, + Array.prototype.slice.call( arguments ) + ); + }, }; } diff --git a/test/Trait/DefinitionTest.js b/test/Trait/DefinitionTest.js index c4b1b26..f7726a8 100644 --- a/test/Trait/DefinitionTest.js +++ b/test/Trait/DefinitionTest.js @@ -267,4 +267,17 @@ require( 'common' ).testCase( // this one was not this.assertOk( this.Class.isA( Tc, o ) === false ); }, + + + /** + * Ensure that the named class staging object permits mixins. + */ + 'Can mix traits into named class': function() + { + var called = false, + T = this.Sut( { foo: function() { called = true; } } ); + + this.Class( 'Named' ).use( T ).extend( {} )().foo(); + this.assertOk( called ); + }, } );