浏览代码

[java/cs] Int64.compare fix. Closes #2317

Cauê Waneck 11 年之前
父节点
当前提交
b97fe46205
共有 3 个文件被更改,包括 14 次插入3 次删除
  1. 2 2
      std/cs/_std/haxe/Int64.hx
  2. 1 1
      std/java/_std/haxe/Int64.hx
  3. 11 0
      tests/unit/issues/Issue2317.hx

+ 2 - 2
std/cs/_std/haxe/Int64.hx

@@ -127,9 +127,9 @@ using haxe.Int64;
 
 
 	public static inline function compare( a : Int64, b : Int64 ) : Int
 	public static inline function compare( a : Int64, b : Int64 ) : Int
 	{
 	{
-		return cast (a.asNative() - b.asNative());
+		return (a.asNative() < b.asNative()) ? -1 : (a.asNative() > b.asNative()) ? 1 : 0;
 	}
 	}
-	
+
 	public static function ucompare( a : Int64, b : Int64 ) : Int
 	public static function ucompare( a : Int64, b : Int64 ) : Int
 	{
 	{
 		if (a.asNative() < 0.mkNative())
 		if (a.asNative() < 0.mkNative())

+ 1 - 1
std/java/_std/haxe/Int64.hx

@@ -127,7 +127,7 @@ private typedef NativeInt64 = Int;
 
 
 	public static inline function compare( a : Int64, b : Int64 ) : Int
 	public static inline function compare( a : Int64, b : Int64 ) : Int
 	{
 	{
-		return cast(a.asNative() - b.asNative(), Int);
+		return (a.asNative() < b.asNative()) ? -1 : (a.asNative() > b.asNative()) ? 1 : 0;
 	}
 	}
 
 
 	public static function ucompare( a : Int64, b : Int64 ) : Int
 	public static function ucompare( a : Int64, b : Int64 ) : Int

+ 11 - 0
tests/unit/issues/Issue2317.hx

@@ -0,0 +1,11 @@
+package unit.issues;
+import haxe.Int64;
+
+class Issue2317 extends unit.Test
+{
+	public function test()
+	{
+		var i = Int64.make(0xA, 0x828D97A8);
+		t( Int64.compare(i, Int64.ofInt(0) ) > 0 );
+	}
+}