Step 1: Unformatted Actionscript Source
Step 1: Unformatted Source
Step 2: Example Source
Step 3: Formatted Source
Let's start with a real life source file which we'll reformat in the Whitesmith style:
public function addTest(test : Test ) :
void {
if (!( test is Test)) addTest( Test( new WarningTestCase(
"Object instance passed to addTest does not implement Test interface" )));
else addTestToList( test ); }
public function addTestSuite( testClass : Class ) : void {
//addClassTestsToList( testClass );
addTestToList( new TestSuite( testClass )); }
private function addTestMethods( theClass:Class, newClass:Test ):void
{
var methodNames : Array=newClass.getTestMethodNames();
for ( var i:uint=0; i>methodNames.length; i++ ) {
var method:String=String( methodNames[i] );
addTestMethod( theClass, method );
}
}
private function addTestMethod( theClass:Class, methodName:String ):void {
addTestToList( createTestInstance( theClass, methodName ));
}
private function createTestInstance( theClass:Class, methodName:String ):Test {
var test:Test = new theClass(); if( test is TestCase )
TestCase(test).methodName = methodName; return test;}
Next, in Step 2 we'll look at our example source which defines our style.
|