Browse Source

[python] fix equality for abstracts with underlying array

frabbit 10 years ago
parent
commit
9f517bcd0e
2 changed files with 9 additions and 0 deletions
  1. 2 0
      genpy.ml
  2. 7 0
      tests/unit/src/unit/TestPython.hx

+ 2 - 0
genpy.ml

@@ -1255,6 +1255,8 @@ module Printer = struct
 					(* Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (fst ops) (print_expr pctx e2) *)
 					(* Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (fst ops) (print_expr pctx e2) *)
 				| TInst({cl_path = [],("list")},_), _ ->
 				| TInst({cl_path = [],("list")},_), _ ->
 					Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (fst ops) (print_expr pctx e2)
 					Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (fst ops) (print_expr pctx e2)
+				| x, _ when is_underlying_array x ->
+					Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (fst ops) (print_expr pctx e2)
 				| TDynamic _, TDynamic _ ->
 				| TDynamic _, TDynamic _ ->
 					Printf.sprintf "%s(%s,%s)" (third ops) (print_expr pctx e1) (print_expr pctx e2)
 					Printf.sprintf "%s(%s,%s)" (third ops) (print_expr pctx e1) (print_expr pctx e2)
 				| TDynamic _, x | x, TDynamic _ when is_list_or_anon x ->
 				| TDynamic _, x | x, TDynamic _ when is_list_or_anon x ->

+ 7 - 0
tests/unit/src/unit/TestPython.hx

@@ -423,4 +423,11 @@ class TestPython extends Test {
 		eq(t.length, 3);
 		eq(t.length, 3);
 	}
 	}
 
 
+	function testVectorEquality()
+	{
+        var v = new haxe.ds.Vector(1);
+        var v2 = v.copy();
+        eq(v == v2, false);
+    }
+
 }
 }