Explorar el Código

even more As3 unit test fixes

Simon Krajewski hace 13 años
padre
commit
d5aa671bd7
Se han modificado 6 ficheros con 9 adiciones y 9 borrados
  1. 2 1
      codegen.ml
  2. 1 2
      genas3.ml
  3. 2 2
      tests/unit/MyClass.hx
  4. 1 1
      tests/unit/TestMeta.hx
  5. 2 2
      tests/unit/TestType.hx
  6. 1 1
      type.ml

+ 2 - 1
codegen.ml

@@ -1370,6 +1370,8 @@ let fix_override com c f fd =
 						{ e with eexpr = TBlock (v :: el) }
 				);
 			} in
+			(* as3 does not allow wider visibility, so the base method has to be made public *)
+			if Common.defined com "as3" && f.cf_public then f2.cf_public <- true;
 			let targs = List.map (fun(v,c) -> (v.v_name, Option.is_some c, v.v_type)) nargs in
 			let fde = (match f.cf_expr with None -> assert false | Some e -> e) in
 			{ f with cf_expr = Some { fde with eexpr = TFunction fd2 }; cf_type = TFun(targs,tret) }
@@ -1390,7 +1392,6 @@ let fix_overrides com t =
 			c.cl_ordered_fields <- List.filter (fun f ->
 				try
 					if find_field c f == f then raise Not_found;
-					print_endline ("Filter " ^ f.cf_name ^ " from class " ^ (s_type_path c.cl_path));
 					c.cl_fields <- PMap.remove f.cf_name c.cl_fields;
 					false;
 				with Not_found ->

+ 1 - 2
genas3.ml

@@ -664,8 +664,7 @@ and gen_expr ctx e =
 		handle_break();
 	| TObjectDecl fields ->
 		spr ctx "{ ";
-		let quote s = if Hashtbl.mem reserved s then "\"_" ^ s ^ "\"" else s in 
-		concat ctx ", " (fun (f,e) -> print ctx "%s : " (quote f); gen_value ctx e) fields;
+		concat ctx ", " (fun (f,e) -> print ctx "%s : " (s_ident f); gen_value ctx e) fields;
 		spr ctx "}"
 	| TFor (v,it,e) ->
 		let handle_break = handle_break ctx e in

+ 2 - 2
tests/unit/MyClass.hx

@@ -31,13 +31,13 @@ class MyParent {
 	function a() return 11
 	function b() return 20
 }
-#if !as3
+
 class MyChild1 extends MyParent {
 	public override function a() { return 12; }
 	override function b() return 21
 	function c() return 19
 }
-
+#if !as3
 class MyChild2 extends MyParent {
 	public function test1(mc1:MyChild1) return mc1.b()
 }

+ 1 - 1
tests/unit/TestMeta.hx

@@ -38,7 +38,7 @@ package unit;
 
 		var m = haxe.rtti.Meta.getFields(TestMeta);
 		eq( fields(m), "_" );
-		eq( fields(m._), "new" );
+		eq( fields(m._), #if as3 "_"+#end "new" );
 
 		var m = haxe.rtti.Meta.getStatics(TestMeta);
 		eq( fields(m), "foo" );

+ 2 - 2
tests/unit/TestType.hx

@@ -90,11 +90,11 @@ class TestType extends Test {
 	}
 	
 	function testWiderVisibility() {
-		// TODO: get this working for As3
-		#if !as3
 		var c = new MyClass.MyChild1();
 		eq(12, c.a());
 		
+		// TODO: this is also a problem
+		#if !as3
 		var mc2 = new MyChild2();
 		eq(21, mc2.test1(new MyChild1()));
 		#end

+ 1 - 1
type.ml

@@ -132,7 +132,7 @@ and texpr = {
 and tclass_field = {
 	cf_name : string;
 	mutable cf_type : t;
-	cf_public : bool;
+	mutable cf_public : bool;
 	cf_pos : pos;
 	mutable cf_doc : Ast.documentation;
 	mutable cf_meta : metadata;