Sfoglia il codice sorgente

activate remaining Int64 tests (closes #2665)

Simon Krajewski 10 anni fa
parent
commit
78c43f4288
1 ha cambiato i file con 33 aggiunte e 66 eliminazioni
  1. 33 66
      tests/unit/src/unit/TestInt64.hx

+ 33 - 66
tests/unit/src/unit/TestInt64.hx

@@ -1,6 +1,7 @@
 package unit;
 
 using haxe.Int64;
+import haxe.Int64.*;
 
 class TestInt64 extends Test {
 
@@ -337,40 +338,6 @@ class TestInt64 extends Test {
 		int64eq( b.toInt(), -4 );
 	}
 
-	function int64eq( v : Int64, v2 : Int64, ?pos ) {
-		Test.count++;
-		if( v != v2 ) {
-			Test.report(Std.string(v)+" should be "+Std.string(v2),pos);
-			Test.success = false;
-		}
-	}
-}
-
-/*
-package unit;
-using haxe.Int64;
-import haxe.Int64.*;
-
-class TestInt64 extends Test {
-
-	public function test() {
-		eq( 1.ofInt().toInt(), 1 );
-		eq( ( -1).ofInt().toInt(), -1 );
-		eq( Std.string(156.ofInt()), "156" );
-
-		var v = (1 << 20).ofInt();
-		eq( Std.string(v), "1048576" );
-
-		var p40 = v.shl(20);
-		eq( p40.getLow(), 0 );
-		eq( p40.getHigh(), 256 );
-		eq( Std.string(p40), "1099511627776" );
-
-		eq( 1.ofInt().shl(0).toStr(), "1" );
-
-		eq(Int64.ofInt(0).toStr(), "0");
-	}
-
 	public function testCapture()
 	{
 		var a = Int64.make(0xFF00FF00,0xF0F0F0F0),
@@ -390,7 +357,7 @@ class TestInt64 extends Test {
 		var b = Int64.make(0, 0x39193D1B);
 		var c = Int64.mul(a, b);
 		eq( c.toStr(), "572248275467371265" );
-		// trace(Int64.toStr(c) + " should be 572248275467371265"); // but gives 7572248271172403969 in javascript
+		eq(Int64.toStr(c), "572248275467371265");
 
 		var a = Int64.make(0, 0xD3F9C9F4);
 		var b = Int64.make(0, 0xC865C765);
@@ -405,17 +372,13 @@ class TestInt64 extends Test {
 		var a = Int64.make(0xFFF21CDA, 0x972E8BA3);
 		var b = Int64.make(0x0098C29B, 0x81000001);
 		var c = Int64.mul(a, b);
-		#if !as3
 		var expected = Int64.make(0xDDE8A2E8, 0xBA2E8BA3);
 		eq( expected.compare(c), 0 );
-		#end
 	}
 
-	// tests ported from https://github.com/candu/node-int64-native/blob/master/test/int64.js
-	public function testCompare()
-	{
-    var a = ofInt(2),
-        b = ofInt(3);
+	public function testCompare() {
+		var a = ofInt(2),
+		    b = ofInt(3);
 		t(a == a);
 		t(b == b);
 		eq(a.compare(a), 0);
@@ -423,28 +386,26 @@ class TestInt64 extends Test {
 		eq(b.compare(a), 1);
 	}
 
-	public function testBits()
-	{
-	  var x = make(0xfedcba98,0x76543210);
-    var y = x.and((ofInt(0xffff))),
-        z = x.or((ofInt(0xffff))),
-        w = x.xor((make(0xffffffff,0xffffffff)));
-    eq(y.toStr(), '12816');
-    eq(z.toStr(), '-81985529216434177');
-    eq(w.toStr(), '81985529216486895');
-    eq(x.and(ofInt(0xffff)).toStr(), '12816');
-    eq((x.or(ofInt(0xffff))).toStr(), '-81985529216434177');
-    eq((x.xor(ofInt(0xffff))).toStr(), '-81985529216446993');
-    eq((x.and(make(0x1,0xffffffff))).toStr(), '1985229328');
-    eq((x.or(make(0x1,0xffffffff))).toStr(), '-81985522611781633');
-    eq((x.xor(make(0x1, 0xffffffff))).toStr(), '-81985524597010961');
-    var a = ofInt(7),
-        b = a.shl(1);
-    eq(b.toStr(), '14');
+	public function testBits() {
+		var x = make(0xfedcba98,0x76543210);
+		var y = x.and((ofInt(0xffff))),
+		    z = x.or((ofInt(0xffff))),
+		    w = x.xor((make(0xffffffff,0xffffffff)));
+		eq(y.toStr(), '12816');
+		eq(z.toStr(), '-81985529216434177');
+		eq(w.toStr(), '81985529216486895');
+		eq(x.and(ofInt(0xffff)).toStr(), '12816');
+		eq((x.or(ofInt(0xffff))).toStr(), '-81985529216434177');
+		eq((x.xor(ofInt(0xffff))).toStr(), '-81985529216446993');
+		eq((x.and(make(0x1,0xffffffff))).toStr(), '1985229328');
+		eq((x.or(make(0x1,0xffffffff))).toStr(), '-81985522611781633');
+		eq((x.xor(make(0x1, 0xffffffff))).toStr(), '-81985524597010961');
+		var a = ofInt(7),
+			b = a.shl(1);
+		eq(b.toStr(), '14');
 	}
 
-	public function testAdd()
-	{
+	public function testAdd() {
 		var a = ofInt(3),
 				b = ofInt(2),
 				c = make(0xffffffff,0xfffffffe);
@@ -455,11 +416,17 @@ class TestInt64 extends Test {
 		eq( a.add(make(0x1, 0)).toStr(), '4294967299');
 	}
 
-	public function testNeg()
-	{
+	public function testNeg() {
 		eq(Std.string(ofInt(-1)),Std.string(neg(ofInt(1))));
 		eq(Std.string(ofInt(-100)),Std.string(neg(ofInt(100))));
 		eq(Std.string(make(-2147483648, 1)), Std.string(neg(make(2147483647, -1)))); // -9223372036854775807 == neg(9223372036854775807)
 	}
-}
-*/
+
+	function int64eq( v : Int64, v2 : Int64, ?pos ) {
+		Test.count++;
+		if( v != v2 ) {
+			Test.report(Std.string(v)+" should be "+Std.string(v2),pos);
+			Test.success = false;
+		}
+	}
+}