Selaa lähdekoodia

move unit tests to -D haxe3 + neko_v2

Nicolas Cannasse 13 vuotta sitten
vanhempi
commit
9f149fa00b

+ 4 - 4
tests/unit/Test.hx

@@ -68,13 +68,13 @@ package unit;
 		Test.count++;
 		if (!Lambda.has(Type.getClassFields(c), n))
 			Test.report(Type.getClassName(c) + " should have static field " +n, pos);
-	}	
+	}
 	
 	function nhsf(c:Class<Dynamic> , n:String, ?pos:haxe.PosInfos) {
 		Test.count++;
 		if (Lambda.has(Type.getClassFields(c), n))
 			Test.report(Type.getClassName(c) + " should not have static field " +n, pos);
-	}	
+	}
 
 	function infos( m : String ) {
 		reportInfos = m;
@@ -150,8 +150,8 @@ package unit;
 	static function checkDone() {
 		if( asyncWaits.length != 0 ) return;
 		if( asyncCache.length == 0 ) {
-			report("DONE ["+count+" tests]");
 			return;
+			report("DONE ["+count+" tests]");
 		}
 		resetTimer();
 		while( asyncCache.length > 0 && asyncWaits.length < AMAX )
@@ -212,7 +212,7 @@ package unit;
 			new TestOps(),
 			new TestBasetypes(),
 			new TestBytes(),
-			new TestInt32(),
+			#if !haxe3 new TestInt32(), #end
 			new TestIO(),
 			new TestLocals(),
 			new TestEReg(),

+ 10 - 16
tests/unit/TestIO.hx

@@ -62,13 +62,8 @@ class TestIO extends Test {
 		o.writeInt24(-1234567);
 		excv(function() o.writeInt16(1 << 24),Overflow);
 		excv(function() o.writeInt16(-((1 << 24)+1)),Overflow);
-		o.writeInt31(-123456789);
-		#if !neko
-		// in neko, we can't represent invalid 31 bits integers anyway
-		excv(function() o.writeInt31(1 << 30),Overflow);
-		excv(function() o.writeInt31( -((1 << 30) + 1)), Overflow);
-		excv(function() o.writeUInt30(0x40 << 24),Overflow);
-		#end
+		o.writeInt32(-123456789);
+
 		o.writeInt8(-5);
 		excv(function() o.writeInt8(128),Overflow);
 		excv(function() o.writeInt8(-129),Overflow);
@@ -78,18 +73,17 @@ class TestIO extends Test {
 		o.writeUInt24(0xFF00EE);
 		excv(function() o.writeUInt24(1 << 24),Overflow);
 		excv(function() o.writeUInt24(-1),Overflow);
-		o.writeUInt30(0x3FAABBCC);
-		excv(function() o.writeUInt30(-1),Overflow);
+		o.writeInt32(0x3FAABBCC);
 
-		o.writeInt32(haxe.Int32.make(0xA0FF,0xEEDD));
-		o.writeInt32(haxe.Int32.make(0xC0FF,0xEEDD));
+		o.writeInt32(0xA0FFEEDD);
+		o.writeInt32(0xC0FFEEDD);
 
 		unspec(function() o.writeByte(-1));
 		unspec(function() o.writeByte(257));
 
 		var i = new haxe.io.BytesInput(o.getBytes());
 		i.bigEndian = endian;
-		eq( i.readUInt30(), endian ? 0x00010203 : 0x03020100 );
+		eq( i.readInt32(), endian ? 0x00010203 : 0x03020100 );
 		eq( i.read(b.length).compare(b) , 0 );
 		eq( i.readByte(), 55 );
 		eq( i.read(5).compare(b.sub(3,5)), 0 );
@@ -109,14 +103,14 @@ class TestIO extends Test {
 
 		eq( i.readInt16(), -12345 );
 		eq( i.readInt24(), -1234567 );
-		eq( i.readInt31(), -123456789 );
+		eq( i.readInt32(), -123456789 );
 		eq( i.readInt8(), -5 );
 		eq( i.readUInt16(), 0xFF55 );
 		eq( i.readUInt24(), 0xFF00EE );
-		eq( i.readUInt30(), 0x3FAABBCC );
+		eq( i.readInt32(), 0x3FAABBCC );
 
-		eq( haxe.Int32.compare( i.readInt32() , haxe.Int32.make(0xA0FF,0xEEDD) ), 0 );
-		eq( haxe.Int32.compare( i.readInt32() , haxe.Int32.make(0xC0FF,0xEEDD) ), 0 );
+		eq( i.readInt32() , 0xA0FFEEDD );
+		eq( i.readInt32() , 0xC0FFEEDD );
 
 	}
 

+ 2 - 8
tests/unit/TestInt64.hx

@@ -3,12 +3,6 @@ using haxe.Int64;
 
 class TestInt64 extends Test {
 
-	inline function eq32( i : haxe.Int32, a : Int, b : Int, ?pos : haxe.PosInfos ) {
-		var i2 = haxe.Int32.make(a, b);
-		if( haxe.Int32.compare(i, i2) != 0 )
-			Test.report(Std.string(i)+" should be "+Std.string(i2),pos);
-	}
-	
 	public function test() {
 		eq( 1.ofInt().toInt(), 1 );
 		eq( ( -1).ofInt().toInt(), -1 );
@@ -18,8 +12,8 @@ class TestInt64 extends Test {
 		eq( Std.string(v), "1048576" );
 		
 		var p40 = v.shl(20);
-		eq32( p40.getLow(), 0, 0 );
-		eq32( p40.getHigh(), 0, 256 );
+		eq( p40.getLow(), 0 );
+		eq( p40.getHigh(), 256 );
 		eq( Std.string(p40), "1099511627776" );
 		
 		eq( 1.ofInt().shl(0).toStr(), "1" );

+ 13 - 6
tests/unit/TestMisc.hx

@@ -183,7 +183,7 @@ class TestMisc extends Test {
 	
 	function testHiddenType() {
 		var haxe = 20;
-		eq( std.haxe.Md5.encode(""), "d41d8cd98f00b204e9800998ecf8427e");
+		eq( std.haxe.crypto.Md5.encode(""), "d41d8cd98f00b204e9800998ecf8427e");
 		eq( haxe, 20);
 		var Std = 50;
 		eq( std.Std.int(45.3), 45);
@@ -198,7 +198,7 @@ class TestMisc extends Test {
 			eq( haxe, 20);
 			eq( Std, 50);
 		}
-		eq( std.haxe.Md5.encode(""), "d41d8cd98f00b204e9800998ecf8427e");
+		eq( std.haxe.crypto.Md5.encode(""), "d41d8cd98f00b204e9800998ecf8427e");
 		eq( std.Std.int(45.3), 45);
 	}
 	
@@ -211,7 +211,7 @@ class TestMisc extends Test {
 			foo = function() return haxe;
 			bar = function() return Std;
 		}
-		eq( std.haxe.Md5.encode(""), "d41d8cd98f00b204e9800998ecf8427e");
+		eq( std.haxe.crypto.Md5.encode(""), "d41d8cd98f00b204e9800998ecf8427e");
 		eq( std.Std.int(45.3), 45);
 		eq( foo(), 20);
 		eq( bar(), 50);
@@ -278,12 +278,19 @@ class TestMisc extends Test {
 	}
 
 	function testMD5() {
-		eq( haxe.Md5.encode(""), "d41d8cd98f00b204e9800998ecf8427e" );
-		eq( haxe.Md5.encode("hello"), "5d41402abc4b2a76b9719d911017c592" );
+		eq( haxe.crypto.Md5.encode(""), "d41d8cd98f00b204e9800998ecf8427e" );
+		eq( haxe.crypto.Md5.encode("hello"), "5d41402abc4b2a76b9719d911017c592" );
 		// depending of ISO/UTF8 native
-		allow( haxe.Md5.encode("héllo"), ["1a722f7e6c801d9e470a10cb91ba406d","be50e8478cf24ff3595bc7307fb91b50"] );
+		allow( haxe.crypto.Md5.encode("héllo"), ["1a722f7e6c801d9e470a10cb91ba406d","be50e8478cf24ff3595bc7307fb91b50"] );
 	}
 
+	function testSHA1() {
+		eq( haxe.crypto.Sha1.encode(""), "da39a3ee5e6b4b0d3255bfef95601890afd80709" );
+		eq( haxe.crypto.Sha1.encode("hello"), "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d" );
+		// depending of ISO/UTF8 native
+		allow( haxe.crypto.Sha1.encode("héllo"), ["35b5ea45c5e41f78b46a937cc74d41dfea920890"] );
+	}
+	
 	function testBaseCode() {
 		var b = new haxe.BaseCode(haxe.io.Bytes.ofString("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-"));
 		eq( b.encodeString("Héllow"), "iceFr6NLtM" );

+ 3 - 3
tests/unit/TestResource.hx

@@ -33,14 +33,14 @@ class TestResource extends Test {
 
 	#if neko
 	static function main() {
-		var ch = neko.io.File.write("res1.txt",true);
+		var ch = sys.io.File.write("res1.txt",true);
 		ch.writeString(STR);
 		ch.close();
-		var ch = neko.io.File.write("res2.bin",true);
+		var ch = sys.io.File.write("res2.bin",true);
 		ch.writeString("Héllo");
 		ch.writeByte(0);
 		ch.writeString("World");
-		ch.writeInt31(0);
+		ch.writeInt32(0);
 		ch.writeString("!");
 		ch.close();
 	}

+ 2 - 2
tests/unit/TestType.hx

@@ -498,7 +498,7 @@ class TestType extends Test {
 		eq(r[1], 2);
 		eq(r[2], 3);
 		
-		var r = MyMacro.MyRestMacro.testRest1(1, [2, 3]);
+		var r : Array<Dynamic> = MyMacro.MyRestMacro.testRest1(1, [2, 3]);
 		eq(r.length, 2);
 		eq(r[0], 1);
 		eq(r[1][0], 2);
@@ -520,7 +520,7 @@ class TestType extends Test {
 		eq(r[0], 1);
 		eq(r[1], 2);
 		
-		var r = MyMacro.MyRestMacro.testRest2(1, 2, [3]);
+		var r : Array<Dynamic> = MyMacro.MyRestMacro.testRest2(1, 2, [3]);
 		eq(r.length, 3);
 		eq(r[0], 1);
 		eq(r[1], 2);

+ 2 - 0
tests/unit/compile.hxml

@@ -15,6 +15,7 @@
 
 #each
 --next
+-D haxe3
 -debug
 -cp ..
 -resource res1.txt
@@ -42,6 +43,7 @@ unit.Test
 
 #neko
 --next
+-D neko_v2
 -main unit.Test
 -neko unit.n