From 83cecb5fdc61d5f6d0938da0d09647aa1bc47172 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Wed, 29 Dec 2010 21:18:03 -0500 Subject: [PATCH] Instantiating test object only once --- test/test-class-extend.js | 3 ++- test/test-class.js | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/test/test-class-extend.js b/test/test-class-extend.js index 3a5f3f3..00839d3 100644 --- a/test/test-class-extend.js +++ b/test/test-class-extend.js @@ -70,7 +70,8 @@ for ( var prop in sub_props ) assert.ok( ( new SubFoo() instanceof Foo ), - "Subtypes must be considered to be instances of their supertypes" + "Subtypes are considered to be instances of their supertypes " + + "(via instanceof operator)" ); diff --git a/test/test-class.js b/test/test-class.js index 6d8c62b..b9d814f 100644 --- a/test/test-class.js +++ b/test/test-class.js @@ -50,6 +50,9 @@ assert.ok( ); +var inst = new Foo(); + + // // isClass assert.ok( @@ -58,7 +61,7 @@ assert.ok( ); assert.ok( - ( !( Class.isClass( new Foo() ) ) ), + !( Class.isClass( inst ) ), "Class instances are not considered to be classes (they are objects)" ); @@ -66,7 +69,7 @@ assert.ok( // // isClassInstance assert.ok( - ( Class.isClassInstance( new Foo() ) ), + ( Class.isClassInstance( inst ) ), "Class instances are considered to be classes instances" ); @@ -95,7 +98,7 @@ if ( Object.isFrozen ) // // isInstanceOf assert.ok( - Class.isInstanceOf( Foo, new Foo() ), + Class.isInstanceOf( Foo, inst ), "Class instance is recognized by Class.isInstanceOf()" ); @@ -105,7 +108,8 @@ assert.ok( ); assert.ok( - !( Class.isInstanceOf( new Foo(), Foo ) ), + !( Class.isInstanceOf( inst, Foo ) ), "Class is not an instance of its instance" ); +