2007年 02月 21日

test memo あとで書く

wget http://as3flexunitlib.googlecode.com/files/flexunit-.85.zip
unzip flexunit-.85.zip
cp flexunit/bin/flexunit.swc ~/sdk/flex_sdk_2/frameworks/libs/

とりあえず

package {
	import flexunit.framework.Test;
	import flexunit.framework.TestCase;
	import flexunit.framework.TestSuite;
	import flash.utils.describeType;

	import Rational;

	public class RationalTest extends TestCase {

		public function RationalTest(methodName:String) {
			super(methodName);
		}

		public static function suite():TestSuite {
			var ts:TestSuite = new TestSuite();
			var t:XML = describeType(RationalTest);
			for each (var m:XML in t.factory.method) {
				if (m.@name.match(/^test/) && m.@declaredBy == t.@name) {
					ts.addTest( Test( new RationalTest(String(m.@name)) ) );
				}
			}

			return ts;
		}

		public function testTrue():void {
			assertTrue("trueTrue", true);
		}

		public function testRationalInit():void {
			assertEquals("(new Rational(2, 6)).numerator   == 1", (new Rational(2, 6)).numerator, 1);
			assertEquals("(new Rational(2, 6)).denominator == 3", (new Rational(2, 6)).denominator, 3);
		}

		public function testToString():void {
			assertEquals("String(new Rational(2, 6))", String(new Rational(2, 6)), "1 / 3");
		}

		public function testAdd():void {
		}
	}
}

みたいに書いたけど (途中) 、かくのがめんどい。メタプログラミングしたい!