Browse Source

more tests

Nicolas Cannasse 17 years ago
parent
commit
879fae53ce
6 changed files with 46 additions and 14 deletions
  1. 2 0
      tests/unit/MySubClass.hx
  2. 1 0
      tests/unit/Test.hx
  3. 6 4
      tests/unit/TestMisc.hx
  4. 26 0
      tests/unit/TestType.hx
  5. 5 5
      tests/unit/unit.hxml
  6. 6 5
      tests/unit/unit.hxp

+ 2 - 0
tests/unit/MySubClass.hx

@@ -6,4 +6,6 @@ class MySubClass extends MyClass {
 		return val * 2;
 	}
 
+	static var XXX = 3;
+
 }

+ 1 - 0
tests/unit/Test.hx

@@ -175,6 +175,7 @@ class Test #if swf_mark implements mt.Protect #end {
 			new TestMisc(),
 			new TestResource(),
 			new TestEReg(),
+			new TestType(),
 //			new TestRemoting(),
 		];
 		var current = null;

+ 6 - 4
tests/unit/TestMisc.hx

@@ -7,6 +7,8 @@ class TestMisc extends Test {
 		unspec(function() String.fromCharCode(0));
 		unspec(function() String.fromCharCode(-1));
 		unspec(function() String.fromCharCode(256));
+		eq( null + "x" , "nullx" );
+		eq( "x" + null, "xnull" );
 	}
 
 	function testClosure() {
@@ -29,15 +31,15 @@ class TestMisc extends Test {
 		// depending of ISO/UTF8 native
 		allow( haxe.Md5.encode("héllo"), ["1a722f7e6c801d9e470a10cb91ba406d","be50e8478cf24ff3595bc7307fb91b50"] );
 	}
-	
+
 	function opt1( ?x : Int, ?y : String ) {
 		return { x : x, y : y };
 	}
-	
+
 	function opt2( ?x = 5, ?y = "hello" ) {
 		return { x : x, y : y };
 	}
-	
+
 	function testOptionalParams() {
 		eq( opt1().x, null );
 		eq( opt1().y, null );
@@ -47,7 +49,7 @@ class TestMisc extends Test {
 		eq( opt1("str").y, "str" );
 		eq( opt1(66,"hello").x, 66 );
 		eq( opt1(66,"hello").y, "hello" );
-		
+
 		eq( opt2().x, 5 );
 		eq( opt2().y, "hello" );
 	}

+ 26 - 0
tests/unit/TestType.hx

@@ -0,0 +1,26 @@
+package unit;
+
+class TestType extends Test {
+
+	public function testType() {
+		eq( Type.resolveClass("unit.MyClass"), unit.MyClass );
+		eq( Type.getClassName(unit.MyClass), "unit.MyClass" );
+		eq( Type.getClassFields(unit.MyClass).length , 0 );
+	}
+
+
+	public function testFields() {
+		var sfields = Type.getClassFields(unit.MySubClass);
+		eq( sfields.length , 1 );
+		eq( sfields[0], "XXX" );
+
+		var fields = ["add","get","intValue","ref","set","stringValue","val"];
+		var fl = Type.getInstanceFields(unit.MyClass);
+		fl.sort(Reflect.compare);
+		eq( fl.join("|"), fields.join("|") );
+		var fl = Type.getInstanceFields(unit.MySubClass);
+		fl.sort(Reflect.compare);
+		eq( fl.join("|"), fields.join("|") );
+	}
+
+}

+ 5 - 5
tests/unit/unit.hxml

@@ -15,11 +15,11 @@
 -resource res1.txt
 -resource res2.bin
 
---next
--as3 as3
--cp ..
--main unit.Test
--cmd mxmlc -output unit9_as3.swf as3/__main__.as
+#--next
+#-as3 as3
+#-cp ..
+#-main unit.Test
+#-cmd mxmlc -output unit9_as3.swf as3/__main__.as
 
 --next
 # JS

+ 6 - 5
tests/unit/unit.hxp

@@ -6,11 +6,11 @@
 -resource res1.txt
 -resource res2.bin
 
---next
--as3 as3
--cp ..
--main unit.Test
--cmd mxmlc -output unit9_as3.swf as3/__main__.as</output>
+#--next
+#-as3 as3
+#-cp ..
+#-main unit.Test
+#-cmd mxmlc -output unit9_as3.swf as3/__main__.as</output>
   <output name="JS" mode="js" out="unit.js" class="unit.Test" lib="" cmd="" main="False" debug="False">-cp ..
 -resource res1.txt
 -resource res2.bin</output>
@@ -39,5 +39,6 @@
     <file path="TestRemoting.hx" />
     <file path="TestResource.hx" />
     <file path="TestSerialize.hx" />
+    <file path="TestType.hx" />
   </files>
 </haxe>