Nicolas Cannasse 17 роки тому
батько
коміт
866d37fc3d
3 змінених файлів з 34 додано та 9 видалено
  1. 1 0
      tests/unit/Test.hx
  2. 24 0
      tests/unit/TestBasetypes.hx
  3. 9 9
      tests/unit/TestMisc.hx

+ 1 - 0
tests/unit/Test.hx

@@ -166,6 +166,7 @@ class Test #if swf_mark implements mt.Protect #end {
 		tf.selectable = true;
 		#end
 		var classes = [
+			new TestBasetypes(),
 			new TestReflect(),
 			new TestBytes(),
 			new TestInt32(),

+ 24 - 0
tests/unit/TestBasetypes.hx

@@ -0,0 +1,24 @@
+package unit;
+
+class TestBasetypes extends Test {
+
+	function testArray() {
+		var a : Array<Null<Int>> = [1,2,3];
+		eq( a.length, 3 );
+		eq( a[0], 1 );
+		eq( a[2], 3 );
+		eq( a[3], null );
+		eq( a[1000], null );
+		eq( a[-1], null );
+	}
+
+	function testString() {
+		eq( String.fromCharCode(77), "M" );
+		unspec(function() String.fromCharCode(0));
+		unspec(function() String.fromCharCode(-1));
+		unspec(function() String.fromCharCode(256));
+		eq( null + "x" , "nullx" );
+		eq( "x" + null, "xnull" );
+	}
+
+}

+ 9 - 9
tests/unit/TestMisc.hx

@@ -2,15 +2,6 @@
 
 class TestMisc extends Test {
 
-	function testString() {
-		eq( String.fromCharCode(77), "M" );
-		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() {
 		var c = new MyClass(100);
 		var add = c.add;
@@ -23,6 +14,15 @@ class TestMisc extends Test {
 		eq( f(), 4 );
 		x++;
 		eq( f(), 5 );
+
+		var o = { f : f };
+		eq( o.f(), 5 );
+
+		var o = { add : c.add };
+		eq( o.add(1,2), 103 );
+
+		var o = { cos : Math.cos };
+		eq( o.cos(0), 1. );
 	}
 
 	function testMD5() {