From f3a8dea25dbc5417979a0ee2c68734de1a907ccd Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Wed, 27 May 2015 23:38:07 -0400 Subject: [PATCH] Test ensuring `#use` staging object satisfies `Class.isClass` --- README.traits | 6 ------ test/Trait/DefinitionTest.js | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.traits b/README.traits index 772978a..4c959f6 100644 --- a/README.traits +++ b/README.traits @@ -78,11 +78,5 @@ complete. improvement. Until that time, be mindful of the performance test cases in the =test/perf= directory. -* TODO Intermediate object as class - The immediate syntax---=Foo.use(T)()=---is a short-hand equivalent - of =Foo.use(T).extend({})()=. As such, for consistency, =Class.isA= - should consider the intermediate object returned by a call to =use= - to be a class. - If we are to do so, though, we must make sure that the entire class API is supported. diff --git a/test/Trait/DefinitionTest.js b/test/Trait/DefinitionTest.js index df6ba8f..adc6f7a 100644 --- a/test/Trait/DefinitionTest.js +++ b/test/Trait/DefinitionTest.js @@ -455,4 +455,24 @@ require( 'common' ).testCase( Sut( dfn ); } ); }, + + + /** + * The stating object rendered by `#use` calls implement the same + * methods as classes, and are even treated as classes when invoked + * using the immediate syntax (see ImmediateTest). When defining + * abstract classes, staging objects may be extended as if they were + * classes (see AbstractTest). + * + * It makes sense for staging objects to be able to be treated as if + * they were classes, which demands reflection API consistency. + */ + 'Staging object for eventual mixin is considered to be class': function() + { + var T = this.Sut( {} ); + + this.assertOk( + this.Class.isClass( this.Class( {} ).use( T ) ) + ); + }, } );