ソースを参照

[cs] WIP: overriding native properties

Cauê Waneck 11 年 前
コミット
df4964d0c0
2 ファイル変更33 行追加0 行削除
  1. 22 0
      tests/unit/TestCSharp.hx
  2. 11 0
      tests/unit/native_cs/src/haxe/test/MyClass.cs

+ 22 - 0
tests/unit/TestCSharp.hx

@@ -51,6 +51,10 @@ class TestCSharp extends Test
 
 	function testOverloadOverride()
 	{
+		var c = new haxe.test.MyClass();
+		eq(42,c.SomeProp);
+		eq(42,c.SomeProp2);
+
 		var c = new TestMyClass();
 		c.normalOverload(true);
 		t(c.boolCalled);
@@ -62,6 +66,9 @@ class TestCSharp extends Test
 		t(c.stringCalled);
 		c.normalOverload({});
 		t(c.dynamicCalled);
+		eq(21,c.SomeProp);
+		t(c.getCalled);
+		eq(21,c.SomeProp2);
 
 		var c = new TestMyClass("");
 		t(c.alternativeCtorCalled);
@@ -76,6 +83,9 @@ class TestCSharp extends Test
 		t(c.stringCalled);
 		b.normalOverload({});
 		t(c.dynamicCalled);
+		eq(21,c.SomeProp);
+		t(c.getCalled);
+		eq(21,c.SomeProp2);
 	}
 
 	function testEnum()
@@ -253,6 +263,7 @@ private class TestMyClass extends haxe.test.MyClass
 	public var int64Called:Bool;
 	public var stringCalled:Bool;
 	public var dynamicCalled:Bool;
+	public var getCalled:Bool;
 
 	@:overload override public function normalOverload(b:Bool):Void
 	{
@@ -278,4 +289,15 @@ private class TestMyClass extends haxe.test.MyClass
 	{
 		this.dynamicCalled = true;
 	}
+
+	@:overload override private function get_SomeProp():Int
+	{
+		getCalled = true;
+		return 21;
+	}
+
+	@:overload override private function get_SomeProp2():Int
+	{
+		return Std.int(super.get_SomeProp2() / 2);
+	}
 }

+ 11 - 0
tests/unit/native_cs/src/haxe/test/MyClass.cs

@@ -42,6 +42,17 @@ public class MyClass
 	{
 		
 	}
+
+	virtual public int SomeProp
+	{
+		get { return 42; }
+	}
+
+	virtual public int SomeProp2
+	{
+		get { return 42; }
+	}
+
 }
 
 }